Well, the title says it all. I am looking for a way to add rows or columns to an object created with
mm = math.matrix([[0, 1], [2, 3], [4, 5]]);
// can we do something like
mm.push([0,1]);
I refer to the mathjs library here.
Well, the title says it all. I am looking for a way to add rows or columns to an object created with
mm = math.matrix([[0, 1], [2, 3], [4, 5]]);
// can we do something like
mm.push([0,1]);
I refer to the mathjs library here.
i also checked their docs..they don't have direct push or any other functionality to achieve this.we have try our self in different manner to achieve that functionality .
1) convert to array and pass to matrix again
2) or add ur own method for matrix object
math.push=function(e){
// ur own code to implement the push
}
There is no push
like function available. You can of course open a request for this in the issues section of the project.
The solution that comes closest is using the concat
function:
mm = math.matrix([[0, 1], [2, 3], [4, 5]]);
mm = math.concat(mm, [[0,1]], 0);
// mm now contains: [[0, 1], [2, 3], [4, 5], [0, 1]]
The last number in the concat
function specifies the dimension where to add the new data.