From cc20cb52cbd2e5002bf080bb333b54308598fc4d Mon Sep 17 00:00:00 2001 From: Dan Rose Date: Thu, 14 Sep 2023 02:44:58 -0500 Subject: [PATCH] Rename index.esm.js -> esm.mjs (#249 take 2) (#257) * Rename index.esm.js -> esm.mjs This is needed for node to properly deduce that the file is ESM. Otherwise, node crashes when you try to `import("vectorious")` with an error like: > Uncaught SyntaxError: Unexpected token 'export' * 6.1.12 --- README.md | 2 +- dist/{index.esm.js => index.mjs} | 2 +- dist/{index.esm.js.map => index.mjs.map} | 0 docs/vectorious/6.1.11/index.html | 2 +- package-lock.json | 4 ++-- package.json | 8 ++++---- 6 files changed, 9 insertions(+), 9 deletions(-) rename dist/{index.esm.js => index.mjs} (99%) rename dist/{index.esm.js.map => index.mjs.map} (100%) diff --git a/README.md b/README.md index 5eb0c1f8..eb8a6691 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ It exposes a global variable named `v` in the `window` object and can be accesse #### ES module -Added in version 6.1.0, vectorious exposes an ES module bundle at `dist/index.esm.js` which can be imported using the `import` syntax: +Added in version 6.1.0, vectorious exposes an ES module bundle at `dist/index.mjs` which can be imported using the `import` syntax: ```typescript import { array } from 'vectorious'; diff --git a/dist/index.esm.js b/dist/index.mjs similarity index 99% rename from dist/index.esm.js rename to dist/index.mjs index 71b8f157..b327fda6 100644 --- a/dist/index.esm.js +++ b/dist/index.mjs @@ -8,4 +8,4 @@ var Xt=Object.create;var mr=Object.defineProperty;var Yt=Object.getOwnPropertyDe `)>=0&&e++,n+s.replace(/\u001b\[\d\d?m/g,"").length+1},0);return a>60?o[0]+(t===""?"":t+` `)+" "+r.join(`, `)+" "+o[1]:o[0]+t+" "+r.join(", ")+" "+o[1]}function Rt(r){return Array.isArray(r)}h.isArray=Rt;function ar(r){return typeof r=="boolean"}h.isBoolean=ar;function P(r){return r===null}h.isNull=P;function nn(r){return r==null}h.isNullOrUndefined=nn;function Pt(r){return typeof r=="number"}h.isNumber=Pt;function B(r){return typeof r=="string"}h.isString=B;function an(r){return typeof r=="symbol"}h.isSymbol=an;function x(r){return r===void 0}h.isUndefined=x;function U(r){return E(r)&&ir(r)==="[object RegExp]"}h.isRegExp=U;function E(r){return typeof r=="object"&&r!==null}h.isObject=E;function nr(r){return E(r)&&ir(r)==="[object Date]"}h.isDate=nr;function $(r){return E(r)&&(ir(r)==="[object Error]"||r instanceof Error)}h.isError=$;function C(r){return typeof r=="function"}h.isFunction=C;function sn(r){return r===null||typeof r=="boolean"||typeof r=="number"||typeof r=="string"||typeof r=="symbol"||typeof r>"u"}h.isPrimitive=sn;h.isBuffer=$t();function ir(r){return Object.prototype.toString.call(r)}function or(r){return r<10?"0"+r.toString(10):r.toString(10)}var mn=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function fn(){var r=new Date,t=[or(r.getHours()),or(r.getMinutes()),or(r.getSeconds())].join(":");return[r.getDate(),mn[r.getMonth()],t].join(" ")}h.log=function(){console.log("%s - %s",fn(),h.format.apply(h,arguments))};h.inherits=Ct();h._extend=function(r,t){if(!t||!E(t))return r;for(var o=Object.keys(t),e=o.length;e--;)r[o[e]]=t[o[e]];return r};function Bt(r,t){return Object.prototype.hasOwnProperty.call(r,t)}});var k=32,V=r=>r.reduce((t,o)=>t.concat(Array.isArray(o)?V(o):o),[]),G=r=>ArrayBuffer.isView(r)&&!(r instanceof DataView),S=r=>r.reduce((t,o)=>t*o,1),W=r=>Array.isArray(r)||G(r)?[r.length].concat(W(r[0])):[],I=r=>[...r.slice(1).map((t,o)=>r.slice(o+1).reduce((e,a)=>e*a,1)),1],fr=r=>{let{constructor:{name:t="Float32Array"}={}}=r||{};switch(t){case"Int8Array":return"int8";case"Uint8Array":return"uint8";case"Int16Array":return"int16";case"Uint16Array":return"uint16";case"Int32Array":return"int32";case"Uint32Array":return"uint32";case"Uint8ClampedArray":return"uint8c";case"Float32Array":return"float32";case"Float64Array":return"float64";default:return"float64"}},g=r=>{switch(r){case"int8":return Int8Array;case"uint8":return Uint8Array;case"int16":return Int16Array;case"uint16":return Uint16Array;case"int32":return Int32Array;case"uint32":return Uint32Array;case"uint8c":return Uint8ClampedArray;case"float32":return Float32Array;case"float64":return Float64Array;default:return Float64Array}};var i=(...r)=>new A(...r);var p=class{x;shape;shapem1;strides;backstrides;length;lengthm1;nd;ndm1;index;coords;pos;factors;constructor(t){this.x=i(t);let{shape:o,strides:e,length:a}=this.x;this.length=a,this.lengthm1=a-1,this.nd=o.length,this.ndm1=this.nd-1,this.shape=Array(k).fill(0),this.strides=Array(k).fill(0),this.shapem1=Array(k).fill(0),this.coords=Array(k).fill(0),this.backstrides=Array(k).fill(0),this.factors=Array(k).fill(0),this.nd!==0&&(this.factors[this.nd-1]=1);let n;for(n=0;n0&&(this.factors[this.ndm1-n]=this.factors[this.nd-n]*o[this.nd-n]);this.index=0,this.pos=0}done(){return this.index>this.lengthm1}current(){let t=this.done();return{value:t?void 0:this.pos,done:t}}next(){let t=this.current();if(t.done)return t;let{ndm1:o,shapem1:e,strides:a,backstrides:n}=this,s;for(s=o;s>=0;s-=1){if(this.coords[s]new p(f)),this.numiter=t.length;let o,e;for(o=0,e=0;o=0){if(m=a.x.shape[s],m==1)continue;if(this.shape[o]==1)this.shape[o]=m;else if(this.shape[o]!==m)throw new Error("shape mismatch")}for(m=this.shape.reduce((f,u)=>f*u,1),this.length=m,this.lengthm1=m-1,o=0;o0&&(a.factors[this.nd-n-1]=a.factors[this.nd-n]*this.shape[this.nd-n]);this.index=0,this.pos=Array(this.numiter).fill(0)}done(){return this.index>this.lengthm1}current(){let t=this.done();return{value:t?void 0:this.pos,done:t}}next(){let t=this.current();if(t.done)return t;this.index+=1;let{numiter:o}=this,e,a;for(a=0;ai(r).abs();function pr(){let{data:r}=this,t=new p(this);for(let o of t)r[o]=oo(r[o]);return this}var{acos:no}=Math,ao=r=>i(r).acos();function ur(){let{data:r}=this,t=new p(this);for(let o of t)r[o]=no(r[o]);return this}var{acosh:io}=Math,so=r=>i(r).acosh();function cr(){let{data:r}=this,t=new p(this);for(let o of t)r[o]=io(r[o]);return this}var b;try{b=H("nblas")}catch{}var X=b&&b.NoTrans,Rn=b&&b.Trans;function yr(r,t,o,e,a,n,s){if(e.length/a!==t||n.length/s!==t)throw new Error("lengths do not match");switch(r){case"float64":return b.daxpy(t,o,e,a,n,s);case"float32":return b.saxpy(t,o,e,a,n,s);default:throw new Error("wrong dtype")}}function lr(r,t,o,e,a,n){if(o.length/e!==t||a.length/n!==t)throw new Error("lengths do not match");switch(r){case"float64":return b.ddot(t,o,e,a,n);case"float32":return b.sdot(t,o,e,a,n);default:throw new Error("wrong dtype")}}function hr(r,t,o,e){if(o.length/e!==t)throw new Error("lengths do not match");switch(r){case"float64":return b.idamax(t,o,e);case"float32":return b.isamax(t,o,e);default:throw new Error("wrong dtype")}}function dr(r,t,o,e,a,n,s,m,f,u,y,c,l,d){let{length:v}=m,{length:q}=u,{length:_}=l;if(t===b.NoTrans&&v!==f*e||t===b.Trans&&v!==f*n)throw new Error("lengths do not match");if(o===b.NoTrans&&q!==y*n||o===b.Trans&&q!==y*a)throw new Error("lengths do not match");if(_!==d*e)throw new Error("lengths do not match");switch(r){case"float64":return b.dgemm(t,o,e,a,n,s,m,f,u,y,c,l,d);case"float32":return b.sgemm(t,o,e,a,n,s,m,f,u,y,c,l,d);default:throw new Error("wrong dtype")}}function Ar(r,t,o,e){if(o.length/e!==t)throw new Error("lengths do not match");switch(r){case"float64":return b.dnrm2(t,o,e);case"float32":return b.snrm2(t,o,e);default:throw new Error("wrong dtype")}}function br(r,t,o,e,a){if(e.length/a!==t)throw new Error("lengths do not match");switch(r){case"float64":return b.dscal(t,o,e,a);case"float32":return b.sscal(t,o,e,a);default:throw new Error("wrong dtype")}}var mo=(r,t,o=1)=>i(r).add(i(t),o);function Dr(r,t=1){let{data:o,length:e,strides:a,dtype:n}=this,{data:s,strides:m}=i(r);try{let f=m[m.length-1],u=a[a.length-1];if(f!==u)throw new Error("inc_x and inc_y must be equal");yr(n,e,t,s,f,o,u)}catch{let u=new D(this,r);for(let[y,c]of u)o[y]+=t*s[c]}return this}var{acos:fo}=Math,po=(r,t)=>i(r).angle(i(t));function Nr(r){return fo(this.dot(i(r))/this.norm()/i(r).norm())}var{asin:uo}=Math,co=r=>i(r).asin();function gr(){let{data:r}=this,t=new p(this);for(let o of t)r[o]=uo(r[o]);return this}var{asinh:yo}=Math,lo=r=>i(r).asinh();function xr(){let{data:r}=this,t=new p(this);for(let o of t)r[o]=yo(r[o]);return this}var{atan:ho}=Math,Ao=r=>i(r).atan();function wr(){let{data:r}=this,t=new p(this);for(let o of t)r[o]=ho(r[o]);return this}var{atanh:bo}=Math,Do=r=>i(r).atanh();function kr(){let{data:r}=this,t=new p(this);for(let o of t)r[o]=bo(r[o]);return this}var N=(...r)=>new A(new Float64Array(r.reduce((t,o)=>t*o,1)),{shape:r}).fill(0);var Y=(r,t)=>i(r).augment(i(t));function Lr(r){let[t,o]=this.shape,[e,a]=i(r).shape,{data:n}=this,{data:s}=i(r);if(e===0||a===0)return this;if(t!==e)throw new Error("rows do not match");let m=N(t,o+a),{data:f}=m,u,y;for(u=0;ui(r).binOp(i(t),o);function Ir(r,t){let{data:o}=this,{data:e}=i(r),a=new D(this,r);for(let[n,s]of a)o[n]=t(o[n],e[s],n);return this}var{cbrt:go}=Math,xo=r=>i(r).cbrt();function Tr(){let{data:r}=this,t=new p(this);for(let o of t)r[o]=go(r[o]);return this}var{ceil:wo}=Math,ko=r=>i(r).ceil();function Er(){let{data:r}=this,t=new p(this);for(let o of t)r[o]=wo(r[o]);return this}var Lo=(r,...t)=>{i(r).check(...t)};function vr(...r){let{shape:t,length:o}=this;if(r.length===1){let[e]=r;if(e<0||e>o-1||!Number.isFinite(e))throw new Error("index out of bounds")}else if(!t.every((e,a)=>e>r[a]&&Number.isFinite(r[a])&&r[a]>=0))throw new Error("index out of bounds")}var Io=(r,t)=>i(r).combine(i(t));function Mr(r){if(this.shape.length!==1&&r.shape.length!==1)throw new Error("combine operation not permitted for multidimensional arrays");let{length:t,data:o}=this,{length:e,data:a}=r;if(e===0)return this;if(t===0)return this.data=new(g(r.dtype))(a),this.length=e,this.dtype=r.dtype,this;let n=t+e,s=new(g(this.dtype))(n);return s.set(o),s.set(a,t),this.data=s,this.length=n,this.shape=[n],this}var To=r=>i(r).copy();function jr(){let r=N(...this.shape),{data:t}=this,{data:o}=r,e=new D(this,r);for(let[a,n]of e)o[n]=t[a];return r}var{cos:Eo}=Math,vo=r=>i(r).cos();function qr(){let{data:r}=this,t=new p(this);for(let o of t)r[o]=Eo(r[o]);return this}var{cosh:Mo}=Math,jo=r=>i(r).cosh();function _r(){let{data:r}=this,t=new p(this);for(let o of t)r[o]=Mo(r[o]);return this}var qo=(r,t)=>i(r).cross(i(t));function Sr(r){let{length:t}=this,{length:o}=r;if(t!==3||o!==3)throw new Error("vectors must have three components");let e=this.y*r.z-this.z*r.y,a=this.z*r.x-this.x*r.z,n=this.x*r.y-this.y*r.x;return this.x=e,this.y=a,this.z=n,this}var _o=r=>i(r).det();function zr(){this.square();let[r]=this.shape,[t,o]=this.copy().lu_factor(),{data:e}=t,a=1,n=1,s;for(s=0;si(r).diagonal();function Or(){this.square();let{length:r}=this,[t,o]=this.shape,e=Math.min(t,o);return this.reshape(r).slice(0,r,e+1)}var zo=(r,t)=>i(r).dot(i(t));function Fr(r){let{data:t,length:o,strides:e,dtype:a}=this,{data:n,strides:s}=r,m=0;try{let f=s[s.length-1],u=e[e.length-1];if(f!==u)throw new Error("inc_x and inc_y must be equal");m=lr(a,o,n,f,t,u)}catch{let u=new D(this,r);for(let[y,c]of u)m+=t[y]*n[c]}return m}var M=r=>{let t=new A(new Float64Array(r*r),{shape:[r,r]}),{data:o}=t,e;for(e=0;e{let[m]=r.shape,{data:f}=r,u=f[e*m+a],y=1/(t+o);f[e*m+a]=u-o*(f[n*m+s]+y*u),f[n*m+s]+=o*(u-y*f[n*m+s])},Oo=r=>i(r).eig();function Ur(){this.square();let[r]=this.shape;try{["float32","float64"].includes(this.dtype)||(this.dtype="float32",this.data=g(this.dtype).from(this.data));let t=j.NoEigenvector,o=j.Eigenvector,e=N(r),a=N(r),n=N(r,r),s=N(r,r),{data:m}=this,{data:f}=e,{data:u}=a,{data:y}=n,{data:c}=s;return this.dtype==="float64"&&j.dgeev(t,o,r,m,r,f,u,y,r,c,r),this.dtype==="float32"&&j.sgeev(t,o,r,m,r,f,u,y,r,c,r),[e,s]}catch{let{data:o}=this,e=M(r),a=0,n=0,s=0,m=0,f=0;do{for(n=0;n=a&&(a=Math.abs(o[n*r+s]),m=n,f=s);let u;if(Math.abs(o[m*r+f])=1e-9);return[this.diagonal(),e]}}var Fo=(r,t,o=1e-6)=>i(r).equals(i(t),o);function $r(r,t=1e-6){let{data:o}=this,{data:e}=r,a=new D(this,r);for(let[n,s]of a)if(Math.abs(o[n]-e[s])>t)return!1;return!0}var Uo=(r,t)=>{i(r).equidimensional(i(t))};function Cr(r){let{shape:t}=this,{shape:o}=r;if(!t.every((e,a)=>e===o[a]))throw new Error(`shapes ${t} and ${o} do not match`)}var $o=(r,t)=>{i(r).equilateral(i(t))};function Rr(r){let{length:t}=this,{length:o}=r;if(t!==o)throw new Error(`lengths ${t} and ${o} do not match`)}var{exp:Co}=Math,Ro=r=>i(r).exp();function Pr(){let{data:r}=this,t=new p(this);for(let o of t)r[o]=Co(r[o]);return this}var{expm1:Po}=Math,Bo=r=>i(r).expm1();function Br(){let{data:r}=this,t=new p(this);for(let o of t)r[o]=Po(r[o]);return this}var Ho=(r,t=0)=>i(r).fill(t);function Hr(r=0){let{data:t}=this,o=new p(this);for(let e of o)t[e]=r instanceof Function?r(e):r;return this}var{floor:Jo}=Math,Vo=r=>i(r).floor();function Jr(){let{data:r}=this,t=new p(this);for(let o of t)r[o]=Jo(r[o]);return this}var Go=(r,t)=>{r.forEach(t)};function Vr(r){let{data:t}=this,o=new p(this);for(let e of o)r.call(this,t[e],e,t)}var{fround:Wo}=Math,Xo=r=>i(r).fround();function Gr(){let{data:r}=this,t=new p(this);for(let o of t)r[o]=Wo(r[o]);return this}var Yo=r=>i(r).gauss();function Wr(){let{shape:[r,t],data:o}=this,e=0,a,n,s,m,f;for(s=0;si(r).get(...t);function Xr(...r){this.check(...r);let{data:t,shape:o}=this,{length:e}=o,a=r[e-1],n,s;for(n=0;ni(r).inv();function Kr(){this.square();let{shape:[r],dtype:t}=this;try{let{data:o}=this,e=new Int32Array(r);return O(t,r,r,o,r,e),Yr(t,r,o,r,e),this}catch{let e=M(r),a=Y(this,e).gauss(),n=N(r,r),s=N(r,r),{data:m}=a,{data:f}=n,{data:u}=s,y=new p(a),[c,l]=y.coords;for(let d of y)li(r).log();function Qr(){let{data:r}=this,t=new p(this);for(let o of t)r[o]=Qo(r[o]);return this}var{log10:te}=Math,oe=r=>i(r).log10();function rt(){let{data:r}=this,t=new p(this);for(let o of t)r[o]=te(r[o]);return this}var{log1p:ee}=Math,ne=r=>i(r).log1p();function tt(){let{data:r}=this,t=new p(this);for(let o of t)r[o]=ee(r[o]);return this}var{log2:ae}=Math,ie=r=>i(r).log2();function ot(){let{data:r}=this,t=new p(this);for(let o of t)r[o]=ae(r[o]);return this}var se=r=>i(r).lu();function et(){let[r,t]=this.copy().lu_factor(),o=r.copy(),e=r.copy(),{data:a}=o,{data:n}=e,s=new p(r),[m,f]=s.coords;for(let u of s)fi(r).lu_factor();function nt(){let{data:r,shape:[t],dtype:o}=this,e=new Int32Array(t);try{O(o,t,t,r,t,e)}catch{let n,s,m,f,u,y,c;for(c=0;ci(r).map(t);function at(r){let{data:t}=this,o=new p(this),e=r.bind(this),a=this.copy(),{data:n}=a;for(let s of o)n[s]=e(t[s],s,t);return a}var pe=r=>i(r).max();function it(){let{data:r,length:t,strides:o,dtype:e}=this,a=Number.NEGATIVE_INFINITY;try{let n=o[o.length-1];a=r[hr(e,t,r,n)]}catch{let s=new p(this);for(let m of s){let f=r[m];ai(r).mean();function st(){let{data:r,length:t}=this,o=new p(this),e=0;for(let a of o)e+=r[a];return e/t}var ce=r=>i(r).min();function mt(){let{data:r}=this,t=new p(this),o=Number.POSITIVE_INFINITY;for(let e of t){let a=r[e];o>a&&(o=a)}return o}var K=(r,t)=>new A(new Float64Array(r*t),{shape:[r,t]});var ye=(r,t)=>i(r).multiply(i(t));function ft(r){let{shape:[t,o],data:e,dtype:a}=this.copy(),{shape:[n,s],data:m}=r.copy();if(o!==n)throw new Error("sizes do not match");let f=K(t,s),{data:u}=f;try{dr(a,X,X,t,s,o,1,e,o,m,s,0,u,s)}catch{let c=new p(f),l,[d,v]=c.coords;for(let q of c){let _=0;for(l=0;li(r).norm();function pt(){let{data:r,length:t,strides:o,dtype:e}=this,a=0;try{let n=o[o.length-1];a=Ar(e,t,r,n)}catch{a=le(this.dot(this))}return a}var de=r=>i(r).normalize();function ut(){return this.scale(1/this.norm())}var{pow:Ae}=Math,be=(r,t)=>i(r).pow(t);function ct(r){let{data:t}=this,o=new p(this);for(let e of o)t[e]=Ae(t[e],r);return this}var De=r=>i(r).prod();function yt(){let{data:r}=this,t=new p(this),o=1;for(let e of t)o*=r[e];return o}var Ne=(r,t)=>i(r).product(i(t));function lt(r){let{data:t}=this,{data:o}=r,e=new D(this,r);for(let[a,n]of e)t[a]*=o[n];return this}var ge=(r,t)=>i(r).project(i(t));function ht(r){return r.scale(this.dot(r)/r.dot(r))}var xe=(r,t)=>i(r).push(t);function dt(r){if(this.shape.length!==1)throw new Error("push operation not permitted for multidimensional arrays");let{data:t,length:o}=this,e=o+1,a=new(g(this.dtype))(e);return a.set(t),a[o]=r,this.data=a,this.length=e,this.shape=[e],this}var we=(r,t=1e-6)=>i(r).rank(t);function At(r=1e-6){let{data:t}=this.copy().gauss(),o=new p(this),e=0,[a,n]=o.coords;for(let s of o)e<=a&&n>=a&&Math.abs(t[s])>r&&(e+=1),[a,n]=o.coords;return e}var ke=r=>i(r).reciprocal();function bt(){let{data:r}=this,t=new p(this);for(let o of t)r[o]=1/r[o];return this}var Le=(r,t,o)=>i(r).reduce(t,o);function Dt(r,t){let{data:o,length:e}=this;if(e===0&&typeof t>"u")throw new Error("Reduce of empty array with no initial value.");let a=new p(this),n=r.bind(this),s;typeof t>"u"?(s=o[0],a.next()):s=t;for(let m of a)s=n(s,o[m],m,o);return s}var Ie=(r,...t)=>i(r).reshape(...t);function Nt(...r){let{length:t}=this;if(r.reduce((o,e)=>o*e,1)!==t)throw new Error(`shape ${r} does not match length ${t}`);return this.shape=r,this.strides=I(r),this}var{round:Te}=Math,Ee=r=>i(r).round();function gt(){let{data:r}=this,t=new p(this);for(let o of t)r[o]=Te(r[o]);return this}var ve=(r,t,o,e=1)=>i(r).row_add(t,o,e);function xt(r,t,o=1){this.check(r,0),this.check(t,0);let[,e]=this.shape,{data:a}=this,n;for(n=0;ni(r).scale(t);function wt(r){let{data:t,length:o,strides:e,dtype:a}=this;try{let n=e[e.length-1];br(a,o,r,t,n)}catch{let s=new p(this);for(let m of s)t[m]*=r}return this}var je=(r,...t)=>{r.set(...t)};function kt(...r){let t=r.slice(0,-1),o=r[r.length-1];this.check(...t);let{shape:e}=this,a=t[t.length-1],n;for(n=0;ni(r).sign();function Lt(){let{data:r}=this,t=new p(this);for(let o of t)r[o]=qe(r[o]);return this}var{sin:Se}=Math,ze=r=>i(r).sin();function It(){let{data:r}=this,t=new p(this);for(let o of t)r[o]=Se(r[o]);return this}var{sinh:Oe}=Math,Fe=r=>i(r).sinh();function Tt(){let{data:r}=this,t=new p(this);for(let o of t)r[o]=Oe(r[o]);return this}var Ue=(r,t,o,e)=>i(r).slice(t,o,e);function Et(r=0,t=this.shape[0],o=1){let{data:e,shape:a}=this,n=a.length;if(r<0||t<0)return this.slice(r<0?a[a.length-1]+r:r,t<0?a[a.length-1]+t:t);if(r>t)return this.slice(t,r,o);if(o<=0)throw new Error("step argument has to be a positive integer");let s=[Math.ceil((t-r)/Math.abs(o)),...a.slice(1)],m=S(s),f=I(s),u=n>1?e.subarray(r*s[s.length-1],t*s[s.length-1]):e.subarray(r,t);return f[0]*=o,new A(u,{shape:s,length:m,strides:f})}var $e=(r,t)=>i(r).solve(i(t));function vt(r){let{data:t,dtype:o}=this,{data:e,shape:[a,n]}=r;try{let s=new Int32Array(a);Zr(o,a,n,t,a,s,e,n)}catch{let[m,f]=this.lu_factor(),{data:u}=m,{data:y}=r,c,l,d;for(c=0;c=0;c-=1){for(l=c+1;li(r).sqrt();function Mt(){let{data:r}=this,t=new p(this);for(let o of t)r[o]=Ce(r[o]);return this}var Pe=r=>{i(r).square()};function jt(){let{length:r}=this.shape,[t,o]=this.shape;if(r!==2||t!==o)throw new Error("matrix is not square")}var Be=(r,t)=>i(r).subtract(i(t));function qt(r){return this.add(r,-1)}var He=r=>i(r).sum();function _t(){let{data:r}=this,t=new p(this),o=0;for(let e of t)o+=r[e];return o}var Je=(r,t,o)=>i(r).swap(t,o);function St(r,t){this.check(r,0),this.check(t,0);let{data:o}=this,[,e]=this.shape,a=o.slice(r*e,(r+1)*e);return o.copyWithin(r*e,t*e,(t+1)*e),o.set(a,t*e),this}var{tan:Ve}=Math,Ge=r=>i(r).tan();function zt(){let{data:r}=this,t=new p(this);for(let o of t)r[o]=Ve(r[o]);return this}var{tanh:We}=Math,Xe=r=>i(r).tanh();function Ot(){let{data:r}=this,t=new p(this);for(let o of t)r[o]=We(r[o]);return this}var Ye=r=>i(r).toArray();function Ft(r=0,t=0){let{data:o,shape:e,strides:a}=this,{length:n}=e;if(t>=n)return o[r];let s=e[t],m=a[t],f=[];for(let u=0;ui(r).toString();function sr(){return`array(${(0,Jt.inspect)(this.toArray(),{depth:10,breakLength:40})}, dtype=${this.dtype})`}var un=r=>i(r).trace();function Vt(){let[r,t]=this.shape,{data:o}=this,e=Math.min(r,t),a=0,n;for(n=0;ni(r).transpose();function Gt(){if(this.shape.length<2)return this;let r=this.shape[0];return this.shape[0]=this.shape[1],this.shape[1]=r,r=this.strides[0],this.strides[0]=this.strides[1],this.strides[1]=r,this}var{trunc:yn}=Math,ln=r=>i(r).trunc();function Wt(){let{data:r}=this,t=new p(this);for(let o of t)r[o]=yn(r[o]);return this}var hn=r=>{if(r<0)throw new Error("invalid n");let t=new Float64Array(r*r),o=new A(t,{shape:[r,r]}),e=new p(o),[a,n]=e.coords;for(let s of e){let m=r-a-1,f=r-n-1;t[s]=(n+m*2+1)%r*r+(f+m*2+1)%r+1,[a,n]=e.coords}return o};var dn=(...r)=>new A(new Float64Array(r.reduce((t,o)=>t*o,1)),{shape:r}).fill(1);var An=(...r)=>new A(new Float64Array(r.reduce((t,o)=>t*o,1)),{shape:r}).map(()=>Math.random());var bn=(...r)=>{let t=Float64Array,o=!1,e,a,n;switch(r.length){case 2:n=r.pop(),a=1,e=r.pop();break;case 3:n=r.pop(),a=r.pop(),e=r.pop();break;default:throw new Error("invalid range")}if(n-e<0){let u=n;n=e,e=u,o=!0}if(a>n-e)throw new Error("invalid range");let s=new t(Math.ceil((n-e)/a)),m=e,f=0;if(o)for(;mBrowser </script>

ES module

-

Added in version 6.1.0, vectorious exposes an ES module bundle at dist/index.esm.js which can be imported using the import syntax:

+

Added in version 6.1.0, vectorious exposes an ES module bundle at dist/index.mjs which can be imported using the import syntax:

import { array } from 'vectorious';
 
 const x = array([1, 2, 3]);
diff --git a/package-lock.json b/package-lock.json
index c4ebdf72..e3dfe87f 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
 {
   "name": "vectorious",
-  "version": "6.1.11",
+  "version": "6.1.12",
   "lockfileVersion": 2,
   "requires": true,
   "packages": {
     "": {
       "name": "vectorious",
-      "version": "6.1.11",
+      "version": "6.1.12",
       "license": "MIT",
       "devDependencies": {
         "@types/jest": "^29.5.0",
diff --git a/package.json b/package.json
index b4f7abc7..1f7690cb 100644
--- a/package.json
+++ b/package.json
@@ -1,10 +1,10 @@
 {
   "name": "vectorious",
-  "version": "6.1.11",
+  "version": "6.1.12",
   "description": "A high performance linear algebra library.",
   "main": "dist/index.js",
   "browser": "dist/index.browser.js",
-  "module": "dist/index.esm.js",
+  "module": "dist/index.mjs",
   "types": "dist/index.d.ts",
   "files": [
     "dist"
@@ -12,7 +12,7 @@
   "exports": {
     ".": {
       "require": "./dist/index.js",
-      "import": "./dist/index.esm.js"
+      "import": "./dist/index.mjs"
     }
   },
   "scripts": {
@@ -21,7 +21,7 @@
     "docs": "tsc --outDir built && jsdoc --configure jsdoc.json && rimraf built",
     "build:node": "esbuild --bundle src/index.ts --minify --sourcemap --platform=node --outfile=dist/index.js --external:nblas --external:nlapack",
     "build:browser": "esbuild --bundle src/index.ts --minify --sourcemap --platform=browser --global-name=v --outfile=dist/index.browser.js --external:nblas --external:nlapack",
-    "build:esm": "esbuild --bundle src/index.ts --minify --sourcemap --format=esm --outfile=dist/index.esm.js --external:nblas --external:nlapack",
+    "build:esm": "esbuild --bundle src/index.ts --minify --sourcemap --format=esm --outfile=dist/index.mjs --external:nblas --external:nlapack",
     "build": "rimraf dist && tsc -emitDeclarationOnly && npm run build:node && npm run build:browser && npm run build:esm",
     "prepublishOnly": "npm run build"
   },