hadamardProductToEachColumn static method
Return copy of matrix
where each column where multiplied by column
with Hadamard product
Implementation
static Matrix hadamardProductToEachColumn(Matrix matrix, Matrix column) {
if (column.m == 1 && matrix.n == column.n) {
Matrix resultMatrix = Matrix.zero(n: matrix.n, m: matrix.m);
for (int i = 0; i < resultMatrix.n; i += 1) {
for (int j = 0; j < resultMatrix.m; j += 1) {
resultMatrix[i][j] = matrix[i][j] * column[i][0];
}
}
return resultMatrix;
} else {
throw Exception('Dimensions error: A.shape != B.shape');
}
}