rowBind static method
Return Matrix created as binded a
and b
by rows.
Elements of a
set first, and elements of b
second
Example:
final a = Matrix.row([0,0,0]);
final b = Matrix.row([1,1,1]);
final matrix = MatrixOperation.rowBind(a, b);
print(matrix);
// Output:
// matrix 2тип3
// [[0.0, 0.0, 0.0]
// [1.0, 1.0, 1.0]]
Throw an exception
if dimension's condition not met
Implementation
static Matrix rowBind(Matrix a, Matrix b) {
if (a.m == b.m) {
var resultMatrix = Matrix.zero(n: a.n + b.n, m: a.m);
for (int i = 0; i < resultMatrix.n; i += 1) {
for (int j = 0; j < resultMatrix.m; j += 1) {
resultMatrix[i][j] = i < a.n ? a[i][j] : b[i - a.n][j];
}
}
return resultMatrix;
} else {
throw Exception('Dimensions error: A.n != B.n');
}
}