我正在尝试使用mathJS包执行向量和矩阵运算。
我有一个向量,我想把它和它的转置相乘,变成一个矩阵。
预期的结果将是
a = [1 1 1], [1x3] vector
a^T = [1 1 1]^T, [3,1] vector
[1, 1, 1]
a^T * a = [1, 1, 1]
[1, 1, 1]
由于某些原因,我在javascript中构造列向量时遇到了问题,因为
const test1 = math.multiply(math.transpose([1, 1, 1]), [1, 1, 1]);
const test2 = math.multiply([1, 1, 1], math.transpose([1, 1, 1]));
test1和test2都返回3。我漏掉了什么?
发布于 2021-11-18 09:42:56
你漏掉了括号。
const test1 = math.multiply(math.transpose([[1, 1, 1]]), [[1, 1, 1]]);
[1, 1, 1]
的维度是1,但[[1, 1, 1]]
的维度是1x3。
https://stackoverflow.com/questions/66222768
复制相似问题