// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 !function(r,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(r="undefined"!=typeof globalThis?globalThis:r||self).forEach=e()}(this,(function(){"use strict";var r="function";function e(e){return typeof e.get===r&&typeof e.set===r}var t={complex128:function(r,e){return r.get(e)},complex64:function(r,e){return r.get(e)},default:function(r,e){return r.get(e)}};function n(r){var e=t[r];return"function"==typeof e?e:t.default}var o={complex128:function(r,e,t){r.set(t,e)},complex64:function(r,e,t){r.set(t,e)},default:function(r,e,t){r.set(t,e)}};function i(r){var e=o[r];return"function"==typeof e?e:o.default}var a={float64:function(r,e){return r[e]},float32:function(r,e){return r[e]},int32:function(r,e){return r[e]},int16:function(r,e){return r[e]},int8:function(r,e){return r[e]},uint32:function(r,e){return r[e]},uint16:function(r,e){return r[e]},uint8:function(r,e){return r[e]},uint8c:function(r,e){return r[e]},generic:function(r,e){return r[e]},default:function(r,e){return r[e]}};function f(r){var e=a[r];return"function"==typeof e?e:a.default}var u={float64:function(r,e,t){r[e]=t},float32:function(r,e,t){r[e]=t},int32:function(r,e,t){r[e]=t},int16:function(r,e,t){r[e]=t},int8:function(r,e,t){r[e]=t},uint32:function(r,e,t){r[e]=t},uint16:function(r,e,t){r[e]=t},uint8:function(r,e,t){r[e]=t},uint8c:function(r,e,t){r[e]=t},generic:function(r,e,t){r[e]=t},default:function(r,e,t){r[e]=t}};function s(r){var e=u[r];return"function"==typeof e?e:u.default}function l(r){var e,t,n;if(0===(e=r.length))return 0;for(t=1,n=0;n0&&(e-=1),t=n.toExponential(e)):t=n.toPrecision(r.precision),r.alternate||(t=T.call(t,L,"$1e"),t=T.call(t,F,"e"),t=T.call(t,S,""));break;default:throw new Error("invalid double notation. Value: "+r.specifier)}return t=T.call(t,x,"e+0$1"),t=T.call(t,A,"e-0$1"),r.alternate&&(t=T.call(t,V,"$1."),t=T.call(t,j,"$1.e")),n>=0&&r.sign&&(t=r.sign+t),t=r.specifier===_.call(r.specifier)?_.call(t):E.call(t)}function k(r){var e,t="";for(e=0;e127)throw new Error("invalid character code. Value: "+n.arg);n.arg=O(i)?String(n.arg):R(i)}break;case"e":case"E":case"f":case"F":case"g":case"G":e||(n.precision=6),n.arg=I(n);break;default:throw new Error("invalid specifier: "+n.specifier)}n.maxWidth>=0&&n.arg.length>n.maxWidth&&(n.arg=n.arg.substring(0,n.maxWidth)),n.padZeros?n.arg=g(n.arg,n.width||n.precision,n.padRight):n.width&&(n.arg=(l=n.arg,c=n.width,h=n.padRight,p=void 0,(p=c-l.length)<0?l:l=h?l+k(p):k(p)+l)),a+=n.arg||"",f+=1}return a}var N=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function P(r){var e={mapping:r[1]?parseInt(r[1],10):void 0,flags:r[2],width:r[3],precision:r[5],specifier:r[6]};return"."===r[4]&&void 0===r[5]&&(e.precision="1"),e}function U(r){var e,t,n,o;for(t=[],o=0,n=N.exec(r);n;)(e=r.slice(o,N.lastIndex-n[0].length)).length&&t.push(e),t.push(P(n)),o=N.lastIndex,n=N.exec(r);return(e=r.slice(o)).length&&t.push(e),t}function Y(r){var e,t;if("string"!=typeof r)throw new TypeError(Y("invalid argument. First argument must be a string. Value: `%s`.",r));for(e=[U(r)],t=1;t=0;o--)t[o]=n,n*=r[o];return t}(r)}q(D,"assign",(function(r,e,t){return"column-major"===e?function(r,e){var t,n;for(t=1,n=0;n=0;n--)e[n]=t,t*=r[n];return e}(r,t)}));var H="row-major";function Q(r,e){var t,n,o;return"object"!=typeof(o=r.strides)||null===o?0===(n=r.shape).length?[0]:("string"!=typeof(t=r.order)&&(t=H),D(n,t)):e?c(o):o}function rr(r){var e,t,n;return"number"==typeof(n=r.offset)?n:0===(t=r.shape).length||"object"!=typeof(e=r.strides)||null===e?0:function(r,e){var t,n,o;for(n=r.length,t=0,o=0;oo&&(n=!1),!n&&!e)return 0;o=i}return n&&e?3:n?1:2}var nr="row-major",or="column-major";function ir(r){var e,t;return"string"==typeof(t=r.order)?t:"object"!=typeof(e=r.strides)||null===e||1===(t=tr(e))||3===t?nr:2===t?or:0===r.shape.length?nr:null}function ar(r){var t,o,a,u;return t=function(r){return r.data}(r),a=function(r,e){var t=r.shape;return e?c(t):t}(r,!0),u=function(r){return r.dtype}(r),o=e(t),{ref:r,dtype:u,data:t,length:l(a),shape:a,strides:Q(r,!0),offset:rr(r),order:ir(r),accessorProtocol:o,accessors:o?[n(u),i(u)]:[f(u),s(u)]}}function fr(r){var e,t;if(e=[],r<=0)return e;for(t=0;tEe&&Te(r)}function Ae(r){return ye(r)&&xe(r)}function Ve(r){return we(r)&&xe(r.valueOf())}function je(r){return Ae(r)||Ve(r)}function Se(r){return Ae(r)&&r>=0}function Fe(r){return Ve(r)&&r.valueOf()>=0}function Le(r){return Se(r)||Fe(r)}q(je,"isPrimitive",Ae),q(je,"isObject",Ve),q(Le,"isPrimitive",Se),q(Le,"isObject",Fe);var Ie=4294967295;function ke(r){return"object"==typeof r&&null!==r&&"number"==typeof r.length&&Te(r.length)&&r.length>=0&&r.length<=Ie}var Re=9007199254740991;function Be(r){return"object"==typeof r&&null!==r&&"number"==typeof r.length&&Te(r.length)&&r.length>=0&&r.length<=Re}var Oe="function"==typeof ArrayBuffer;function Ce(r){return Oe&&r instanceof ArrayBuffer||"[object ArrayBuffer]"===yr(r)}function Me(r){return"object"==typeof r&&null!==r&&!gr(r)}function Ne(r){return"string"==typeof r}var Pe=String.prototype.valueOf;var Ue=sr();function Ye(r){return"object"==typeof r&&(r instanceof String||(Ue?function(r){try{return Pe.call(r),!0}catch(r){return!1}}(r):"[object String]"===yr(r)))}function We(r){return Ne(r)||Ye(r)}q(We,"isPrimitive",Ne),q(We,"isObject",Ye);var $e=/./;function Ze(r){return"boolean"==typeof r}var Ge=Boolean,Je=Boolean.prototype.toString;var Ke=sr();function ze(r){return"object"==typeof r&&(r instanceof Ge||(Ke?function(r){try{return Je.call(r),!0}catch(r){return!1}}(r):"[object Boolean]"===yr(r)))}function Xe(r){return Ze(r)||ze(r)}q(Xe,"isPrimitive",Ze),q(Xe,"isObject",ze);var qe="object"==typeof self?self:null,De="object"==typeof window?window:null,He="object"==typeof global?global:null,Qe="object"==typeof globalThis?globalThis:null;var rt=function(r){if(arguments.length){if(!Ze(r))throw new TypeError(Y("invalid argument. Must provide a boolean. Value: `%s`.",r));if(r)return new Function("return this;")()}if(Qe)return Qe;if(qe)return qe;if(De)return De;if(He)return He;throw new Error("unexpected error. Unable to resolve global object.")}(),et=rt.document&&rt.document.childNodes,tt=Int8Array;var nt="function"==typeof $e||"object"==typeof tt||"function"==typeof et?function(r){return Er(r).toLowerCase()}:function(r){var e;return null===r?"null":"object"===(e=typeof r)?Er(r).toLowerCase():e};function ot(r){return"function"===nt(r)}function it(r,e){if(!(this instanceof it))throw new TypeError("invalid invocation. Constructor must be called with the `new` keyword.");if(!ye(r))throw new TypeError(Y("invalid argument. Real component must be a number. Value: `%s`.",r));if(!ye(e))throw new TypeError(Y("invalid argument. Imaginary component must be a number. Value: `%s`.",e));return X(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:r}),X(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:e}),this}q(it,"BYTES_PER_ELEMENT",8),q(it.prototype,"BYTES_PER_ELEMENT",8),q(it.prototype,"byteLength",16),q(it.prototype,"toString",(function(){var r=""+this.re;return this.im<0?r+=" - "+-this.im:r+=" + "+this.im,r+="i"})),q(it.prototype,"toJSON",(function(){var r={type:"Complex128"};return r.re=this.re,r.im=this.im,r}));var at="function"==typeof Math.fround?Math.fround:null,ft=new Rr(1);var ut="function"==typeof at?at:function(r){return ft[0]=r,ft[0]};function st(r,e){if(!(this instanceof st))throw new TypeError("invalid invocation. Constructor must be called with the `new` keyword.");if(!ye(r))throw new TypeError(Y("invalid argument. Real component must be a number. Value: `%s`.",r));if(!ye(e))throw new TypeError(Y("invalid argument. Imaginary component must be a number. Value: `%s`.",e));return X(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:ut(r)}),X(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:ut(e)}),this}function lt(r){return r instanceof it||r instanceof st||"object"==typeof r&&null!==r&&"number"==typeof r.re&&"number"==typeof r.im}function ct(r){return Te(r/2)}q(st,"BYTES_PER_ELEMENT",4),q(st.prototype,"BYTES_PER_ELEMENT",4),q(st.prototype,"byteLength",8),q(st.prototype,"toString",(function(){var r=""+this.re;return this.im<0?r+=" - "+-this.im:r+=" + "+this.im,r+="i"})),q(st.prototype,"toJSON",(function(){var r={type:"Complex64"};return r.re=this.re,r.im=this.im,r}));var ht=8;function pt(r){return"object"==typeof r&&null!==r&&"Complex64Array"===r.constructor.name&&r.BYTES_PER_ELEMENT===ht}var mt=16;function yt(r){return"object"==typeof r&&null!==r&&"Complex128Array"===r.constructor.name&&r.BYTES_PER_ELEMENT===mt}function gt(){return"function"==typeof pr&&"symbol"==typeof pr("foo")&&hr(pr,"iterator")&&"symbol"==typeof pr.iterator}var vt=gt()?Symbol.iterator:null;function dt(r,e,t){X(r,e,{configurable:!1,enumerable:!1,get:t})}function wt(r,e){if(!(this instanceof wt))throw new TypeError("invalid invocation. Constructor must be called with the `new` keyword.");if(!ye(r))throw new TypeError(Y("invalid argument. Real component must be a number. Value: `%s`.",r));if(!ye(e))throw new TypeError(Y("invalid argument. Imaginary component must be a number. Value: `%s`.",e));return X(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:ut(r)}),X(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:ut(e)}),this}function bt(r){return r.re}function Et(r){return r.im}function _t(r,e){return new Rr(r.buffer,r.byteOffset+r.BYTES_PER_ELEMENT*e,2*(r.length-e))}function Tt(r,e){return new jr(r.buffer,r.byteOffset+r.BYTES_PER_ELEMENT*e,2*(r.length-e))}function xt(r){var e,t,n;for(e=[];!(t=r.next()).done;)if(ke(n=t.value)&&n.length>=2)e.push(n[0],n[1]);else{if(!lt(n))return new TypeError(Y("invalid argument. An iterator must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",n));e.push(bt(n),Et(n))}return e}q(wt,"BYTES_PER_ELEMENT",4),q(wt.prototype,"BYTES_PER_ELEMENT",4),q(wt.prototype,"byteLength",8),q(wt.prototype,"toString",(function(){var r=""+this.re;return this.im<0?r+=" - "+-this.im:r+=" + "+this.im,r+="i"})),q(wt.prototype,"toJSON",(function(){var r={type:"Complex64"};return r.re=this.re,r.im=this.im,r}));var At=2*Rr.BYTES_PER_ELEMENT,Vt=gt();function jt(r){return r instanceof Lt||"object"==typeof r&&null!==r&&("Complex64Array"===r.constructor.name||"Complex128Array"===r.constructor.name)&&"number"==typeof r._length&&"object"==typeof r._buffer}function St(r){return r===Lt||"Complex128Array"===r.name}function Ft(r,e){return new wt(r[e*=2],r[e+1])}function Lt(){var r,e,t,n;if(e=arguments.length,!(this instanceof Lt))return 0===e?new Lt:1===e?new Lt(arguments[0]):2===e?new Lt(arguments[0],arguments[1]):new Lt(arguments[0],arguments[1],arguments[2]);if(0===e)t=new Rr(0);else if(1===e)if(Se(arguments[0]))t=new Rr(2*arguments[0]);else if(Be(arguments[0]))if((n=(t=arguments[0]).length)&&gr(t)&<(t[0])){if(t=function(r,e){var t,n,o,i;for(t=e.length,i=0,o=0;ot.byteLength-r)throw new RangeError(Y("invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.",n*At));t=new Rr(t,r,2*n)}}return q(this,"_buffer",t),q(this,"_length",t.length/2),this}function It(r,e){if(!(this instanceof It))throw new TypeError("invalid invocation. Constructor must be called with the `new` keyword.");if(!ye(r))throw new TypeError(Y("invalid argument. Real component must be a number. Value: `%s`.",r));if(!ye(e))throw new TypeError(Y("invalid argument. Imaginary component must be a number. Value: `%s`.",e));return X(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:r}),X(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:e}),this}function kt(r){return r.re}function Rt(r){return r.im}function Bt(r){var e,t,n;for(e=[];!(t=r.next()).done;)if(ke(n=t.value)&&n.length>=2)e.push(n[0],n[1]);else{if(!lt(n))return new TypeError(Y("invalid argument. An iterator must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",n));e.push(kt(n),Rt(n))}return e}q(Lt,"BYTES_PER_ELEMENT",At),q(Lt,"name","Complex64Array"),q(Lt,"from",(function(r){var e,t,o,i,a,u,s,l,c,h,p,m;if(!ot(this))throw new TypeError("invalid invocation. `this` context must be a constructor.");if(!St(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if((t=arguments.length)>1){if(!ot(o=arguments[1]))throw new TypeError(Y("invalid argument. Second argument must be a function. Value: `%s`.",o));t>2&&(e=arguments[2])}if(jt(r)){if(l=r.length,o){for(a=(i=new this(l))._buffer,m=0,p=0;p=2))throw new TypeError(Y("invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",h));a[m]=h[0],a[m+1]=h[1]}m+=2}return i}return new this(r)}if(Be(r)){if(o){for(l=r.length,s=r.get&&r.set?n("default"):f("default"),p=0;p=2))throw new TypeError(Y("invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",h));a[m]=h[0],a[m+1]=h[1]}m+=2}return i}return new this(r)}if(Me(r)&&Vt&&ot(r[vt])){if(!ot((a=r[vt]()).next))throw new TypeError(Y("invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.",r));if(u=o?function(r,e,t){var n,o,i,a;for(n=[],a=-1;!(o=r.next()).done;)if(a+=1,ke(i=e.call(t,o.value,a))&&i.length>=2)n.push(i[0],i[1]);else{if(!lt(i))return new TypeError(Y("invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",i));n.push(bt(i),Et(i))}return n}(a,o,e):xt(a),u instanceof Error)throw u;for(a=(i=new this(l=u.length/2))._buffer,p=0;p=this._length))return Ft(this._buffer,r)})),dt(Lt.prototype,"buffer",(function(){return this._buffer.buffer})),dt(Lt.prototype,"byteLength",(function(){return this._buffer.byteLength})),dt(Lt.prototype,"byteOffset",(function(){return this._buffer.byteOffset})),q(Lt.prototype,"BYTES_PER_ELEMENT",Lt.BYTES_PER_ELEMENT),q(Lt.prototype,"copyWithin",(function(r,e){if(!jt(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");return 2===arguments.length?this._buffer.copyWithin(2*r,2*e):this._buffer.copyWithin(2*r,2*e,2*arguments[2]),this})),q(Lt.prototype,"entries",(function(){var r,e,t,n,o,i,a;if(!jt(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");return e=this,r=this._buffer,n=this._length,i=-1,a=-2,q(t={},"next",(function(){var e;if(i+=1,o||i>=n)return{done:!0};return e=new wt(r[a+=2],r[a+1]),{value:[i,e],done:!1}})),q(t,"return",(function(r){if(o=!0,arguments.length)return{value:r,done:!0};return{done:!0}})),vt&&q(t,vt,(function(){return e.entries()})),t})),q(Lt.prototype,"every",(function(r,e){var t,n;if(!jt(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!ot(r))throw new TypeError(Y("invalid argument. First argument must be a function. Value: `%s`.",r));for(t=this._buffer,n=0;n1){if(!Te(e))throw new TypeError(Y("invalid argument. Second argument must be an integer. Value: `%s`.",e));if(e<0&&(e+=o)<0&&(e=0),arguments.length>2){if(!Te(t))throw new TypeError(Y("invalid argument. Third argument must be an integer. Value: `%s`.",t));t<0&&(t+=o)<0&&(t=0),t>o&&(t=o)}else t=o}else e=0,t=o;for(a=bt(r),f=Et(r),u=e;u=0;n--)if(o=Ft(t,n),r.call(e,o,n,this))return o})),q(Lt.prototype,"findLastIndex",(function(r,e){var t,n,o;if(!jt(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!ot(r))throw new TypeError(Y("invalid argument. First argument must be a function. Value: `%s`.",r));for(t=this._buffer,n=this._length-1;n>=0;n--)if(o=Ft(t,n),r.call(e,o,n,this))return n;return-1})),q(Lt.prototype,"forEach",(function(r,e){var t,n,o;if(!jt(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!ot(r))throw new TypeError(Y("invalid argument. First argument must be a function. Value: `%s`.",r));for(t=this._buffer,n=0;n=this._length))return Ft(this._buffer,r)})),q(Lt.prototype,"includes",(function(r,e){var t,n,o,i,a;if(!jt(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!lt(r))throw new TypeError(Y("invalid argument. First argument must be a complex number. Value: `%s`.",r));if(arguments.length>1){if(!Te(e))throw new TypeError(Y("invalid argument. Second argument must be an integer. Value: `%s`.",e));e<0&&(e+=this._length)<0&&(e=0)}else e=0;for(o=bt(r),i=Et(r),t=this._buffer,a=e;a1){if(!Te(e))throw new TypeError(Y("invalid argument. Second argument must be an integer. Value: `%s`.",e));e<0&&(e+=this._length)<0&&(e=0)}else e=0;for(o=bt(r),i=Et(r),t=this._buffer,a=e;a1){if(!Te(e))throw new TypeError(Y("invalid argument. Second argument must be an integer. Value: `%s`.",e));e>=this._length?e=this._length-1:e<0&&(e+=this._length)}else e=this._length-1;for(o=bt(r),i=Et(r),t=this._buffer,a=e;a>=0;a--)if(o===t[n=2*a]&&i===t[n+1])return a;return-1})),dt(Lt.prototype,"length",(function(){return this._length})),q(Lt.prototype,"map",(function(r,e){var t,n,o,i,a;if(!jt(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!ot(r))throw new TypeError(Y("invalid argument. First argument must be a function. Value: `%s`.",r));for(n=this._buffer,t=(o=new this.constructor(this._length))._buffer,i=0;i1)n=e,i=0;else{if(0===o)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");n=Ft(t,0),i=1}for(;i1){if(!Se(t=arguments[1]))throw new TypeError(Y("invalid argument. Index argument must be a nonnegative integer. Value: `%s`.",t))}else t=0;if(lt(r)){if(t>=this._length)throw new RangeError(Y("invalid argument. Index argument is out-of-bounds. Value: `%u`.",t));return n[t*=2]=bt(r),void(n[t+1]=Et(r))}if(jt(r)){if(t+(a=r._length)>this._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");if(e=r._buffer,s=n.byteOffset+t*At,e.buffer===n.buffer&&e.byteOffsets){for(o=new Rr(e.length),u=0;uthis._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");if(e=r,s=n.byteOffset+t*At,e.buffer===n.buffer&&e.byteOffsets){for(o=new Rr(a),u=0;uthis._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");for(t*=2,u=0;uf&&(e=f)}}for(t=ro&&(e=o)}}return r>=o?(o=0,t=n.byteLength):r>=e?(o=0,t=n.byteOffset+r*At):(o=e-r,t=n.byteOffset+r*At),new this.constructor(n.buffer,t,o<0?0:o)})),q(Lt.prototype,"toReversed",(function(){var r,e,t,n,o,i;if(!jt(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");for(t=this._length,e=new this.constructor(t),n=this._buffer,r=e._buffer,o=0;o=o)throw new RangeError(Y("invalid argument. Index argument is out-of-bounds. Value: `%s`.",r));if(!lt(e))throw new TypeError(Y("invalid argument. Second argument must be a complex number. Value: `%s`.",e));return(t=(n=new this.constructor(this._buffer))._buffer)[2*r]=bt(e),t[2*r+1]=Et(e),n})),q(It,"BYTES_PER_ELEMENT",8),q(It.prototype,"BYTES_PER_ELEMENT",8),q(It.prototype,"byteLength",16),q(It.prototype,"toString",(function(){var r=""+this.re;return this.im<0?r+=" - "+-this.im:r+=" + "+this.im,r+="i"})),q(It.prototype,"toJSON",(function(){var r={type:"Complex128"};return r.re=this.re,r.im=this.im,r}));var Ot=2*jr.BYTES_PER_ELEMENT,Ct=gt();function Mt(r){return r instanceof Ut||"object"==typeof r&&null!==r&&("Complex64Array"===r.constructor.name||"Complex128Array"===r.constructor.name)&&"number"==typeof r._length&&"object"==typeof r._buffer}function Nt(r){return r===Ut||"Complex64Array"===r.name}function Pt(r,e){return new It(r[e*=2],r[e+1])}function Ut(){var r,e,t,n;if(e=arguments.length,!(this instanceof Ut))return 0===e?new Ut:1===e?new Ut(arguments[0]):2===e?new Ut(arguments[0],arguments[1]):new Ut(arguments[0],arguments[1],arguments[2]);if(0===e)t=new jr(0);else if(1===e)if(Se(arguments[0]))t=new jr(2*arguments[0]);else if(Be(arguments[0]))if((n=(t=arguments[0]).length)&&gr(t)&<(t[0])){if(t=function(r,e){var t,n,o,i;for(t=e.length,i=0,o=0;ot.byteLength-r)throw new RangeError(Y("invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.",n*Ot));t=new jr(t,r,2*n)}}return q(this,"_buffer",t),q(this,"_length",t.length/2),this}q(Ut,"BYTES_PER_ELEMENT",Ot),q(Ut,"name","Complex128Array"),q(Ut,"from",(function(r){var e,t,o,i,a,u,s,l,c,h,p,m;if(!ot(this))throw new TypeError("invalid invocation. `this` context must be a constructor.");if(!Nt(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if((t=arguments.length)>1){if(!ot(o=arguments[1]))throw new TypeError(Y("invalid argument. Second argument must be a function. Value: `%s`.",o));t>2&&(e=arguments[2])}if(Mt(r)){if(l=r.length,o){for(a=(i=new this(l))._buffer,m=0,p=0;p=2))throw new TypeError(Y("invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",h));a[m]=h[0],a[m+1]=h[1]}m+=2}return i}return new this(r)}if(Be(r)){if(o){for(l=r.length,s=r.get&&r.set?n("default"):f("default"),p=0;p=2))throw new TypeError(Y("invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",h));a[m]=h[0],a[m+1]=h[1]}m+=2}return i}return new this(r)}if(Me(r)&&Ct&&ot(r[vt])){if(!ot((a=r[vt]()).next))throw new TypeError(Y("invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.",r));if(u=o?function(r,e,t){var n,o,i,a;for(n=[],a=-1;!(o=r.next()).done;)if(a+=1,ke(i=e.call(t,o.value,a))&&i.length>=2)n.push(i[0],i[1]);else{if(!lt(i))return new TypeError(Y("invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",i));n.push(kt(i),Rt(i))}return n}(a,o,e):Bt(a),u instanceof Error)throw u;for(a=(i=new this(l=u.length/2))._buffer,p=0;p=this._length))return Pt(this._buffer,r)})),dt(Ut.prototype,"buffer",(function(){return this._buffer.buffer})),dt(Ut.prototype,"byteLength",(function(){return this._buffer.byteLength})),dt(Ut.prototype,"byteOffset",(function(){return this._buffer.byteOffset})),q(Ut.prototype,"BYTES_PER_ELEMENT",Ut.BYTES_PER_ELEMENT),q(Ut.prototype,"copyWithin",(function(r,e){if(!Mt(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");return 2===arguments.length?this._buffer.copyWithin(2*r,2*e):this._buffer.copyWithin(2*r,2*e,2*arguments[2]),this})),q(Ut.prototype,"entries",(function(){var r,e,t,n,o,i,a;if(!Mt(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");return e=this,r=this._buffer,n=this._length,i=-1,a=-2,q(t={},"next",(function(){var e;if(i+=1,o||i>=n)return{done:!0};return e=new It(r[a+=2],r[a+1]),{value:[i,e],done:!1}})),q(t,"return",(function(r){if(o=!0,arguments.length)return{value:r,done:!0};return{done:!0}})),vt&&q(t,vt,(function(){return e.entries()})),t})),q(Ut.prototype,"every",(function(r,e){var t,n;if(!Mt(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!ot(r))throw new TypeError(Y("invalid argument. First argument must be a function. Value: `%s`.",r));for(t=this._buffer,n=0;n1){if(!Te(e))throw new TypeError(Y("invalid argument. Second argument must be an integer. Value: `%s`.",e));if(e<0&&(e+=o)<0&&(e=0),arguments.length>2){if(!Te(t))throw new TypeError(Y("invalid argument. Third argument must be an integer. Value: `%s`.",t));t<0&&(t+=o)<0&&(t=0),t>o&&(t=o)}else t=o}else e=0,t=o;for(a=kt(r),f=Rt(r),u=e;u=0;n--)if(o=Pt(t,n),r.call(e,o,n,this))return o})),q(Ut.prototype,"findLastIndex",(function(r,e){var t,n,o;if(!Mt(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!ot(r))throw new TypeError(Y("invalid argument. First argument must be a function. Value: `%s`.",r));for(t=this._buffer,n=this._length-1;n>=0;n--)if(o=Pt(t,n),r.call(e,o,n,this))return n;return-1})),q(Ut.prototype,"forEach",(function(r,e){var t,n,o;if(!Mt(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!ot(r))throw new TypeError(Y("invalid argument. First argument must be a function. Value: `%s`.",r));for(t=this._buffer,n=0;n=this._length))return Pt(this._buffer,r)})),dt(Ut.prototype,"length",(function(){return this._length})),q(Ut.prototype,"includes",(function(r,e){var t,n,o,i,a;if(!Mt(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!lt(r))throw new TypeError(Y("invalid argument. First argument must be a complex number. Value: `%s`.",r));if(arguments.length>1){if(!Te(e))throw new TypeError(Y("invalid argument. Second argument must be an integer. Value: `%s`.",e));e<0&&(e+=this._length)<0&&(e=0)}else e=0;for(o=kt(r),i=Rt(r),t=this._buffer,a=e;a1){if(!Te(e))throw new TypeError(Y("invalid argument. Second argument must be an integer. Value: `%s`.",e));e<0&&(e+=this._length)<0&&(e=0)}else e=0;for(o=kt(r),i=Rt(r),t=this._buffer,a=e;a1){if(!Te(e))throw new TypeError(Y("invalid argument. Second argument must be an integer. Value: `%s`.",e));e>=this._length?e=this._length-1:e<0&&(e+=this._length)}else e=this._length-1;for(o=kt(r),i=Rt(r),t=this._buffer,a=e;a>=0;a--)if(o===t[n=2*a]&&i===t[n+1])return a;return-1})),q(Ut.prototype,"map",(function(r,e){var t,n,o,i,a;if(!Mt(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!ot(r))throw new TypeError(Y("invalid argument. First argument must be a function. Value: `%s`.",r));for(n=this._buffer,t=(o=new this.constructor(this._length))._buffer,i=0;i1)n=e,i=0;else{if(0===o)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");n=Pt(t,0),i=1}for(;i1){if(!Se(t=arguments[1]))throw new TypeError(Y("invalid argument. Index argument must be a nonnegative integer. Value: `%s`.",t))}else t=0;if(lt(r)){if(t>=this._length)throw new RangeError(Y("invalid argument. Index argument is out-of-bounds. Value: `%u`.",t));return n[t*=2]=kt(r),void(n[t+1]=Rt(r))}if(Mt(r)){if(t+(a=r._length)>this._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");if(e=r._buffer,s=n.byteOffset+t*Ot,e.buffer===n.buffer&&e.byteOffsets){for(o=new jr(e.length),u=0;uthis._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");if(e=r,s=n.byteOffset+t*Ot,e.buffer===n.buffer&&e.byteOffsets){for(o=new jr(a),u=0;uthis._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");for(t*=2,u=0;uf&&(e=f)}}for(t=ro&&(e=o)}}return r>=o?(o=0,t=n.byteLength):r>=e?(o=0,t=n.byteOffset+r*Ot):(o=e-r,t=n.byteOffset+r*Ot),new this.constructor(n.buffer,t,o<0?0:o)})),q(Ut.prototype,"toReversed",(function(){var r,e,t,n,o,i;if(!Mt(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");for(t=this._length,e=new this.constructor(t),n=this._buffer,r=e._buffer,o=0;o=o)throw new RangeError(Y("invalid argument. Index argument is out-of-bounds. Value: `%s`.",r));if(!lt(e))throw new TypeError(Y("invalid argument. Second argument must be a complex number. Value: `%s`.",e));return(t=(n=new this.constructor(this._buffer))._buffer)[2*r]=kt(e),t[2*r+1]=Rt(e),n}));var Yt=[jr,Rr,$r,Nr,Qr,zr,me,oe,se,Lt,Ut],Wt=["float64","float32","int32","uint32","int16","uint16","int8","uint8","uint8c","complex64","complex128"],$t=Wt.length;function Zt(r){var t=function(r){var e;if(gr(r))return"generic";if(dr(r))return null;for(e=0;e<$t;e++)if(r instanceof Yt[e])return Wt[e];return _r[Er(r)]||null}(r);return e(r)?{data:r,dtype:t,accessorProtocol:!0,accessors:[n(t),i(t)]}:{data:r,dtype:t,accessorProtocol:!1,accessors:[f(t),s(t)]}}function Gt(r,e,t,n){var o,i,a;for(i=2*t,a=2*n,o=0;a>=0&&a=0&&!(((s=r[i])<0?-s:s)<=t);)r[i+1]=s,e[a+1]=e[a],i-=1,a-=1;r[i+1]=f,e[a+1]=u,n+=1,o+=1}}(e=c(e),t),{sh:r=Jt(r,t),sx:e,idx:t}}q(fr,"assign",(function(r,e,t){var n=Zt(r);return n.accessorProtocol?"complex128"===n.dtype?Gt(r,Tt(r,0),e,t):"complex64"===n.dtype?Gt(r,_t(r,0),e,t):function(r,e,t){var n,o,i,a;for(n=r.data,o=r.accessors[1],a=t,i=0;a>=0&&a=0&&o=f&&(o=f-1);else if("wrap"===i)o<0?(o+=f)<0&&0!==(o%=f)&&(o+=f):o>=f&&(o-=f)>=f&&(o%=f);else if("normalize"===i&&o<0&&(o+=f),o<0||o>=f)throw new RangeError(Y("invalid argument. Linear index must not exceed array dimensions. Number of array elements: `%u`. Value: `%d`.",f,o));if(u=t,"column-major"===n){for(l=0;l=0;l--)o-=s=o%r[l],o/=r[l],u+=s*e[l];return u}var Qt=Math.ceil;function rn(r){return r<0?Qt(r):_e(r)}function en(r,e,t,n,o,i,a){var f,u,s,l,c;for(f=r.length,u=1,c=0;c=u&&(o=u-1);else if("wrap"===i)o<0?(o+=u)<0&&0!==(o%=u)&&(o+=u):o>=u&&(o-=u)>=u&&(o%=u);else if("normalize"===i&&o<0&&(o+=u),o<0||o>=u)throw new RangeError(Y("invalid argument. Linear index must not exceed array dimensions. Number of array elements: `%u`. Value: `%d`.",u,o));if(0===t){if("column-major"===n){for(c=0;c=0;c--)o-=l=o%r[c],o/=r[c],a[c]=l;return a}if("column-major"===n){for(c=f-1;c>=0;c--)(l=e[c])<0?(o-=(s=rn(o/l))*l,a[c]=r[c]-1+s):(o-=(s=rn(o/l))*l,a[c]=s);return a}for(c=0;c0;)for(d0;)for(v0;)for(T0;)for(_0;)for(E0;)for(S0;)for(j0;)for(V0;)for(A0;)for(R0;)for(k0;)for(I0;)for(L0;)for(F0;)for(N0;)for(M0;)for(C0;)for(O0;)for(B0;)for(R0;)for($0;)for(W0;)for(Y0;)for(U0;)for(P0;)for(N0;)for(M0;)for(z0;)for(K0;)for(J0;)for(G0;)for(Z0;)for($0;)for(W0;)for(Y0;)for(Q0;)for(H0;)for(D0;)for(q0;)for(X0;)for(z0;)for(K0;)for(J0;)for(G0;)for(or0;)for(nr0;)for(tr0;)for(er0;)for(rr0;)for(Q0;)for(H0;)for(D0;)for(q0;)for(X0;)for(w0;)for(d0;)for(x0;)for(T0;)for(_0;)for(F0;)for(S0;)for(j0;)for(V0;)for(B0;)for(R0;)for(k0;)for(I0;)for(L0;)for(P0;)for(N0;)for(M0;)for(C0;)for(O0;)for(B0;)for(Z0;)for($0;)for(W0;)for(Y0;)for(U0;)for(P0;)for(N0;)for(X0;)for(z0;)for(K0;)for(J0;)for(G0;)for(Z0;)for($0;)for(W0;)for(rr0;)for(Q0;)for(H0;)for(D0;)for(q0;)for(X0;)for(z0;)for(K0;)for(J0;)for(ir0;)for(or0;)for(nr0;)for(tr0;)for(er0;)for(rr0;)for(Q0;)for(H0;)for(D0;)for(q