@compute.ts/math
Version:
Provide math operators for the computeTS package
1 lines • 3.91 kB
JavaScript
;function arcCos(r){if(r<-1||1<r)throw Error("The given value: "+r+", is not in the arcCos domain [-1: 1]");return Math.acos(r)}function arcCosH(r){var t=Math.acosh(r);if(isNaN(t))throw Error("The given value: "+r+", is not in the arcCosH domain");return t}function arcSin(r){var t=Math.asin(r);if(isNaN(t))throw Error("The given value: "+r+", is not in the arcSin domain");return t}function arcSinH(r){var t=Math.asinh(r);if(isNaN(t))throw Error("The given value: "+r+", is not in the arcSinH domain");return t}function arcTan(r){var t=Math.atan(r);if(isNaN(t))throw Error("The given value: "+r+", is not in the arcTan domain");return t}function arcTan2(r,t){var n=Math.atan2(r,t);if(isNaN(n))throw Error("The given values: "+r+" or "+t+" are not in the arcTan2 domain");return n}function arcTanH(r){var t=Math.atanh(r);if(isNaN(t))throw Error("The given value: "+r+", is not in the arcTanH domain");return t}function ceil(r){return Math.ceil(r)}function cos(r){return Math.cos(r)}function cosH(r){var t=Math.cosh(r);if(isNaN(t))throw Error("The given value: "+r+", is not in the cosH domain");return t}function exp(r){return Math.exp(r)}function floor(r){return Math.floor(r)}function gcd(r,t){for(;t;){var n=r%=t;r=t,t=n}return r}function inverse(r){if(0===r)throw Error("The given value is zero");return 1/r}function log2(r){if(r<=0)throw Error("The given value is negative");return Math.log2(r)}function log10(r){if(r<=0)throw Error("The given value is negative");return Math.log10(r)}function max(r){for(var t=r[0],n=0,o=r;n<o.length;n++){var e=o[n];t<e&&(t=e)}return t}function argMax(r){for(var t=r[0],n=0,o=0;o<r.length;o++){var e=r[o];t<e&&(t=e,n=o)}return n}function mean(r){return sum(r)/r.length}function sum(r){for(var t=0,n=0,o=r;n<o.length;n++)t+=o[n];return t}function times(r){for(var t=1,n=0,o=r;n<o.length;n++)t*=o[n];return t}function median(r){return r.sort(),r[Math.floor(r.length/2)]}function min(r){for(var t=r[0],n=0,o=r;n<o.length;n++){var e=o[n];e<t&&(t=e)}return t}function sort(r){return r.sort()}function argMin(r){for(var t=r[0],n=0,o=0;o<r.length;o++){var e=r[o];e<t&&(t=e,n=o)}return n}function pow(r,t){return Math.pow(r,t)}function sign(r){return Math.sign(r)}function sin(r){return Math.sin(r)}function sinH(r){var t=Math.sinh(r);if(isNaN(t))throw Error("The given value: "+r+", is not in the sinH domain");return t}function sqrt(r){r=Math.sqrt(r);if(isNaN(r))throw Error("The given value is negative");return r}function tan(r){return Math.tan(r)}function tanH(r){var t=Math.tanh(r);if(isNaN(t))throw Error("The given value: "+r+", is not in the tanH domain");return t}function trunc(r){return Math.trunc(r)}function x2(r){return r*r}function x3(r){return r*r*r}Object.defineProperty(exports,"__esModule",{value:!0}),exports.x3=exports.x2=exports.trunc=exports.tanH=exports.tan=exports.sqrt=exports.sinH=exports.sin=exports.sign=exports.pow=exports.argMin=exports.sort=exports.min=exports.median=exports.times=exports.sum=exports.mean=exports.argMax=exports.max=exports.log10=exports.log2=exports.inverse=exports.gcd=exports.floor=exports.exp=exports.cosH=exports.cos=exports.ceil=exports.arcTanH=exports.arcTan2=exports.arcTan=exports.arcSinH=exports.arcSin=exports.arcCosH=exports.arcCos=void 0,exports.arcCos=arcCos,exports.arcCosH=arcCosH,exports.arcSin=arcSin,exports.arcSinH=arcSinH,exports.arcTan=arcTan,exports.arcTan2=arcTan2,exports.arcTanH=arcTanH,exports.ceil=ceil,exports.cos=cos,exports.cosH=cosH,exports.exp=exp,exports.floor=floor,exports.gcd=gcd,exports.inverse=inverse,exports.log2=log2,exports.log10=log10,exports.max=max,exports.argMax=argMax,exports.mean=mean,exports.sum=sum,exports.times=times,exports.median=median,exports.min=min,exports.sort=sort,exports.argMin=argMin,exports.pow=pow,exports.sign=sign,exports.sin=sin,exports.sinH=sinH,exports.sqrt=sqrt,exports.tan=tan,exports.tanH=tanH,exports.trunc=trunc,exports.x2=x2,exports.x3=x3;