matrix.sc
matrix.sc
Module with functions for manipulating matrices and vectors.
Functions:
colSums
Function for summarizing the columns of a matrix.
Detailed Description
D - all protection domains |
Supported types - bool / uint8 / uint16 / uint32 / uint / int8 / int16 / int32 / int / float32 / float64 |
Parameters
mat |
- a matrix of supported type |
returns a vector with the sums of each column in the input matrix |
None |
Function Overloads
D uint colSums(D bool[[2]] mat)
D uint8 colSums(D uint8[[2]] mat)
D uint16 colSums(D uint16[[2]] mat)
D uint32 colSums(D uint32[[2]] mat)
D uint colSums(D uint[[2]] mat)
D int8 colSums(D int8[[2]] mat)
D int16 colSums(D int16[[2]] mat)
D int32 colSums(D int32[[2]] mat)
D int colSums(D int[[2]] mat)
D float32 colSums(D float32[[2]] mat)
D float64 colSums(D float64[[2]] mat)
determinant
Function for finding the determinant of a matrix.
leftTransposedMultiplication
Function for multiplying X^T by X.
Detailed Description
D - any protection domain |
Supported types uint8 / uint16 / uint32 / uint / int8 / int16 / int32 / int / float32 / float64 |
Parameters
x |
- matrix |
returns transposed x multiplied by x |
None |
Function Overloads
D uint8 leftTransposedMultiplication(D uint8[[2]] x)
D uint16 leftTransposedMultiplication(D uint16[[2]] x)
D uint32 leftTransposedMultiplication(D uint32[[2]] x)
D uint64 leftTransposedMultiplication(D uint64[[2]] x)
D int8 leftTransposedMultiplication(D int8[[2]] x)
D int16 leftTransposedMultiplication(D int16[[2]] x)
D int32 leftTransposedMultiplication(D int32[[2]] x)
D int64 leftTransposedMultiplication(D int64[[2]] x)
D float32 leftTransposedMultiplication(D float32[[2]] x)
D float64 leftTransposedMultiplication(D float64[[2]] x)
rightTransposedMultiplication
Function for multiplying X by X^T.
Detailed Description
D - any protection domain |
Supported types uint8 / uint16 / uint32 / uint / int8 / int16 / int32 / int / float32 / float64 |
Parameters
x |
- matrix |
returns x multiplied by transposed x |
None |
Function Overloads
D uint8 rightTransposedMultiplication(D uint8[[2]] x)
D uint16 rightTransposedMultiplication(D uint16[[2]] x)
D uint32 rightTransposedMultiplication(D uint32[[2]] x)
D uint64 rightTransposedMultiplication(D uint64[[2]] x)
D int8 rightTransposedMultiplication(D int8[[2]] x)
D int16 rightTransposedMultiplication(D int16[[2]] x)
D int32 rightTransposedMultiplication(D int32[[2]] x)
D int64 rightTransposedMultiplication(D int64[[2]] x)
D float32 rightTransposedMultiplication(D float32[[2]] x)
D float64 rightTransposedMultiplication(D float64[[2]] x)
rowSums
Function for summing the rows of a matrix.
Detailed Description
D - all protection domains |
Supported types - bool / uint8 / uint16 / uint32 / uint / int8 / int16 / int32 / int / float32 / float64 |
Parameters
mat |
- a matrix of supported type |
returns a vector with the sums of each row in the input matrix |
None |
Function Overloads
D uint rowSums(D bool[[2]] mat)
D uint8 rowSums(D uint8[[2]] mat)
D uint16 rowSums(D uint16[[2]] mat)
D uint32 rowSums(D uint32[[2]] mat)
D uint rowSums(D uint[[2]] mat)
D int8 rowSums(D int8[[2]] mat)
D int16 rowSums(D int16[[2]] mat)
D int32 rowSums(D int32[[2]] mat)
D int rowSums(D int[[2]] mat)
D float32 rowSums(D float32[[2]] mat)
D float64 rowSums(D float64[[2]] mat)
unitMatrix
Function for creating a unit matrix.
crossProduct
Function for finding the cross product of two vectors/matrices.
Functions:
D - all protection domains |
Supported types - int8 / int16 / int32 / int / float32 / float64 |
crossProduct[[1]]
Function for finding the cross product of two vectors.
Detailed Description
D - all protection domains |
Supported types - int8 / int16 / int32 / int / float32 / float64 |
Parameters
x, y |
- vectors of supported type |
returns a vector with the cross product of the two input vectors |
None |
Function Overloads
D int8 crossProduct(D int8[[1]] x, D int8[[1]] y)
D int16 crossProduct(D int16[[1]] x, D int16[[1]] y)
D int32 crossProduct(D int32[[1]] x, D int32[[1]] y)
D int crossProduct(D int[[1]] x, D int[[1]] y)
D float32 crossProduct(D float32[[1]] x, D float32[[1]] y)
D float64 crossProduct(D float64[[1]] x, D float64[[1]] y)
crossProduct[[2]]
Function for finding the cross product of two matrices.
Detailed Description
D - all protection domains |
Supported types - int8 / int16 / int32 / int / float32 / float64 |
Parameters
x, y |
- matrices of supported type |
returns a matrix with the cross product of each row of the two input matrices |
None |
Function Overloads
D int8 crossProduct(D int8[[2]] x, D int8[[2]] y)
D int16 crossProduct(D int16[[2]] x, D int16[[2]] y)
D int32 crossProduct(D int32[[2]] x, D int32[[2]] y)
D int crossProduct(D int[[2]] x, D int[[2]] y)
D float32 crossProduct(D float32[[2]] x, D float32[[2]] y)
D float64 crossProduct(D float64[[2]] x, D float64[[2]] y)
diagMatrixMultiplication
Function for multiplying two diagonal matrices.
Functions:
D - any protection domain |
Supported types - uint8 / uint16 / uint32 / uint / int8 / int16 / int32 / int / float32 / float64 |
diagMatrixMultiplication[[2]]
Function for multiplying two diagonal matrices.
Detailed Description
D - any protection domain |
Supported types - uint8 / uint16 / uint32 / uint / int8 / int16 / int32 / int / float32 / float64 |
NB! This matrix multiplication is very conditional. Before using, make sure that your matrices are in the right format. y must be diagonal |
Parameters
x, y |
- 2-dimensional matrices of supported type and shape |
returns the matrix of x*y |
None |
Function Overloads
D uint8 diagMatrixMultiplication(D uint8[[2]] x, D uint8[[2]] y)
D uint16 diagMatrixMultiplication(D uint16[[2]] x, D uint16[[2]] y)
D uint32 diagMatrixMultiplication(D uint32[[2]] x, D uint32[[2]] y)
D uint diagMatrixMultiplication(D uint[[2]] x, D uint[[2]] y)
D int8 diagMatrixMultiplication(D int8[[2]] x, D int8[[2]] y)
D int16 diagMatrixMultiplication(D int16[[2]] x, D int16[[2]] y)
D int32 diagMatrixMultiplication(D int32[[2]] x, D int32[[2]] y)
D int diagMatrixMultiplication(D int[[2]] x, D int[[2]] y)
D float32 diagMatrixMultiplication(D float32[[2]] x, D float32[[2]] y)
D float64 diagMatrixMultiplication(D float64[[2]] x, D float64[[2]] y)
diagMatrixMultiplication[[3]]
Function for multiplying two diagonal matrices.
Detailed Description
D - any protection domain |
Supported types - uint8 / uint16 / uint32 / uint / int8 / int16 / int32 / int / float32 / float64 |
NB! This matrix multiplication is very conditional. Before using, make sure that your matrices are in the right format. y must be diagonal |
Parameters
x, y |
- 3-dimensional matrices of supported type and shape |
We multiply across the last two dimensions and return a vector of product matrices |
None |
Function Overloads
D uint8 diagMatrixMultiplication(D uint8[[3]] x, D uint8[[3]] y)
D uint16 diagMatrixMultiplication(D uint16[[3]] x, D uint16[[3]] y)
D uint32 diagMatrixMultiplication(D uint32[[3]] x, D uint32[[3]] y)
D uint diagMatrixMultiplication(D uint[[3]] x, D uint[[3]] y)
D int8 diagMatrixMultiplication(D int8[[3]] x, D int8[[3]] y)
D int16 diagMatrixMultiplication(D int16[[3]] x, D int16[[3]] y)
D int32 diagMatrixMultiplication(D int32[[3]] x, D int32[[3]] y)
D int diagMatrixMultiplication(D int[[3]] x, D int[[3]] y)
D float32 diagMatrixMultiplication(D float32[[3]] x, D float32[[3]] y)
D float64 diagMatrixMultiplication(D float64[[3]] x, D float64[[3]] y)
dotProduct
Function for finding the dot product of two vectors/matrices.
Functions:
D - all protection domains |
Supported types - uint8 / uint16 / uint32 / uint / int8 / int16 / int32 / int / float32 / float64 |
dotProduct[[1]]
Function for finding the dot product of two vectors.
Detailed Description
D - all protection domains |
Supported types - uint8 / uint16 / uint32 / uint / int8 / int16 / int32 / int / float32 / float64 |
Parameters
x, y |
- input vectors |
returns a scalar with the dot product of the two input vectors |
None |
Function Overloads
D uint8 dotProduct(D uint8[[1]] x, D uint8[[1]] y)
D uint16 dotProduct(D uint16[[1]] x, D uint16[[1]] y)
D uint32 dotProduct(D uint32[[1]] x, D uint32[[1]] y)
D uint dotProduct(D uint[[1]] x, D uint[[1]] y)
D int8 dotProduct(D int8[[1]] x, D int8[[1]] y)
D int16 dotProduct(D int16[[1]] x, D int16[[1]] y)
D int32 dotProduct(D int32[[1]] x, D int32[[1]] y)
D int dotProduct(D int[[1]] x, D int[[1]] y)
D float32 dotProduct(D float32[[1]] x, D float32[[1]] y)
D float64 dotProduct(D float64[[1]] x, D float64[[1]] y)
dotProduct[[2]]
Function for finding the dot product of two matrices.
Detailed Description
D - all protection domains |
Supported types - uint8 / uint16 / uint32 / uint / int8 / int16 / int32 / int / float32 / float64 |
Parameters
x, y |
- matrices of supported type |
returns a vector with the dot product of each row of the two input matrices |
None |
Function Overloads
D uint8 dotProduct(D uint8[[2]] x, D uint8[[2]] y)
D uint16 dotProduct(D uint16[[2]] x, D uint16[[2]] y)
D uint32 dotProduct(D uint32[[2]] x, D uint32[[2]] y)
D uint dotProduct(D uint[[2]] x, D uint[[2]] y)
D int8 dotProduct(D int8[[2]] x, D int8[[2]] y)
D int16 dotProduct(D int16[[2]] x, D int16[[2]] y)
D int32 dotProduct(D int32[[2]] x, D int32[[2]] y)
D int dotProduct(D int[[2]] x, D int[[2]] y)
D float32 dotProduct(D float32[[2]] x, D float32[[2]] y)
D float64 dotProduct(D float64[[2]] x, D float64[[2]] y)
matrixMultiplication
Function for multiplying two matrices.
Functions:
D - any protection domain |
Supported types - uint8 / uint16 / uint32 / uint / int8 / int16 / int32 / int / float32 / float64 |
matrixMultiplication[[2]]
Function for multiplying two matrices.
Detailed Description
D - all protection domains |
Supported types - uint8 / uint16 / uint32 / uint / int8 / int16 / int32 / int / float32 / float64 |
no. of columns of x must equal no. of rows of y |
Parameters
x, y |
- matrices of supported type and shape |
returns the matrix of x*y |
None |
Function Overloads
D uint8 matrixMultiplication(D uint8[[2]] x, D uint8[[2]] y)
D uint16 matrixMultiplication(D uint16[[2]] x, D uint16[[2]] y)
D uint32 matrixMultiplication(D uint32[[2]] x, D uint32[[2]] y)
D uint matrixMultiplication(D uint[[2]] x, D uint[[2]] y)
D int8 matrixMultiplication(D int8[[2]] x, D int8[[2]] y)
D int16 matrixMultiplication(D int16[[2]] x, D int16[[2]] y)
D int32 matrixMultiplication(D int32[[2]] x, D int32[[2]] y)
D int matrixMultiplication(D int[[2]] x, D int[[2]] y)
D float32 matrixMultiplication(D float32[[2]] x, D float32[[2]] y)
D float64 matrixMultiplication(D float64[[2]] x, D float64[[2]] y)
matrixMultiplication[[3]]
Function for multiplying two matrices.
Detailed Description
D - any protection domain |
Supported types - uint8 / uint16 / uint32 / uint / int8 / int16 / int32 / int / float32 / float64 |
no. of columns of x must equal no. of rows of y. Also, there should be an equal no. of matrices in both structures |
Parameters
x, y |
- 3-dimensional matrices of supported type and shape |
We multiply across the last two dimensions and return a vector of product matrices |
None |
Function Overloads
D uint8 matrixMultiplication(D uint8[[3]] x, D uint8[[3]] y)
D uint16 matrixMultiplication(D uint16[[3]] x, D uint16[[3]] y)
D uint32 matrixMultiplication(D uint32[[3]] x, D uint32[[3]] y)
D uint matrixMultiplication(D uint[[3]] x, D uint[[3]] y)
D int8 matrixMultiplication(D int8[[3]] x, D int8[[3]] y)
D int16 matrixMultiplication(D int16[[3]] x, D int16[[3]] y)
D int32 matrixMultiplication(D int32[[3]] x, D int32[[3]] y)
D int matrixMultiplication(D int[[3]] x, D int[[3]] y)
D float32 matrixMultiplication(D float32[[3]] x, D float32[[3]] y)
D float64 matrixMultiplication(D float64[[3]] x, D float64[[3]] y)