Skip to content
Snippets Groups Projects
Commit 639f137a authored by Alexander Rose's avatar Alexander Rose
Browse files

fix PrincipalAxes

parent 29609e04
No related branches found
No related tags found
No related merge requests found
......@@ -52,9 +52,13 @@ namespace Matrix {
}
export function transpose<N extends number, M extends number>(out: Matrix<M, N>, mat: Matrix<N, M>): Matrix<M, N> {
if (out.cols !== mat.rows || out.rows !== mat.cols) {
throw new Error('transpose: matrix dimensions incompatible')
}
if (out.data === mat.data) {
throw new Error('transpose: matrices share memory')
}
const nrows = mat.rows, ncols = mat.cols
// TODO add in-place transpose
if (out as any === mat) mat = clone(mat)
const md = mat.data, mtd = out.data
for (let i = 0, mi = 0, mti = 0; i < nrows; mti += 1, mi += ncols, ++i) {
let ri = mti
......
......@@ -45,7 +45,7 @@ namespace PrincipalAxes {
// calculate
const mean = Matrix.meanRows(points)
const pointsM = Matrix.subRows(Matrix.clone(points), mean)
const pointsT = Matrix.transpose(pointsM as Matrix<number, 3>, pointsM)
const pointsT = Matrix.transpose(Matrix.create(n, 3), pointsM)
Matrix.multiplyABt(A, pointsT, pointsT)
svd(A, W, U, V)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment