Skip to content

Initialization

Constructors for new NDArrays. Default floating-point type is Float32.

zeros

cuNumeric.zeros Function
julia
cuNumeric.zeros([T=Float32,] dims::Int...)
cuNumeric.zeros([T=Float32,] dims::Tuple)

Create an NDArray with element type T, of all zeros with size specified by dims. The default type is Float32 if not specified.

Examples

julia
cuNumeric.zeros(2, 2)
cuNumeric.zeros(Float64, 3)
cuNumeric.zeros(Int32, (2,3))
source

ones

cuNumeric.ones Function
julia
cuNumeric.ones([T=Float32,] dims::Int...)
cuNumeric.ones([T=Float32,] dims::Tuple)

Create an NDArray with element type T, of all zeros with size specified by dims. The default type is Float32 if not specified.

Examples

julia
cuNumeric.ones(2, 2)
cuNumeric.ones(Float32, 3)
cuNumeric.ones(Int32, (2, 3))
source

fill

cuNumeric.fill Function
julia
cuNumeric.fill(val::T, dims::Dims)
cuNumeric.fill(val::T, dims::Int...)

Create an NDArray filled with the scalar value val, with the shape specified by dims.

Examples

julia
cuNumeric.fill(7.5, (2, 3))
cuNumeric.fill(0, 4)
source

trues

cuNumeric.trues Function
julia
cuNumeric.trues(dims::Tuple, val)
cuNumeric.trues(dim::Int, val)
cuNumeric.trues(dims::Int...)

Create an NDArray filled with the true, with the shape specified by dims.

Examples

julia
cuNumeric.trues(2, 3)
source

falses

cuNumeric.falses Function
julia
cuNumeric.falses(dims::Tuple, val)
cuNumeric.falses(dim::Int, val)
cuNumeric.falses(dims::Int...)

Create an NDArray filled with the false, with the shape specified by dims.

Examples

julia
cuNumeric.falses(2, 3)
source

eye

cuNumeric.eye Function
julia
cuNumeric.eye([T=Float32,] rows::Int)

Create a 2D identity NDArray of size rows × rows with element type T. The default type is Float32 if not specified.

source

rand

cuNumeric.rand Function
julia
cuNumeric.rand([T=Float32,] dims::Int...)
cuNumeric.rand([T=Float32,] dims::Tuple)

Create a new NDArray filled with uniform random values.

The backend currently supports only Float64 draws. Other floating types are converted automatically.

Examples

julia
cuNumeric.rand(2, 2)
cuNumeric.rand((4, 1))
A = cuNumeric.zeros(Float64, 2, 2); cuNumeric.rand!(A)
source

rand!

Random.rand! Method
julia
cuNumeric.rand!(arr::NDArray{Float64})

Fill arr in-place with uniform random Float64 values.

source

The backend currently draws Float64 uniforms. cuNumeric.rand(Float32, dims...) converts for you. rand! on NDArray currently requires Float64 storage.