v2025.6.2
All Bundles

Matrix2D

2D matrix operations

Operations

Add

Adds a constant to a matrix

function : native : Add(c:Float, m:Float[,]) ~ Float[,]

Parameters

NameTypeDescription
cFloatconstant
mFloatmatrix

Return

TypeDescription
Floatupdated matrix

Add

Adds a constant to a matrix

function : native : Add(m:Float[,], c:Float) ~ Float[,]

Parameters

NameTypeDescription
mFloatmatrix
cFloatconstant

Return

TypeDescription
Floatupdated matrix

Add

Adds two matrices

function : native : Add(m1:Float[,], m2:Float[,]) ~ Float[,]

Parameters

NameTypeDescription
m1Floatleft matrix
m2Floatright matrix

Return

TypeDescription
Floatupdated matrix

AverageColumn

Average of the given column

function : native : AverageColumn(c:Int, matrix:Float[,]) ~ Float

Parameters

NameTypeDescription
cIntcolumn index
matrixFloatmatrix

Return

TypeDescription
Floataverage of the column

AverageRow

Average of the given row

function : native : AverageRow(r:Int, matrix:Float[,]) ~ Float

Parameters

NameTypeDescription
rIntrow index
matrixFloatmatrix

Return

TypeDescription
Floataverage of the row

Concatenate

Concatenates two matrix

function : Concatenate(a:Float[,], b:Float[,], is_row:Bool) ~ Float[,]

Parameters

NameTypeDescription
aFloatleft matrix
bFloatright matrix
is_rowBooltrue concatenate by rows, false for columns

Return

TypeDescription
Floatconcatenated matrix

Divide

Divides a constant by a matrix

function : native : Divide(c:Float, m:Float[,]) ~ Float[,]

Parameters

NameTypeDescription
cFloatconstant
mFloatmatrix

Return

TypeDescription
Floatupdated matrix

Divide

Divides a constant by a matrix

function : native : Divide(m:Float[,], c:Float) ~ Float[,]

Parameters

NameTypeDescription
mFloatmatrix
cFloatconstant

Return

TypeDescription
Floatupdated matrix

DotProduct

Calculates the dot product.

function : native : DotProduct(m1:Float[,], m2:Float[,]) ~ Float[,]

Parameters

NameTypeDescription
m1Floatleft matrix
m2Floatright matrix

Return

TypeDescription
Floatupdated 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
aFloatmatrix
bFloatmatrix

Return

TypeDescription
Floatupdated matrix

EuclideanDistance

Calculates the Euclidean Distance between the two vectors

function : native : EuclideanDistance(m1:Float[,]) ~ Float

Parameters

NameTypeDescription
m1Floatdata matrix

Return

TypeDescription
FloatEuclidean Distance between the two vectors

GetColumn

Get the column from a matrix

function : native : GetColumn(c:Int, matrix:Float[,]) ~ Float[]

Parameters

NameTypeDescription
cIntcolumn index
matrixFloatmatrix

Return

TypeDescription
Floatcolumn from matrix

GetRow

Get the row from a matrix

function : native : GetRow(r:Int, matrix:Float[,]) ~ Float[]

Parameters

NameTypeDescription
rIntrow index
matrixFloatmatrix

Return

TypeDescription
Floatrow from matrix

HadamardDivide

Divides two matrices using the Hadamard rule

function : native : HadamardDivide(m1:Float[,], m2:Float[,]) ~ Float[,]

Parameters

NameTypeDescription
m1Floatleft matrix
m2Floatright matrix

Return

TypeDescription
Floatupdated matrix

HadamardProduct

Multiplies two matrices using the Hadamard rule

function : native : HadamardProduct(m1:Float[,], m2:Float[,]) ~ Float[,]

Parameters

NameTypeDescription
m1Floatleft matrix
m2Floatright matrix

Return

TypeDescription
Floatupdated matrix

Identity

Creates an identity a matrix

function : native : Identity(s:Int) ~ Float[,]

Parameters

NameTypeDescription
sIntsize of matrix

Return

TypeDescription
Floatrow from matrix

Inverse

Inverse of matrix

function : native : Inverse(a:Float[,]) ~ Float[,]

Parameters

NameTypeDescription
aFloatmatrix

Return

TypeDescription
Floatinverted matrix

Multiple

Multiplies a constant by a matrix

function : native : Multiple(c:Float, m:Float[,]) ~ Float[,]

Parameters

NameTypeDescription
cFloatconstant
mFloatmatrix

Return

TypeDescription
Floatupdated matrix

Multiple

Multiplies a constant by a matrix

function : native : Multiple(m:Float[,], c:Float) ~ Float[,]

Parameters

NameTypeDescription
mFloatmatrix
cFloatconstant

Return

TypeDescription
Floatupdated 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
Floatupdated 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
Floatupdated matrix

RandomNormal

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

Sigmoid

Applies the Sigmoid function to all elements

function : native : Sigmoid(b:Float[,]) ~ Float[,]

Parameters

NameTypeDescription
bFloatmatrix

Return

TypeDescription
Floatupdated matrix

Solve

Solves a unit of equations

function : native : Solve(m1:Float[,], m2:Float[,]) ~ Float[]

Parameters

NameTypeDescription
m1Floatdata matrix
m2Floatresult matrix

Return

TypeDescription
Floatleast squares

Split

Splits a matrix

function : native : Split(b:Float[,], offset:Int, count:Int, is_row:Bool) ~ Float[,]

Parameters

NameTypeDescription
bFloatmatrix
offsetIntoffset index
countIntnumber of rows to split
is_rowBooltrue for row split, false for column

Return

TypeDescription
Floatcopied matrix

Subtract

Subtracts a constant from a matrix

function : native : Subtract(c:Float, m:Float[,]) ~ Float[,]

Parameters

NameTypeDescription
cFloatconstant
mFloatmatrix

Return

TypeDescription
Floatupdated matrix

Subtract

Adds a constant to a matrix

function : native : Subtract(m:Float[,], c:Float) ~ Float[,]

Parameters

NameTypeDescription
mFloatmatrix
cFloatconstant

Return

TypeDescription
Floatupdated matrix

Subtract

Subtracts two matrices

function : native : Subtract(m1:Float[,], m2:Float[,]) ~ Float[,]

Parameters

NameTypeDescription
m1Floatleft matrix
m2Floatright matrix

Return

TypeDescription
Floatupdated matrix

SumColumn

Sum of the given column

function : native : SumColumn(c:Int, matrix:Float[,]) ~ Float

Parameters

NameTypeDescription
cIntcolumn index
matrixFloatmatrix

Return

TypeDescription
Floatsum of the column

SumRow

Sum of the given row

function : native : SumRow(r:Int, matrix:Float[,]) ~ Float

Parameters

NameTypeDescription
rIntrow index
matrixFloatmatrix

Return

TypeDescription
Floatsum of the row

ToBool

Parsers a boolean value

function : ToBool(m:Float[,]) ~ Bool

Parameters

NameTypeDescription
mFloatmatrix

Return

TypeDescription
Boolboolean value

ToFloat

Parsers a decimal value

function : ToFloat(m:Float[,]) ~ Float

Parameters

NameTypeDescription
mFloatmatrix

Return

TypeDescription
Floatdecimal value

ToInt

Parsers an integer value

function : ToInt(m:Float[,]) ~ Int

Parameters

NameTypeDescription
mFloatmatrix

Return

TypeDescription
Intinteger value

Transpose

Transpose of matrix

function : native : Transpose(a:Float[,]) ~ Float[,]

Parameters

NameTypeDescription
aFloatmatrix

Return

TypeDescription
Floattransposed matrix