(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[994],{19456:function(t,e,r){"use strict";r.r(e),r.d(e,{default:function(){return a}});let o=Object.prototype.toString;function i(t){let e=o.call(t);return e.endsWith("Array]")&&!e.includes("Big")}let n=Object.prototype.toString,s=Object.prototype.toString;function a(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(i(t)){if(0===t.length)throw TypeError("input must not be empty")}else throw TypeError("input must be an array");if(void 0!==r.output){if(!i(r.output))throw TypeError("output option must be an array if specified");e=r.output}else e=Array(t.length);var o=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!function(t){let e=s.call(t);return e.endsWith("Array]")&&!e.includes("Big")}(t))throw TypeError("input must be an array");if(0===t.length)throw TypeError("input must not be empty");var r=e.fromIndex,o=void 0===r?0:r,i=e.toIndex,n=void 0===i?t.length:i;if(o<0||o>=t.length||!Number.isInteger(o))throw Error("fromIndex must be a positive integer smaller than length");if(n<=o||n>t.length||!Number.isInteger(n))throw Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=t[o],h=o+1;h1&&void 0!==arguments[1]?arguments[1]:{};if(!function(t){let e=n.call(t);return e.endsWith("Array]")&&!e.includes("Big")}(t))throw TypeError("input must be an array");if(0===t.length)throw TypeError("input must not be empty");var r=e.fromIndex,o=void 0===r?0:r,i=e.toIndex,s=void 0===i?t.length:i;if(o<0||o>=t.length||!Number.isInteger(o))throw Error("fromIndex must be a positive integer smaller than length");if(s<=o||s>t.length||!Number.isInteger(s))throw Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=t[o],h=o+1;ha&&(a=t[h]);return a}(t);if(o===a)throw RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var h=r.min,u=void 0===h?r.autoMinMax?o:0:h,l=r.max,f=void 0===l?r.autoMinMax?a:1:l;if(u>=f)throw RangeError("min option must be smaller than max option");for(var c=(f-u)/(a-o),m=0;mt.get(e,r)){i=!0;break t}}for(let e=0;e=0&&m?` ${h(c,o-1)}`:h(c,o)).padEnd(o)))}f.push(`${r.join(" ")}`)}return l!==a&&(f[f.length-1]+=` ... ${a-r} more columns`),u!==n&&f.push(`... ${n-e} more rows`),f.join(` ${s}`)}(t,r,o,i,a)} ${n}] ${n}rows: ${t.rows} ${n}columns: ${t.columns} }`}function h(t,e){let r=t.toString();if(r.length<=e)return r;let o=t.toFixed(e);if(o.length>e&&(o=t.toFixed(Math.max(0,e-(o.length-e)))),o.length<=e&&!o.startsWith("0.000")&&!o.startsWith("-0.000"))return o;let i=t.toExponential(e);return i.length>e&&(i=t.toExponential(Math.max(0,e-(i.length-e)))),i.slice(0)}function u(t,e,r){let o=r?t.rows:t.rows-1;if(e<0||e>o)throw RangeError("Row index out of range")}function l(t,e,r){let o=r?t.columns:t.columns-1;if(e<0||e>o)throw RangeError("Column index out of range")}function f(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.columns)throw RangeError("vector size must be the same as the number of columns");return e}function c(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.rows)throw RangeError("vector size must be the same as the number of rows");return e}function m(t,e){if(!o.isAnyArray(e))throw TypeError("row indices must be an array");for(let r=0;r=t.rows)throw RangeError("row indices are out of range")}function g(t,e){if(!o.isAnyArray(e))throw TypeError("column indices must be an array");for(let r=0;r=t.columns)throw RangeError("column indices are out of range")}function p(t,e,r,o,i){if(5!=arguments.length)throw RangeError("expected 4 arguments");if(w("startRow",e),w("endRow",r),w("startColumn",o),w("endColumn",i),e>r||o>i||e<0||e>=t.rows||r<0||r>=t.rows||o<0||o>=t.columns||i<0||i>=t.columns)throw RangeError("Submatrix indices are out of range")}function d(t,e=0){let r=[];for(let o=0;o=i)throw RangeError("min must be smaller than max");let s=i-o,a=new M(t,e);for(let r=0;rr?(i=!0,r=e):(o=!1,i=!0);t++}return o}isReducedEchelonForm(){let t=0,e=0,r=-1,o=!0,i=!1;for(;tr?(i=!0,r=e):(o=!1,i=!0);for(let r=e+1;rt.get(o,r)&&(o=i);if(0===t.get(o,r))r++;else{t.swapRows(e,o);let i=t.get(e,r);for(let o=r;o=0;)if(0===t.maxRow(o))o--;else{let i=0,n=!1;for(;it[e]&&(t[e]=this.get(e,r));return t}case"column":{let t=Array(this.columns).fill(Number.NEGATIVE_INFINITY);for(let e=0;et[r]&&(t[r]=this.get(e,r));return t}case void 0:{let t=this.get(0,0);for(let e=0;et&&(t=this.get(e,r));return t}default:throw Error(`invalid option: ${t}`)}}maxIndex(){y(this);let t=this.get(0,0),e=[0,0];for(let r=0;rt&&(t=this.get(r,o),e[0]=r,e[1]=o);return e}min(t){if(this.isEmpty())return NaN;switch(t){case"row":{let t=Array(this.rows).fill(Number.POSITIVE_INFINITY);for(let e=0;ee&&(e=this.get(t,r));return e}maxRowIndex(t){u(this,t),y(this);let e=this.get(t,0),r=[t,0];for(let o=1;oe&&(e=this.get(t,o),r[1]=o);return r}minRow(t){if(u(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let r=1;re&&(e=this.get(r,t));return e}maxColumnIndex(t){l(this,t),y(this);let e=this.get(0,t),r=[0,t];for(let o=1;oe&&(e=this.get(o,t),r[0]=o);return r}minColumn(t){if(l(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let r=1;r=r)throw RangeError("min must be smaller than max");let o=new M(this.rows,this.columns);for(let t=0;t0&&i(n,{min:e,max:r,output:n}),o.setRow(t,n)}return o}scaleColumns(t={}){if("object"!=typeof t)throw TypeError("options must be an object");let{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw TypeError("min must be a number");if(!Number.isFinite(r))throw TypeError("max must be a number");if(e>=r)throw RangeError("min must be smaller than max");let o=new M(this.rows,this.columns);for(let t=0;tr||e<0||e>=this.columns||r<0||r>=this.columns)throw RangeError("Argument out of range");let o=new M(t.length,r-e+1);for(let i=0;i=this.rows)throw RangeError(`Row index out of range: ${t[i]}`);o.set(i,n-e,this.get(t[i],n))}return o}subMatrixColumn(t,e,r){if(void 0===e&&(e=0),void 0===r&&(r=this.rows-1),e>r||e<0||e>=this.rows||r<0||r>=this.rows)throw RangeError("Argument out of range");let o=new M(r-e+1,t.length);for(let i=0;i=this.columns)throw RangeError(`Column index out of range: ${t[i]}`);o.set(n-e,i,this.get(n,t[i]))}return o}setSubMatrix(t,e,r){if((t=M.checkMatrix(t)).isEmpty())return this;let o=e+t.rows-1,i=r+t.columns-1;p(this,e,o,r,i);for(let o=0;o=0)for(let r=0;r=0)this.#t(t,e);else if(o.isAnyArray(t)){let r=t;if("number"!=typeof(e=(t=r.length)?r[0].length:0))throw TypeError("Data must be a 2D array with at least one element");this.data=[];for(let o=0;o"number"==typeof t))throw TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(r[o]))}this.rows=t,this.columns=e}else throw TypeError("First argument must be a positive number or an array")}set(t,e,r){return this.data[t][e]=r,this}get(t,e){return this.data[t][e]}removeRow(t){return u(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),u(this,t,!0),e=Float64Array.from(f(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){l(this,t);for(let e=0;e>t);return this},v.prototype.signPropagatingRightShiftM=function(t){if(t=M.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw RangeError("Matrices dimensions must be equal");for(let e=0;e>t.get(e,r));return this},v.signPropagatingRightShift=function(t,e){return new M(t).signPropagatingRightShift(e)},v.prototype.rightShift=function(t){return"number"==typeof t?this.rightShiftS(t):this.rightShiftM(t)},v.prototype.rightShiftS=function(t){for(let e=0;e>>t);return this},v.prototype.rightShiftM=function(t){if(t=M.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw RangeError("Matrices dimensions must be equal");for(let e=0;e>>t.get(e,r));return this},v.rightShift=function(t,e){return new M(t).rightShift(e)},v.prototype.zeroFillRightShift=v.prototype.rightShift,v.prototype.zeroFillRightShiftS=v.prototype.rightShiftS,v.prototype.zeroFillRightShiftM=v.prototype.rightShiftM,v.zeroFillRightShift=v.rightShift,v.prototype.not=function(){for(let t=0;t=0)this.#e=new M(t,t);else if(this.#e=new M(t),!this.isSymmetric())throw TypeError("not symmetric data")}clone(){let t=new x(this.diagonalSize);for(let[e,r,o]of this.upperRightEntries())t.set(e,r,o);return t}toMatrix(){return new M(this)}get(t,e){return this.#e.get(t,e)}set(t,e,r){return this.#e.set(t,e,r),this.#e.set(e,t,r),this}removeCross(t){return this.#e.removeRow(t),this.#e.removeColumn(t),this}addCross(t,e){void 0===e&&(e=t,t=this.diagonalSize);let r=e.slice();return r.splice(t,1),this.#e.addRow(t,r),this.#e.addColumn(t,e),this}applyMask(t){if(t.length!==this.diagonalSize)throw RangeError("Mask size do not match with matrix size");let e=[];for(let[r,o]of t.entries())o||e.push(r);for(let t of(e.reverse(),e))this.removeCross(t);return this}toCompact(){let{diagonalSize:t}=this,e=Array(t*(t+1)/2);for(let r=0,o=0,i=0;i=t&&(r=++o);return e}static fromCompact(t){let e=t.length,r=(Math.sqrt(8*e+1)-1)/2;if(!Number.isInteger(r))throw TypeError(`This array is not a compact representation of a Symmetric Matrix, ${JSON.stringify(t)}`);let o=new x(r);for(let i=0,n=0,s=0;s=r&&(i=++n);return o}*upperRightEntries(){for(let t=0,e=0;t=this.diagonalSize&&(e=++t)}}*upperRightValues(){for(let t=0,e=0;t=this.diagonalSize&&(e=++t)}}}x.prototype.klassType="SymmetricMatrix";class S extends x{static isDistanceMatrix(t){return x.isSymmetricMatrix(t)&&"DistanceMatrix"===t.klassSubType}constructor(t){if(super(t),!this.isDistance())throw TypeError("Provided arguments do no produce a distance matrix")}set(t,e,r){return t===e&&(r=0),super.set(t,e,r)}addCross(t,e){return void 0===e&&(e=t,t=this.diagonalSize),(e=e.slice())[t]=0,super.addCross(t,e)}toSymmetricMatrix(){return new x(this)}clone(){let t=new S(this.diagonalSize);for(let[e,r,o]of this.upperRightEntries())e!==r&&t.set(e,r,o);return t}toCompact(){let{diagonalSize:t}=this,e=Array((t-1)*t/2);for(let r=1,o=0,i=0;i=t&&(r=++o+1);return e}static fromCompact(t){let e=t.length,r=(Math.sqrt(8*e+1)+1)/2;if(!Number.isInteger(r))throw TypeError(`This array is not a compact representation of a DistanceMatrix, ${JSON.stringify(t)}`);let o=new this(r);for(let i=1,n=0,s=0;s=r&&(i=++n+1);return o}}S.prototype.klassSubType="DistanceMatrix";class E extends v{constructor(t,e,r){super(),this.matrix=t,this.rows=e,this.columns=r}}class R extends E{constructor(t,e){l(t,e),super(t,t.rows,1),this.column=e}set(t,e,r){return this.matrix.set(t,this.column,r),this}get(t){return this.matrix.get(t,this.column)}}class k extends E{constructor(t,e){g(t,e),super(t,t.rows,e.length),this.columnIndices=e}set(t,e,r){return this.matrix.set(t,this.columnIndices[e],r),this}get(t,e){return this.matrix.get(t,this.columnIndices[e])}}class N extends E{constructor(t){super(t,t.rows,t.columns)}set(t,e,r){return this.matrix.set(t,this.columns-e-1,r),this}get(t,e){return this.matrix.get(t,this.columns-e-1)}}class z extends E{constructor(t){super(t,t.rows,t.columns)}set(t,e,r){return this.matrix.set(this.rows-t-1,e,r),this}get(t,e){return this.matrix.get(this.rows-t-1,e)}}class _ extends E{constructor(t,e){u(t,e),super(t,1,t.columns),this.row=e}set(t,e,r){return this.matrix.set(this.row,e,r),this}get(t,e){return this.matrix.get(this.row,e)}}class A extends E{constructor(t,e){m(t,e),super(t,e.length,t.columns),this.rowIndices=e}set(t,e,r){return this.matrix.set(this.rowIndices[t],e,r),this}get(t,e){return this.matrix.get(this.rowIndices[t],e)}}class P extends E{constructor(t,e,r){m(t,e),g(t,r),super(t,e.length,r.length),this.rowIndices=e,this.columnIndices=r}set(t,e,r){return this.matrix.set(this.rowIndices[t],this.columnIndices[e],r),this}get(t,e){return this.matrix.get(this.rowIndices[t],this.columnIndices[e])}}class I extends E{constructor(t,e,r,o,i){p(t,e,r,o,i),super(t,r-e+1,i-o+1),this.startRow=e,this.startColumn=o}set(t,e,r){return this.matrix.set(this.startRow+t,this.startColumn+e,r),this}get(t,e){return this.matrix.get(this.startRow+t,this.startColumn+e)}}class O extends E{constructor(t){super(t,t.columns,t.rows)}set(t,e,r){return this.matrix.set(e,t,r),this}get(t,e){return this.matrix.get(e,t)}}class C extends v{constructor(t,e={}){let{rows:r=1}=e;if(t.length%r!=0)throw Error("the data length is not divisible by the number of rows");super(),this.rows=r,this.columns=t.length/r,this.data=t}set(t,e,r){let o=this._calculateIndex(t,e);return this.data[o]=r,this}get(t,e){let r=this._calculateIndex(t,e);return this.data[r]}_calculateIndex(t,e){return t*this.columns+e}}class T extends v{constructor(t){super(),this.data=t,this.rows=t.length,this.columns=t[0].length}set(t,e,r){return this.data[t][e]=r,this}get(t,e){return this.data[t][e]}}class j{constructor(t){let e,r,o,i,n,s,a,h,u;let l=(t=T.checkMatrix(t)).clone(),f=l.rows,c=l.columns,m=new Float64Array(f),g=1;for(e=0;eMath.abs(h[i])&&(i=e);if(i!==r){for(o=0;o=0;o--){for(r=0;re?o.set(i,e,t.get(i,e)):i===e?o.set(i,e,1):o.set(i,e,0);return o}get upperTriangularMatrix(){let t=this.LU,e=t.rows,r=t.columns,o=new M(e,r);for(let i=0;iMath.abs(e)?(r=e/t,Math.abs(t)*Math.sqrt(1+r*r)):0!==e?(r=t/e,Math.abs(e)*Math.sqrt(1+r*r)):0}class D{constructor(t){let e,r,o,i;let n=(t=T.checkMatrix(t)).clone(),s=t.rows,a=t.columns,h=new Float64Array(a);for(o=0;on.get(o,o)&&(t=-t),e=o;e=0;o--){for(r=0;r=0;r--){for(t=0;tr.get(t,t)&&(m[t]=-m[t]);for(let e=t;e=0;t--)if(0!==m[t]){for(let e=t+1;e=0;t--){if(t0;){let t,e;for(t=S-2;t>=-1&&-1!==t;t--){let e=Number.MIN_VALUE+R*Math.abs(m[t]+Math.abs(m[t+1]));if(Math.abs(d[t])<=e||Number.isNaN(d[t])){d[t]=0;break}}if(t===S-2)e=4;else{let r;for(r=S-1;r>=t&&r!==t;r--){let e=(r!==S?Math.abs(d[r]):0)+(r!==t+1?Math.abs(d[r-1]):0);if(Math.abs(m[r])<=R*e){m[r]=0;break}}r===t?e=3:r===S-1?e=1:(e=2,t=r)}switch(t++,e){case 1:{let e=d[S-2];d[S-2]=0;for(let r=S-2;r>=t;r--){let o=F(m[r],e),n=m[r]/o,s=e/o;if(m[r]=o,r!==t&&(e=-s*d[r-1],d[r-1]=n*d[r-1]),u)for(let t=0;t=m[t+1]);){let e=m[t];if(m[t]=m[t+1],m[t+1]=e,u&&te&&i.set(n,r,t.get(n,r)/this.s[r]);let n=this.U,s=n.rows,a=n.columns,h=new M(r,s);for(let t=0;tt&&e++;return e}get diagonal(){return Array.from(this.s)}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return M.diag(this.s)}}function q(t,e,r=!1){return(t=T.checkMatrix(t),e=T.checkMatrix(e),r)?new V(t).solve(e):t.isSquare()?new j(t).solve(e):new D(t).solve(e)}class L{constructor(t,e={}){let r,o;let{assumeSymmetric:i=!1}=e;if(!(t=T.checkMatrix(t)).isSquare())throw Error("Matrix is not a square matrix");if(t.isEmpty())throw Error("Matrix must be non-empty");let n=t.columns,s=new M(n,n),a=new Float64Array(n),h=new Float64Array(n),u=t;if(i||t.isSymmetric()){for(r=0;r0;a--){for(u=0,f=0,s=0;u0&&(n=-n),e[a]=f*n,s-=i*n,r[a-1]=i-n,h=0;hu)do{for(i=r[u],c=F(f=(r[u+1]-i)/(2*e[u]),1),f<0&&(c=-c),r[u]=e[u]/(f+c),r[u+1]=e[u]*(f+c),m=r[u+1],n=i-r[u],s=u+2;s=u;s--)for(h=0,d=p,p=g,v=y,i=g*e[s],n=g*f,c=F(f,e[s]),e[s+1]=y*c,y=e[s]/c,f=(g=f/c)*r[s]-y*i,r[s+1]=n+y*(g*i+y*r[s]);hx*M);r[u]=r[u]+b,e[u]=0}for(s=0;s=u;a--)r[a]=e.get(a,u-1)/l,s+=r[a]*r[a];for(n=Math.sqrt(s),r[u]>0&&(n=-n),s-=r[u]*n,r[u]=r[u]-n,h=u;h=u;a--)i+=r[a]*e.get(a,h);for(i/=s,a=u;a<=f;a++)e.set(a,h,e.get(a,h)-i*r[a])}for(a=0;a<=f;a++){for(i=0,h=f;h>=u;h--)i+=r[h]*e.get(a,h);for(i/=s,h=u;h<=f;h++)e.set(a,h,e.get(a,h)-i*r[h])}r[u]=l*r[u],e.set(u,u-1,l*n)}}for(a=0;a=1;u--)if(0!==e.get(u,u-1)){for(a=u+1;a<=f;a++)r[a]=e.get(a,u-1);for(h=u;h<=f;h++){for(n=0,a=u;a<=f;a++)n+=r[a]*o.get(a,h);for(n=n/r[u]/e.get(u,u-1),a=u;a<=f;a++)o.set(a,h,o.get(a,h)+n*r[a])}}})(n,t,e,s),function(t,e,r,o,i){let n,s,a,h,u,l,f,c,m,g,p,d,w,y,v,b=t-1,M=t-1,x=Number.EPSILON,S=0,E=0,R=0,k=0,N=0,z=0,_=0,A=0;for(n=0;nM)&&(r[n]=i.get(n,n),e[n]=0),s=Math.max(n-1,0);s=0;){for(h=b;h>0&&(0===(z=Math.abs(i.get(h-1,h-1))+Math.abs(i.get(h,h)))&&(z=E),!(Math.abs(i.get(h,h-1))=0){for(_=R>=0?R+_:R-_,r[b-1]=c+_,r[b]=r[b-1],0!==_&&(r[b]=c-f/_),e[b-1]=0,e[b]=0,z=Math.abs(c=i.get(b,b-1))+Math.abs(_),N=Math.sqrt((R=c/z)*R+(k=_/z)*k),R/=N,k/=N,s=b-1;s0){for(z=Math.sqrt(z),m=h&&(z=Math.abs(R=((N=c-(_=i.get(u,u)))*(z=m-_)-f)/i.get(u+1,u)+i.get(u,u+1))+Math.abs(k=i.get(u+1,u+1)-_-N-z)+Math.abs(N=i.get(u+2,u+1)),R/=z,k/=z,N/=z,!(u===h||Math.abs(i.get(u,u-1))*(Math.abs(k)+Math.abs(N))u+2&&i.set(n,n-3,0);for(a=u;a<=b-1&&(y=a!==b-1,a!==u&&0!==(c=Math.abs(R=i.get(a,a-1))+Math.abs(k=i.get(a+1,a-1))+Math.abs(N=y?i.get(a+2,a-1):0))&&(R/=c,k/=c,N/=c),0!==c);a++)if(z=Math.sqrt(R*R+k*k+N*N),R<0&&(z=-z),0!==z){for(a!==u?i.set(a,a-1,-z*c):h!==u&&i.set(a,a-1,-i.get(a,a-1)),R+=z,c=R/z,m=k/z,_=N/z,k/=R,N/=R,s=a;s=0;b--)if(R=r[b],0===(k=e[b]))for(h=b,i.set(b,b,1),n=b-1;n>=0;n--){for(f=i.get(n,n)-R,N=0,s=h;s<=b;s++)N+=i.get(n,s)*i.get(s,b);if(e[n]<0)_=f,z=N;else if(h=n,0===e[n]?i.set(n,b,0!==f?-N/f:-N/(x*E)):(c=i.get(n,n+1),m=i.get(n+1,n),l=(c*z-_*N)/(k=(r[n]-R)*(r[n]-R)+e[n]*e[n]),i.set(n,b,l),i.set(n+1,b,Math.abs(c)>Math.abs(_)?(-N-f*l)/c:(-z-m*l)/_)),x*(l=Math.abs(i.get(n,b)))*l>1)for(s=n;s<=b;s++)i.set(s,b,i.get(s,b)/l)}else if(k<0)for(h=b-1,Math.abs(i.get(b,b-1))>Math.abs(i.get(b-1,b))?(i.set(b-1,b-1,k/i.get(b,b-1)),i.set(b-1,b,-(i.get(b,b)-R)/i.get(b,b-1))):(v=U(0,-i.get(b-1,b),i.get(b-1,b-1)-R,k),i.set(b-1,b-1,v[0]),i.set(b-1,b,v[1])),i.set(b,b-1,0),i.set(b,b,1),n=b-2;n>=0;n--){for(g=0,p=0,s=h;s<=b;s++)g+=i.get(n,s)*i.get(s,b-1),p+=i.get(n,s)*i.get(s,b);if(f=i.get(n,n)-R,e[n]<0)_=f,N=g,z=p;else if(h=n,0===e[n]?(v=U(-g,-p,f,k),i.set(n,b-1,v[0]),i.set(n,b,v[1])):(c=i.get(n,n+1),m=i.get(n+1,n),d=(r[n]-R)*(r[n]-R)+e[n]*e[n]-k*k,w=(r[n]-R)*2*k,0===d&&0===w&&(d=x*E*(Math.abs(f)+Math.abs(k)+Math.abs(c)+Math.abs(m)+Math.abs(_))),v=U(c*N-_*g+k*p,c*z-_*p-k*g,d,w),i.set(n,b-1,v[0]),i.set(n,b,v[1]),Math.abs(c)>Math.abs(_)+Math.abs(k)?(i.set(n+1,b-1,(-g-f*i.get(n,b-1)+k*i.get(n,b))/c),i.set(n+1,b,(-p-f*i.get(n,b)-k*i.get(n,b-1))/c)):(v=U(-N-m*i.get(n,b-1),-z-m*i.get(n,b),_,k),i.set(n+1,b-1,v[0]),i.set(n+1,b,v[1]))),x*(l=Math.max(Math.abs(i.get(n,b-1)),Math.abs(i.get(n,b))))*l>1)for(s=n;s<=b;s++)i.set(s,b-1,i.get(s,b-1)/l),i.set(s,b,i.get(s,b)/l)}for(n=0;nM)for(s=n;s=0;s--)for(n=0;n<=M;n++){for(a=0,_=0;a<=Math.min(s,M);a++)_+=o.get(n,a)*i.get(a,s);o.set(n,s,_)}}}(n,h,a,s,t)}this.n=n,this.e=h,this.d=a,this.V=s}get realEigenvalues(){return Array.from(this.d)}get imaginaryEigenvalues(){return Array.from(this.e)}get eigenvectorMatrix(){return this.V}get diagonalMatrix(){let t,e,r=this.n,o=this.e,i=this.d,n=new M(r,r);for(t=0;t0?n.set(t,t+1,o[t]):o[t]<0&&n.set(t,t-1,o[t])}return n}}function U(t,e,r,o){let i,n;return Math.abs(r)>Math.abs(o)?(i=o/r,n=r+i*o,[(t+i*e)/n,(e-i*t)/n]):(i=r/o,n=o+i*r,[(i*t+e)/n,(i*e-t)/n])}class H{constructor(t){let e,r,o;if(!(t=T.checkMatrix(t)).isSymmetric())throw Error("Matrix is not symmetric");let i=t,n=i.rows,s=new M(n,n),a=!0;for(r=0;r0,s.set(r,r,Math.sqrt(Math.max(t,0))),o=r+1;o=0;o--)for(r=0;rf;e++)s=(s=t.transpose().mmul(r).div(r.transpose().mmul(r).get(0,0))).div(s.norm()),i=t.mmul(s).div(s.transpose().mmul(s).get(0,0)),e>0&&(c=i.clone().sub(a).pow(2).sum()),a=i.clone(),h?(n=(n=h.transpose().mmul(i).div(i.transpose().mmul(i).get(0,0))).div(n.norm()),r=h.mmul(n).div(n.transpose().mmul(n).get(0,0))):r=i;if(h){let e=t.transpose().mmul(i).div(i.transpose().mmul(i).get(0,0));e=e.div(e.norm());let o=t.clone().sub(i.clone().mmul(e.transpose())),a=r.transpose().mmul(i).div(i.transpose().mmul(i).get(0,0)),u=h.clone().sub(i.clone().mulS(a.get(0,0)).mmul(n.transpose()));this.t=i,this.p=e.transpose(),this.w=s.transpose(),this.q=n,this.u=r,this.s=i.transpose().mmul(i),this.xResidual=o,this.yResidual=u,this.betas=a}else this.w=s.transpose(),this.s=i.transpose().mmul(i).sqrt(),u?this.t=i.clone().div(this.s.get(0,0)):this.t=i,this.xResidual=t.sub(i.mmul(s.transpose()))}}e.XA=v,e.a_=H,e.yQ=H,e.Hs=S,e.Ec=L,e.dx=L,e.LU=j,e.Rm=j,e.y3=M,e.qK=k,e.pb=R,e.j=N,e.sO=z,e.BZ=A,e.EK=_,e.Db=P,e.Fx=I,e.tU=O,e.Ym=$,e.rs=$,e.QR=D,e.TB=D,e.oH=V,e.Sc=V,e.BN=x,e.it=C,e.$r=T,e.QM=function(t,e=t,r={}){t=new M(t);let i=!1;if("object"!=typeof e||M.isMatrix(e)||o.isAnyArray(e)?e=new M(e):(r=e,e=t,i=!0),t.rows!==e.rows)throw TypeError("Both matrices must have the same number of rows");let{center:n=!0,scale:s=!0}=r;n&&(t.center("column"),i||e.center("column")),s&&(t.scale("column"),i||e.scale("column"));let a=t.standardDeviation("column",{unbiased:!0}),h=i?a:e.standardDeviation("column",{unbiased:!0}),u=t.transpose().mmul(e);for(let e=0;ei)return Array(e.rows+1).fill(0);{let t=e.addRow(r,[0]);for(let e=0;ee?n[t]=1/n[t]:n[t]=0;return i.mmul(M.diag(n).mmul(o.transpose()))},e.F1=q,e.re=function(t,e){if(o.isAnyArray(t))return t[0]&&o.isAnyArray(t[0])?new T(t):new C(t,e);throw Error("the argument is not an array")}},19068:function(t,e,r){"use strict";r.r(e),r.d(e,{isAnyArray:function(){return i}});let o=Object.prototype.toString;function i(t){let e=o.call(t);return e.endsWith("Array]")&&!e.includes("Big")}},99949:function(t,e,r){"use strict";var o=r(88877);function i(){}function n(){}n.resetWarningCache=i,t.exports=function(){function t(t,e,r,i,n,s){if(s!==o){var a=Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw a.name="Invariant Violation",a}}function e(){return t}t.isRequired=t;var r={array:t,bigint:t,bool:t,func:t,number:t,object:t,string:t,symbol:t,any:t,arrayOf:e,element:t,elementType:t,instanceOf:e,node:t,objectOf:e,oneOf:e,oneOfType:e,shape:e,exact:e,checkPropTypes:n,resetWarningCache:i};return r.PropTypes=r,r}},41448:function(t,e,r){t.exports=r(99949)()},88877:function(t){"use strict";t.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},86108:function(t,e,r){"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)}Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t){var e=function(e){!function(t,e){if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&h(t,e)}(a,e);var r,i,s=(r=function(){if("undefined"==typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}(),function(){var t,e=l(a);return t=r?Reflect.construct(e,arguments,l(this).constructor):e.apply(this,arguments),function(t,e){if(e&&("object"===o(e)||"function"==typeof e))return e;if(void 0!==e)throw TypeError("Derived constructors may only return object or undefined");return u(t)}(this,t)});function a(t){var e;return function(t,e){if(!(t instanceof e))throw TypeError("Cannot call a class as a function")}(this,a),(e=s.call(this,t)).p=Promise.resolve(),e.resizeHandler=null,e.handlers={},e.syncWindowResize=e.syncWindowResize.bind(u(e)),e.syncEventHandlers=e.syncEventHandlers.bind(u(e)),e.attachUpdateEvents=e.attachUpdateEvents.bind(u(e)),e.getRef=e.getRef.bind(u(e)),e.handleUpdate=e.handleUpdate.bind(u(e)),e.figureCallback=e.figureCallback.bind(u(e)),e.updatePlotly=e.updatePlotly.bind(u(e)),e}return i=[{key:"updatePlotly",value:function(e,r,o){var i=this;this.p=this.p.then(function(){if(!i.unmounting){if(!i.el)throw Error("Missing element reference");return t.react(i.el,{data:i.props.data,layout:i.props.layout,config:i.props.config,frames:i.props.frames})}}).then(function(){!i.unmounting&&(i.syncWindowResize(e),i.syncEventHandlers(),i.figureCallback(r),o&&i.attachUpdateEvents())}).catch(function(t){i.props.onError&&i.props.onError(t)})}},{key:"componentDidMount",value:function(){this.unmounting=!1,this.updatePlotly(!0,this.props.onInitialized,!0)}},{key:"componentDidUpdate",value:function(t){this.unmounting=!1;var e=t.frames&&t.frames.length?t.frames.length:0,r=this.props.frames&&this.props.frames.length?this.props.frames.length:0,o=!(t.layout===this.props.layout&&t.data===this.props.data&&t.config===this.props.config&&r===e),i=void 0!==t.revision,n=t.revision!==this.props.revision;(o||i&&(!i||n))&&this.updatePlotly(!1,this.props.onUpdate,!1)}},{key:"componentWillUnmount",value:function(){this.unmounting=!0,this.figureCallback(this.props.onPurge),this.resizeHandler&&m&&(window.removeEventListener("resize",this.resizeHandler),this.resizeHandler=null),this.removeUpdateEvents(),t.purge(this.el)}},{key:"attachUpdateEvents",value:function(){var t=this;this.el&&this.el.removeListener&&c.forEach(function(e){t.el.on(e,t.handleUpdate)})}},{key:"removeUpdateEvents",value:function(){var t=this;this.el&&this.el.removeListener&&c.forEach(function(e){t.el.removeListener(e,t.handleUpdate)})}},{key:"handleUpdate",value:function(){this.figureCallback(this.props.onUpdate)}},{key:"figureCallback",value:function(t){if("function"==typeof t){var e=this.el;t({data:e.data,layout:e.layout,frames:this.el._transitionData?this.el._transitionData._frames:null},this.el)}}},{key:"syncWindowResize",value:function(e){var r=this;m&&(this.props.useResizeHandler&&!this.resizeHandler?(this.resizeHandler=function(){return t.Plots.resize(r.el)},window.addEventListener("resize",this.resizeHandler),e&&this.resizeHandler()):!this.props.useResizeHandler&&this.resizeHandler&&(window.removeEventListener("resize",this.resizeHandler),this.resizeHandler=null))}},{key:"getRef",value:function(t){this.el=t,this.props.debug&&m&&(window.gd=this.el)}},{key:"syncEventHandlers",value:function(){var t=this;f.forEach(function(e){var r=t.props["on"+e],o=t.handlers[e],i=!!o;r&&!i?t.addEventHandler(e,r):!r&&i?t.removeEventHandler(e):r&&i&&r!==o&&(t.removeEventHandler(e),t.addEventHandler(e,r))})}},{key:"addEventHandler",value:function(t,e){this.handlers[t]=e,this.el.on(this.getPlotlyEventName(t),this.handlers[t])}},{key:"removeEventHandler",value:function(t){this.el.removeListener(this.getPlotlyEventName(t),this.handlers[t]),delete this.handlers[t]}},{key:"getPlotlyEventName",value:function(t){return"plotly_"+t.toLowerCase()}},{key:"render",value:function(){return n.default.createElement("div",{id:this.props.divId,style:this.props.style,ref:this.getRef,className:this.props.className})}}],function(t,e){for(var r=0;r=s[0])return 0;for(var a=0;a=s[0])return 0;s[0]=r,n[0]=o,a[0]=i;for(var h=0,u=0;;){var l=2*h+1,f=l+1,c=t[0][0].length;if(l>=c)break;if(f>=c){if(s[l]>r)u=l;else break}else if(s[l]>=s[f]){if(rr.length;a++)1===i[a]&&o[a]=0?(i[s]=0,Math.floor(r[s])):-1}},5778:function(t,e,r){"use strict";var o=r(28158);Object.defineProperty(e,"u",{enumerable:!0,get:function(){return o.UMAP}})},78965:function(t,e,r){"use strict";var o,i=this&&this.__createBinding||(Object.create?function(t,e,r,o){void 0===o&&(o=r),Object.defineProperty(t,o,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,o){void 0===o&&(o=r),t[o]=e[r]}),n=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),s=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)"default"!==r&&Object.hasOwnProperty.call(t,r)&&i(e,t,r);return n(e,t),e},a=this&&this.__read||function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var o,i,n=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(o=n.next()).done;)s.push(o.value)}catch(t){i={error:t}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(i)throw i.error}}return s},h=this&&this.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],o=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&o>=t.length&&(t=void 0),{value:t&&t[o++],done:!t}}};throw TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(e,"__esModule",{value:!0}),e.getCSR=e.normalize=e.eliminateZeros=e.multiplyScalar=e.maximum=e.subtract=e.add=e.pairwiseMultiply=e.identity=e.transpose=e.SparseMatrix=void 0;var u=s(r(10006)),l=function(){function t(t,e,r,o){if(this.entries=new Map,this.nRows=0,this.nCols=0,t.length!==e.length||t.length!==r.length)throw Error("rows, cols and values arrays must all have the same length");this.nRows=o[0],this.nCols=o[1];for(var i=0;ie?t:e})},e.multiplyScalar=function(t,e){return t.map(function(t){return t*e})},e.eliminateZeros=function(t){for(var e=new Set,r=t.getValues(),o=t.getRows(),i=t.getCols(),n=0;ne?t[r]:e;return t.map(function(t){return t/e})},o.l1=function(t){for(var e=0,r=0;r=t.length&&(t=void 0),{value:t&&t[o++],done:!t}}};throw TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(e,"__esModule",{value:!0}),e.initializeSearch=e.makeInitializedNNSearch=e.makeInitializations=e.makeNNDescent=void 0;var a=n(r(35230)),h=n(r(78965)),u=n(r(50993)),l=n(r(10006));e.makeNNDescent=function(t,e){return function(r,o,i,n,s,h,u,f){void 0===n&&(n=10),void 0===s&&(s=50),void 0===h&&(h=.001),void 0===u&&(u=.5),void 0===f&&(f=!0);for(var c=r.length,m=a.makeHeap(r.length,i),g=0;g0)&&!(o=n.next()).done;)s.push(o.value)}catch(t){i={error:t}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(i)throw i.error}}return s},a=this&&this.__spread||function(){for(var t=[],e=0;e=t.length&&(t=void 0),{value:t&&t[o++],done:!t}}};throw TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(e,"__esModule",{value:!0}),e.searchFlatTree=e.makeLeafArray=e.makeForest=e.FlatTree=void 0;var u=n(r(10006)),l=function(t,e,r,o){this.hyperplanes=t,this.offsets=e,this.children=r,this.indices=o};e.FlatTree=l,e.makeForest=function(t,e,r,o){var i=Math.max(10,e);return u.range(r).map(function(e,r){var n,s;return void 0===(n=i)&&(n=30),s=u.range(t.length),function t(e,r,o,i,n){if(void 0===o&&(o=30),r.length>o){var s=function(t,e,r){var o=t[0].length,i=u.tauRandInt(e.length,r),n=u.tauRandInt(e.length,r);n+=i===n?1:0,n%=e.length;for(var s=e[i],a=e[n],h=0,l=u.zeros(o),f=0;f0?(g[f]=0,c+=1):(g[f]=1,m+=1)}var w=u.zeros(c),y=u.zeros(m);c=0,m=0;for(var f=0;f0))return[[-1]];var e,r,o=[];try{for(var i=h(t),n=i.next();!n.done;n=i.next()){var s=n.value;o.push.apply(o,a(s.indices))}}catch(t){e={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}return o},e.searchFlatTree=function(t,e,r){for(var o=0;e.children[o][0]>0;)o=0===function(t,e,r,o){for(var i=e,n=0;n0?0:1}(e.hyperplanes[o],e.offsets[o],t,r)?e.children[o][0]:e.children[o][1];var i=-1*e.children[o][0];return e.indices[i]}},28158:function(t,e,r){"use strict";var o=this&&this.__createBinding||(Object.create?function(t,e,r,o){void 0===o&&(o=r),Object.defineProperty(t,o,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,o){void 0===o&&(o=r),t[o]=e[r]}),i=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),n=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)"default"!==r&&Object.hasOwnProperty.call(t,r)&&o(e,t,r);return i(e,t),e},s=this&&this.__awaiter||function(t,e,r,o){return new(r||(r=Promise))(function(i,n){function s(t){try{h(o.next(t))}catch(t){n(t)}}function a(t){try{h(o.throw(t))}catch(t){n(t)}}function h(t){var e;t.done?i(t.value):((e=t.value)instanceof r?e:new r(function(t){t(e)})).then(s,a)}h((o=o.apply(t,e||[])).next())})},a=this&&this.__generator||function(t,e){var r,o,i,n,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return n={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(n[Symbol.iterator]=function(){return this}),n;function a(n){return function(a){return function(n){if(r)throw TypeError("Generator is already executing.");for(;s;)try{if(r=1,o&&(i=2&n[0]?o.return:n[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,n[1])).done)return i;switch(o=0,i&&(n=[2&n[0],i.value]),n[0]){case 0:case 1:i=n;break;case 4:return s.label++,{value:n[1],done:!1};case 5:s.label++,o=n[1],n=[0];continue;case 7:n=s.ops.pop(),s.trys.pop();continue;default:if(!(i=(i=s.trys).length>0&&i[i.length-1])&&(6===n[0]||2===n[0])){s=0;continue}if(3===n[0]&&(!i||n[1]>i[0]&&n[1]0)&&!(o=n.next()).done;)s.push(o.value)}catch(t){i={error:t}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(i)throw i.error}}return s},u=this&&this.__spread||function(){for(var t=[],e=0;e0&&i.set(n,u,l)}var f=c.transpose(i);return c.maximum(i,f)},t.prototype.transform=function(t){var e=this,r=this.X;if(void 0===r||0===r.length)throw Error("No data has been fit.");var o=Math.floor(this.nNeighbors*this.transformQueueSize);o=Math.min(r.length,o);var i=m.initializeSearch(this.rpForest,r,t,o,this.initFromRandom,this.initFromTree,this.random),n=this.search(r,this.searchGraph,i,t),s=f.deheapSort(n),a=s.indices,h=s.weights;a=a.map(function(t){return t.slice(0,e.nNeighbors)}),h=h.map(function(t){return t.slice(0,e.nNeighbors)});var u=Math.max(0,this.localConnectivity-1),l=this.smoothKNNDistance(h,this.nNeighbors,u),g=l.sigmas,d=l.rhos,w=this.computeMembershipStrengths(a,h,g,d),y=w.rows,v=w.cols,b=w.vals,M=[t.length,r.length],x=new c.SparseMatrix(y,v,b,M),S=c.normalize(x,"l1"),E=c.getCSR(S),k=t.length,N=R(p.reshape2d(E.indices,k,this.nNeighbors),p.reshape2d(E.values,k,this.nNeighbors),this.embedding),z=this.nEpochs?this.nEpochs/3:x.nRows<=1e4?100:30,_=x.getValues().reduce(function(t,e){return e>t?e:t},0);x=x.map(function(t){return t<_/z?0:t}),x=c.eliminateZeros(x);var A=this.makeEpochsPerSample(x.getValues(),z),P=x.getRows(),I=x.getCols();return this.assignOptimizationStateParameters({headEmbedding:N,tailEmbedding:this.embedding,head:P,tail:I,currentEpoch:0,nEpochs:z,nVertices:x.getDims()[1],epochsPerSample:A}),this.prepareForOptimizationLoop(),this.optimizeLayout()},t.prototype.processGraphForSupervisedProjection=function(){var t=this.Y,e=this.X;if(t){if(t.length!==e.length)throw Error("Length of X and y must be equal");if("categorical"===this.targetMetric){var r=this.targetWeight<1?1/(1-this.targetWeight)*2.5:1e12;this.graph=this.categoricalSimplicialSetIntersection(this.graph,t,r)}}},t.prototype.step=function(){var t=this.optimizationState.currentEpoch;return t0});if(m.length>=r){var g=Math.floor(r),d=r-g;g>0?(s[h]=m[g-1],d>1e-5&&(s[h]+=d*(m[g]-m[g-1]))):s[h]=d*m[0]}else m.length>0&&(s[h]=p.max(m));for(var w=0;w0?y+=Math.exp(-(b/f)):y+=1}if(1e-5>Math.abs(y-n))break;y>n?f=(u+(l=f))/2:(u=f,l===1/0?f*=2:f=(u+l)/2)}if(a[h]=f,s[h]>0){var M=p.mean(c);a[h]<.001*M&&(a[h]=.001*M)}else{var x=p.mean(t.map(p.mean));a[h]<.001*x&&(a[h]=.001*x)}}return{sigmas:a,rhos:s}},t.prototype.computeMembershipStrengths=function(t,e,r,o){for(var i=t.length,n=t[0].length,s=p.zeros(i*n),a=p.zeros(i*n),h=p.zeros(i*n),u=0;u0&&(r[o]=e/i[o])}),r},t.prototype.assignOptimizationStateParameters=function(t){Object.assign(this.optimizationState,t)},t.prototype.prepareForOptimizationLoop=function(){var t=this.repulsionStrength,e=this.learningRate,r=this.negativeSampleRate,o=this.optimizationState,i=o.epochsPerSample,n=o.headEmbedding,s=o.tailEmbedding,a=n[0].length,h=n.length===s.length,l=i.map(function(t){return t/r}),f=u(l),c=u(i);this.assignOptimizationStateParameters({epochOfNextSample:c,epochOfNextNegativeSample:f,epochsPerNegativeSample:l,moveOther:h,initialAlpha:e,alpha:e,gamma:t,dim:a})},t.prototype.initializeOptimization=function(){var t=this.embedding,e=this.embedding,r=this.optimizationState,o=r.head,i=r.tail,n=r.epochsPerSample,s=this.getNEpochs(),a=this.graph.nCols,h=x(this.spread,this.minDist),u=h.a,l=h.b;this.assignOptimizationStateParameters({headEmbedding:t,tailEmbedding:e,head:o,tail:i,epochsPerSample:n,a:u,b:l,nEpochs:s,nVertices:a})},t.prototype.optimizeLayoutStep=function(t){for(var e=this.optimizationState,r=e.head,o=e.tail,i=e.headEmbedding,n=e.tailEmbedding,s=e.epochsPerSample,a=e.epochOfNextSample,h=e.epochOfNextNegativeSample,u=e.epochsPerNegativeSample,l=e.moveOther,f=e.initialAlpha,c=e.alpha,m=e.gamma,g=e.a,d=e.b,w=e.dim,y=e.nEpochs,v=e.nVertices,x=0;xt)){var S=r[x],E=o[x],R=i[S],k=n[E],N=M(R,k),z=0;N>0&&(z=-2*g*d*Math.pow(N,d-1)/(g*Math.pow(N,d)+1));for(var _=0;_0)j=2*m*d/((.001+T)*(g*Math.pow(T,d)+1));else if(S===O)continue;for(var _=0;_0&&(A=b(j*(R[_]-C[_]),4)),R[_]+=A*c}}h[x]+=P*u[x]}return e.alpha=f*(1-t/y),e.currentEpoch+=1,i},t.prototype.optimizeLayoutAsync=function(t){var e=this;return void 0===t&&(t=function(){return!0}),new Promise(function(r,o){var i=function(){return s(e,void 0,void 0,function(){var e,n,s,h,u,l;return a(this,function(a){try{if(n=(e=this.optimizationState).nEpochs,s=e.currentEpoch,this.embedding=this.optimizeLayoutStep(s),h=this.optimizationState.currentEpoch,u=!1===t(h),l=h===n,u||l)return[2,r(l)];setTimeout(function(){return i()},0)}catch(t){o(t)}return[2]})})};setTimeout(function(){return i()},0)})},t.prototype.optimizeLayout=function(t){void 0===t&&(t=function(){return!0});for(var e=!1,r=[];!e;){var o=this.optimizationState,i=o.nEpochs,n=o.currentEpoch;r=this.optimizeLayoutStep(n);var s=this.optimizationState.currentEpoch,a=!1===t(s);e=s===i||a}return r},t.prototype.getNEpochs=function(){var t=this.graph;if(this.nEpochs>0)return this.nEpochs;var e=t.nRows;return e<=2500?500:e<=5e3?400:e<=7500?300:200},t}();function y(t,e){for(var r=0,o=0;oe?e:t<-e?-e:t}function M(t,e){for(var r=0,o=0;o=e?Math.exp(-(r[i]-e)/t):o}),i=d.default({x:r,y:o},function(t){var e=h(t,2),r=e[0],o=e[1];return function(t){return 1/(1+r*Math.pow(t,2*o))}},{damping:1.5,initialValues:[.5,.5],gradientDifference:.1,maxIterations:100,errorTolerance:.01}).parameterValues,n=h(i,2);return{a:n[0],b:n[1]}}function S(t,e,r,o){return void 0===r&&(r=1),void 0===o&&(o=5),t.map(function(t,i,n){return -1===e[i]||-1===e[n]?t*Math.exp(-r):e[i]!==e[n]?t*Math.exp(-o):t})}function E(t){t=c.normalize(t,"max");var e=c.transpose(t),r=c.pairwiseMultiply(e,t);return t=c.add(t,c.subtract(e,r)),c.eliminateZeros(t)}function R(t,e,r){for(var o=p.zeros(t.length).map(function(t){return p.zeros(r[0].length)}),i=0;i=t.length&&(t=void 0),{value:t&&t[o++],done:!t}}};throw TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};function o(t,e){return Math.floor(e()*t)}function i(t){for(var e=[],r=0;re?t[r]:e;return e},e.max2d=function(t){for(var e=0,r=0;re?t[r][o]:e;return e},e.rejectionSample=function(t,e,r){for(var i=s(t),n=0;n