Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
ndarray-lu-solve
Advanced tools
solve a system of linear equations from an LU decomposition
var solve = require('ndarray-lu-solve');
var show = require('ndarray-show');
var crout = require('ndarray-crout-decomposition');
var ndarray = require('ndarray');
var zeros = require('zeros');
var A = ndarray(
[ 2, 1, -1, 8, -3, -1, 2, -11, -2, 1, 2, -3 ],
[ 4, 3 ], [ 1, 4 ]
);
var L = zeros([ 3, 3 ]);
var U = zeros([ 3, 3 ]);
crout(A.hi(3,3), L, U);
var X = ndarray(new Float64Array(3));
var Y = ndarray(new Float64Array(3));
var solution = solve(L, U, A.lo(3,0).pick(0), X, Y);
console.log('input:\n' + show(A), '\n');
console.log('solution:\n' + show(solution));
output:
input:
2.000 1.000 -1.000 8.000
-3.000 -1.000 2.000 -11.000
-2.000 1.000 2.000 -3.000
solution:
2.000 3.000 -1.000
You can pass fewer of the parameters if you want and use a packed representation for L and U in the same matrix:
var solve = require('ndarray-lu-solve');
var show = require('ndarray-show');
var crout = require('ndarray-crout-decomposition');
var ndarray = require('ndarray');
var zeros = require('zeros');
var A = ndarray(
[ 2, 1, -1, 8, -3, -1, 2, -11, -2, 1, 2, -3 ],
[ 4, 3 ], [ 1, 4 ]
);
var LU = zeros([ 3, 3 ]);
crout(A.hi(3,3), LU);
var solution = solve(LU, A.lo(3,0).pick(0));
console.log('input:\n' + show(A), '\n');
console.log('solution:\n' + show(solution));
output:
input:
2.000 1.000 -1.000 8.000
-3.000 -1.000 2.000 -11.000
-2.000 1.000 2.000 -3.000
solution:
2.000 3.000 -1.000
Just note that it's up to you to
ndscratch.free()
the solution
you get back to prevent leaking memory.
var solve = require('ndarray-lu-solve')
Given an L
and U
ndarrays from a decomposition and a vector B
, solve the
system LY = B
for Y
and UX = Y
for X
.
L
and U
can also be the same matrix.
The solution
is written to X
as the computation procedes but is also the
return value.
Optional X
and Y
parameters are modified in-place and contain elements of
the result. If not given, X
and Y
will be allocated.
You can omit the U
parameter if you have a L
and U
values packed into the
same matrix. The other parameters work the same.
With npm do:
npm install ndarray-lu-solve
MIT
FAQs
solve a linear system of equations from an LU decomposition
The npm package ndarray-lu-solve receives a total of 2 weekly downloads. As such, ndarray-lu-solve popularity was classified as not popular.
We found that ndarray-lu-solve demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.