matrix
matrix copied to clipboard
Concatenate horizontally 2 matrix
Is there a method to concatenate horizontally or vertically 2 matrix ? I don't find anything, so I have to use that :
function concatMatrix(A, B, direction='H'){
var result = A;
if(direction == 'H'){
for(var i = 0; i < B.columns; i++){
result = result.addColumnVector(B.getColumn(i));
}
}
else{
for(var i = 0; i < B.rows; i++){
result = result.addRowVector(B.getRow(i));
}
}
return result;
}
No, there isn't. I think a matrix1.concat(matrix2)
makes sense, but that should return a new Matrix. It is a lot more efficient than dynamically changing the size of A.
oki thx