matrix icon indicating copy to clipboard operation
matrix copied to clipboard

Concatenate horizontally 2 matrix

Open jajoe opened this issue 7 years ago • 2 comments

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;
}

jajoe avatar Jul 17 '17 13:07 jajoe

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.

targos avatar Jul 17 '17 13:07 targos

oki thx

jajoe avatar Jul 17 '17 14:07 jajoe