!function(t,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports.f6=r():t.f6=r()}(this,(function(){return function(t){var r={};function e(o){if(r[o])return r[o].exports;var n=r[o]={i:o,l:!1,exports:{}};return t[o].call(n.exports,n,n.exports,e),n.l=!0,n.exports}return e.m=t,e.c=r,e.d=function(t,r,o){e.o(t,r)||Object.defineProperty(t,r,{enumerable:!0,get:o})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,r){if(1&r&&(t=e(t)),8&r)return t;if(4&r&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(e.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&r&&"string"!=typeof t)for(var n in t)e.d(o,n,function(r){return t[r]}.bind(null,n));return o},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,r){return Object.prototype.hasOwnProperty.call(t,r)},e.p="",e(e.s=408)}({10:function(t,r,e){"use strict";var o=this&&this.__createBinding||(Object.create?function(t,r,e,o){void 0===o&&(o=e),Object.defineProperty(t,o,{enumerable:!0,get:function(){return r[e]}})}:function(t,r,e,o){void 0===o&&(o=e),t[o]=r[e]}),n=this&&this.__exportStar||function(t,r){for(var e in t)"default"===e||Object.prototype.hasOwnProperty.call(r,e)||o(r,t,e)};Object.defineProperty(r,"__esModule",{value:!0}),n(e(11),r),n(e(12),r),n(e(13),r),n(e(14),r),n(e(15),r),n(e(16),r)},102:function(t,r,e){"use strict";e.r(r),e.d(r,"AbstractMatrix",(function(){return Q})),e.d(r,"default",(function(){return K})),e.d(r,"Matrix",(function(){return K})),e.d(r,"MatrixColumnView",(function(){return at})),e.d(r,"MatrixColumnSelectionView",(function(){return yt})),e.d(r,"MatrixFlipColumnView",(function(){return xt})),e.d(r,"MatrixFlipRowView",(function(){return _t})),e.d(r,"MatrixRowView",(function(){return Vt})),e.d(r,"MatrixRowSelectionView",(function(){return Ut})),e.d(r,"MatrixSelectionView",(function(){return Xt})),e.d(r,"MatrixSubView",(function(){return or})),e.d(r,"MatrixTransposeView",(function(){return cr})),e.d(r,"wrap",(function(){return Or})),e.d(r,"WrapperMatrix1D",(function(){return wr})),e.d(r,"WrapperMatrix2D",(function(){return Er})),e.d(r,"solve",(function(){return Vr})),e.d(r,"inverse",(function(){return Ir})),e.d(r,"determinant",(function(){return qr})),e.d(r,"linearDependencies",(function(){return Br})),e.d(r,"pseudoInverse",(function(){return Lr})),e.d(r,"covariance",(function(){return Ur})),e.d(r,"correlation",(function(){return Qr})),e.d(r,"SingularValueDecomposition",(function(){return Nr})),e.d(r,"SVD",(function(){return Nr})),e.d(r,"EigenvalueDecomposition",(function(){return Hr})),e.d(r,"EVD",(function(){return Hr})),e.d(r,"CholeskyDecomposition",(function(){return re})),e.d(r,"CHO",(function(){return re})),e.d(r,"LuDecomposition",(function(){return jr})),e.d(r,"LU",(function(){return jr})),e.d(r,"QrDecomposition",(function(){return Tr})),e.d(r,"QR",(function(){return Tr})),e.d(r,"Nipals",(function(){return oe})),e.d(r,"NIPALS",(function(){return oe}));var o=Object.prototype.toString;function n(t){return o.call(t).endsWith("Array]")}var i=function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!n(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var e=r.fromIndex,o=void 0===e?0:e,i=r.toIndex,s=void 0===i?t.length:i;if(o<0||o>=t.length||!Number.isInteger(o))throw new Error("fromIndex must be a positive integer smaller than length");if(s<=o||s>t.length||!Number.isInteger(s))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var u=t[o],a=o+1;au&&(u=t[a]);return u};var s=function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!n(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var e=r.fromIndex,o=void 0===e?0:e,i=r.toIndex,s=void 0===i?t.length:i;if(o<0||o>=t.length||!Number.isInteger(o))throw new Error("fromIndex must be a positive integer smaller than length");if(s<=o||s>t.length||!Number.isInteger(s))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var u=t[o],a=o+1;a1&&void 0!==arguments[1]?arguments[1]:{};if(!n(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");if(void 0!==e.output){if(!n(e.output))throw new TypeError("output option must be an array if specified");r=e.output}else r=new Array(t.length);var o=s(t),u=i(t);if(o===u)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var a=e.min,f=void 0===a?e.autoMinMax?o:0:a,c=e.max,h=void 0===c?e.autoMinMax?u:1:c;if(f>=h)throw new RangeError("min option must be smaller than max option");for(var l=(h-f)/(u-o),p=0;p1&&void 0!==arguments[1]?arguments[1]:{},e=r.maxRows,o=void 0===e?15:e,n=r.maxColumns,i=void 0===n?10:n,s=r.maxNumSize,u=void 0===s?8:s;return"".concat(t.constructor.name," {\n").concat(a,"[\n").concat(f).concat(h(t,o,i,u),"\n").concat(a,"]\n").concat(a,"rows: ").concat(t.rows,"\n").concat(a,"columns: ").concat(t.columns,"\n}")}function h(t,r,e,o){for(var n=t.rows,i=t.columns,s=Math.min(n,r),u=Math.min(i,e),a=[],c=0;co)throw new RangeError("Row index out of range")}function y(t,r,e){var o=e?t.columns:t.columns-1;if(r<0||r>o)throw new RangeError("Column index out of range")}function m(t,r){if(r.to1DArray&&(r=r.to1DArray()),r.length!==t.columns)throw new RangeError("vector size must be the same as the number of columns");return r}function g(t,r){if(r.to1DArray&&(r=r.to1DArray()),r.length!==t.rows)throw new RangeError("vector size must be the same as the number of rows");return r}function w(t,r,e){return{row:b(t,r),column:d(t,e)}}function b(t,r){if("object"!==p(r))throw new TypeError("unexpected type for row indices");if(r.some((function(r){return r<0||r>=t.rows})))throw new RangeError("row indices are out of range");return Array.isArray(r)||(r=Array.from(r)),r}function d(t,r){if("object"!==p(r))throw new TypeError("unexpected type for column indices");if(r.some((function(r){return r<0||r>=t.columns})))throw new RangeError("column indices are out of range");return Array.isArray(r)||(r=Array.from(r)),r}function M(t,r,e,o,n){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(k("startRow",r),k("endRow",e),k("startColumn",o),k("endColumn",n),r>e||o>n||r<0||r>=t.rows||e<0||e>=t.rows||o<0||o>=t.columns||n<0||n>=t.columns)throw new RangeError("Submatrix indices are out of range")}function x(t){for(var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,e=[],o=0;oe?(n=!0,e=r):(o=!1,n=!0);t++}return o}},{key:"isReducedEchelonForm",value:function(){for(var t=0,r=0,e=-1,o=!0,n=!1;te?(n=!0,e=r):(o=!1,n=!0);for(var i=r+1;it.get(o,e)&&(o=n);if(0===t.get(o,e))e++;else{t.swapRows(r,o);for(var i=t.get(r,e),s=e;s=0;)if(0===t.maxRow(o))o--;else{for(var n=0,i=!1;n0&&void 0!==arguments[0]?arguments[0]:{};if("object"!==L(t))throw new TypeError("options must be an object");var r=t.rows,e=void 0===r?1:r,o=t.columns,n=void 0===o?1:o;if(!Number.isInteger(e)||e<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(n)||n<=0)throw new TypeError("columns must be a positive integer");for(var i=new K(this.rows*e,this.columns*n),s=0;st&&(t=this.get(r,e));return t}},{key:"maxIndex",value:function(){S(this);for(var t=this.get(0,0),r=[0,0],e=0;et&&(t=this.get(e,o),r[0]=e,r[1]=o);return r}},{key:"min",value:function(){if(this.isEmpty())return NaN;for(var t=this.get(0,0),r=0;rr&&(r=this.get(t,e));return r}},{key:"maxRowIndex",value:function(t){v(this,t),S(this);for(var r=this.get(t,0),e=[t,0],o=1;or&&(r=this.get(t,o),e[1]=o);return e}},{key:"minRow",value:function(t){if(v(this,t),this.isEmpty())return NaN;for(var r=this.get(t,0),e=1;er&&(r=this.get(e,t));return r}},{key:"maxColumnIndex",value:function(t){y(this,t),S(this);for(var r=this.get(0,t),e=[0,t],o=1;or&&(r=this.get(o,t),e[0]=o);return e}},{key:"minColumn",value:function(t){if(y(this,t),this.isEmpty())return NaN;for(var r=this.get(0,t),e=1;e0&&void 0!==arguments[0]?arguments[0]:"frobenius",r=0;if("max"===t)return this.max();if("frobenius"===t){for(var e=0;e0&&void 0!==arguments[0]?arguments[0]:{};if("object"!==L(t))throw new TypeError("options must be an object");var r=t.min,e=void 0===r?0:r,o=t.max,n=void 0===o?1:o;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(n))throw new TypeError("max must be a number");if(e>=n)throw new RangeError("min must be smaller than max");for(var i=new K(this.rows,this.columns),s=0;s0&&u(a,{min:e,max:n,output:a}),i.setRow(s,a)}return i}},{key:"scaleColumns",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if("object"!==L(t))throw new TypeError("options must be an object");var r=t.min,e=void 0===r?0:r,o=t.max,n=void 0===o?1:o;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(n))throw new TypeError("max must be a number");if(e>=n)throw new RangeError("min must be smaller than max");for(var i=new K(this.rows,this.columns),s=0;s0&&void 0!==arguments[0]?arguments[0]:J,r=0;r0&&void 0!==arguments[0]?arguments[0]:J,r=0;re||r<0||r>=this.columns||e<0||e>=this.columns)throw new RangeError("Argument out of range");for(var o=new K(t.length,e-r+1),n=0;n=this.rows)throw new RangeError("Row index out of range: ".concat(t[n]));o.set(n,i-r,this.get(t[n],i))}return o}},{key:"subMatrixColumn",value:function(t,r,e){if(void 0===r&&(r=0),void 0===e&&(e=this.rows-1),r>e||r<0||r>=this.rows||e<0||e>=this.rows)throw new RangeError("Argument out of range");for(var o=new K(e-r+1,t.length),n=0;n=this.columns)throw new RangeError("Column index out of range: ".concat(t[n]));o.set(i-r,n,this.get(i,t[n]))}return o}},{key:"setSubMatrix",value:function(t,r,e){if((t=K.checkMatrix(t)).isEmpty())return this;M(this,r,r+t.rows-1,e,e+t.columns-1);for(var o=0;o1&&void 0!==arguments[1]?arguments[1]:{};if("object"===L(t)&&(r=t,t=void 0),"object"!==L(r))throw new TypeError("options must be an object");var e=r,o=e.unbiased,n=void 0===o||o,i=e.mean,s=void 0===i?this.mean(t):i;if("boolean"!=typeof n)throw new TypeError("unbiased must be a boolean");switch(t){case"row":if(!Array.isArray(s))throw new TypeError("mean must be an array");return E(this,n,s);case"column":if(!Array.isArray(s))throw new TypeError("mean must be an array");return O(this,n,s);case void 0:if("number"!=typeof s)throw new TypeError("mean must be a number");return R(this,n,s);default:throw new Error("invalid option: ".concat(t))}}},{key:"standardDeviation",value:function(t,r){"object"===L(t)&&(r=t,t=void 0);var e=this.variance(t,r);if(void 0===t)return Math.sqrt(e);for(var o=0;o1&&void 0!==arguments[1]?arguments[1]:{};if("object"===L(t)&&(r=t,t=void 0),"object"!==L(r))throw new TypeError("options must be an object");var e=r,o=e.center,n=void 0===o?this.mean(t):o;switch(t){case"row":if(!Array.isArray(n))throw new TypeError("center must be an array");return j(this,n),this;case"column":if(!Array.isArray(n))throw new TypeError("center must be an array");return _(this,n),this;case void 0:if("number"!=typeof n)throw new TypeError("center must be a number");return P(this,n),this;default:throw new Error("invalid option: ".concat(t))}}},{key:"scale",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("object"===L(t)&&(r=t,t=void 0),"object"!==L(r))throw new TypeError("options must be an object");var e=r.scale;switch(t){case"row":if(void 0===e)e=T(this);else if(!Array.isArray(e))throw new TypeError("scale must be an array");return A(this,e),this;case"column":if(void 0===e)e=C(this);else if(!Array.isArray(e))throw new TypeError("scale must be an array");return N(this,e),this;case void 0:if(void 0===e)e=I(this);else if("number"!=typeof e)throw new TypeError("scale must be a number");return V(this,e),this;default:throw new Error("invalid option: ".concat(t))}}},{key:"toString",value:function(t){return c(this,t)}}],[{key:"from1DArray",value:function(t,r,e){if(t*r!==e.length)throw new RangeError("data length does not match given dimensions");for(var o=new K(t,r),n=0;n2&&void 0!==arguments[2]?arguments[2]:{};if("object"!==L(e))throw new TypeError("options must be an object");for(var o=e.random,n=void 0===o?Math.random:o,i=new K(t,r),s=0;s2&&void 0!==arguments[2]?arguments[2]:{};if("object"!==L(e))throw new TypeError("options must be an object");var o=e.min,n=void 0===o?0:o,i=e.max,s=void 0===i?1e3:i,u=e.random,a=void 0===u?Math.random:u;if(!Number.isInteger(n))throw new TypeError("min must be an integer");if(!Number.isInteger(s))throw new TypeError("max must be an integer");if(n>=s)throw new RangeError("min must be smaller than max");for(var f=s-n,c=new K(t,r),h=0;h=0){if(n.data=[],!(Number.isInteger(o)&&o>=0))throw new TypeError("nColumns must be a positive integer");for(var i=0;i>t);return this},Y.prototype.signPropagatingRightShiftM=function(t){if(t=H.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(var r=0;r>t.get(r,e));return this},Y.signPropagatingRightShift=function(t,r){return new H(t).signPropagatingRightShift(r)},Y.prototype.rightShift=function(t){return"number"==typeof t?this.rightShiftS(t):this.rightShiftM(t)},Y.prototype.rightShiftS=function(t){for(var r=0;r>>t);return this},Y.prototype.rightShiftM=function(t){if(t=H.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(var r=0;r>>t.get(r,e));return this},Y.rightShift=function(t,r){return new H(t).rightShift(r)},Y.prototype.zeroFillRightShift=Y.prototype.rightShift,Y.prototype.zeroFillRightShiftS=Y.prototype.rightShiftS,Y.prototype.zeroFillRightShiftM=Y.prototype.rightShiftM,Y.zeroFillRightShift=Y.rightShift,Y.prototype.not=function(){for(var t=0;t1&&void 0!==arguments[1]?arguments[1]:{};lr(this,i);var o=e.rows,s=void 0===o?1:o;if(t.length%s!=0)throw new Error("the data length is not divisible by the number of rows");return(r=n.call(this)).rows=s,r.columns=t.length/s,r.data=t,r}return r=i,(e=[{key:"set",value:function(t,r,e){var o=this._calculateIndex(t,r);return this.data[o]=e,this}},{key:"get",value:function(t,r){var e=this._calculateIndex(t,r);return this.data[e]}},{key:"_calculateIndex",value:function(t,r){return t*this.columns+r}}])&&pr(r.prototype,e),o&&pr(r,o),i}(Q);function br(t){return(br="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function dr(t,r){for(var e=0;eMath.abs(f[i])&&(i=e);if(i!==o){for(n=0;n=0;n--){for(o=0;oi?o.set(n,i,t.get(n,i)):n===i?o.set(n,i,1):o.set(n,i,0);return o}},{key:"upperTriangularMatrix",get:function(){for(var t=this.LU,r=t.rows,e=t.columns,o=new K(r,e),n=0;nMath.abs(r)?(e=r/t,Math.abs(t)*Math.sqrt(1+e*e)):0!==r?(e=t/r,Math.abs(r)*Math.sqrt(1+e*e)):0}function Pr(t,r){for(var e=0;e=0;i--){for(n=0;n=0;e--){for(t=0;t1&&void 0!==arguments[1]?arguments[1]:{};if(Ar(this,t),(r=Er.checkMatrix(r)).isEmpty())throw new Error("Matrix must be non-empty");var o,n=r.rows,i=r.columns,s=e.computeLeftSingularVectors,u=void 0===s||s,a=e.computeRightSingularVectors,f=void 0===a||a,c=e.autoTranspose,h=void 0!==c&&c,l=Boolean(u),p=Boolean(f),v=!1;if(n=0;H--)if(0!==w[H]){for(var X=H+1;X=0;ot--){if(ot0;){var ht=void 0,lt=void 0;for(ht=Q-2;ht>=-1&&-1!==ht;ht--){var pt=Number.MIN_VALUE+ct*Math.abs(w[ht]+Math.abs(w[ht+1]));if(Math.abs(M[ht])<=pt||Number.isNaN(M[ht])){M[ht]=0;break}}if(ht===Q-2)lt=4;else{var vt=void 0;for(vt=Q-1;vt>=ht&&vt!==ht;vt--){var yt=(vt!==Q?Math.abs(M[vt]):0)+(vt!==ht+1?Math.abs(M[vt-1]):0);if(Math.abs(w[vt])<=ct*yt){w[vt]=0;break}}vt===ht?lt=3:vt===Q-1?lt=1:(lt=2,ht=vt)}switch(ht++,lt){case 1:var mt=M[Q-2];M[Q-2]=0;for(var gt=Q-2;gt>=ht;gt--){var wt=_r(w[gt],mt),bt=w[gt]/wt,dt=mt/wt;if(w[gt]=wt,gt!==ht&&(mt=-dt*M[gt-1],M[gt-1]=bt*M[gt-1]),p)for(var Mt=0;Mt=w[ht+1]);){var Jt=w[ht];if(w[ht]=w[ht+1],w[ht+1]=Jt,p&&htr&&n.set(i,s,t.get(i,s)/this.s[s]);for(var u=this.U,a=u.rows,f=u.columns,c=new K(e,a),h=0;ht&&r++;return r}},{key:"diagonal",get:function(){return Array.from(this.s)}},{key:"threshold",get:function(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}},{key:"leftSingularVectors",get:function(){return this.U}},{key:"rightSingularVectors",get:function(){return this.V}},{key:"diagonalMatrix",get:function(){return K.diag(this.s)}}])&&Cr(r.prototype,e),o&&Cr(r,o),t}();function Ir(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return t=Er.checkMatrix(t),r?new Nr(t).inverse():Vr(t,K.eye(t.rows))}function Vr(t,r){var e=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return t=Er.checkMatrix(t),r=Er.checkMatrix(r),e?new Nr(t).solve(r):t.isSquare()?new jr(t).solve(r):new Tr(t).solve(r)}function qr(t){var r,e,o,n,i,s;if((t=K.checkMatrix(t)).isSquare())return 0===t.columns?1:2===t.columns?(r=t.get(0,0),e=t.get(0,1),o=t.get(1,0),r*t.get(1,1)-e*o):3===t.columns?(n=new Xt(t,[1,2],[1,2]),i=new Xt(t,[1,2],[0,2]),s=new Xt(t,[1,2],[0,1]),r=t.get(0,0),e=t.get(0,1),o=t.get(0,2),r*qr(n)-e*qr(i)+o*qr(s)):new jr(t).determinant;throw Error("determinant can only be calculated for a square matrix")}function Dr(t,r){for(var e=[],o=0;o3&&void 0!==arguments[3]?arguments[3]:1e-9,n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1e-9;if(t>n)return new Array(r.rows+1).fill(0);for(var i=r.addRow(e,[0]),s=0;s1&&void 0!==arguments[1]?arguments[1]:{},e=r.thresholdValue,o=void 0===e?1e-9:e,n=r.thresholdError,i=void 0===n?1e-9:n,s=(t=K.checkMatrix(t)).rows,u=new K(s,s),a=0;a1&&void 0!==arguments[1]?arguments[1]:Number.EPSILON;if((t=K.checkMatrix(t)).isEmpty())return t.transpose();for(var e=new Nr(t,{autoTranspose:!0}),o=e.leftSingularVectors,n=e.rightSingularVectors,i=e.diagonal,s=0;sr?i[s]=1/i[s]:i[s]=0;return n.mmul(K.diag(i).mmul(o.transpose()))}function zr(t){return(zr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Ur(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};t=new K(t);var o=!1;if("object"!==zr(r)||K.isMatrix(r)||Array.isArray(r)?r=new K(r):(e=r,r=t,o=!0),t.rows!==r.rows)throw new TypeError("Both matrices must have the same number of rows");var n=e,i=n.center,s=void 0===i||i;s&&(t=t.center("column"),o||(r=r.center("column")));for(var u=t.transpose().mmul(r),a=0;a1&&void 0!==arguments[1]?arguments[1]:t,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};t=new K(t);var o=!1;if("object"!==Wr(r)||K.isMatrix(r)||Array.isArray(r)?r=new K(r):(e=r,r=t,o=!0),t.rows!==r.rows)throw new TypeError("Both matrices must have the same number of rows");var n=e,i=n.center,s=void 0===i||i,u=n.scale,a=void 0===u||u;s&&(t.center("column"),o||r.center("column")),a&&(t.scale("column"),o||r.scale("column"));for(var f=t.standardDeviation("column",{unbiased:!0}),c=o?f:r.standardDeviation("column",{unbiased:!0}),h=t.transpose().mmul(r),l=0;l1&&void 0!==arguments[1]?arguments[1]:{};Jr(this,t);var o=e.assumeSymmetric,n=void 0!==o&&o;if(!(r=Er.checkMatrix(r)).isSquare())throw new Error("Matrix is not a square matrix");if(r.isEmpty())throw new Error("Matrix must be non-empty");var i,s,u=r.columns,a=new K(u,u),f=new Float64Array(u),c=new Float64Array(u),h=r;if(!!n||r.isSymmetric()){for(i=0;i0?i.set(t,t+1,o[t]):o[t]<0&&i.set(t,t-1,o[t])}return i}}])&&Yr(r.prototype,e),o&&Yr(r,o),t}();function Kr(t,r,e,o){var n,i,s,u,a,f,c,h;for(a=0;a0;u--){for(h=0,s=0,f=0;f0&&(i=-i),r[u]=h*i,s-=n*i,e[u-1]=n-i,a=0;af){0;do{for(1,n=e[f],l=_r(h=(e[f+1]-n)/(2*r[f]),1),h<0&&(l=-l),e[f]=r[f]/(h+l),e[f+1]=r[f]*(h+l),p=e[f+1],i=n-e[f],s=f+2;s=f;s--)for(m=y,y=v,b=w,n=v*r[s],i=v*h,l=_r(h,r[s]),r[s+1]=w*l,w=r[s]/l,h=(v=h/l)*e[s]-w*n,e[s+1]=i+w*(v*n+w*e[s]),a=0;ax*M)}e[f]=e[f]+d,r[f]=0}for(s=0;s=f;u--)e[u]=r.get(u,f-1)/c,s+=e[u]*e[u];for(i=Math.sqrt(s),e[f]>0&&(i=-i),s-=e[f]*i,e[f]=e[f]-i,a=f;a=f;u--)n+=e[u]*r.get(u,a);for(n/=s,u=f;u<=h;u++)r.set(u,a,r.get(u,a)-n*e[u])}for(u=0;u<=h;u++){for(n=0,a=h;a>=f;a--)n+=e[a]*r.get(u,a);for(n/=s,a=f;a<=h;a++)r.set(u,a,r.get(u,a)-n*e[a])}e[f]=c*e[f],r.set(f,f-1,c*i)}}for(u=0;u=1;f--)if(0!==r.get(f,f-1)){for(u=f+1;u<=h;u++)e[u]=r.get(u,f-1);for(a=f;a<=h;a++){for(i=0,u=f;u<=h;u++)i+=e[u]*o.get(u,a);for(i=i/e[f]/r.get(f,f-1),u=f;u<=h;u++)o.set(u,a,o.get(u,a)+i*e[u])}}}function Zr(t,r,e,o,n){var i,s,u,a,f,c,h,l,p,v,y,m,g,w,b,d=t-1,M=t-1,x=Number.EPSILON,k=0,S=0,E=0,O=0,R=0,j=0,_=0,P=0;for(i=0;iM)&&(e[i]=n.get(i,i),r[i]=0),s=Math.max(i-1,0);s=0;){for(a=d;a>0&&(0===(j=Math.abs(n.get(a-1,a-1))+Math.abs(n.get(a,a)))&&(j=S),!(Math.abs(n.get(a,a-1))=0){for(_=E>=0?E+_:E-_,e[d-1]=l+_,e[d]=e[d-1],0!==_&&(e[d]=l-h/_),r[d-1]=0,r[d]=0,E=(l=n.get(d,d-1))/(j=Math.abs(l)+Math.abs(_)),O=_/j,E/=R=Math.sqrt(E*E+O*O),O/=R,s=d-1;s0){for(j=Math.sqrt(j),p=a&&(E=((R=l-(_=n.get(f,f)))*(j=p-_)-h)/n.get(f+1,f)+n.get(f,f+1),O=n.get(f+1,f+1)-_-R-j,R=n.get(f+2,f+1),E/=j=Math.abs(E)+Math.abs(O)+Math.abs(R),O/=j,R/=j,f!==a)&&!(Math.abs(n.get(f,f-1))*(Math.abs(O)+Math.abs(R))f+2&&n.set(i,i-3,0);for(u=f;u<=d-1&&(w=u!==d-1,u!==f&&(E=n.get(u,u-1),O=n.get(u+1,u-1),R=w?n.get(u+2,u-1):0,0!==(l=Math.abs(E)+Math.abs(O)+Math.abs(R))&&(E/=l,O/=l,R/=l)),0!==l);u++)if(j=Math.sqrt(E*E+O*O+R*R),E<0&&(j=-j),0!==j){for(u!==f?n.set(u,u-1,-j*l):a!==f&&n.set(u,u-1,-n.get(u,u-1)),l=(E+=j)/j,p=O/j,_=R/j,O/=E,R/=E,s=u;s=0;d--)if(E=e[d],0===(O=r[d]))for(a=d,n.set(d,d,1),i=d-1;i>=0;i--){for(h=n.get(i,i)-E,R=0,s=a;s<=d;s++)R+=n.get(i,s)*n.get(s,d);if(r[i]<0)_=h,j=R;else if(a=i,0===r[i]?n.set(i,d,0!==h?-R/h:-R/(x*S)):(l=n.get(i,i+1),p=n.get(i+1,i),c=(l*j-_*R)/(O=(e[i]-E)*(e[i]-E)+r[i]*r[i]),n.set(i,d,c),n.set(i+1,d,Math.abs(l)>Math.abs(_)?(-R-h*c)/l:(-j-p*c)/_)),x*(c=Math.abs(n.get(i,d)))*c>1)for(s=i;s<=d;s++)n.set(s,d,n.get(s,d)/c)}else if(O<0)for(a=d-1,Math.abs(n.get(d,d-1))>Math.abs(n.get(d-1,d))?(n.set(d-1,d-1,O/n.get(d,d-1)),n.set(d-1,d,-(n.get(d,d)-E)/n.get(d,d-1))):(b=$r(0,-n.get(d-1,d),n.get(d-1,d-1)-E,O),n.set(d-1,d-1,b[0]),n.set(d-1,d,b[1])),n.set(d,d-1,0),n.set(d,d,1),i=d-2;i>=0;i--){for(v=0,y=0,s=a;s<=d;s++)v+=n.get(i,s)*n.get(s,d-1),y+=n.get(i,s)*n.get(s,d);if(h=n.get(i,i)-E,r[i]<0)_=h,R=v,j=y;else if(a=i,0===r[i]?(b=$r(-v,-y,h,O),n.set(i,d-1,b[0]),n.set(i,d,b[1])):(l=n.get(i,i+1),p=n.get(i+1,i),m=(e[i]-E)*(e[i]-E)+r[i]*r[i]-O*O,g=2*(e[i]-E)*O,0===m&&0===g&&(m=x*S*(Math.abs(h)+Math.abs(O)+Math.abs(l)+Math.abs(p)+Math.abs(_))),b=$r(l*R-_*v+O*y,l*j-_*y-O*v,m,g),n.set(i,d-1,b[0]),n.set(i,d,b[1]),Math.abs(l)>Math.abs(_)+Math.abs(O)?(n.set(i+1,d-1,(-v-h*n.get(i,d-1)+O*n.get(i,d))/l),n.set(i+1,d,(-y-h*n.get(i,d)-O*n.get(i,d-1))/l)):(b=$r(-R-p*n.get(i,d-1),-j-p*n.get(i,d),_,O),n.set(i+1,d-1,b[0]),n.set(i+1,d,b[1]))),x*(c=Math.max(Math.abs(n.get(i,d-1)),Math.abs(n.get(i,d))))*c>1)for(s=i;s<=d;s++)n.set(s,d-1,n.get(s,d-1)/c),n.set(s,d,n.get(s,d)/c)}for(i=0;iM)for(s=i;s=0;s--)for(i=0;i<=M;i++){for(_=0,u=0;u<=Math.min(s,M);u++)_+=o.get(i,u)*n.get(u,s);o.set(i,s,_)}}}function $r(t,r,e,o){var n,i;return Math.abs(e)>Math.abs(o)?[(t+(n=o/e)*r)/(i=e+n*o),(r-n*t)/i]:[((n=e/o)*t+r)/(i=o+n*e),(n*r-t)/i]}function te(t,r){for(var e=0;e0,u.set(o,o,Math.sqrt(Math.max(f,0))),n=o+1;n=0;i--)for(n=0;n1&&void 0!==arguments[1]?arguments[1]:{};ee(this,t),r=Er.checkMatrix(r);var o,n=e.Y,i=e.scaleScores,s=void 0!==i&&i,u=e.maxIterations,a=void 0===u?1e3:u,f=e.terminationCriteria,c=void 0===f?1e-10:f;if(n){if((n=Array.isArray(n)&&"number"==typeof n[0]?K.columnVector(n):Er.checkMatrix(n)).rows!==r.rows)throw new Error("Y should have the same number of rows as X");o=n.getColumnVector(0)}else o=r.getColumnVector(0);for(var h,l,p,v,y=1,m=0;mc;m++)p=(p=r.transpose().mmul(o).div(o.transpose().mmul(o).get(0,0))).div(p.norm()),h=r.mmul(p).div(p.transpose().mmul(p).get(0,0)),m>0&&(y=h.clone().sub(v).pow(2).sum()),v=h.clone(),n?(l=(l=n.transpose().mmul(h).div(h.transpose().mmul(h).get(0,0))).div(l.norm()),o=n.mmul(l).div(l.transpose().mmul(l).get(0,0))):o=h;if(n){var g=r.transpose().mmul(h).div(h.transpose().mmul(h).get(0,0));g=g.div(g.norm());var w=r.clone().sub(h.clone().mmul(g.transpose())),b=o.transpose().mmul(h).div(h.transpose().mmul(h).get(0,0)),d=n.clone().sub(h.clone().mulS(b.get(0,0)).mmul(l.transpose()));this.t=h,this.p=g.transpose(),this.w=p.transpose(),this.q=l,this.u=o,this.s=h.transpose().mmul(h),this.xResidual=w,this.yResidual=d,this.betas=b}else this.w=p.transpose(),this.s=h.transpose().mmul(h).sqrt(),this.t=s?h.clone().div(this.s.get(0,0)):h,this.xResidual=r.sub(h.mmul(p.transpose()))}},11:function(t,r,e){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.camelize=r.isString=void 0;r.isString=function(t){return"string"==typeof t};var o,n,i=/-(\w)/g;r.camelize=(o=function(t){return t.replace(i,(function(t,r){return r?r.toUpperCase():""}))},n=Object.create(null),function(t){return n[t]||(n[t]=o(t))})},12:function(t,r,e){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.isArray=void 0,r.isArray=Array.isArray},13:function(t,r,e){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.toNumber=r.isNaN=r.isNumber=void 0;r.isNumber=function(t){return"number"==typeof t};r.isNaN=function(t){return Number.isNaN(Number(t))};r.toNumber=function(t){var e=parseFloat(t);return r.isNaN(e)?t:e}},14:function(t,r,e){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.traverseTreeUp=r.scaleMatrix=r.getAdjMatrix=r.floydWarshall=r.getDegree=void 0;r.getDegree=function(t,r,e){for(var o=[],n=0;nr[o][i]+r[i][n]&&(r[o][n]=r[o][i]+r[i][n]);return r};r.getAdjMatrix=function(t,r){var e=t.nodes,o=t.edges,n=[],i={};if(!e)throw new Error("invalid nodes data!");return e&&e.forEach((function(t,r){i[t.id]=r;n.push([])})),o&&o.forEach((function(t){var e=t.source,o=t.target,s=i[e],u=i[o];n[s][u]=1,r||(n[u][s]=1)})),n};r.scaleMatrix=function(t,r){var e=[];return t.forEach((function(t){var o=[];t.forEach((function(t){o.push(t*r)})),e.push(o)})),e};r.traverseTreeUp=function(t,r){"function"==typeof r&&function t(r,e){if(r&&r.children)for(var o=r.children.length-1;o>=0;o--)if(!t(r.children[o],e))return;return!!e(r)}(t,r)}},15:function(t,r,e){"use strict";function o(t){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var n=this&&this.__assign||function(){return(n=Object.assign||function(t){for(var r,e=1,o=arguments.length;e