Home

Matrix2D

Encapsulates 2D matrix operations

Operations

Add

Adds a constant to a matrix

function : public : 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 : public : native : Add(b:Float[,], x:Float) ~ Float[,]
Parameters
NameTypeDescription
bFloat[,]matrix
xFloatconstant to add

Return
TypeDescription
Float[,]updated matrix

Adds two matrices

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

Return
TypeDescription
Float[,]updated matrix

Concatenate

Concatenates two matrix

function : public : 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 : public : 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 : public : native : Divide(x:Float, b:Float[,]) ~ Float[,]
Parameters
NameTypeDescription
xFloatconstant to divide
bFloat[,]matrix

Return
TypeDescription
Float[,]updated matrix

Divides two matrices

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

Return
TypeDescription
Float[,]updated matrix

Dot

Calculates the dot product.

function : public : 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 : public : 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 : public : 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 : public : 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 : public : 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 : public : Random(rows:Int, cols:Int) ~ Float[,]
Parameters
NameTypeDescription
rowsIntrows
colsIntcolumns

Return
TypeDescription
Float[,]updated matrix

RandomNormal

Generates a random normal distribution of values

function : public : 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 : public : RandomNormal(mean:Float, variance:Float) ~ Float
Parameters
NameTypeDescription
meanFloatcenter of values
varianceFloatvariance in values

Return
TypeDescription
Floatupdated matrix

Sigmoid

Sigmoid 'S' function

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

Return
TypeDescription
FloatSigmoid value

Applies the Sigmoid function to all elements

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

Return
TypeDescription
Float[,]updated matrix

Split

Splits a matrix

function : public : 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 : public : 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 : public : native : Subtract(b:Float[,], x:Float) ~ Float[,]
Parameters
NameTypeDescription
bFloat[,]matrix
xFloatconstant to add

Return
TypeDescription
Float[,]updated matrix

Subtracts two matrices

function : public : 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 : public : native : Transpose(a:Float[,]) ~ Float[,]
Parameters
NameTypeDescription
aFloat[,]matrix

Return
TypeDescription
Float[,]transposed matrix