adelie.adelie_core.matrix.MatrixNaiveConvexReluDense32F#
- class adelie.adelie_core.matrix.MatrixNaiveConvexReluDense32F#
Core matrix class for naive convex relu matrix with dense underlying.
Methods
__init__
(self, mat, mask, n_threads)bmul
(self, arg0, arg1, arg2, arg3, arg4)Computes a column block matrix-vector multiplication.
bmul_safe
(self, arg0, arg1, arg2, arg3, arg4)Computes a column block matrix-vector multiplication.
btmul
(self, arg0, arg1, arg2, arg3)Computes a column block matrix transpose-vector multiplication increment.
cmul
(self, arg0, arg1, arg2)Computes a column vector-vector multiplication.
cmul_safe
(self, arg0, arg1, arg2)Computes a column vector-vector multiplication.
cols
(self)Returns the number of columns.
cov
(self, arg0, arg1, arg2, arg3)Computes a weighted covariance matrix.
ctmul
(self, arg0, arg1, arg2)Computes a column vector-scalar multiplication increment.
mean
(self, arg0, arg1)Computes the implied column means.
mul
(self, arg0, arg1, arg2)Computes a matrix-vector multiplication.
rows
(self)Returns the number of rows.
sp_tmul
(self, arg0, arg1)Computes a matrix transpose-sparse matrix multiplication.
sq_mul
(self, arg0, arg1)Computes a squared matrix-vector multiplication.
var
(self, arg0, arg1, arg2)Computes the implied column variances.
Attributes
Number of dimensions.
Shape of the matrix.
- __init__(self: adelie.adelie_core.matrix.MatrixNaiveConvexReluDense32F, mat: numpy.ndarray[numpy.float32[m, n], flags.f_contiguous], mask: numpy.ndarray[bool[m, n], flags.f_contiguous], n_threads: int) None #
- bmul(self: adelie.adelie_core.matrix.MatrixNaiveBase32, arg0: int, arg1: int, arg2: numpy.ndarray[numpy.float32[1, n]], arg3: numpy.ndarray[numpy.float32[1, n]], arg4: numpy.ndarray[numpy.float32[1, n], flags.writeable]) None #
Computes a column block matrix-vector multiplication.
Computes the matrix-vector multiplication
(v * w).T @ X[:, j:j+q]
.Warning
This function is not thread-safe!
- Parameters:
- jint
Column index.
- qint
Number of columns.
- v(n,) ndarray
Vector to multiply with the block matrix.
- w(n,) ndarray
Vector of weights.
- out(q,) ndarray
Vector to store in-place the result.
- bmul_safe(self: adelie.adelie_core.matrix.MatrixNaiveBase32, arg0: int, arg1: int, arg2: numpy.ndarray[numpy.float32[1, n]], arg3: numpy.ndarray[numpy.float32[1, n]], arg4: numpy.ndarray[numpy.float32[1, n], flags.writeable]) None #
Computes a column block matrix-vector multiplication.
Thread-safe version of
bmul()
.- Parameters:
- jint
Column index.
- qint
Number of columns.
- v(n,) ndarray
Vector to multiply with the block matrix.
- w(n,) ndarray
Vector of weights.
- out(q,) ndarray
Vector to store in-place the result.
- btmul(self: adelie.adelie_core.matrix.MatrixNaiveBase32, arg0: int, arg1: int, arg2: numpy.ndarray[numpy.float32[1, n]], arg3: numpy.ndarray[numpy.float32[1, n], flags.writeable]) None #
Computes a column block matrix transpose-vector multiplication increment.
Computes the matrix-vector multiplication
v.T @ X[:, j:j+q].T
. The result is incremented into the output vector.Warning
This function is not thread-safe!
- Parameters:
- jint
Column index.
- qint
Number of columns.
- v(q,) ndarray
Vector to multiply with the block matrix.
- out(n,) ndarray
Vector to increment in-place the result.
- cmul(self: adelie.adelie_core.matrix.MatrixNaiveBase32, arg0: int, arg1: numpy.ndarray[numpy.float32[1, n]], arg2: numpy.ndarray[numpy.float32[1, n]]) float #
Computes a column vector-vector multiplication.
Computes the dot-product
(v * w).T @ X[:,j]
.Warning
This function is not thread-safe!
- Parameters:
- jint
Column index.
- v(n,) ndarray
Vector to dot product with the
j
th column.- w(n,) ndarray
Vector of weights.
- Returns:
- dotfloat
Column vector-vector multiplication.
- cmul_safe(self: adelie.adelie_core.matrix.MatrixNaiveBase32, arg0: int, arg1: numpy.ndarray[numpy.float32[1, n]], arg2: numpy.ndarray[numpy.float32[1, n]]) float #
Computes a column vector-vector multiplication.
Thread-safe version of
cmul()
.- Parameters:
- jint
Column index.
- v(n,) ndarray
Vector to dot product with the
j
th column.- w(n,) ndarray
Vector of weights.
- Returns:
- dotfloat
Column vector-vector multiplication.
- cols(self: adelie.adelie_core.matrix.MatrixNaiveBase32) int #
Returns the number of columns.
- Returns:
- colsint
Number of columns.
- cov(self: adelie.adelie_core.matrix.MatrixNaiveBase32, arg0: int, arg1: int, arg2: numpy.ndarray[numpy.float32[1, n]], arg3: numpy.ndarray[numpy.float32[m, n], flags.writeable, flags.f_contiguous]) None #
Computes a weighted covariance matrix.
Computes the weighted covariance matrix
X[:, j:j+q].T @ W @ X[:, j:j+q]
.This function is thread-safe.
Note
Although the name is “covariance”, we do not center the columns of
X
!- Parameters:
- jint
Column index.
- qint
Number of columns.
- sqrt_weights(n,) ndarray
Square-root of the weights.
- out(q, q) ndarray
Matrix to store in-place the result.
- ctmul(self: adelie.adelie_core.matrix.MatrixNaiveBase32, arg0: int, arg1: float, arg2: numpy.ndarray[numpy.float32[1, n], flags.writeable]) None #
Computes a column vector-scalar multiplication increment.
Computes the vector-scalar multiplication
v * X[:,j]
. The result is incremented into the output vector.Warning
This function is not thread-safe!
- Parameters:
- jint
Column index.
- vfloat
Scalar to multiply with the
j
th column.- out(n,) ndarray
Vector to increment in-place the result.
- mean(self: adelie.adelie_core.matrix.MatrixNaiveBase32, arg0: numpy.ndarray[numpy.float32[1, n]], arg1: numpy.ndarray[numpy.float32[1, n], flags.writeable]) None #
Computes the implied column means.
The default implied column means are given by
w.T @ X
. Unless stated otherwise, this function will compute the default version.- Parameters:
- weights(n,) ndarray
Vector of weights.
- out(p,) ndarray
Vector to store in-place the result.
- mul(self: adelie.adelie_core.matrix.MatrixNaiveBase32, arg0: numpy.ndarray[numpy.float32[1, n]], arg1: numpy.ndarray[numpy.float32[1, n]], arg2: numpy.ndarray[numpy.float32[1, n], flags.writeable]) None #
Computes a matrix-vector multiplication.
Computes the matrix-vector multiplication
(v * w).T @ X
.- Parameters:
- v(n,) ndarray
Vector to multiply with the matrix.
- w(n,) ndarray
Vector of weights.
- out(p,) ndarray
Vector to store in-place the result.
- rows(self: adelie.adelie_core.matrix.MatrixNaiveBase32) int #
Returns the number of rows.
- Returns:
- rowsint
Number of rows.
- sp_tmul(self: adelie.adelie_core.matrix.MatrixNaiveBase32, arg0: scipy.sparse.csr_matrix[numpy.float32], arg1: numpy.ndarray[numpy.float32[m, n], flags.writeable, flags.c_contiguous]) None #
Computes a matrix transpose-sparse matrix multiplication.
Computes the matrix transpose-sparse matrix multiplication
v.T @ X.T
.- Parameters:
- v(L, p) csr_matrix
Sparse matrix to multiply with the matrix.
- out(L, n) ndarray
Matrix to store in-place the result.
- sq_mul(self: adelie.adelie_core.matrix.MatrixNaiveBase32, arg0: numpy.ndarray[numpy.float32[1, n]], arg1: numpy.ndarray[numpy.float32[1, n], flags.writeable]) None #
Computes a squared matrix-vector multiplication.
Computes the squared matrix-vector multiplication
w.T @ X ** 2
.- Parameters:
- weights(n,) ndarray
Vector of weights.
- out(p,) ndarray
Vector to store in-place the result.
- var(self: adelie.adelie_core.matrix.MatrixNaiveBase32, arg0: numpy.ndarray[numpy.float32[1, n]], arg1: numpy.ndarray[numpy.float32[1, n]], arg2: numpy.ndarray[numpy.float32[1, n], flags.writeable]) None #
Computes the implied column variances.
The default implied column variances are given by
w.T @ (X-c[None])**2
. Unless stated otherwise, this function will compute the default version.- Parameters:
- centers(p,) ndarray
Vector of centers.
- weights(n,) ndarray
Vector of weights.
- out(p,) ndarray
Vector to store in-place the result.
- ndim#
Number of dimensions. It is always
2
.
- shape#
Shape of the matrix.