You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 10, 2022. It is now read-only.
/*** * @author Jason Reynolds * @param - inputM the matrix in the equation Ax=b, namely A* @param - input_col the column vector in the equation Ax = b, namely b* @returns - the matrix answer , x, to the equation Ax=b using lu decomposition** Function that uniquely solves the equation Ax = b for a square matrix/Mat A and column vector b*/functionlusolve(inputM,input_col){*importmath: deep_copy//declare raw_in, raw_in_col as input.clone() if Mat otherwise, inputM, input_col themselves letin_type_M=(inputMinstanceofMat);letraw_in=(in_type_M) ? inputM.clone() : deep_copy(inputM);letin_type_col=(input_colinstanceofMat);letraw_in_col=(in_type_col) ? input_col.clone() : deep_copy(input_col);//if any input is Mat, degrade to JS arrayif(raw_ininstanceofMat){raw_in=raw_in.val;}if(input_colinstanceofMat){raw_in_col=raw_in_col.val;}//check: 0 dims? not square? column vector not equal to length of matrix row length? (if input is m x n, b is m x 1, while solution is n x 1 if(raw_in.length===0||raw_in[0].length===0||!(raw_in.length===raw_in[0].length)||!(raw_in_col.length===raw_in.length)){thrownewError('Wrong dimensions. Need nxn matrix, may want to try lusolveAll or check column vector');}//define the result to be the lusolve output ie the solutionletresult=mathjs.lusolve(raw_in,raw_in_col);//return it as a Mat objectreturnnewMat(result);}```
The text was updated successfully, but these errors were encountered:
Gaoooooo
changed the title
Ex function that handles Mat/JS arrays (lusolve from mathjs)
Example function that handles Mat/JS arrays (lusolve from mathjs)
Apr 29, 2022
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The text was updated successfully, but these errors were encountered: