嗯,标题说明了一切。我正在寻找一种方法来添加行或列的对象创建的
mm = math.matrix([[0, 1], [2, 3], [4, 5]]);
// can we do something like
mm.push([0,1]);
这里我指的是mathjs库。
发布于 2015-09-17 21:59:32
我还检查了他们docs..they没有直接推送或任何其他功能来实现this.we已经尝试了我们自己的不同方式来实现这些功能。
1)转换为数组,并再次传递给矩阵
2)或为矩阵对象添加自己的方法
math.push=function(e){
// ur own code to implement the push
}
发布于 2015-09-30 17:49:22
没有类似push
的函数可用。当然,您可以在项目的issues section中打开请求。
最接近的解决方案是使用concat
函数:
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]]
concat
函数中的最后一个数字指定要添加新数据的维度。
https://stackoverflow.com/questions/32630758
复制相似问题