Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
},
"homepage": "https://github.com/mljs/fcnnls#readme",
"dependencies": {
"ml-matrix": "^6.12.2"
"ml-matrix": "^6.13.0"
},
"devDependencies": {
"@types/node": "^26.0.0",
Expand Down
11 changes: 5 additions & 6 deletions src/fcnnls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,12 @@ export function fcnnls<T extends boolean | undefined>(
info = false,
} = options;

// pre-computes part of pseudo-inverse. XtX is the Gram matrix XᵀX.
// TODO: replace `Xt.mmul(X)` with `X.gram()` once ml-matrix is released with
// the gram() method (mljs/matrix, branch `add-gram`). gram() computes this XᵀX
// bit-identically, ~2.8x faster on dense and far faster on the sparse predictor
// matrices common here (it skips zeros and never materializes the transpose).
// pre-computes part of pseudo-inverse. XtX is the symmetric Gram matrix XᵀX;
// gram() computes this bit-identically to Xt.mmul(X) but only fills the upper
// triangle, skips zeros and never materializes the transpose, so it is much
// faster on the sparse predictor matrices common here.
const Xt = X.transpose();
const XtX = Xt.mmul(X);
const XtX = X.gram();
const XtY = Xt.mmul(Y);

const { columns: nColsY, rows: nRowsY } = Y;
Expand Down
Loading