All Bundles

Matrix2D

2D matrix operations

Operations

Add

Adds a constant to a matrix

function : native : Add(x:Float, b:Float[,]) ~ Float[,]
Parameters
NameTypeDescription
xFloatconstant to add
bFloat[,]matrix

Return
TypeDescription
Float[,]updated matrix

Adds a constant to a matrix

function : native : Add(b:Float[,], x:Float) ~ Float[,]
Parameters
NameTypeDescription
bFloat[,]matrix
xFloatconstant to add

Return
TypeDescription
Float[,]updated matrix

Adds two matrices

function : native : Add(a:Float[,], b:Float[,]) ~ Float[,]
Parameters
NameTypeDescription
aFloat[,]matrix
bFloat[,]matrix

Return
TypeDescription
Float[,]updated matrix

Concatenate

Concatenates two matrix

function : Concatenate(a:Float[,], b:Float[,], is_row:Bool) ~ Float[,]
Parameters
NameTypeDescription
aFloat[,]left matrix
bFloat[,]right matrix
is_rowBooltrue concatenate by rows, false for columns

Return
TypeDescription
Float[,]concatenated matrix

Divide

Divides a constant by a matrix

function : native : Divide(b:Float[,], x:Float) ~ Float[,]
Parameters
NameTypeDescription
bFloat[,]matrix
xFloatconstant to divide

Return
TypeDescription
Float[,]updated matrix

Divides a constant by a matrix

function : native : Divide(x:Float, b:Float[,]) ~ Float[,]
Parameters
NameTypeDescription
xFloatconstant to divide
bFloat[,]matrix

Return
TypeDescription
Float[,]updated matrix

Divides two matrices

function : native : Divide(a:Float[,], b:Float[,]) ~ Float[,]
Parameters
NameTypeDescription
aFloat[,]matrix
bFloat[,]matrix

Return
TypeDescription
Float[,]updated matrix

Dot

Calculates the dot product.

function : native : Dot(a:Float[,], b:Float[,]) ~ Float[,]
Parameters
NameTypeDescription
aFloat[,]matrix
bFloat[,]matrix

Return
TypeDescription
Float[,]updated matrix

DotSigmoid

Calculates the Dot Product applying while applying the Sigmoid function to all elements

function : native : DotSigmoid(a:Float[,], b:Float[,]) ~ Float[,]
Parameters
NameTypeDescription
aFloat[,]matrix
bFloat[,]matrix

Return
TypeDescription
Float[,]updated matrix

Multiple

Multiplies a constant by a matrix

function : native : Multiple(x:Float, b:Float[,]) ~ Float[,]
Parameters
NameTypeDescription
xFloatconstant to multiple
bFloat[,]matrix

Return
TypeDescription
Float[,]updated matrix

Multiplies a constant by a matrix

function : native : Multiple(b:Float[,], x:Float) ~ Float[,]
Parameters
NameTypeDescription
bFloat[,]matrix
xFloatconstant to multiple

Return
TypeDescription
Float[,]updated matrix

Multiplies two matrices using the Hadamard rule

function : native : Multiple(a:Float[,], b:Float[,]) ~ Float[,]
Parameters
NameTypeDescription
aFloat[,]matrix
bFloat[,]matrix

Return
TypeDescription
Float[,]updated matrix

Random

Generates a random 2D array of values from 0.0 to 1.0

function : Random(rows:Int, cols:Int) ~ Float[,]
Parameters
NameTypeDescription
rowsIntrows
colsIntcolumns

Return
TypeDescription
Float[,]updated matrix

RandomNormal

Generates a random normal distribution of values

function : RandomNormal(mean:Float, variance:Float, rows:Int, cols:Int) ~ Float[,]
Parameters
NameTypeDescription
meanFloatcenter of values
varianceFloatvariance in values
rowsIntrows
colsIntcolumns

Return
TypeDescription
Float[,]updated matrix

Generates a random normal value

function : RandomNormal(mean:Float, variance:Float) ~ Float
Parameters
NameTypeDescription
meanFloatcenter of values
varianceFloatvariance in values

Return
TypeDescription
Floatupdated matrix

Sigmoid

Sigmoid 'S' function

function : native : Sigmoid(x:Float) ~ Float
Parameters
NameTypeDescription
xFloatinput value

Return
TypeDescription
FloatSigmoid value

Applies the Sigmoid function to all elements

function : native : Sigmoid(b:Float[,]) ~ Float[,]
Parameters
NameTypeDescription
bFloat[,]matrix

Return
TypeDescription
Float[,]updated matrix

Split

Splits a matrix

function : native : Split(b:Float[,], offset:Int, count:Int, is_row:Bool) ~ Float[,]
Parameters
NameTypeDescription
bFloat[,]matrix
offsetIntoffset index
countIntnumber of rows to split
is_rowBooltrue for row split, false for column

Return
TypeDescription
Float[,]copied matrix

Subtract

Subtracts a constant from a matrix

function : native : Subtract(x:Float, b:Float[,]) ~ Float[,]
Parameters
NameTypeDescription
xFloatconstant to subtract
bFloat[,]matrix

Return
TypeDescription
Float[,]updated matrix

Adds a constant to a matrix

function : native : Subtract(b:Float[,], x:Float) ~ Float[,]
Parameters
NameTypeDescription
bFloat[,]matrix
xFloatconstant to add

Return
TypeDescription
Float[,]updated matrix

Subtracts two matrices

function : native : Subtract(a:Float[,], b:Float[,]) ~ Float[,]
Parameters
NameTypeDescription
aFloat[,]matrix
bFloat[,]matrix

Return
TypeDescription
Float[,]updated matrix

Transpose

Transpose a matrix swapping rows and columns.

function : native : Transpose(a:Float[,]) ~ Float[,]
Parameters
NameTypeDescription
aFloat[,]matrix

Return
TypeDescription
Float[,]transposed matrix