UNPKG

@stdlib/esm

Version:

ES module distribution for Stdlib, a standard library for JavaScript and Node.js.

3 lines 3.19 kB
// This file is a part of stdlib. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 import t from"./../../utils/define-nonenumerable-read-only-property.js";import e from"./../../utils/define-nonenumerable-read-only-accessor.js";import r from"./../../utils/define-nonenumerable-read-write-accessor.js";import n from"./../../assert/is-plain-object.js";import o from"./../../assert/is-function.js";import i from"./../../assert/is-boolean.js";import s from"./../../assert/has-own-property.js";import a from"./../../assert/is-uint32array.js";import p from"./mt19937.js";import m from"./../../utils/constant-function.js";import u from"./../../utils/noop.js";import l from"./../../array/to-json.js";import f from"./../../math/base/special/sqrt.js";import c from"./../../math/base/special/ln.js";import d from"./../../math/base/special/sin.js";import h from"./../../math/base/special/cos.js";import y from"./../../constants/math/float64-two-pi.js";import g from"./../../constants/math/float64-pi.js";var b=f,j=c,v=d,w=h,N=y;function M(t){var e,r;return e=!0,function(){var n,o,i,s;if(e){do{n=t(),o=t()}while(0===n);return i=b(-2*j(n)),r=i*w(s=N*o),e=!1,i*v(s)}return e=!0,r}}var L=f,E=c,O=h,A=g,I=O(A);function T(t){return L(-2*E(t))*I}var x=f,q=c,P=h,z=y;function G(t){return x(-2*q(t))*P(z*t)}var J=t,R=e,S=r,X=n,k=o,U=i.isPrimitive,V=s,B=a,C=p.factory,D=m,F=u,H=l,K=M,Q=T,W=G;function Y(t){var e,r,n,o;if(o={copy:!0},arguments.length){if(!X(t))throw new TypeError("invalid argument. Must provide an object. Value: `"+t+"`.");if(V(t,"copy")&&(o.copy=t.copy,!U(t.copy)))throw new TypeError("invalid option. `copy` option must be a boolean. Option: `"+t.copy+"`.");if(V(t,"prng")){if(!k(t.prng))throw new TypeError("invalid option. `prng` option must be a pseudorandom number generator function. Option: `"+t.prng+"`.");e=t.prng}else if(V(t,"state")){if(o.state=t.state,!B(t.state))throw new TypeError("invalid option. `state` option must be a Uint32Array. Option: `"+t.state+"`.")}else if(V(t,"seed")&&(o.seed=t.seed,void 0===t.seed))throw new TypeError("invalid option. `seed` option must be either a positive integer less than or equal to the maximum unsigned 32-bit integer or an array-like object containing integer values less than or equal to the maximum unsigned 32-bit integer. Option: `"+t.seed+"`.")}return void 0===o.state?void 0===e?e=(n=C(o)).normalized:o.seed=null:e=(n=C(o)).normalized,r=K(e),J(r,"NAME","box-muller"),null===o.seed?(J(r,"seed",null),J(r,"seedLength",null)):(R(r,"seed",i),R(r,"seedLength",s)),t&&t.prng?(S(r,"state",D(null),F),J(r,"stateLength",null),J(r,"byteLength",null),J(r,"toJSON",D(null))):(S(r,"state",m,u),R(r,"stateLength",a),R(r,"byteLength",p),J(r,"toJSON",l)),J(r,"PRNG",e),V(e,"MIN")?(J(r,"MIN",Q(e.MIN)),J(r,"MAX",W(e.MIN))):(J(r,"MIN",null),J(r,"MAX",null)),r;function i(){return n.seed}function s(){return n.seedLength}function a(){return n.stateLength}function p(){return n.byteLength}function m(){return n.state}function u(t){n.state=t}function l(){var t={type:"PRNG"};return t.name=r.NAME,t.state=H(n.state),t.params=[],t}}var Z=Y,$=Z(),_=t,tt=$,et=Y;_(tt,"factory",et);export default tt; //# sourceMappingURL=box-muller.js.map