Untitled
4 years ago in Plain Text
<html>
<head>
<style>
.il {
display: inline-block;
width: 400px;
}
.app {
width: 500px;
}
h4 {
margin-bottom: 5px;
}
.slidecontainer {
width: 100%;
}
.td1 {
padding: 0 0 0 10px;
}
.slider {
-webkit-appearance: none;
/* Override default CSS styles */
appearance: none;
width: 100%;
/* Full-width */
height: 15px;
/* Specified height */
background: #d3d3d3;
/* Grey background */
outline: none;
/* Remove outline */
opacity: 0.7;
/* Set transparency (for mouse-over effects on hover) */
-webkit-transition: .2s;
/* 0.2 seconds transition on hover */
transition: opacity .2s;
}
/* Mouse-over effects */
.slider:hover {
opacity: 1;
/* Fully shown on mouse-over */
}
/* The slider handle (use -webkit- (Chrome, Opera, Safari, Edge) and -moz- (Firefox) to override default look) */
.slider::-webkit-slider-thumb {
-webkit-appearance: none;
/* Override default look */
appearance: none;
width: 15px;
/* Set a specific slider handle width */
height: 15px;
/* Slider handle height */
background: #4CAF50;
/* Green background */
cursor: pointer;
/* Cursor on hover */
}
.slider::-moz-range-thumb {
width: 15px;
/* Set a specific slider handle width */
height: 15px;
/* Slider handle height */
background: #4CAF50;
/* Green background */
cursor: pointer;
/* Cursor on hover */
}
</style>
<!--<script src="https://rawgit.com/nicolaspanel/numjs/893016ec40e62eaaa126e1024dbe250aafb3014b/dist/numjs.min.js">
</script>-->
<script type="text/javascript">
/*! numjs#0.8.0 */
!function(r){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=r();else if("function"==typeof define&&define.amd)define([],r);else{var i;i="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,i.nj=r()}}(function(){return function r(i,n,t){function a(u,c){if(!n[u]){if(!i[u]){var e="function"==typeof require&&require;if(!c&&e)return e(u,!0);if(s)return s(u,!0);var f=new Error("Cannot find module '"+u+"'");throw f.code="MODULE_NOT_FOUND",f}var g=n[u]={exports:{}};i[u][0].call(g.exports,function(r){var n=i[u][1][r];return a(n?n:r)},g,g.exports,r,i,n,t)}return n[u].exports}for(var s="function"==typeof require&&require,u=0;u<t.length;u++)a(t[u]);return a}({1:[function(r,i,n){var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(r){"use strict";function i(r){var i=r.charCodeAt(0);return i===u||i===h?62:i===c||i===o?63:e>i?-1:e+10>i?i-e+26+26:g+26>i?i-g:f+26>i?i-f+26:void 0}function n(r){function n(r){f[h++]=r}var t,a,u,c,e,f;if(r.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var g=r.length;e="="===r.charAt(g-2)?2:"="===r.charAt(g-1)?1:0,f=new s(3*r.length/4-e),u=e>0?r.length-4:r.length;var h=0;for(t=0,a=0;u>t;t+=4,a+=3)c=i(r.charAt(t))<<18|i(r.charAt(t+1))<<12|i(r.charAt(t+2))<<6|i(r.charAt(t+3)),n((16711680&c)>>16),n((65280&c)>>8),n(255&c);return 2===e?(c=i(r.charAt(t))<<2|i(r.charAt(t+1))>>4,n(255&c)):1===e&&(c=i(r.charAt(t))<<10|i(r.charAt(t+1))<<4|i(r.charAt(t+2))>>2,n(c>>8&255),n(255&c)),f}function a(r){function i(r){return t.charAt(r)}function n(r){return i(r>>18&63)+i(r>>12&63)+i(r>>6&63)+i(63&r)}var a,s,u,c=r.length%3,e="";for(a=0,u=r.length-c;u>a;a+=3)s=(r[a]<<16)+(r[a+1]<<8)+r[a+2],e+=n(s);switch(c){case 1:s=r[r.length-1],e+=i(s>>2),e+=i(s<<4&63),e+="==";break;case 2:s=(r[r.length-2]<<8)+r[r.length-1],e+=i(s>>10),e+=i(s>>4&63),e+=i(s<<2&63),e+="="}return e}var s="undefined"!=typeof Uint8Array?Uint8Array:Array,u="+".charCodeAt(0),c="/".charCodeAt(0),e="0".charCodeAt(0),f="a".charCodeAt(0),g="A".charCodeAt(0),h="-".charCodeAt(0),o="_".charCodeAt(0);r.toByteArray=n,r.fromByteArray=a}("undefined"==typeof n?this.base64js={}:n)},{}],2:[function(r,i,n){"use strict";"use restrict";function t(r){var i=32;return r&=-r,r&&i--,65535&r&&(i-=16),16711935&r&&(i-=8),252645135&r&&(i-=4),858993459&r&&(i-=2),1431655765&r&&(i-=1),i}var a=32;n.INT_BITS=a,n.INT_MAX=2147483647,n.INT_MIN=-1<<a-1,n.sign=function(r){return(r>0)-(0>r)},n.abs=function(r){var i=r>>a-1;return(r^i)-i},n.min=function(r,i){return i^(r^i)&-(i>r)},n.max=function(r,i){return r^(r^i)&-(i>r)},n.isPow2=function(r){return!(r&r-1||!r)},n.log2=function(r){var i,n;return i=(r>65535)<<4,r>>>=i,n=(r>255)<<3,r>>>=n,i|=n,n=(r>15)<<2,r>>>=n,i|=n,n=(r>3)<<1,r>>>=n,i|=n,i|r>>1},n.log10=function(r){return r>=1e9?9:r>=1e8?8:r>=1e7?7:r>=1e6?6:r>=1e5?5:r>=1e4?4:r>=1e3?3:r>=100?2:r>=10?1:0},n.popCount=function(r){return r-=r>>>1&1431655765,r=(858993459&r)+(r>>>2&858993459),16843009*(r+(r>>>4)&252645135)>>>24},n.countTrailingZeros=t,n.nextPow2=function(r){return r+=0===r,--r,r|=r>>>1,r|=r>>>2,r|=r>>>4,r|=r>>>8,r|=r>>>16,r+1},n.prevPow2=function(r){return r|=r>>>1,r|=r>>>2,r|=r>>>4,r|=r>>>8,r|=r>>>16,r-(r>>>1)},n.parity=function(r){return r^=r>>>16,r^=r>>>8,r^=r>>>4,r&=15,27030>>>r&1};var s=new Array(256);!function(r){for(var i=0;256>i;++i){var n=i,t=i,a=7;for(n>>>=1;n;n>>>=1)t<<=1,t|=1&n,--a;r[i]=t<<a&255}}(s),n.reverse=function(r){return s[255&r]<<24|s[r>>>8&255]<<16|s[r>>>16&255]<<8|s[r>>>24&255]},n.interleave2=function(r,i){return r&=65535,r=16711935&(r|r<<8),r=252645135&(r|r<<4),r=858993459&(r|r<<2),r=1431655765&(r|r<<1),i&=65535,i=16711935&(i|i<<8),i=252645135&(i|i<<4),i=858993459&(i|i<<2),i=1431655765&(i|i<<1),r|i<<1},n.deinterleave2=function(r,i){return r=r>>>i&1431655765,r=858993459&(r|r>>>1),r=252645135&(r|r>>>2),r=16711935&(r|r>>>4),r=65535&(r|r>>>16),r<<16>>16},n.interleave3=function(r,i,n){return r&=1023,r=4278190335&(r|r<<16),r=251719695&(r|r<<8),r=3272356035&(r|r<<4),r=1227133513&(r|r<<2),i&=1023,i=4278190335&(i|i<<16),i=251719695&(i|i<<8),i=3272356035&(i|i<<4),i=1227133513&(i|i<<2),r|=i<<1,n&=1023,n=4278190335&(n|n<<16),n=251719695&(n|n<<8),n=3272356035&(n|n<<4),n=1227133513&(n|n<<2),r|n<<2},n.deinterleave3=function(r,i){return r=r>>>i&1227133513,r=3272356035&(r|r>>>2),r=251719695&(r|r>>>4),r=4278190335&(r|r>>>8),r=1023&(r|r>>>16),r<<22>>22},n.nextCombination=function(r){var i=r|r-1;return i+1|(~i&-~i)-1>>>t(r)+1}},{}],3:[function(r,i,n){(function(i){"use strict";function t(){function r(){}try{var i=new Uint8Array(1);return i.foo=function(){return 42},i.constructor=r,42===i.foo()&&i.constructor===r&&"function"==typeof i.subarray&&0===i.subarray(1,1).byteLength}catch(n){return!1}}function a(){return s.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function s(r){return this instanceof s?(s.TYPED_ARRAY_SUPPORT||(this.length=0,this.parent=void 0),"number"==typeof r?u(this,r):"string"==typeof r?c(this,r,arguments.length>1?arguments[1]:"utf8"):e(this,r)):arguments.length>1?new s(r,arguments[1]):new s(r)}function u(r,i){if(r=X(r,0>i?0:0|b(i)),!s.TYPED_ARRAY_SUPPORT)for(var n=0;i>n;n++)r[n]=0;return r}function c(r,i,n){("string"!=typeof n||""===n)&&(n="utf8");var t=0|j(i,n);return r=X(r,t),r.write(i,n),r}function e(r,i){if(s.isBuffer(i))return f(r,i);if(Y(i))return g(r,i);if(null==i)throw new TypeError("must start with number, buffer, array or string");if("undefined"!=typeof ArrayBuffer){if(i.buffer instanceof ArrayBuffer)return h(r,i);if(i instanceof ArrayBuffer)return o(r,i)}return i.length?v(r,i):y(r,i)}function f(r,i){var n=0|b(i.length);return r=X(r,n),i.copy(r,0,0,n),r}function g(r,i){var n=0|b(i.length);r=X(r,n);for(var t=0;n>t;t+=1)r[t]=255&i[t];return r}function h(r,i){var n=0|b(i.length);r=X(r,n);for(var t=0;n>t;t+=1)r[t]=255&i[t];return r}function o(r,i){return s.TYPED_ARRAY_SUPPORT?(i.byteLength,r=s._augment(new Uint8Array(i))):r=h(r,new Uint8Array(i)),r}function v(r,i){var n=0|b(i.length);r=X(r,n);for(var t=0;n>t;t+=1)r[t]=255&i[t];return r}function y(r,i){var n,t=0;"Buffer"===i.type&&Y(i.data)&&(n=i.data,t=0|b(n.length)),r=X(r,t);for(var a=0;t>a;a+=1)r[a]=255&n[a];return r}function X(r,i){s.TYPED_ARRAY_SUPPORT?(r=s._augment(new Uint8Array(i)),r.__proto__=s.prototype):(r.length=i,r._isBuffer=!0);var n=0!==i&&i<=s.poolSize>>>1;return n&&(r.parent=Z),r}function b(r){if(r>=a())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a().toString(16)+" bytes");return 0|r}function d(r,i){if(!(this instanceof d))return new d(r,i);var n=new s(r,i);return delete n.parent,n}function j(r,i){"string"!=typeof r&&(r=""+r);var n=r.length;if(0===n)return 0;for(var t=!1;;)switch(i){case"ascii":case"binary":case"raw":case"raws":return n;case"utf8":case"utf-8":return Q(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return T(r).length;default:if(t)return Q(r).length;i=(""+i).toLowerCase(),t=!0}}function k(r,i,n){var t=!1;if(i=0|i,n=void 0===n||n===1/0?this.length:0|n,r||(r="utf8"),0>i&&(i=0),n>this.length&&(n=this.length),i>=n)return"";for(;;)switch(r){case"hex":return E(this,i,n);case"utf8":case"utf-8":return A(this,i,n);case"ascii":return C(this,i,n);case"binary":return D(this,i,n);case"base64":return z(this,i,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return F(this,i,n);default:if(t)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),t=!0}}function l(r,i,n,t){n=Number(n)||0;var a=r.length-n;t?(t=Number(t),t>a&&(t=a)):t=a;var s=i.length;if(s%2!==0)throw new Error("Invalid hex string");t>s/2&&(t=s/2);for(var u=0;t>u;u++){var c=parseInt(i.substr(2*u,2),16);if(isNaN(c))throw new Error("Invalid hex string");r[n+u]=c}return u}function m(r,i,n,t){return U(Q(i,r.length-n),r,n,t)}function p(r,i,n,t){return U(R(i),r,n,t)}function q(r,i,n,t){return p(r,i,n,t)}function w(r,i,n,t){return U(T(i),r,n,t)}function x(r,i,n,t){return U(S(i,r.length-n),r,n,t)}function z(r,i,n){return 0===i&&n===r.length?V.fromByteArray(r):V.fromByteArray(r.slice(i,n))}function A(r,i,n){n=Math.min(r.length,n);for(var t=[],a=i;n>a;){var s=r[a],u=null,c=s>239?4:s>223?3:s>191?2:1;if(n>=a+c){var e,f,g,h;switch(c){case 1:128>s&&(u=s);break;case 2:e=r[a+1],128===(192&e)&&(h=(31&s)<<6|63&e,h>127&&(u=h));break;case 3:e=r[a+1],f=r[a+2],128===(192&e)&&128===(192&f)&&(h=(15&s)<<12|(63&e)<<6|63&f,h>2047&&(55296>h||h>57343)&&(u=h));break;case 4:e=r[a+1],f=r[a+2],g=r[a+3],128===(192&e)&&128===(192&f)&&128===(192&g)&&(h=(15&s)<<18|(63&e)<<12|(63&f)<<6|63&g,h>65535&&1114112>h&&(u=h))}}null===u?(u=65533,c=1):u>65535&&(u-=65536,t.push(u>>>10&1023|55296),u=56320|1023&u),t.push(u),a+=c}return B(t)}function B(r){var i=r.length;if($>=i)return String.fromCharCode.apply(String,r);for(var n="",t=0;i>t;)n+=String.fromCharCode.apply(String,r.slice(t,t+=$));return n}function C(r,i,n){var t="";n=Math.min(r.length,n);for(var a=i;n>a;a++)t+=String.fromCharCode(127&r[a]);return t}function D(r,i,n){var t="";n=Math.min(r.length,n);for(var a=i;n>a;a++)t+=String.fromCharCode(r[a]);return t}function E(r,i,n){var t=r.length;(!i||0>i)&&(i=0),(!n||0>n||n>t)&&(n=t);for(var a="",s=i;n>s;s++)a+=P(r[s]);return a}function F(r,i,n){for(var t=r.slice(i,n),a="",s=0;s<t.length;s+=2)a+=String.fromCharCode(t[s]+256*t[s+1]);return a}function G(r,i,n){if(r%1!==0||0>r)throw new RangeError("offset is not uint");if(r+i>n)throw new RangeError("Trying to access beyond buffer length")}function H(r,i,n,t,a,u){if(!s.isBuffer(r))throw new TypeError("buffer must be a Buffer instance");if(i>a||u>i)throw new RangeError("value is out of bounds");if(n+t>r.length)throw new RangeError("index out of range")}function I(r,i,n,t){0>i&&(i=65535+i+1);for(var a=0,s=Math.min(r.length-n,2);s>a;a++)r[n+a]=(i&255<<8*(t?a:1-a))>>>8*(t?a:1-a)}function J(r,i,n,t){0>i&&(i=4294967295+i+1);for(var a=0,s=Math.min(r.length-n,4);s>a;a++)r[n+a]=i>>>8*(t?a:3-a)&255}function K(r,i,n,t,a,s){if(i>a||s>i)throw new RangeError("value is out of bounds");if(n+t>r.length)throw new RangeError("index out of range");if(0>n)throw new RangeError("index out of range")}function L(r,i,n,t,a){return a||K(r,i,n,4,3.4028234663852886e38,-3.4028234663852886e38),W.write(r,i,n,t,23,4),n+4}function M(r,i,n,t,a){return a||K(r,i,n,8,1.7976931348623157e308,-1.7976931348623157e308),W.write(r,i,n,t,52,8),n+8}function N(r){if(r=O(r).replace(rr,""),r.length<2)return"";for(;r.length%4!==0;)r+="=";return r}function O(r){return r.trim?r.trim():r.replace(/^\s+|\s+$/g,"")}function P(r){return 16>r?"0"+r.toString(16):r.toString(16)}function Q(r,i){i=i||1/0;for(var n,t=r.length,a=null,s=[],u=0;t>u;u++){if(n=r.charCodeAt(u),n>55295&&57344>n){if(!a){if(n>56319){(i-=3)>-1&&s.push(239,191,189);continue}if(u+1===t){(i-=3)>-1&&s.push(239,191,189);continue}a=n;continue}if(56320>n){(i-=3)>-1&&s.push(239,191,189),a=n;continue}n=(a-55296<<10|n-56320)+65536}else a&&(i-=3)>-1&&s.push(239,191,189);if(a=null,128>n){if((i-=1)<0)break;s.push(n)}else if(2048>n){if((i-=2)<0)break;s.push(n>>6|192,63&n|128)}else if(65536>n){if((i-=3)<0)break;s.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(1114112>n))throw new Error("Invalid code point");if((i-=4)<0)break;s.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return s}function R(r){for(var i=[],n=0;n<r.length;n++)i.push(255&r.charCodeAt(n));return i}function S(r,i){for(var n,t,a,s=[],u=0;u<r.length&&!((i-=2)<0);u++)n=r.charCodeAt(u),t=n>>8,a=n%256,s.push(a),s.push(t);return s}function T(r){return V.toByteArray(N(r))}function U(r,i,n,t){for(var a=0;t>a&&!(a+n>=i.length||a>=r.length);a++)i[a+n]=r[a];return a}var V=r("base64-js"),W=r("ieee754"),Y=r("isarray");n.Buffer=s,n.SlowBuffer=d,n.INSPECT_MAX_BYTES=50,s.poolSize=8192;var Z={};s.TYPED_ARRAY_SUPPORT=void 0!==i.TYPED_ARRAY_SUPPORT?i.TYPED_ARRAY_SUPPORT:t(),s.TYPED_ARRAY_SUPPORT?(s.prototype.__proto__=Uint8Array.prototype,s.__proto__=Uint8Array):(s.prototype.length=void 0,s.prototype.parent=void 0),s.isBuffer=function(r){return!(null==r||!r._isBuffer)},s.compare=function(r,i){if(!s.isBuffer(r)||!s.isBuffer(i))throw new TypeError("Arguments must be Buffers");if(r===i)return 0;for(var n=r.length,t=i.length,a=0,u=Math.min(n,t);u>a&&r[a]===i[a];)++a;return a!==u&&(n=r[a],t=i[a]),t>n?-1:n>t?1:0},s.isEncoding=function(r){switch(String(r).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},s.concat=function(r,i){if(!Y(r))throw new TypeError("list argument must be an Array of Buffers.");if(0===r.length)return new s(0);var n;if(void 0===i)for(i=0,n=0;n<r.length;n++)i+=r[n].length;var t=new s(i),a=0;for(n=0;n<r.length;n++){var u=r[n];u.copy(t,a),a+=u.length}return t},s.byteLength=j,s.prototype.toString=function(){var r=0|this.length;return 0===r?"":0===arguments.length?A(this,0,r):k.apply(this,arguments)},s.prototype.equals=function(r){if(!s.isBuffer(r))throw new TypeError("Argument must be a Buffer");return this===r?!0:0===s.compare(this,r)},s.prototype.inspect=function(){var r="",i=n.INSPECT_MAX_BYTES;return this.length>0&&(r=this.toString("hex",0,i).match(/.{2}/g).join(" "),this.length>i&&(r+=" ... ")),"<Buffer "+r+">"},s.prototype.compare=function(r){if(!s.isBuffer(r))throw new TypeError("Argument must be a Buffer");return this===r?0:s.compare(this,r)},s.prototype.indexOf=function(r,i){function n(r,i,n){for(var t=-1,a=0;n+a<r.length;a++)if(r[n+a]===i[-1===t?0:a-t]){if(-1===t&&(t=a),a-t+1===i.length)return n+t}else t=-1;return-1}if(i>2147483647?i=2147483647:-2147483648>i&&(i=-2147483648),i>>=0,0===this.length)return-1;if(i>=this.length)return-1;if(0>i&&(i=Math.max(this.length+i,0)),"string"==typeof r)return 0===r.length?-1:String.prototype.indexOf.call(this,r,i);if(s.isBuffer(r))return n(this,r,i);if("number"==typeof r)return s.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,r,i):n(this,[r],i);throw new TypeError("val must be string, number or Buffer")},s.prototype.get=function(r){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(r)},s.prototype.set=function(r,i){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(r,i)},s.prototype.write=function(r,i,n,t){if(void 0===i)t="utf8",n=this.length,i=0;else if(void 0===n&&"string"==typeof i)t=i,n=this.length,i=0;else if(isFinite(i))i=0|i,isFinite(n)?(n=0|n,void 0===t&&(t="utf8")):(t=n,n=void 0);else{var a=t;t=i,i=0|n,n=a}var s=this.length-i;if((void 0===n||n>s)&&(n=s),r.length>0&&(0>n||0>i)||i>this.length)throw new RangeError("attempt to write outside buffer bounds");t||(t="utf8");for(var u=!1;;)switch(t){case"hex":return l(this,r,i,n);case"utf8":case"utf-8":return m(this,r,i,n);case"ascii":return p(this,r,i,n);case"binary":return q(this,r,i,n);case"base64":return w(this,r,i,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,r,i,n);default:if(u)throw new TypeError("Unknown encoding: "+t);t=(""+t).toLowerCase(),u=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var $=4096;s.prototype.slice=function(r,i){var n=this.length;r=~~r,i=void 0===i?n:~~i,0>r?(r+=n,0>r&&(r=0)):r>n&&(r=n),0>i?(i+=n,0>i&&(i=0)):i>n&&(i=n),r>i&&(i=r);var t;if(s.TYPED_ARRAY_SUPPORT)t=s._augment(this.subarray(r,i));else{var a=i-r;t=new s(a,void 0);for(var u=0;a>u;u++)t[u]=this[u+r]}return t.length&&(t.parent=this.parent||this),t},s.prototype.readUIntLE=function(r,i,n){r=0|r,i=0|i,n||G(r,i,this.length);for(var t=this[r],a=1,s=0;++s<i&&(a*=256);)t+=this[r+s]*a;return t},s.prototype.readUIntBE=function(r,i,n){r=0|r,i=0|i,n||G(r,i,this.length);for(var t=this[r+--i],a=1;i>0&&(a*=256);)t+=this[r+--i]*a;return t},s.prototype.readUInt8=function(r,i){return i||G(r,1,this.length),this[r]},s.prototype.readUInt16LE=function(r,i){return i||G(r,2,this.length),this[r]|this[r+1]<<8},s.prototype.readUInt16BE=function(r,i){return i||G(r,2,this.length),this[r]<<8|this[r+1]},s.prototype.readUInt32LE=function(r,i){return i||G(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+16777216*this[r+3]},s.prototype.readUInt32BE=function(r,i){return i||G(r,4,this.length),16777216*this[r]+(this[r+1]<<16|this[r+2]<<8|this[r+3])},s.prototype.readIntLE=function(r,i,n){r=0|r,i=0|i,n||G(r,i,this.length);for(var t=this[r],a=1,s=0;++s<i&&(a*=256);)t+=this[r+s]*a;return a*=128,t>=a&&(t-=Math.pow(2,8*i)),t},s.prototype.readIntBE=function(r,i,n){r=0|r,i=0|i,n||G(r,i,this.length);for(var t=i,a=1,s=this[r+--t];t>0&&(a*=256);)s+=this[r+--t]*a;return a*=128,s>=a&&(s-=Math.pow(2,8*i)),s},s.prototype.readInt8=function(r,i){return i||G(r,1,this.length),128&this[r]?-1*(255-this[r]+1):this[r]},s.prototype.readInt16LE=function(r,i){i||G(r,2,this.length);var n=this[r]|this[r+1]<<8;return 32768&n?4294901760|n:n},s.prototype.readInt16BE=function(r,i){i||G(r,2,this.length);var n=this[r+1]|this[r]<<8;return 32768&n?4294901760|n:n},s.prototype.readInt32LE=function(r,i){return i||G(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24},s.prototype.readInt32BE=function(r,i){return i||G(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]},s.prototype.readFloatLE=function(r,i){return i||G(r,4,this.length),W.read(this,r,!0,23,4)},s.prototype.readFloatBE=function(r,i){return i||G(r,4,this.length),W.read(this,r,!1,23,4)},s.prototype.readDoubleLE=function(r,i){return i||G(r,8,this.length),W.read(this,r,!0,52,8)},s.prototype.readDoubleBE=function(r,i){return i||G(r,8,this.length),W.read(this,r,!1,52,8)},s.prototype.writeUIntLE=function(r,i,n,t){r=+r,i=0|i,n=0|n,t||H(this,r,i,n,Math.pow(2,8*n),0);var a=1,s=0;for(this[i]=255&r;++s<n&&(a*=256);)this[i+s]=r/a&255;return i+n},s.prototype.writeUIntBE=function(r,i,n,t){r=+r,i=0|i,n=0|n,t||H(this,r,i,n,Math.pow(2,8*n),0);var a=n-1,s=1;for(this[i+a]=255&r;--a>=0&&(s*=256);)this[i+a]=r/s&255;return i+n},s.prototype.writeUInt8=function(r,i,n){return r=+r,i=0|i,n||H(this,r,i,1,255,0),s.TYPED_ARRAY_SUPPORT||(r=Math.floor(r)),this[i]=255&r,i+1},s.prototype.writeUInt16LE=function(r,i,n){return r=+r,i=0|i,n||H(this,r,i,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[i]=255&r,this[i+1]=r>>>8):I(this,r,i,!0),i+2},s.prototype.writeUInt16BE=function(r,i,n){return r=+r,i=0|i,n||H(this,r,i,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[i]=r>>>8,this[i+1]=255&r):I(this,r,i,!1),i+2},s.prototype.writeUInt32LE=function(r,i,n){return r=+r,i=0|i,n||H(this,r,i,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[i+3]=r>>>24,this[i+2]=r>>>16,this[i+1]=r>>>8,this[i]=255&r):J(this,r,i,!0),i+4},s.prototype.writeUInt32BE=function(r,i,n){return r=+r,i=0|i,n||H(this,r,i,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[i]=r>>>24,this[i+1]=r>>>16,this[i+2]=r>>>8,this[i+3]=255&r):J(this,r,i,!1),i+4},s.prototype.writeIntLE=function(r,i,n,t){if(r=+r,i=0|i,!t){var a=Math.pow(2,8*n-1);H(this,r,i,n,a-1,-a)}var s=0,u=1,c=0>r?1:0;for(this[i]=255&r;++s<n&&(u*=256);)this[i+s]=(r/u>>0)-c&255;return i+n},s.prototype.writeIntBE=function(r,i,n,t){if(r=+r,i=0|i,!t){var a=Math.pow(2,8*n-1);H(this,r,i,n,a-1,-a)}var s=n-1,u=1,c=0>r?1:0;for(this[i+s]=255&r;--s>=0&&(u*=256);)this[i+s]=(r/u>>0)-c&255;return i+n},s.prototype.writeInt8=function(r,i,n){return r=+r,i=0|i,n||H(this,r,i,1,127,-128),s.TYPED_ARRAY_SUPPORT||(r=Math.floor(r)),0>r&&(r=255+r+1),this[i]=255&r,i+1},s.prototype.writeInt16LE=function(r,i,n){return r=+r,i=0|i,n||H(this,r,i,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[i]=255&r,this[i+1]=r>>>8):I(this,r,i,!0),i+2},s.prototype.writeInt16BE=function(r,i,n){return r=+r,i=0|i,n||H(this,r,i,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[i]=r>>>8,this[i+1]=255&r):I(this,r,i,!1),i+2},s.prototype.writeInt32LE=function(r,i,n){return r=+r,i=0|i,n||H(this,r,i,4,2147483647,-2147483648),s.TYPED_ARRAY_SUPPORT?(this[i]=255&r,this[i+1]=r>>>8,this[i+2]=r>>>16,this[i+3]=r>>>24):J(this,r,i,!0),i+4},s.prototype.writeInt32BE=function(r,i,n){return r=+r,i=0|i,n||H(this,r,i,4,2147483647,-2147483648),0>r&&(r=4294967295+r+1),s.TYPED_ARRAY_SUPPORT?(this[i]=r>>>24,this[i+1]=r>>>16,this[i+2]=r>>>8,this[i+3]=255&r):J(this,r,i,!1),i+4},s.prototype.writeFloatLE=function(r,i,n){return L(this,r,i,!0,n)},s.prototype.writeFloatBE=function(r,i,n){return L(this,r,i,!1,n)},s.prototype.writeDoubleLE=function(r,i,n){return M(this,r,i,!0,n)},s.prototype.writeDoubleBE=function(r,i,n){return M(this,r,i,!1,n)},s.prototype.copy=function(r,i,n,t){if(n||(n=0),t||0===t||(t=this.length),i>=r.length&&(i=r.length),i||(i=0),t>0&&n>t&&(t=n),t===n)return 0;if(0===r.length||0===this.length)return 0;if(0>i)throw new RangeError("targetStart out of bounds");if(0>n||n>=this.length)throw new RangeError("sourceStart out of bounds");if(0>t)throw new RangeError("sourceEnd out of bounds");t>this.length&&(t=this.length),r.length-i<t-n&&(t=r.length-i+n);var a,u=t-n;if(this===r&&i>n&&t>i)for(a=u-1;a>=0;a--)r[a+i]=this[a+n];else if(1e3>u||!s.TYPED_ARRAY_SUPPORT)for(a=0;u>a;a++)r[a+i]=this[a+n];else r._set(this.subarray(n,n+u),i);return u},s.prototype.fill=function(r,i,n){if(r||(r=0),i||(i=0),n||(n=this.length),i>n)throw new RangeError("end < start");if(n!==i&&0!==this.length){if(0>i||i>=this.length)throw new RangeError("start out of bounds");if(0>n||n>this.length)throw new RangeError("end out of bounds");var t;if("number"==typeof r)for(t=i;n>t;t++)this[t]=r;else{var a=Q(r.toString()),s=a.length;for(t=i;n>t;t++)this[t]=a[t%s]}return this}},s.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(s.TYPED_ARRAY_SUPPORT)return new s(this).buffer;for(var r=new Uint8Array(this.length),i=0,n=r.length;n>i;i+=1)r[i]=this[i];return r.buffer}throw new TypeError("Buffer.toArrayBuffer not supported in this browser")};var _=s.prototype;s._augment=function(r){return r.constructor=s,r._isBuffer=!0,r._set=r.set,r.get=_.get,r.set=_.set,r.write=_.write,r.toString=_.toString,r.toLocaleString=_.toString,r.toJSON=_.toJSON,r.equals=_.equals,r.compare=_.compare,r.indexOf=_.indexOf,r.copy=_.copy,r.slice=_.slice,r.readUIntLE=_.readUIntLE,r.readUIntBE=_.readUIntBE,r.readUInt8=_.readUInt8,r.readUInt16LE=_.readUInt16LE,r.readUInt16BE=_.readUInt16BE,r.readUInt32LE=_.readUInt32LE,r.readUInt32BE=_.readUInt32BE,r.readIntLE=_.readIntLE,r.readIntBE=_.readIntBE,r.readInt8=_.readInt8,r.readInt16LE=_.readInt16LE,r.readInt16BE=_.readInt16BE,r.readInt32LE=_.readInt32LE,r.readInt32BE=_.readInt32BE,r.readFloatLE=_.readFloatLE,r.readFloatBE=_.readFloatBE,r.readDoubleLE=_.readDoubleLE,r.readDoubleBE=_.readDoubleBE,r.writeUInt8=_.writeUInt8,r.writeUIntLE=_.writeUIntLE,r.writeUIntBE=_.writeUIntBE,r.writeUInt16LE=_.writeUInt16LE,r.writeUInt16BE=_.writeUInt16BE,r.writeUInt32LE=_.writeUInt32LE,r.writeUInt32BE=_.writeUInt32BE,r.writeIntLE=_.writeIntLE,r.writeIntBE=_.writeIntBE,r.writeInt8=_.writeInt8,r.writeInt16LE=_.writeInt16LE,r.writeInt16BE=_.writeInt16BE,r.writeInt32LE=_.writeInt32LE,r.writeInt32BE=_.writeInt32BE,r.writeFloatLE=_.writeFloatLE,r.writeFloatBE=_.writeFloatBE,r.writeDoubleLE=_.writeDoubleLE,r.writeDoubleBE=_.writeDoubleBE,r.fill=_.fill,r.inspect=_.inspect,r.toArrayBuffer=_.toArrayBuffer,r};var rr=/[^+\/0-9A-Za-z-_]/g}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"base64-js":1,ieee754:10,isarray:4}],4:[function(r,i,n){var t={}.toString;i.exports=Array.isArray||function(r){return"[object Array]"==t.call(r)}},{}],5:[function(r,i,n){"use strict";function t(){this.argTypes=[],this.shimArgs=[],this.arrayArgs=[],this.arrayBlockIndices=[],this.scalarArgs=[],this.offsetArgs=[],this.offsetArgIndex=[],this.indexArgs=[],this.shapeArgs=[],this.funcName="",this.pre=null,this.body=null,this.post=null,this.debug=!1}function a(r){var i=new t;i.pre=r.pre,i.body=r.body,i.post=r.post;var n=r.args.slice(0);i.argTypes=n;for(var a=0;a<n.length;++a){var u=n[a];if("array"===u||"object"==typeof u&&u.blockIndices){if(i.argTypes[a]="array",i.arrayArgs.push(a),i.arrayBlockIndices.push(u.blockIndices?u.blockIndices:0),i.shimArgs.push("array"+a),a<i.pre.args.length&&i.pre.args[a].count>0)throw new Error("cwise: pre() block may not reference array args");if(a<i.post.args.length&&i.post.args[a].count>0)throw new Error("cwise: post() block may not reference array args")}else if("scalar"===u)i.scalarArgs.push(a),i.shimArgs.push("scalar"+a);else if("index"===u){if(i.indexArgs.push(a),a<i.pre.args.length&&i.pre.args[a].count>0)throw new Error("cwise: pre() block may not reference array index");if(a<i.body.args.length&&i.body.args[a].lvalue)throw new Error("cwise: body() block may not write to array index");if(a<i.post.args.length&&i.post.args[a].count>0)throw new Error("cwise: post() block may not reference array index")}else if("shape"===u){if(i.shapeArgs.push(a),a<i.pre.args.length&&i.pre.args[a].lvalue)throw new Error("cwise: pre() block may not write to array shape");if(a<i.body.args.length&&i.body.args[a].lvalue)throw new Error("cwise: body() block may not write to array shape");if(a<i.post.args.length&&i.post.args[a].lvalue)throw new Error("cwise: post() block may not write to array shape")}else{if("object"!=typeof u||!u.offset)throw new Error("cwise: Unknown argument type "+n[a]);i.argTypes[a]="offset",i.offsetArgs.push({array:u.array,offset:u.offset}),i.offsetArgIndex.push(a)}}if(i.arrayArgs.length<=0)throw new Error("cwise: No array arguments specified");if(i.pre.args.length>n.length)throw new Error("cwise: Too many arguments in pre() block");if(i.body.args.length>n.length)throw new Error("cwise: Too many arguments in body() block");if(i.post.args.length>n.length)throw new Error("cwise: Too many arguments in post() block");return i.debug=!!r.printCode||!!r.debug,i.funcName=r.funcName||"cwise",i.blockSize=r.blockSize||64,s(i)}var s=r("./lib/thunk.js");i.exports=a},{"./lib/thunk.js":7}],6:[function(r,i,n){"use strict";function t(r,i,n){var t,a,s=r.length,u=i.arrayArgs.length,c=i.indexArgs.length>0,e=[],f=[],g=0,h=0;for(t=0;s>t;++t)f.push(["i",t,"=0"].join(""));for(a=0;u>a;++a)for(t=0;s>t;++t)h=g,g=r[t],0===t?f.push(["d",a,"s",t,"=t",a,"p",g].join("")):f.push(["d",a,"s",t,"=(t",a,"p",g,"-s",h,"*t",a,"p",h,")"].join(""));for(e.push("var "+f.join(",")),t=s-1;t>=0;--t)g=r[t],e.push(["for(i",t,"=0;i",t,"<s",g,";++i",t,"){"].join(""));for(e.push(n),t=0;s>t;++t){for(h=g,g=r[t],a=0;u>a;++a)e.push(["p",a,"+=d",a,"s",t].join(""));c&&(t>0&&e.push(["index[",h,"]-=s",h].join("")),e.push(["++index[",g,"]"].join(""))),e.push("}")}return e.join("\n")}function a(r,i,n,a){for(var s=i.length,u=n.arrayArgs.length,c=n.blockSize,e=n.indexArgs.length>0,f=[],g=0;u>g;++g)f.push(["var offset",g,"=p",g].join(""));for(var g=r;s>g;++g)f.push(["for(var j"+g+"=SS[",i[g],"]|0;j",g,">0;){"].join("")),f.push(["if(j",g,"<",c,"){"].join("")),f.push(["s",i[g],"=j",g].join("")),f.push(["j",g,"=0"].join("")),f.push(["}else{s",i[g],"=",c].join("")),f.push(["j",g,"-=",c,"}"].join("")),e&&f.push(["index[",i[g],"]=j",g].join(""));for(var g=0;u>g;++g){for(var h=["offset"+g],o=r;s>o;++o)h.push(["j",o,"*t",g,"p",i[o]].join(""));f.push(["p",g,"=(",h.join("+"),")"].join(""))}f.push(t(i,n,a));for(var g=r;s>g;++g)f.push("}");return f.join("\n")}function s(r){for(var i=0,n=r[0].length;n>i;){for(var t=1;t<r.length;++t)if(r[t][i]!==r[0][i])return i;++i}return i}function u(r,i,n){for(var t=r.body,a=[],s=[],u=0;u<r.args.length;++u){var c=r.args[u];if(!(c.count<=0)){var e=new RegExp(c.name,"g"),f="",g=i.arrayArgs.indexOf(u);switch(i.argTypes[u]){case"offset":var h=i.offsetArgIndex.indexOf(u),o=i.offsetArgs[h];g=o.array,f="+q"+h;case"array":f="p"+g+f;var v="l"+u,y="a"+g;if(0===i.arrayBlockIndices[g])1===c.count?"generic"===n[g]?c.lvalue?(a.push(["var ",v,"=",y,".get(",f,")"].join("")),t=t.replace(e,v),s.push([y,".set(",f,",",v,")"].join(""))):t=t.replace(e,[y,".get(",f,")"].join("")):t=t.replace(e,[y,"[",f,"]"].join("")):"generic"===n[g]?(a.push(["var ",v,"=",y,".get(",f,")"].join("")),t=t.replace(e,v),c.lvalue&&s.push([y,".set(",f,",",v,")"].join(""))):(a.push(["var ",v,"=",y,"[",f,"]"].join("")),t=t.replace(e,v),c.lvalue&&s.push([y,"[",f,"]=",v].join("")));else{for(var X=[c.name],b=[f],d=0;d<Math.abs(i.arrayBlockIndices[g]);d++)X.push("\\s*\\[([^\\]]+)\\]"),b.push("$"+(d+1)+"*t"+g+"b"+d);if(e=new RegExp(X.join(""),"g"),f=b.join("+"),"generic"===n[g])throw new Error("cwise: Generic arrays not supported in combination with blocks!");t=t.replace(e,[y,"[",f,"]"].join(""))}break;case"scalar":t=t.replace(e,"Y"+i.scalarArgs.indexOf(u));break;case"index":t=t.replace(e,"index");break;case"shape":t=t.replace(e,"shape")}}}return[a.join("\n"),t,s.join("\n")].join("\n").trim()}function c(r){for(var i=new Array(r.length),n=!0,t=0;t<r.length;++t){var a=r[t],s=a.match(/\d+/);s=s?s[0]:"",0===a.charAt(0)?i[t]="u"+a.charAt(1)+s:i[t]=a.charAt(0)+s,t>0&&(n=n&&i[t]===i[t-1])}return n?i[0]:i.join("")}function e(r,i){for(var n=i[1].length-Math.abs(r.arrayBlockIndices[0])|0,e=new Array(r.arrayArgs.length),g=new Array(r.arrayArgs.length),h=0;h<r.arrayArgs.length;++h)g[h]=i[2*h],e[h]=i[2*h+1];for(var o=[],v=[],y=[],X=[],b=[],h=0;h<r.arrayArgs.length;++h){r.arrayBlockIndices[h]<0?(y.push(0),X.push(n),o.push(n),v.push(n+r.arrayBlockIndices[h])):(y.push(r.arrayBlockIndices[h]),X.push(r.arrayBlockIndices[h]+n),o.push(0),v.push(r.arrayBlockIndices[h]));for(var d=[],j=0;j<e[h].length;j++)y[h]<=e[h][j]&&e[h][j]<X[h]&&d.push(e[h][j]-y[h]);b.push(d)}for(var k=["SS"],l=["'use strict'"],m=[],j=0;n>j;++j)m.push(["s",j,"=SS[",j,"]"].join(""));for(var h=0;h<r.arrayArgs.length;++h){k.push("a"+h),k.push("t"+h),k.push("p"+h);for(var j=0;n>j;++j)m.push(["t",h,"p",j,"=t",h,"[",y[h]+j,"]"].join(""));for(var j=0;j<Math.abs(r.arrayBlockIndices[h]);++j)m.push(["t",h,"b",j,"=t",h,"[",o[h]+j,"]"].join(""))}for(var h=0;h<r.scalarArgs.length;++h)k.push("Y"+h);if(r.shapeArgs.length>0&&m.push("shape=SS.slice(0)"),r.indexArgs.length>0){for(var p=new Array(n),h=0;n>h;++h)p[h]="0";m.push(["index=[",p.join(","),"]"].join(""))}for(var h=0;h<r.offsetArgs.length;++h){for(var q=r.offsetArgs[h],w=[],j=0;j<q.offset.length;++j)0!==q.offset[j]&&(1===q.offset[j]?w.push(["t",q.array,"p",j].join("")):w.push([q.offset[j],"*t",q.array,"p",j].join("")));0===w.length?m.push("q"+h+"=0"):m.push(["q",h,"=",w.join("+")].join(""))}var x=f([].concat(r.pre.thisVars).concat(r.body.thisVars).concat(r.post.thisVars));m=m.concat(x),l.push("var "+m.join(","));for(var h=0;h<r.arrayArgs.length;++h)l.push("p"+h+"|=0");r.pre.body.length>3&&l.push(u(r.pre,r,g));var z=u(r.body,r,g),A=s(b);n>A?l.push(a(A,b[0],r,z)):l.push(t(b[0],r,z)),r.post.body.length>3&&l.push(u(r.post,r,g)),r.debug&&console.log("-----Generated cwise routine for ",i,":\n"+l.join("\n")+"\n----------");var B=[r.funcName||"unnamed","_cwise_loop_",e[0].join("s"),"m",A,c(g)].join(""),C=new Function(["function ",B,"(",k.join(","),"){",l.join("\n"),"} return ",B].join(""));return C()}var f=r("uniq");i.exports=e},{uniq:22}],7:[function(r,i,n){"use strict";function t(r){var i=["'use strict'","var CACHED={}"],n=[],t=r.funcName+"_cwise_thunk";i.push(["return function ",t,"(",r.shimArgs.join(","),"){"].join(""));for(var s=[],u=[],c=[["array",r.arrayArgs[0],".shape.slice(",Math.max(0,r.arrayBlockIndices[0]),r.arrayBlockIndices[0]<0?","+r.arrayBlockIndices[0]+")":")"].join("")],e=[],f=[],g=0;g<r.arrayArgs.length;++g){var h=r.arrayArgs[g];n.push(["t",h,"=array",h,".dtype,","r",h,"=array",h,".order"].join("")),s.push("t"+h),s.push("r"+h),u.push("t"+h),u.push("r"+h+".join()"),c.push("array"+h+".data"),c.push("array"+h+".stride"),c.push("array"+h+".offset|0"),g>0&&(e.push("array"+r.arrayArgs[0]+".shape.length===array"+h+".shape.length+"+(Math.abs(r.arrayBlockIndices[0])-Math.abs(r.arrayBlockIndices[g]))),f.push("array"+r.arrayArgs[0]+".shape[shapeIndex+"+Math.max(0,r.arrayBlockIndices[0])+"]===array"+h+".shape[shapeIndex+"+Math.max(0,r.arrayBlockIndices[g])+"]"))}r.arrayArgs.length>1&&(i.push("if (!("+e.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same dimensionality!')"),i.push("for(var shapeIndex=array"+r.arrayArgs[0]+".shape.length-"+Math.abs(r.arrayBlockIndices[0])+"; shapeIndex-->0;) {"),i.push("if (!("+f.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same shape!')"),
i.push("}"));for(var g=0;g<r.scalarArgs.length;++g)c.push("scalar"+r.scalarArgs[g]);n.push(["type=[",u.join(","),"].join()"].join("")),n.push("proc=CACHED[type]"),i.push("var "+n.join(",")),i.push(["if(!proc){","CACHED[type]=proc=compile([",s.join(","),"])}","return proc(",c.join(","),")}"].join("")),r.debug&&console.log("-----Generated thunk:\n"+i.join("\n")+"\n----------");var o=new Function("compile",i.join("\n"));return o(a.bind(void 0,r))}var a=r("./compile.js");i.exports=t},{"./compile.js":6}],8:[function(r,i,n){i.exports=r("cwise-compiler")},{"cwise-compiler":5}],9:[function(r,i,n){"use strict";function t(r,i,n){var a=0|r[n];if(0>=a)return[];var s,u=new Array(a);if(n===r.length-1)for(s=0;a>s;++s)u[s]=i;else for(s=0;a>s;++s)u[s]=t(r,i,n+1);return u}function a(r,i){var n,t;for(n=new Array(r),t=0;r>t;++t)n[t]=i;return n}function s(r,i){switch("undefined"==typeof i&&(i=0),typeof r){case"number":if(r>0)return a(0|r,i);break;case"object":if("number"==typeof r.length)return t(r,i,0)}return[]}i.exports=s},{}],10:[function(r,i,n){n.read=function(r,i,n,t,a){var s,u,c=8*a-t-1,e=(1<<c)-1,f=e>>1,g=-7,h=n?a-1:0,o=n?-1:1,v=r[i+h];for(h+=o,s=v&(1<<-g)-1,v>>=-g,g+=c;g>0;s=256*s+r[i+h],h+=o,g-=8);for(u=s&(1<<-g)-1,s>>=-g,g+=t;g>0;u=256*u+r[i+h],h+=o,g-=8);if(0===s)s=1-f;else{if(s===e)return u?NaN:(v?-1:1)*(1/0);u+=Math.pow(2,t),s-=f}return(v?-1:1)*u*Math.pow(2,s-t)},n.write=function(r,i,n,t,a,s){var u,c,e,f=8*s-a-1,g=(1<<f)-1,h=g>>1,o=23===a?Math.pow(2,-24)-Math.pow(2,-77):0,v=t?0:s-1,y=t?1:-1,X=0>i||0===i&&0>1/i?1:0;for(i=Math.abs(i),isNaN(i)||i===1/0?(c=isNaN(i)?1:0,u=g):(u=Math.floor(Math.log(i)/Math.LN2),i*(e=Math.pow(2,-u))<1&&(u--,e*=2),i+=u+h>=1?o/e:o*Math.pow(2,1-h),i*e>=2&&(u++,e/=2),u+h>=g?(c=0,u=g):u+h>=1?(c=(i*e-1)*Math.pow(2,a),u+=h):(c=i*Math.pow(2,h-1)*Math.pow(2,a),u=0));a>=8;r[n+v]=255&c,v+=y,c/=256,a-=8);for(u=u<<a|c,f+=a;f>0;r[n+v]=255&u,v+=y,u/=256,f-=8);r[n+v-y]|=128*X}},{}],11:[function(r,i,n){"use strict";function t(r){for(var i=new Array(r),n=0;r>n;++n)i[n]=n;return i}i.exports=t},{}],12:[function(r,i,n){i.exports=function(r){return!(null==r||!(r._isBuffer||r.constructor&&"function"==typeof r.constructor.isBuffer&&r.constructor.isBuffer(r)))}},{}],13:[function(r,i,n){"use strict";function t(r,i,n){var t,e,f=i.shape,g=f.length,h=1,o=new Array(g),v=0;for(t=g-1;t>=0;--t)if(o[t]=h,h*=f[t],v=Math.max(v,c.scratchMemory(f[t])),i.shape[t]!==n.shape[t])throw new Error("Shape mismatch, real and imaginary arrays must have same size");var y,X=4*h+v;y="array"===i.dtype||"float64"===i.dtype||"custom"===i.dtype?u.mallocDouble(X):u.mallocFloat(X);var b,d,j,k,l=s(y,f.slice(0),o,0),m=s(y,f.slice(0),o.slice(0),h),p=s(y,f.slice(0),o.slice(0),2*h),q=s(y,f.slice(0),o.slice(0),3*h),w=4*h;for(a.assign(l,i),a.assign(m,n),t=g-1;t>=0&&(c(r,h/f[t],f[t],y,l.offset,m.offset,w),0!==t);--t){for(d=1,j=p.stride,k=q.stride,e=t-1;g>e;++e)k[e]=j[e]=d,d*=f[e];for(e=t-2;e>=0;--e)k[e]=j[e]=d,d*=f[e];a.assign(p,l),a.assign(q,m),b=l,l=p,p=b,b=m,m=q,q=b}a.assign(i,l),a.assign(n,m),u.free(y)}var a=r("ndarray-ops"),s=r("ndarray"),u=r("typedarray-pool"),c=r("./lib/fft-matrix.js");i.exports=t},{"./lib/fft-matrix.js":14,ndarray:18,"ndarray-ops":17,"typedarray-pool":21}],14:[function(r,i,n){function t(r,i,n,t,a,e,f){r|=0,i|=0,n|=0,a|=0,e|=0,c.isPow2(n)?s(r,i,n,t,a,e):u(r,i,n,t,a,e,f)}function a(r){return c.isPow2(r)?0:2*r+4*c.nextPow2(2*r+1)}function s(r,i,n,t,a,s){r|=0,i|=0,n|=0,a|=0,s|=0;var u,e,f,g,h,o,v,y,X,b,d,j,k,l,m,p,q,w,x,z,A,B,C,D,E;for(u=n,e=c.log2(u),w=0;i>w;++w){for(v=u>>1,h=0,f=0;u-1>f;f++){for(h>f&&(k=t[a+f],t[a+f]=t[a+h],t[a+h]=k,k=t[s+f],t[s+f]=t[s+h],t[s+h]=k),o=v;h>=o;)h-=o,o>>=1;h+=o}for(d=-1,j=0,b=1,y=0;e>y;y++){for(X=b,b<<=1,p=1,q=0,h=0;X>h;h++){for(f=h;u>f;f+=b)g=f+X,x=t[a+g],z=t[s+g],A=t[a+f],B=t[s+f],C=p*(x+z),D=x*(q-p),E=z*(p+q),l=C-E,m=C+D,t[a+g]=A-l,t[s+g]=B-m,t[a+f]+=l,t[s+f]+=m;C=d*(p+q),D=p*(j-d),E=q*(d+j),p=C-E,q=C+D}j=Math.sqrt((1-d)/2),0>r&&(j=-j),d=Math.sqrt((1+d)/2)}if(0>r){var F=1/u;for(f=0;u>f;f++)t[a+f]*=F,t[s+f]*=F}a+=n,s+=n}}function u(r,i,n,t,a,u,e){r|=0,i|=0,n|=0,a|=0,u|=0,e|=0;var f,g,h,o,v,y,X,b,d,j=c.nextPow2(2*n+1),k=e,l=k+n,m=l+n,p=m+j,q=p+j,w=q+j,x=-r*Math.PI/n;for(d=0;n>d;++d)g=x*(d*d%(2*n)),o=Math.cos(g),v=Math.sin(g),t[q+(j-d)]=t[q+d]=t[k+d]=o,t[w+(j-d)]=t[w+d]=t[l+d]=v;for(d=n;j-n>=d;++d)t[q+d]=0;for(d=n;j-n>=d;++d)t[w+d]=0;for(s(1,1,j,t,q,w),x=0>r?1/n:1,f=0;i>f;++f){for(d=0;n>d;++d)g=t[a+d],h=t[u+d],o=t[k+d],v=-t[l+d],y=o*(g+h),X=g*(v-o),b=h*(o+v),t[m+d]=y-b,t[p+d]=y+X;for(d=n;j>d;++d)t[m+d]=0;for(d=n;j>d;++d)t[p+d]=0;for(s(1,1,j,t,m,p),d=0;j>d;++d)g=t[m+d],h=t[p+d],o=t[q+d],v=t[w+d],y=o*(g+h),X=g*(v-o),b=h*(o+v),t[m+d]=y-b,t[p+d]=y+X;for(s(-1,1,j,t,m,p),d=0;n>d;++d)g=t[m+d],h=t[p+d],o=t[k+d],v=-t[l+d],y=o*(g+h),X=g*(v-o),b=h*(o+v),t[a+d]=x*(y-b),t[u+d]=x*(y+X);a+=n,u+=n}}var c=r("bit-twiddle");i.exports=t,i.exports.scratchMemory=a},{"bit-twiddle":2}],15:[function(r,i,n){"use strict";function t(r){return Array.isArray(r)?[r.length,r[0].length]:r.shape}function a(r,i,n){var a=t(r),s=t(i),u=t(n);if(a[0]!==s[0]||a[1]!==u[1]||s[1]!==u[0])throw new Error("Mismatched array shapes for matrix product")}function s(r){if(Array.isArray(r)){if(Array.isArray(r))return["r","native"]}else if(r.shape&&2===r.shape.length)return r.order[0]?["r",r.dtype]:["c",r.dtype];throw new Error("Unrecognized data type")}function u(r,i,n,t,u){void 0===t&&(t=1),void 0===u&&(u=0);var f=1!==t,g=0!==u,h=s(r),o=s(i),v=s(n);a(r,i,n);var y=[h,o,v,f,g].join(":"),X=e[y];return X||(X=e[y]=c(h,o,v,f,g)),X(r,i,n,t,u)}i.exports=u;var c=r("./lib/planner.js"),e={}},{"./lib/planner.js":16}],16:[function(r,i,n){"use strict";function t(r,i){return"native"===i[1]?[r,"d0=",r,".length,",r,"d1=",r,"[0].length,"].join(""):[r,"d0=",r,".shape[0],",r,"d1=",r,".shape[1],",r,"s0=",r,".stride[0],",r,"s1=",r,".stride[1],",r,"o=",r,".offset,",r,"d=",r,".data,"].join("")}function a(r,i,n,t,a,s){var u=[];return"native"===n[1]?r[0]&&(t?u.push("var ",i,"p=",i,"[",t,"];"):u.push("var ",i,"p=",i,"[0];")):t&&a?s?u.push("var ",i,"t0=",i,"s",r[0],",",i,"t1=",i,"s",r[1],"-",i,"s",r[0],"*",s,",",i,"p=",i,"o+",t,"*",i,"s0+",a,"*",i,"s1;"):u.push("var ",i,"t0=",i,"s",r[0],",",i,"p=",i,"o+",t,"*",i,"s0+",a,"*",i,"s1;"):t?u.push("var ",i,"t0=",i,"s",r[0],",",i,"p=",i,"o+",t,"*",i,"s0;"):a?u.push("var ",i,"t0=",i,"s",r[0],",",i,"p=",i,"o+",a,"*",i,"s1;"):u.push("var ",i,"t0=",i,"s",r[0],",",i,"t1=",i,"s",r[1],"-",i,"s",r[0],"*",i,"d",r[0],",",i,"p=",i,"o;"),u}function s(r,i,n,t,a){var s=[];return"native"===n[1]?r[0]&&1===t&&s.push(i,"p=",i,"[",a,"+1]"):s.push(i,"p+=",i,"t",t,";"),s}function u(r,i,n,t,a,s){var u=[];return"native"===n[1]?r[0]?u.push(i,"p[",a,"]=",s,";"):u.push(i,"[",t,"][",a,"]=",s,";"):"generic"===n[1]?u.push(i,"d.set(",i,"p,",s,");"):u.push(i,"d[",i,"p]=",s,";"),u}function c(r,i,n,t,a){var s=[];return"native"===n[1]?r[0]?s.push(i,"p[",a,"]"):s.push(i,"[",t,"][",a,"]"):"generic"===n[1]?s.push(i,"d.get(",i,"p)"):s.push(i,"d[",i,"p]"),s.join("")}function e(r,i,n,t,e){var f=[],g="r"===r[0]?[1,0]:[0,1],h=[1,0],o=[0,1],v=["i","j"];return f.push.apply(f,a(g,"o",r)),g[1]?(f.push("for(j=0;j<od1;++j){"),f.push("for(i=0;i<od0;++i){")):(f.push("for(i=0;i<od0;++i){"),f.push("for(j=0;j<od1;++j){")),f.push.apply(f,a(h,"a",i,"i")),f.push.apply(f,a(o,"b",n,void 0,"j")),f.push("var r=0.0;","for(k=0;k<ad1;++k){","r+=",c(h,"a",i,"i","k"),"*",c(o,"b",n,"k","j"),";"),f.push.apply(f,s(h,"a",i,0,"k")),f.push.apply(f,s(o,"b",n,0,"k")),f.push("}"),t&&f.push("r*=A;"),e&&f.push("r+=B*",c(g,"o",r,"i","j"),";"),f.push.apply(f,u(g,"o",r,"i","j","r")),f.push.apply(f,s(g,"o",r,0,v[1])),f.push("}"),f.push.apply(f,s(g,"o",r,1,v[0])),f.push("}"),f}function f(r,i){var n,t=[],e="r"===r[0]?[1,0]:[0,1];return i&&t.push("if(B!==1.0){"),t.push.apply(t,a(e,"o",r)),e[0]?(t.push("for(i=0;i<od0;++i){for(j=0;j<od1;++j){"),n=["i","j"]):(t.push("for(j=0;j<od1;++j){for(i=0;i<od0;++i){"),n=["j","i"]),i?t.push.apply(t,u(e,"o",r,"i","j","B*"+c(e,"o",r,"i","j"))):t.push.apply(t,u(e,"o",r,"i","j","0")),t.push.apply(t,s(e,"o",r,0,n[1])),t.push("}"),t.push.apply(t,s(e,"o",r,1,n[0])),t.push("}"),i&&t.push("}"),t}function g(r,i,n,t,e){var g=[],h=["od0","od1","ad1"],v=[1,0],y=[1,0],X=[0,1];g.push.apply(g,f(r,e));for(var b=0;3>b;++b)g.push("for(var i",b,"=",h[b],";i",b,">0;){","var w",b,"=",o,";","if(i",b,"<",o,"){","w",b,"=i",b,";","i",b,"=0;","}else{","i",b,"-=",o,";","}");g.push.apply(g,a(v,"o",r,"i0","i1","w1")),g.push("for(i=0;i<w0;++i){for(j=0;j<w1;++j){var r=0.0;"),g.push.apply(g,a(y,"a",i,"(i0+i)","i2")),g.push.apply(g,a(X,"b",n,"i2","(i1+j)")),g.push("for(k=0;k<w2;++k){"),g.push("r+=",c(y,"a",i,"(i0+i)","(i2+k)"),"*",c(X,"b",n,"(i2+k)","(i1+j)"),";"),g.push.apply(g,s(y,"a",i,0,"(i2+k)")),g.push.apply(g,s(X,"b",n,0,"(i2+k)")),g.push("}");var d="r";return t&&(d="A*r"),g.push.apply(g,u(v,"o",r,"(i0+i)","(i1+j)",d+"+"+c(v,"o",r,"(i0+i)","(i1+j)"))),g.push.apply(g,s(v,"o",r,0,"(i1+j)")),g.push("}"),g.push.apply(g,s(v,"o",r,1,"(i0+i)")),g.push("}}}}"),g}function h(r,i,n,a,s){var u=["gemm",r[0],r[1],"a",i[0],i[1],"b",n[0],n[1],a?"alpha":"",s?"beta":""].join(""),c=["function ",u,"(o,a,b,A,B){","var ",t("o",r),t("a",i),t("b",n),"i,j,k;"];"r"===i[0]&&"c"===n[0]?c.push.apply(c,e(r,i,n,a,s)):c.push.apply(c,g(r,i,n,a,s)),c.push("}return ",u);var f=new Function(c.join(""));return f()}i.exports=h;var o=32},{}],17:[function(r,i,n){"use strict";function t(r){if(!r)return c;for(var i=0;i<r.args.length;++i){var n=r.args[i];0===i?r.args[i]={name:n,lvalue:!0,rvalue:!!r.rvalue,count:r.count||1}:r.args[i]={name:n,lvalue:!1,rvalue:!0,count:1}}return r.thisVars||(r.thisVars=[]),r.localVars||(r.localVars=[]),r}function a(r){return u({args:r.args,pre:t(r.pre),body:t(r.body),post:t(r.proc),funcName:r.funcName})}function s(r){for(var i=[],n=0;n<r.args.length;++n)i.push("a"+n);var t=new Function("P",["return function ",r.funcName,"_ndarrayops(",i.join(","),") {P(",i.join(","),");return a0}"].join(""));return t(a(r))}var u=r("cwise-compiler"),c={body:"",args:[],thisVars:[],localVars:[]},e={add:"+",sub:"-",mul:"*",div:"/",mod:"%",band:"&",bor:"|",bxor:"^",lshift:"<<",rshift:">>",rrshift:">>>"};!function(){for(var r in e){var i=e[r];n[r]=s({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+i+"c"},funcName:r}),n[r+"eq"]=s({args:["array","array"],body:{args:["a","b"],body:"a"+i+"=b"},rvalue:!0,funcName:r+"eq"}),n[r+"s"]=s({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+i+"s"},funcName:r+"s"}),n[r+"seq"]=s({args:["array","scalar"],body:{args:["a","s"],body:"a"+i+"=s"},rvalue:!0,funcName:r+"seq"})}}();var f={not:"!",bnot:"~",neg:"-",recip:"1.0/"};!function(){for(var r in f){var i=f[r];n[r]=s({args:["array","array"],body:{args:["a","b"],body:"a="+i+"b"},funcName:r}),n[r+"eq"]=s({args:["array"],body:{args:["a"],body:"a="+i+"a"},rvalue:!0,count:2,funcName:r+"eq"})}}();var g={and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">="};!function(){for(var r in g){var i=g[r];n[r]=s({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+i+"c"},funcName:r}),n[r+"s"]=s({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+i+"s"},funcName:r+"s"}),n[r+"eq"]=s({args:["array","array"],body:{args:["a","b"],body:"a=a"+i+"b"},rvalue:!0,count:2,funcName:r+"eq"}),n[r+"seq"]=s({args:["array","scalar"],body:{args:["a","s"],body:"a=a"+i+"s"},rvalue:!0,count:2,funcName:r+"seq"})}}();var h=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan"];!function(){for(var r=0;r<h.length;++r){var i=h[r];n[i]=s({args:["array","array"],pre:{args:[],body:"this_f=Math."+i,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b)",thisVars:["this_f"]},funcName:i}),n[i+"eq"]=s({args:["array"],pre:{args:[],body:"this_f=Math."+i,thisVars:["this_f"]},body:{args:["a"],body:"a=this_f(a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:i+"eq"})}}();var o=["max","min","atan2","pow"];!function(){for(var r=0;r<o.length;++r){var i=o[r];n[i]=s({args:["array","array","array"],pre:{args:[],body:"this_f=Math."+i,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(b,c)",thisVars:["this_f"]},funcName:i}),n[i+"s"]=s({args:["array","array","scalar"],pre:{args:[],body:"this_f=Math."+i,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(b,c)",thisVars:["this_f"]},funcName:i+"s"}),n[i+"eq"]=s({args:["array","array"],pre:{args:[],body:"this_f=Math."+i,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(a,b)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:i+"eq"}),n[i+"seq"]=s({args:["array","scalar"],pre:{args:[],body:"this_f=Math."+i,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(a,b)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:i+"seq"})}}();var v=["atan2","pow"];!function(){for(var r=0;r<v.length;++r){var i=v[r];n[i+"op"]=s({args:["array","array","array"],pre:{args:[],body:"this_f=Math."+i,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(c,b)",thisVars:["this_f"]},funcName:i+"op"}),n[i+"ops"]=s({args:["array","array","scalar"],pre:{args:[],body:"this_f=Math."+i,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(c,b)",thisVars:["this_f"]},funcName:i+"ops"}),n[i+"opeq"]=s({args:["array","array"],pre:{args:[],body:"this_f=Math."+i,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b,a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:i+"opeq"}),n[i+"opseq"]=s({args:["array","scalar"],pre:{args:[],body:"this_f=Math."+i,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b,a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:i+"opseq"})}}(),n.any=u({args:["array"],pre:c,body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"if(a){return true}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return false"},funcName:"any"}),n.all=u({args:["array"],pre:c,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1}],body:"if(!x){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"all"}),n.sum=u({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"this_s+=a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"sum"}),n.prod=u({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=1"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"this_s*=a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"prod"}),n.norm2squared=u({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:2}],body:"this_s+=a*a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm2squared"}),n.norm2=u({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:2}],body:"this_s+=a*a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return Math.sqrt(this_s)"},funcName:"norm2"}),n.norminf=u({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:4}],body:"if(-a>this_s){this_s=-a}else if(a>this_s){this_s=a}",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norminf"}),n.norm1=u({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:3}],body:"this_s+=a<0?-a:a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm1"}),n.sup=u({args:["array"],pre:{body:"this_h=-Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_>this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}}),n.inf=u({args:["array"],pre:{body:"this_h=Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_<this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}}),n.argmin=u({args:["index","array","shape"],pre:{body:"{this_v=Infinity;this_i=_inline_0_arg2_.slice(0)}",args:[{name:"_inline_0_arg0_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg1_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg2_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_i","this_v"],localVars:[]},body:{body:"{if(_inline_1_arg1_<this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}}),n.argmax=u({args:["index","array","shape"],pre:{body:"{this_v=-Infinity;this_i=_inline_0_arg2_.slice(0)}",args:[{name:"_inline_0_arg0_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg1_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg2_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_i","this_v"],localVars:[]},body:{body:"{if(_inline_1_arg1_>this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}}),n.random=s({args:["array"],pre:{args:[],body:"this_f=Math.random",thisVars:["this_f"]},body:{args:["a"],body:"a=this_f()",thisVars:["this_f"]},funcName:"random"}),n.assign=s({args:["array","array"],body:{args:["a","b"],body:"a=b"},funcName:"assign"}),n.assigns=s({args:["array","scalar"],body:{args:["a","b"],body:"a=b"},funcName:"assigns"}),n.equals=u({args:["array","array"],pre:c,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1},{name:"y",lvalue:!1,rvalue:!0,count:1}],body:"if(x!==y){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"equals"})},{"cwise-compiler":5}],18:[function(r,i,n){function t(r,i){return r[0]-i[0]}function a(){var r,i=this.stride,n=new Array(i.length);for(r=0;r<n.length;++r)n[r]=[Math.abs(i[r]),r];n.sort(t);var a=new Array(n.length);for(r=0;r<a.length;++r)a[r]=n[r][1];return a}function s(r,i){var n=["View",i,"d",r].join("");0>i&&(n="View_Nil"+r);var t="generic"===r;if(-1===i){var s="function "+n+"(a){this.data=a;};var proto="+n+".prototype;proto.dtype='"+r+"';proto.index=function(){return -1};proto.size=0;proto.dimension=-1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function(){return new "+n+"(this.data);};proto.get=proto.set=function(){};proto.pick=function(){return null};return function construct_"+n+"(a){return new "+n+"(a);}",u=new Function(s);return u()}if(0===i){var s="function "+n+"(a,d) {this.data = a;this.offset = d};var proto="+n+".prototype;proto.dtype='"+r+"';proto.index=function(){return this.offset};proto.dimension=0;proto.size=1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function "+n+"_copy() {return new "+n+"(this.data,this.offset)};proto.pick=function "+n+"_pick(){return TrivialArray(this.data);};proto.valueOf=proto.get=function "+n+"_get(){return "+(t?"this.data.get(this.offset)":"this.data[this.offset]")+"};proto.set=function "+n+"_set(v){return "+(t?"this.data.set(this.offset,v)":"this.data[this.offset]=v")+"};return function construct_"+n+"(a,b,c,d){return new "+n+"(a,d)}",u=new Function("TrivialArray",s);return u(h[r][0])}var s=["'use strict'"],c=e(i),f=c.map(function(r){return"i"+r}),g="this.offset+"+c.map(function(r){return"this.stride["+r+"]*i"+r}).join("+"),o=c.map(function(r){return"b"+r}).join(","),v=c.map(function(r){return"c"+r}).join(",");s.push("function "+n+"(a,"+o+","+v+",d){this.data=a","this.shape=["+o+"]","this.stride=["+v+"]","this.offset=d|0}","var proto="+n+".prototype","proto.dtype='"+r+"'","proto.dimension="+i),s.push("Object.defineProperty(proto,'size',{get:function "+n+"_size(){return "+c.map(function(r){return"this.shape["+r+"]"}).join("*"),"}})"),1===i?s.push("proto.order=[0]"):(s.push("Object.defineProperty(proto,'order',{get:"),4>i?(s.push("function "+n+"_order(){"),2===i?s.push("return (Math.abs(this.stride[0])>Math.abs(this.stride[1]))?[1,0]:[0,1]}})"):3===i&&s.push("var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})")):s.push("ORDER})")),s.push("proto.set=function "+n+"_set("+f.join(",")+",v){"),t?s.push("return this.data.set("+g+",v)}"):s.push("return this.data["+g+"]=v}"),s.push("proto.get=function "+n+"_get("+f.join(",")+"){"),t?s.push("return this.data.get("+g+")}"):s.push("return this.data["+g+"]}"),s.push("proto.index=function "+n+"_index(",f.join(),"){return "+g+"}"),s.push("proto.hi=function "+n+"_hi("+f.join(",")+"){return new "+n+"(this.data,"+c.map(function(r){return["(typeof i",r,"!=='number'||i",r,"<0)?this.shape[",r,"]:i",r,"|0"].join("")}).join(",")+","+c.map(function(r){return"this.stride["+r+"]"}).join(",")+",this.offset)}");var y=c.map(function(r){return"a"+r+"=this.shape["+r+"]"}),X=c.map(function(r){return"c"+r+"=this.stride["+r+"]"});s.push("proto.lo=function "+n+"_lo("+f.join(",")+"){var b=this.offset,d=0,"+y.join(",")+","+X.join(","));for(var b=0;i>b;++b)s.push("if(typeof i"+b+"==='number'&&i"+b+">=0){d=i"+b+"|0;b+=c"+b+"*d;a"+b+"-=d}");s.push("return new "+n+"(this.data,"+c.map(function(r){return"a"+r}).join(",")+","+c.map(function(r){return"c"+r}).join(",")+",b)}"),s.push("proto.step=function "+n+"_step("+f.join(",")+"){var "+c.map(function(r){return"a"+r+"=this.shape["+r+"]"}).join(",")+","+c.map(function(r){return"b"+r+"=this.stride["+r+"]"}).join(",")+",c=this.offset,d=0,ceil=Math.ceil");for(var b=0;i>b;++b)s.push("if(typeof i"+b+"==='number'){d=i"+b+"|0;if(d<0){c+=b"+b+"*(a"+b+"-1);a"+b+"=ceil(-a"+b+"/d)}else{a"+b+"=ceil(a"+b+"/d)}b"+b+"*=d}");s.push("return new "+n+"(this.data,"+c.map(function(r){return"a"+r}).join(",")+","+c.map(function(r){return"b"+r}).join(",")+",c)}");for(var d=new Array(i),j=new Array(i),b=0;i>b;++b)d[b]="a[i"+b+"]",j[b]="b[i"+b+"]";s.push("proto.transpose=function "+n+"_transpose("+f+"){"+f.map(function(r,i){return r+"=("+r+"===undefined?"+i+":"+r+"|0)"}).join(";"),"var a=this.shape,b=this.stride;return new "+n+"(this.data,"+d.join(",")+","+j.join(",")+",this.offset)}"),s.push("proto.pick=function "+n+"_pick("+f+"){var a=[],b=[],c=this.offset");for(var b=0;i>b;++b)s.push("if(typeof i"+b+"==='number'&&i"+b+">=0){c=(c+this.stride["+b+"]*i"+b+")|0}else{a.push(this.shape["+b+"]);b.push(this.stride["+b+"])}");s.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"),s.push("return function construct_"+n+"(data,shape,stride,offset){return new "+n+"(data,"+c.map(function(r){return"shape["+r+"]"}).join(",")+","+c.map(function(r){return"stride["+r+"]"}).join(",")+",offset)}");var u=new Function("CTOR_LIST","ORDER",s.join("\n"));return u(h[r],a)}function u(r){if(f(r))return"buffer";if(g)switch(Object.prototype.toString.call(r)){case"[object Float64Array]":return"float64";case"[object Float32Array]":return"float32";case"[object Int8Array]":return"int8";case"[object Int16Array]":return"int16";case"[object Int32Array]":return"int32";case"[object Uint8Array]":return"uint8";case"[object Uint16Array]":return"uint16";case"[object Uint32Array]":return"uint32";case"[object Uint8ClampedArray]":return"uint8_clamped"}return Array.isArray(r)?"array":"generic"}function c(r,i,n,t){if(void 0===r){var a=h.array[0];return a([])}"number"==typeof r&&(r=[r]),void 0===i&&(i=[r.length]);var c=i.length;if(void 0===n){n=new Array(c);for(var e=c-1,f=1;e>=0;--e)n[e]=f,f*=i[e]}if(void 0===t){t=0;for(var e=0;c>e;++e)n[e]<0&&(t-=(i[e]-1)*n[e])}for(var g=u(r),o=h[g];o.length<=c+1;)o.push(s(g,o.length-1));var a=o[c+1];return a(r,i,n,t)}var e=r("iota-array"),f=r("is-buffer"),g="undefined"!=typeof Float64Array,h={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],buffer:[],generic:[]};i.exports=c},{"iota-array":11,"is-buffer":12}],19:[function(r,i,n){(function(r){function i(r,i){for(var n=0,t=r.length-1;t>=0;t--){var a=r[t];"."===a?r.splice(t,1):".."===a?(r.splice(t,1),n++):n&&(r.splice(t,1),n--)}if(i)for(;n--;n)r.unshift("..");return r}function t(r,i){if(r.filter)return r.filter(i);for(var n=[],t=0;t<r.length;t++)i(r[t],t,r)&&n.push(r[t]);return n}var a=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,s=function(r){return a.exec(r).slice(1)};n.resolve=function(){for(var n="",a=!1,s=arguments.length-1;s>=-1&&!a;s--){var u=s>=0?arguments[s]:r.cwd();if("string"!=typeof u)throw new TypeError("Arguments to path.resolve must be strings");u&&(n=u+"/"+n,a="/"===u.charAt(0))}return n=i(t(n.split("/"),function(r){return!!r}),!a).join("/"),(a?"/":"")+n||"."},n.normalize=function(r){var a=n.isAbsolute(r),s="/"===u(r,-1);return r=i(t(r.split("/"),function(r){return!!r}),!a).join("/"),r||a||(r="."),r&&s&&(r+="/"),(a?"/":"")+r},n.isAbsolute=function(r){return"/"===r.charAt(0)},n.join=function(){var r=Array.prototype.slice.call(arguments,0);return n.normalize(t(r,function(r,i){if("string"!=typeof r)throw new TypeError("Arguments to path.join must be strings");return r}).join("/"))},n.relative=function(r,i){function t(r){for(var i=0;i<r.length&&""===r[i];i++);for(var n=r.length-1;n>=0&&""===r[n];n--);return i>n?[]:r.slice(i,n-i+1)}r=n.resolve(r).substr(1),i=n.resolve(i).substr(1);for(var a=t(r.split("/")),s=t(i.split("/")),u=Math.min(a.length,s.length),c=u,e=0;u>e;e++)if(a[e]!==s[e]){c=e;break}for(var f=[],e=c;e<a.length;e++)f.push("..");return f=f.concat(s.slice(c)),f.join("/")},n.sep="/",n.delimiter=":",n.dirname=function(r){var i=s(r),n=i[0],t=i[1];return n||t?(t&&(t=t.substr(0,t.length-1)),n+t):"."},n.basename=function(r,i){var n=s(r)[2];return i&&n.substr(-1*i.length)===i&&(n=n.substr(0,n.length-i.length)),n},n.extname=function(r){return s(r)[3]};var u="b"==="ab".substr(-1)?function(r,i,n){return r.substr(i,n)}:function(r,i,n){return 0>i&&(i=r.length+i),r.substr(i,n)}}).call(this,r("_process"))},{_process:20}],20:[function(r,i,n){function t(){g=!1,c.length?f=c.concat(f):h=-1,f.length&&a()}function a(){if(!g){var r=setTimeout(t);g=!0;for(var i=f.length;i;){for(c=f,f=[];++h<i;)c&&c[h].run();h=-1,i=f.length}c=null,g=!1,clearTimeout(r)}}function s(r,i){this.fun=r,this.array=i}function u(){}var c,e=i.exports={},f=[],g=!1,h=-1;e.nextTick=function(r){var i=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)i[n-1]=arguments[n];f.push(new s(r,i)),1!==f.length||g||setTimeout(a,0)},s.prototype.run=function(){this.fun.apply(null,this.array)},e.title="browser",e.browser=!0,e.env={},e.argv=[],e.version="",e.versions={},e.on=u,e.addListener=u,e.once=u,e.off=u,e.removeListener=u,e.removeAllListeners=u,e.emit=u,e.binding=function(r){throw new Error("process.binding is not supported")},e.cwd=function(){return"/"},e.chdir=function(r){throw new Error("process.chdir is not supported")},e.umask=function(){return 0}},{}],21:[function(r,i,n){(function(i,t){"use strict";function a(r){if(r){var i=r.length||r.byteLength,n=j.log2(i);p[n].push(r)}}function s(r){a(r.buffer)}function u(r){var r=j.nextPow2(r),i=j.log2(r),n=p[i];return n.length>0?n.pop():new ArrayBuffer(r)}function c(r){return new Uint8Array(u(r),0,r)}function e(r){return new Uint16Array(u(2*r),0,r)}function f(r){return new Uint32Array(u(4*r),0,r)}function g(r){return new Int8Array(u(r),0,r)}function h(r){return new Int16Array(u(2*r),0,r)}function o(r){return new Int32Array(u(4*r),0,r)}function v(r){return new Float32Array(u(4*r),0,r)}function y(r){return new Float64Array(u(8*r),0,r)}function X(r){return l?new Uint8ClampedArray(u(r),0,r):c(r)}function b(r){return new DataView(u(r),0,r)}function d(r){r=j.nextPow2(r);var i=j.log2(r),n=q[i];return n.length>0?n.pop():new t(r)}var j=r("bit-twiddle"),k=r("dup");i.__TYPEDARRAY_POOL||(i.__TYPEDARRAY_POOL={UINT8:k([32,0]),UINT16:k([32,0]),UINT32:k([32,0]),INT8:k([32,0]),INT16:k([32,0]),INT32:k([32,0]),FLOAT:k([32,0]),DOUBLE:k([32,0]),DATA:k([32,0]),UINT8C:k([32,0]),BUFFER:k([32,0])});var l="undefined"!=typeof Uint8ClampedArray,m=i.__TYPEDARRAY_POOL;m.UINT8C||(m.UINT8C=k([32,0])),m.BUFFER||(m.BUFFER=k([32,0]));var p=m.DATA,q=m.BUFFER;n.free=function(r){if(t.isBuffer(r))q[j.log2(r.length)].push(r);else{if("[object ArrayBuffer]"!==Object.prototype.toString.call(r)&&(r=r.buffer),!r)return;var i=r.length||r.byteLength,n=0|j.log2(i);p[n].push(r)}},n.freeUint8=n.freeUint16=n.freeUint32=n.freeInt8=n.freeInt16=n.freeInt32=n.freeFloat32=n.freeFloat=n.freeFloat64=n.freeDouble=n.freeUint8Clamped=n.freeDataView=s,n.freeArrayBuffer=a,n.freeBuffer=function(r){q[j.log2(r.length)].push(r)},n.malloc=function(r,i){if(void 0===i||"arraybuffer"===i)return u(r);switch(i){case"uint8":return c(r);case"uint16":return e(r);case"uint32":return f(r);case"int8":return g(r);case"int16":return h(r);case"int32":return o(r);case"float":case"float32":return v(r);case"double":case"float64":return y(r);case"uint8_clamped":return X(r);case"buffer":return d(r);case"data":case"dataview":return b(r);default:return null}return null},n.mallocArrayBuffer=u,n.mallocUint8=c,n.mallocUint16=e,n.mallocUint32=f,n.mallocInt8=g,n.mallocInt16=h,n.mallocInt32=o,n.mallocFloat32=n.mallocFloat=v,n.mallocFloat64=n.mallocDouble=y,n.mallocUint8Clamped=X,n.mallocDataView=b,n.mallocBuffer=d,n.clearCache=function(){for(var r=0;32>r;++r)m.UINT8[r].length=0,m.UINT16[r].length=0,m.UINT32[r].length=0,m.INT8[r].length=0,m.INT16[r].length=0,m.INT32[r].length=0,m.FLOAT[r].length=0,m.DOUBLE[r].length=0,m.UINT8C[r].length=0,p[r].length=0,q[r].length=0}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},r("buffer").Buffer)},{"bit-twiddle":2,buffer:3,dup:9}],22:[function(r,i,n){"use strict";function t(r,i){for(var n=1,t=r.length,a=r[0],s=r[0],u=1;t>u;++u)if(s=a,a=r[u],i(a,s)){if(u===n){n++;continue}r[n++]=a}return r.length=n,r}function a(r){for(var i=1,n=r.length,t=r[0],a=r[0],s=1;n>s;++s,a=t)if(a=t,t=r[s],t!==a){if(s===i){i++;continue}r[i++]=t}return r.length=i,r}function s(r,i,n){return 0===r.length?r:i?(n||r.sort(i),t(r,i)):(n||r.sort(),a(r))}i.exports=s},{}],23:[function(r,i,n){"use strict";i.exports={printThreshold:7,nFloatingValues:5}},{}],24:[function(r,i,n){"use strict";i.exports={int8:Int8Array,int16:Int16Array,int32:Int32Array,uint8:Uint8Array,uint16:Uint16Array,uint32:Uint32Array,float32:Float32Array,float64:Float64Array}},{}],25:[function(r,i,n){"use strict";i.exports={ValueError:function(){var r=Error.apply(this,arguments);return r.name=this.constructor.name,r},ConfigError:function(){var r=Error.apply(this,arguments);return r.name=this.constructor.name,r},NotImplementedError:function(){var r=Error.apply(this,arguments);return r.name=this.constructor.name,r}}},{}],26:[function(r,i,n){"use strict";i.exports=function(r,i,n,t,a){var s=i-1,u=i+t-1,c=r-1,e=r+n-1;return 0!==i&&0!==r?a.selection.get(c,s)-a.selection.get(e,s)-a.selection.get(c,u)+a.selection.get(e,u):0===i&&0===r?a.selection.get(r+n-1,i+t-1):0===i?-a.selection.get(c,i+t-1)+a.selection.get(r+n-1,i+t-1):-a.selection.get(e,s)+a.selection.get(e,u)}},{}],27:[function(r,i,n){"use strict";var t=r("./area-sum");i.exports=function(r,i,n,a,s){return t(r,i,n,a,s)/(n*a)}},{"./area-sum":26}],28:[function(r,i,n){(function(n){"use strict";function t(r){return s(a.join(u,r))}var a=r("path"),s=r("./read"),u=a.join(a.resolve(n),"../../data"),c={};
Object.defineProperty(c,"digit",{get:function(){return t("five.png")}}),Object.defineProperty(c,"five",{get:function(){return t("five.png")}}),Object.defineProperty(c,"node",{get:function(){return t("nodejs.png")}}),Object.defineProperty(c,"lena",{get:function(){return t("lenna.png")}}),Object.defineProperty(c,"lenna",{get:function(){return t("lenna.png")}}),Object.defineProperty(c,"moon",{get:function(){return t("moon.jpg")}}),i.exports=c}).call(this,"/src/images")},{"./read":32,path:19}],29:[function(r,i,n){"use strict";var t=r("../ndarray");i.exports=function(r){return new t(r.selection.step(null,-1))}},{"../ndarray":42}],30:[function(r,i,n){"use strict";i.exports={data:r("./data"),read:r("./read"),save:r("./save"),resize:r("./resize"),sat:r("./sat"),ssat:r("./ssat"),sobel:r("./sobel"),scharr:r("./scharr"),areaSum:r("./area-sum"),areaValue:r("./area-value"),rgb2gray:r("./rgb2gray"),flip:r("./flip")}},{"./area-sum":26,"./area-value":27,"./data":28,"./flip":29,"./read":32,"./resize":33,"./rgb2gray":34,"./sat":35,"./save":36,"./scharr":37,"./sobel":38,"./ssat":39}],31:[function(r,i,n){"use strict";var t=r("../ndarray"),a=r("cwise/lib/wrapper")({args:["array","array","array"],pre:{body:"{this_isgray=!0}",args:[],thisVars:["this_isgray"],localVars:[]},body:{body:"{(_inline_88_arg0_!==_inline_88_arg1_||_inline_88_arg1_!==_inline_88_arg2_)&&(this_isgray=!1)}",args:[{name:"_inline_88_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_88_arg1_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_88_arg2_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_isgray"],localVars:[]},post:{body:"{return this_isgray}",args:[],thisVars:["this_isgray"],localVars:[]},debug:!1,funcName:"doCheckIsGrayscaleCwise",blockSize:64});i.exports=function(r){r instanceof t&&(r=r.selection);var i=r.shape;return 1===i.length?!1:2===i.length||3===i.length&&1===i[2]?!0:3!==i.length||3!==i[2]&&4!==i[2]?!1:a(r.pick(null,null,0),r.pick(null,null,1),r.pick(null,null,2))}},{"../ndarray":42,"cwise/lib/wrapper":8}],32:[function(r,i,n){"use strict";function t(r){var i=r.getContext("2d"),n=i.getImageData(0,0,r.width,r.height),t=[r.width,r.height,4],a=[4,4*r.width,1],c=s(new Uint8Array(n.data),t,a,0),f=c.transpose(1,0);return e(f)&&(f=f.pick(null,null,0)),new u(f)}function a(r){var i=document.createElement("canvas");i.width=r.width,i.height=r.height;var n=i.getContext("2d");n.drawImage(r,0,0);var t=n.getImageData(0,0,r.width,r.height),a=[r.width,r.height,4],c=[4,4*r.width,1],f=s(new Uint8Array(t.data),a,c,0),g=f.transpose(1,0);return e(g)&&(g=g.pick(null,null,0)),new u(g)}var s=r("ndarray"),u=r("../ndarray"),c=r("../errors"),e=(r("./utils"),r("./is-grayscale"));i.exports=function(r){if(r instanceof HTMLCanvasElement)return t(r);if(r instanceof HTMLImageElement)return a(r);throw new c.ValueError("expect input to be either an HTML Canvas or a (loaded) Image")}},{"../errors":25,"../ndarray":42,"./is-grayscale":31,"./utils":40,ndarray:18}],33:[function(r,i,n){"use strict";var t=r("./utils"),a=r("ndarray"),s=r("../ndarray");i.exports=function(r,i,n){var u=r.shape,c=u[0],e=u[1],f=u[2]||1,g=document.createElement("canvas");g.height=c,g.width=e;var h=g.getContext("2d"),o=h.createImageData(e,c),v=t.setRawData(r.selection,o.data);if(v)throw v;var y=c/i,X=e/n,b=Math.min(y,X),d=i*b,j=n*b,k=(c-b*i)/2,l=(e-b*n)/2;h.putImageData(o,0,0),h.drawImage(g,l,k,j,d,0,0,n,i);var m=h.getImageData(0,0,n,i),p=[0|n,0|i,4],q=[4,4*n|0,1],w=a(new Uint8Array(m.data),p,q,0),x=w.transpose(1,0);return 2===u.length?x=x.pick(null,null,0):3===u.length&&1===f&&(x=x.pick(null,null,0)),new s(x)}},{"../ndarray":42,"./utils":40,ndarray:18}],34:[function(r,i,n){"use strict";var t=r("../ndarray"),a=r("../utils"),s=r("cwise/lib/wrapper")({args:["array","array","array","array"],pre:{body:"{}",args:[],thisVars:[],localVars:[]},body:{body:"{_inline_85_arg0_=4899*_inline_85_arg1_+9617*_inline_85_arg2_+1868*_inline_85_arg3_+8192>>14}",args:[{name:"_inline_85_arg0_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_85_arg1_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_85_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_85_arg3_",lvalue:!1,rvalue:!0,count:1}],thisVars:[],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:!1,funcName:"rgb2grayCwise",blockSize:64});i.exports=function(r){r instanceof t||(r=new t(r));var i=r.shape,n=i[0],u=i[1],c=i[2]||1;if(1===c)return r;var e=[n,u],f=new t(new Uint8Array(a.shapeSize(e)),e),g=r.selection.pick(null,null,0),h=r.selection.pick(null,null,1),o=r.selection.pick(null,null,2);return s(f.selection,g,h,o),f}},{"../ndarray":42,"../utils":43,"cwise/lib/wrapper":8}],35:[function(r,i,n){"use strict";var t=r("../ndarray"),a=r("./rgb2gray"),s=r("cwise/lib/wrapper")({args:["array","array","index",{offset:[-1,-1],array:0},{offset:[-1,0],array:0},{offset:[0,-1],array:0}],pre:{body:"{}",args:[],thisVars:[],localVars:[]},body:{body:"{_inline_73_arg0_=0!==_inline_73_arg2_[0]&&0!==_inline_73_arg2_[1]?_inline_73_arg1_+_inline_73_arg4_+_inline_73_arg5_-_inline_73_arg3_:0===_inline_73_arg2_[0]&&0===_inline_73_arg2_[1]?_inline_73_arg1_:0===_inline_73_arg2_[0]?_inline_73_arg1_+_inline_73_arg5_:_inline_73_arg1_+_inline_73_arg4_}",args:[{name:"_inline_73_arg0_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_73_arg1_",lvalue:!1,rvalue:!0,count:4},{name:"_inline_73_arg2_",lvalue:!1,rvalue:!0,count:5},{name:"_inline_73_arg3_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_73_arg4_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_73_arg5_",lvalue:!1,rvalue:!0,count:2}],thisVars:[],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:!1,funcName:"doIntegrateBody",blockSize:64});i.exports=function(r){var i=a(r),n=i.shape,u=n[0],c=n[1],e=new t(new Uint32Array(u*c),[u,c]);return s(e.selection,i.selection),e}},{"../ndarray":42,"./rgb2gray":34,"cwise/lib/wrapper":8}],36:[function(r,i,n){"use strict";var t=r("./utils"),a=(r("../ndarray"),r("../errors"));i.exports=function(r,i){var n=r.shape,s=n[0],u=n[1];if(!(i instanceof HTMLCanvasElement))throw new a.ValueError("expect input to be either an HTML Canvas or a (loaded) Image");var c=document.createElement("canvas");c.height=s,c.width=u;var e=c.getContext("2d"),f=e.createImageData(u,s),g=t.setRawData(r.selection,f.data);if(g)throw g;e.putImageData(f,0,0),e.drawImage(c,u,s),i.getContext("2d").drawImage(c,0,0,u,s,0,0,i.width,i.height)}},{"../errors":25,"../ndarray":42,"./utils":40}],37:[function(r,i,n){"use strict";var t=r("ndarray-ops"),a=r("../ndarray"),s=r("../utils"),u=r("./rgb2gray"),c=r("cwise/lib/wrapper")({args:["array","array",{offset:[-1,-1],array:1},{offset:[-1,0],array:1},{offset:[-1,1],array:1},{offset:[0,-1],array:1},{offset:[0,1],array:1},{offset:[1,-1],array:1},{offset:[1,0],array:1},{offset:[1,1],array:1}],pre:{body:"{}",args:[],thisVars:[],localVars:[]},body:{body:"{var _inline_82_q=3*_inline_82_arg2_+10*_inline_82_arg3_+3*_inline_82_arg4_-3*_inline_82_arg7_-10*_inline_82_arg8_-3*_inline_82_arg9_,_inline_82_s=3*_inline_82_arg2_-3*_inline_82_arg4_+10*_inline_82_arg5_-10*_inline_82_arg6_+3*_inline_82_arg7_-3*_inline_82_arg9_;_inline_82_arg0_=Math.sqrt(_inline_82_s*_inline_82_s+_inline_82_q*_inline_82_q)}",args:[{name:"_inline_82_arg0_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_82_arg1_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_82_arg2_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_82_arg3_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_82_arg4_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_82_arg5_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_82_arg6_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_82_arg7_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_82_arg8_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_82_arg9_",lvalue:!1,rvalue:!0,count:2}],thisVars:[],localVars:["_inline_82_q","_inline_82_s"]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:!1,funcName:"doSobelBody",blockSize:64});i.exports=function(r){var i=u(r),n=i.shape,e=n[0],f=n[1],g=new a(new Float32Array(s.shapeSize(n)),n);return c(g.selection,i.selection),t.assigns(g.selection.pick(0,null),0),t.assigns(g.selection.pick(null,0),0),t.assigns(g.selection.pick(e-1,null),0),t.assigns(g.selection.pick(null,f-1),0),g.divide(16*Math.sqrt(2),!1)}},{"../ndarray":42,"../utils":43,"./rgb2gray":34,"cwise/lib/wrapper":8,"ndarray-ops":17}],38:[function(r,i,n){"use strict";var t=r("ndarray-ops"),a=r("../ndarray"),s=r("../utils"),u=r("./rgb2gray"),c=r("cwise/lib/wrapper")({args:["array","array",{offset:[-1,-1],array:1},{offset:[-1,0],array:1},{offset:[-1,1],array:1},{offset:[0,-1],array:1},{offset:[0,1],array:1},{offset:[1,-1],array:1},{offset:[1,0],array:1},{offset:[1,1],array:1}],pre:{body:"{}",args:[],thisVars:[],localVars:[]},body:{body:"{var _inline_79_q=_inline_79_arg2_+2*_inline_79_arg3_+_inline_79_arg4_-_inline_79_arg7_-2*_inline_79_arg8_-_inline_79_arg9_,_inline_79_s=_inline_79_arg2_-_inline_79_arg4_+2*_inline_79_arg5_-2*_inline_79_arg6_+_inline_79_arg7_-_inline_79_arg9_;_inline_79_arg0_=Math.sqrt(_inline_79_s*_inline_79_s+_inline_79_q*_inline_79_q)}",args:[{name:"_inline_79_arg0_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_79_arg1_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_79_arg2_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_79_arg3_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_79_arg4_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_79_arg5_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_79_arg6_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_79_arg7_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_79_arg8_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_79_arg9_",lvalue:!1,rvalue:!0,count:2}],thisVars:[],localVars:["_inline_79_q","_inline_79_s"]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:!1,funcName:"doSobelBody",blockSize:64});i.exports=function(r){var i=u(r),n=i.shape,e=n[0],f=n[1],g=new a(new Float32Array(s.shapeSize(n)),n);return c(g.selection,i.selection),t.assigns(g.selection.pick(0,null),0),t.assigns(g.selection.pick(null,0),0),t.assigns(g.selection.pick(e-1,null),0),t.assigns(g.selection.pick(null,f-1),0),g.divide(4*Math.sqrt(2),!1)}},{"../ndarray":42,"../utils":43,"./rgb2gray":34,"cwise/lib/wrapper":8,"ndarray-ops":17}],39:[function(r,i,n){"use strict";var t=r("../ndarray"),a=r("./rgb2gray"),s=r("cwise/lib/wrapper")({args:["array","array","index",{offset:[-1,-1],array:0},{offset:[-1,0],array:0},{offset:[0,-1],array:0}],pre:{body:"{}",args:[],thisVars:[],localVars:[]},body:{body:"{_inline_76_arg0_=0!==_inline_76_arg2_[0]&&0!==_inline_76_arg2_[1]?_inline_76_arg1_*_inline_76_arg1_+_inline_76_arg4_+_inline_76_arg5_-_inline_76_arg3_:0===_inline_76_arg2_[0]&&0===_inline_76_arg2_[1]?_inline_76_arg1_*_inline_76_arg1_:0===_inline_76_arg2_[0]?_inline_76_arg1_*_inline_76_arg1_+_inline_76_arg5_:_inline_76_arg1_*_inline_76_arg1_+_inline_76_arg4_}",args:[{name:"_inline_76_arg0_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_76_arg1_",lvalue:!1,rvalue:!0,count:8},{name:"_inline_76_arg2_",lvalue:!1,rvalue:!0,count:5},{name:"_inline_76_arg3_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_76_arg4_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_76_arg5_",lvalue:!1,rvalue:!0,count:2}],thisVars:[],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:!1,funcName:"doIntegrateBody",blockSize:64});i.exports=function(r){var i=a(r),n=i.shape,u=n[0],c=n[1],e=new t(new Uint32Array(u*c),[u,c]);return s(e.selection,i.selection),e}},{"../ndarray":42,"./rgb2gray":34,"cwise/lib/wrapper":8}],40:[function(r,i,n){"use strict";var t=r("../ndarray");i.exports.getRawData=function(r){r instanceof t&&(r=r.selection);var i,n,a=0,s=r.shape,u=s[0],c=s[1],e=s[2]||1,f=new Uint8Array(u*c*e);if(3===r.shape.length)if(3===e)for(i=0;u>i;++i)for(n=0;c>n;++n)f[a++]=r.get(i,n,0),f[a++]=r.get(i,n,1),f[a++]=r.get(i,n,2);else if(4===e)for(i=0;u>i;++i)for(n=0;c>n;++n)f[a++]=r.get(i,n,0),f[a++]=r.get(i,n,1),f[a++]=r.get(i,n,2),f[a++]=r.get(i,n,3);else{if(1!==e)return new Error("Incompatible array shape");for(i=0;u>i;++i)for(n=0;c>n;++n)f[a++]=r.get(i,n,0)}else{if(2!==r.shape.length)return new Error("Invalid image");for(i=0;u>i;++i)for(n=0;c>n;++n)f[a++]=r.get(i,n)}return f},i.exports.setRawData=function(r,i){var n,t,a,s=0,u=r.shape[0],c=r.shape[1],e=r.shape[2]||1;if(3===r.shape.length)if(3===e)for(n=0;u>n;++n)for(t=0;c>t;++t)i[s++]=r.get(n,t,0),i[s++]=r.get(n,t,1),i[s++]=r.get(n,t,2),i[s++]=255;else if(4===e)for(n=0;u>n;++n)for(t=0;c>t;++t)i[s++]=r.get(n,t,0),i[s++]=r.get(n,t,1),i[s++]=r.get(n,t,2),i[s++]=r.get(n,t,3);else{if(1!==e)return new Error("Incompatible array shape");for(n=0;u>n;++n)for(t=0;c>t;++t)a=r.get(n,t,0),i[s++]=a,i[s++]=a,i[s++]=a,i[s++]=255}else{if(2!==r.shape.length)return new Error("Invalid image");for(n=0;u>n;++n)for(t=0;c>t;++t)a=r.get(n,t),i[s++]=a,i[s++]=a,i[s++]=a,i[s++]=255}}},{"../ndarray":42}],41:[function(r,i,n){"use strict";function t(r,i){if(0!==r.length&&0!==i.length){for(var n=r.slice().reverse(),t=i.slice().reverse(),a=Math.max(r.length,i.length),s=new Array(a),u=0;a>u;u++)if(n[u]&&1!==n[u])if(t[u]&&1!==t[u]){if(n[u]!==t[u])return;s[u]=n[u]}else s[u]=n[u];else s[u]=t[u];return s.reverse()}}function a(r,i){return Y["new"](r).add(i)}function s(r,i){return Y["new"](r).multiply(i)}function u(r,i){return Y["new"](r).divide(i)}function c(r,i){return Y["new"](r).subtract(i)}function e(r,i){return Y["new"](r).equal(i)}function f(r){return Y["new"](r).flatten()}function g(r,i){return Y["new"](r).reshape(i)}function h(r){return Y["new"](r).exp()}function o(r){return Y["new"](r).sqrt()}function v(r,i){return Y["new"](r).pow(i)}function y(r){return Y["new"](r).sum()}function X(r){return Y["new"](r).mean()}function b(r){return Y["new"](r).std()}function d(r){return Y["new"](r).min()}function j(r){return Y["new"](r).max()}function k(r,i){return Y["new"](r).transpose(i)}function l(r){return Y["new"](r).negative()}function m(r,i,n,t){1===arguments.length?(i=r,r=0,n=1):2===arguments.length&&Z.isNumber(i)?n=1:2===arguments.length?(t=i,i=r,r=0,n=1):3!==arguments.length||Z.isNumber(n)||(t=n,n=1);for(var a=[],s=0;i>r;)a[s++]=r,r+=n;return Y["new"](a,t)}function p(r,i){Z.isNumber(r)&&r>=0&&(r=[r]);var n=Z.shapeSize(r),t=Z.getType(i),a=new Y(new t(n),r);return S.assigns(a.selection,0),a}function q(r,i){Z.isNumber(r)&&r>=0&&(r=[r]);var n=Z.shapeSize(r),t=Z.getType(i),a=new Y(new t(n),r);return S.assigns(a.selection,1),a}function w(r){if(0===arguments.length)return Y["new"](Math.random());r=1===arguments.length?Z.isNumber(r)?[0|r]:r:arguments;var i=Z.shapeSize(r),n=new Y(new Array(i),r);return S.random(n.selection),n}function x(r){var i=Y["new"](r).exp(),n=i.sum();return S.divseq(i.selection,n),i}function z(r,i){return r=Y["new"](r).clone(),i=i||1,_(r.selection,i),r}function A(r,i,n){1===arguments.length?(i=0,n=1):2===arguments.length&&(n=1);var t=r instanceof Y?r.clone():Y["new"](r);return rr(t.selection,i,n),t}function B(r,i){i=i||.001;var n=r instanceof Y?r.clone():Y["new"](r);return ir(n.selection,i),n}function C(r){var i=r instanceof Y?r.clone():Y["new"](r);return nr(i.selection),i}function D(r){var i=r instanceof Y?r.clone():Y["new"](r);return S.abseq(i.selection),i}function E(r){var i=r instanceof Y?r.clone():Y["new"](r);return S.coseq(i.selection),i}function F(r){var i=r instanceof Y?r.clone():Y["new"](r);return S.acoseq(i.selection),i}function G(r){var i=r instanceof Y?r.clone():Y["new"](r);return S.sineq(i.selection),i}function H(r){var i=r instanceof Y?r.clone():Y["new"](r);return S.asineq(i.selection),i}function I(r){var i=r instanceof Y?r.clone():Y["new"](r);return S.taneq(i.selection),i}function J(r){var i=r instanceof Y?r.clone():Y["new"](r);return S.ataneq(i.selection),i}function K(r,i){r=Y["new"](r),i=Y["new"](i);var n,t,a=r.shape,s=i.shape,u=Z.getType(r.dtype);if(2===a.length&&2===s.length&&a[1]===s[0])return n=[a[0],s[1]],t=new Y(new u(Z.shapeSize(n)),n),T(t.selection,r.selection,i.selection),t;if(1===a.length&&2===s.length&&a[0]===s[0])return K(r.reshape([a[0],1]).transpose(),i).reshape(s[1]);if(2===a.length&&1===s.length&&a[1]===s[0])return K(r,i.reshape([s[0],1])).reshape(a[0]);if(1===a.length&&1===s.length&&a[0]===s[0])return K(r.reshape([a[0],1]).transpose(),i.reshape([s[0],1])).reshape([1]);throw new $.ValueError("cannot compute the matrix product of given arrays")}function L(r){arguments.length>1&&(r=[].slice.call(arguments));var i,n;for(i=0;i<r.length;i++)n=r[i],r[i]=n instanceof Y?n.tolist():Z.isNumber(n)?[n]:n;var t=r[0];for(i=1;i<r.length;i++){n=r[i];var a=Z.getShape(t),s=Z.getShape(n);if(a.length!==s.length)throw new $.ValueError("all the input arrays must have same number of dimensions");if(1===a.length&&1===s.length)t=t.concat(n);else if(2===a.length&&2===s.length&&a[0]===s[0]||1===a.length&&2===s.length&&a[0]===s[0]||2===a.length&&1===s.length&&a[0]===s[0])for(var u=0;u<a[0];u++)t[u]=t[u].concat(n[u]);else{if(!(3===a.length&&3===s.length&&a[0]===s[0]&&a[1]===s[1]||2===a.length&&3===s.length&&a[0]===s[0]&&a[1]===s[1]||3===a.length&&2===s.length&&a[0]===s[0]&&a[1]===s[1]))throw new $.ValueError('cannot concatenate "'+a+'" with "'+s+'"');for(var c=0;c<a[0];c++){for(var e=new Array(a[1]),f=0;f<a[1];f++)e[f]=t[c][f].concat(n[c][f]);t[c]=e}}}return Y["new"](t,r[0].dtype)}function M(r){return Y["new"](r).round()}function N(r,i){return Y["new"](r).convolve(i)}function O(r,i){return Y["new"](r).fftconvolve(i)}function P(r){r=r instanceof Y?r.clone():Y["new"](r);var i=r.shape,n=i.length;if(2!==i[n-1])throw new $.ValueError("expect last dimension of the array to have 2 values (for both real and imaginary part)");var t=new Array(n),a=new Array(n);return t[n-1]=0,a[n-1]=1,U(1,r.selection.pick.apply(r.selection,t),r.selection.pick.apply(r.selection,a)),r}function Q(r){r=r instanceof Y?r.clone():Y["new"](r);var i=r.shape,n=i.length;if(2!==i[n-1])throw new $.ValueError("expect last dimension of the array to have 2 values (for both real and imaginary part)");var t=new Array(n),a=new Array(n);return t[n-1]=0,a[n-1]=1,U(-1,r.selection.pick.apply(r.selection,t),r.selection.pick.apply(r.selection,a)),r}var R=r("ndarray"),S=r("ndarray-ops"),T=r("ndarray-gemm"),U=r("ndarray-fft"),V=r("./config"),W=r("./dtypes"),Y=r("./ndarray"),Z=r("./utils"),$=r("./errors"),_=r("cwise/lib/wrapper")({args:["array","scalar"],pre:{body:"{}",args:[],thisVars:[],localVars:[]},body:{body:"{_inline_46_arg0_=-30>_inline_46_arg0_?0:_inline_46_arg0_>30?1:1/(1+Math.exp(-1*_inline_46_arg1_*_inline_46_arg0_))}",args:[{name:"_inline_46_arg0_",lvalue:!0,rvalue:!0,count:4},{name:"_inline_46_arg1_",lvalue:!1,rvalue:!0,count:1}],thisVars:[],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:!1,funcName:"sigmoidCwise",blockSize:64}),rr=r("cwise/lib/wrapper")({args:["array","scalar","scalar"],pre:{body:"{}",args:[],thisVars:[],localVars:[]},body:{body:"{_inline_49_arg0_=Math.min(Math.max(_inline_49_arg1_,_inline_49_arg0_),_inline_49_arg2_)}",args:[{name:"_inline_49_arg0_",lvalue:!0,rvalue:!0,count:2},{name:"_inline_49_arg1_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_49_arg2_",lvalue:!1,rvalue:!0,count:1}],thisVars:[],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:!1,funcName:"clipCwise",blockSize:64}),ir=r("cwise/lib/wrapper")({args:["array","scalar"],pre:{body:"{}",args:[],thisVars:[],localVars:[]},body:{body:"{_inline_52_arg0_=Math.max(_inline_52_arg1_*_inline_52_arg0_,_inline_52_arg0_)}",args:[{name:"_inline_52_arg0_",lvalue:!0,rvalue:!0,count:3},{name:"_inline_52_arg1_",lvalue:!1,rvalue:!0,count:1}],thisVars:[],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:!1,funcName:"leakyReluCwise",blockSize:64}),nr=r("cwise/lib/wrapper")({args:["array"],pre:{body:"{}",args:[],thisVars:[],localVars:[]},body:{body:"{_inline_55_arg0_=(Math.exp(2*_inline_55_arg0_)-1)/(Math.exp(2*_inline_55_arg0_)+1)}",args:[{name:"_inline_55_arg0_",lvalue:!0,rvalue:!0,count:3}],thisVars:[],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:!1,funcName:"tanhCwise",blockSize:64});i.exports={config:V,dtypes:W,NdArray:Y,ndarray:R,array:Y["new"],arange:m,reshape:g,zeros:p,ones:q,flatten:f,random:w,softmax:x,sigmoid:z,leakyRelu:B,abs:D,arccos:F,arcsin:H,arctan:J,cos:E,sin:G,tan:I,tanh:C,clip:A,exp:h,sqrt:o,power:v,sum:y,mean:X,std:b,dot:K,add:a,subtract:c,multiply:s,divide:u,negative:l,equal:e,max:j,min:d,concatenate:L,transpose:k,errors:$,broadcast:t,round:M,convolve:N,fftconvolve:O,fft:P,ifft:Q,int8:function(r){return Y["new"](r,W.int8)},uint8:function(r){return Y["new"](r,W.uint8)},int16:function(r){return Y["new"](r,W.int16)},uint16:function(r){return Y["new"](r,W.uint16)},int32:function(r){return Y["new"](r,W.int32)},uint32:function(r){return Y["new"](r,W.uint32)},float32:function(r){return Y["new"](r,W.float32)},float64:function(r){return Y["new"](r,W.float64)},images:r("./images")}},{"./config":23,"./dtypes":24,"./errors":25,"./images":30,"./ndarray":42,"./utils":43,"cwise/lib/wrapper":8,ndarray:18,"ndarray-fft":13,"ndarray-gemm":15,"ndarray-ops":17}],42:[function(r,i,n){"use strict";function t(r,i){if(r instanceof y)return r;var n=v.getType(i);if(v.isNumber(r))return n!==Array?new y(new n([r]),[1]):new y([r],[1]);var t=v.getShape(r);return t.length>1&&(r=v.flatten(r,!0)),r instanceof n||(r=new n(r)),new y(r,t)}function a(r,i){i=i||0;var n=0|r[i];if(0>=n)return[];var t,s=new Array(n);if(i===r.length-1)for(t=0;n>t;++t)s[t]=0;else for(t=0;n>t;++t)s[t]=a(r,i+1);return s}function s(r){var i=a(r.shape,0);return j(r,i),i}function u(r){return String(Number((r||0).toFixed(h.nFloatingValues)))}var c=r("ndarray"),e=r("ndarray-ops"),f=(r("ndarray-gemm"),r("ndarray-fft")),g=r("typedarray-pool"),h=r("./config"),o=r("./errors"),v=r("./utils"),y=function(){if(1===arguments.length)this.selection=arguments[0];else{if(0===arguments.length)throw new o.ValueError("Required argument 'data' not found");this.selection=c.apply(null,arguments)}Object.defineProperty(this,"size",{get:function(){return this.selection.size}.bind(this)}),Object.defineProperty(this,"shape",{get:function(){return this.selection.shape}.bind(this)}),Object.defineProperty(this,"ndim",{get:function(){return this.selection.shape.length}.bind(this)}),Object.defineProperty(this,"dtype",{get:function(){return this.selection.dtype}.bind(this),set:function(r){var i=v.getType(r);this.selection=c(new i(this.selection.data),this.selection.shape,this.selection.stride,this.selection.offset)}.bind(this)}),Object.defineProperty(this,"T",{get:function(){return this.transpose()}.bind(this)})};y.prototype.get=function(){for(var r=arguments.length,i=0;r>i;i++)arguments[i]<0&&(arguments[i]+=this.shape[i]);return this.selection.get.apply(this.selection,arguments)},y.prototype.set=function(){return this.selection.set.apply(this.selection,arguments)},y.prototype.slice=function(){for(var r=this.ndim,i=new Array(r),n=new Array(r),t=new Array(r),a=this.shape,s=0;r>s;s++){var u=arguments[s];if("undefined"==typeof u)break;if(null!==u)if(v.isNumber(u))n[s]=0>u?u+a[s]:u,i[s]=null,t[s]=1;else{var c=u[0]<0?u[0]+a[s]:u[0],e=u[1]<0?u[1]+a[s]:u[1];n[s]=e?c:0,i[s]=e?e-c:c,t[s]=u[2]||1}}var f=this.selection.lo.apply(this.selection,n),g=f.hi.apply(f,i),h=g.step.apply(g,t);return new y(h)},y.prototype.pick=function(r){return new y(this.selection.pick.apply(this.selection,arguments))},y.prototype.lo=function(){return new y(this.selection.lo.apply(this.selection,arguments))},y.prototype.hi=function(){return new y(this.selection.hi.apply(this.selection,arguments))},y.prototype.step=function(){return new y(this.selection.step.apply(this.selection,arguments))},y.prototype.flatten=function(){if(1===this.shape.length)return new y(this.selection);var r=v.getType(this.dtype),i=v.flatten(this.tolist(),!0);return i instanceof r||(i=new r(i)),new y(i,[this.size])},y.prototype.reshape=function(r){if(0===arguments.length)throw new o.ValueError("function takes at least one argument (0 given)");if(1===arguments.length&&v.isNumber(r)&&(r=[r]),arguments.length>1&&(r=arguments),this.size!==v.shapeSize(r))throw new o.ValueError("total size of new array must be unchanged");var i,n,t,a,s=this.selection.shape,u=this.selection.offset,c=this.selection.stride,e=s.length,f=r.length;if(e===f){var g=!0;for(t=0;f>t;++t)if(s[t]!==r[t]){g=!1;break}if(g)return new y(this.selection.data,s,c,u)}else if(1===e){for(i=new Array(f),t=f-1,a=1;t>=0;--t)i[t]=a,a*=r[t];for(n=u,t=0;f>t;++t)i[t]<0&&(n-=(r[t]-1)*i[t]);return new y(this.selection.data,r,i,n)}var h=Math.min(e,f),X=!0;for(t=0;h>t;t++)if(s[t]!==r[t]){X=!1;break}if(X){for(i=new Array(f),t=0;f>t;t++)i[t]=c[t]||1;return n=u,new y(this.selection.data,r,i,n)}return this.flatten().reshape(r)},y.prototype.transpose=function(r){if(0===arguments.length){var i=this.ndim;r=new Array(i);for(var n=0;i>n;n++)r[n]=i-n-1}else arguments.length>1&&(r=arguments);return new y(this.selection.transpose.apply(this.selection,r))},y.prototype.add=function(r,i){1===arguments.length&&(i=!0);var n=i?this.clone():this;return v.isNumber(r)?(e.addseq(n.selection,r),n):(r=t(r,this.dtype),e.addeq(n.selection,r.selection),n)},y.prototype.subtract=function(r,i){1===arguments.length&&(i=!0);var n=i?this.clone():this;return v.isNumber(r)?(e.subseq(n.selection,r),n):(r=t(r,this.dtype),e.subeq(n.selection,r.selection),n)},y.prototype.multiply=function(r,i){1===arguments.length&&(i=!0);var n=i?this.clone():this;return v.isNumber(r)?(e.mulseq(n.selection,r),n):(r=t(r,this.dtype),e.muleq(n.selection,r.selection),n)},y.prototype.divide=function(r,i){1===arguments.length&&(i=!0);var n=i?this.clone():this;return v.isNumber(r)?(e.divseq(n.selection,r),n):(r=t(r,this.dtype),e.diveq(n.selection,r.selection),n)},y.prototype.pow=function(r,i){1===arguments.length&&(i=!0);var n=i?this.clone():this;return v.isNumber(r)?(e.powseq(n.selection,r),n):(r=t(r,this.dtype),e.poweq(n.selection,r.selection),n)},y.prototype.exp=function(r){0===arguments.length&&(r=!0);var i=r?this.clone():this;return e.expeq(i.selection),i},y.prototype.sqrt=function(r){0===arguments.length&&(r=!0);var i=r?this.clone():this;return e.sqrteq(i.selection),i},y.prototype.max=function(){return 0===this.selection.size?null:e.sup(this.selection)},y.prototype.min=function(){return 0===this.selection.size?null:e.inf(this.selection)},y.prototype.sum=function(){return e.sum(this.selection)},y.prototype.std=function(){var r=this.clone();e.powseq(r.selection,2);var i=this.mean(),n=Math.abs(e.sum(r.selection)/v.shapeSize(this.shape)-i*i);return n>0?Math.sqrt(n):0},y.prototype.mean=function(){return e.sum(this.selection)/v.shapeSize(this.shape)},y.prototype.tolist=function(){return s(this.selection)},y.prototype.valueOf=function(){return this.tolist()},y.prototype.toString=function(){function r(n,t){if(v.isString(t))return t;if(v.isNumber(t)){var a=u(t);return new Array(Math.max(0,i-a.length+2)).join(" ")+a}n=n||0;var s,c=h.printThreshold,e=c/2|0;return s=t.length>c?[].concat(t.slice(0,e),[" ..."],t.slice(t.length-e)):t,new Array(n+1).join(" ")+"["+s.map(function(i,t){return r(0===t&&0===n?1:n+1,i)}).join(",")+"]"}var i=u(this.max()).length,n=/\]\,(\s*)\[/g,t="],\n$1 [",a=/\]\,(\s+)...\,(\s+)\[/g,s="],\n$2 ...\n$2 [",c=/\[\s+\[/g,e="[[",f=JSON.stringify(this.tolist(),r).replace(n,t).replace(c,e).replace(c,e).replace(a,s).slice(2,-1);switch(this.dtype){case"array":return"array(["+f+")";default:return"array(["+f+", dtype="+this.dtype+")"}},y.prototype.inspect=y.prototype.toString,y.prototype.toJSON=function(){return JSON.stringify(this.tolist())},y.prototype.clone=function(){var r=this.selection;return new y(c(r.data.slice(),r.shape,r.stride,r.offset))},y.prototype.equal=function(r){if(r=t(r),this.size!==r.size||this.ndim!==r.ndim)return!1;for(var i=this.ndim,n=0;i>n;n++)if(this.shape[n]!==r.shape[n])return!1;return e.all(e.eqeq(this.selection,r.selection))},y.prototype.round=function(r){0===arguments.length&&(r=!0);var i=r?this.clone():this;return e.roundeq(i.selection),i},y.prototype.negative=function(){var r=this.clone();return e.neg(r.selection,this.selection),r},y.prototype.iteraxis=function(r,i){var n=this.shape;if(-1===r&&(r=n.length-1),0>r||r>n.length-1)throw new o.ValueError("invalid axis");for(var a=0;a<n[r];a++){for(var u=new Array(r+1),c=0;r+1>c;c++)u[c]=c===r?a:null;var e=this.selection.pick.apply(this.selection,u),f=t(s(e),this.dtype);i(f,a)}};var X=r("cwise/lib/wrapper")({args:["array","array","array","array"],pre:{body:"{}",args:[],thisVars:[],localVars:[]},body:{body:"{var _inline_58_c=_inline_58_arg2_,_inline_58_f=_inline_58_arg3_,_inline_58_i=_inline_58_arg0_,_inline_58_o=_inline_58_arg1_,_inline_58_t=_inline_58_i*(_inline_58_c+_inline_58_f);_inline_58_arg0_=_inline_58_t-_inline_58_f*(_inline_58_i+_inline_58_o),_inline_58_arg1_=_inline_58_t+_inline_58_c*(_inline_58_o-_inline_58_i)}",args:[{name:"_inline_58_arg0_",lvalue:!0,rvalue:!0,count:2},{name:"_inline_58_arg1_",lvalue:!0,rvalue:!0,count:2},{name:"_inline_58_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_58_arg3_",lvalue:!1,rvalue:!0,count:1}],thisVars:[],localVars:["_inline_58_c","_inline_58_f","_inline_58_i","_inline_58_o","_inline_58_t"]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:!1,funcName:"cwise",blockSize:64}),b=(r("cwise/lib/wrapper")({args:["array","array"],pre:{body:"{this_sum=0}",args:[],thisVars:["this_sum"],localVars:[]},body:{body:"{this_sum+=_inline_61_arg0_*_inline_61_arg1_}",args:[{name:"_inline_61_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_61_arg1_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_sum"],localVars:[]},post:{body:"{return this_sum}",args:[],thisVars:["this_sum"],localVars:[]},debug:!1,funcName:"cwise",blockSize:64}),r("cwise/lib/wrapper")({args:["array","array","scalar","scalar","scalar","scalar","scalar","scalar","scalar","scalar","scalar",{offset:[-1,-1],array:1},{offset:[-1,0],array:1},{offset:[-1,1],array:1},{offset:[0,-1],array:1},{offset:[0,1],array:1},{offset:[1,-1],array:1},{offset:[1,0],array:1},{offset:[1,1],array:1}],pre:{body:"{}",args:[],thisVars:[],localVars:[]},body:{body:"{_inline_64_arg0_=_inline_64_arg11_*_inline_64_arg10_+_inline_64_arg12_*_inline_64_arg9_+_inline_64_arg13_*_inline_64_arg8_+_inline_64_arg14_*_inline_64_arg7_+_inline_64_arg1_*_inline_64_arg6_+_inline_64_arg15_*_inline_64_arg5_+_inline_64_arg16_*_inline_64_arg4_+_inline_64_arg17_*_inline_64_arg3_+_inline_64_arg18_*_inline_64_arg2_}",args:[{name:"_inline_64_arg0_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_64_arg1_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_64_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_64_arg3_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_64_arg4_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_64_arg5_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_64_arg6_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_64_arg7_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_64_arg8_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_64_arg9_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_64_arg10_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_64_arg11_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_64_arg12_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_64_arg13_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_64_arg14_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_64_arg15_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_64_arg16_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_64_arg17_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_64_arg18_",lvalue:!1,rvalue:!0,count:1}],thisVars:[],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:!1,funcName:"cwise",blockSize:64})),d=r("cwise/lib/wrapper")({args:["index","array","array","scalar","scalar","scalar","scalar","scalar","scalar","scalar","scalar","scalar","scalar","scalar","scalar","scalar","scalar","scalar","scalar","scalar","scalar","scalar","scalar","scalar","scalar","scalar","scalar","scalar",{offset:[-2,-2],array:1},{offset:[-2,-1],array:1},{offset:[-2,0],array:1},{offset:[-2,1],array:1},{offset:[-2,2],array:1},{offset:[-1,-2],array:1},{offset:[-1,-1],array:1},{offset:[-1,0],array:1},{offset:[-1,1],array:1},{offset:[-1,2],array:1},{offset:[0,-2],array:1},{offset:[0,-1],array:1},{offset:[0,1],array:1},{offset:[0,2],array:1},{offset:[1,-2],array:1},{offset:[1,-1],array:1},{offset:[1,0],array:1},{offset:[1,1],array:1
},{offset:[1,2],array:1},{offset:[2,-2],array:1},{offset:[2,-1],array:1},{offset:[2,0],array:1},{offset:[2,1],array:1},{offset:[2,2],array:1}],pre:{body:"{}",args:[],thisVars:[],localVars:[]},body:{body:"{_inline_67_arg1_=_inline_67_arg0_[0]<2||_inline_67_arg0_[1]<2?0:_inline_67_arg28_*_inline_67_arg27_+_inline_67_arg29_*_inline_67_arg26_+_inline_67_arg30_*_inline_67_arg25_+_inline_67_arg31_*_inline_67_arg24_+_inline_67_arg32_*_inline_67_arg23_+_inline_67_arg33_*_inline_67_arg22_+_inline_67_arg34_*_inline_67_arg21_+_inline_67_arg35_*_inline_67_arg20_+_inline_67_arg36_*_inline_67_arg19_+_inline_67_arg37_*_inline_67_arg18_+_inline_67_arg38_*_inline_67_arg17_+_inline_67_arg39_*_inline_67_arg16_+_inline_67_arg2_*_inline_67_arg15_+_inline_67_arg40_*_inline_67_arg14_+_inline_67_arg41_*_inline_67_arg13_+_inline_67_arg42_*_inline_67_arg12_+_inline_67_arg43_*_inline_67_arg11_+_inline_67_arg44_*_inline_67_arg10_+_inline_67_arg45_*_inline_67_arg9_+_inline_67_arg46_*_inline_67_arg8_+_inline_67_arg47_*_inline_67_arg7_+_inline_67_arg48_*_inline_67_arg6_+_inline_67_arg49_*_inline_67_arg5_+_inline_67_arg50_*_inline_67_arg4_+_inline_67_arg51_*_inline_67_arg3_}",args:[{name:"_inline_67_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_67_arg1_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_67_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_67_arg3_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_67_arg4_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_67_arg5_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_67_arg6_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_67_arg7_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_67_arg8_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_67_arg9_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_67_arg10_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_67_arg11_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_67_arg12_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_67_arg13_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_67_arg14_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_67_arg15_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_67_arg16_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_67_arg17_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_67_arg18_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_67_arg19_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_67_arg20_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_67_arg21_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_67_arg22_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_67_arg23_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_67_arg24_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_67_arg25_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_67_arg26_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_67_arg27_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_67_arg28_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_67_arg29_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_67_arg30_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_67_arg31_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_67_arg32_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_67_arg33_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_67_arg34_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_67_arg35_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_67_arg36_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_67_arg37_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_67_arg38_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_67_arg39_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_67_arg40_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_67_arg41_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_67_arg42_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_67_arg43_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_67_arg44_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_67_arg45_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_67_arg46_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_67_arg47_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_67_arg48_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_67_arg49_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_67_arg50_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_67_arg51_",lvalue:!1,rvalue:!0,count:1}],thisVars:[],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:!1,funcName:"cwise",blockSize:64});y.prototype.convolve=function(r){r=y["new"](r);var i=this.ndim;if(i!==r.ndim)throw new o.ValueError("arrays must have the same dimensions");for(var n=new Array(i),t=new Array(i),a=this.selection,s=this.shape,u=r.selection,c=r.shape,e=0;i>e;e++){var f=s[e]-c[e]+1;if(0>f)throw new o.ValueError("filter cannot be greater than the array");n[e]=f,t[e]=-1}if(2===i&&3===c[0]&&3===c[1]){var g=new y(new Float32Array(v.shapeSize(s)),s);return b(g.selection,a,u.get(0,0),u.get(0,1),u.get(0,2),u.get(1,0),u.get(1,1),u.get(1,2),u.get(2,0),u.get(2,1),u.get(2,2)),g.lo(1,1).hi(n[0],n[1])}if(3===i&&1===c[2]&&1===s[2]&&3===c[0]&&3===c[1]){var h=new y(new Float32Array(v.shapeSize(s)),s);return b(h.selection.pick(null,null,0),a.pick(null,null,0),u.get(0,0,0),u.get(0,1,0),u.get(0,2,0),u.get(1,0,0),u.get(1,1,0),u.get(1,2,0),u.get(2,0,0),u.get(2,1,0),u.get(2,2,0)),h.lo(1,1).hi(n[0],n[1])}if(2===i&&5===c[0]&&5===c[1]){var X=new y(new Float32Array(v.shapeSize(s)),s);return d(X.selection,a,u.get(0,0),u.get(0,1),u.get(0,2),u.get(0,3),u.get(0,4),u.get(1,0),u.get(1,1),u.get(1,2),u.get(1,3),u.get(1,4),u.get(2,0),u.get(2,1),u.get(2,2),u.get(2,3),u.get(2,4),u.get(3,0),u.get(3,1),u.get(3,2),u.get(3,3),u.get(3,4),u.get(4,0),u.get(4,1),u.get(4,2),u.get(4,3),u.get(4,4)),X.lo(2,2).hi(n[0],n[1])}if(3===i&&1===c[2]&&1===s[2]&&5===c[0]&&5===c[1]){var j=new y(new Float32Array(v.shapeSize(s)),s);return d(j.selection,a,u.get(0,0,0),u.get(0,1,0),u.get(0,2,0),u.get(0,3,0),u.get(0,4,0),u.get(1,0,0),u.get(1,1,0),u.get(1,2,0),u.get(1,3,0),u.get(1,4,0),u.get(2,0,0),u.get(2,1,0),u.get(2,2,0),u.get(2,3,0),u.get(2,4,0),u.get(3,0,0),u.get(3,1,0),u.get(3,2,0),u.get(3,3,0),u.get(3,4,0),u.get(4,0,0),u.get(4,1,0),u.get(4,2,0),u.get(4,3,0),u.get(4,4,0)),j.lo(2,2).hi(n[0],n[1])}return this.fftconvolve(r)},y.prototype.fftconvolve=function(r){if(r=y["new"](r),this.ndim!==r.ndim)throw new o.ValueError("arrays must have the same dimensions");var i,n=this.selection,t=r.selection,a=this.ndim,s=1,u=new Array(a),h=new Array(a),b=new Array(a);for(i=a-1;i>=0;--i)h[i]=n.shape[i],u[i]=s,s*=h[i],b[i]=n.shape[i]-t.shape[i]+1;var d=v.getType(n.dtype),j=new y(new d(v.shapeSize(b)),b),k=j.selection,l=g.mallocDouble(s),m=c(l,h,u,0);e.assigns(m,0),e.assign(m.hi.apply(m,n.shape),n);var p=g.mallocDouble(s),q=c(p,h,u,0);e.assigns(q,0),f(1,m,q);var w=g.mallocDouble(s),x=c(w,h,u,0);e.assigns(x,0),e.assign(x.hi.apply(x,t.shape),t);var z=g.mallocDouble(s),A=c(z,h,u,0);e.assigns(A,0),f(1,x,A),X(m,q,x,A),f(-1,m,q);var B=new Array(a),C=new Array(a),D=!1;for(i=0;a>i;++i)k.shape[i]>h[i]&&(D=!0),C[i]=+t.shape[i]-1,B[i]=Math.min(k.shape[i],h[i]-C[i]);var E;return D&&e.assign(k,0),E=m.lo.apply(m,C),E=E.hi.apply(E,B),e.assign(k.hi.apply(k,B),E),g.freeDouble(l),g.freeDouble(p),g.freeDouble(w),g.freeDouble(z),j},y["new"]=t,i.exports=y;var j=r("cwise/lib/wrapper")({args:["array","scalar","index"],pre:{body:"{}",args:[],thisVars:[],localVars:[]},body:{body:"{var _inline_70_a,_inline_70_e=_inline_70_arg1_;for(_inline_70_a=0;_inline_70_a<_inline_70_arg2_.length-1;++_inline_70_a)_inline_70_e=_inline_70_e[_inline_70_arg2_[_inline_70_a]];_inline_70_e[_inline_70_arg2_[_inline_70_arg2_.length-1]]=_inline_70_arg0_}",args:[{name:"_inline_70_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_70_arg1_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_70_arg2_",lvalue:!1,rvalue:!0,count:4}],thisVars:[],localVars:["_inline_70_a","_inline_70_e"]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:!1,funcName:"unpackCwise",blockSize:64})},{"./config":23,"./errors":25,"./utils":43,"cwise/lib/wrapper":8,ndarray:18,"ndarray-fft":13,"ndarray-gemm":15,"ndarray-ops":17,"typedarray-pool":21}],43:[function(r,i,n){"use strict";function t(r){return"number"==typeof r}function a(r){return"string"==typeof r}function s(r){return"function"==typeof r}function u(r,i,n){n=n||[];for(var a=-1,s=r.length;++a<s;){var c=r[a];t(c)?n[n.length]=c:i?u(c,i,n):n.push(c)}return n}function c(r){for(var i=1,n=0;n<r.length;n++)i*=r[n];return i}function e(r){return s(r)?r:h[r]||Array}function f(r){for(var i=[];"object"==typeof r;)i.push(r.length),r=r[0];return i}function g(r){var i,n;return"object"==typeof r?(i=r[0],"object"==typeof i?(n=i[0],"object"==typeof n?f(r):[r.length,i.length]):[r.length]):[]}var h=r("./dtypes");i.exports={isNumber:t,isString:a,isFunction:s,flatten:u,shapeSize:c,getType:e,getShape:g}},{"./dtypes":24}]},{},[41])(41)});
</script>
</head>
<body>
</body>
<h3>MRI Contrast Simulator</h3>
<input type="file" id="file" name="file">
<div class="app" id="app">
<div class="il">
<canvas id="imageCanvas"></canvas>
</div>
<table class="slidecontainer" style="border-collapse: collapse">
<tr>
<td><input type="checkbox" id="scaleCheck"></td>
<td style="width:20%">: Autoscale</td>
<td class="td1">TR</td>
<td class="slidecontainer"><input type="range" min="300" max="5000" value="500" class="slider" id="tr_slider"></td>
<td style="padding: 0 0 0 10px">
<div style="width: 32px" id="trValue">500</div>
</td>
</tr>
<tr>
<td><input type="checkbox" id="noiseCheck"></td>
<td>: Add Noise</td>
<td class="td1">TE</td>
<td><input type="range" min="10" max="250" value="50" class="slider" id="te_slider"></td>
<td class="td1">
<div style="width: 32px" id="teValue">50</div>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td class="td1">TI</td>
<td><input type="range" min="0" max="2500" value="0" class="slider" id="ti_slider"></td>
<td class="td1">
<div style="width: 32px" id="tiValue">0</div>
</td>
</tr>
</table>
</div>
<img style="display: none" id="brainMapImage" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALQAAADYCAYAAABC+8kTAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAACCISURBVHhe7Z1LqyzXdcfPuVd2ZEWyHo7kOBNHliHzGBwQBAL5AhkETEw8jUCTTDzyIIhAMjIZBjwxeGIIJJN8hYAGBn2AEMkaOkFgx1zF1vOe1L9OrXNXr15r7bX2o6q6T/9Q6fbprtq1H7+9atU+fbqvrx48c3N1oR83n0//+2zarqf/npr+fYBnL6zEpbd7cjOJfPPxIjW4dO/aXCJ0Dx7/ZnlAPJy2x9MW6VpE8i/cRnNMhJtPlqeX5y6kuAjdwpHI9fzhU09d/e/jx/N2CBP+QpGL0CXuouYeu+kiu+QitGTXAltcxCYuQoOOEn/+2mvLozgf3dxcvfnBB1c/efRoeaYH91Py+y30vCrxKR7c/lxJjcQZHr733vKohvsl9v0TukM0Hi1wiXrBz1/u+yF0g8Qpeb/94fJg4qc/XB4ofPOt5QGDjv3Zs7f/FrhEbZ3zFrohpQiJTBIyeR8+fGN5lOfzz3+0PFr47veXBwsB2VOiX3/x7KQ+T6GTIoejcGeBI5iSd5P7vKL1eQmdTC1S6cS7t2lCRuAjGQ2qywzKfZ/EPg+hgyKnInEgCkeFbSV0fi0vZ8RTkdMW+/SFNtKL7zz77NW/fHibIqQiMZiiMZeIxMFznsSZSEvUTArtPHflFMQG5xyxT1foQFQuiixyYlcUh4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qXqXp6UYpyoz2JfQhUgNomLPg/JH7WIDeRzfH6/J4739NWh/bz++jyy/xFG5SkSOsHeZwb6EBpbU+EuYJYKnozUIpiKWVFmJQEnkDM0SAyEyaJP5wTQu+BvAis84HMT+hAaa1BQBaqQGIg0BJUmkFNgfz8njWsWtmSwWJZGjAhNmVMaNe8Mfs45in0IDLjWiM6I0Qbn2JPnnr37t9nGEZLTOoIlEZfPXespLmBNqEXlmeX95BDe1mFn/FyZR9it0CXYDmY7WoCJi7wX3isAlBjUi09Xw5rfTpuixk3xZ43SFJmqjNTEwatfiCqvRkFJwHr7/i+XRxAnKDE5faKI2tyZIbDAocqdFtWj+auFjDmX+aNqUL/DZuczgfIQGrWkIR4ncwzFExRIkaIm+GgcSEycsMzgvoTmVEXuUPB50TrDWec9RZnC+Qguq8uszQ5UYzCtKeD/N6eXMknsjNOe+yT2LfCethqbAfpfmPO6l0Jxzk1tPJT5xZFag38yeIPdeaM6pyW2mEJyszCeWYkguQhfYWvKQtBYZmfFxEzt6T0YtF6HPlajM85uLTi9Xthj7QTMXNuLxJDNffpuknTcCEk8RGenFGckMLhH6wllxidAXzoqL0BfOiovQF86Ki9AXzoqL0BfOiovQF86Ki9AXzoirq/8H9pCavKPkRxkAAAAASUVORK5CYII=">
<script>
// NOTE: NumJs is available globally under the name 'nj'
//var size = 150;
var t1, t2, pd;
var tr=500, te=50, ti=0;
var t1_relax, t2_relax, ti_recovery;
var noise;
var $imageCanvas;
function prepareImage(image) {
var aspect = image.height / image.width;
var img = nj.images.read(image);
pd = img.slice(null, null, [0, 1, 1]);
t1 = img.slice(null, null, [1, 2, 1]);
t1.dtype = 'float32';
t1 = t1.multiply(10);
t2 = img.slice(null, null, [2, 3, 1]);
t2.dtype = 'float32';
t2 = t2.multiply(2);
var te_array = nj.ones(pd.shape).multiply(te);
//var tr_array = nj.ones(pd.shape).multiply(tr);
//t1_relax = nj.exp(tr_array.divide(t1).multiply(-1)).multiply(-1).add(1)
calcT1Relax();
t2_relax = nj.exp(te_array.divide(t2).multiply(-1));
noise = nj.random(pd.shape).multiply(30).subtract(15);
//$imageCanvas.width = W * 3; $imageCanvas.height = H * 3;
$imageCanvas.width = 500;
$imageCanvas.height = $imageCanvas.width * aspect;
calculateImage();
}
function loadImage(src) {
var $image = new Image();
$image.crossOrigin = 'Anonymous';
$image.onload = function() {
//var $image2 = document.getElementById("brainMapImage");
prepareImage($image);
};
$image.src = src;
}
function handleFileSelect(e) {
var file = e.target.files[0];
var reader = new FileReader();
reader.onload = function(e) {
loadImage(reader.result);
};
reader.readAsDataURL(file);
}
document.getElementById('file').addEventListener('change', handleFileSelect, false);
function calculateImage() {
var image;
image = t2_relax.multiply(pd).multiply(t1_relax);
noiselessMax = image.max();
if (noiseCheck.checked == true) {
image = nj.clip(image.add(noise), 0, 255);
}
if (scaleCheck.checked == true) {
image = image.multiply(255 / noiselessMax).add(2);
}
nj.images.save(image, $imageCanvas);
}
var tr_slider = document.getElementById("tr_slider");
var te_slider = document.getElementById("te_slider");
var ti_slider = document.getElementById("ti_slider");
var scaleCheck = document.getElementById("scaleCheck");
scaleCheck.addEventListener('change', calculateImage, false);
var noiseCheck = document.getElementById("noiseCheck");
noiseCheck.addEventListener('change', calculateImage, false);
function calcT1Relax() {
var tr_array = nj.ones([216, 180, 1]).multiply(tr);
if (ti > 0) {
var ti_array = nj.ones([216, 180, 1]).multiply(ti);
t1_relax = nj.abs(nj.exp(ti_array.divide(t1).multiply(-1)).multiply(-2).add(1).add(nj.exp(tr_array.divide(t1).multiply(-1)).multiply(-1)));
} else {
t1_relax = nj.exp(tr_array.divide(t1).multiply(-1)).multiply(-1).add(1);
}
}
tr_slider.oninput = function() {
tr = Number(this.value);
document.getElementById('trValue').innerHTML = this.value;
//if(te > tr) {
// te_slider.value = tr;
//}
calcT1Relax();
calculateImage();
}
te_slider.oninput = function() {
te = Number(this.value);
document.getElementById('teValue').innerHTML = this.value;
var te_array = nj.ones([216, 180, 1]).multiply(te);
t2_relax = nj.exp(te_array.divide(t2).multiply(-1));
calculateImage();
}
ti_slider.oninput = function() {
ti = Number(this.value);
document.getElementById('tiValue').innerHTML = this.value;
calcT1Relax();
calculateImage();
}
$imageCanvas = document.getElementById('imageCanvas');
prepareImage(document.getElementById('brainMapImage'))
</script>
</html>