From 7ef6b91f3726ba3c6002ee922c8ab452c3b2b585 Mon Sep 17 00:00:00 2001 From: Nikos M Date: Tue, 28 Jan 2020 09:24:17 +0200 Subject: [PATCH] v.0.9.10 * faster sparse polynomial division and multiplication using Maxheap * Abacus.Heap implementation * System of diophantine equations check additional rows for solution if over-determined system * update examples, tests --- README.md | 4 +- src/js/Abacus.js | 77 ++++- src/js/Abacus.min.js | 4 +- test/combination_subsets.txt | 48 +-- test/combinations.txt | 26 +- test/combinations_repeats.txt | 88 +++--- test/complex.txt | 2 +- test/compositions.txt | 8 +- test/conditional_permutations_algebraic.txt | 6 +- test/conditional_permutations_boolean.txt | 4 +- test/connected_permutations.txt | 10 +- test/cyclic_permutations.txt | 8 +- test/derangements.txt | 86 +++--- test/diophantine.js | 16 + test/diophantine.txt | 14 +- test/filtered.txt | 2 +- test/filtered_compositions.txt | 2 +- test/filtered_partitions.txt | 2 +- test/involutions.txt | 8 +- test/k-derangements.txt | 4 +- test/latin_squares.txt | 2 +- test/magic_squares.txt | 2 +- test/matrices.txt | 2 +- test/multiset_permutations.txt | 320 ++++++++++---------- test/number_theory.txt | 2 +- test/numbers.txt | 2 +- test/ordered_combinations.txt | 206 ++++++------- test/ordered_combinations_repeats.txt | 214 ++++++------- test/partially_fixed_permutations.txt | 4 +- test/partitions.txt | 10 +- test/permutations-bigint.txt | 4 +- test/permutations.txt | 42 +-- test/permutations_of_combinations.txt | 4 +- test/permutations_of_permutations.txt | 2 +- test/polynomials.txt | 6 +- test/primes.txt | 2 +- test/progressions.txt | 2 +- test/rationals.txt | 2 +- test/recursive_permutations.txt | 2 +- test/restricted_compositions.txt | 14 +- test/restricted_partitions.txt | 18 +- test/subsets.txt | 210 ++++++------- test/tensors.txt | 8 +- test/tuples.txt | 46 +-- 44 files changed, 818 insertions(+), 727 deletions(-) diff --git a/README.md b/README.md index 3c33604..5f847b3 100644 --- a/README.md +++ b/README.md @@ -139,7 +139,7 @@ A variety of combinatorial algorithms, number theory algorithms & statistics * [Numerical algorithms for the computation of the Smith normal form of integral matrices, C. Koukouvinos, M. Mitrouli, J. Seberry](https://ro.uow.edu.au/cgi/viewcontent.cgi?referer=https://www.google.com/&httpsredir=1&article=2173&context=infopapers) * [Fraction-free matrix factors: new forms for LU and QR factors, Wenqin ZHOU, David J. JEFFREY](http://ftp.cecm.sfu.ca/personal/pborwein/MITACS/papers/FFMatFacs08.pdf) * [Algorithms and Data Structures for Sparse Polynomial Arithmetic, M. Asadi, A. Brandt, R. H. C. Moir, M. M. Maza](https://www.researchgate.net/publication/333182217_Algorithms_and_Data_Structures_for_Sparse_Polynomial_Arithmetic) -* [High Performance Sparse Multivariate Polynomials: Fundamental Data Structures and Algorithms, Alex Brandt (MSc thesis)](https://pdfs.semanticscholar.org/0f93/5035aefc4afce591cd52c507cd7fa35eb061.pdf?_ga=2.149338422.1292196222.1579944113-1940599073.1579944113) +* [High Performance Sparse Multivariate Polynomials: Fundamental Data Structures and Algorithms, Alex Brandt (MSc thesis)](https://www.semanticscholar.org/paper/High-Performance-Sparse-Multivariate-Polynomials%3A-Brandt/016a97690ecaed04d7a60c1dbf27eb5a96de2dc1) * [Algorithms for Normal Forms for Matrices of Polynomials and Ore Polynomials, Howard Cheng (PhD thesis)](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.9.4150&rep=rep1&type=pdf) ### Example API @@ -605,7 +605,7 @@ o.dispose() * support efficient primality tests and prime sieves **[DONE PARTIALY]** * support efficient integer factorization algorithms **[DONE PARTIALY]** * support solutions of (systems of) **linear diophantine and linear congruence equations** (with one or many variables) **[DONE]** -* use sparse representation for polynomials (univariate and multivariate) instead of the, in general, inefficient dense representation **[DONE PARTIALY]** +* use sparse representation for polynomials (univariate and multivariate) instead of the, in general, inefficient dense representation (and optimise associated arithmetic operations) **[DONE]** * support (univariate) polynomial (partial) factorisation, (rational) root finding **[DONE PARTIALY]** * support multivariate polynomial, multivariate division/reduction, groebner basis computations (TODO) * implement `LLL` algorithm (TODO) diff --git a/src/js/Abacus.js b/src/js/Abacus.js index f00275a..b0d2e5b 100644 --- a/src/js/Abacus.js +++ b/src/js/Abacus.js @@ -3325,6 +3325,12 @@ function solvediophs( a, b, with_param, with_free_vars ) })); }); free_vars.symbol = symbol; + + // if over-determined system (m > k) + // check if additional rows are satisfied by solution as well + for(i=k; ib;}; var i = 0, j = 0, k = 0, n1 = a.length, n2 = b.length, c = new Array(n1+n2), res; while( i b.length ){ t=a; a=b; b=t;} // swap to achieve better performance n1 = a.length; n2 = b.length; c = new Array(n1*n2); if ( 0b[0] ? 1 : 0); + return a[0]-b[0]; }); f = array(n1, 0); while( max=heap.peek() ) { - if ( c[k].e!==max[0] && !c[k].c.equ(0) ) c[++k] = Coeff(0, max[0]); - heap.pop(); + if ( c[k].e!==max[0] ) + { + if ( !c[k].c.equ(0) ) c[++k] = Coeff(0, -1); + c[k].e = max[0]; + } c[k].c = c[k].c.add(max[1]); f[max[2]]++; - if ( f[max[2]] < n2 ) heap.push([a[max[2]].e+b[f[max[2]]].e, a[max[2]].c.mul(b[f[max[2]]].c), max[2]]); + if ( f[max[2]] < n2 ) heap.replace([a[max[2]].e+b[f[max[2]]].e, a[max[2]].c.mul(b[f[max[2]]].c), max[2]]); + else heap.pop(); } + heap.dispose(); if ( c.length > k+1 ) c.length = k+1; // truncate if needed } return c; @@ -8495,7 +8508,7 @@ Polynomial = Abacus.Polynomial = Class(INumber, { ,div: function( x, q_and_r ) { var self = this, Arithmetic = Abacus.Arithmetic, O = Arithmetic.O, I = Arithmetic.I, - q, r, d, diff, diff0; + q, r, d, diff, diff0, k, res, Q, a, na, b, nb, heap; if ( x instanceof Complex ) x = x.real; else if ( Arithmetic.isNumber(x) ) x = Rational(x); @@ -8518,9 +8531,10 @@ Polynomial = Abacus.Polynomial = Class(INumber, { }), self.symbol); return true===q_and_r ? [q, Polynomial([], self.symbol)] : q; } + // polynomial long division // TODO: make it faster - r = Polynomial(self); + /*r = Polynomial(self); diff = r.deg()-x.deg(); if ( 0 <= diff ) { @@ -8539,7 +8553,56 @@ Polynomial = Abacus.Polynomial = Class(INumber, { { q = []; } + q = Polynomial(q, self.symbol);*/ + + // sparse polynomial long division + // https://www.semanticscholar.org/paper/High-Performance-Sparse-Multivariate-Polynomials%3A-Brandt/016a97690ecaed04d7a60c1dbf27eb5a96de2dc1 + a = self.coeff; na = a.length; b = x.coeff; nb = b.length; + heap = Heap([], "max", function(a,b){return a.coeff.e-b.coeff.e;}); + q = []; r = []; k = 0; + while( (d=heap.peek()) || kd.n ) + heap.replace({coeff:Coeff(d.Q.c.mul(b[d.n].c), d.Q.e+b[d.n].e), n:d.n+1, Q:d.Q}); + else + heap.pop(); + k++; + + if ( res.c.equ(O) ) continue; // zero coefficient, skip + } + else + { + res = Coeff(d.coeff.c.neg(), d.coeff.e); + if ( nb>d.n ) + heap.replace({coeff:Coeff(d.Q.c.mul(b[d.n].c), d.Q.e+b[d.n].e), n:d.n+1, Q:d.Q}); + else + heap.pop(); + } + + if ( b[0].e<=res.e ) // if b[0] divides res + { + Q = Coeff(res.c.div(b[0].c), res.e-b[0].e); + q = addition_sparse(q, [Q]); + if ( nb>1 ) + heap.push({coeff:Coeff(Q.c.mul(b[1].c), Q.e+b[1].e), n:2, Q:Q}); + } + else + { + r = addition_sparse(r, [res]); + } + } + heap.dispose(); q = Polynomial(q, self.symbol); + r = Polynomial(r, self.symbol); + // return both quotient and remainder if requested return true===q_and_r ? [q, r] : q; } diff --git a/src/js/Abacus.min.js b/src/js/Abacus.min.js index eaa55e1..fcc1942 100644 --- a/src/js/Abacus.min.js +++ b/src/js/Abacus.min.js @@ -2,7 +2,7 @@ * * Abacus * A combinatorics and number theory library for Node.js / Browser / XPCOM Javascript, Python, Java -* @version: 0.9.9 +* @version: 0.9.10 * https://github.com/foo123/Abacus **/ -!function(t,n,e){"use strict";"undefined"!=typeof Components&&"object"==typeof Components.classes&&"object"==typeof Components.classesByID&&Components.utils&&"function"==typeof Components.utils.import?(t.$deps=t.$deps||{})&&(t.EXPORTED_SYMBOLS=[n])&&(t[n]=t.$deps[n]=e.call(t)):"object"==typeof module&&module.exports?(module.$deps=module.$deps||{})&&(module.exports=module.$deps[n]=e.call(t)):"function"==typeof define&&define.amd&&"function"==typeof require&&"function"==typeof require.specified&&require.specified(n)?define(n,["module"],function(n){return e.moduleUri=n.uri,e.call(t)}):n in t||(t[n]=e.call(t)||1)&&"function"==typeof define&&define.amd&&define(function(){return t[n]})}("undefined"!=typeof self?self:this,"Abacus",function(t){"use strict";var n,e,r,u,s,o,f,c,h,a,m,d,g,_,v,p,b,A,y,q,x={VERSION:"0.9.9"},I=Math,w="prototype",S="constructor",N=Array.prototype.slice,R=Object[w].hasOwnProperty,$=Object[w].toString,E=I.log2||function(t){return I.log(t)/I.LN2},D=/^\s+|\s+$/g,L=String.prototype.trim?function(t){return t.trim()}:function(t){return t.replace(D,"")},M=/\[(\d+)\]/g,C=/^\{(\d+(?:(?:\.\.\d+)?|(?:,\d+)*))\}$/,k=/^!\{(\d+(?:(?:\.\.\d+)?|(?:,\d+)*))\}$/,T=/^(-)?(\d+)(\.(\d+)?(\[\d+\])?)?$/,U=/^\\frac\{(-?\d+)\}\{(-?\d+)\}$/,j=function(){return Object.create(null)},P=Object.create,J=Object.keys,X=function(){var t,n,e,i,r=arguments,u=r.length;for(t=(u?r[0]:{})||{},e=1;e0?new Array(e+1).join("0")+n:n}function dt(t){var n=String(t).split("_");return n[0]+(n.length>1?"_{"+n[1]+"}":"")}function gt(t){return"function"==typeof t.toTex?t.toTex():String(t)}function _t(t,n,e,i,r,u,l){var s,o,f,c,h,a,m,d,g=n,_=null,v=e&&(st(e)||ot(e));if(v&&(null==i&&(i=0),null==r&&(r=e.length-1)),null==u&&(u=i>r?-1:1),0===u||v&&!e.length||0>=I.floor((r-i)/u)+1)return g;if(0>u?((d=(i-r)%-u)&&(_=r),a=r+=d,m=i,c=-1,f=-(-u<<4)):((d=(r-i)%u)&&(_=r),a=i,m=r-=d,c=1,f=u<<4),h=i+u*(15&I.floor((r-i)/u+1)),v){for(a=I.max(0,a),m=I.min(e.length-1,m),s=i;a<=s&&s<=m&&00?new Array(t):[];if(0<(t=i.length)&&null!=n){e=e||0;var r=n;_t(at(n)?function(t,e,i){return t[i]=n(i),t}:n===+n?function(t,n,i){return t[i]=r,r+=e,t}:function(t,e,i){return t[i]=n,t},i,i)}return i}function pt(t,n,e){return _t(function(t,n,i){return t[i]=n[e],t},t,n)}function bt(t,n,e,i,r){return null==n?t:_t(st(e)?function(t,n,i){return t[i]=e[i]-1-n,t}:function(t,n,i){return t[i]=e-1-n,t},t,n,i,r)}function At(t,n,e,i,r){if(null==n)return t;if(null==i&&(i=0),null==r&&(r=n.length-1),t!==n||i0?(n+u)%e[i]:0,u+=e[i]-t[i],t}:function(t,n,i){return t[i]=(n+u)%e,u+=e-t[i],t},t,n,i,r)}function xt(t,n,e,i,r){return null==n?t:(null==r&&(r=n.length-1),null==i&&(i=0),t!==n||0!==e?_t(function(t,n,i){return t[i+e]=n,t},t,n,0>e?i:r,0>e?r:i,0>e?1:-1):t)}function It(t,n,e,i,r,u,l,s){if(null==n)return null;null==e&&(e=1),null==i&&(i=0),null==r&&(r=0),null==u&&(u=n.length-1),null==l&&(l=r),null==s&&(s=u);var o=0,f=l>s?-1:1,c=l;return _t(function(t,n,r){return n=i+e*n,t[c]=n-o,o=n,c+=f,t},t,n,r,u)}function Ot(t,n,e,i,r,u,l,s){if(null==n)return null;null==e&&(e=1),null==i&&(i=0),null==r&&(r=0),null==u&&(u=n.length-1),null==l&&(l=r),null==s&&(s=u);var o=0,f=l>s?-1:1,c=l;return _t(function(t,n,r){return o+=n,t[c]=i+e*o,c+=f,t},t,n,r,u)}function wt(t,n,e,i,r,u,l,s,o){o=!0===o,i=-1===i?-1:1,null==r&&(r=0),null==u&&(u=n===+n?n-1:n.length-1),null==l&&(l=0),null==s&&(s=e?e.length-1:-1);var f=r>u?-1:1,c=l>s?-1:1,h=f*(u-r)+1,a=r,m=l,d=0;if(!e||!e.length)return n===+n?vt(n,r,f):n?n.slice():n;if(null==t&&(t=new Array(o?2*h:h)),n===+n){for(;0<=f*(u-a)&&0<=c*(s-m);)a===e[m]?(o&&(t[d++]=a),a+=f,m+=c):1===i&&a>e[m]||-1===i&&ae[m]||-1===i&&n[a]u?-1:1,a=l>s?-1:1,m=h*(u-r)+1+(a*(s-l)+1),d=r,g=l,_=0,v=null,p=!f;if(null==t&&(t=new Array(m)),0===t.length)return c?n:t;for(;0<=h*(u-d)&&0<=a*(s-g);){if(f&&_){if(n[d]===v){d+=h;continue}if(e[g]===v){g+=a;continue}}o?1===i&&n[d][0]e[g][0]?(t[_++]=v=n[d],d+=h):1===i&&n[d][0]>e[g][0]||-1===i&&n[d][0]e[g][1]?(t[_++]=v=n[d],p&&(t[_++]=e[g])):(t[_++]=v=e[g],p&&(t[_++]=n[d])),d+=h,g+=a):1===i&&n[d]e[g]?(t[_++]=v=n[d],d+=h):1===i&&n[d]>e[g]||-1===i&&n[d]h?u:r,_=0;_l){if(1===c){f=s-1;break}0===c&&(c=-1)}u=l}if(0===c&&(c=1),-1===f)f=e,i[0]=o,i[1]=f,i[2]=c;else{for(h=f+1,a=-1,u=r?t[h][0]:t[h],s=h+1;s<=e;s++){if(u<(l=r?t[s][0]:t[s])){if(-1===m){a=s-1;break}0===m&&(m=1)}else if(u>l){if(1===m){a=s-1;break}0===m&&(m=-1)}u=l}-1===a&&(a=e),0===m&&(m=1),i[0]=o,i[1]=f,i[2]=c,i[3]=h,i[4]=a,i[5]=m}}function Rt(t,n,e,i,r,u){null==r&&(r=0),null==u&&(u=t.length-1);var l=r>u?-1:1,s=l*(u-r)+1;if(i=!0===i,1>=s)return i?1===s?[r]:[]:t;n=-1===n?-1:1;var o,f,c,h,a,m=s,d=1,g=2,_=I.min,v=new Array(s);if(i&&(t=_t(function(t,n,e){return t[e-r]=[n,e],t},new Array(s),t,r,u,1),r=0,u=s-1),!0===e){h=r,a=-1,o=[-1,-1,0,-1,-1,0];do{Nt(t,r,u,o,i),-1===o[3]?(n!==o[2]&&r>=1;return i?pt(t,t,1):t}function $t(t,n,e,i){var r,u,l,s=t.length;if(null==e&&(e=0),null==i&&(i=s-1),null==n||0===n){for(n=0,u=t[e],r=e+1;r<=i;r++){if(u<(l=t[r])){if(-1===n)return 0;0===n&&(n=1)}else if(u>l){if(1===n)return 0;0===n&&(n=-1)}u=l}return 0===n?1:n}if(n=-1===n?-1:1,e>=i)return n;if(-1===n)for(u=t[e],r=e+1;r<=i;r++){if(u<(l=t[r]))return 0;u=l}else for(u=t[e],r=e+1;r<=i;r++){if(u>(l=t[r]))return 0;u=l}return n}function Et(t,n,e,i){var r,u=x.Math.rndInt,l=!0===n?1:0;return st(e)?1<(r=e.length)&&_t(function(t){if(l=0;o--)f=r[o],c=t[u+a],t[u+a]=t[u+f],t[u+f]=c,a++;return e&&Rt(s),s}function Lt(t,n,e,i,r,u){var l;if(u=u||function(t,n){return ti)return-1;if(-1===(e=-1===e?-1:1))for(;i>>1],n)?i=l+1:r=l;else for(;i>>1])?r=l:i=l+1;return i}function Mt(t){return!0===t?function(t,n){return t.equ(n)?0:t.lt(n)?-1:1}:t?function(n,e){return t.equ(n,e)?0:t.lt(n,e)?-1:1}:function(t,n){return t===n?0:t>=1,t=jt(t,t,e);else for(i=u.II;!u.equ(n,l);)u.equ(s,u.mod(n,i))&&(r=jt(r,t,e)),n=u.div(n,i),t=jt(t,t,e);return r}function Xt(t){var n,e,i,r,u,l,s=x.Arithmetic,o=(s.num,s.O),f=s.I;if(s.equ(t,o)||s.equ(t,f))return t;if(s.isDefault()||s.lte(t,W))return s.num(I.floor(I.sqrt(s.val(t))));for(l=s.II,n=f,e=s.div(t,l),u=n;s.lte(n,e);){if(i=s.div(s.add(n,e),l),r=s.mul(i,i),s.equ(r,t))return i;s.lt(r,t)?(n=s.add(i,f),u=i):e=s.sub(i,f)}return u}function Ft(t,n,e){var i,r,u,l,s,o,f=x.Arithmetic,c=f.num,h=f.O,a=f.J,m=f.I,d=f.II;if(f.lt(n,h)||f.equ(h,f.mod(n,d)))return null;if((f.lt(t,h)||f.gt(t,n))&&(t=f.mod(t,n)),f.equ(h,t))return f.equ(m,n)?m:h;if(f.equ(m,n)||f.equ(m,t))return m;if(null==e&&(e=rn(t,n)),!f.equ(m,e))return h;for(u=c(3),l=c(4),s=c(5),o=c(8),i=m,f.lt(t,h)&&(t=f.mul(a,t),f.equ(f.mod(n,l),u)&&(i=f.mul(a,i)));!f.equ(h,t);){for(;f.gt(t,h)&&f.equ(h,f.mod(t,d));)t=f.div(t,d),r=f.mod(n,o),(f.equ(r,u)||f.equ(r,s))&&(i=f.mul(a,i));r=t,t=n,n=r,f.equ(u,f.mod(t,l))&&f.equ(u,f.mod(n,l))&&(i=f.mul(a,i)),t=f.mod(t,n)}return f.equ(m,n)||(i=h),i}function Wt(t,n){var e=x.Arithmetic,i=(e.num,e.I),r=e.II;return Jt(t,e.div(e.sub(n,i),r),n)}function Zt(t,n){var e=x.Arithmetic,i=e.O,r=e.I,u=i;if(e.lt(n,e.II))return i;if(e.lte(t,n))return e.equ(t,n)?r:i;if(e.isDefault()||e.lte(t,W))return e.num(I.floor(I.log(e.val(t))/I.log(e.val(n))));for(;e.gte(t,n);)t=e.div(t,n),u=e.add(u,r);return u}function Gt(){var t=x.Arithmetic.num;return Gt.list||(Gt.list=[t(2),t(3),t(5),t(7),t(11),t(13),t(17),t(19),t(23),t(29),t(31),t(37),t(41),t(43),t(47),t(53),t(59),t(61),t(67),t(71),t(73),t(79),t(83),t(89),t(97),t(101),t(103),t(107),t(109),t(113),t(127),t(131),t(137),t(139),t(149),t(151),t(157),t(163),t(167),t(173),t(179),t(181),t(191),t(193),t(197),t(199),t(211),t(223),t(227),t(229),t(233),t(239),t(241),t(251),t(257),t(263),t(269),t(271),t(277),t(281),t(283),t(293),t(307),t(311),t(313),t(317),t(331),t(337),t(347),t(349),t(353),t(359),t(367),t(373),t(379),t(383),t(389),t(397),t(401),t(409),t(419),t(421),t(431),t(433),t(439),t(443),t(449),t(457),t(461),t(463),t(467),t(479),t(487),t(491),t(499),t(503),t(509),t(521),t(523),t(541),t(547),t(557),t(563),t(569),t(571),t(577),t(587),t(593),t(599),t(601),t(607),t(613),t(617),t(619),t(631),t(641),t(643),t(647),t(653),t(659),t(661),t(673),t(677),t(683),t(691),t(701),t(709),t(719),t(727),t(733),t(739),t(743),t(751),t(757),t(761),t(769),t(773),t(787),t(797),t(809),t(811),t(821),t(823),t(827),t(829),t(839),t(853),t(857),t(859),t(863),t(877),t(881),t(883),t(887),t(907),t(911),t(919),t(929),t(937),t(941),t(947),t(953),t(967),t(971),t(977),t(983),t(991),t(997),t(1009),t(1013),t(1019),t(1021),t(1031),t(1033),t(1039),t(1049),t(1051),t(1061),t(1063),t(1069),t(1087),t(1091),t(1093),t(1097),t(1103),t(1109),t(1117),t(1123),t(1129),t(1151),t(1153),t(1163),t(1171),t(1181),t(1187),t(1193),t(1201),t(1213),t(1217),t(1223),t(1229),t(1231),t(1237),t(1249),t(1259),t(1277),t(1279),t(1283),t(1289),t(1291),t(1297),t(1301),t(1303),t(1307),t(1319),t(1321),t(1327),t(1361),t(1367),t(1373),t(1381),t(1399),t(1409),t(1423),t(1427),t(1429),t(1433),t(1439),t(1447),t(1451),t(1453),t(1459),t(1471),t(1481),t(1483),t(1487),t(1489),t(1493),t(1499),t(1511),t(1523),t(1531),t(1543),t(1549),t(1553),t(1559),t(1567),t(1571),t(1579),t(1583),t(1597),t(1601),t(1607),t(1609),t(1613),t(1619),t(1621),t(1627),t(1637),t(1657),t(1663),t(1667),t(1669),t(1693),t(1697),t(1699),t(1709),t(1721),t(1723),t(1733),t(1741),t(1747),t(1753),t(1759),t(1777),t(1783),t(1787),t(1789),t(1801),t(1811),t(1823),t(1831),t(1847),t(1861),t(1867),t(1871),t(1873),t(1877),t(1879),t(1889),t(1901),t(1907),t(1913),t(1931),t(1933),t(1949),t(1951),t(1973),t(1979),t(1987),t(1993),t(1997),t(1999),t(2003),t(2011),t(2017),t(2027),t(2029),t(2039),t(2053),t(2063),t(2069),t(2081),t(2083),t(2087),t(2089),t(2099),t(2111),t(2113),t(2129),t(2131),t(2137),t(2141),t(2143),t(2153),t(2161),t(2179),t(2203),t(2207),t(2213),t(2221),t(2237),t(2239),t(2243),t(2251),t(2267),t(2269),t(2273),t(2281),t(2287),t(2293),t(2297),t(2309),t(2311),t(2333),t(2339),t(2341),t(2347),t(2351),t(2357),t(2371),t(2377),t(2381),t(2383),t(2389),t(2393),t(2399),t(2411),t(2417),t(2423),t(2437),t(2441),t(2447),t(2459),t(2467),t(2473),t(2477),t(2503),t(2521),t(2531),t(2539),t(2543),t(2549),t(2551),t(2557),t(2579),t(2591),t(2593),t(2609),t(2617),t(2621),t(2633),t(2647),t(2657),t(2659),t(2663),t(2671),t(2677),t(2683),t(2687),t(2689),t(2693),t(2699),t(2707),t(2711),t(2713),t(2719),t(2729),t(2731),t(2741),t(2749),t(2753),t(2767),t(2777),t(2789),t(2791),t(2797),t(2801),t(2803),t(2819),t(2833),t(2837),t(2843),t(2851),t(2857),t(2861),t(2879),t(2887),t(2897),t(2903),t(2909),t(2917),t(2927),t(2939),t(2953),t(2957),t(2963),t(2969),t(2971),t(2999),t(3001),t(3011),t(3019),t(3023),t(3037),t(3041),t(3049),t(3061),t(3067),t(3079),t(3083),t(3089),t(3109),t(3119),t(3121),t(3137),t(3163),t(3167),t(3169),t(3181),t(3187),t(3191),t(3203),t(3209),t(3217),t(3221),t(3229),t(3251),t(3253),t(3257),t(3259),t(3271),t(3299),t(3301),t(3307),t(3313),t(3319),t(3323),t(3329),t(3331),t(3343),t(3347),t(3359),t(3361),t(3371),t(3373),t(3389),t(3391),t(3407),t(3413),t(3433),t(3449),t(3457),t(3461),t(3463),t(3467),t(3469),t(3491),t(3499),t(3511),t(3517),t(3527),t(3529),t(3533),t(3539),t(3541),t(3547),t(3557),t(3559),t(3571),t(3581),t(3583),t(3593),t(3607),t(3613),t(3617),t(3623),t(3631),t(3637),t(3643),t(3659),t(3671),t(3673),t(3677),t(3691),t(3697),t(3701),t(3709),t(3719),t(3727),t(3733),t(3739),t(3761),t(3767),t(3769),t(3779),t(3793),t(3797),t(3803),t(3821),t(3823),t(3833),t(3847),t(3851),t(3853),t(3863),t(3877),t(3881),t(3889),t(3907),t(3911),t(3917),t(3919),t(3923),t(3929),t(3931),t(3943),t(3947),t(3967),t(3989),t(4001),t(4003),t(4007),t(4013),t(4019),t(4021),t(4027),t(4049),t(4051),t(4057),t(4073),t(4079),t(4091),t(4093),t(4099),t(4111),t(4127),t(4129),t(4133),t(4139),t(4153),t(4157),t(4159),t(4177),t(4201),t(4211),t(4217),t(4219),t(4229),t(4231),t(4241),t(4243),t(4253),t(4259),t(4261),t(4271),t(4273),t(4283),t(4289),t(4297),t(4327),t(4337),t(4339),t(4349),t(4357),t(4363),t(4373),t(4391),t(4397),t(4409),t(4421),t(4423),t(4441),t(4447),t(4451),t(4457),t(4463),t(4481),t(4483),t(4493),t(4507),t(4513),t(4517),t(4519),t(4523),t(4547),t(4549),t(4561),t(4567),t(4583),t(4591),t(4597),t(4603),t(4621),t(4637),t(4639),t(4643),t(4649),t(4651),t(4657),t(4663),t(4673),t(4679),t(4691),t(4703),t(4721),t(4723),t(4729),t(4733),t(4751),t(4759),t(4783),t(4787),t(4789),t(4793),t(4799),t(4801),t(4813),t(4817),t(4831),t(4861),t(4871),t(4877),t(4889),t(4903),t(4909),t(4919),t(4931),t(4933),t(4937),t(4943),t(4951),t(4957),t(4967),t(4969),t(4973),t(4987),t(4993),t(4999),t(5003),t(5009),t(5011),t(5021),t(5023),t(5039),t(5051),t(5059),t(5077),t(5081),t(5087),t(5099),t(5101),t(5107),t(5113),t(5119),t(5147),t(5153),t(5167),t(5171),t(5179),t(5189),t(5197),t(5209),t(5227),t(5231),t(5233),t(5237),t(5261),t(5273),t(5279),t(5281),t(5297),t(5303),t(5309),t(5323),t(5333),t(5347),t(5351),t(5381),t(5387),t(5393),t(5399),t(5407),t(5413),t(5417),t(5419),t(5431),t(5437),t(5441),t(5443),t(5449),t(5471),t(5477),t(5479),t(5483),t(5501),t(5503),t(5507),t(5519),t(5521),t(5527),t(5531),t(5557),t(5563),t(5569),t(5573),t(5581),t(5591),t(5623),t(5639),t(5641),t(5647),t(5651),t(5653),t(5657),t(5659),t(5669),t(5683),t(5689),t(5693),t(5701),t(5711),t(5717),t(5737),t(5741),t(5743),t(5749),t(5779),t(5783),t(5791),t(5801),t(5807),t(5813),t(5821),t(5827),t(5839),t(5843),t(5849),t(5851),t(5857),t(5861),t(5867),t(5869),t(5879),t(5881),t(5897),t(5903),t(5923),t(5927),t(5939),t(5953),t(5981),t(5987),t(6007),t(6011),t(6029),t(6037),t(6043),t(6047),t(6053),t(6067),t(6073),t(6079),t(6089),t(6091),t(6101),t(6113),t(6121),t(6131),t(6133),t(6143),t(6151),t(6163),t(6173),t(6197),t(6199),t(6203),t(6211),t(6217),t(6221),t(6229),t(6247),t(6257),t(6263),t(6269),t(6271),t(6277),t(6287),t(6299),t(6301),t(6311),t(6317),t(6323),t(6329),t(6337),t(6343),t(6353),t(6359),t(6361),t(6367),t(6373),t(6379),t(6389),t(6397),t(6421),t(6427),t(6449),t(6451),t(6469),t(6473),t(6481),t(6491),t(6521),t(6529),t(6547),t(6551),t(6553),t(6563),t(6569),t(6571),t(6577),t(6581),t(6599),t(6607),t(6619),t(6637),t(6653),t(6659),t(6661),t(6673),t(6679),t(6689),t(6691),t(6701),t(6703),t(6709),t(6719),t(6733),t(6737),t(6761),t(6763),t(6779),t(6781),t(6791),t(6793),t(6803),t(6823),t(6827),t(6829),t(6833),t(6841),t(6857),t(6863),t(6869),t(6871),t(6883),t(6899),t(6907),t(6911),t(6917),t(6947),t(6949),t(6959),t(6961),t(6967),t(6971),t(6977),t(6983),t(6991),t(6997),t(7001),t(7013),t(7019),t(7027),t(7039),t(7043),t(7057),t(7069),t(7079),t(7103),t(7109),t(7121),t(7127),t(7129),t(7151),t(7159),t(7177),t(7187),t(7193),t(7207),t(7211),t(7213),t(7219),t(7229),t(7237),t(7243),t(7247),t(7253),t(7283),t(7297),t(7307),t(7309),t(7321),t(7331),t(7333),t(7349),t(7351),t(7369),t(7393),t(7411),t(7417),t(7433),t(7451),t(7457),t(7459),t(7477),t(7481),t(7487),t(7489),t(7499),t(7507),t(7517),t(7523),t(7529),t(7537),t(7541),t(7547),t(7549),t(7559),t(7561),t(7573),t(7577),t(7583),t(7589),t(7591),t(7603),t(7607),t(7621),t(7639),t(7643),t(7649),t(7669),t(7673),t(7681),t(7687),t(7691),t(7699),t(7703),t(7717),t(7723),t(7727),t(7741),t(7753),t(7757),t(7759),t(7789),t(7793),t(7817),t(7823),t(7829),t(7841),t(7853),t(7867),t(7873),t(7877),t(7879),t(7883),t(7901),t(7907),t(7919),t(7927),t(7933),t(7937),t(7949),t(7951),t(7963),t(7993),t(8009),t(8011),t(8017),t(8039),t(8053),t(8059),t(8069),t(8081),t(8087),t(8089),t(8093),t(8101),t(8111),t(8117),t(8123),t(8147),t(8161),t(8167),t(8171),t(8179),t(8191),t(8209),t(8219),t(8221),t(8231),t(8233),t(8237),t(8243),t(8263),t(8269),t(8273),t(8287),t(8291),t(8293),t(8297),t(8311),t(8317),t(8329),t(8353),t(8363),t(8369),t(8377),t(8387),t(8389),t(8419),t(8423),t(8429),t(8431),t(8443),t(8447),t(8461),t(8467),t(8501),t(8513),t(8521),t(8527),t(8537),t(8539),t(8543),t(8563),t(8573),t(8581),t(8597),t(8599),t(8609),t(8623),t(8627),t(8629),t(8641),t(8647),t(8663),t(8669),t(8677),t(8681),t(8689),t(8693),t(8699),t(8707),t(8713),t(8719),t(8731),t(8737),t(8741),t(8747),t(8753),t(8761),t(8779),t(8783),t(8803),t(8807),t(8819),t(8821),t(8831),t(8837),t(8839),t(8849),t(8861),t(8863),t(8867),t(8887),t(8893),t(8923),t(8929),t(8933),t(8941),t(8951),t(8963),t(8969),t(8971),t(8999),t(9001),t(9007),t(9011),t(9013),t(9029),t(9041),t(9043),t(9049),t(9059),t(9067),t(9091),t(9103),t(9109),t(9127),t(9133),t(9137),t(9151),t(9157),t(9161),t(9173),t(9181),t(9187),t(9199),t(9203),t(9209),t(9221),t(9227),t(9239),t(9241),t(9257),t(9277),t(9281),t(9283),t(9293),t(9311),t(9319),t(9323),t(9337),t(9341),t(9343),t(9349),t(9371),t(9377),t(9391),t(9397),t(9403),t(9413),t(9419),t(9421),t(9431),t(9433),t(9437),t(9439),t(9461),t(9463),t(9467),t(9473),t(9479),t(9491),t(9497),t(9511),t(9521),t(9533),t(9539),t(9547),t(9551),t(9587),t(9601),t(9613),t(9619),t(9623),t(9629),t(9631),t(9643),t(9649),t(9661),t(9677),t(9679),t(9689),t(9697),t(9719),t(9721),t(9733),t(9739),t(9743),t(9749),t(9767),t(9769),t(9781),t(9787),t(9791),t(9803),t(9811),t(9817),t(9829),t(9833),t(9839),t(9851),t(9857),t(9859),t(9871),t(9883),t(9887),t(9901),t(9907),t(9923),t(9929),t(9931),t(9941),t(9949),t(9967),t(9973),t(10007),t(10009),t(10037),t(10039),t(10061),t(10067),t(10069),t(10079),t(10091),t(10093),t(10099),t(10103),t(10111),t(10133),t(10139),t(10141),t(10151),t(10159),t(10163),t(10169),t(10177),t(10181),t(10193),t(10211),t(10223),t(10243),t(10247),t(10253),t(10259),t(10267),t(10271),t(10273),t(10289),t(10301),t(10303),t(10313),t(10321),t(10331),t(10333),t(10337),t(10343),t(10357),t(10369),t(10391),t(10399),t(10427),t(10429),t(10433),t(10453),t(10457),t(10459),t(10463),t(10477),t(10487),t(10499),t(10501),t(10513),t(10529),t(10531),t(10559),t(10567),t(10589),t(10597),t(10601),t(10607),t(10613),t(10627),t(10631),t(10639),t(10651),t(10657),t(10663),t(10667),t(10687),t(10691),t(10709),t(10711),t(10723),t(10729),t(10733),t(10739),t(10753),t(10771),t(10781),t(10789),t(10799),t(10831),t(10837),t(10847),t(10853),t(10859),t(10861),t(10867),t(10883),t(10889),t(10891),t(10903),t(10909),t(10937),t(10939),t(10949),t(10957),t(10973),t(10979),t(10987),t(10993),t(11003),t(11027),t(11047),t(11057),t(11059),t(11069),t(11071),t(11083),t(11087),t(11093),t(11113),t(11117),t(11119),t(11131),t(11149),t(11159),t(11161),t(11171),t(11173),t(11177),t(11197),t(11213),t(11239),t(11243),t(11251),t(11257),t(11261),t(11273),t(11279),t(11287),t(11299),t(11311),t(11317),t(11321),t(11329),t(11351),t(11353),t(11369),t(11383),t(11393),t(11399),t(11411),t(11423),t(11437),t(11443),t(11447),t(11467),t(11471),t(11483),t(11489),t(11491),t(11497),t(11503),t(11519),t(11527),t(11549),t(11551),t(11579),t(11587),t(11593),t(11597),t(11617),t(11621),t(11633),t(11657),t(11677),t(11681),t(11689),t(11699),t(11701),t(11717),t(11719),t(11731),t(11743),t(11777),t(11779),t(11783),t(11789),t(11801),t(11807),t(11813),t(11821),t(11827),t(11831),t(11833),t(11839),t(11863),t(11867),t(11887),t(11897),t(11903),t(11909),t(11923),t(11927),t(11933),t(11939),t(11941),t(11953),t(11959),t(11969),t(11971),t(11981),t(11987),t(12007),t(12011),t(12037),t(12041),t(12043),t(12049),t(12071),t(12073),t(12097),t(12101),t(12107),t(12109),t(12113),t(12119),t(12143),t(12149),t(12157),t(12161),t(12163),t(12197),t(12203),t(12211),t(12227),t(12239),t(12241),t(12251),t(12253),t(12263),t(12269),t(12277),t(12281),t(12289),t(12301),t(12323),t(12329),t(12343),t(12347),t(12373),t(12377),t(12379),t(12391),t(12401),t(12409),t(12413),t(12421),t(12433),t(12437),t(12451),t(12457),t(12473),t(12479),t(12487),t(12491),t(12497),t(12503),t(12511),t(12517),t(12527),t(12539),t(12541),t(12547),t(12553),t(12569),t(12577),t(12583),t(12589),t(12601),t(12611),t(12613),t(12619),t(12637),t(12641),t(12647),t(12653),t(12659),t(12671),t(12689),t(12697),t(12703),t(12713),t(12721),t(12739),t(12743),t(12757),t(12763),t(12781),t(12791),t(12799),t(12809),t(12821),t(12823),t(12829),t(12841),t(12853),t(12889),t(12893),t(12899),t(12907),t(12911),t(12917),t(12919),t(12923),t(12941),t(12953),t(12959),t(12967),t(12973),t(12979),t(12983),t(13001),t(13003),t(13007),t(13009),t(13033),t(13037),t(13043),t(13049),t(13063),t(13093),t(13099),t(13103),t(13109),t(13121),t(13127),t(13147),t(13151),t(13159),t(13163),t(13171),t(13177),t(13183),t(13187),t(13217),t(13219),t(13229),t(13241),t(13249),t(13259),t(13267),t(13291),t(13297),t(13309),t(13313),t(13327),t(13331),t(13337),t(13339),t(13367),t(13381),t(13397),t(13399),t(13411),t(13417),t(13421),t(13441),t(13451),t(13457),t(13463),t(13469),t(13477),t(13487),t(13499),t(13513),t(13523),t(13537),t(13553),t(13567),t(13577),t(13591),t(13597),t(13613),t(13619),t(13627),t(13633),t(13649),t(13669),t(13679),t(13681),t(13687),t(13691),t(13693),t(13697),t(13709),t(13711),t(13721),t(13723),t(13729),t(13751),t(13757),t(13759),t(13763),t(13781),t(13789),t(13799),t(13807),t(13829),t(13831),t(13841),t(13859),t(13873),t(13877),t(13879),t(13883),t(13901),t(13903),t(13907),t(13913),t(13921),t(13931),t(13933),t(13963),t(13967),t(13997),t(13999),t(14009),t(14011),t(14029),t(14033),t(14051),t(14057),t(14071),t(14081),t(14083),t(14087),t(14107),t(14143),t(14149),t(14153),t(14159),t(14173),t(14177),t(14197),t(14207),t(14221),t(14243),t(14249),t(14251),t(14281),t(14293),t(14303),t(14321),t(14323),t(14327),t(14341),t(14347),t(14369),t(14387),t(14389),t(14401),t(14407),t(14411),t(14419),t(14423),t(14431),t(14437),t(14447),t(14449),t(14461),t(14479),t(14489),t(14503),t(14519),t(14533),t(14537),t(14543),t(14549),t(14551),t(14557),t(14561),t(14563),t(14591),t(14593),t(14621),t(14627),t(14629),t(14633),t(14639),t(14653),t(14657),t(14669),t(14683),t(14699),t(14713),t(14717),t(14723),t(14731),t(14737),t(14741),t(14747),t(14753),t(14759),t(14767),t(14771),t(14779),t(14783),t(14797),t(14813),t(14821),t(14827),t(14831),t(14843),t(14851),t(14867),t(14869),t(14879),t(14887),t(14891),t(14897),t(14923),t(14929),t(14939),t(14947),t(14951),t(14957),t(14969),t(14983),t(15013),t(15017),t(15031),t(15053),t(15061),t(15073),t(15077),t(15083),t(15091),t(15101),t(15107),t(15121),t(15131),t(15137),t(15139),t(15149),t(15161),t(15173),t(15187),t(15193),t(15199),t(15217),t(15227),t(15233),t(15241),t(15259),t(15263),t(15269),t(15271),t(15277),t(15287),t(15289),t(15299),t(15307),t(15313),t(15319),t(15329),t(15331),t(15349),t(15359),t(15361),t(15373),t(15377),t(15383),t(15391),t(15401),t(15413),t(15427),t(15439),t(15443),t(15451),t(15461),t(15467),t(15473),t(15493),t(15497),t(15511),t(15527),t(15541),t(15551),t(15559),t(15569),t(15581),t(15583),t(15601),t(15607),t(15619),t(15629),t(15641),t(15643),t(15647),t(15649),t(15661),t(15667),t(15671),t(15679),t(15683),t(15727),t(15731),t(15733),t(15737),t(15739),t(15749),t(15761),t(15767),t(15773),t(15787),t(15791),t(15797),t(15803),t(15809),t(15817),t(15823),t(15859),t(15877),t(15881),t(15887),t(15889),t(15901),t(15907),t(15913),t(15919),t(15923),t(15937),t(15959),t(15971),t(15973),t(15991),t(16001),t(16007),t(16033),t(16057),t(16061),t(16063),t(16067),t(16069),t(16073),t(16087),t(16091),t(16097),t(16103),t(16111),t(16127),t(16139),t(16141),t(16183),t(16187),t(16189),t(16193),t(16217),t(16223),t(16229),t(16231),t(16249),t(16253),t(16267),t(16273),t(16301),t(16319),t(16333),t(16339),t(16349),t(16361),t(16363),t(16369),t(16381),t(16411),t(16417),t(16421),t(16427),t(16433),t(16447),t(16451),t(16453),t(16477),t(16481),t(16487),t(16493),t(16519),t(16529),t(16547),t(16553),t(16561),t(16567),t(16573),t(16603),t(16607),t(16619),t(16631),t(16633),t(16649),t(16651),t(16657),t(16661),t(16673),t(16691),t(16693),t(16699),t(16703),t(16729),t(16741),t(16747),t(16759),t(16763),t(16787),t(16811),t(16823),t(16829),t(16831),t(16843),t(16871),t(16879),t(16883),t(16889),t(16901),t(16903),t(16921),t(16927),t(16931),t(16937),t(16943),t(16963),t(16979),t(16981),t(16987),t(16993),t(17011),t(17021),t(17027),t(17029),t(17033),t(17041),t(17047),t(17053),t(17077),t(17093),t(17099),t(17107),t(17117),t(17123),t(17137),t(17159),t(17167),t(17183),t(17189),t(17191),t(17203),t(17207),t(17209),t(17231),t(17239),t(17257),t(17291),t(17293),t(17299),t(17317),t(17321),t(17327),t(17333),t(17341),t(17351),t(17359),t(17377),t(17383),t(17387),t(17389)]),Gt.list}function zt(t,n,e){var i,r,u,l,s,o,f,c,h=x.Arithmetic,a=(h.num,h.O,h.I),m=h.II;for(i=h.sub(t,a),r=h.sub(i,a),l=i,u=0;s=h.div(l,m),o=h.mod(l,m),!h.equ(o,a);)u+=1,l=s;function d(n){var e,r;if(e=Jt(n,l,t),h.equ(e,a)||h.equ(e,i))return!1;for(r=1;ri?"0":n.slice(0,i+1)]:u}(c.add(t,a),null,!0))[1],l=l[0],s=h,i=function(t,n,e,i,r){var u,l,s,o,f,c,h,a,m=x.Arithmetic,d=m.O,g=m.J,_=m.I,v=m.II;if(u=m.sub(m.mul(n,n),m.mul(e,4)),m.equ(d,u))return null;if("0"===(r=r||m.digits(i,2)))return[d,v,e];if(l=_,s=n,c=e,h=r.length,m.equ(_,e))for(a=1;ar);)if(f+=1,s=u(s),l=u(u(l)),c=rn(m.sub(s,l),t),!m.equ(g,c)){if(m.equ(t,c))break;return c}l=m.rnd(d,h),e=m.rnd(g,a),u=null}return null}function tn(t){var n,e=x.Arithmetic;return e.digits(t).length<=20?function(t,n){var e,i,r,u,l,o,f,c,h,a,m,d=x.Arithmetic,g=d.num,_=d.O,v=d.I,p=d.II,b=Gt();for(b.length||(b=[p,g(3)]),e=null,u=null,l=0,o=t,f=0,c=b.length;f=c)for(h=d.add(h,p),a=d.mul(h,h);d.lte(a,t)&&(null==n||d.lte(a,n));){for(r=_;d.equ(_,d.mod(t,h));)r=d.add(v,r),t=d.div(t,h);d.lt(_,r)&&((i=new s([h,r])).l=u,u&&(u.r=i),u=i,l++,e||(e=u)),h=d.add(h,p),a=d.mul(h,h)}return null==n&&d.gt(t,v)&&((i=new s([t,v])).l=u,u&&(u.r=i),u=i,l++,e||(e=u)),m=vt(l,function(){var t=e,n=t.v;return e=e.r,t.dispose(),e&&(e.l=null),n}),null==n?m:[m,t]}(t):(null==(n=Qt(t,e.II,e.I,5,100,null))&&(n=function(t,n,e,i){var r,u,l,s,o,f,c,h=x.Arithmetic,a=h.num,m=(h.O,h.I),d=h.II,g=Gt(),_=g.length;if(null==i&&(i=0),null==e&&(e=d),null==n&&(n=a(10)),i=+i,h.lt(t,4)||h.lt(n,3))return null;for(f=h.sub(t,d),r=0;r<=i;r++){for(u=e,c=0;c<_&&(l=g[c],!h.gt(l,n));c++)s=Zt(n,l),u=Jt(u,h.pow(l,s),t);if(o=rn(h.sub(u,m),t),h.gt(o,m)&&h.lt(o,t))return o;e=h.rnd(d,f)}return null}(t,e.num(10),e.II,5)),null==n?[[t,e.I]]:function(t,n){var e,i=x.Arithmetic,r=0,u=0,l=t.length,s=n.length,o=0;for(e=new Array(l+s);ro&&(e.length=o),e}(tn(n),tn(e.div(t,n))))}function nn(t,n){return t===n}function en(t,n,e){var i,r,u,l;for(e=e||nn,r=t(i=t(n));!e(i,r);)i=t(i),r=t(t(r));for(u=0,i=n;!e(i,r);)i=t(i),r=t(r),u++;for(l=1,r=t(i);!e(i,r);)r=t(r),l++;return[l,u]}function rn(){var t,n,e,i,r=arguments.length&&(st(arguments[0])||ot(arguments[0]))?arguments[0]:arguments,u=r.length,l=x.Arithmetic,s=(l.num,l.O),o=l.I;if(0===u)return s;for(i=0;i=i)return 1===i?e[0]:u;if(r.equ(u,e[0])||r.equ(u,e[1]))return u;for(n=un(e[0],e[1]),t=2;te)return null;if(s)return u=a,c.equ(a,t)||(o=t),a;if(o)return n=o,o=null,n;for(u=c.add(u,a);c.lte(u,r);){if(c.equ(h,c.mod(t,u)))return l=c.div(t,u),c.equ(l,u)||(o=l),u;u=c.add(u,a)}return null}));for(r=Xt(t),u=a;c.lte(u,r);u=c.add(u,a))c.equ(h,c.mod(t,u))&&(l=c.div(t,u),c.equ(l,u)?(i=new s(u,g,null),_++,g&&(g.r=i),g=i):(i=new s(u,g,null),_++,g&&(g.r=i),g=i,i=new s(l,null,d),v++,d&&(d.l=i),d=i),m||(m=g));return g&&(g.r=d,d&&(d.l=g)),g=null,d=null,vt(_+v,function(){var t=m,n=t.v;return m=t.r,t.dispose(),m&&(m.l=null),n})}function hn(t,n,e){var i,r=(e=e||x.DefaultArithmetic).O,u=I.min(t.length,n.length);for(i=0;i0;s--)r=rn(_[0],t[s]),_[0]=q.div(_[0],r),t[s]=q.div(t[s],r),_.unshift(r);for(_.push(t[i-1]),A=[],y=vt(i,function(t){return S+"_"+(t+1)}),n=d(n),s=0,h=_.length;sn.length&&(n=n.concat(vt(r-n.length,function(t){return A}))),s=(l=t.t().concat(v.I(u)).ref(!0,[u,r]))[0],o=l[1].length,c=s.slice(0,r,-1,-1).t(),f=s.slice(0,0,u-1,r-1).t(),_=new Array(u),p=new Array(u-o),h=0;h=o)p[h-o]=I+"_"+(h-o+1),_[h]=d(m(p[h-o],y));else{for(g=A,a=0;ai)return r.I;if(e===i)return n[e];var u=e+i>>>1;return r.mul(t(n,e,u),t(n,u+1,i))}(h,0,h.length-1)},e=function t(e,i){if(l.lt(e,f))return o;var r=t(l.div(e,f),i);return l.mul(l.mul(r,r),n(e,i))},l.lt(t,f)?o:(i=l.sub(t,l.digits(t,2).split("").reduce(function(t,n){return l.add(t,"1"===n?o:s)},s)),r=(u=q()).get(function(n){return l.lte(n,t)}),u.dispose(),l.mul(e(t,r),vn(i)))}function An(t,n){var e,i=x.Arithmetic,r=i.O,u=i.I,l=i.J,s=i.num,o=i.add,f=(i.sub,i.div),c=i.mul,h=s(t),a=r,m=x.Options.MAXMEM;if(null==n){if(12>=t)return 0>t?r:s([1,1,2,6,24,120,720,5040,40320,362880,3628800,39916800,479001600][t]);if(600<=t)return bn(h);e=String(t),null==An.mem1[e]?(a=c(An(t-1),t),i.lt(h,m)&&(An.mem1[e]=a)):a=An.mem1[e]}else if(!1===n){if(12>=t)return 2>t?r:s([1,2,9,44,265,1854,14833,133496,1334961,14684570,176214841][t-2]);e="!"+String(t),null==An.mem2[e]?(a=o(1&t?l:u,c(An(t-1,!1),t)),i.lt(h,m)&&(An.mem2[e]=a)):a=An.mem2[e]}else if(!0===n){if(18>=t)return 0>t?r:s([1,1,2,4,10,26,76,232,764,2620,9496,35696,140152,568504,2390480,10349536,46206736,211799312,997313824][t]);e="I"+String(t),null==An.mem2[e]?(a=o(An(t-1,!0),c(An(t-2,!0),t-1)),i.lt(h,m)&&(An.mem2[e]=a)):a=An.mem2[e]}else if(st(n)){if(!n.length)return 0>t?r:An(t);if(0>t)return r;e=String(t)+"@"+Rt(n.slice(),1,!0).join(","),null==An.mem3[e]?(a=f(An(t),_t(function(t,n){return c(t,An(n))},An(n[n.length-1]),n,n.length-2,0)),i.lt(h,m)&&(An.mem3[e]=a)):a=An.mem3[e]}else if(n===+n)if(0>n){if(-n>=t)return-n===t?An(t):r;e=String(t)+"@"+String(n),null==An.mem3[e]?(a=_t(c,u,null,t+n+1,t),i.lt(h,m)&&(An.mem3[e]=a)):a=An.mem3[e]}else{if(0>n||1>t||n>t)return r;if(n<<1>t&&(n=t-n),0===n||1===t)return u;if(1===n)return h;e=String(t)+"@"+String(n),null==An.mem3[e]?(a=i.isDefault()?I.round(_t(function(n,e){return n*(1+t/e)},1+(t-=n),null,2,n)):o(An(t-1,n-1),An(t-1,n)),i.lt(h,m)&&(An.mem3[e]=a)):a=An.mem3[e]}return a}function yn(t,n,e){var i,r=x.Arithmetic,u=r.O,l=r.I,s=r.add,o=r.mul,f=r.num(t),c=u,h=x.Options.MAXMEM;if(0>t||0>n)return u;if(2===e){if(t===n||1===n&&0>t)return l;if(0===t||0===n)return u;i=String(t)+","+String(n),null==yn.mem2[i]?(c=s(yn(t-1,n-1,2),o(yn(t-1,n,2),n)),r.lt(f,h)&&(yn.mem2[i]=c)):c=yn.mem2[i]}else if(-1===e){if(n>t||0===n&&0>t)return u;if(t===n)return l;i=String(t)+","+String(n)+"-",null==yn.mem1[i]?(c=s(yn(t-1,n-1,-1),o(yn(t-1,n,-1),1-t)),r.lt(f,h)&&(yn.mem1[i]=c)):c=yn.mem1[i]}else{if(n>t||0===n&&0>t)return u;if(t===n)return l;if(1===n)return An(t-1);c=t-n&1?r.neg(yn(t,n,-1)):yn(t,n,-1)}return c}function qn(t,n,e,i){var r,u,l=x.Arithmetic,s=l.add,o=l.I,f=l.O;return 0>t||0>=n||e>i||e+n>t+1||n*it||n&&e&&(n+e>t+1||n*et||n&&n>t?c:(e&&!n&&(l=0,s=1,o=e,f=e,n=e,e=null),i=String(t)+"|"+String(n)+"|"+String(e),null==xn.mem[i]&&(xn.mem[i]=_t(function(n,e){return _t(function(n,i){return u(n,qn(t,e,1,i))},n,null,s,l||t-e+1,1)},c,null,o,f,1)),xn.mem[i])}function In(t,n,e,i){var r,u=x.Arithmetic,l=u.add,s=u.O,o=u.I;return 0>t||0>=n||e>i||e*n>t||n*it||n&&e&&(n+e>t+1||n*et||n&&n>t?f:(i=String(t)+"|"+String(n)+"|"+String(e),null==On.mem[i]&&(On.mem[i]=n&&e?n*e===t?l:o(In(t-e,n-1,1,e),n):n?In(t,n,1,t):e?t===e?l:_t(function(n,i){return s(n,In(t,i,1,e))},f,null,I.ceil(t/e),t-e+1,1):1<=t?vn(t-1):l),On.mem[i])}function wn(t){var n,e=x.Arithmetic,i=e.O,r=e.num,u=e.div,l=e.mul,s=i,o=x.Options.MAXMEM;return 17>=t?0>t?i:r([1,1,2,5,14,42,132,429,1430,4862,16796,58786,208012,742900,2674440,9694845,35357670,129644790][t]):(n=String(t),null==wn.mem[n]?e.lt(r(t),o)?(s=u(l(wn(t-1),4*t-2),t+1),wn.mem[n]=s):s=u(An(2*t,t),t+1):s=wn.mem[n],s)}function Sn(t){var n,e=x.Arithmetic,i=e.O,r=e.num,u=e.add,l=e.mul,s=i,o=x.Options.MAXMEM;return 14>=t?0>t?i:r([1,1,2,5,15,52,203,877,4140,21147,115975,678570,4213597,27644437,190899322][t]):(n=String(t),null==Sn.mem[n]?(s=_t(function(n,e){return u(n,l(An(t-1,e),Sn(e)))},i,null,0,t-1,1),e.lt(r(t),o)&&(Sn.mem[n]=s)):s=Sn.mem[n],s)}function Nn(t){var n,e,i,r,u=x.Arithmetic,l=u.O,s=u.num,o=l,f=x.Options.MAXMEM;return 36>=t?0>t?l:s([0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765,10946,17711,28657,46368,75025,121393,196418,317811,514229,832040,1346269,2178309,3524578,5702887,9227465,14930352][t]):(r=String(t),null==Nn.mem[r]?(e=Nn((n=t>>>1)+1),i=Nn(n),o=1&t?u.add(u.mul(e,e),u.mul(i,i)):u.mul(i,u.sub(u.mul(e,u.II),i)),u.lt(s(t),f)&&(Nn.mem[r]=o)):o=Nn.mem[r],o)}function Rn(){var t,n,e,i,r,u,l,s,o,f,c,h=arguments,a=h.length;if(!a)return[];if(!0===h[0]){for(f=h[1].length,t=2;t=0;n--)if(r=e%(i=h[n].length),e=~~(e/i),st(l=h[n][r])||ot(l))for(u=l.length-1;u>=0;u--)s[a-++o]=l[u];else s[a-++o]=l;c[t]=s}}return c}function $n(t,n,e){var i,r,u,l,s,o,f,c,h,a,m,d,g,_,v,p,b,A,y,q,x,I,O,w,S,N=t.length,R=null,$=null;if(!N)return[];for(at(e)?($=e,e=!0):e=!1,Z!==n&&G!==n&&z!==n&&B!==n&&V!==n&&H!==n&&(n=!1),A=new Array(N),y=[],q=0,b=[],r=1,i=0;i=r)return[];if(!b.length)return[];for(v=new Array(r),_=0,d=N-1,x=b.length-1,i=0;i=0;u--)o=l%(s=t[p=b[u]].length),l=~~(l/s),a[p]=t[p][o];for(u=0,q=y.length;u=0;m--){if(null==(c=a[m])||isNaN(c)||Z===n&&h!==c||G===n&&1===R[c]||z===n&&c>=h||B===n&&c<=h||V===n&&ch||e&&!$(a,m,d)){I=!0;break}G===n&&(R[c]=1),h=c}I||(v[_++]=a)}return v.length>_&&(v.length=_),v}function En(t,n,e,i){i=i||function(t,n){return t>n};for(var r,u=0,l=0,s=0,o=t.length,f=n.length,c=new Array(o+f);us&&(c.length=s),c}function Dn(t,n,e){if(null==n||!n.length||1>=n.length)return 1===n.length?vt(t-1,function(t){return t=n)return[];var e,i=vt(n,0,0),r=t.length;for(n-=1,e=0;e=(i=_t(kt,0,n))?r=n.slice():(0<(i-=_t(kt,0,r=kn(Dn(i-1,Cn(n,u-1,e)))))&&r.push(i),0>e&&At(r,r));else{var l,s,o,f,c,h=1,a=0,m=0,d="push";if(0>e&&(h=-h,a=u-1-a,d="unshift"),st(n[a]))for(r=[[(c=n[a])[1],c[0]]],l=0,o=1,f=h+a;oe?0:l,(c=n[f])[1]===r[s][0]?r[s][1]+=c[0]:(r[d]([c[1],c[0]]),l++);else for(r=vt(i=n[a],1,0),0>e&&(m=i-1-m),o=1,f=h+a;o0;)r[s]++,c--,l++,s+=h}return r}function Un(t,n,e){var i=t?t.length:0,r=1,u=0,l=0,s=l=s&&(u+=r,s=++l>>1<<1]),l[i]+=1,i>>>=1;return l[i]+=1,t[e]=n,t},t||new Array(i),n)}function Jn(t,n,e){var i,r,u,l=n.length,s=I.ceil(E(e||l)),o=1<=f[i<<=1]&&(n-=f[i],i++);return f[i]=0,t[e]=i-o,t},t||new Array(l),n)}function Xn(t,n,e){var i,r=t.length,u=null==n;if(r>1)for(u&&(n=new Array(r-1),e=0),i=r-1;i>=1;i--)n[e++]=[t[0],t[i]];else u&&(n=[]);return u?n:e}function Fn(t,n){var e,i,r,u,l=t.length,s=new Array(l),o=!0===n?1:0,f=new Array(l),c=0,h=0;for(e=0;eo&&(r.length=u,s[h++]=r),r=new Array(l),u=0;co&&(r.length=u,s[h++]=r),hr?function(e,i){return e[i]=i=n&&(n=Q)}else n=rt&t?rt&t:Q;return et&n&&it&n&&(n&=~it),nt&n&&(tt|Q)&n&&(n&=~(tt|Q)),tt&n&&Q&n&&(n&=~Q),et&n&&(n&=~K),n}function Bn(t,n,e,i,r){if(null==t)return null;var u,l=null;if("ordered"===r||"variation"===r)for(l={},u=0;u=n},lte:function(t,n){return t<=n},gt:function(t,n){return t>n},lt:function(t,n){return t=n&&t<=e:t>n&&te?e:t},wrap:function(t,n,e){return te?n:t},wrapR:function(t,n){return t<0?t+n:t},add:kt,sub:function(t,n){return t-n},mul:function(t,n){return t*n},div:function(t,n){return I.floor(t/n)},mod:function(t,n){return t%n},pow:I.pow,shl:function(t,n){return t<>n},bor:function(t,n){return t|n},band:function(t,n){return t&n},xor:function(t,n){return t^n},abs:I.abs,min:I.min,max:I.max,rnd:Gn},x.Arithmetic=X({},r,{isDefault:function(){return 0===this.O&&this.add===kt},neg:function(t){return x.Arithmetic.mul(x.Arithmetic.J,t)},abs:function(t){return x.Arithmetic.gt(x.Arithmetic.O,t)?x.Arithmetic.neg(t):t},min:function(t,n){return x.Arithmetic.lt(t,n)?t:n},max:function(t,n){return x.Arithmetic.gt(t,n)?t:n}}),x.Math={rnd:I.random,rndInt:Gn,factorial:An,stirling:yn,partitions:xn,compositions:On,bell:Sn,catalan:wn,fibonacci:Nn,polygonal:function(t,n){var e=x.Arithmetic,i=(e.O,e.I,e.II),r=e.num;return 3>(n=+n)?null:(t=r(t),e.div(e.mul(t,e.sub(e.mul(t,n-2),n-4)),i))},sum:Tt,product:Ut,pow2:vn,exp:pn,powsq:function(t,n){var e=x.Arithmetic;return function(t,n){var e,i,r=x.Arithmetic,u=r.O,l=r.I;if(r.num,r.gt(u,n))return null;if(r.equ(u,n))return l;if(r.equ(l,n))return t;if(i=l,r.isDefault()||r.lte(n,W))for(n=r.val(n);0!==n;)1&n&&(i=r.mul(i,t)),n>>=1,t=r.mul(t,t);else for(e=r.II;!r.equ(u,n);)r.equ(l,r.mod(n,e))&&(i=r.mul(i,t)),n=r.div(n,e),t=r.mul(t,t);return i}(e.num(t),e.num(n))},addm:function(t,n,e){var i=x.Arithmetic;return function(t,n,e){var i=x.Arithmetic;return i.num,i.equ(e,i.I)?i.O:i.mod(i.add(t,n),e)}(i.num(t),i.num(n),i.num(e))},negm:function(t,n){var e=x.Arithmetic;return function(t,n){var e=x.Arithmetic;return e.equ(n,e.I)?e.O:e.mod(e.sub(n,t),n)}(e.num(t),e.num(n))},mulm:function(t,n,e){var i=x.Arithmetic;return jt(i.num(t),i.num(n),i.num(e))},invm:function(t,n){var e=x.Arithmetic;return Pt(e.num(t),e.num(n))},powm:function(t,n,e){var i=x.Arithmetic;return Jt(i.num(t),i.num(n),i.num(e))},isqrt:function(t){return Xt(x.Arithmetic.num(t))},ikthroot:function(t,n){return function(t,n){var e,i,r,u,l=x.Arithmetic,s=(l.num,l.I);if(1>(n=+n))return null;if(1===n||l.equ(t,l.O)||l.equ(t,s))return t;for(u=n-1,e=t,i=l.add(t,s);l.lt(e,i);)i=e,r=l.add(l.mul(i,u),l.div(t,l.pow(i,u))),e=l.div(r,n);return i}(x.Arithmetic.num(t),+n)},isqrtp:function(t,n){var e=x.Arithmetic;return function(t,n){var e,i,r,u,l,s,o,f,c,h,a,m,d,g=x.Arithmetic,_=(g.num,g.O),v=g.I;if(!g.equ(v,Wt(t,n)))return null;for(e=g.II,r=i=g.sub(n,v),u=0;g.equ(_,g.mod(r,e));)r=g.div(r,e),u+=1;if(1===u)return Jt(t,g.div(g.add(n,v),4),n);for(l=_;g.lt(l,n)&&!g.equ(i,Wt(l,n));l=g.add(l,v));for(s=Jt(l,r,n),o=Jt(t,g.div(g.add(r,v),e),n),c=Jt(t,r,n),h=u,a=_;!g.equ(_,g.mod(g.sub(c,v),n));){for(a=jt(c,c,n),d=1;d=i)return 1===i?e[0]:_([]);if(e[0].equ(r)||e[1].equ(r))return _([],e[0].symbol);for(n=fn(e[0],e[1]),t=2;t(n=-1===n?-1:1)){if(i.lte(t,l))return null;if(i.equ(t,3))return l;for(e=i.sub(t,i.equ(r,i.mod(t,l))?u:l);;e=i.sub(e,l))if(Ht(e)&&Yt(e))return e}else{if(i.lt(t,l))return l;for(e=i.add(t,i.equ(r,i.mod(t,l))?u:l);;e=i.add(e,l))if(Ht(e)&&Yt(e))return e}}(x.Arithmetic.num(t),-1===n?-1:1)},diophantine:function(t,n,e){var i=x.Arithmetic;return(st(t)||ot(t))&&t.length?dn(i.nums(t),i.num(n||0),e):null},diophantines:function(t,n,e,i){var r=x.Arithmetic;return(t instanceof v||st(t)||ot(t))&&(!(t instanceof v)||t.nr&&t.nc)&&(t instanceof v||t.length)?(t=t instanceof v?t:r.nums(t),n instanceof v||st(n)||ot(n)||(n=vt(t instanceof v?t.nr:t.length,function(){return n||0})),gn(t,n=n instanceof v?n:r.nums(n),e,!0===i)):null},congruence:function(t,n,e,i){var r=x.Arithmetic;return(st(t)||ot(t))&&t.length?function(t,n,e,i){var r,u=x.Arithmetic,l=u.O;return t.length?null==(r=dn(t.concat(e),n,i))?null:vt(r.length-1,function(t){var n=r[t];return!1===i?u.gt(l,n)&&(n=u.add(n,e)):n.c().real.lt(l)&&(n=n.add(e)),n}):null}(r.nums(t),r.num(n||0),r.num(e||0),i):null},congruences:function(t,n,e,i){var r=x.Arithmetic;return(t instanceof v||st(t)||ot(t))&&(!(t instanceof v)||t.nr&&t.nc)&&(t instanceof v||t.length)?(t=t instanceof v?t:r.nums(t),n instanceof v||st(n)||ot(n)||(n=vt(t instanceof v?t.nr:t.length,function(){return n||0})),n=n instanceof v?n:r.nums(n),e instanceof v||st(e)||ot(e)||(e=vt(t instanceof v?t.nr:t.length,function(){return e||0})),e=e instanceof v?e:r.nums(e),function(t,n,e,i){var r,u,l,s,o=x.Arithmetic,f=o.O;return t instanceof v||(t=v(t)),t.nr&&t.nc?(st(e)||ot(e)||e instanceof v||(e=o.num(e),e=vt(t.nr,function(t){return e})),(st(e)||ot(e))&&(e=v(e)),(st(n)||ot(n))&&(n=v(n)),l=e.col(0),u=ln(l),t=t.concat(e),null!=(r=gn(t,n,i,!0))&&(s=r[1],r=r[0]),null==r?null:vt(r.length-1,function(t){var n,e=r[t],l=!0;if(!1===i)o.gt(f,e)&&(e=o.add(e,u));else{for(n in e.terms)if(R.call(e.terms,n)&&"1"!==n&&o.equ(f,o.mod(u,e.terms[n].c().real.num))){l=!1;break}l&&(e=e.add(m(s.symbol+"_"+(s.length+1),u))),e.c().real.lt(f)&&(e=e.add(u))}return e})):null}(t,n,e,i)):null},pythagorean:function(t,n){var e=x.Arithmetic;return(st(t)||ot(t))&&t.length?function(t,n){var e,i,r,u,l,s,o,f,c,h,a,g=x.Arithmetic,_=g.O,v=g.I,p=g.J,b=g.II,A=t.length,y=ct(n)&&n.length?n:"i";if(!A)return null;if(h=t.filter(function(t){return 1===_n(t)}).length,a=t.filter(function(t){return-1===_n(t)}).length,1===A||0===h||0===a)return vt(A,function(){return d()});if(c=vt(A,function(n){return Xt(g.abs(t[n]))}),A!==t.filter(function(t,n){return g.equ(g.abs(t),g.mul(c[n],c[n]))}).length)return vt(A,function(){return d()});if(u=vt(A-1,function(t){return y+"_"+(t+1)}),2===A)return[d(m(u[0],c[1])),d(m(u[0],c[0]))];for(0>_n(t[0])+_n(t[1])+_n(t[2])&&(t=t.map(function(t){return g.neg(t)})),e=0,l=0;l0&&0===l||0===e&&1===l?c[l]:g.equ(_,g.mod(c[l],b))?g.div(c[l],b):c[l]);for(l=0;l=s)return 1===s?[t[n]]:[];for(i=j(),u=new Array(s),l=0;n<=e;)i[r=String(t[n])]||(u[l++]=t[n],i[r]=1),n++;return u.length>l&&(u.length=l),u},intersection:function(t,n,e,i,r,u,l,s){i=-1===i?-1:1,null==r&&(r=0),null==u&&(u=n.length-1),null==l&&(l=0),null==s&&(s=e.length-1);var o=r>u?-1:1,f=l>s?-1:1,c=o*(u-r)+1,h=f*(s-l)+1,a=r,m=l,d=0;if(null==t&&(t=new Array(I.min(c,h))),0===t.length)return t;for(;0<=o*(u-a)&&0<=f*(s-m);)1===i&&n[a]e[m]?a+=o:1===i&&n[a]>e[m]||-1===i&&n[a]u?-1:1,f=l>s?-1:1,c=o*(u-r)+1,h=r,a=l,m=0;if(!i||!i.length)return e?e.slice():e;for(null==t&&(t=new Array(c));0<=o*(u-h)&&0<=f*(s-a);)e[h]===i[a]?1i[a]?a+=f:(t[m++]=e[h],n[e[h]]--,h+=o);for(;0<=o*(u-h);)0c)return-1;if(u(t,n[f]))return f;if(u(t,n[c]))return c;if(-1===e)for(;f>>1]))return s;l(o,t)?c=s-1:f=s+1}else for(;f>>1]))return s;l(t,o)?c=s-1:f=s+1}return-1},bisect:Lt,complementation:bt,reflection:At,reversion:yt,gray:qt,finitedifference:It,partialsum:Ot,convolution:function(t,n,e){var i,r,u,l=t.length,s=n.length;if(!0===e)for(u=vt(l+s-1,function(){return 0}),i=0;i=r?n[e].neg():e>=u?t[e]:t[e].sub(n[e])}:function(e){return e>=r?n[e]:e>=u?t[e]:t[e].add(n[e])}:e?i?function(i){return i>=r?e.neg(n[i]):i>=u?t[i]:e.sub(t[i],n[i])}:function(i){return i>=r?n[i]:i>=u?t[i]:e.add(t[i],n[i])}:i?function(e){return e>=r?-n[e]:e>=u?t[e]:t[e]-n[e]}:function(e){return e>=r?n[e]:e>=u?t[e]:t[e]+n[e]})},wheel:function(){var t,n,e,i,r,u=arguments.length&&st(arguments[0])?arguments[0]:arguments,l=u.length;if(!l||!u[0])return null;for(r=1,e=0;e=t.length)return!0;for(n=0,e=t.length-1;n=(t=String(t)).length)return!0;for(n=0,e=t.length-1;n=0;s--)if("0"!==v.charAt(s)){c=!1;break}c&&(v=null)}if(o=d(10),v){if(_){for(;_.length>=v.length&&_.slice(-v.length)===v;)_=_.slice(0,-v.length);_.length||(_=null)}r=h.sub(h.pow(o,(_?_.length:0)+v.length),_?h.pow(o,_.length):m),i=h.add(h.mul(r,e),h.sub(d((_||"")+v),_?d(_):a))}else{for(;_&&"0"===_.slice(-1);)_=_.slice(0,-1);_&&_.length?(r=h.pow(o,_.length),i=h.add(h.mul(r,e),d(_))):(r=m,i=e)}return!1!==n&&(l=rn(i,r),i=h.div(i,l),r=h.div(r,l)),f[0]=g?h.neg(i):i,f[1]=r,f}(t,!h.autoSimplify);return n?h(n):null},fromString:function(t){var n,e,i,r=x.Arithmetic,u="+";return(t=L(t?String(t):"")).length?("+"!==t.charAt(0)&&"-"!==t.charAt(0)||(u=t.charAt(0),t=L(t.slice(1))),t.length&&"("===t.charAt(0)&&")"===t.charAt(t.length-1)&&(t=L(t.slice(1,-1))),n=String(t).split("/"),e=r.num(n[0].length?n[0]:"0"),i=1=0;s--)if("0"!==h.charAt(s)){d=!1;break}h=d?"":"["+h+"]"}if((a=u.slice(0,l[1]).join("")).length){for(d=!0,s=a.length-1;s>=0;s--)if("0"!==a.charAt(s)){d=!1;break}d&&!h.length&&(a="")}return c+(a.length||h.length?".":"")+a+h}(this.num,this.den)),this._dec},valueOf:function(){var t=x.Arithmetic;return t.val(this.num)/t.val(this.den)},toString:function(t){var n=x.Arithmetic;return null==this._str&&(this._str=String(this.num)+(n.equ(n.I,this.den)?"":"/"+String(this.den)),this._strp=n.equ(n.I,this.den)?String(this.num):(n.gt(n.O,this.num)?"-":"")+"("+String(n.abs(this.num))+"/"+String(this.den)+")"),t?this._strp:this._str},toTex:function(){var t=x.Arithmetic;return null==this._tex&&(this._tex=t.equ(t.I,this.den)?gt(this.num):(t.gt(t.O,this.num)?"-":"")+"\\frac{"+gt(t.abs(this.num))+"}{"+gt(this.den)+"}"),this._tex}}),a=x.Complex=F(c,{constructor:function t(){var n,e,i=arguments,r=x.Arithmetic.O;if(i.length&&(st(i[0])||ot(i[0]))&&(i=i[0]),1W||!ht(t)&&r.gt(t,W))return null;if(i.equ(u)){if(r.gt(u,t))throw new Error("Zero denominator in negative power in Abacus.Complex!");return a()}if(r.equ(u,t))return a(l);if(r.equ(l,t))return a(i);for(r.gt(u,t)&&(i=i.inv(),t=r.neg(t)),t=r.val(t),e=i,n=a(l);0!==t;)1&t&&(n=n.mul(e)),t>>=1,e=e.mul(e);return n}return i},simpl:function(){return this.real.simpl(),this.imag.simpl(),this._str=null,this._tex=null,this},integer:function(){return null==this._int&&(this._int=a(this.real.integer(),this.imag.integer())),this._int},remainder:function(){return null==this._rem&&(this._rem=a(this.real.remainder(),this.imag.remainder())),this._rem},tuple:function(){return[this.real,this.imag]},valueOf:function(){return this.real.valueOf()},toString:function(){var t,n=x.Arithmetic,e=n.O;return null==this._str&&(t=this.real.equ(e),this._str=(t?"":this.real.toString())+(this.imag.equ(e)?"":(this.imag.gt(e)?t?"":"+":"")+(this.imag.equ(n.I)?"":this.imag.equ(n.J)?"-":this.imag.toString(!0)+"*")+a.Symbol),this._str.length||(this._str="0")),this._str},toTex:function(){var t,n=x.Arithmetic,e=n.O;return null==this._tex&&(t=this.real.equ(e),this._tex=(t?"":this.real.toTex())+(this.imag.equ(e)?"":(this.imag.gt(e)?t?"":"+":"")+(this.imag.equ(n.I)?"":this.imag.equ(n.J)?"-":this.imag.toTex())+a.Symbol),this._tex.length||(this._tex="0")),this._tex},toDec:function(){var t,n=x.Arithmetic,e=n.O;return null==this._dec&&(t=this.real.equ(e),this._dec=(t?"":this.real.toDec())+(this.imag.equ(e)?"":(this.imag.gt(e)?t?"":"+":"")+(this.imag.equ(n.I)?"":this.imag.equ(n.J)?"-":this.imag.toDec())+a.Symbol),this._dec.length||(this._dec="0")),this._dec}}),m=x.Term=F(c,{constructor:function t(n,e){var i,r=x.Arithmetic;if(!(this instanceof t))return new t(n,e);n instanceof t?(e=n.factors[1].clone(),this.symbol=n.symbol,this.symbolTex=n.symbolTex,n=n.factors,i=e,this.factors=j(),this.factors[1]=i,this.factors[1].equ(r.O)||t.Merge(n,this)):((i=null==e?r.I:e)instanceof a||(i=a(i)),this.factors=j(),this.factors[1]=i,this.factors[1].equ(r.O)||t.Merge(n,this),t.Symbol(this))},__static__:{Merge:function(t,n,e){var i,r,u,l,s=x.Arithmetic,o=s.O,f=s.I;function c(t,i,r){var u=!1!==r?t.indexOf("^"):-1;i=i||o,-1!==u&&(i=s.num(t.slice(u+1)),t=t.slice(0,u)),"1"!==t&&t.length&&(-1===e?n.factors[t]&&(n.factors[t]=s.sub(n.factors[t],i),s.gte(o,n.factors[t])&&delete n.factors[t]):n.factors[t]?n.factors[t]=s.add(n.factors[t],i):n.factors[t]=i)}if(st(t)||ot(t))for(r=0,u=t.length;rn)return null;if(s[1].equ(f)||"1"===t||!R.call(s,t)||o.lt(s[t],n))return m({},f);for(e in i={},s)if(R.call(s,e)&&"1"!==e)if(t===e)for(o.gt(s[e],n)&&(i[e]=o.sub(s[e],n)),r=c,u=s[e],l=n;l--;)r=o.mul(r,u),u=o.sub(u,c);else i[e]=s[e];return m(i,s[1].mul(r))},valueOf:function(t){var n=this,e=x.Arithmetic,i=e.O,r=e.I;return t=t||{},"1"===n.symbol?n.factors[1]:n.symbols().reduce(function(u,l){if(u.equ(i))return a(i);var s,o=n.factors[l],f=t[l]||i;return f=f instanceof a?f:a(f),s="1"===l?o:f.equ(i)?i:e.equ(r,o)?f:f.pow(o),u.mul(s)},a(r))},toString:function(){var t,n=x.Arithmetic,e=n.O;return null==this._str&&((t=this.factors[1]).equ(e)?this._str="0":t.isReal()?this._str="1"===this.symbol?t.real.toString():(t.real.equ(n.J)?"-":t.real.equ(n.I)?"":t.real.toString(!0)+"*")+this.symbol:this._str="1"===this.symbol?"("+t.toString()+")":"("+t.toString()+")*"+this.symbol),this._str},toTex:function(){var t,n=x.Arithmetic,e=n.O;return null==this._tex&&((t=this.factors[1]).equ(e)?this._tex="0":t.isReal()?this._tex="1"===this.symbol?t.real.toTex():(t.real.equ(n.J)?"-":t.real.equ(n.I)?"":t.real.toTex())+this.symbolTex:this._tex="1"===this.symbol?"("+t.toTex()+")":"("+t.toTex()+")"+this.symbolTex),this._tex}}),d=x.Expr=F(c,{constructor:function t(){var n,e,i=arguments.length&&(st(arguments[0])||ot(arguments[0]))?arguments[0]:arguments;if(!(this instanceof t))return new t(i);for(this.terms=j(),this.terms[1]=m(1,x.Arithmetic.O),n=0,e=i.length;nW||!ht(t)&&i.gt(t,W))return null;if(this.equ(r))return d();if(i.equ(r,t))return d([m(1,u)]);if(i.equ(u,t))return d(this.args());for(t=i.val(t),e=this,n=d([m(1,u)]);0!==t;)1&t&&(n=n.mul(e)),t>>=1,e=e.mul(e);return n}return this},d:function(t,n){var e=this;return null==n&&(n=1),n=+n,t=String(t||"x"),0>n?null:d(e.symbols().map(function(i){return"1"===i?x.Arithmetic.O:e.terms[i].d(t,n)}))},valueOf:function(t){var n=this;x.Arithmetic.O;return t=t||{},n.symbols().reduce(function(e,i){return e.add(n.terms[i].valueOf(t))},a.ZERO())},toString:function(){var t,n,e,i,r,u=x.Arithmetic.O,l="",s=!1;if(null==this._str){for(e=(t=this.symbols()).length,n=0;nn.length&&(u=t,t=n,n=u),l=t.length,s=n.length,o=new Array(l*s),0c&&(c=a,h=r);o[e].e!==c&&(o[e].c.equ(0)||(o[++e]=g(0,-1)),o[e].e=c),o[e].c=o[e].c.add(t[h].c.mul(n[f[h]].c)),f[h]++,f[h]>=s&&i++}o.length>e+1&&(o.length=e+1)}return o}(n.coeff,t.coeff):[];else if(t instanceof h)if(t.equ(r))n.coeff=[];else if(t.equ(i.I));else for(e=n.coeff.length-1;e>=0;e--)n.coeff[e].c=n.coeff[e].c.mul(t);else if(i.isNumber(t))if(i.equ(r,t))n.coeff=[];else if(i.equ(i.I,t));else for(e=n.coeff.length-1;e>=0;e--)n.coeff[e].c=n.coeff[e].c.mul(t);return n},C:function(t,n){return new _(t||x.Arithmetic.O,n||"x")},fromExpr:function(t,n){if(!(t instanceof d))return null;n=String(n||"x");var e,i,r,u=t.symbols(),l=x.Arithmetic.O,s={};for(e=u.length-1;e>=0;e--)i=u[e],(r=t.terms[i].c()).equ(l)||("1"===i?s[0]=r.real:n===i?s[1]=r.real:i.length>n.length+1&&n+"^"===i.slice(0,n.length+1)&&-1===i.indexOf("*")&&(s[i.slice(n.length+1)]=r.real));return new _(s,n)},fromString:function(t){var n,e,i,r,u,l=x.Arithmetic,s={},o=null,f=/(\+|-)?\s*(\(?-?\d+(?:\/-?\d+)?\)?)?(?:\s*\*?\s*([a-zA-Z])(?:\^\{?(\d+)\}?)?)?/g;for(t=L(String(t));(n=f.exec(t))&&n[0].length;)if(L(n[0]).length){if(n[3]){if(null==o)o=n[3];else if(n[3]!==o)continue;r=n[4]||"1",i=n[2]||"1"}else r="0",i=n[2]||"0";for(;r.length&&"0"===r.charAt(0);)r=r.slice(1);r.length||(r="0"),e=n[1]||"",u=h.fromString(e+i),s[r]=s[r]?s[r].add(u):u}return J(s).reduce(function(t,n){return s[n].equ(l.O)&&t.push(n),t},[]).forEach(function(t){delete s[t]}),new _(s,o)}},coeff:null,symbol:null,_str:null,_tex:null,_n:null,_expr:null,_prim:null,_roots:null,dispose:function(){return this._n&&this._n._n===this&&(this._n._n=null),this.coeff=null,this.symbol=null,this._str=null,this._tex=null,this._n=null,this._expr=null,this._prim=null,this._roots=null,this},clone:function(t){return new _(this)},isInt:function(){var t,n=this.coeff;for(t=n.length-1;t>=0;t--)if(!n[t].c.isInt())return!1;return!0},isMono:function(){var t=this.coeff;return 1===t.length&&0!==t[0].e},deg:function(){var t=this.coeff;return t.length?t[0].e:0},lead:function(){var t=this.coeff;return t.length?t[0].c:h.ZERO()},c:function(){var t=this.coeff;return t.length?t[t.length-1].c:h.ZERO()},primitive:function(t){var n,e,i,r=x.Arithmetic,u=this.coeff;return null==this._prim&&(u.length?(e=u.reduce(function(t,n){return r.mul(t,n.c.den)},r.I),n=u.map(function(t){return t.c.mul(e).integer()}),i=rn(n),n=n.map(function(t){return r.div(t,i)}),r.gt(r.O,n[0])&&(n=n.map(function(t){return r.neg(t)}),i=r.neg(i)),this._prim=[_(n.map(function(t,n){return g(t,u[n].e)}),this.symbol),h(i,e).simpl()]):this._prim=[_([],this.symbol),h(r.I)]),!0===t?this._prim.slice():this._prim[0]},roots:function(){var t,n,e,i,r,u,l,s,o,f,c,a,m,d=x.Arithmetic,g=d.O;if(null==this._roots){if(t=[],0=0;e--)if(!u[e].c.equ(n[e].c)||u[e].e!==n[e].e)return!1;return!0}return t instanceof m?!(2<=u.length)&&(0===u.length?t.c().equ(r):(0===u[0].e?"1":this.symbol+"^"+u[0].e)===t.symbol&&t.c().equ(u[0].c)):t instanceof d?this.toExpr().equ(t):!!ct(t)&&(t===this.toString()||t===this.toTex())},gt:function(t){var n=x.Arithmetic;return t instanceof a||t instanceof h||n.isNumber(t)?!(0W||!ht(t)&&i.gt(t,W))return null;if(0===(t=i.val(t)))return _(i.I,this.symbol);if(1===t)return _(this);if(2===t)return _.Mul(this,_(this));for(n=_(i.I,this.symbol),e=_(this);0!==t;)1&t&&(n=_.Mul(e,n)),t>>=1,e=_.Mul(e,e);return n},compose:function(t){var n,e,i,r,u=x.Arithmetic;u.O;if(t instanceof v)return null;if(t instanceof m&&(t=d(t)),t instanceof d&&(t=_.fromExpr(t,this.symbol)),t instanceof a&&(t=t.real),u.isNumber(t)||t instanceof h)return _(this.valueOf(t),this.symbol);if(t instanceof _){if(!this.coeff.length)return _([],t.symbol);if(0===this.deg())return _(this.coeff.slice(),t.symbol);if(0===t.deg())return _(this.valueOf(t.c()),t.symbol);for(i=(e=this.coeff)[0].e,n=_(e[0].c,t.symbol),r=1;0t?this.coeff.map(function(n){return n.e<-t?null:g(n.c,n.e+t)}).filter(g.isNonZero):this.coeff.map(function(n){return g(n.c,n.e+t)}),this.symbol)},d:function(t){var n=x.Arithmetic;n.O;return null==t&&(t=1),0>(t=+t)?null:0===this.coeff.length?_([],this.symbol):t>=this.coeff[0].e?_([],this.symbol):_(this.coeff.map(function(e){if(t>e.e)return null;for(var i=n.I,r=e.e;r+t>e.e;r--)i=n.mul(i,r);return g(e.c.mul(i),e.e-t)}).filter(g.isNonZero),this.symbol)},valueOf:function(t){var n,e,i,r=x.Arithmetic.O,u=this.coeff;if(!u.length)return h.ZERO();for(t=t instanceof a?t.real:t instanceof h?t:h(t||r),n=u[0].e,i=u[0].c,e=1;0=0;e--)i.push(m(0===t[e].e?"1":1===t[e].e?n:n+"^"+String(t[e].e),t[e].c));i.length||i.push(m(1,r)),this._expr=d(i)}return this._expr}}),v=x.Matrix=F(c,{constructor:function t(n,e,i){var r,u,l,s,o=x.Arithmetic;if(!(this instanceof t))return new t(n,e,i);if(st(n)||ot(n))st(n[0])||ot(n[0])?(ot(n)&&(n=N.call(n)),ot(n[0])&&(n=n.map(function(t){return N.call(t)})),this.val=n):this.val=e?vt(1,function(t){return vt(n.length,function(t){return n[t]})}):vt(n.length,function(t){return vt(1,function(e){return n[t]})});else if(null==e&&(e=n),n=+(n||0),e=+(e||0),this.val=vt(n,function(t){return vt(e,function(t){return o.O})}),ft(i))for(r in i)R.call(i,r)&&-1!==r.indexOf(",")&&(u=i[r],l=(r=r.split(",").map(function(t){return parseInt(L(t),10)}))[0],s=r[1],0<=l&&l(t=+t)||0>n?null:new v(vt(t,function(t){return vt(n,function(t){return e})}))},D:function(t,n,e){var i=x.Arithmetic.O;return e=e||i,null==n&&(n=t),n=+n,0>(t=+t)||0>n?null:new v(vt(t,function(t){return vt(n,function(n){return t===n?st(e)||ot(e)?tt&&(t+=i),0>n&&(n+=r),0<=t&&t=t.nr?n.val[i].slice():i>=n.nr?t.val[i].slice():vt(I.max(n.nc,t.nc),function(r){return r>=t.nc?n.val[i][r]:r>=n.nc?t.val[i][r]:e.add(n.val[i][r],t.val[i][r])})})):n},sub:function(t){var n=this,e=x.Arithmetic;return t instanceof a?t=t.real.integer():t instanceof h&&(t=t.integer()),e.isNumber(t)?n.map(function(n){return e.sub(n,t)}):t instanceof v?v(vt(I.max(n.nr,t.nr),function(i){return i>=t.nr?n.val[i].slice():i>=n.nr?t.val[i].map(function(t){return e.neg(t)}):vt(I.max(n.nc,t.nc),function(r){return r>=t.nc?n.val[i][r]:r>=n.nc?e.neg(t.val[i][r]):e.sub(n.val[i][r],t.val[i][r])})})):n},mul:function(t){var n,e=this,i=x.Arithmetic;return t instanceof a?t=t.real.integer():t instanceof h&&(t=t.integer()),i.isNumber(t)?e.map(function(n){return i.mul(n,t)}):t instanceof v?(n=I.min(e.nc,t.nr),v(vt(e.nr,function(r){return vt(t.nc,function(u){for(var l=i.O,s=0;s=n.nr?t.val[i].slice():i>=t.nr?n.val[i].slice():vt(I.max(n.nc,t.nc),function(r){return r>=n.nc?t.val[i][r]:r>=t.nc?n.val[i][r]:e.mul(n.val[i][r],t.val[i][r])})})):n},kron:function(t){var n,e,i,r,u,l=this,s=x.Arithmetic;return t instanceof a?t=t.real.integer():t instanceof h&&(t=t.integer()),s.isNumber(t)?l.map(function(n){return s.mul(n,t)}):t instanceof v?(n=l.nr,e=l.nc,i=t.nr,r=t.nc,u=e*r,v(vt(n*i,function(n){var e=~~(n/i),o=n%i;return vt(u,function(n){var i=~~(n/r),u=n%r;return s.mul(l.val[e][i],t.val[o][u])})}))):l},div:function(t){var n=x.Arithmetic;return t instanceof a?t=t.real.integer():t instanceof h&&(t=t.integer()),n.isNumber(t)?this.map(function(e){return n.div(e,t)}):this},mod:function(t){var n=x.Arithmetic;return t instanceof a?t=t.real.integer():t instanceof h&&(t=t.integer()),n.isNumber(t)?this.map(function(e){return n.mod(e,t)}):this},divmod:ut,pow:function(t){var n,e,i=x.Arithmetic;if(!i.isNumber(t)||i.gt(i.O,t)||ht(t)&&t>W||!ht(t)&&i.gt(t,W))return null;if(0===(t=i.val(t)))return v.I(this.nc);if(1===t)return this.clone();if(2===t)return this.mul(this);for(n=null,e=this;0!==t;)1&t&&(n=null==n?e:e.mul(n)),t>>=1,e=e.mul(e);return n},fwdsub:function(t,n){var e,i,r,u,l,s,o,f=x.Arithmetic,c=f.O,h=this.val;for(t instanceof v&&(t=t.col(0)),n instanceof v&&(n=n.diag()),u=I.min(this.nr,this.nc,t.length),l=new Array(u),e=0;e=0;e--){for(r=c,i=u-1;i>e;i--)r=f.add(r,f.mul(h[e][i],l[i]));if(s=f.sub(t[e],r),o=h[e][e],f.equ(c,o)){if(!f.equ(c,s))return null}else if(n)s=f.mul(s,f.div(n[e],o));else{if(!f.equ(c,f.mod(s,o)))return null;s=f.div(s,o)}l[e]=s}return l},backsuby:function(t){var n,e,i,r,u,l,s,o=x.Arithmetic,f=o.O,c=this.val;for(t instanceof v&&(t=t.col(0)),r=I.min(this.nr,this.nc,t.length),u=new Array(r),n=r-1;n>=0;n--){for(i=f,e=r-1;e>n;e--)i=o.add(i,o.mul(c[n][e],u[e]));if(l=o.sub(o.mul(c[r-1][r-1],t[n]),i),s=c[n][n],o.equ(f,s)||!o.equ(f,o.mod(l,s)))return null;l=o.div(l,s),u[n]=l}return u},snf:function(){var t,n,e,i,r,u,l,s,o,f,c,h,a,m,d,g,_,p,b,A,y,q=x.Arithmetic,O=q.O,w=q.I,S=q.J,N=this.nr,R=this.nc;if(null==this._snf){for(t=I.min(N,R),n=this.clone(),e=v.I(N),i=v.I(R),r=-1,u=0;u=0;a--)m=sn(n.val[a][a],n.val[h][h]),q.equ(O,m[0])||(d=m[1],g=m[2],_=q.div(n.val[h][h],m[0]),p=q.div(n.val[a][a],m[0]),A=q.mul(g,_),y=q.sub(w,q.mul(d,p)),v.MULR(n.val,a,h,w,g,_,q.sub(A,w)),v.MULC(e.val,a,h,q.sub(w,A),g,_,S),v.MULC(n.val,a,h,d,y,w,q.mul(S,p)),v.MULR(i.val,a,h,p,y,w,q.mul(S,d)));this._snf=[n,e,i]}return this._snf.slice()},lu:function(){var t,n,e,i,r,u,l,s,o,f,c,h,a,m=x.Arithmetic,d=m.O,g=m.I,_=(m.J,this.nr),p=this.nc;if(null==this._lu){for(a=!1,e=this.clone(),n=v.I(_),i=vt(_,function(){return d}),t=v.I(_),r=g,u=0;u<_-1;u++){if(m.equ(d,e.val[u][u])){for(o=u+1,f=!0;o<_&&f;)m.equ(d,e.val[o][u])?o++:f=!1;if(_<=o){a=!0;break}v.SWAPR(e.val,u,o),v.SWAPR(t.val,u,o)}for(c=e.val[u][u],n.val[u][u]=c,i[u]=m.mul(r,c),l=u+1;l<_;l++){for(h=e.val[l][u],n.val[l][u]=h,s=u+1;s=0;e--)if(t===i[e][n])return e;return-1}for(e=q,st(n)&&(e=I.min(e,n[1])),g=this.clone(!0),i=new Array(e),f=0,r=b,u=0;uO&&(i.length=O),this._ref=[g,i,r]}return t?this._ref.slice():this._ref[0]},rref:function(t,n){var e,i,r,u,l,s,o,f,c,h,a=x.Arithmetic,m=a.O,d=a.I,g=a.J,_=(this.nr,this.nc);if(null==this._rref){for(f=(h=this.ref(!0,n))[0].clone(),e=h[1],i=h[2],r=e.length,l=0;lt&&(t+=u),0>n&&(n+=l),0>e&&(e+=u),0>i&&(i+=l),t=I.max(0,I.min(u-1,t)),e=I.max(0,I.min(u-1,e)),n=I.max(0,I.min(l-1,n)),i=I.max(0,I.min(l-1,i)),t<=e&&n<=i?v(vt(e-t+1,function(e){return vt(i-n+1,function(i){return r.val[t+e][n+i]})})):v()):v()},concat:function(t,n){var e=this,i=x.Arithmetic.O;return t instanceof v?v("vertical"===(n=n||"horizontal")?vt(e.nr+t.nr,function(n){return vt(I.max(e.nc,t.nc),function(r){return r>=e.nc?n=t.nc?n=e.nr?r=t.nr?rt[e]&&(t[e]=i.length),t},t)},vt(this.nc,function(){return 0})),this._str=this.val.map(function(n,e){return"|"+n.map(function(n,e){return Ct(String(n),t[e])}).join(" ")+"|"}).join("\n")),this._str},toTex:function(){return null==this._tex&&(this._tex="\\begin{bmatrix}"+this.val.map(function(t,n){return t.map(function(t,n){return gt(t)}).join(" & ")}).join(" \\\\ ")+"\\end{bmatrix}"),this._tex}}),x.BitArray=F({constructor:function t(n){if(!(this instanceof t))return new t(n);this.length=n,this.bits=new Uint32Array(I.ceil(n/32))},length:0,bits:null,dispose:function(){return this.length=null,this.bits=null,this},clone:function(){var t=new x.BitArray(this.length);return t.bits=new Uint32Array(this.bits),t},fromArray:function(t){return this.bits=new Uint32Array(t),this},toArray:function(){return N.call(this.bits)},toString:function(){return this.toArray().map(mt).join("")},reset:function(){var t,n=this.bits,e=n.length;for(t=0;t>>5]&1<<(31&t))},set:function(t){return this.bits[t>>>5]|=1<<(31&t),this},unset:function(t){return this.bits[t>>>5]&=~(1<<(31&t)),this},toggle:function(t){return this.bits[t>>>5]^=1<<(31&t),this}}),u=x.Filter=F({constructor:function t(n){if(!(this instanceof t))return new t(n);this.filter=n||null},__static__:{UNIQUE:function(){return u(function(t){var n,e=t.length,i={};for(n=0;narguments.length||null==n)&&(n=!0),ct(t)&&("<"===t?(t=1,n=!0):">"===t?(t=-1,n=!0):"<="===t||"=<"===t?(t=1,n=!1):">="!==t&&"=>"!==t||(t=-1,n=!1)),u(-1===(t=-1===(t=+t)?-1:1)?function(t){for(var e=t[0],i=1,r=t.length;i=t[i]||!n&&e>t[i])return!1;e=t[i]}return!0})},LEN:function(t,n){return t=+t,u(">="===(n=n||"==")?function(n){return n.length>=t}:">"===n?function(n){return n.length>t}:"<"===n?function(n){return n.length="===(e=e||"==")||"=>"===e?function(e){return 0<=t&&t=n}:">"===e?function(e){return 0<=t&&tn}:"<"===e?function(e){return 0<=t&&t="===(n=n||"==")||"=>"===n?function(n){return _t(function(t,e){return n[e]>t&&(t=n[e]),t},-1/0,null,0,n.length-1,1)>=t}:">"===n?function(n){return _t(function(t,e){return n[e]>t&&(t=n[e]),t},-1/0,null,0,n.length-1,1)>t}:"<"===n?function(n){return _t(function(t,e){return n[e]>t&&(t=n[e]),t},-1/0,null,0,n.length-1,1)t&&(t=n[e]),t},-1/0,null,0,n.length-1,1)<=t}:"!="===n?function(n){return _t(function(t,e){return n[e]>t&&(t=n[e]),t},-1/0,null,0,n.length-1,1)!==t}:function(n){return _t(function(t,e){return n[e]>t&&(t=n[e]),t},-1/0,null,0,n.length-1,1)===t})},MIN:function(t,n){return t=+t,u(">="===(n=n||"==")||"=>"===n?function(n){return _t(function(t,e){return n[e]=t}:">"===n?function(n){return _t(function(t,e){return n[e]t}:"<"===n?function(n){return _t(function(t,e){return n[e](n=+n)){var i=t;t=n,n=i}return(3>arguments.length||null==e)&&(e=!0),u(e?function(e){for(var i=0,r=e.length;in)return!1;return!0}:function(e){for(var i=0,r=e.length;i=n)return!1;return!0})}},filter:null,dispose:function(){return this.filter=null,this},apply:function(t,n){var e=this.filter;return!e||!at(e)||Boolean(e.call(n||null,t))},NOT:function(){var t=this;return u(function(n){return!t.apply(n,this)})},OR:function(t){var n=this;return at(t)||t instanceof u?(t instanceof u||(t=u(t)),u(function(e){return n.apply(e,this)||t.apply(e,this)})):n},XOR:function(t){var n=this;return at(t)||t instanceof u?(t instanceof u||(t=u(t)),u(function(e){var i=n.apply(e,this),r=t.apply(e,this);return i&&!r||!i&&r})):n},AND:function(t){var n=this;return at(t)||t instanceof u?(t instanceof u||(t=u(t)),u(function(e){return n.apply(e,this)&&t.apply(e,this)})):n}}),n=x.Iterator=F({constructor:function t(n,e){var i=x.Arithmetic;if(!(this instanceof t))return new t(n,e);(st(n)||ot(n))&&(n[0]instanceof t||n[n.length-1]instanceof t)?(this.name="Iterator",this.$=e||{},this.$.seq=ot(n)?N.call(n):n,this.$.count=_t(function(t,n){return i.add(t,n.total())},i.O,this.$.seq),this.rewind()):at(n)?(this.name="Generator",this.$={},this.$.generator=n,this.$.state=e||{},this.$.count=i.I,this.rewind()):(this.name=n||"Iterator",this.$=e||{},this.$.count=this.$.count||i.O)},__static__:{Iterable:function t(n,e){if(!(this instanceof t))return new t(n,e);e=-1===e?-1:1,this.next=function(){var t=n.hasNext(e)?n.next(e):null;return null==t?{done:!0}:{value:t}}}},name:"Iterator",$:null,__index:null,__item:null,_index:null,_item:null,__subindex:null,_subindex:null,__subitem:null,_subitem:null,dispose:function(){return this.$.seq&&this.$.seq.length&&(_t(function(t,n){n.dispose()},null,this.$.seq),this.$.seq=null),this.$=null,this.__index=null,this.__item=null,this._index=null,this._item=null,this.__subindex=null,this._subindex=null,this.__subitem=null,this._subitem=null,this},filterBy:function(t){var n=this.$;return!1===t?n.filter&&(n.filter=null):(t instanceof u||at(t))&&(n.filter=t instanceof u?t:u(t)),this},mapTo:function(t){var n=this.$;return!1===t?n.output&&(n.output=null):at(t)&&(n.output=t),this._item=this.output(this.__item),this},fuse:function(t,e,i){var r=this.$;return 1===arguments.length&&!1===t?r.sub&&(r.sub=null,r.submethod=null,r.subcascade=null,r.subcount=null,this.rewind()):e instanceof n&&at(t)&&(r.sub=e,r.submethod=t,r.subcascade=-1===i?-1:1,r.subcount=x.Arithmetic.mul(r.count,e.total()),this.rewind()),this},unfuse:function(){return this.fuse(!1)},juxtaposeWith:function(t,n){return this.fuse(function(t,n){return[].concat(t).concat(n)},t,n)},state:function(t){return arguments.length?(this.$.state=t,this):this.$.state},output:function(t){var n=this.$.output;return null==t?null:at(n)?n(t):t},fusion:function(t,n){var e,i=this.$;return i.sub?(-1===i.subcascade&&(e=t,t=n,n=e),null==t||null==n?t||n||null:i.submethod.call(this,t,n)):t},order:function(){return this},rewind:function(t,n){var e,i,r,u=this.$;if(t=-1===t?-1:1,st(u.seq)){for(e=0,i=u.seq.length;et?i-1:0;do{null==(r=u.seq[u.seqindex].next(t))&&(u.seqindex+=t)}while(null==r&&0<=u.seqindex&&u.seqindexr.seqindex||r.seqindex>=r.seq.length)&&r.sub&&r.sub.hasNext(t)&&(this.rewind(t,!0),i=this.__item,this.__subitem=r.sub.next(t)),this.__item=i,this._item=this.output(this.__item),this._subitem=r.sub&&null!=this._item&&null!=this.__subitem?this.fusion(this._item,this.__subitem):null}while(r.filter&&null!=e&&!r.filter.apply(e,this));return e}if(at(r.generator)){do{n=this.__item,e=r.sub?this._subitem:this._item,this.__item=r.generator.call(this,n,t,r.state,!1),null==this.__item&&r.sub&&r.sub.hasNext(t)&&(this.rewind(t,!0),this.__subitem=r.sub.next(t)),this._item=this.output(this.__item),this._subitem=r.sub&&null!=this._item&&null!=this.__subitem?this.fusion(this._item,this.__subitem):null}while(r.filter&&null!=e&&!r.filter.apply(e,this));return e}return null},get:function(t){var n,e,i=[];if(at(t))for(;this.hasNext()&&null!=(n=this.next())&&t(n);)i.push(n);else for(e=!arguments.length||null==t,null!=t&&(t=+t);(e||i.lengths&&(s=e),ef&&(f=i),i(e=-1===e?-1:1)||K&(n&&null!=n.order?n.order:Q)?n.seq[n.seq.length-1].item0(e):n.seq[0].item0(e):null},succ:function(t,n,e,i,r,u){if(null==e||null==t)return null;var l,s,o,f,c,h=x.Arithmetic;if(r=-1===r?-1:1,i&&"sequence"===i.type){if(!(c=i.seq)||!c.length)return null;for(K&(i&&null!=i.order?i.order:Q)?(l=-1,s=c.length-1):(l=1,s=0),f=l*i.seq_curr+s,o=l*r;0<=f&&fr?h.J:h.I),e,i)},rand:function(t,n){var e,i,r,u,l,s,o=x.Arithmetic,f=o.O;if(n&&"sequence"===n.type){if(!(r=n.seq)||!r.length)return null;for(e=null!=n.last?n.last:o.sub(this.count(t,n),o.I),i=o.rnd(f,e),u=0,l=r.length;o.gte(i,s=r[u].total())&&(i=o.sub(i,s),!(++u>=l||o.lt(i,f))););return u=o.$.mindimension&&u<=o.$.maxdimension){if(l=o[S].rank(t,o.n,o.$),c.gt(l,a)){f=!0;break}s=c.add(s,o.total())}return f?c.add(l,s):a}return ut()},unrank:function(t,n,e){if(e&&"sequence"===e.type){var i,r,u=x.Arithmetic,l=u.O,s=e.seq;if(!s||!s.length)return null;if(null==t||!u.inside(t,u.J,null!=e.count?e.count:this.count(n,e)))return null;for(r=s.length,i=0;u.gte(t,s[i].total())&&(t=u.sub(t,s[i].total()),!(++i>=r||u.lt(t,l))););return if&&(f=n[t]+1),n[t]):f+e[t-n.length]}:function(t){return t=0;d--)b.splice(n[d],1);for(d=0,m=0;mt?u.seq.length-1:0:-1),et&f?("gen"===x.Options.RANDOM||1===u.rand[u.type]||s.gt(e,x.Options.MAXMEM)||s.isDefault()&&0>e?(this.__item=r.rand(l,u),this.__index=o):(this._traversed&&this._traversed.dispose(),this._traversed=new x.BitArray(s.val(e)),n=this.random("index"),this._traversed.set(+n),this.__item=r.unrank(n,l,u),null!=this.__item&&(this.__index=n)),this._index=o):(this.__item=r.initial(l,u,t,!0),null!=this.__item&&(this.__index=0>t?i:o,this._update()),this._index=this.__index),this._item=this.output(this.__item),this._prev=!(et&f||0t&&!(et&f))&&null!=this.__item,this},_update:function(){return this.item__=null,this},order:function(t,n){if(!arguments.length)return this._order;this[S];var e,i,r,u,l,s,o=x.Arithmetic,f=(o.O,o.I,!0===t);if(n=-1===n,this.n,r=this.$,this._traversed&&(this._traversed.dispose(),this._traversed=null),f?t=r.order:ct(t)&&-1<(i=t.indexOf("|"))?(e=t.substr(i+1),t=zn(t.substr(0,i))):e=t=zn(t),u=n?-1:1,r.order=t,r.sub?(f?r.sub.rewind(u):r.sub.order(e,u),this.__subindex=r.sub.index(),this.__subitem=r.sub.next(u),this._subindex=null,this._subitem=null):(this.__subindex=null,this.__subitem=null,this._subindex=null,this._subitem=null),"sequence"===r.type&&r.seq&&r.seq.length)for(l=0,s=r.seq.length;l(t=-1===t?-1:1)&&et&p)return null;n=0>t?g:d;do{if(f=null!=(o=v.sub?this._subitem:this._item),et&p)if(u=v.last,a.lt(this._index,u))if(e=this._traversed){for(r=this.random("index"),s=x.Math.rnd()>.5?g:d;e.isset(+r);)r=a.wrap(a.add(r,s),m,u);e.set(+r),this.__item=h.unrank(r,_,v),null!=this.__item&&(this.__index=r)}else this.__item=h.rand(_,v),this.__index=null;else this._item=this.__item=null,this._traversed&&(this._traversed.dispose(),this._traversed=null);else this.__item=h.succ(this.__item,this.__index,_,v,t,this.item__),null!=this.__item&&(this.__index=a.add(this.__index,n));if(c=null!=this.__item)this._index=a.add(this._index,n),null===this.__index&&(this.__index=this._index),0>t?(this._prev=c,this._next=f):(this._prev=f,this._next=c);else if(v.sub&&v.sub.hasNext(t))if(this.__subindex=v.sub.index(),this.__subitem=v.sub.next(t),null==this.__subitem)this.__subindex=null,this.__subitem=null,0>t?(this._prev=c,this._next=f):(this._prev=f,this._next=c);else{if("sequence"===v.type&&v.seq&&v.seq.length)for(i=0,l=v.seq.length;it?(this._prev=c,this._next=f):(this._prev=f,this._next=c);this._item=this.output(this.__item),v.sub&&(c=c&&null!=this.__subitem,this._subindex=c?a.add(a.mul(this.__subindex,b),this._index):null,this._subitem=c?this.fusion(this._item,this.__subitem):null,0>t?this._prev=c:this._next=c)}while(v.filter&&null!=o&&!v.filter.apply(o,this));return o},range:function(t,n){var e,i,r,u,l,s,o=x.Arithmetic,f=o.num,c=o.O,h=o.I,a=this.$,m=a.sub?a.subcount:a.count,d=a.sub?o.sub(m,h):a.last,g=1,_=arguments.length,v=!(et&a.order);if(_<1?(t=c,n=d):_<2?(t=f(t),n=d):(t=f(t),n=f(n)),t=o.wrapR(t,m),n=o.wrapR(n,m),o.gt(t,n)&&(e=t,t=n,n=e,g=-1),t=o.clamp(t,c,d),v&&(n=o.clamp(n,c,d)),o.lte(t,n)){for(s=[this.$.order,this.__index,this._index,this.__item&&this.__item.slice(),this._item,this.__subindex,this._subindex,this.__subitem,this._subitem,this._prev,this._next],v&&this.index(t),r=o.val(o.sub(n,t)),i=new Array(r+1),l=0;l<=r&&null!=(u=this.next());)i[l++]=u;i.length>l&&(i.length=l),0>g&&1t?i.INF===this._max?(this.__item=null,this._item=null):("geometric"===this.$.type?this.__item=i.mul(this._min,i.pow(this._step,this.$.last)):this.__item=i.add(this._min,i.mul(this._step,this.$.last)),this._item=this.output(this.__item)):(this.__item=this._min,this._item=this.output(this.__item)),e.sub&&!0!==n&&(e.sub.rewind(t),this.__subitem=e.sub.next(t),this._subitem=null!=this._item&&null!=this.__subitem?this.fusion(this._item,this.__subitem):null),this},hasNext:function(t){t=-1===t?-1:1;var n=this.$;return x.Arithmetic.INF===this._max?0t?r.equ(e,this._min)?this.__item=null:this.__item=r.div(e,this._step):r.INF!==this._max&&r.equ(e,this._max)?this.__item=null:this.__item=r.mul(e,this._step):0>t?r.equ(e,this._min)?this.__item=null:this.__item=r.sub(e,this._step):r.INF!==this._max&&r.equ(e,this._max)?this.__item=null:this.__item=r.add(e,this._step),null!=this.__item&&(r.lt(this.__item,this._min)||r.INF!==this._max&&r.gt(this.__item,this._max))&&(this.__item=null),this._item=null==this.__item?null:this.output(this.__item)),null==this.__item&&i.sub&&i.sub.hasNext(t)&&(this.rewind(t,!0),this.__subitem=i.sub.next(t),this._subitem=null!=this._item&&null!=this.__subitem?this.fusion(this._item,this.__subitem):null)}while(i.filter&&null!=n&&!i.filter.apply(n,this));return n}}),o=function t(){var n=this,e=null;if(!(n instanceof t))return new t;e=j(),n.dispose=function(){return n.empty(),e=null,n},n.empty=function(){var t,i,r,u;if(!e)return n;for(t in e)if(R.call(e,t)&&null!=e[t])for(r=0,u=(i=e[t]).length;r(t=-1===t?-1:1))return null;var n,e,i,r,u,l=this.$,s=this._multiples,o=this._small_primes,f=x.Arithmetic,c=f.II,h=this.__item;do{if(this._pt[1]&&(t[1]=n),t},[1/0,0],r);if(n.base=r,n.minbase=o[0],n.maxbase=o[1],n.dimension=r.length,"gray"===n.output)n.output=function(n,e){return t.gray(n,e)};else if("inversion"===n.output)n.output=function(n,e){return t.inversion(n)};else if(st(n.output)){var f=n.output;n.output=function(n,e){return t.component(n,f)}}}e.call(this,"Tensor",r,n,i?{method:"partial"===n.type?n.submethod||"complete":n.submethod,iter:i,pos:"partial"===n.type?n.subpos||n.position:n.subpos,cascade:n.subcascade}:null)},__static__:{C:e.C,P:e.P,T:e.T,DUAL:e.DUAL,count:function(t,n){var e=x.Arithmetic.O,i=n&&n.type?n.type:"tensor";return"partial"===i?n.data&&n.data.length?x.Arithmetic.num(n.data.length):e:"tuple"===i?!t||0>=t[0]?e:pn(t[1],t[0]):t&&t.length?Ut(t):e},initial:function(t,n,e){var i,r=n&&n.type?n.type:"tensor",u=n&&n.order?n.order:Q;return e=-1===e?-1:1,(!(tt&u)&&K&u||tt&u&&!(K&u))&&(e=-e),"partial"===r?i=n.data&&n.data.length?0>e?n.data[n.data.length-1]:n.data[0]:null:(i="tuple"===r?t[0]?vt(t[0],0>e?t[1]-1:0,0):[]:t.length?0>e?vt(t.length,function(n){return t[n]-1}):vt(t.length,0,0):[],i=this.DUAL(i,t,n)),i},succ:function(t,n,e,i,r,u){if(!e||null==t)return null;var l,s=i&&i.type?i.type:"tensor",o=i&&null!=i.order?i.order:Q,f=x.Arithmetic;return r=-1===r?-1:1,"partial"===s?i.data&&i.data.length?(K&o&&(r=-r,null!=n&&(n=f.sub(f.num(i.data.length-1),n))),null==n&&(n=Zn(i.data,t,!0)),l=f.val(n),0>r?0<=l-1?i.data[l-1]:null:0<=l&&l+1=e[0]?null:function(t,n,e,i,r,u){var l,s,o,f,c,h,a,m,d,g=n;"tuple"===i?(l=g[0],g=g[1]):l=g.length;0,h=1,f=d=l-1,c=0,a=1,m=0,tt&r&&(h=-h,f=d-f,c=d-c,a=-a,m=d-m);Y&r&&(h=-h,f=d-f,c=d-c,a=-a,m=d-m);K&r&&(e=-e);if(0>e)if("tuple"===i){for(s=f;0<=s&&d>=s&&0===t[s];)s-=h;if(0<=s&&d>=s)for(g-=1,t[s]=t[s]-1,o=s+h;0<=o&&d>=o;o+=h)t[o]=g;else t=null}else{for(s=f;0<=s&&d>=s&&0===t[s];)s-=h;if(0<=s&&d>=s)for(t[s]=t[s]-1,o=s+h;0<=o&&d>=o;o+=h)t[o]=g[a*o+m]-1;else t=null}else if("tuple"===i){for(s=f;0<=s&&d>=s&&t[s]+1===g;)s-=h;if(0<=s&&d>=s)for(t[s]=t[s]+1,o=s+h;0<=o&&d>=o;o+=h)t[o]=0;else t=null}else{for(s=f;0<=s&&d>=s&&t[s]+1===g[a*s+m];)s-=h;if(0<=s&&d>=s)for(t[s]=t[s]+1,o=s+h;0<=o&&d>=o;o+=h)t[o]=0;else t=null}return t}(t,e,r,s,o)},rand:function(t,n){var e,i=x.Math.rndInt,r=n&&n.type?n.type:"tensor";return"partial"===r?e=n.data&&n.data.length?n.data[i(0,n.data.length-1)]:null:(e="tuple"===r?t[0]?vt(t[0],function(n){return i(0,t[1]-1)}):[]:t.length?vt(t.length,function(n){return i(0,t[n]-1)}):[],e=this.DUAL(e,t,n)),e},randu:e.rand,rank:function(t,n,e){var i,r,u=x.Arithmetic,l=e&&null!=e.order?e.order:Q,s=e&&e.type?e.type:"tensor",o=u.add,f=u.sub,c=u.mul,h=u.O,a=u.J;if("partial"===s)h=u.num(Zn(e.data,t,!0));else if(t=this.DUAL(t,n,e),"tuple"===s){if(!(i=n[0]))return a;for(n=n[1],r=0;r=0;u--)l=m(i,r),i=d(i,r),s[u]=g(l)}else{if(!(o=n.length))return[];for(s=new Array(o),i=t,u=o-1;u>=0;u--)l=m(i,r=n[u]),i=d(i,r),s[u]=g(l)}s=this.DUAL(s,n,e)}return s},gray:function(t,n){return qt(new Array(t.length),t,n)},inversion:function(t){var n,e=t.length,i=e?[0]:[];for(n=1;n=t+e[n].length&&(t+=e[n++].length),t+e[n][i-t]})},component:function(t,n){return null==t?null:null==n?t:vt(t.length,function(e){return e=t.length||null==t[e])return n[e];var i=t[e];return ht(i)?n[e]+i:i[0]*n[e]+(i[1]||0)})}:lt},conditional:$n,generate:function(t,n,e,i,r){r=r||{},e=e||vt(n.length||0,0,1);var u,l,s,o,f,c,h,a,m,d,g=null==r.min?0:r.min,_=null==r.max?t-1:r.max,v=_-g+1,p=n,b=p.length,A=!1,y=[],q=[],x={},I=function(t){return g<=t&&t<=_};for(n=[],A=!1,c=0,s=0;su[1]?Dn(t,vt(u[0]-u[1]+1,u[1],1).filter(I)).reverse():Dn(t,vt(u[1]-u[0]+1,u[0],1).filter(I)):Dn(t,u[1].split(",").map(Number).filter(I))).length){A=!0;break}n.push(o)}else if(u=l.match(C)){if(!(o=0u[1]?vt(u[0]-u[1]+1,u[0],-1):vt(u[1]-u[0]+1,u[0],1)).filter(I):u[1].split(",").map(Number).filter(I)).length){A=!0;break}n.push(o)}else{if(a=!0,h=[],m=null,l=l.replace(M,function(t,n){var e=parseInt(n,10),i="v"+String(e);return!isNaN(e)&&I(e)||(a=!1),a&&-1===h.indexOf(e)&&h.push(e),i}),!a){e&&e.splice(c--,1);continue}h.sort(Mt());try{m=new Function(h.map(function(t){return"v"+String(t)}).join(","),"return Math.floor("+l+");")}catch(t){m=null}if(!at(m)){e&&e.splice(c--,1);continue}for(f=0;fn||n>_))return!1;return!0})).length){A=!0;break}n[u[1][f]]=o}if(A)break}return A?[]:(i="="===i?Z:"!="===i||"<>"===i?G:"<"===i?z:"<="===i||"=<"===i?H:">"===i?B:(">="===i||"=>"===i)&&V,d=at(r.extra_conditions)?function(t,n,u){var l=t[n];return!(g>l||l>_||z===i&&e[n]>l||B===i&&e[e.length-1]-e[n]>l)&&r.extra_conditions(t,n,u)}:function(t,n,r){var u=t[n];return!(g>u||u>_||z===i&&e[n]>u||B===i&&e[e.length-1]-e[n]>u)},!0===r.lazy?n:$n(n,i,d))}}}),x.Permutation=F(e,{constructor:function t(n,i){var r=null;if(!(this instanceof t))return new t(n,i);(i=i||{}).type=String(i.type||"permutation").toLowerCase(),(n=n||0)instanceof e?n=(r=n).dimension():r=i.sub,i.base=i.dimension=n,i.rand=i.rand||{},i.rand.derangement=1,i.rand.involution=1,i.rand.connected=1,"multiset"===i.type&&(i.multiplicity=st(i.multiplicity)&&i.multiplicity.length?i.multiplicity.slice():vt(n,1,0),i.multiplicity=i.multiplicity.concat(vt(n-_t(kt,0,i.multiplicity),1,0)),i.base=i.multiplicity.length,i.multiset=Un(i.multiplicity,n)),e.call(this,"Permutation",n,i,r?{method:i.submethod,iter:r,pos:i.subpos,cascade:i.subcascade}:null)},__static__:{C:e.C,P:e.P,T:e.T,DUAL:e.DUAL,count:function(t,n){var e=x.Arithmetic,i=e.O,r=n&&n.type?n.type:"permutation",u=n&&null!=n["cycles="]?0|n["cycles="]:null,l=n&&null!=n["fixed="]?0|n["fixed="]:null;return 0>t?i:"cyclic"===r?e.num(t):"multiset"===r?An(t,n.multiplicity):"derangement"===r?l?2>t-l?i:e.mul(An(t,l),An(t-l,!1)):2>t?i:An(t,!1):"involution"===r?An(t,!0):"connected"===r?An(t-1):u?yn(t,u,1):An(t)},initial:function(t,n,e){var i,r=n&&n.type?n.type:"permutation",u=n&&null!=-n.order?n.order:Q,l=n&&null!=n["cycles="]?0|n["cycles="]:null,s=n&&null!=n["fixed="]?0|n["fixed="]:null;if(0===t)return[];if(e=-1===e?-1:1,(!(tt&u)&&K&u||tt&u&&!(K&u))&&(e=-e),"cyclic"===r)i=0>e?[t-1].concat(vt(t-1,0,1)):vt(t,0,1);else if("derangement"===r){if(s||2>t)return null;if(1&t){var o=I.floor(t/2);i=0>e?vt(t-o-1,t-1,-1).concat([o-1,o]).concat(vt(o-1,o-2,-1)):vt(t-3,function(t){return 1&t?t-1:t+1}).concat([t-2,t-1,t-3])}else i=0>e?vt(t,t-1,-1):vt(t,function(t){return 1&t?t-1:t+1})}else i="multiset"===r?0>e?n.multiset.slice().reverse():n.multiset.slice():"connected"===r?null:"involution"===r?0>e?vt(t,t-1,-1):vt(t,0,1):l?null:0>e?vt(t,t-1,-1):vt(t,0,1);return i=this.DUAL(i,t,n)},succ:function(t,n,e,i,r,u){if(!e||0>=e||null==t)return null;var l=i&&i.type?i.type:"permutation",s=i&&null!=i["cycles="]?0|i["cycles="]:null,o=i&&null!=i["fixed="]?0|i["fixed="]:null;return"derangement"===l&&o||"permutation"===l&&s?null:function(t,n,e,i,r,u,l){var s,o,f,c,h,a,m,d,g,_,v,p,b,A=n,y=null==u?A:u;0,d=1,m=b=A-1,g=1,_=0,v=1,p=0,tt&r&&(d=-d,m=b-m,g=-g,_=y-1-_,e=-e);Y&r&&(d=-d,m=b-m,v=-1,p=y-1);K&r&&(e=-e);if(0>e)if("cyclic"===i)if(g*t[s=b-m]+_>0)for(v=A-1,d=A+d,f=0;f0&&g*t[s]<=g*t[o];)o-=d;for(h=t[s],t[s]=t[o],t[o]=h,f=s+d,c=m;0<=f&&f<=b&&0<=c&&c<=b&&d*(c-f)>0;)h=t[f],t[f]=t[c],t[c]=h,a=a||v*f+p===t[f]||v*c+p===t[c],f+=d,c-=d;if("derangement"===i)for(0<=o&&o<=b&&(a=a||v*o+p===t[o]),0<=c&&c<=b&&(a=a||v*c+p===t[c]),a=a||v*s+p===t[s],f=s-d;!a&&0<=f&&f<=b;f-=d)a=v*f+p===t[f];else a=!1}else t=null}while(t&&a);else if("cyclic"===i)if(g*t[s=b-m]+_=g*t[s+d];)s-=d;if(0<=s&&s<=b){for(o=m;0<=o&&o<=b&&d*(o-s)>0&&g*t[s]>=g*t[o];)o-=d;for(h=t[s],t[s]=t[o],t[o]=h,f=s+d,c=m;0<=f&&f<=b&&0<=c&&c<=b&&d*(c-f)>0;)h=t[f],t[f]=t[c],t[c]=h,a=a||v*f+p===t[f]||v*c+p===t[c],f+=d,c-=d;if("derangement"===i)for(0<=o&&o<=b&&(a=a||v*o+p===t[o]),0<=c&&c<=b&&(a=a||v*c+p===t[c]),a=a||v*s+p===t[s],f=s-d;!a&&0<=f&&f<=b;f-=d)a=v*f+p===t[f];else a=!1}else t=null}while(t&&a);return t}(t,e,r=-1===r?-1:1,l,i&&null!=i.order?i.order:Q,i&&null!=i.base?i.base:null)},rand:function(t,n){var e,i=x.Math.rndInt,r=n&&n.type?n.type:"permutation",u=n&&null!=n["cycles="]?0|n["cycles="]:null,l=n&&null!=n["fixed="]?0|n["fixed="]:null;if(0===t)return[];if("cyclic"===r){var s=i(0,t-1);e=0v&&(m=y[a=i(0,b-1)],--b,g=y[a],y[a]=y[b],y[b]=g,g=e[m],e[m]=e[h],e[h]=g)}else if("multiset"===r)e=Et(n.multiset.slice());else if("connected"===r)e=Et(vt(t,0,1),!0);else{if(u)return null;e=Et(vt(t,0,1))}return e=this.DUAL(e,t,n)},randu:e.rand,rank:function(t,n,e){var i,r,u,l,s,o=x.Arithmetic,f=e&&e.type?e.type:"permutation",c=e&&null!=e["cycles="]?0|e["cycles="]:null,h=(e&&null!=e["fixed="]&&e["fixed="],e&&null!=-e.order?e.order:Q),a=o.sub,m=o.add,d=o.mul,g=o.div,_=o.O,v=o.I,p=o.J;if(!(n=n||t.length))return _;if(t=this.DUAL(t,n,e),"cyclic"===f)_=o.num(t[0]);else{if("derangement"===f||"involution"===f||"connected"===f)return ut();if("multiset"===f)for(s=e.multiplicity.slice(),l=e&&null!=e.count?e.count:An(n,s),u=n-1,i=0;i=0;u--)o=g(r,s=n-u),r=_(r,s),i[u]=b(o);Jn(i,i)}}return i=this.DUAL(i,n,e)},permute:Wn,shuffle:function(t,n){if("cyclic"===n){var e=t.length,i=x.Math.rndInt(0,e-1);return 0=n+i&&(n+=i,i=t[++e].length),n+t[e][r-n]})}(st(arguments[0])&&st(arguments[0][0])?arguments[0]:N.call(arguments)):null},cycles:function(t,n){return-1===n?cycles2permutation(t):Fn(t)},swaps:function(t,n){return-1===n?function(t,n){var e,i,r,u=t.length,l=new Array(n);for(e=0;e=l&&(r=0,i++);else for(i=0,r=0;i=l&&(r=0,i++);return t}(null,t,n):function(t,n,e){var i,r,u=n.length,l=u*u;for(t=t||new Array(l),i=0,r=0;i=u&&(r=0,i+=u);if(!0===e)for(i=0;i(i=t[e])||i>=n||0n)return!1;return!0!==e||i===n},isInvolution:function(t){for(var n=t.length,e=0,i=t[e];ei||n<=i||t[i]!==e)return!1;return!0},isKthroot:function(t,n){if(1>(n=n||1))return!1;var e,i,r,u=t.length;for(e=0;e=n||0e&&(e=r),e<=i)return!1;return!0},isKcycle:function(t,n,e,i){if(!t.length||0>=n)return!1;i=!1!==i;var r,u,l,s,o,f=t.length;for(r=0,l=0,o=0,s=new Array(f);o="===e||"=>"===e?l>=n:l===n}},_update:function(){return this.item__=(this.__item,this.n,this.$.order,this.$.type,null),this}}),(b=x.Combination=F(e,{constructor:function t(n,i,r){var u=null;if(!(this instanceof t))return new t(n,i,r);if(st(n)||ot(n)?(r=i||{},i=n[1]||0,n=n[0]||0):(r=r||{},n=n||0,i=i||0),r.type=String(r.type||"combination").toLowerCase(),-1e?t[0]-1:0,0):"ordered"===r||"variation"===r?0>e?vt(t[1],t[0]-1,-1):vt(t[1],0,1):vt(t[1],0>e?t[0]-t[1]:0,1),i=this.DUAL(i,t,n))},succ:function(t,n,e,i,r,u){return!e||!e[0]||0>=e[0]||0===e[1]||null==t?null:function(t,n,e,i,r,u){var l,s,o,f,c,h,a,m,d,g,_,v,p,b=n[1],A=n[0];0,h=1,c=a=b-1,m=1,d=0,g=1,_=0,tt&r&&(m=-m,d=A-1-d,h=-h,c=a-c,g=-g,_=a-_);Y&r&&(h=-h,c=a-c,g=-g,_=a-_);K&r&&(e=-e);if(0>e)if("ordered+repeated"===i||"variation+repeated"===i||"repeated+variation"===i){for(l=c;0<=l&&l<=a&&0===t[l];)l-=h;if(0<=l&&l<=a)for(A-=1,t[l]=t[l]-1,s=l+h;0<=s&&s<=a;s+=h)t[s]=A;else t=null}else if("ordered"===i||"variation"===i){for(null==u&&(u=Bn(t,A,b,r,i)),l=c,o=-1;-1===o&&0<=l&&l<=a;){if(m*t[l]+d-m>=0)for(s=m*t[l]+d-m;0<=s&&s(h=-h)?0:a,!p&&t[s]+1>b||p&&t[s]>0){if(p)for(;0<=l&&l<=a&&0===t[l];)l+=h;else for(;0<=l&&l<=a&&g*l+_===t[l];)l+=h;for(t[l]-=1,l-=h;0<=l&&l<=a;)t[l]=t[l+h]-v,l-=h}else t=null;else{for(o=-1,l=c;0<=l-h&&l-h<=a;l-=h)if(t[l]>t[l-h]+v){o=l;break}if(!(0<=o&&o<=a)&&0h?a:0]&&(o=0>h?a:0),0<=o&&o<=a){for(f=A-1+v,l=c;0<=l&&l<=a&&0=0;o--)s=g(l,n),l=d(l,n),i[o]=b(s);else if("ordered"===y||"variation"===y){for(l=t,o=A-1;o>=0;o--)s=g(l,u=n-o),l=d(l,u),i[o]=b(s);Jn(i,i,u)}else{u=(f="repeated"===y||"combination+repeated"===y)?n+A-1:n,t=m(m(r=e&&e.count?e.count:An(u,A),a),t),r=d(_(r,u-A),u),s=u-A+1,l=A,o=u-1;do{v(r,t)?(i[A-l]=f?u-s-A+1:u-s-l+1,p(r,h)&&(t=m(t,r),r=d(_(r,l),o)),l--,o--):(r=d(_(r,o-l),o),s--,o--)}while(l>0)}return i=this.DUAL(i,n,e)},complement:function(t,n,e){return!0===e?Et(Dn(n,t,!0)):Dn(n,t)},binary:function(t,n,e){return-1===e?Mn(t,n):Ln(t,n)},pick:function(t,n,e){return 0e&&_t(function(t,n){i[n]=n},null,null,0,t,1):0>e&&(i[0]=t-1,i[t]=1),i=this.DUAL(i,t,n,1)},succ:function(t,n,i,r,u,l){return null==t?null:r&&"binary"===r.type?e.succ.call(this,t,n,i,r,u):function(t,n,e,i){var r,u,l,s,o,f,c=n,h=n-1;if(s=1,1,0,tt&i)return null;Y&i&&(s=-s);K&i&&(e=-e);0>s?(r=n-(t[c]||1),o=u=n-1,f=r):(r=0,u=t[c]-1,o=r,f=u);0>e?00?1===t[c]||l>t[f-s]+1?(t[f]-=1,t[f+s]=h,t[c]++):t[c]--:t[c]=0:t=null:0===t[c]?(t[r]=0,t[c]=1):1*t[o]+0=0;u--)i(0,1)&&(r={len:r?r.len+1:1,k:u,next:r});return e=(e=r?vt(r.len,function(t){var n=r.k;return r=r.next,n}):[]).concat(e.length=t||o&&s&&(o+s>t+1||o*st||s&&s>t?null:(e=-1===e?-1:1,(!(tt&f)&&K&f||tt&f&&!(K&f))&&(e=-e),(i=new Array(c+1))[c]=0,o&&s?(i[c]=o,1===o&&(i[0]=s),h?(i=_t(function(t,n,e){return t[e]=n,t},i,[(t-s)%(u=I.min(s,I.ceil((t-s)/(o-1))))||u].concat(vt(o-2,u,0)).concat([s])),0>e&&At(i,i,0,0,o-1)):0>e?(o-=r=I.min(o,I.floor(t/s)||1),0===(t-=r*s)&&0e&&At(i,i,0,0,o-1)):(r=t%(u=I.ceil(t/o))||u,i=_t(function(t,n,e){return t[e]=n,t},i,0>e?[t-o+1].concat(vt(o-1,1,0)):vt(o-1,u,0).concat([r])))):s?(r=I.floor(t/s),u=t%s,i=_t(function(t,n,e){return t[e]=n,t[c]++,t},i,h?0>e?vt(r,s,0).concat(u?[u]:[]):vt(t-s,1,0).concat([s]):0>e?vt(r,s,0).concat(u?[u]:[]):[s].concat(vt(t-s,1,0)))):i=_t(function(t,n,e){return t[e]=n,t[c]++,t},i,0>e?[t]:vt(t,1,0)),i=this.DUAL(i,t,n,1))},succ:function(t,n,e,i,r,u){if(null==e||null==t)return null;var l=i&&i.type?i.type:"partition",s=i&&i["max="]?0|i["max="]:null,o=i&&i["parts="]?0|i["parts="]:null;return 0>=e||o&&s&&(o+s>e+1||o*se||s&&s>e?null:(r=-1===r?-1:1,"composition"===l?function(t,n,e,i,r,u,l){var s,o,f,c,h,a,m,d,g=n,_=i||(r?g-r+1:g);a=1,Y&u&&(a=-a);K&u&&(e=-e);0>a?(m=_-(t[_]||1),o=d=_-1,f=m):(m=0,d=t[_]-1,o=m,f=d);if(0>e)if(i)if(r)t=null;else if(tt&u)if(c=t[o],g-i+1>c){for(t[o]=1,s=o+a;m<=s&&s<=d&&1===t[s];)s+=a;t[s]--,m<=s-a&&s-a<=d&&(t[s-a]=1+c)}else t=null;else if(c=t[f],g-i+1>c){for(t[f]=1,s=f;m<=s&&s<=d&&1===t[s];)s-=a;t[s]--,m<=s+a&&s+a<=d&&(t[s+a]=1+c)}else t=null;else if(r)t=null;else if(tt&u)t=null;else if(g>t[_]){for(s=f,h=0;m<=s&&s<=d&&1===t[s];)s-=a,h++;if(c=t[s]-1,t[s]=c,0<++h)if(m<=s+a&&s+a<=d)t[s+=a]=h,h=0,t[_]=0>a?_-s:s+1;else for(;0t[f]){for(s=o;m<=s&&s<=d&&1===t[s];)s+=a;c=t[s],t[s]=1,t[o]=c-1,m<=s+a&&s+a<=d&&t[s+a]++}else t=null;else if(g-i+1>t[o]){for(s=f;m<=s&&s<=d&&1===t[s];)s-=a;c=t[s],t[s]=1,t[f]=c-1,m<=s-a&&s-a<=d&&t[s-a]++}else t=null;else if(r)t=null;else if(tt&u)t=null;else if(g>t[o])for(h=t[f],t[f-a]++,t[_]--,s=f-a,h--;0d?(g=p-(t[p]||1),f=_=p-1,c=g):(g=0,_=t[p]-1,f=g,c=_);if(0>e)if(i)t=null;else if(tt&u)t=null;else if(g<=(o=r?f+d:f)&&o<=_&&t[o]>1){for(s=c,m=0;g<=s&&s<=_&&d*(s-o)>=0&&1===t[s];)m+=t[s],s-=d;if(a=t[s]-1,m++,t[s]=a,t[p]=0>d?p-s:s+1,ah||t[f+(h-1)*d]0&&t[s]===t[s-d];)m+=t[s],s-=d;for(t[s]++,m--,t[p]=0>d?p-s:s+1;0=t||h&&c&&(h+c>t+1||h*ct||c&&c>t)return null;if(h&&c)return null;if(c&&!h&&(h=c,_=!0),h)1===h?(i=[t],m=t):t===h?(i=vt(h,1,0),m=t):(e={},r=t-2,vt(i=Rt(vt(h-1,function(){for(l=o(0,r);1===e[l];)l=(l+1)%(r+1);return e[l]=1,l+1})),function(t){return l=i[t],u=l-a,a=l,m+=u,u}));else{for(e=null,l=1;l(i=t[0].indexOf(r))||0(i=t[0].indexOf(r))||0>>1,h=new Array(u);for(n=0;nu||n!==h[i-1][0]||0!==h[i-1][1])return!1;if(l=i,h[(i=t[0][n])-1]||(h[i-1]=[0,n]),i<1||i>u||0!==h[i-1][0]||n!==h[i-1][1])return!1;for(s=i,o+=t[n][n],f+=t[n][r-1-n],e=1;eu||n!==h[i-1][0]||e!==h[i-1][1])return!1;if(l+=i,h[(i=t[e][n])-1]||(h[i-1]=[e,n]),i<1||i>u||e!==h[i-1][0]||n!==h[i-1][1])return!1;s+=i}if(l!==c||s!==c)return!1}return o===c&&f===c},make:function t(n){if(0>=n||2===n)return null;if(1===n)return[[1]];var e,i,r,u,l,s,o,f,c,h,a,m,d,g,_,v=1&n,p=0==(3&n),b=n*n,A=n-v>>>1;for(_=new Array(n),e=0;e=n&&(e++,i=0),_[e][i]=(d+i-e)%n*n+(g+e+i)%n+1;else if(p)for(r=0,e=0,i=0;r=n&&(e++,i=0),_[e][i]=(e+1&3)>>>1==(i+1&3)>>>1?b-r:r+1;else{for(u=t(A),c=(f=(o=s=A*A)<<1)+s,r=0,e=0,i=0;r=A&&(e++,i=0),l=u[e][i],_[e][i]=l,_[e+A][i+A]=l+o,_[e+A][i]=l+f,_[e][i+A]=l+c;for(a=h=A>>>1,i=0;in-a||e===h&&i===h)||0===e&&i===h||(m=_[e][i],_[e][i]=_[e][i+A],_[e][i+A]=m)}return _},product:function(){if(1>=arguments.length)return arguments[0];for(var t,n,e,i,r,u,l,s,o,f,c,h,a,m=arguments,d=m.length,g=m[0],_=1;_=r&&(a=0,++c>=r&&(o+=r,c=0,a=0,++h>=i&&(f++,s+=r,h=0,o=0,c=0,a=0),f0?new Array(e+1).join("0")+n:n}function gt(t){var n=String(t).split("_");return n[0]+(n.length>1?"_{"+n[1]+"}":"")}function _t(t){return"function"==typeof t.toTex?t.toTex():String(t)}function vt(t,n,e,i,r,u,l){var s,o,f,c,h,a,m,d,g=n,_=null,v=e&&(ot(e)||ft(e));if(v&&(null==i&&(i=0),null==r&&(r=e.length-1)),null==u&&(u=i>r?-1:1),0===u||v&&!e.length||0>=w.floor((r-i)/u)+1)return g;if(0>u?((d=(i-r)%-u)&&(_=r),a=r+=d,m=i,c=-1,f=-(-u<<4)):((d=(r-i)%u)&&(_=r),a=i,m=r-=d,c=1,f=u<<4),h=i+u*(15&w.floor((r-i)/u+1)),v){for(a=w.max(0,a),m=w.min(e.length-1,m),s=i;a<=s&&s<=m&&00?new Array(t):[];if(0<(t=i.length)&&null!=n){e=e||0;var r=n;vt(mt(n)?function(t,e,i){return t[i]=n(i),t}:n===+n?function(t,n,i){return t[i]=r,r+=e,t}:function(t,e,i){return t[i]=n,t},i,i)}return i}function bt(t,n,e){return vt(function(t,n,i){return t[i]=n[e],t},t,n)}function At(t,n,e,i,r){return null==n?t:vt(ot(e)?function(t,n,i){return t[i]=e[i]-1-n,t}:function(t,n,i){return t[i]=e-1-n,t},t,n,i,r)}function yt(t,n,e,i,r){if(null==n)return t;if(null==i&&(i=0),null==r&&(r=n.length-1),t!==n||i0?(n+u)%e[i]:0,u+=e[i]-t[i],t}:function(t,n,i){return t[i]=(n+u)%e,u+=e-t[i],t},t,n,i,r)}function It(t,n,e,i,r){return null==n?t:(null==r&&(r=n.length-1),null==i&&(i=0),t!==n||0!==e?vt(function(t,n,i){return t[i+e]=n,t},t,n,0>e?i:r,0>e?r:i,0>e?1:-1):t)}function Ot(t,n,e,i,r,u,l,s){if(null==n)return null;null==e&&(e=1),null==i&&(i=0),null==r&&(r=0),null==u&&(u=n.length-1),null==l&&(l=r),null==s&&(s=u);var o=0,f=l>s?-1:1,c=l;return vt(function(t,n,r){return n=i+e*n,t[c]=n-o,o=n,c+=f,t},t,n,r,u)}function wt(t,n,e,i,r,u,l,s){if(null==n)return null;null==e&&(e=1),null==i&&(i=0),null==r&&(r=0),null==u&&(u=n.length-1),null==l&&(l=r),null==s&&(s=u);var o=0,f=l>s?-1:1,c=l;return vt(function(t,n,r){return o+=n,t[c]=i+e*o,c+=f,t},t,n,r,u)}function St(t,n,e,i,r,u,l,s,o){o=!0===o,i=-1===i?-1:1,null==r&&(r=0),null==u&&(u=n===+n?n-1:n.length-1),null==l&&(l=0),null==s&&(s=e?e.length-1:-1);var f=r>u?-1:1,c=l>s?-1:1,h=f*(u-r)+1,a=r,m=l,d=0;if(!e||!e.length)return n===+n?pt(n,r,f):n?n.slice():n;if(null==t&&(t=new Array(o?2*h:h)),n===+n){for(;0<=f*(u-a)&&0<=c*(s-m);)a===e[m]?(o&&(t[d++]=a),a+=f,m+=c):1===i&&a>e[m]||-1===i&&ae[m]||-1===i&&n[a]u?-1:1,a=l>s?-1:1,m=h*(u-r)+1+(a*(s-l)+1),d=r,g=l,_=0,v=null,p=!f;if(null==t&&(t=new Array(m)),0===t.length)return c?n:t;for(;0<=h*(u-d)&&0<=a*(s-g);){if(f&&_){if(n[d]===v){d+=h;continue}if(e[g]===v){g+=a;continue}}o?1===i&&n[d][0]e[g][0]?(t[_++]=v=n[d],d+=h):1===i&&n[d][0]>e[g][0]||-1===i&&n[d][0]e[g][1]?(t[_++]=v=n[d],p&&(t[_++]=e[g])):(t[_++]=v=e[g],p&&(t[_++]=n[d])),d+=h,g+=a):1===i&&n[d]e[g]?(t[_++]=v=n[d],d+=h):1===i&&n[d]>e[g]||-1===i&&n[d]h?u:r,_=0;_l){if(1===c){f=s-1;break}0===c&&(c=-1)}u=l}if(0===c&&(c=1),-1===f)f=e,i[0]=o,i[1]=f,i[2]=c;else{for(h=f+1,a=-1,u=r?t[h][0]:t[h],s=h+1;s<=e;s++){if(u<(l=r?t[s][0]:t[s])){if(-1===m){a=s-1;break}0===m&&(m=1)}else if(u>l){if(1===m){a=s-1;break}0===m&&(m=-1)}u=l}-1===a&&(a=e),0===m&&(m=1),i[0]=o,i[1]=f,i[2]=c,i[3]=h,i[4]=a,i[5]=m}}function $t(t,n,e,i,r,u){null==r&&(r=0),null==u&&(u=t.length-1);var l=r>u?-1:1,s=l*(u-r)+1;if(i=!0===i,1>=s)return i?1===s?[r]:[]:t;n=-1===n?-1:1;var o,f,c,h,a,m=s,d=1,g=2,_=w.min,v=new Array(s);if(i&&(t=vt(function(t,n,e){return t[e-r]=[n,e],t},new Array(s),t,r,u,1),r=0,u=s-1),!0===e){h=r,a=-1,o=[-1,-1,0,-1,-1,0];do{Rt(t,r,u,o,i),-1===o[3]?(n!==o[2]&&r>=1;return i?bt(t,t,1):t}function Et(t,n,e,i){var r,u,l,s=t.length;if(null==e&&(e=0),null==i&&(i=s-1),null==n||0===n){for(n=0,u=t[e],r=e+1;r<=i;r++){if(u<(l=t[r])){if(-1===n)return 0;0===n&&(n=1)}else if(u>l){if(1===n)return 0;0===n&&(n=-1)}u=l}return 0===n?1:n}if(n=-1===n?-1:1,e>=i)return n;if(-1===n)for(u=t[e],r=e+1;r<=i;r++){if(u<(l=t[r]))return 0;u=l}else for(u=t[e],r=e+1;r<=i;r++){if(u>(l=t[r]))return 0;u=l}return n}function Ct(t,n,e,i){var r,u=I.Math.rndInt,l=!0===n?1:0;return ot(e)?1<(r=e.length)&&vt(function(t){if(l=0;o--)f=r[o],c=t[u+a],t[u+a]=t[u+f],t[u+f]=c,a++;return e&&$t(s),s}function Mt(t,n,e,i,r,u){var l;if(u=u||function(t,n){return ti)return-1;if(-1===(e=-1===e?-1:1))for(;i>>1],n)?i=l+1:r=l;else for(;i>>1])?r=l:i=l+1;return i}function kt(t){return!0===t?function(t,n){return t.equ(n)?0:t.lt(n)?-1:1}:t?function(n,e){return t.equ(n,e)?0:t.lt(n,e)?-1:1}:function(t,n){return t===n?0:t>=1,t=Pt(t,t,e);else for(i=u.II;!u.equ(n,l);)u.equ(s,u.mod(n,i))&&(r=Pt(r,t,e)),n=u.div(n,i),t=Pt(t,t,e);return r}function Ft(t){var n,e,i,r,u,l,s=I.Arithmetic,o=(s.num,s.O),f=s.I;if(s.equ(t,o)||s.equ(t,f))return t;if(s.isDefault()||s.lte(t,W))return s.num(w.floor(w.sqrt(s.val(t))));for(l=s.II,n=f,e=s.div(t,l),u=n;s.lte(n,e);){if(i=s.div(s.add(n,e),l),r=s.mul(i,i),s.equ(r,t))return i;s.lt(r,t)?(n=s.add(i,f),u=i):e=s.sub(i,f)}return u}function Zt(t,n,e){var i,r,u,l,s,o,f=I.Arithmetic,c=f.num,h=f.O,a=f.J,m=f.I,d=f.II;if(f.lt(n,h)||f.equ(h,f.mod(n,d)))return null;if((f.lt(t,h)||f.gt(t,n))&&(t=f.mod(t,n)),f.equ(h,t))return f.equ(m,n)?m:h;if(f.equ(m,n)||f.equ(m,t))return m;if(null==e&&(e=un(t,n)),!f.equ(m,e))return h;for(u=c(3),l=c(4),s=c(5),o=c(8),i=m,f.lt(t,h)&&(t=f.mul(a,t),f.equ(f.mod(n,l),u)&&(i=f.mul(a,i)));!f.equ(h,t);){for(;f.gt(t,h)&&f.equ(h,f.mod(t,d));)t=f.div(t,d),r=f.mod(n,o),(f.equ(r,u)||f.equ(r,s))&&(i=f.mul(a,i));r=t,t=n,n=r,f.equ(u,f.mod(t,l))&&f.equ(u,f.mod(n,l))&&(i=f.mul(a,i)),t=f.mod(t,n)}return f.equ(m,n)||(i=h),i}function Wt(t,n){var e=I.Arithmetic,i=(e.num,e.I),r=e.II;return Xt(t,e.div(e.sub(n,i),r),n)}function zt(t,n){var e=I.Arithmetic,i=e.O,r=e.I,u=i;if(e.lt(n,e.II))return i;if(e.lte(t,n))return e.equ(t,n)?r:i;if(e.isDefault()||e.lte(t,W))return e.num(w.floor(w.log(e.val(t))/w.log(e.val(n))));for(;e.gte(t,n);)t=e.div(t,n),u=e.add(u,r);return u}function Gt(){var t=I.Arithmetic.num;return Gt.list||(Gt.list=[t(2),t(3),t(5),t(7),t(11),t(13),t(17),t(19),t(23),t(29),t(31),t(37),t(41),t(43),t(47),t(53),t(59),t(61),t(67),t(71),t(73),t(79),t(83),t(89),t(97),t(101),t(103),t(107),t(109),t(113),t(127),t(131),t(137),t(139),t(149),t(151),t(157),t(163),t(167),t(173),t(179),t(181),t(191),t(193),t(197),t(199),t(211),t(223),t(227),t(229),t(233),t(239),t(241),t(251),t(257),t(263),t(269),t(271),t(277),t(281),t(283),t(293),t(307),t(311),t(313),t(317),t(331),t(337),t(347),t(349),t(353),t(359),t(367),t(373),t(379),t(383),t(389),t(397),t(401),t(409),t(419),t(421),t(431),t(433),t(439),t(443),t(449),t(457),t(461),t(463),t(467),t(479),t(487),t(491),t(499),t(503),t(509),t(521),t(523),t(541),t(547),t(557),t(563),t(569),t(571),t(577),t(587),t(593),t(599),t(601),t(607),t(613),t(617),t(619),t(631),t(641),t(643),t(647),t(653),t(659),t(661),t(673),t(677),t(683),t(691),t(701),t(709),t(719),t(727),t(733),t(739),t(743),t(751),t(757),t(761),t(769),t(773),t(787),t(797),t(809),t(811),t(821),t(823),t(827),t(829),t(839),t(853),t(857),t(859),t(863),t(877),t(881),t(883),t(887),t(907),t(911),t(919),t(929),t(937),t(941),t(947),t(953),t(967),t(971),t(977),t(983),t(991),t(997),t(1009),t(1013),t(1019),t(1021),t(1031),t(1033),t(1039),t(1049),t(1051),t(1061),t(1063),t(1069),t(1087),t(1091),t(1093),t(1097),t(1103),t(1109),t(1117),t(1123),t(1129),t(1151),t(1153),t(1163),t(1171),t(1181),t(1187),t(1193),t(1201),t(1213),t(1217),t(1223),t(1229),t(1231),t(1237),t(1249),t(1259),t(1277),t(1279),t(1283),t(1289),t(1291),t(1297),t(1301),t(1303),t(1307),t(1319),t(1321),t(1327),t(1361),t(1367),t(1373),t(1381),t(1399),t(1409),t(1423),t(1427),t(1429),t(1433),t(1439),t(1447),t(1451),t(1453),t(1459),t(1471),t(1481),t(1483),t(1487),t(1489),t(1493),t(1499),t(1511),t(1523),t(1531),t(1543),t(1549),t(1553),t(1559),t(1567),t(1571),t(1579),t(1583),t(1597),t(1601),t(1607),t(1609),t(1613),t(1619),t(1621),t(1627),t(1637),t(1657),t(1663),t(1667),t(1669),t(1693),t(1697),t(1699),t(1709),t(1721),t(1723),t(1733),t(1741),t(1747),t(1753),t(1759),t(1777),t(1783),t(1787),t(1789),t(1801),t(1811),t(1823),t(1831),t(1847),t(1861),t(1867),t(1871),t(1873),t(1877),t(1879),t(1889),t(1901),t(1907),t(1913),t(1931),t(1933),t(1949),t(1951),t(1973),t(1979),t(1987),t(1993),t(1997),t(1999),t(2003),t(2011),t(2017),t(2027),t(2029),t(2039),t(2053),t(2063),t(2069),t(2081),t(2083),t(2087),t(2089),t(2099),t(2111),t(2113),t(2129),t(2131),t(2137),t(2141),t(2143),t(2153),t(2161),t(2179),t(2203),t(2207),t(2213),t(2221),t(2237),t(2239),t(2243),t(2251),t(2267),t(2269),t(2273),t(2281),t(2287),t(2293),t(2297),t(2309),t(2311),t(2333),t(2339),t(2341),t(2347),t(2351),t(2357),t(2371),t(2377),t(2381),t(2383),t(2389),t(2393),t(2399),t(2411),t(2417),t(2423),t(2437),t(2441),t(2447),t(2459),t(2467),t(2473),t(2477),t(2503),t(2521),t(2531),t(2539),t(2543),t(2549),t(2551),t(2557),t(2579),t(2591),t(2593),t(2609),t(2617),t(2621),t(2633),t(2647),t(2657),t(2659),t(2663),t(2671),t(2677),t(2683),t(2687),t(2689),t(2693),t(2699),t(2707),t(2711),t(2713),t(2719),t(2729),t(2731),t(2741),t(2749),t(2753),t(2767),t(2777),t(2789),t(2791),t(2797),t(2801),t(2803),t(2819),t(2833),t(2837),t(2843),t(2851),t(2857),t(2861),t(2879),t(2887),t(2897),t(2903),t(2909),t(2917),t(2927),t(2939),t(2953),t(2957),t(2963),t(2969),t(2971),t(2999),t(3001),t(3011),t(3019),t(3023),t(3037),t(3041),t(3049),t(3061),t(3067),t(3079),t(3083),t(3089),t(3109),t(3119),t(3121),t(3137),t(3163),t(3167),t(3169),t(3181),t(3187),t(3191),t(3203),t(3209),t(3217),t(3221),t(3229),t(3251),t(3253),t(3257),t(3259),t(3271),t(3299),t(3301),t(3307),t(3313),t(3319),t(3323),t(3329),t(3331),t(3343),t(3347),t(3359),t(3361),t(3371),t(3373),t(3389),t(3391),t(3407),t(3413),t(3433),t(3449),t(3457),t(3461),t(3463),t(3467),t(3469),t(3491),t(3499),t(3511),t(3517),t(3527),t(3529),t(3533),t(3539),t(3541),t(3547),t(3557),t(3559),t(3571),t(3581),t(3583),t(3593),t(3607),t(3613),t(3617),t(3623),t(3631),t(3637),t(3643),t(3659),t(3671),t(3673),t(3677),t(3691),t(3697),t(3701),t(3709),t(3719),t(3727),t(3733),t(3739),t(3761),t(3767),t(3769),t(3779),t(3793),t(3797),t(3803),t(3821),t(3823),t(3833),t(3847),t(3851),t(3853),t(3863),t(3877),t(3881),t(3889),t(3907),t(3911),t(3917),t(3919),t(3923),t(3929),t(3931),t(3943),t(3947),t(3967),t(3989),t(4001),t(4003),t(4007),t(4013),t(4019),t(4021),t(4027),t(4049),t(4051),t(4057),t(4073),t(4079),t(4091),t(4093),t(4099),t(4111),t(4127),t(4129),t(4133),t(4139),t(4153),t(4157),t(4159),t(4177),t(4201),t(4211),t(4217),t(4219),t(4229),t(4231),t(4241),t(4243),t(4253),t(4259),t(4261),t(4271),t(4273),t(4283),t(4289),t(4297),t(4327),t(4337),t(4339),t(4349),t(4357),t(4363),t(4373),t(4391),t(4397),t(4409),t(4421),t(4423),t(4441),t(4447),t(4451),t(4457),t(4463),t(4481),t(4483),t(4493),t(4507),t(4513),t(4517),t(4519),t(4523),t(4547),t(4549),t(4561),t(4567),t(4583),t(4591),t(4597),t(4603),t(4621),t(4637),t(4639),t(4643),t(4649),t(4651),t(4657),t(4663),t(4673),t(4679),t(4691),t(4703),t(4721),t(4723),t(4729),t(4733),t(4751),t(4759),t(4783),t(4787),t(4789),t(4793),t(4799),t(4801),t(4813),t(4817),t(4831),t(4861),t(4871),t(4877),t(4889),t(4903),t(4909),t(4919),t(4931),t(4933),t(4937),t(4943),t(4951),t(4957),t(4967),t(4969),t(4973),t(4987),t(4993),t(4999),t(5003),t(5009),t(5011),t(5021),t(5023),t(5039),t(5051),t(5059),t(5077),t(5081),t(5087),t(5099),t(5101),t(5107),t(5113),t(5119),t(5147),t(5153),t(5167),t(5171),t(5179),t(5189),t(5197),t(5209),t(5227),t(5231),t(5233),t(5237),t(5261),t(5273),t(5279),t(5281),t(5297),t(5303),t(5309),t(5323),t(5333),t(5347),t(5351),t(5381),t(5387),t(5393),t(5399),t(5407),t(5413),t(5417),t(5419),t(5431),t(5437),t(5441),t(5443),t(5449),t(5471),t(5477),t(5479),t(5483),t(5501),t(5503),t(5507),t(5519),t(5521),t(5527),t(5531),t(5557),t(5563),t(5569),t(5573),t(5581),t(5591),t(5623),t(5639),t(5641),t(5647),t(5651),t(5653),t(5657),t(5659),t(5669),t(5683),t(5689),t(5693),t(5701),t(5711),t(5717),t(5737),t(5741),t(5743),t(5749),t(5779),t(5783),t(5791),t(5801),t(5807),t(5813),t(5821),t(5827),t(5839),t(5843),t(5849),t(5851),t(5857),t(5861),t(5867),t(5869),t(5879),t(5881),t(5897),t(5903),t(5923),t(5927),t(5939),t(5953),t(5981),t(5987),t(6007),t(6011),t(6029),t(6037),t(6043),t(6047),t(6053),t(6067),t(6073),t(6079),t(6089),t(6091),t(6101),t(6113),t(6121),t(6131),t(6133),t(6143),t(6151),t(6163),t(6173),t(6197),t(6199),t(6203),t(6211),t(6217),t(6221),t(6229),t(6247),t(6257),t(6263),t(6269),t(6271),t(6277),t(6287),t(6299),t(6301),t(6311),t(6317),t(6323),t(6329),t(6337),t(6343),t(6353),t(6359),t(6361),t(6367),t(6373),t(6379),t(6389),t(6397),t(6421),t(6427),t(6449),t(6451),t(6469),t(6473),t(6481),t(6491),t(6521),t(6529),t(6547),t(6551),t(6553),t(6563),t(6569),t(6571),t(6577),t(6581),t(6599),t(6607),t(6619),t(6637),t(6653),t(6659),t(6661),t(6673),t(6679),t(6689),t(6691),t(6701),t(6703),t(6709),t(6719),t(6733),t(6737),t(6761),t(6763),t(6779),t(6781),t(6791),t(6793),t(6803),t(6823),t(6827),t(6829),t(6833),t(6841),t(6857),t(6863),t(6869),t(6871),t(6883),t(6899),t(6907),t(6911),t(6917),t(6947),t(6949),t(6959),t(6961),t(6967),t(6971),t(6977),t(6983),t(6991),t(6997),t(7001),t(7013),t(7019),t(7027),t(7039),t(7043),t(7057),t(7069),t(7079),t(7103),t(7109),t(7121),t(7127),t(7129),t(7151),t(7159),t(7177),t(7187),t(7193),t(7207),t(7211),t(7213),t(7219),t(7229),t(7237),t(7243),t(7247),t(7253),t(7283),t(7297),t(7307),t(7309),t(7321),t(7331),t(7333),t(7349),t(7351),t(7369),t(7393),t(7411),t(7417),t(7433),t(7451),t(7457),t(7459),t(7477),t(7481),t(7487),t(7489),t(7499),t(7507),t(7517),t(7523),t(7529),t(7537),t(7541),t(7547),t(7549),t(7559),t(7561),t(7573),t(7577),t(7583),t(7589),t(7591),t(7603),t(7607),t(7621),t(7639),t(7643),t(7649),t(7669),t(7673),t(7681),t(7687),t(7691),t(7699),t(7703),t(7717),t(7723),t(7727),t(7741),t(7753),t(7757),t(7759),t(7789),t(7793),t(7817),t(7823),t(7829),t(7841),t(7853),t(7867),t(7873),t(7877),t(7879),t(7883),t(7901),t(7907),t(7919),t(7927),t(7933),t(7937),t(7949),t(7951),t(7963),t(7993),t(8009),t(8011),t(8017),t(8039),t(8053),t(8059),t(8069),t(8081),t(8087),t(8089),t(8093),t(8101),t(8111),t(8117),t(8123),t(8147),t(8161),t(8167),t(8171),t(8179),t(8191),t(8209),t(8219),t(8221),t(8231),t(8233),t(8237),t(8243),t(8263),t(8269),t(8273),t(8287),t(8291),t(8293),t(8297),t(8311),t(8317),t(8329),t(8353),t(8363),t(8369),t(8377),t(8387),t(8389),t(8419),t(8423),t(8429),t(8431),t(8443),t(8447),t(8461),t(8467),t(8501),t(8513),t(8521),t(8527),t(8537),t(8539),t(8543),t(8563),t(8573),t(8581),t(8597),t(8599),t(8609),t(8623),t(8627),t(8629),t(8641),t(8647),t(8663),t(8669),t(8677),t(8681),t(8689),t(8693),t(8699),t(8707),t(8713),t(8719),t(8731),t(8737),t(8741),t(8747),t(8753),t(8761),t(8779),t(8783),t(8803),t(8807),t(8819),t(8821),t(8831),t(8837),t(8839),t(8849),t(8861),t(8863),t(8867),t(8887),t(8893),t(8923),t(8929),t(8933),t(8941),t(8951),t(8963),t(8969),t(8971),t(8999),t(9001),t(9007),t(9011),t(9013),t(9029),t(9041),t(9043),t(9049),t(9059),t(9067),t(9091),t(9103),t(9109),t(9127),t(9133),t(9137),t(9151),t(9157),t(9161),t(9173),t(9181),t(9187),t(9199),t(9203),t(9209),t(9221),t(9227),t(9239),t(9241),t(9257),t(9277),t(9281),t(9283),t(9293),t(9311),t(9319),t(9323),t(9337),t(9341),t(9343),t(9349),t(9371),t(9377),t(9391),t(9397),t(9403),t(9413),t(9419),t(9421),t(9431),t(9433),t(9437),t(9439),t(9461),t(9463),t(9467),t(9473),t(9479),t(9491),t(9497),t(9511),t(9521),t(9533),t(9539),t(9547),t(9551),t(9587),t(9601),t(9613),t(9619),t(9623),t(9629),t(9631),t(9643),t(9649),t(9661),t(9677),t(9679),t(9689),t(9697),t(9719),t(9721),t(9733),t(9739),t(9743),t(9749),t(9767),t(9769),t(9781),t(9787),t(9791),t(9803),t(9811),t(9817),t(9829),t(9833),t(9839),t(9851),t(9857),t(9859),t(9871),t(9883),t(9887),t(9901),t(9907),t(9923),t(9929),t(9931),t(9941),t(9949),t(9967),t(9973),t(10007),t(10009),t(10037),t(10039),t(10061),t(10067),t(10069),t(10079),t(10091),t(10093),t(10099),t(10103),t(10111),t(10133),t(10139),t(10141),t(10151),t(10159),t(10163),t(10169),t(10177),t(10181),t(10193),t(10211),t(10223),t(10243),t(10247),t(10253),t(10259),t(10267),t(10271),t(10273),t(10289),t(10301),t(10303),t(10313),t(10321),t(10331),t(10333),t(10337),t(10343),t(10357),t(10369),t(10391),t(10399),t(10427),t(10429),t(10433),t(10453),t(10457),t(10459),t(10463),t(10477),t(10487),t(10499),t(10501),t(10513),t(10529),t(10531),t(10559),t(10567),t(10589),t(10597),t(10601),t(10607),t(10613),t(10627),t(10631),t(10639),t(10651),t(10657),t(10663),t(10667),t(10687),t(10691),t(10709),t(10711),t(10723),t(10729),t(10733),t(10739),t(10753),t(10771),t(10781),t(10789),t(10799),t(10831),t(10837),t(10847),t(10853),t(10859),t(10861),t(10867),t(10883),t(10889),t(10891),t(10903),t(10909),t(10937),t(10939),t(10949),t(10957),t(10973),t(10979),t(10987),t(10993),t(11003),t(11027),t(11047),t(11057),t(11059),t(11069),t(11071),t(11083),t(11087),t(11093),t(11113),t(11117),t(11119),t(11131),t(11149),t(11159),t(11161),t(11171),t(11173),t(11177),t(11197),t(11213),t(11239),t(11243),t(11251),t(11257),t(11261),t(11273),t(11279),t(11287),t(11299),t(11311),t(11317),t(11321),t(11329),t(11351),t(11353),t(11369),t(11383),t(11393),t(11399),t(11411),t(11423),t(11437),t(11443),t(11447),t(11467),t(11471),t(11483),t(11489),t(11491),t(11497),t(11503),t(11519),t(11527),t(11549),t(11551),t(11579),t(11587),t(11593),t(11597),t(11617),t(11621),t(11633),t(11657),t(11677),t(11681),t(11689),t(11699),t(11701),t(11717),t(11719),t(11731),t(11743),t(11777),t(11779),t(11783),t(11789),t(11801),t(11807),t(11813),t(11821),t(11827),t(11831),t(11833),t(11839),t(11863),t(11867),t(11887),t(11897),t(11903),t(11909),t(11923),t(11927),t(11933),t(11939),t(11941),t(11953),t(11959),t(11969),t(11971),t(11981),t(11987),t(12007),t(12011),t(12037),t(12041),t(12043),t(12049),t(12071),t(12073),t(12097),t(12101),t(12107),t(12109),t(12113),t(12119),t(12143),t(12149),t(12157),t(12161),t(12163),t(12197),t(12203),t(12211),t(12227),t(12239),t(12241),t(12251),t(12253),t(12263),t(12269),t(12277),t(12281),t(12289),t(12301),t(12323),t(12329),t(12343),t(12347),t(12373),t(12377),t(12379),t(12391),t(12401),t(12409),t(12413),t(12421),t(12433),t(12437),t(12451),t(12457),t(12473),t(12479),t(12487),t(12491),t(12497),t(12503),t(12511),t(12517),t(12527),t(12539),t(12541),t(12547),t(12553),t(12569),t(12577),t(12583),t(12589),t(12601),t(12611),t(12613),t(12619),t(12637),t(12641),t(12647),t(12653),t(12659),t(12671),t(12689),t(12697),t(12703),t(12713),t(12721),t(12739),t(12743),t(12757),t(12763),t(12781),t(12791),t(12799),t(12809),t(12821),t(12823),t(12829),t(12841),t(12853),t(12889),t(12893),t(12899),t(12907),t(12911),t(12917),t(12919),t(12923),t(12941),t(12953),t(12959),t(12967),t(12973),t(12979),t(12983),t(13001),t(13003),t(13007),t(13009),t(13033),t(13037),t(13043),t(13049),t(13063),t(13093),t(13099),t(13103),t(13109),t(13121),t(13127),t(13147),t(13151),t(13159),t(13163),t(13171),t(13177),t(13183),t(13187),t(13217),t(13219),t(13229),t(13241),t(13249),t(13259),t(13267),t(13291),t(13297),t(13309),t(13313),t(13327),t(13331),t(13337),t(13339),t(13367),t(13381),t(13397),t(13399),t(13411),t(13417),t(13421),t(13441),t(13451),t(13457),t(13463),t(13469),t(13477),t(13487),t(13499),t(13513),t(13523),t(13537),t(13553),t(13567),t(13577),t(13591),t(13597),t(13613),t(13619),t(13627),t(13633),t(13649),t(13669),t(13679),t(13681),t(13687),t(13691),t(13693),t(13697),t(13709),t(13711),t(13721),t(13723),t(13729),t(13751),t(13757),t(13759),t(13763),t(13781),t(13789),t(13799),t(13807),t(13829),t(13831),t(13841),t(13859),t(13873),t(13877),t(13879),t(13883),t(13901),t(13903),t(13907),t(13913),t(13921),t(13931),t(13933),t(13963),t(13967),t(13997),t(13999),t(14009),t(14011),t(14029),t(14033),t(14051),t(14057),t(14071),t(14081),t(14083),t(14087),t(14107),t(14143),t(14149),t(14153),t(14159),t(14173),t(14177),t(14197),t(14207),t(14221),t(14243),t(14249),t(14251),t(14281),t(14293),t(14303),t(14321),t(14323),t(14327),t(14341),t(14347),t(14369),t(14387),t(14389),t(14401),t(14407),t(14411),t(14419),t(14423),t(14431),t(14437),t(14447),t(14449),t(14461),t(14479),t(14489),t(14503),t(14519),t(14533),t(14537),t(14543),t(14549),t(14551),t(14557),t(14561),t(14563),t(14591),t(14593),t(14621),t(14627),t(14629),t(14633),t(14639),t(14653),t(14657),t(14669),t(14683),t(14699),t(14713),t(14717),t(14723),t(14731),t(14737),t(14741),t(14747),t(14753),t(14759),t(14767),t(14771),t(14779),t(14783),t(14797),t(14813),t(14821),t(14827),t(14831),t(14843),t(14851),t(14867),t(14869),t(14879),t(14887),t(14891),t(14897),t(14923),t(14929),t(14939),t(14947),t(14951),t(14957),t(14969),t(14983),t(15013),t(15017),t(15031),t(15053),t(15061),t(15073),t(15077),t(15083),t(15091),t(15101),t(15107),t(15121),t(15131),t(15137),t(15139),t(15149),t(15161),t(15173),t(15187),t(15193),t(15199),t(15217),t(15227),t(15233),t(15241),t(15259),t(15263),t(15269),t(15271),t(15277),t(15287),t(15289),t(15299),t(15307),t(15313),t(15319),t(15329),t(15331),t(15349),t(15359),t(15361),t(15373),t(15377),t(15383),t(15391),t(15401),t(15413),t(15427),t(15439),t(15443),t(15451),t(15461),t(15467),t(15473),t(15493),t(15497),t(15511),t(15527),t(15541),t(15551),t(15559),t(15569),t(15581),t(15583),t(15601),t(15607),t(15619),t(15629),t(15641),t(15643),t(15647),t(15649),t(15661),t(15667),t(15671),t(15679),t(15683),t(15727),t(15731),t(15733),t(15737),t(15739),t(15749),t(15761),t(15767),t(15773),t(15787),t(15791),t(15797),t(15803),t(15809),t(15817),t(15823),t(15859),t(15877),t(15881),t(15887),t(15889),t(15901),t(15907),t(15913),t(15919),t(15923),t(15937),t(15959),t(15971),t(15973),t(15991),t(16001),t(16007),t(16033),t(16057),t(16061),t(16063),t(16067),t(16069),t(16073),t(16087),t(16091),t(16097),t(16103),t(16111),t(16127),t(16139),t(16141),t(16183),t(16187),t(16189),t(16193),t(16217),t(16223),t(16229),t(16231),t(16249),t(16253),t(16267),t(16273),t(16301),t(16319),t(16333),t(16339),t(16349),t(16361),t(16363),t(16369),t(16381),t(16411),t(16417),t(16421),t(16427),t(16433),t(16447),t(16451),t(16453),t(16477),t(16481),t(16487),t(16493),t(16519),t(16529),t(16547),t(16553),t(16561),t(16567),t(16573),t(16603),t(16607),t(16619),t(16631),t(16633),t(16649),t(16651),t(16657),t(16661),t(16673),t(16691),t(16693),t(16699),t(16703),t(16729),t(16741),t(16747),t(16759),t(16763),t(16787),t(16811),t(16823),t(16829),t(16831),t(16843),t(16871),t(16879),t(16883),t(16889),t(16901),t(16903),t(16921),t(16927),t(16931),t(16937),t(16943),t(16963),t(16979),t(16981),t(16987),t(16993),t(17011),t(17021),t(17027),t(17029),t(17033),t(17041),t(17047),t(17053),t(17077),t(17093),t(17099),t(17107),t(17117),t(17123),t(17137),t(17159),t(17167),t(17183),t(17189),t(17191),t(17203),t(17207),t(17209),t(17231),t(17239),t(17257),t(17291),t(17293),t(17299),t(17317),t(17321),t(17327),t(17333),t(17341),t(17351),t(17359),t(17377),t(17383),t(17387),t(17389)]),Gt.list}function Qt(t,n,e){var i,r,u,l,s,o,f,c,h=I.Arithmetic,a=(h.num,h.O,h.I),m=h.II;for(i=h.sub(t,a),r=h.sub(i,a),l=i,u=0;s=h.div(l,m),o=h.mod(l,m),!h.equ(o,a);)u+=1,l=s;function d(n){var e,r;if(e=Xt(n,l,t),h.equ(e,a)||h.equ(e,i))return!1;for(r=1;ri?"0":n.slice(0,i+1)]:u}(c.add(t,a),null,!0))[1],l=l[0],s=h,i=function(t,n,e,i,r){var u,l,s,o,f,c,h,a,m=I.Arithmetic,d=m.O,g=m.J,_=m.I,v=m.II;if(u=m.sub(m.mul(n,n),m.mul(e,4)),m.equ(d,u))return null;if("0"===(r=r||m.digits(i,2)))return[d,v,e];if(l=_,s=n,c=e,h=r.length,m.equ(_,e))for(a=1;ar);)if(f+=1,s=u(s),l=u(u(l)),c=un(m.sub(s,l),t),!m.equ(g,c)){if(m.equ(t,c))break;return c}l=m.rnd(d,h),e=m.rnd(g,a),u=null}return null}function nn(t){var n,e=I.Arithmetic;return e.digits(t).length<=20?function(t,n){var e,i,r,u,l,o,f,c,h,a,m,d=I.Arithmetic,g=d.num,_=d.O,v=d.I,p=d.II,b=Gt();for(b.length||(b=[p,g(3)]),e=null,u=null,l=0,o=t,f=0,c=b.length;f=c)for(h=d.add(h,p),a=d.mul(h,h);d.lte(a,t)&&(null==n||d.lte(a,n));){for(r=_;d.equ(_,d.mod(t,h));)r=d.add(v,r),t=d.div(t,h);d.lt(_,r)&&((i=new s([h,r])).l=u,u&&(u.r=i),u=i,l++,e||(e=u)),h=d.add(h,p),a=d.mul(h,h)}return null==n&&d.gt(t,v)&&((i=new s([t,v])).l=u,u&&(u.r=i),u=i,l++,e||(e=u)),m=pt(l,function(){var t=e,n=t.v;return e=e.r,t.dispose(),e&&(e.l=null),n}),null==n?m:[m,t]}(t):(null==(n=tn(t,e.II,e.I,5,100,null))&&(n=function(t,n,e,i){var r,u,l,s,o,f,c,h=I.Arithmetic,a=h.num,m=(h.O,h.I),d=h.II,g=Gt(),_=g.length;if(null==i&&(i=0),null==e&&(e=d),null==n&&(n=a(10)),i=+i,h.lt(t,4)||h.lt(n,3))return null;for(f=h.sub(t,d),r=0;r<=i;r++){for(u=e,c=0;c<_&&(l=g[c],!h.gt(l,n));c++)s=zt(n,l),u=Xt(u,h.pow(l,s),t);if(o=un(h.sub(u,m),t),h.gt(o,m)&&h.lt(o,t))return o;e=h.rnd(d,f)}return null}(t,e.num(10),e.II,5)),null==n?[[t,e.I]]:function(t,n){var e,i=I.Arithmetic,r=0,u=0,l=t.length,s=n.length,o=0;for(e=new Array(l+s);ro&&(e.length=o),e}(nn(n),nn(e.div(t,n))))}function en(t,n){return t===n}function rn(t,n,e){var i,r,u,l;for(e=e||en,r=t(i=t(n));!e(i,r);)i=t(i),r=t(t(r));for(u=0,i=n;!e(i,r);)i=t(i),r=t(r),u++;for(l=1,r=t(i);!e(i,r);)r=t(r),l++;return[l,u]}function un(){var t,n,e,i,r=arguments.length&&(ot(arguments[0])||ft(arguments[0]))?arguments[0]:arguments,u=r.length,l=I.Arithmetic,s=(l.num,l.O),o=l.I;if(0===u)return s;for(i=0;i=i)return 1===i?e[0]:u;if(r.equ(u,e[0])||r.equ(u,e[1]))return u;for(n=ln(e[0],e[1]),t=2;te)return null;if(s)return u=a,c.equ(a,t)||(o=t),a;if(o)return n=o,o=null,n;for(u=c.add(u,a);c.lte(u,r);){if(c.equ(h,c.mod(t,u)))return l=c.div(t,u),c.equ(l,u)||(o=l),u;u=c.add(u,a)}return null}));for(r=Ft(t),u=a;c.lte(u,r);u=c.add(u,a))c.equ(h,c.mod(t,u))&&(l=c.div(t,u),c.equ(l,u)?(i=new s(u,g,null),_++,g&&(g.r=i),g=i):(i=new s(u,g,null),_++,g&&(g.r=i),g=i,i=new s(l,null,d),v++,d&&(d.l=i),d=i),m||(m=g));return g&&(g.r=d,d&&(d.l=g)),g=null,d=null,pt(_+v,function(){var t=m,n=t.v;return m=t.r,t.dispose(),m&&(m.l=null),n})}function an(t,n,e){var i,r=(e=e||I.DefaultArithmetic).O,u=w.min(t.length,n.length);for(i=0;i0;s--)r=un(_[0],t[s]),_[0]=q.div(_[0],r),t[s]=q.div(t[s],r),_.unshift(r);for(_.push(t[i-1]),A=[],y=pt(i,function(t){return S+"_"+(t+1)}),n=g(n),s=0,h=_.length;sn.length&&(n=n.concat(pt(r-n.length,function(t){return A}))),s=(l=t.t().concat(p.I(u)).ref(!0,[u,r]))[0],o=l[1].length,c=s.slice(0,r,-1,-1).t(),f=s.slice(0,0,u-1,r-1).t(),_=new Array(u),v=new Array(u-o),h=0;h=o)v[h-o]=x+"_"+(h-o+1),_[h]=g(d(v[h-o],y));else{for(m=A,a=0;ai)return r.I;if(e===i)return n[e];var u=e+i>>>1;return r.mul(t(n,e,u),t(n,u+1,i))}(h,0,h.length-1)},e=function t(e,i){if(l.lt(e,f))return o;var r=t(l.div(e,f),i);return l.mul(l.mul(r,r),n(e,i))},l.lt(t,f)?o:(i=l.sub(t,l.digits(t,2).split("").reduce(function(t,n){return l.add(t,"1"===n?o:s)},s)),r=(u=x()).get(function(n){return l.lte(n,t)}),u.dispose(),l.mul(e(t,r),pn(i)))}function yn(t,n){var e,i=I.Arithmetic,r=i.O,u=i.I,l=i.J,s=i.num,o=i.add,f=(i.sub,i.div),c=i.mul,h=s(t),a=r,m=I.Options.MAXMEM;if(null==n){if(12>=t)return 0>t?r:s([1,1,2,6,24,120,720,5040,40320,362880,3628800,39916800,479001600][t]);if(600<=t)return An(h);e=String(t),null==yn.mem1[e]?(a=c(yn(t-1),t),i.lt(h,m)&&(yn.mem1[e]=a)):a=yn.mem1[e]}else if(!1===n){if(12>=t)return 2>t?r:s([1,2,9,44,265,1854,14833,133496,1334961,14684570,176214841][t-2]);e="!"+String(t),null==yn.mem2[e]?(a=o(1&t?l:u,c(yn(t-1,!1),t)),i.lt(h,m)&&(yn.mem2[e]=a)):a=yn.mem2[e]}else if(!0===n){if(18>=t)return 0>t?r:s([1,1,2,4,10,26,76,232,764,2620,9496,35696,140152,568504,2390480,10349536,46206736,211799312,997313824][t]);e="I"+String(t),null==yn.mem2[e]?(a=o(yn(t-1,!0),c(yn(t-2,!0),t-1)),i.lt(h,m)&&(yn.mem2[e]=a)):a=yn.mem2[e]}else if(ot(n)){if(!n.length)return 0>t?r:yn(t);if(0>t)return r;e=String(t)+"@"+$t(n.slice(),1,!0).join(","),null==yn.mem3[e]?(a=f(yn(t),vt(function(t,n){return c(t,yn(n))},yn(n[n.length-1]),n,n.length-2,0)),i.lt(h,m)&&(yn.mem3[e]=a)):a=yn.mem3[e]}else if(n===+n)if(0>n){if(-n>=t)return-n===t?yn(t):r;e=String(t)+"@"+String(n),null==yn.mem3[e]?(a=vt(c,u,null,t+n+1,t),i.lt(h,m)&&(yn.mem3[e]=a)):a=yn.mem3[e]}else{if(0>n||1>t||n>t)return r;if(n<<1>t&&(n=t-n),0===n||1===t)return u;if(1===n)return h;e=String(t)+"@"+String(n),null==yn.mem3[e]?(a=i.isDefault()?w.round(vt(function(n,e){return n*(1+t/e)},1+(t-=n),null,2,n)):o(yn(t-1,n-1),yn(t-1,n)),i.lt(h,m)&&(yn.mem3[e]=a)):a=yn.mem3[e]}return a}function qn(t,n,e){var i,r=I.Arithmetic,u=r.O,l=r.I,s=r.add,o=r.mul,f=r.num(t),c=u,h=I.Options.MAXMEM;if(0>t||0>n)return u;if(2===e){if(t===n||1===n&&0>t)return l;if(0===t||0===n)return u;i=String(t)+","+String(n),null==qn.mem2[i]?(c=s(qn(t-1,n-1,2),o(qn(t-1,n,2),n)),r.lt(f,h)&&(qn.mem2[i]=c)):c=qn.mem2[i]}else if(-1===e){if(n>t||0===n&&0>t)return u;if(t===n)return l;i=String(t)+","+String(n)+"-",null==qn.mem1[i]?(c=s(qn(t-1,n-1,-1),o(qn(t-1,n,-1),1-t)),r.lt(f,h)&&(qn.mem1[i]=c)):c=qn.mem1[i]}else{if(n>t||0===n&&0>t)return u;if(t===n)return l;if(1===n)return yn(t-1);c=t-n&1?r.neg(qn(t,n,-1)):qn(t,n,-1)}return c}function xn(t,n,e,i){var r,u,l=I.Arithmetic,s=l.add,o=l.I,f=l.O;return 0>t||0>=n||e>i||e+n>t+1||n*it||n&&e&&(n+e>t+1||n*et||n&&n>t?c:(e&&!n&&(l=0,s=1,o=e,f=e,n=e,e=null),i=String(t)+"|"+String(n)+"|"+String(e),null==In.mem[i]&&(In.mem[i]=vt(function(n,e){return vt(function(n,i){return u(n,xn(t,e,1,i))},n,null,s,l||t-e+1,1)},c,null,o,f,1)),In.mem[i])}function On(t,n,e,i){var r,u=I.Arithmetic,l=u.add,s=u.O,o=u.I;return 0>t||0>=n||e>i||e*n>t||n*it||n&&e&&(n+e>t+1||n*et||n&&n>t?f:(i=String(t)+"|"+String(n)+"|"+String(e),null==wn.mem[i]&&(wn.mem[i]=n&&e?n*e===t?l:o(On(t-e,n-1,1,e),n):n?On(t,n,1,t):e?t===e?l:vt(function(n,i){return s(n,On(t,i,1,e))},f,null,w.ceil(t/e),t-e+1,1):1<=t?pn(t-1):l),wn.mem[i])}function Sn(t){var n,e=I.Arithmetic,i=e.O,r=e.num,u=e.div,l=e.mul,s=i,o=I.Options.MAXMEM;return 17>=t?0>t?i:r([1,1,2,5,14,42,132,429,1430,4862,16796,58786,208012,742900,2674440,9694845,35357670,129644790][t]):(n=String(t),null==Sn.mem[n]?e.lt(r(t),o)?(s=u(l(Sn(t-1),4*t-2),t+1),Sn.mem[n]=s):s=u(yn(2*t,t),t+1):s=Sn.mem[n],s)}function Nn(t){var n,e=I.Arithmetic,i=e.O,r=e.num,u=e.add,l=e.mul,s=i,o=I.Options.MAXMEM;return 14>=t?0>t?i:r([1,1,2,5,15,52,203,877,4140,21147,115975,678570,4213597,27644437,190899322][t]):(n=String(t),null==Nn.mem[n]?(s=vt(function(n,e){return u(n,l(yn(t-1,e),Nn(e)))},i,null,0,t-1,1),e.lt(r(t),o)&&(Nn.mem[n]=s)):s=Nn.mem[n],s)}function Rn(t){var n,e,i,r,u=I.Arithmetic,l=u.O,s=u.num,o=l,f=I.Options.MAXMEM;return 36>=t?0>t?l:s([0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765,10946,17711,28657,46368,75025,121393,196418,317811,514229,832040,1346269,2178309,3524578,5702887,9227465,14930352][t]):(r=String(t),null==Rn.mem[r]?(e=Rn((n=t>>>1)+1),i=Rn(n),o=1&t?u.add(u.mul(e,e),u.mul(i,i)):u.mul(i,u.sub(u.mul(e,u.II),i)),u.lt(s(t),f)&&(Rn.mem[r]=o)):o=Rn.mem[r],o)}function $n(){var t,n,e,i,r,u,l,s,o,f,c,h=arguments,a=h.length;if(!a)return[];if(!0===h[0]){for(f=h[1].length,t=2;t=0;n--)if(r=e%(i=h[n].length),e=~~(e/i),ot(l=h[n][r])||ft(l))for(u=l.length-1;u>=0;u--)s[a-++o]=l[u];else s[a-++o]=l;c[t]=s}}return c}function En(t,n,e){var i,r,u,l,s,o,f,c,h,a,m,d,g,_,v,p,b,A,y,q,x,I,O,w,S,N=t.length,R=null,$=null;if(!N)return[];for(mt(e)?($=e,e=!0):e=!1,z!==n&&G!==n&&Q!==n&&B!==n&&H!==n&&V!==n&&(n=!1),A=new Array(N),y=[],q=0,b=[],r=1,i=0;i=r)return[];if(!b.length)return[];for(v=new Array(r),_=0,d=N-1,x=b.length-1,i=0;i=0;u--)o=l%(s=t[p=b[u]].length),l=~~(l/s),a[p]=t[p][o];for(u=0,q=y.length;u=0;m--){if(null==(c=a[m])||isNaN(c)||z===n&&h!==c||G===n&&1===R[c]||Q===n&&c>=h||B===n&&c<=h||H===n&&ch||e&&!$(a,m,d)){I=!0;break}G===n&&(R[c]=1),h=c}I||(v[_++]=a)}return v.length>_&&(v.length=_),v}function Cn(t,n,e,i){i=i||function(t,n){return t>n};for(var r,u=0,l=0,s=0,o=t.length,f=n.length,c=new Array(o+f);us&&(c.length=s),c}function Dn(t,n,e){if(null==n||!n.length||1>=n.length)return 1===n.length?pt(t-1,function(t){return t=n)return[];var e,i=pt(n,0,0),r=t.length;for(n-=1,e=0;e=(i=vt(Tt,0,n))?r=n.slice():(0<(i-=vt(Tt,0,r=Tn(Dn(i-1,Ln(n,u-1,e)))))&&r.push(i),0>e&&yt(r,r));else{var l,s,o,f,c,h=1,a=0,m=0,d="push";if(0>e&&(h=-h,a=u-1-a,d="unshift"),ot(n[a]))for(r=[[(c=n[a])[1],c[0]]],l=0,o=1,f=h+a;oe?0:l,(c=n[f])[1]===r[s][0]?r[s][1]+=c[0]:(r[d]([c[1],c[0]]),l++);else for(r=pt(i=n[a],1,0),0>e&&(m=i-1-m),o=1,f=h+a;o0;)r[s]++,c--,l++,s+=h}return r}function jn(t,n,e){var i=t?t.length:0,r=1,u=0,l=0,s=l=s&&(u+=r,s=++l>>1<<1]),l[i]+=1,i>>>=1;return l[i]+=1,t[e]=n,t},t||new Array(i),n)}function Xn(t,n,e){var i,r,u,l=n.length,s=w.ceil(C(e||l)),o=1<=f[i<<=1]&&(n-=f[i],i++);return f[i]=0,t[e]=i-o,t},t||new Array(l),n)}function Fn(t,n,e){var i,r=t.length,u=null==n;if(r>1)for(u&&(n=new Array(r-1),e=0),i=r-1;i>=1;i--)n[e++]=[t[0],t[i]];else u&&(n=[]);return u?n:e}function Zn(t,n){var e,i,r,u,l=t.length,s=new Array(l),o=!0===n?1:0,f=new Array(l),c=0,h=0;for(e=0;eo&&(r.length=u,s[h++]=r),r=new Array(l),u=0;co&&(r.length=u,s[h++]=r),hr?function(e,i){return e[i]=i=n&&(n=tt)}else n=ut&t?ut&t:tt;return it&n&&rt&n&&(n&=~rt),et&n&&(nt|tt)&n&&(n&=~(nt|tt)),nt&n&&tt&n&&(n&=~tt),it&n&&(n&=~K),n}function Bn(t,n,e,i,r){if(null==t)return null;var u,l=null;if("ordered"===r||"variation"===r)for(l={},u=0;u=n},lte:function(t,n){return t<=n},gt:function(t,n){return t>n},lt:function(t,n){return t=n&&t<=e:t>n&&te?e:t},wrap:function(t,n,e){return te?n:t},wrapR:function(t,n){return t<0?t+n:t},add:Tt,sub:function(t,n){return t-n},mul:function(t,n){return t*n},div:function(t,n){return w.floor(t/n)},mod:function(t,n){return t%n},pow:w.pow,shl:function(t,n){return t<>n},bor:function(t,n){return t|n},band:function(t,n){return t&n},xor:function(t,n){return t^n},abs:w.abs,min:w.min,max:w.max,rnd:Gn},I.Arithmetic=F({},r,{isDefault:function(){return 0===this.O&&this.add===Tt},neg:function(t){return I.Arithmetic.mul(I.Arithmetic.J,t)},abs:function(t){return I.Arithmetic.gt(I.Arithmetic.O,t)?I.Arithmetic.neg(t):t},min:function(t,n){return I.Arithmetic.lt(t,n)?t:n},max:function(t,n){return I.Arithmetic.gt(t,n)?t:n}}),I.Math={rnd:w.random,rndInt:Gn,factorial:yn,stirling:qn,partitions:In,compositions:wn,bell:Nn,catalan:Sn,fibonacci:Rn,polygonal:function(t,n){var e=I.Arithmetic,i=(e.O,e.I,e.II),r=e.num;return 3>(n=+n)?null:(t=r(t),e.div(e.mul(t,e.sub(e.mul(t,n-2),n-4)),i))},sum:Ut,product:jt,pow2:pn,exp:bn,powsq:function(t,n){var e=I.Arithmetic;return function(t,n){var e,i,r=I.Arithmetic,u=r.O,l=r.I;if(r.num,r.gt(u,n))return null;if(r.equ(u,n))return l;if(r.equ(l,n))return t;if(i=l,r.isDefault()||r.lte(n,W))for(n=r.val(n);0!==n;)1&n&&(i=r.mul(i,t)),n>>=1,t=r.mul(t,t);else for(e=r.II;!r.equ(u,n);)r.equ(l,r.mod(n,e))&&(i=r.mul(i,t)),n=r.div(n,e),t=r.mul(t,t);return i}(e.num(t),e.num(n))},addm:function(t,n,e){var i=I.Arithmetic;return function(t,n,e){var i=I.Arithmetic;return i.num,i.equ(e,i.I)?i.O:i.mod(i.add(t,n),e)}(i.num(t),i.num(n),i.num(e))},negm:function(t,n){var e=I.Arithmetic;return function(t,n){var e=I.Arithmetic;return e.equ(n,e.I)?e.O:e.mod(e.sub(n,t),n)}(e.num(t),e.num(n))},mulm:function(t,n,e){var i=I.Arithmetic;return Pt(i.num(t),i.num(n),i.num(e))},invm:function(t,n){var e=I.Arithmetic;return Jt(e.num(t),e.num(n))},powm:function(t,n,e){var i=I.Arithmetic;return Xt(i.num(t),i.num(n),i.num(e))},isqrt:function(t){return Ft(I.Arithmetic.num(t))},ikthroot:function(t,n){return function(t,n){var e,i,r,u,l=I.Arithmetic,s=(l.num,l.I);if(1>(n=+n))return null;if(1===n||l.equ(t,l.O)||l.equ(t,s))return t;for(u=n-1,e=t,i=l.add(t,s);l.lt(e,i);)i=e,r=l.add(l.mul(i,u),l.div(t,l.pow(i,u))),e=l.div(r,n);return i}(I.Arithmetic.num(t),+n)},isqrtp:function(t,n){var e=I.Arithmetic;return function(t,n){var e,i,r,u,l,s,o,f,c,h,a,m,d,g=I.Arithmetic,_=(g.num,g.O),v=g.I;if(!g.equ(v,Wt(t,n)))return null;for(e=g.II,r=i=g.sub(n,v),u=0;g.equ(_,g.mod(r,e));)r=g.div(r,e),u+=1;if(1===u)return Xt(t,g.div(g.add(n,v),4),n);for(l=_;g.lt(l,n)&&!g.equ(i,Wt(l,n));l=g.add(l,v));for(s=Xt(l,r,n),o=Xt(t,g.div(g.add(r,v),e),n),c=Xt(t,r,n),h=u,a=_;!g.equ(_,g.mod(g.sub(c,v),n));){for(a=Pt(c,c,n),d=1;d=i)return 1===i?e[0]:v([]);if(e[0].equ(r)||e[1].equ(r))return v([],e[0].symbol);for(n=cn(e[0],e[1]),t=2;t(n=-1===n?-1:1)){if(i.lte(t,l))return null;if(i.equ(t,3))return l;for(e=i.sub(t,i.equ(r,i.mod(t,l))?u:l);;e=i.sub(e,l))if(Vt(e)&&Yt(e))return e}else{if(i.lt(t,l))return l;for(e=i.add(t,i.equ(r,i.mod(t,l))?u:l);;e=i.add(e,l))if(Vt(e)&&Yt(e))return e}}(I.Arithmetic.num(t),-1===n?-1:1)},diophantine:function(t,n,e){var i=I.Arithmetic;return(ot(t)||ft(t))&&t.length?gn(i.nums(t),i.num(n||0),e):null},diophantines:function(t,n,e,i){var r=I.Arithmetic;return(t instanceof p||ot(t)||ft(t))&&(!(t instanceof p)||t.nr&&t.nc)&&(t instanceof p||t.length)?(t=t instanceof p?t:r.nums(t),n instanceof p||ot(n)||ft(n)||(n=pt(t instanceof p?t.nr:t.length,function(){return n||0})),_n(t,n=n instanceof p?n:r.nums(n),e,!0===i)):null},congruence:function(t,n,e,i){var r=I.Arithmetic;return(ot(t)||ft(t))&&t.length?function(t,n,e,i){var r,u=I.Arithmetic,l=u.O;return t.length?null==(r=gn(t.concat(e),n,i))?null:pt(r.length-1,function(t){var n=r[t];return!1===i?u.gt(l,n)&&(n=u.add(n,e)):n.c().real.lt(l)&&(n=n.add(e)),n}):null}(r.nums(t),r.num(n||0),r.num(e||0),i):null},congruences:function(t,n,e,i){var r=I.Arithmetic;return(t instanceof p||ot(t)||ft(t))&&(!(t instanceof p)||t.nr&&t.nc)&&(t instanceof p||t.length)?(t=t instanceof p?t:r.nums(t),n instanceof p||ot(n)||ft(n)||(n=pt(t instanceof p?t.nr:t.length,function(){return n||0})),n=n instanceof p?n:r.nums(n),e instanceof p||ot(e)||ft(e)||(e=pt(t instanceof p?t.nr:t.length,function(){return e||0})),e=e instanceof p?e:r.nums(e),function(t,n,e,i){var r,u,l,s,o=I.Arithmetic,f=o.O;return t instanceof p||(t=p(t)),t.nr&&t.nc?(ot(e)||ft(e)||e instanceof p||(e=o.num(e),e=pt(t.nr,function(t){return e})),(ot(e)||ft(e))&&(e=p(e)),(ot(n)||ft(n))&&(n=p(n)),l=e.col(0),u=sn(l),t=t.concat(e),null!=(r=_n(t,n,i,!0))&&(s=r[1],r=r[0]),null==r?null:pt(r.length-1,function(t){var n,e=r[t],l=!0;if(!1===i)o.gt(f,e)&&(e=o.add(e,u));else{for(n in e.terms)if($.call(e.terms,n)&&"1"!==n&&o.equ(f,o.mod(u,e.terms[n].c().real.num))){l=!1;break}l&&(e=e.add(d(s.symbol+"_"+(s.length+1),u))),e.c().real.lt(f)&&(e=e.add(u))}return e})):null}(t,n,e,i)):null},pythagorean:function(t,n){var e=I.Arithmetic;return(ot(t)||ft(t))&&t.length?function(t,n){var e,i,r,u,l,s,o,f,c,h,a,m=I.Arithmetic,_=m.O,v=m.I,p=m.J,b=m.II,A=t.length,y=ht(n)&&n.length?n:"i";if(!A)return null;if(h=t.filter(function(t){return 1===vn(t)}).length,a=t.filter(function(t){return-1===vn(t)}).length,1===A||0===h||0===a)return pt(A,function(){return g()});if(c=pt(A,function(n){return Ft(m.abs(t[n]))}),A!==t.filter(function(t,n){return m.equ(m.abs(t),m.mul(c[n],c[n]))}).length)return pt(A,function(){return g()});if(u=pt(A-1,function(t){return y+"_"+(t+1)}),2===A)return[g(d(u[0],c[1])),g(d(u[0],c[0]))];for(0>vn(t[0])+vn(t[1])+vn(t[2])&&(t=t.map(function(t){return m.neg(t)})),e=0,l=0;l0&&0===l||0===e&&1===l?c[l]:m.equ(_,m.mod(c[l],b))?m.div(c[l],b):c[l]);for(l=0;l=s)return 1===s?[t[n]]:[];for(i=P(),u=new Array(s),l=0;n<=e;)i[r=String(t[n])]||(u[l++]=t[n],i[r]=1),n++;return u.length>l&&(u.length=l),u},intersection:function(t,n,e,i,r,u,l,s){i=-1===i?-1:1,null==r&&(r=0),null==u&&(u=n.length-1),null==l&&(l=0),null==s&&(s=e.length-1);var o=r>u?-1:1,f=l>s?-1:1,c=o*(u-r)+1,h=f*(s-l)+1,a=r,m=l,d=0;if(null==t&&(t=new Array(w.min(c,h))),0===t.length)return t;for(;0<=o*(u-a)&&0<=f*(s-m);)1===i&&n[a]e[m]?a+=o:1===i&&n[a]>e[m]||-1===i&&n[a]u?-1:1,f=l>s?-1:1,c=o*(u-r)+1,h=r,a=l,m=0;if(!i||!i.length)return e?e.slice():e;for(null==t&&(t=new Array(c));0<=o*(u-h)&&0<=f*(s-a);)e[h]===i[a]?1i[a]?a+=f:(t[m++]=e[h],n[e[h]]--,h+=o);for(;0<=o*(u-h);)0c)return-1;if(u(t,n[f]))return f;if(u(t,n[c]))return c;if(-1===e)for(;f>>1]))return s;l(o,t)?c=s-1:f=s+1}else for(;f>>1]))return s;l(t,o)?c=s-1:f=s+1}return-1},bisect:Mt,complementation:At,reflection:yt,reversion:qt,gray:xt,finitedifference:Ot,partialsum:wt,convolution:function(t,n,e){var i,r,u,l=t.length,s=n.length;if(!0===e)for(u=pt(l+s-1,function(){return 0}),i=0;i=r?n[e].neg():e>=u?t[e]:t[e].sub(n[e])}:function(e){return e>=r?n[e]:e>=u?t[e]:t[e].add(n[e])}:e?i?function(i){return i>=r?e.neg(n[i]):i>=u?t[i]:e.sub(t[i],n[i])}:function(i){return i>=r?n[i]:i>=u?t[i]:e.add(t[i],n[i])}:i?function(e){return e>=r?-n[e]:e>=u?t[e]:t[e]-n[e]}:function(e){return e>=r?n[e]:e>=u?t[e]:t[e]+n[e]})},wheel:function(){var t,n,e,i,r,u=arguments.length&&ot(arguments[0])?arguments[0]:arguments,l=u.length;if(!l||!u[0])return null;for(r=1,e=0;e=t.length)return!0;for(n=0,e=t.length-1;n=(t=String(t)).length)return!0;for(n=0,e=t.length-1;nn?1:0},heapify:function(t,n,e){var i,r=t.length;if(e=e||o.CMP,"max"===n)for(i=(r>>>1)-1;i>=0;i--)o._siftup_max(t,i,e);else for(i=(r>>>1)-1;i>=0;i--)o._siftup(t,i,e);return t},_siftdown:function(t,n,e,i){for(var r,u,l=t[e];e>n&&0>i(l,u=t[r=e-1>>>1]);)t[e]=u,e=r;t[e]=l},_siftup:function(t,n,e){var i,r,u=t.length,l=n,s=t[n];for(i=2*n+1;in&&0>i(u=t[r=e-1>>>1],l);)t[e]=u,e=r;t[e]=l},_siftup_max:function(t,n,e){var i,r,u=t.length,l=n,s=t[n];for(i=2*n+1;i=0;s--)if("0"!==v.charAt(s)){c=!1;break}c&&(v=null)}if(o=d(10),v){if(_){for(;_.length>=v.length&&_.slice(-v.length)===v;)_=_.slice(0,-v.length);_.length||(_=null)}r=h.sub(h.pow(o,(_?_.length:0)+v.length),_?h.pow(o,_.length):m),i=h.add(h.mul(r,e),h.sub(d((_||"")+v),_?d(_):a))}else{for(;_&&"0"===_.slice(-1);)_=_.slice(0,-1);_&&_.length?(r=h.pow(o,_.length),i=h.add(h.mul(r,e),d(_))):(r=m,i=e)}return!1!==n&&(l=un(i,r),i=h.div(i,l),r=h.div(r,l)),f[0]=g?h.neg(i):i,f[1]=r,f}(t,!a.autoSimplify);return n?a(n):null},fromString:function(t){var n,e,i,r=I.Arithmetic,u="+";return(t=M(t?String(t):"")).length?("+"!==t.charAt(0)&&"-"!==t.charAt(0)||(u=t.charAt(0),t=M(t.slice(1))),t.length&&"("===t.charAt(0)&&")"===t.charAt(t.length-1)&&(t=M(t.slice(1,-1))),n=String(t).split("/"),e=r.num(n[0].length?n[0]:"0"),i=1=0;s--)if("0"!==h.charAt(s)){d=!1;break}h=d?"":"["+h+"]"}if((a=u.slice(0,l[1]).join("")).length){for(d=!0,s=a.length-1;s>=0;s--)if("0"!==a.charAt(s)){d=!1;break}d&&!h.length&&(a="")}return c+(a.length||h.length?".":"")+a+h}(this.num,this.den)),this._dec},valueOf:function(){var t=I.Arithmetic;return t.val(this.num)/t.val(this.den)},toString:function(t){var n=I.Arithmetic;return null==this._str&&(this._str=String(this.num)+(n.equ(n.I,this.den)?"":"/"+String(this.den)),this._strp=n.equ(n.I,this.den)?String(this.num):(n.gt(n.O,this.num)?"-":"")+"("+String(n.abs(this.num))+"/"+String(this.den)+")"),t?this._strp:this._str},toTex:function(){var t=I.Arithmetic;return null==this._tex&&(this._tex=t.equ(t.I,this.den)?_t(this.num):(t.gt(t.O,this.num)?"-":"")+"\\frac{"+_t(t.abs(this.num))+"}{"+_t(this.den)+"}"),this._tex}}),m=I.Complex=Z(h,{constructor:function t(){var n,e,i=arguments,r=I.Arithmetic.O;if(i.length&&(ot(i[0])||ft(i[0]))&&(i=i[0]),1W||!at(t)&&r.gt(t,W))return null;if(i.equ(u)){if(r.gt(u,t))throw new Error("Zero denominator in negative power in Abacus.Complex!");return m()}if(r.equ(u,t))return m(l);if(r.equ(l,t))return m(i);for(r.gt(u,t)&&(i=i.inv(),t=r.neg(t)),t=r.val(t),e=i,n=m(l);0!==t;)1&t&&(n=n.mul(e)),t>>=1,e=e.mul(e);return n}return i},simpl:function(){return this.real.simpl(),this.imag.simpl(),this._str=null,this._tex=null,this},integer:function(){return null==this._int&&(this._int=m(this.real.integer(),this.imag.integer())),this._int},remainder:function(){return null==this._rem&&(this._rem=m(this.real.remainder(),this.imag.remainder())),this._rem},tuple:function(){return[this.real,this.imag]},valueOf:function(){return this.real.valueOf()},toString:function(){var t,n=I.Arithmetic,e=n.O;return null==this._str&&(t=this.real.equ(e),this._str=(t?"":this.real.toString())+(this.imag.equ(e)?"":(this.imag.gt(e)?t?"":"+":"")+(this.imag.equ(n.I)?"":this.imag.equ(n.J)?"-":this.imag.toString(!0)+"*")+m.Symbol),this._str.length||(this._str="0")),this._str},toTex:function(){var t,n=I.Arithmetic,e=n.O;return null==this._tex&&(t=this.real.equ(e),this._tex=(t?"":this.real.toTex())+(this.imag.equ(e)?"":(this.imag.gt(e)?t?"":"+":"")+(this.imag.equ(n.I)?"":this.imag.equ(n.J)?"-":this.imag.toTex())+m.Symbol),this._tex.length||(this._tex="0")),this._tex},toDec:function(){var t,n=I.Arithmetic,e=n.O;return null==this._dec&&(t=this.real.equ(e),this._dec=(t?"":this.real.toDec())+(this.imag.equ(e)?"":(this.imag.gt(e)?t?"":"+":"")+(this.imag.equ(n.I)?"":this.imag.equ(n.J)?"-":this.imag.toDec())+m.Symbol),this._dec.length||(this._dec="0")),this._dec}}),d=I.Term=Z(h,{constructor:function t(n,e){var i,r=I.Arithmetic;if(!(this instanceof t))return new t(n,e);n instanceof t?(e=n.factors[1].clone(),this.symbol=n.symbol,this.symbolTex=n.symbolTex,n=n.factors,i=e,this.factors=P(),this.factors[1]=i,this.factors[1].equ(r.O)||t.Merge(n,this)):((i=null==e?r.I:e)instanceof m||(i=m(i)),this.factors=P(),this.factors[1]=i,this.factors[1].equ(r.O)||t.Merge(n,this),t.Symbol(this))},__static__:{Merge:function(t,n,e){var i,r,u,l,s=I.Arithmetic,o=s.O,f=s.I;function c(t,i,r){t=M(t);var u,l=!1!==r?t.indexOf("^"):-1;i=i||o,-1!==l&&("{"===(u=t.slice(l+1)).charAt(0)&&"}"===u.charAt(u.length-1)&&(u=u.slice(1,-1)),i=s.num(u),t=t.slice(0,l)),-1!==(l=t.indexOf("_"))&&"{"===t.charAt(l+1)&&"}"===t.charAt(t.length-1)&&(t=t.slice(0,l+1)+t.slice(l+2,-1)),"1"!==t&&t.length&&(-1===e?n.factors[t]&&(n.factors[t]=s.sub(n.factors[t],i),s.gte(o,n.factors[t])&&delete n.factors[t]):n.factors[t]?n.factors[t]=s.add(n.factors[t],i):n.factors[t]=i)}if(ot(t)||ft(t))for(r=0,u=t.length;rn)return null;if(s[1].equ(f)||"1"===t||!$.call(s,t)||o.lt(s[t],n))return d({},f);for(e in i={},s)if($.call(s,e)&&"1"!==e)if(t===e)for(o.gt(s[e],n)&&(i[e]=o.sub(s[e],n)),r=c,u=s[e],l=n;l--;)r=o.mul(r,u),u=o.sub(u,c);else i[e]=s[e];return d(i,s[1].mul(r))},valueOf:function(t){var n=this,e=I.Arithmetic,i=e.O,r=e.I;return t=t||{},"1"===n.symbol?n.factors[1]:n.symbols().reduce(function(u,l){if(u.equ(i))return m(i);var s,o=n.factors[l],f=t[l]||i;return f=f instanceof m?f:m(f),s="1"===l?o:f.equ(i)?i:e.equ(r,o)?f:f.pow(o),u.mul(s)},m(r))},toString:function(){var t,n=I.Arithmetic,e=n.O;return null==this._str&&((t=this.factors[1]).equ(e)?this._str="0":t.isReal()?this._str="1"===this.symbol?t.real.toString():(t.real.equ(n.J)?"-":t.real.equ(n.I)?"":t.real.toString(!0)+"*")+this.symbol:this._str="1"===this.symbol?"("+t.toString()+")":"("+t.toString()+")*"+this.symbol),this._str},toTex:function(){var t,n=I.Arithmetic,e=n.O;return null==this._tex&&((t=this.factors[1]).equ(e)?this._tex="0":t.isReal()?this._tex="1"===this.symbol?t.real.toTex():(t.real.equ(n.J)?"-":t.real.equ(n.I)?"":t.real.toTex())+this.symbolTex:this._tex="1"===this.symbol?"("+t.toTex()+")":"("+t.toTex()+")"+this.symbolTex),this._tex}}),g=I.Expr=Z(h,{constructor:function t(){var n,e,i=arguments.length&&(ot(arguments[0])||ft(arguments[0]))?arguments[0]:arguments;if(!(this instanceof t))return new t(i);for(this.terms=P(),this.terms[1]=d(1,I.Arithmetic.O),n=0,e=i.length;nW||!at(t)&&i.gt(t,W))return null;if(this.equ(r))return g();if(i.equ(r,t))return g([d(1,u)]);if(i.equ(u,t))return g(this.args());for(t=i.val(t),e=this,n=g([d(1,u)]);0!==t;)1&t&&(n=n.mul(e)),t>>=1,e=e.mul(e);return n}return this},d:function(t,n){var e=this;return null==n&&(n=1),n=+n,t=String(t||"x"),0>n?null:g(e.symbols().map(function(i){return"1"===i?I.Arithmetic.O:e.terms[i].d(t,n)}))},valueOf:function(t){var n=this;I.Arithmetic.O;return t=t||{},n.symbols().reduce(function(e,i){return e.add(n.terms[i].valueOf(t))},m.ZERO())},toString:function(){var t,n,e,i,r,u=I.Arithmetic.O,l="",s=!1;if(null==this._str){for(e=(t=this.symbols()).length,n=0;nn.length&&(i=t,t=n,n=i),r=t.length,u=n.length,l=new Array(r*u),0e+1&&(l.length=e+1)}return l}(n.coeff,t.coeff):[];else if(t instanceof a)if(t.equ(r))n.coeff=[];else if(t.equ(i.I));else for(e=n.coeff.length-1;e>=0;e--)n.coeff[e].c=n.coeff[e].c.mul(t);else if(i.isNumber(t))if(i.equ(r,t))n.coeff=[];else if(i.equ(i.I,t));else for(e=n.coeff.length-1;e>=0;e--)n.coeff[e].c=n.coeff[e].c.mul(t);return n},C:function(t,n){return new v(t||I.Arithmetic.O,n||"x")},fromExpr:function(t,n){if(!(t instanceof g))return null;n=String(n||"x");var e,i,r,u=t.symbols(),l=I.Arithmetic.O,s={};for(e=u.length-1;e>=0;e--)i=u[e],(r=t.terms[i].c()).equ(l)||("1"===i?s[0]=r.real:n===i?s[1]=r.real:i.length>n.length+1&&n+"^"===i.slice(0,n.length+1)&&-1===i.indexOf("*")&&(s[i.slice(n.length+1)]=r.real));return new v(s,n)},fromString:function(t){var n,e,i,r,u,l,s=I.Arithmetic,o={},f=null,c=/(\+|-)?\s*(\(?(?:(?:-?\\frac\{-?\d+\}\{-?\d+\})|(?:-?\d+(?:\/-?\d+)?))\)?)?(?:\s*\*?\s*([a-zA-Z])(?:\^\{?(\d+)\}?)?)?/g;for(t=M(String(t));(n=c.exec(t))&&n[0].length;)if(M(n[0]).length){if(n[3]){if(null==f)f=n[3];else if(n[3]!==f)continue;r=n[4]||"1",i=n[2]||"1"}else r="0",i=n[2]||"0";for(l=0;l=0;t--)if(!n[t].c.isInt())return!1;return!0},isMono:function(){var t=this.coeff;return 1===t.length&&0!==t[0].e},deg:function(){var t=this.coeff;return t.length?t[0].e:0},lc:function(){var t=this.coeff;return t.length?t[0].c:a.ZERO()},cc:function(){var t=this.coeff;return t.length?t[t.length-1].c:a.ZERO()},lead:function(){return this.lc()},c:function(){return this.cc()},primitive:function(t){var n,e,i,r=I.Arithmetic,u=this.coeff;return null==this._prim&&(u.length?(e=u.reduce(function(t,n){return r.mul(t,n.c.den)},r.I),n=u.map(function(t){return t.c.mul(e).integer()}),i=un(n),n=n.map(function(t){return r.div(t,i)}),r.gt(r.O,n[0])&&(n=n.map(function(t){return r.neg(t)}),i=r.neg(i)),this._prim=[v(n.map(function(t,n){return _(t,u[n].e)}),this.symbol),a(i,e).simpl()]):this._prim=[v([],this.symbol),a(r.I)]),!0===t?this._prim.slice():this._prim[0]},roots:function(){var t,n,e,i,r,u,l,s,o,f,c,h,m,d=I.Arithmetic,g=d.O;if(null==this._roots){if(t=[],0=0;e--)if(!u[e].c.equ(n[e].c)||u[e].e!==n[e].e)return!1;return!0}return t instanceof d?!(2<=u.length)&&(0===u.length?t.c().equ(r):(0===u[0].e?"1":this.symbol+"^"+u[0].e)===t.symbol&&t.c().equ(u[0].c)):t instanceof g?this.toExpr().equ(t):!!ht(t)&&(t===this.toString()||t===this.toTex())},gt:function(t){var n=I.Arithmetic;return t instanceof m||t instanceof a||n.isNumber(t)?!(0r.n?g.replace({coeff:_(r.Q.c.mul(h[r.n].c),r.Q.e+h[r.n].e),n:r.n+1,Q:r.Q}):g.pop(),u++,l.c.equ(A))continue}else l=_(r.coeff.c.neg(),r.coeff.e),d>r.n?g.replace({coeff:_(r.Q.c.mul(h[r.n].c),r.Q.e+h[r.n].e),n:r.n+1,Q:r.Q}):g.pop();h[0].e<=l.e?(e=Cn(e,[s=_(l.c.div(h[0].c),l.e-h[0].e)]),d>1&&g.push({coeff:_(s.c.mul(h[1].c),s.e+h[1].e),n:2,Q:s})):i=Cn(i,[l])}return g.dispose(),e=v(e,p.symbol),i=v(i,p.symbol),!0===n?[e,i]:e}return p},mod:function(t){return this.div(t,!0)[1]},divmod:function(t){return this.div(t,!0)},pow:function(t){var n,e,i=I.Arithmetic;if(!i.isNumber(t)||i.gt(i.O,t)||at(t)&&t>W||!at(t)&&i.gt(t,W))return null;if(0===(t=i.val(t)))return v(i.I,this.symbol);if(1===t)return v(this);if(2===t)return v.Mul(this,v(this));for(n=v(i.I,this.symbol),e=v(this);0!==t;)1&t&&(n=v.Mul(e,n)),t>>=1,e=v.Mul(e,e);return n},compose:function(t){var n,e,i,r,u=I.Arithmetic;u.O;if(t instanceof p)return null;if(t instanceof d&&(t=g(t)),t instanceof g&&(t=v.fromExpr(t,this.symbol)),t instanceof m&&(t=t.real),u.isNumber(t)||t instanceof a)return v(this.valueOf(t),this.symbol);if(t instanceof v){if(!this.coeff.length)return v([],t.symbol);if(0===this.deg())return v(this.coeff.slice(),t.symbol);if(0===t.deg())return v(this.valueOf(t.cc()),t.symbol);for(i=(e=this.coeff)[0].e,n=v(e[0].c,t.symbol),r=1;0t?this.coeff.map(function(n){return n.e<-t?null:_(n.c,n.e+t)}).filter(_.isNonZero):this.coeff.map(function(n){return _(n.c,n.e+t)}),this.symbol)},d:function(t){var n=I.Arithmetic;n.O;return null==t&&(t=1),0>(t=+t)?null:0===this.coeff.length?v([],this.symbol):t>=this.coeff[0].e?v([],this.symbol):v(this.coeff.map(function(e){if(t>e.e)return null;for(var i=n.I,r=e.e;r+t>e.e;r--)i=n.mul(i,r);return _(e.c.mul(i),e.e-t)}).filter(_.isNonZero),this.symbol)},valueOf:function(t){var n,e,i,r=I.Arithmetic.O,u=this.coeff;if(!u.length)return a.ZERO();for(t=t instanceof m?t.real:t instanceof a?t:a(t||r),n=u[0].e,i=u[0].c,e=1;0=0;e--)i.push(d(0===t[e].e?"1":1===t[e].e?n:n+"^"+String(t[e].e),t[e].c));i.length||i.push(d(1,r)),this._expr=g(i)}return this._expr}}),p=I.Matrix=Z(h,{constructor:function t(n,e,i){var r,u,l,s,o=I.Arithmetic;if(!(this instanceof t))return new t(n,e,i);if(ot(n)||ft(n))ot(n[0])||ft(n[0])?(ft(n)&&(n=R.call(n)),ft(n[0])&&(n=n.map(function(t){return R.call(t)})),this.val=n):this.val=e?pt(1,function(t){return pt(n.length,function(t){return n[t]})}):pt(n.length,function(t){return pt(1,function(e){return n[t]})});else if(null==e&&(e=n),n=+(n||0),e=+(e||0),this.val=pt(n,function(t){return pt(e,function(t){return o.O})}),ct(i))for(r in i)$.call(i,r)&&-1!==r.indexOf(",")&&(u=i[r],l=(r=r.split(",").map(function(t){return parseInt(M(t),10)}))[0],s=r[1],0<=l&&l(t=+t)||0>n?null:new p(pt(t,function(t){return pt(n,function(t){return e})}))},D:function(t,n,e){var i=I.Arithmetic.O;return e=e||i,null==n&&(n=t),n=+n,0>(t=+t)||0>n?null:new p(pt(t,function(t){return pt(n,function(n){return t===n?ot(e)||ft(e)?tt&&(t+=i),0>n&&(n+=r),0<=t&&t=t.nr?n.val[i].slice():i>=n.nr?t.val[i].slice():pt(w.max(n.nc,t.nc),function(r){return r>=t.nc?n.val[i][r]:r>=n.nc?t.val[i][r]:e.add(n.val[i][r],t.val[i][r])})})):n},sub:function(t){var n=this,e=I.Arithmetic;return t instanceof m?t=t.real.integer():t instanceof a&&(t=t.integer()),e.isNumber(t)?n.map(function(n){return e.sub(n,t)}):t instanceof p?p(pt(w.max(n.nr,t.nr),function(i){return i>=t.nr?n.val[i].slice():i>=n.nr?t.val[i].map(function(t){return e.neg(t)}):pt(w.max(n.nc,t.nc),function(r){return r>=t.nc?n.val[i][r]:r>=n.nc?e.neg(t.val[i][r]):e.sub(n.val[i][r],t.val[i][r])})})):n},mul:function(t){var n,e=this,i=I.Arithmetic;return t instanceof m?t=t.real.integer():t instanceof a&&(t=t.integer()),i.isNumber(t)?e.map(function(n){return i.mul(n,t)}):t instanceof p?(n=w.min(e.nc,t.nr),p(pt(e.nr,function(r){return pt(t.nc,function(u){for(var l=i.O,s=0;s=n.nr?t.val[i].slice():i>=t.nr?n.val[i].slice():pt(w.max(n.nc,t.nc),function(r){return r>=n.nc?t.val[i][r]:r>=t.nc?n.val[i][r]:e.mul(n.val[i][r],t.val[i][r])})})):n},kron:function(t){var n,e,i,r,u,l=this,s=I.Arithmetic;return t instanceof m?t=t.real.integer():t instanceof a&&(t=t.integer()),s.isNumber(t)?l.map(function(n){return s.mul(n,t)}):t instanceof p?(n=l.nr,e=l.nc,i=t.nr,r=t.nc,u=e*r,p(pt(n*i,function(n){var e=~~(n/i),o=n%i;return pt(u,function(n){var i=~~(n/r),u=n%r;return s.mul(l.val[e][i],t.val[o][u])})}))):l},div:function(t){var n=I.Arithmetic;return t instanceof m?t=t.real.integer():t instanceof a&&(t=t.integer()),n.isNumber(t)?this.map(function(e){return n.div(e,t)}):this},mod:function(t){var n=I.Arithmetic;return t instanceof m?t=t.real.integer():t instanceof a&&(t=t.integer()),n.isNumber(t)?this.map(function(e){return n.mod(e,t)}):this},divmod:lt,pow:function(t){var n,e,i=I.Arithmetic;if(!i.isNumber(t)||i.gt(i.O,t)||at(t)&&t>W||!at(t)&&i.gt(t,W))return null;if(0===(t=i.val(t)))return p.I(this.nc);if(1===t)return this.clone();if(2===t)return this.mul(this);for(n=null,e=this;0!==t;)1&t&&(n=null==n?e:e.mul(n)),t>>=1,e=e.mul(e);return n},fwdsub:function(t,n){var e,i,r,u,l,s,o,f=I.Arithmetic,c=f.O,h=this.val;for(t instanceof p&&(t=t.col(0)),n instanceof p&&(n=n.diag()),u=w.min(this.nr,this.nc,t.length),l=new Array(u),e=0;e=0;e--){for(r=c,i=u-1;i>e;i--)r=f.add(r,f.mul(h[e][i],l[i]));if(s=f.sub(t[e],r),o=h[e][e],f.equ(c,o)){if(!f.equ(c,s))return null}else if(n)s=f.mul(s,f.div(n[e],o));else{if(!f.equ(c,f.mod(s,o)))return null;s=f.div(s,o)}l[e]=s}return l},backsuby:function(t){var n,e,i,r,u,l,s,o=I.Arithmetic,f=o.O,c=this.val;for(t instanceof p&&(t=t.col(0)),r=w.min(this.nr,this.nc,t.length),u=new Array(r),n=r-1;n>=0;n--){for(i=f,e=r-1;e>n;e--)i=o.add(i,o.mul(c[n][e],u[e]));if(l=o.sub(o.mul(c[r-1][r-1],t[n]),i),s=c[n][n],o.equ(f,s)||!o.equ(f,o.mod(l,s)))return null;l=o.div(l,s),u[n]=l}return u},snf:function(){var t,n,e,i,r,u,l,s,o,f,c,h,a,m,d,g,_,v,b,A,y,q=I.Arithmetic,x=q.O,O=q.I,S=q.J,N=this.nr,R=this.nc;if(null==this._snf){for(t=w.min(N,R),n=this.clone(),e=p.I(N),i=p.I(R),r=-1,u=0;u=0;a--)m=on(n.val[a][a],n.val[h][h]),q.equ(x,m[0])||(d=m[1],g=m[2],_=q.div(n.val[h][h],m[0]),v=q.div(n.val[a][a],m[0]),A=q.mul(g,_),y=q.sub(O,q.mul(d,v)),p.MULR(n.val,a,h,O,g,_,q.sub(A,O)),p.MULC(e.val,a,h,q.sub(O,A),g,_,S),p.MULC(n.val,a,h,d,y,O,q.mul(S,v)),p.MULR(i.val,a,h,v,y,O,q.mul(S,d)));this._snf=[n,e,i]}return this._snf.slice()},lu:function(){var t,n,e,i,r,u,l,s,o,f,c,h,a,m=I.Arithmetic,d=m.O,g=m.I,_=(m.J,this.nr),v=this.nc;if(null==this._lu){for(a=!1,e=this.clone(),n=p.I(_),i=pt(_,function(){return d}),t=p.I(_),r=g,u=0;u<_-1;u++){if(m.equ(d,e.val[u][u])){for(o=u+1,f=!0;o<_&&f;)m.equ(d,e.val[o][u])?o++:f=!1;if(_<=o){a=!0;break}p.SWAPR(e.val,u,o),p.SWAPR(t.val,u,o)}for(c=e.val[u][u],n.val[u][u]=c,i[u]=m.mul(r,c),l=u+1;l<_;l++){for(h=e.val[l][u],n.val[l][u]=h,s=u+1;s=0;e--)if(t===i[e][n])return e;return-1}for(e=q,ot(n)&&(e=w.min(e,n[1])),g=this.clone(!0),i=new Array(e),f=0,r=b,u=0;ux&&(i.length=x),this._ref=[g,i,r]}return t?this._ref.slice():this._ref[0]},rref:function(t,n){var e,i,r,u,l,s,o,f,c,h,a=I.Arithmetic,m=a.O,d=a.I,g=a.J,_=(this.nr,this.nc);if(null==this._rref){for(f=(h=this.ref(!0,n))[0].clone(),e=h[1],i=h[2],r=e.length,l=0;lt&&(t+=u),0>n&&(n+=l),0>e&&(e+=u),0>i&&(i+=l),t=w.max(0,w.min(u-1,t)),e=w.max(0,w.min(u-1,e)),n=w.max(0,w.min(l-1,n)),i=w.max(0,w.min(l-1,i)),t<=e&&n<=i?p(pt(e-t+1,function(e){return pt(i-n+1,function(i){return r.val[t+e][n+i]})})):p()):p()},concat:function(t,n){var e=this,i=I.Arithmetic.O;return t instanceof p?p("vertical"===(n=n||"horizontal")?pt(e.nr+t.nr,function(n){return pt(w.max(e.nc,t.nc),function(r){return r>=e.nc?n=t.nc?n=e.nr?r=t.nr?rt[e]&&(t[e]=i.length),t},t)},pt(this.nc,function(){return 0})),this._str=this.val.map(function(n,e){return"|"+n.map(function(n,e){return Lt(String(n),t[e])}).join(" ")+"|"}).join("\n")),this._str},toTex:function(){return null==this._tex&&(this._tex="\\begin{bmatrix}"+this.val.map(function(t,n){return t.map(function(t,n){return _t(t)}).join(" & ")}).join(" \\\\ ")+"\\end{bmatrix}"),this._tex}}),I.BitArray=Z({constructor:function t(n){if(!(this instanceof t))return new t(n);this.length=n,this.bits=new Uint32Array(w.ceil(n/32))},length:0,bits:null,dispose:function(){return this.length=null,this.bits=null,this},clone:function(){var t=new I.BitArray(this.length);return t.bits=new Uint32Array(this.bits),t},fromArray:function(t){return this.bits=new Uint32Array(t),this},toArray:function(){return R.call(this.bits)},toString:function(){return this.toArray().map(dt).join("")},reset:function(){var t,n=this.bits,e=n.length;for(t=0;t>>5]&1<<(31&t))},set:function(t){return this.bits[t>>>5]|=1<<(31&t),this},unset:function(t){return this.bits[t>>>5]&=~(1<<(31&t)),this},toggle:function(t){return this.bits[t>>>5]^=1<<(31&t),this}}),u=I.Filter=Z({constructor:function t(n){if(!(this instanceof t))return new t(n);this.filter=n||null},__static__:{UNIQUE:function(){return u(function(t){var n,e=t.length,i={};for(n=0;narguments.length||null==n)&&(n=!0),ht(t)&&("<"===t?(t=1,n=!0):">"===t?(t=-1,n=!0):"<="===t||"=<"===t?(t=1,n=!1):">="!==t&&"=>"!==t||(t=-1,n=!1)),u(-1===(t=-1===(t=+t)?-1:1)?function(t){for(var e=t[0],i=1,r=t.length;i=t[i]||!n&&e>t[i])return!1;e=t[i]}return!0})},LEN:function(t,n){return t=+t,u(">="===(n=n||"==")?function(n){return n.length>=t}:">"===n?function(n){return n.length>t}:"<"===n?function(n){return n.length="===(e=e||"==")||"=>"===e?function(e){return 0<=t&&t=n}:">"===e?function(e){return 0<=t&&tn}:"<"===e?function(e){return 0<=t&&t="===(n=n||"==")||"=>"===n?function(n){return vt(function(t,e){return n[e]>t&&(t=n[e]),t},-1/0,null,0,n.length-1,1)>=t}:">"===n?function(n){return vt(function(t,e){return n[e]>t&&(t=n[e]),t},-1/0,null,0,n.length-1,1)>t}:"<"===n?function(n){return vt(function(t,e){return n[e]>t&&(t=n[e]),t},-1/0,null,0,n.length-1,1)t&&(t=n[e]),t},-1/0,null,0,n.length-1,1)<=t}:"!="===n?function(n){return vt(function(t,e){return n[e]>t&&(t=n[e]),t},-1/0,null,0,n.length-1,1)!==t}:function(n){return vt(function(t,e){return n[e]>t&&(t=n[e]),t},-1/0,null,0,n.length-1,1)===t})},MIN:function(t,n){return t=+t,u(">="===(n=n||"==")||"=>"===n?function(n){return vt(function(t,e){return n[e]=t}:">"===n?function(n){return vt(function(t,e){return n[e]t}:"<"===n?function(n){return vt(function(t,e){return n[e](n=+n)){var i=t;t=n,n=i}return(3>arguments.length||null==e)&&(e=!0),u(e?function(e){for(var i=0,r=e.length;in)return!1;return!0}:function(e){for(var i=0,r=e.length;i=n)return!1;return!0})}},filter:null,dispose:function(){return this.filter=null,this},apply:function(t,n){var e=this.filter;return!e||!mt(e)||Boolean(e.call(n||null,t))},NOT:function(){var t=this;return u(function(n){return!t.apply(n,this)})},OR:function(t){var n=this;return mt(t)||t instanceof u?(t instanceof u||(t=u(t)),u(function(e){return n.apply(e,this)||t.apply(e,this)})):n},XOR:function(t){var n=this;return mt(t)||t instanceof u?(t instanceof u||(t=u(t)),u(function(e){var i=n.apply(e,this),r=t.apply(e,this);return i&&!r||!i&&r})):n},AND:function(t){var n=this;return mt(t)||t instanceof u?(t instanceof u||(t=u(t)),u(function(e){return n.apply(e,this)&&t.apply(e,this)})):n}}),n=I.Iterator=Z({constructor:function t(n,e){var i=I.Arithmetic;if(!(this instanceof t))return new t(n,e);(ot(n)||ft(n))&&(n[0]instanceof t||n[n.length-1]instanceof t)?(this.name="Iterator",this.$=e||{},this.$.seq=ft(n)?R.call(n):n,this.$.count=vt(function(t,n){return i.add(t,n.total())},i.O,this.$.seq),this.rewind()):mt(n)?(this.name="Generator",this.$={},this.$.generator=n,this.$.state=e||{},this.$.count=i.I,this.rewind()):(this.name=n||"Iterator",this.$=e||{},this.$.count=this.$.count||i.O)},__static__:{Iterable:function t(n,e){if(!(this instanceof t))return new t(n,e);e=-1===e?-1:1,this.next=function(){var t=n.hasNext(e)?n.next(e):null;return null==t?{done:!0}:{value:t}}}},name:"Iterator",$:null,__index:null,__item:null,_index:null,_item:null,__subindex:null,_subindex:null,__subitem:null,_subitem:null,dispose:function(){return this.$.seq&&this.$.seq.length&&(vt(function(t,n){n.dispose()},null,this.$.seq),this.$.seq=null),this.$=null,this.__index=null,this.__item=null,this._index=null,this._item=null,this.__subindex=null,this._subindex=null,this.__subitem=null,this._subitem=null,this},filterBy:function(t){var n=this.$;return!1===t?n.filter&&(n.filter=null):(t instanceof u||mt(t))&&(n.filter=t instanceof u?t:u(t)),this},mapTo:function(t){var n=this.$;return!1===t?n.output&&(n.output=null):mt(t)&&(n.output=t),this._item=this.output(this.__item),this},fuse:function(t,e,i){var r=this.$;return 1===arguments.length&&!1===t?r.sub&&(r.sub=null,r.submethod=null,r.subcascade=null,r.subcount=null,this.rewind()):e instanceof n&&mt(t)&&(r.sub=e,r.submethod=t,r.subcascade=-1===i?-1:1,r.subcount=I.Arithmetic.mul(r.count,e.total()),this.rewind()),this},unfuse:function(){return this.fuse(!1)},juxtaposeWith:function(t,n){return this.fuse(function(t,n){return[].concat(t).concat(n)},t,n)},state:function(t){return arguments.length?(this.$.state=t,this):this.$.state},output:function(t){var n=this.$.output;return null==t?null:mt(n)?n(t):t},fusion:function(t,n){var e,i=this.$;return i.sub?(-1===i.subcascade&&(e=t,t=n,n=e),null==t||null==n?t||n||null:i.submethod.call(this,t,n)):t},order:function(){return this},rewind:function(t,n){var e,i,r,u=this.$;if(t=-1===t?-1:1,ot(u.seq)){for(e=0,i=u.seq.length;et?i-1:0;do{null==(r=u.seq[u.seqindex].next(t))&&(u.seqindex+=t)}while(null==r&&0<=u.seqindex&&u.seqindexr.seqindex||r.seqindex>=r.seq.length)&&r.sub&&r.sub.hasNext(t)&&(this.rewind(t,!0),i=this.__item,this.__subitem=r.sub.next(t)),this.__item=i,this._item=this.output(this.__item),this._subitem=r.sub&&null!=this._item&&null!=this.__subitem?this.fusion(this._item,this.__subitem):null}while(r.filter&&null!=e&&!r.filter.apply(e,this));return e}if(mt(r.generator)){do{n=this.__item,e=r.sub?this._subitem:this._item,this.__item=r.generator.call(this,n,t,r.state,!1),null==this.__item&&r.sub&&r.sub.hasNext(t)&&(this.rewind(t,!0),this.__subitem=r.sub.next(t)),this._item=this.output(this.__item),this._subitem=r.sub&&null!=this._item&&null!=this.__subitem?this.fusion(this._item,this.__subitem):null}while(r.filter&&null!=e&&!r.filter.apply(e,this));return e}return null},get:function(t){var n,e,i=[];if(mt(t))for(;this.hasNext()&&null!=(n=this.next())&&t(n);)i.push(n);else for(e=!arguments.length||null==t,null!=t&&(t=+t);(e||i.lengths&&(s=e),ef&&(f=i),i(e=-1===e?-1:1)||K&(n&&null!=n.order?n.order:tt)?n.seq[n.seq.length-1].item0(e):n.seq[0].item0(e):null},succ:function(t,n,e,i,r,u){if(null==e||null==t)return null;var l,s,o,f,c,h=I.Arithmetic;if(r=-1===r?-1:1,i&&"sequence"===i.type){if(!(c=i.seq)||!c.length)return null;for(K&(i&&null!=i.order?i.order:tt)?(l=-1,s=c.length-1):(l=1,s=0),f=l*i.seq_curr+s,o=l*r;0<=f&&fr?h.J:h.I),e,i)},rand:function(t,n){var e,i,r,u,l,s,o=I.Arithmetic,f=o.O;if(n&&"sequence"===n.type){if(!(r=n.seq)||!r.length)return null;for(e=null!=n.last?n.last:o.sub(this.count(t,n),o.I),i=o.rnd(f,e),u=0,l=r.length;o.gte(i,s=r[u].total())&&(i=o.sub(i,s),!(++u>=l||o.lt(i,f))););return u=o.$.mindimension&&u<=o.$.maxdimension){if(l=o[N].rank(t,o.n,o.$),c.gt(l,a)){f=!0;break}s=c.add(s,o.total())}return f?c.add(l,s):a}return lt()},unrank:function(t,n,e){if(e&&"sequence"===e.type){var i,r,u=I.Arithmetic,l=u.O,s=e.seq;if(!s||!s.length)return null;if(null==t||!u.inside(t,u.J,null!=e.count?e.count:this.count(n,e)))return null;for(r=s.length,i=0;u.gte(t,s[i].total())&&(t=u.sub(t,s[i].total()),!(++i>=r||u.lt(t,l))););return if&&(f=n[t]+1),n[t]):f+e[t-n.length]}:function(t){return t=0;d--)b.splice(n[d],1);for(d=0,m=0;mt?u.seq.length-1:0:-1),it&f?("gen"===I.Options.RANDOM||1===u.rand[u.type]||s.gt(e,I.Options.MAXMEM)||s.isDefault()&&0>e?(this.__item=r.rand(l,u),this.__index=o):(this._traversed&&this._traversed.dispose(),this._traversed=new I.BitArray(s.val(e)),n=this.random("index"),this._traversed.set(+n),this.__item=r.unrank(n,l,u),null!=this.__item&&(this.__index=n)),this._index=o):(this.__item=r.initial(l,u,t,!0),null!=this.__item&&(this.__index=0>t?i:o,this._update()),this._index=this.__index),this._item=this.output(this.__item),this._prev=!(it&f||0t&&!(it&f))&&null!=this.__item,this},_update:function(){return this.item__=null,this},order:function(t,n){if(!arguments.length)return this._order;this[N];var e,i,r,u,l,s,o=I.Arithmetic,f=(o.O,o.I,!0===t);if(n=-1===n,this.n,r=this.$,this._traversed&&(this._traversed.dispose(),this._traversed=null),f?t=r.order:ht(t)&&-1<(i=t.indexOf("|"))?(e=t.substr(i+1),t=Qn(t.substr(0,i))):e=t=Qn(t),u=n?-1:1,r.order=t,r.sub?(f?r.sub.rewind(u):r.sub.order(e,u),this.__subindex=r.sub.index(),this.__subitem=r.sub.next(u),this._subindex=null,this._subitem=null):(this.__subindex=null,this.__subitem=null,this._subindex=null,this._subitem=null),"sequence"===r.type&&r.seq&&r.seq.length)for(l=0,s=r.seq.length;l(t=-1===t?-1:1)&&it&p)return null;n=0>t?g:d;do{if(f=null!=(o=v.sub?this._subitem:this._item),it&p)if(u=v.last,a.lt(this._index,u))if(e=this._traversed){for(r=this.random("index"),s=I.Math.rnd()>.5?g:d;e.isset(+r);)r=a.wrap(a.add(r,s),m,u);e.set(+r),this.__item=h.unrank(r,_,v),null!=this.__item&&(this.__index=r)}else this.__item=h.rand(_,v),this.__index=null;else this._item=this.__item=null,this._traversed&&(this._traversed.dispose(),this._traversed=null);else this.__item=h.succ(this.__item,this.__index,_,v,t,this.item__),null!=this.__item&&(this.__index=a.add(this.__index,n));if(c=null!=this.__item)this._index=a.add(this._index,n),null===this.__index&&(this.__index=this._index),0>t?(this._prev=c,this._next=f):(this._prev=f,this._next=c);else if(v.sub&&v.sub.hasNext(t))if(this.__subindex=v.sub.index(),this.__subitem=v.sub.next(t),null==this.__subitem)this.__subindex=null,this.__subitem=null,0>t?(this._prev=c,this._next=f):(this._prev=f,this._next=c);else{if("sequence"===v.type&&v.seq&&v.seq.length)for(i=0,l=v.seq.length;it?(this._prev=c,this._next=f):(this._prev=f,this._next=c);this._item=this.output(this.__item),v.sub&&(c=c&&null!=this.__subitem,this._subindex=c?a.add(a.mul(this.__subindex,b),this._index):null,this._subitem=c?this.fusion(this._item,this.__subitem):null,0>t?this._prev=c:this._next=c)}while(v.filter&&null!=o&&!v.filter.apply(o,this));return o},range:function(t,n){var e,i,r,u,l,s,o=I.Arithmetic,f=o.num,c=o.O,h=o.I,a=this.$,m=a.sub?a.subcount:a.count,d=a.sub?o.sub(m,h):a.last,g=1,_=arguments.length,v=!(it&a.order);if(_<1?(t=c,n=d):_<2?(t=f(t),n=d):(t=f(t),n=f(n)),t=o.wrapR(t,m),n=o.wrapR(n,m),o.gt(t,n)&&(e=t,t=n,n=e,g=-1),t=o.clamp(t,c,d),v&&(n=o.clamp(n,c,d)),o.lte(t,n)){for(s=[this.$.order,this.__index,this._index,this.__item&&this.__item.slice(),this._item,this.__subindex,this._subindex,this.__subitem,this._subitem,this._prev,this._next],v&&this.index(t),r=o.val(o.sub(n,t)),i=new Array(r+1),l=0;l<=r&&null!=(u=this.next());)i[l++]=u;i.length>l&&(i.length=l),0>g&&1t?i.INF===this._max?(this.__item=null,this._item=null):("geometric"===this.$.type?this.__item=i.mul(this._min,i.pow(this._step,this.$.last)):this.__item=i.add(this._min,i.mul(this._step,this.$.last)),this._item=this.output(this.__item)):(this.__item=this._min,this._item=this.output(this.__item)),e.sub&&!0!==n&&(e.sub.rewind(t),this.__subitem=e.sub.next(t),this._subitem=null!=this._item&&null!=this.__subitem?this.fusion(this._item,this.__subitem):null),this},hasNext:function(t){t=-1===t?-1:1;var n=this.$;return I.Arithmetic.INF===this._max?0t?r.equ(e,this._min)?this.__item=null:this.__item=r.div(e,this._step):r.INF!==this._max&&r.equ(e,this._max)?this.__item=null:this.__item=r.mul(e,this._step):0>t?r.equ(e,this._min)?this.__item=null:this.__item=r.sub(e,this._step):r.INF!==this._max&&r.equ(e,this._max)?this.__item=null:this.__item=r.add(e,this._step),null!=this.__item&&(r.lt(this.__item,this._min)||r.INF!==this._max&&r.gt(this.__item,this._max))&&(this.__item=null),this._item=null==this.__item?null:this.output(this.__item)),null==this.__item&&i.sub&&i.sub.hasNext(t)&&(this.rewind(t,!0),this.__subitem=i.sub.next(t),this._subitem=null!=this._item&&null!=this.__subitem?this.fusion(this._item,this.__subitem):null)}while(i.filter&&null!=n&&!i.filter.apply(n,this));return n}}),f=function t(){var n=this,e=null;if(!(n instanceof t))return new t;e=P(),n.dispose=function(){return n.empty(),e=null,n},n.empty=function(){var t,i,r,u;if(!e)return n;for(t in e)if($.call(e,t)&&null!=e[t])for(r=0,u=(i=e[t]).length;r(t=-1===t?-1:1))return null;var n,e,i,r,u,l=this.$,s=this._multiples,o=this._small_primes,f=I.Arithmetic,c=f.II,h=this.__item;do{if(this._pt[1]&&(t[1]=n),t},[1/0,0],r);if(n.base=r,n.minbase=o[0],n.maxbase=o[1],n.dimension=r.length,"gray"===n.output)n.output=function(n,e){return t.gray(n,e)};else if("inversion"===n.output)n.output=function(n,e){return t.inversion(n)};else if(ot(n.output)){var f=n.output;n.output=function(n,e){return t.component(n,f)}}}e.call(this,"Tensor",r,n,i?{method:"partial"===n.type?n.submethod||"complete":n.submethod,iter:i,pos:"partial"===n.type?n.subpos||n.position:n.subpos,cascade:n.subcascade}:null)},__static__:{C:e.C,P:e.P,T:e.T,DUAL:e.DUAL,count:function(t,n){var e=I.Arithmetic.O,i=n&&n.type?n.type:"tensor";return"partial"===i?n.data&&n.data.length?I.Arithmetic.num(n.data.length):e:"tuple"===i?!t||0>=t[0]?e:bn(t[1],t[0]):t&&t.length?jt(t):e},initial:function(t,n,e){var i,r=n&&n.type?n.type:"tensor",u=n&&n.order?n.order:tt;return e=-1===e?-1:1,(!(nt&u)&&K&u||nt&u&&!(K&u))&&(e=-e),"partial"===r?i=n.data&&n.data.length?0>e?n.data[n.data.length-1]:n.data[0]:null:(i="tuple"===r?t[0]?pt(t[0],0>e?t[1]-1:0,0):[]:t.length?0>e?pt(t.length,function(n){return t[n]-1}):pt(t.length,0,0):[],i=this.DUAL(i,t,n)),i},succ:function(t,n,e,i,r,u){if(!e||null==t)return null;var l,s=i&&i.type?i.type:"tensor",o=i&&null!=i.order?i.order:tt,f=I.Arithmetic;return r=-1===r?-1:1,"partial"===s?i.data&&i.data.length?(K&o&&(r=-r,null!=n&&(n=f.sub(f.num(i.data.length-1),n))),null==n&&(n=zn(i.data,t,!0)),l=f.val(n),0>r?0<=l-1?i.data[l-1]:null:0<=l&&l+1=e[0]?null:function(t,n,e,i,r,u){var l,s,o,f,c,h,a,m,d,g=n;"tuple"===i?(l=g[0],g=g[1]):l=g.length;0,h=1,f=d=l-1,c=0,a=1,m=0,nt&r&&(h=-h,f=d-f,c=d-c,a=-a,m=d-m);Y&r&&(h=-h,f=d-f,c=d-c,a=-a,m=d-m);K&r&&(e=-e);if(0>e)if("tuple"===i){for(s=f;0<=s&&d>=s&&0===t[s];)s-=h;if(0<=s&&d>=s)for(g-=1,t[s]=t[s]-1,o=s+h;0<=o&&d>=o;o+=h)t[o]=g;else t=null}else{for(s=f;0<=s&&d>=s&&0===t[s];)s-=h;if(0<=s&&d>=s)for(t[s]=t[s]-1,o=s+h;0<=o&&d>=o;o+=h)t[o]=g[a*o+m]-1;else t=null}else if("tuple"===i){for(s=f;0<=s&&d>=s&&t[s]+1===g;)s-=h;if(0<=s&&d>=s)for(t[s]=t[s]+1,o=s+h;0<=o&&d>=o;o+=h)t[o]=0;else t=null}else{for(s=f;0<=s&&d>=s&&t[s]+1===g[a*s+m];)s-=h;if(0<=s&&d>=s)for(t[s]=t[s]+1,o=s+h;0<=o&&d>=o;o+=h)t[o]=0;else t=null}return t}(t,e,r,s,o)},rand:function(t,n){var e,i=I.Math.rndInt,r=n&&n.type?n.type:"tensor";return"partial"===r?e=n.data&&n.data.length?n.data[i(0,n.data.length-1)]:null:(e="tuple"===r?t[0]?pt(t[0],function(n){return i(0,t[1]-1)}):[]:t.length?pt(t.length,function(n){return i(0,t[n]-1)}):[],e=this.DUAL(e,t,n)),e},randu:e.rand,rank:function(t,n,e){var i,r,u=I.Arithmetic,l=e&&null!=e.order?e.order:tt,s=e&&e.type?e.type:"tensor",o=u.add,f=u.sub,c=u.mul,h=u.O,a=u.J;if("partial"===s)h=u.num(zn(e.data,t,!0));else if(t=this.DUAL(t,n,e),"tuple"===s){if(!(i=n[0]))return a;for(n=n[1],r=0;r=0;u--)l=m(i,r),i=d(i,r),s[u]=g(l)}else{if(!(o=n.length))return[];for(s=new Array(o),i=t,u=o-1;u>=0;u--)l=m(i,r=n[u]),i=d(i,r),s[u]=g(l)}s=this.DUAL(s,n,e)}return s},gray:function(t,n){return xt(new Array(t.length),t,n)},inversion:function(t){var n,e=t.length,i=e?[0]:[];for(n=1;n=t+e[n].length&&(t+=e[n++].length),t+e[n][i-t]})},component:function(t,n){return null==t?null:null==n?t:pt(t.length,function(e){return e=t.length||null==t[e])return n[e];var i=t[e];return at(i)?n[e]+i:i[0]*n[e]+(i[1]||0)})}:st},conditional:En,generate:function(t,n,e,i,r){r=r||{},e=e||pt(n.length||0,0,1);var u,l,s,o,f,c,h,a,m,d,g=null==r.min?0:r.min,_=null==r.max?t-1:r.max,v=_-g+1,p=n,b=p.length,A=!1,y=[],q=[],x={},I=function(t){return g<=t&&t<=_};for(n=[],A=!1,c=0,s=0;su[1]?Dn(t,pt(u[0]-u[1]+1,u[1],1).filter(I)).reverse():Dn(t,pt(u[1]-u[0]+1,u[0],1).filter(I)):Dn(t,u[1].split(",").map(Number).filter(I))).length){A=!0;break}n.push(o)}else if(u=l.match(L)){if(!(o=0u[1]?pt(u[0]-u[1]+1,u[0],-1):pt(u[1]-u[0]+1,u[0],1)).filter(I):u[1].split(",").map(Number).filter(I)).length){A=!0;break}n.push(o)}else{if(a=!0,h=[],m=null,l=l.replace(k,function(t,n){var e=parseInt(n,10),i="v"+String(e);return!isNaN(e)&&I(e)||(a=!1),a&&-1===h.indexOf(e)&&h.push(e),i}),!a){e&&e.splice(c--,1);continue}h.sort(kt());try{m=new Function(h.map(function(t){return"v"+String(t)}).join(","),"return Math.floor("+l+");")}catch(t){m=null}if(!mt(m)){e&&e.splice(c--,1);continue}for(f=0;fn||n>_))return!1;return!0})).length){A=!0;break}n[u[1][f]]=o}if(A)break}return A?[]:(i="="===i?z:"!="===i||"<>"===i?G:"<"===i?Q:"<="===i||"=<"===i?V:">"===i?B:(">="===i||"=>"===i)&&H,d=mt(r.extra_conditions)?function(t,n,u){var l=t[n];return!(g>l||l>_||Q===i&&e[n]>l||B===i&&e[e.length-1]-e[n]>l)&&r.extra_conditions(t,n,u)}:function(t,n,r){var u=t[n];return!(g>u||u>_||Q===i&&e[n]>u||B===i&&e[e.length-1]-e[n]>u)},!0===r.lazy?n:En(n,i,d))}}}),I.Permutation=Z(e,{constructor:function t(n,i){var r=null;if(!(this instanceof t))return new t(n,i);(i=i||{}).type=String(i.type||"permutation").toLowerCase(),(n=n||0)instanceof e?n=(r=n).dimension():r=i.sub,i.base=i.dimension=n,i.rand=i.rand||{},i.rand.derangement=1,i.rand.involution=1,i.rand.connected=1,"multiset"===i.type&&(i.multiplicity=ot(i.multiplicity)&&i.multiplicity.length?i.multiplicity.slice():pt(n,1,0),i.multiplicity=i.multiplicity.concat(pt(n-vt(Tt,0,i.multiplicity),1,0)),i.base=i.multiplicity.length,i.multiset=jn(i.multiplicity,n)),e.call(this,"Permutation",n,i,r?{method:i.submethod,iter:r,pos:i.subpos,cascade:i.subcascade}:null)},__static__:{C:e.C,P:e.P,T:e.T,DUAL:e.DUAL,count:function(t,n){var e=I.Arithmetic,i=e.O,r=n&&n.type?n.type:"permutation",u=n&&null!=n["cycles="]?0|n["cycles="]:null,l=n&&null!=n["fixed="]?0|n["fixed="]:null;return 0>t?i:"cyclic"===r?e.num(t):"multiset"===r?yn(t,n.multiplicity):"derangement"===r?l?2>t-l?i:e.mul(yn(t,l),yn(t-l,!1)):2>t?i:yn(t,!1):"involution"===r?yn(t,!0):"connected"===r?yn(t-1):u?qn(t,u,1):yn(t)},initial:function(t,n,e){var i,r=n&&n.type?n.type:"permutation",u=n&&null!=-n.order?n.order:tt,l=n&&null!=n["cycles="]?0|n["cycles="]:null,s=n&&null!=n["fixed="]?0|n["fixed="]:null;if(0===t)return[];if(e=-1===e?-1:1,(!(nt&u)&&K&u||nt&u&&!(K&u))&&(e=-e),"cyclic"===r)i=0>e?[t-1].concat(pt(t-1,0,1)):pt(t,0,1);else if("derangement"===r){if(s||2>t)return null;if(1&t){var o=w.floor(t/2);i=0>e?pt(t-o-1,t-1,-1).concat([o-1,o]).concat(pt(o-1,o-2,-1)):pt(t-3,function(t){return 1&t?t-1:t+1}).concat([t-2,t-1,t-3])}else i=0>e?pt(t,t-1,-1):pt(t,function(t){return 1&t?t-1:t+1})}else i="multiset"===r?0>e?n.multiset.slice().reverse():n.multiset.slice():"connected"===r?null:"involution"===r?0>e?pt(t,t-1,-1):pt(t,0,1):l?null:0>e?pt(t,t-1,-1):pt(t,0,1);return i=this.DUAL(i,t,n)},succ:function(t,n,e,i,r,u){if(!e||0>=e||null==t)return null;var l=i&&i.type?i.type:"permutation",s=i&&null!=i["cycles="]?0|i["cycles="]:null,o=i&&null!=i["fixed="]?0|i["fixed="]:null;return"derangement"===l&&o||"permutation"===l&&s?null:function(t,n,e,i,r,u,l){var s,o,f,c,h,a,m,d,g,_,v,p,b,A=n,y=null==u?A:u;0,d=1,m=b=A-1,g=1,_=0,v=1,p=0,nt&r&&(d=-d,m=b-m,g=-g,_=y-1-_,e=-e);Y&r&&(d=-d,m=b-m,v=-1,p=y-1);K&r&&(e=-e);if(0>e)if("cyclic"===i)if(g*t[s=b-m]+_>0)for(v=A-1,d=A+d,f=0;f0&&g*t[s]<=g*t[o];)o-=d;for(h=t[s],t[s]=t[o],t[o]=h,f=s+d,c=m;0<=f&&f<=b&&0<=c&&c<=b&&d*(c-f)>0;)h=t[f],t[f]=t[c],t[c]=h,a=a||v*f+p===t[f]||v*c+p===t[c],f+=d,c-=d;if("derangement"===i)for(0<=o&&o<=b&&(a=a||v*o+p===t[o]),0<=c&&c<=b&&(a=a||v*c+p===t[c]),a=a||v*s+p===t[s],f=s-d;!a&&0<=f&&f<=b;f-=d)a=v*f+p===t[f];else a=!1}else t=null}while(t&&a);else if("cyclic"===i)if(g*t[s=b-m]+_=g*t[s+d];)s-=d;if(0<=s&&s<=b){for(o=m;0<=o&&o<=b&&d*(o-s)>0&&g*t[s]>=g*t[o];)o-=d;for(h=t[s],t[s]=t[o],t[o]=h,f=s+d,c=m;0<=f&&f<=b&&0<=c&&c<=b&&d*(c-f)>0;)h=t[f],t[f]=t[c],t[c]=h,a=a||v*f+p===t[f]||v*c+p===t[c],f+=d,c-=d;if("derangement"===i)for(0<=o&&o<=b&&(a=a||v*o+p===t[o]),0<=c&&c<=b&&(a=a||v*c+p===t[c]),a=a||v*s+p===t[s],f=s-d;!a&&0<=f&&f<=b;f-=d)a=v*f+p===t[f];else a=!1}else t=null}while(t&&a);return t}(t,e,r=-1===r?-1:1,l,i&&null!=i.order?i.order:tt,i&&null!=i.base?i.base:null)},rand:function(t,n){var e,i=I.Math.rndInt,r=n&&n.type?n.type:"permutation",u=n&&null!=n["cycles="]?0|n["cycles="]:null,l=n&&null!=n["fixed="]?0|n["fixed="]:null;if(0===t)return[];if("cyclic"===r){var s=i(0,t-1);e=0v&&(m=y[a=i(0,b-1)],--b,g=y[a],y[a]=y[b],y[b]=g,g=e[m],e[m]=e[h],e[h]=g)}else if("multiset"===r)e=Ct(n.multiset.slice());else if("connected"===r)e=Ct(pt(t,0,1),!0);else{if(u)return null;e=Ct(pt(t,0,1))}return e=this.DUAL(e,t,n)},randu:e.rand,rank:function(t,n,e){var i,r,u,l,s,o=I.Arithmetic,f=e&&e.type?e.type:"permutation",c=e&&null!=e["cycles="]?0|e["cycles="]:null,h=(e&&null!=e["fixed="]&&e["fixed="],e&&null!=-e.order?e.order:tt),a=o.sub,m=o.add,d=o.mul,g=o.div,_=o.O,v=o.I,p=o.J;if(!(n=n||t.length))return _;if(t=this.DUAL(t,n,e),"cyclic"===f)_=o.num(t[0]);else{if("derangement"===f||"involution"===f||"connected"===f)return lt();if("multiset"===f)for(s=e.multiplicity.slice(),l=e&&null!=e.count?e.count:yn(n,s),u=n-1,i=0;i=0;u--)o=g(r,s=n-u),r=_(r,s),i[u]=b(o);Xn(i,i)}}return i=this.DUAL(i,n,e)},permute:Wn,shuffle:function(t,n){if("cyclic"===n){var e=t.length,i=I.Math.rndInt(0,e-1);return 0=n+i&&(n+=i,i=t[++e].length),n+t[e][r-n]})}(ot(arguments[0])&&ot(arguments[0][0])?arguments[0]:R.call(arguments)):null},cycles:function(t,n){return-1===n?cycles2permutation(t):Zn(t)},swaps:function(t,n){return-1===n?function(t,n){var e,i,r,u=t.length,l=new Array(n);for(e=0;e=l&&(r=0,i++);else for(i=0,r=0;i=l&&(r=0,i++);return t}(null,t,n):function(t,n,e){var i,r,u=n.length,l=u*u;for(t=t||new Array(l),i=0,r=0;i=u&&(r=0,i+=u);if(!0===e)for(i=0;i(i=t[e])||i>=n||0n)return!1;return!0!==e||i===n},isInvolution:function(t){for(var n=t.length,e=0,i=t[e];ei||n<=i||t[i]!==e)return!1;return!0},isKthroot:function(t,n){if(1>(n=n||1))return!1;var e,i,r,u=t.length;for(e=0;e=n||0e&&(e=r),e<=i)return!1;return!0},isKcycle:function(t,n,e,i){if(!t.length||0>=n)return!1;i=!1!==i;var r,u,l,s,o,f=t.length;for(r=0,l=0,o=0,s=new Array(f);o="===e||"=>"===e?l>=n:l===n}},_update:function(){return this.item__=(this.__item,this.n,this.$.order,this.$.type,null),this}}),(A=I.Combination=Z(e,{constructor:function t(n,i,r){var u=null;if(!(this instanceof t))return new t(n,i,r);if(ot(n)||ft(n)?(r=i||{},i=n[1]||0,n=n[0]||0):(r=r||{},n=n||0,i=i||0),r.type=String(r.type||"combination").toLowerCase(),-1e?t[0]-1:0,0):"ordered"===r||"variation"===r?0>e?pt(t[1],t[0]-1,-1):pt(t[1],0,1):pt(t[1],0>e?t[0]-t[1]:0,1),i=this.DUAL(i,t,n))},succ:function(t,n,e,i,r,u){return!e||!e[0]||0>=e[0]||0===e[1]||null==t?null:function(t,n,e,i,r,u){var l,s,o,f,c,h,a,m,d,g,_,v,p,b=n[1],A=n[0];0,h=1,c=a=b-1,m=1,d=0,g=1,_=0,nt&r&&(m=-m,d=A-1-d,h=-h,c=a-c,g=-g,_=a-_);Y&r&&(h=-h,c=a-c,g=-g,_=a-_);K&r&&(e=-e);if(0>e)if("ordered+repeated"===i||"variation+repeated"===i||"repeated+variation"===i){for(l=c;0<=l&&l<=a&&0===t[l];)l-=h;if(0<=l&&l<=a)for(A-=1,t[l]=t[l]-1,s=l+h;0<=s&&s<=a;s+=h)t[s]=A;else t=null}else if("ordered"===i||"variation"===i){for(null==u&&(u=Bn(t,A,b,r,i)),l=c,o=-1;-1===o&&0<=l&&l<=a;){if(m*t[l]+d-m>=0)for(s=m*t[l]+d-m;0<=s&&s(h=-h)?0:a,!p&&t[s]+1>b||p&&t[s]>0){if(p)for(;0<=l&&l<=a&&0===t[l];)l+=h;else for(;0<=l&&l<=a&&g*l+_===t[l];)l+=h;for(t[l]-=1,l-=h;0<=l&&l<=a;)t[l]=t[l+h]-v,l-=h}else t=null;else{for(o=-1,l=c;0<=l-h&&l-h<=a;l-=h)if(t[l]>t[l-h]+v){o=l;break}if(!(0<=o&&o<=a)&&0h?a:0]&&(o=0>h?a:0),0<=o&&o<=a){for(f=A-1+v,l=c;0<=l&&l<=a&&0=0;o--)s=g(l,n),l=d(l,n),i[o]=b(s);else if("ordered"===y||"variation"===y){for(l=t,o=A-1;o>=0;o--)s=g(l,u=n-o),l=d(l,u),i[o]=b(s);Xn(i,i,u)}else{u=(f="repeated"===y||"combination+repeated"===y)?n+A-1:n,t=m(m(r=e&&e.count?e.count:yn(u,A),a),t),r=d(_(r,u-A),u),s=u-A+1,l=A,o=u-1;do{v(r,t)?(i[A-l]=f?u-s-A+1:u-s-l+1,p(r,h)&&(t=m(t,r),r=d(_(r,l),o)),l--,o--):(r=d(_(r,o-l),o),s--,o--)}while(l>0)}return i=this.DUAL(i,n,e)},complement:function(t,n,e){return!0===e?Ct(Dn(n,t,!0)):Dn(n,t)},binary:function(t,n,e){return-1===e?kn(t,n):Mn(t,n)},pick:function(t,n,e){return 0e&&vt(function(t,n){i[n]=n},null,null,0,t,1):0>e&&(i[0]=t-1,i[t]=1),i=this.DUAL(i,t,n,1)},succ:function(t,n,i,r,u,l){return null==t?null:r&&"binary"===r.type?e.succ.call(this,t,n,i,r,u):function(t,n,e,i){var r,u,l,s,o,f,c=n,h=n-1;if(s=1,1,0,nt&i)return null;Y&i&&(s=-s);K&i&&(e=-e);0>s?(r=n-(t[c]||1),o=u=n-1,f=r):(r=0,u=t[c]-1,o=r,f=u);0>e?00?1===t[c]||l>t[f-s]+1?(t[f]-=1,t[f+s]=h,t[c]++):t[c]--:t[c]=0:t=null:0===t[c]?(t[r]=0,t[c]=1):1*t[o]+0=0;u--)i(0,1)&&(r={len:r?r.len+1:1,k:u,next:r});return e=(e=r?pt(r.len,function(t){var n=r.k;return r=r.next,n}):[]).concat(e.length=t||o&&s&&(o+s>t+1||o*st||s&&s>t?null:(e=-1===e?-1:1,(!(nt&f)&&K&f||nt&f&&!(K&f))&&(e=-e),(i=new Array(c+1))[c]=0,o&&s?(i[c]=o,1===o&&(i[0]=s),h?(i=vt(function(t,n,e){return t[e]=n,t},i,[(t-s)%(u=w.min(s,w.ceil((t-s)/(o-1))))||u].concat(pt(o-2,u,0)).concat([s])),0>e&&yt(i,i,0,0,o-1)):0>e?(o-=r=w.min(o,w.floor(t/s)||1),0===(t-=r*s)&&0e&&yt(i,i,0,0,o-1)):(r=t%(u=w.ceil(t/o))||u,i=vt(function(t,n,e){return t[e]=n,t},i,0>e?[t-o+1].concat(pt(o-1,1,0)):pt(o-1,u,0).concat([r])))):s?(r=w.floor(t/s),u=t%s,i=vt(function(t,n,e){return t[e]=n,t[c]++,t},i,h?0>e?pt(r,s,0).concat(u?[u]:[]):pt(t-s,1,0).concat([s]):0>e?pt(r,s,0).concat(u?[u]:[]):[s].concat(pt(t-s,1,0)))):i=vt(function(t,n,e){return t[e]=n,t[c]++,t},i,0>e?[t]:pt(t,1,0)),i=this.DUAL(i,t,n,1))},succ:function(t,n,e,i,r,u){if(null==e||null==t)return null;var l=i&&i.type?i.type:"partition",s=i&&i["max="]?0|i["max="]:null,o=i&&i["parts="]?0|i["parts="]:null;return 0>=e||o&&s&&(o+s>e+1||o*se||s&&s>e?null:(r=-1===r?-1:1,"composition"===l?function(t,n,e,i,r,u,l){var s,o,f,c,h,a,m,d,g=n,_=i||(r?g-r+1:g);a=1,Y&u&&(a=-a);K&u&&(e=-e);0>a?(m=_-(t[_]||1),o=d=_-1,f=m):(m=0,d=t[_]-1,o=m,f=d);if(0>e)if(i)if(r)t=null;else if(nt&u)if(c=t[o],g-i+1>c){for(t[o]=1,s=o+a;m<=s&&s<=d&&1===t[s];)s+=a;t[s]--,m<=s-a&&s-a<=d&&(t[s-a]=1+c)}else t=null;else if(c=t[f],g-i+1>c){for(t[f]=1,s=f;m<=s&&s<=d&&1===t[s];)s-=a;t[s]--,m<=s+a&&s+a<=d&&(t[s+a]=1+c)}else t=null;else if(r)t=null;else if(nt&u)t=null;else if(g>t[_]){for(s=f,h=0;m<=s&&s<=d&&1===t[s];)s-=a,h++;if(c=t[s]-1,t[s]=c,0<++h)if(m<=s+a&&s+a<=d)t[s+=a]=h,h=0,t[_]=0>a?_-s:s+1;else for(;0t[f]){for(s=o;m<=s&&s<=d&&1===t[s];)s+=a;c=t[s],t[s]=1,t[o]=c-1,m<=s+a&&s+a<=d&&t[s+a]++}else t=null;else if(g-i+1>t[o]){for(s=f;m<=s&&s<=d&&1===t[s];)s-=a;c=t[s],t[s]=1,t[f]=c-1,m<=s-a&&s-a<=d&&t[s-a]++}else t=null;else if(r)t=null;else if(nt&u)t=null;else if(g>t[o])for(h=t[f],t[f-a]++,t[_]--,s=f-a,h--;0d?(g=p-(t[p]||1),f=_=p-1,c=g):(g=0,_=t[p]-1,f=g,c=_);if(0>e)if(i)t=null;else if(nt&u)t=null;else if(g<=(o=r?f+d:f)&&o<=_&&t[o]>1){for(s=c,m=0;g<=s&&s<=_&&d*(s-o)>=0&&1===t[s];)m+=t[s],s-=d;if(a=t[s]-1,m++,t[s]=a,t[p]=0>d?p-s:s+1,ah||t[f+(h-1)*d]0&&t[s]===t[s-d];)m+=t[s],s-=d;for(t[s]++,m--,t[p]=0>d?p-s:s+1;0=t||h&&c&&(h+c>t+1||h*ct||c&&c>t)return null;if(h&&c)return null;if(c&&!h&&(h=c,_=!0),h)1===h?(i=[t],m=t):t===h?(i=pt(h,1,0),m=t):(e={},r=t-2,pt(i=$t(pt(h-1,function(){for(l=o(0,r);1===e[l];)l=(l+1)%(r+1);return e[l]=1,l+1})),function(t){return l=i[t],u=l-a,a=l,m+=u,u}));else{for(e=null,l=1;l(i=t[0].indexOf(r))||0(i=t[0].indexOf(r))||0>>1,h=new Array(u);for(n=0;nu||n!==h[i-1][0]||0!==h[i-1][1])return!1;if(l=i,h[(i=t[0][n])-1]||(h[i-1]=[0,n]),i<1||i>u||0!==h[i-1][0]||n!==h[i-1][1])return!1;for(s=i,o+=t[n][n],f+=t[n][r-1-n],e=1;eu||n!==h[i-1][0]||e!==h[i-1][1])return!1;if(l+=i,h[(i=t[e][n])-1]||(h[i-1]=[e,n]),i<1||i>u||e!==h[i-1][0]||n!==h[i-1][1])return!1;s+=i}if(l!==c||s!==c)return!1}return o===c&&f===c},make:function t(n){if(0>=n||2===n)return null;if(1===n)return[[1]];var e,i,r,u,l,s,o,f,c,h,a,m,d,g,_,v=1&n,p=0==(3&n),b=n*n,A=n-v>>>1;for(_=new Array(n),e=0;e=n&&(e++,i=0),_[e][i]=(d+i-e)%n*n+(g+e+i)%n+1;else if(p)for(r=0,e=0,i=0;r=n&&(e++,i=0),_[e][i]=(e+1&3)>>>1==(i+1&3)>>>1?b-r:r+1;else{for(u=t(A),c=(f=(o=s=A*A)<<1)+s,r=0,e=0,i=0;r=A&&(e++,i=0),l=u[e][i],_[e][i]=l,_[e+A][i+A]=l+o,_[e+A][i]=l+f,_[e][i+A]=l+c;for(a=h=A>>>1,i=0;in-a||e===h&&i===h)||0===e&&i===h||(m=_[e][i],_[e][i]=_[e][i+A],_[e][i+A]=m)}return _},product:function(){if(1>=arguments.length)return arguments[0];for(var t,n,e,i,r,u,l,s,o,f,c,h,a,m=arguments,d=m.length,g=m[0],_=1;_=r&&(a=0,++c>=r&&(o+=r,c=0,a=0,++h>=i&&(f++,s+=r,h=0,o=0,c=0,a=0),f",position:[0,4,5]}).completeWith(Abacus.Permutation(6-3)) @@ -65,7 +65,7 @@ o.rewind(-1) [ 0, 1, 4, 5, 2, 3 ] [ 0, 3, 4, 5, 1, 2 ] o.random() -[ 2, 5, 3, 4, 0, 1 ] +[ 0, 5, 1, 4, 2, 3 ] o.dispose() o = Abacus.Tensor(7,{type:"partial",data:["{0..4}","[0]+1","[1]+1","[3]-1","[4]-1"],ordering:"<>",position:[0,1,2,4,5]}).completeWith(Abacus.Permutation(7-5)) @@ -129,7 +129,7 @@ o.rewind(-1) [ 2, 3, 5, 0, 1, 4 ] [ 1, 2, 3, 0, 4, 5 ] o.random() -[ 2, 3, 5, 1, 0, 4 ] +[ 1, 2, 3, 0, 4, 5 ] o.dispose() Abacus.Tensor(6,{type:"partial",data:{0:"{0..4}",1:"[0]+1",2:"[0]+[1]",3:"5"},ordering:"<>"}).completeWith(Abacus.Permutation(6-4)) o.total() diff --git a/test/conditional_permutations_boolean.txt b/test/conditional_permutations_boolean.txt index b1ae328..2b632c5 100644 --- a/test/conditional_permutations_boolean.txt +++ b/test/conditional_permutations_boolean.txt @@ -1,4 +1,4 @@ -Abacus Algebraic Composition: Permutations w/ Partial Conditions (VERSION = 0.9.9) +Abacus Algebraic Composition: Permutations w/ Partial Conditions (VERSION = 0.9.10) --- 6-Permutations where (unique)values in 0th position ARE (0,1,2) and in 4th position ARE NOT (3,4) o = Abacus.Tensor(6,{type:"partial",data:[[true,0,1,2],[false,3,4]],ordering:"<>",position:[0,4]}).completeWith(Abacus.Permutation(6-2)) @@ -449,7 +449,7 @@ o.rewind(-1) [ 0, 1, 3, 4, 2, 5 ] [ 0, 2, 3, 4, 1, 5 ] o.random() -[ 2, 3, 4, 5, 1, 0 ] +[ 1, 3, 0, 5, 2, 4 ] o.dispose() 6,4-Combinations where values in 0th position ARE (0,1) and in 1st position [0]+1 o = Abacus.Tensor(6,{type:"partial",data:["{0,1}","[0]+1"],ordering:"<",position:[0,1]}).completeWith(Abacus.Combination(6-2,4-2)).filterBy(Abacus.Filter.SORTED("<")) diff --git a/test/connected_permutations.txt b/test/connected_permutations.txt index 6a5dfec..bef1eec 100644 --- a/test/connected_permutations.txt +++ b/test/connected_permutations.txt @@ -1,4 +1,4 @@ -Abacus.Permutations (VERSION = 0.9.9) +Abacus.Permutations (VERSION = 0.9.10) --- o = Abacus.Permutation(2,{type:"connected"}) o.total() @@ -9,19 +9,19 @@ o = Abacus.Permutation(3,{type:"connected"}) o.total() 2 o.random() -[ 1, 2, 0 ] +[ 2, 0, 1 ] o = Abacus.Permutation(4,{type:"connected"}) o.total() 6 o.random() -[ 1, 3, 0, 2 ] +[ 3, 0, 1, 2 ] o = Abacus.Permutation(5,{type:"connected"}) o.total() 24 o.random() -[ 3, 4, 0, 1, 2 ] +[ 2, 0, 3, 4, 1 ] o = Abacus.Permutation(6,{type:"connected"}) o.total() 120 o.random() -[ 5, 3, 0, 2, 1, 4 ] +[ 3, 0, 4, 5, 1, 2 ] diff --git a/test/cyclic_permutations.txt b/test/cyclic_permutations.txt index 3d016f1..26ee38a 100644 --- a/test/cyclic_permutations.txt +++ b/test/cyclic_permutations.txt @@ -1,4 +1,4 @@ -Abacus.Permutations (VERSION = 0.9.9) +Abacus.Permutations (VERSION = 0.9.10) --- o = Abacus.Permutation(4,{type:"cyclic"}) o.total() @@ -47,12 +47,12 @@ o.order("colex,reversed") [ 2, 3, 0, 1 ] [ 1, 2, 3, 0 ] o.order("random") -[ 0, 1, 2, 3 ] -[ 3, 0, 1, 2 ] [ 2, 3, 0, 1 ] +[ 3, 0, 1, 2 ] [ 1, 2, 3, 0 ] +[ 0, 1, 2, 3 ] o.random() -[ 3, 0, 1, 2 ] +[ 1, 2, 3, 0 ] o.order("colex").range(-3, -1) [ 2, 3, 0, 1 ] [ 3, 0, 1, 2 ] diff --git a/test/derangements.txt b/test/derangements.txt index 4798e1d..b66ba09 100644 --- a/test/derangements.txt +++ b/test/derangements.txt @@ -1,4 +1,4 @@ -Abacus.Permutations (VERSION = 0.9.9) +Abacus.Permutations (VERSION = 0.9.10) --- o = Abacus.Permutation(2,{type:"derangement"}) o.total() @@ -51,7 +51,7 @@ o.order("colex,reversed") [ 1, 2, 0 ] o.order("random") [ 2, 0, 1 ] -[ 1, 2, 0 ] +[ 2, 0, 1 ] o.random() [ 2, 0, 1 ] o = Abacus.Permutation(4,{type:"derangement"}) @@ -131,16 +131,16 @@ o.order("colex,reversed") [ 3, 2, 1, 0 ] o.order("random") [ 1, 3, 0, 2 ] -[ 3, 2, 1, 0 ] -[ 3, 2, 0, 1 ] +[ 2, 3, 1, 0 ] +[ 1, 0, 3, 2 ] [ 3, 0, 1, 2 ] -[ 3, 2, 1, 0 ] -[ 3, 2, 0, 1 ] +[ 2, 0, 3, 1 ] +[ 2, 0, 3, 1 ] +[ 2, 0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1, 3 ] +[ 4, 0, 3, 2, 1 ] +[ 1, 2, 0, 4, 3 ] +[ 2, 4, 3, 1, 0 ] +[ 3, 0, 1, 4, 2 ] +[ 2, 3, 4, 0, 1 ] +[ 4, 2, 1, 0, 3 ] +[ 2, 3, 4, 0, 1 ] [ 2, 0, 1, 4, 3 ] -[ 1, 4, 0, 2, 3 ] -[ 3, 2, 4, 0, 1 ] -[ 3, 0, 4, 1, 2 ] -[ 1, 4, 0, 2, 3 ] -[ 2, 4, 1, 0, 3 ] -[ 4, 0, 3, 1, 2 ] +[ 2, 4, 0, 1, 3 ] +[ 2, 4, 3, 1, 0 ] +[ 2, 0, 4, 1, 3 ] +[ 1, 3, 0, 4, 2 ] +[ 3, 0, 4, 2, 1 ] [ 2, 0, 1, 4, 3 ] -[ 4, 3, 1, 0, 2 ] -[ 4, 0, 3, 1, 2 ] -[ 4, 3, 0, 1, 2 ] -[ 4, 2, 3, 0, 1 ] -[ 2, 0, 3, 4, 1 ] [ 3, 0, 4, 2, 1 ] -[ 3, 4, 1, 0, 2 ] [ 3, 0, 1, 4, 2 ] -[ 1, 2, 4, 0, 3 ] +[ 1, 3, 4, 0, 2 ] +[ 2, 0, 4, 1, 3 ] +[ 3, 4, 0, 1, 2 ] +[ 2, 3, 4, 0, 1 ] +[ 2, 3, 1, 4, 0 ] +[ 4, 3, 1, 0, 2 ] o.random() -[ 3, 4, 0, 2, 1 ] +[ 3, 4, 1, 2, 0 ] o = Abacus.Permutation(7,{type:"derangement"}) o.total() 1854 @@ -4224,5 +4224,5 @@ o.rewind(-1) [ 1, 0, 3, 2, 6, 4, 5 ] [ 1, 0, 3, 2, 5, 6, 4 ] o.random() -[ 3, 5, 6, 2, 1, 0, 4 ] +[ 6, 0, 3, 1, 5, 2, 4 ] o.dispose() diff --git a/test/diophantine.js b/test/diophantine.js index 8114e09..866e1ad 100644 --- a/test/diophantine.js +++ b/test/diophantine.js @@ -196,6 +196,22 @@ echo(check_solution_system(o, [[5,6,8],[6,-11,7]]), [1,9]); echo(check_solution_system(o, [[5,6,8],[6,-11,7]], {"i_1":random(-100,100)}), [1,9]); echo('---'); +echo('x + y = 2, 2x + 3y = 5'); // x = 1, y = 1 +echo('o=Abacus.Math.diophantines([[1,1],[2,3]], [2,5])'); +o=Abacus.Math.diophantines([[1,1],[2,3]], [2,5]); +echo(print_solution(o, ['x','y'])); +echo(print_tex(o, ['x','y'])); +echo(check_solution_system(o, [[1,1],[2,3]]), [2,5]); +echo('---'); + +echo('x + y = 2, 2x + 3y = 5, 2x + 4y = 7'); // no solution +echo('o=Abacus.Math.diophantines([[1,1],[2,3],[2,4]], [2,5,7])'); +o=Abacus.Math.diophantines([[1,1],[2,3],[2,4]], [2,5,7]); +echo(print_solution(o, ['x','y'])); +echo(print_tex(o, ['x','y'])); +echo(check_solution_system(o, [[1,1],[2,3],[2,4]]), [2,5,7]); +echo('---'); + echo('Solve a1x1 + a2x2 + .. = b mod m'); echo('3x = 3 mod 10'); echo('o=Abacus.Math.congruence([3], 3, 10)'); diff --git a/test/diophantine.txt b/test/diophantine.txt index b43ef36..5b7473e 100644 --- a/test/diophantine.txt +++ b/test/diophantine.txt @@ -1,4 +1,4 @@ -Abacus.Diophantine (VERSION = 0.9.9) +Abacus.Diophantine (VERSION = 0.9.10) --- Solve a1x1 + a2x2 + a3x3 + .. = c 4x = 7 @@ -92,6 +92,18 @@ x = -5+10i_{1}, y = -1+i_{1}, z = 4-7i_{1} [ 1, 9 ] [ 1, 9 ] [ 1, 9 ] [ 1, 9 ] --- +x + y = 2, 2x + 3y = 5 +o=Abacus.Math.diophantines([[1,1],[2,3]], [2,5]) +x = 1, y = 1 +x = 1, y = 1 +[ 2, 5 ] [ 2, 5 ] +--- +x + y = 2, 2x + 3y = 5, 2x + 4y = 7 +o=Abacus.Math.diophantines([[1,1],[2,3],[2,4]], [2,5,7]) +No Integer solution +No Integer solution +No Integer solution [ 2, 5, 7 ] +--- Solve a1x1 + a2x2 + .. = b mod m 3x = 3 mod 10 o=Abacus.Math.congruence([3], 3, 10) diff --git a/test/filtered.txt b/test/filtered.txt index 44012a7..2048198 100644 --- a/test/filtered.txt +++ b/test/filtered.txt @@ -1,4 +1,4 @@ -Abacus.Combinatorics Filtered Combinatorial Objects (VERSION = 0.9.9) +Abacus.Combinatorics Filtered Combinatorial Objects (VERSION = 0.9.10) --- Get all Permutations filtered from all possible Tuples (an inefficient way to generate permutations) o = Abacus.Tensor(3,3,{"type":"tuple"}).filterBy(Abacus.Filter.UNIQUE()) diff --git a/test/filtered_compositions.txt b/test/filtered_compositions.txt index 3f7beb4..5133847 100644 --- a/test/filtered_compositions.txt +++ b/test/filtered_compositions.txt @@ -1,4 +1,4 @@ -Abacus.Compositions Filtered (VERSION = 0.9.9) +Abacus.Compositions Filtered (VERSION = 0.9.10) --- o = Abacus.Partition(10,{type:"composition"}).filterBy(Abacus.Filter.UNIQUE()) o.total() /* with filtering applied .total() and some other functions still return original data not the filtered ones */ diff --git a/test/filtered_partitions.txt b/test/filtered_partitions.txt index 755d970..e67012a 100644 --- a/test/filtered_partitions.txt +++ b/test/filtered_partitions.txt @@ -1,4 +1,4 @@ -Abacus.Partitions Filtered (VERSION = 0.9.9) +Abacus.Partitions Filtered (VERSION = 0.9.10) --- o = Abacus.Partition(10).filterBy(Abacus.Filter.UNIQUE()) o.total() /* with filtering applied .total() and some other functions still return original data not the filtered ones */ diff --git a/test/involutions.txt b/test/involutions.txt index 7fa3159..800a4e2 100644 --- a/test/involutions.txt +++ b/test/involutions.txt @@ -1,4 +1,4 @@ -Abacus.Permutations (VERSION = 0.9.9) +Abacus.Permutations (VERSION = 0.9.10) --- o = Abacus.Permutation(2,{type:"involution"}) o.total() @@ -36,7 +36,7 @@ o.rewind() [ 1, 0, 2, 3 ] [ 1, 0, 3, 2 ] o.random() -[ 1, 0, 2, 3 ] +[ 0, 3, 2, 1 ] o = Abacus.Permutation(5).filterBy(Abacus.Permutation.isInvolution) o.total() /* with filtering applied .total() and some other functions still return original data not the filtered ones */ 120 @@ -69,7 +69,7 @@ o.rewind() [ 4, 2, 1, 3, 0 ] [ 4, 3, 2, 1, 0 ] o.random() -[ 0, 3, 4, 1, 2 ] +[ 0, 1, 2, 4, 3 ] o = Abacus.Permutation(6).filterBy(Abacus.Permutation.isInvolution) o.total() /* with filtering applied .total() and some other functions still return original data not the filtered ones */ 720 @@ -152,4 +152,4 @@ o.rewind() [ 5, 4, 2, 3, 1, 0 ] [ 5, 4, 3, 2, 1, 0 ] o.random() -[ 0, 5, 3, 2, 4, 1 ] +[ 3, 2, 1, 0, 5, 4 ] diff --git a/test/k-derangements.txt b/test/k-derangements.txt index 75aace3..e88343f 100644 --- a/test/k-derangements.txt +++ b/test/k-derangements.txt @@ -1,4 +1,4 @@ -Abacus Algebraic Composition: k-Derangements (VERSION = 0.9.9) +Abacus Algebraic Composition: k-Derangements (VERSION = 0.9.10) --- o = Abacus.Combination(6,3).completeWith(Abacus.Permutation(6-3,{type:"derangement"})) o.dimension() @@ -1382,7 +1382,7 @@ o.rewind(-1) [ '0,1,2,5,4,3,7,6', 'exactly 4 fixed points' ] [ '0,1,2,3,5,4,7,6', 'exactly 4 fixed points' ] o.random() -[ 7, 1, 0, 3, 4, 5, 2, 6 ] +[ 5, 0, 2, 1, 4, 3, 6, 7 ] o.order("lex").range(-5, -1) [ 7, 2, 1, 3, 4, 5, 6, 0 ] [ 6, 2, 1, 3, 4, 5, 0, 7 ] diff --git a/test/latin_squares.txt b/test/latin_squares.txt index 91091f9..72dd9e8 100644 --- a/test/latin_squares.txt +++ b/test/latin_squares.txt @@ -1,4 +1,4 @@ -Abacus.LatinSquares (VERSION = 0.9.9) +Abacus.LatinSquares (VERSION = 0.9.10) --- 1 diff --git a/test/magic_squares.txt b/test/magic_squares.txt index 9f352b2..65f1244 100644 --- a/test/magic_squares.txt +++ b/test/magic_squares.txt @@ -1,4 +1,4 @@ -Abacus.MagicSquares (VERSION = 0.9.9) +Abacus.MagicSquares (VERSION = 0.9.10) --- 1 diff --git a/test/matrices.txt b/test/matrices.txt index e7086fb..3d9951b 100644 --- a/test/matrices.txt +++ b/test/matrices.txt @@ -1,4 +1,4 @@ -Abacus.Matrices (VERSION = 0.9.9) +Abacus.Matrices (VERSION = 0.9.10) --- Matrices and Matrix operations --- diff --git a/test/multiset_permutations.txt b/test/multiset_permutations.txt index c5198fc..f412c35 100644 --- a/test/multiset_permutations.txt +++ b/test/multiset_permutations.txt @@ -1,4 +1,4 @@ -Abacus.Permutations (VERSION = 0.9.9) +Abacus.Permutations (VERSION = 0.9.10) --- o = Abacus.Permutation(6,{type:"multiset",multiplicity:[1,2,2,1]}) o.total() @@ -1279,186 +1279,186 @@ o.order("colex,reversed") [ 2, 3, 2, 1, 1, 0 ] [ 3, 2, 2, 1, 1, 0 ] o.order("random") -[ 2, 1, 3, 1, 0, 2 ] -[ 2, 3, 1, 1, 0, 2 ] -[ 3, 2, 1, 2, 0, 1 ] -[ 1, 3, 0, 2, 1, 2 ] -[ 3, 2, 1, 0, 1, 2 ] -[ 2, 3, 1, 0, 2, 1 ] -[ 3, 0, 2, 2, 1, 1 ] -[ 1, 0, 2, 2, 1, 3 ] +[ 2, 1, 2, 0, 3, 1 ] +[ 2, 0, 3, 1, 2, 1 ] +[ 0, 2, 3, 2, 1, 1 ] +[ 3, 1, 2, 2, 1, 0 ] +[ 2, 0, 1, 3, 1, 2 ] +[ 1, 2, 3, 2, 0, 1 ] [ 1, 0, 1, 3, 2, 2 ] -[ 2, 2, 1, 1, 0, 3 ] +[ 1, 1, 2, 2, 3, 0 ] +[ 3, 1, 2, 0, 2, 1 ] +[ 1, 2, 2, 3, 0, 1 ] +[ 2, 3, 0, 2, 1, 1 ] +[ 0, 1, 2, 3, 2, 1 ] +[ 0, 3, 1, 2, 2, 1 ] +[ 3, 1, 1, 2, 0, 2 ] +[ 2, 0, 2, 3, 1, 1 ] +[ 0, 2, 1, 3, 2, 1 ] +[ 1, 2, 2, 3, 1, 0 ] +[ 2, 3, 1, 2, 0, 1 ] +[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, 1, 3, 1 ] o.dispose() diff --git a/test/number_theory.txt b/test/number_theory.txt index 5d837ce..2ea9e68 100644 --- a/test/number_theory.txt +++ b/test/number_theory.txt @@ -1,4 +1,4 @@ -Abacus.Number Theory Functions (VERSION = 0.9.9) +Abacus.Number Theory Functions (VERSION = 0.9.10) --- Modular Arithmetic o=Abacus.Math.addm(4, 2, 5) diff --git a/test/numbers.txt b/test/numbers.txt index 92ab592..1ac4c00 100644 --- a/test/numbers.txt +++ b/test/numbers.txt @@ -1,4 +1,4 @@ -Abacus.Numbers (VERSION = 0.9.9) +Abacus.Numbers (VERSION = 0.9.10) --- Triangular numbers ----------------- diff --git a/test/ordered_combinations.txt b/test/ordered_combinations.txt index 55e4263..4828f6a 100644 --- a/test/ordered_combinations.txt +++ b/test/ordered_combinations.txt @@ -1,4 +1,4 @@ -Abacus.Combinations (VERSION = 0.9.9) +Abacus.Combinations (VERSION = 0.9.10) --- o = Abacus.Combination(6,3,{type:"variation"}) o.total() @@ -859,128 +859,128 @@ o.order("colex,reversed") [ 3, 1, 0 ] [ 2, 1, 0 ] o.order("random") -[ 0, 5, 3 ] -[ 2, 1, 0 ] +[ 5, 4, 2 ] +[ 3, 2, 0 ] +[ 3, 5, 0 ] +[ 2, 0, 1 ] +[ 5, 4, 0 ] +[ 1, 5, 0 ] +[ 1, 4, 0 ] +[ 5, 0, 3 ] +[ 4, 3, 2 ] +[ 5, 0, 1 ] +[ 3, 4, 5 ] +[ 2, 1, 5 ] +[ 1, 5, 3 ] +[ 5, 4, 3 ] +[ 0, 4, 5 ] [ 4, 3, 5 ] -[ 5, 4, 1 ] -[ 3, 5, 4 ] -[ 1, 4, 5 ] -[ 0, 3, 2 ] -[ 5, 1, 3 ] -[ 4, 0, 3 ] -[ 5, 1, 0 ] -[ 0, 3, 4 ] -[ 1, 5, 4 ] [ 5, 2, 4 ] -[ 5, 2, 3 ] -[ 0, 4, 3 ] -[ 5, 3, 2 ] -[ 1, 5, 3 ] -[ 5, 4, 0 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 0, 1, 5 ] -[ 0, 2, 1 ] -[ 1, 0, 4 ] +[ 4, 3, 0 ] +[ 0, 5, 3 ] +[ 4, 5, 2 ] [ 1, 2, 0 ] -[ 2, 4, 1 ] +[ 2, 5, 3 ] +[ 1, 0, 2 ] +[ 4, 0, 2 ] +[ 5, 1, 4 ] +[ 5, 0, 2 ] [ 1, 0, 5 ] -[ 2, 3, 4 ] -[ 2, 4, 0 ] -[ 4, 2, 0 ] +[ 1, 2, 3 ] +[ 5, 1, 3 ] +[ 0, 1, 2 ] +[ 5, 3, 2 ] +[ 1, 2, 4 ] +[ 5, 3, 4 ] +[ 5, 3, 0 ] +[ 5, 2, 0 ] [ 4, 1, 3 ] -[ 3, 2, 4 ] -[ 3, 2, 1 ] -[ 3, 2, 0 ] -[ 2, 5, 3 ] -[ 3, 1, 4 ] -[ 3, 1, 2 ] -[ 3, 0, 1 ] -[ 3, 0, 5 ] -[ 3, 0, 4 ] -[ 3, 0, 2 ] +[ 4, 0, 3 ] +[ 4, 0, 5 ] +[ 4, 1, 0 ] +[ 4, 1, 5 ] +[ 4, 1, 2 ] o.random() -[ 0, 4, 1 ] +[ 5, 1, 2 ] o.order("colex").range(-5, -1) [ 4, 3, 5 ] [ 0, 4, 5 ] diff --git a/test/ordered_combinations_repeats.txt b/test/ordered_combinations_repeats.txt index c84a24d..20bf093 100644 --- a/test/ordered_combinations_repeats.txt +++ b/test/ordered_combinations_repeats.txt @@ -1,4 +1,4 @@ -Abacus.CombinationRepeats (VERSION = 0.9.9) +Abacus.CombinationRepeats (VERSION = 0.9.10) --- o = Abacus.Combination(5,3,{type:"variation+repeated"}) o.total() @@ -894,133 +894,133 @@ o.order("colex,reversed") [ 1, 0, 0 ] [ 0, 0, 0 ] o.order("random") -[ 2, 3, 0 ] +[ 3, 4, 1 ] +[ 0, 4, 2 ] +[ 2, 2, 2 ] +[ 0, 1, 4 ] [ 3, 1, 4 ] -[ 2, 3, 3 ] -[ 0, 4, 4 ] -[ 1, 1, 1 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4 ] o.random() -[ 1, 0, 2 ] +[ 2, 1, 3 ] o.order("colex").range(-5, -1) [ 0, 4, 4 ] [ 1, 4, 4 ] diff --git a/test/partially_fixed_permutations.txt b/test/partially_fixed_permutations.txt index 96294da..da3e8e3 100644 --- a/test/partially_fixed_permutations.txt +++ b/test/partially_fixed_permutations.txt @@ -1,4 +1,4 @@ -Abacus Algebraic Composition: Permutations w/ Fixed Partial Data (VERSION = 0.9.9) +Abacus Algebraic Composition: Permutations w/ Fixed Partial Data (VERSION = 0.9.10) --- 6-Permutations where 0th position can have 0,1,2 values and 4th position can have 3,4 values o = Abacus.Tensor(Abacus.Permutation(6-2),{type:"partial",data:[[0,3],[0,4],[1,3],[1,4],[2,3],[2,4]],position:[0,4]}) @@ -305,5 +305,5 @@ o.rewind(-1) [ 0, 1, 2, 3, 4, 5 ] [ 0, 1, 2, 4, 3, 5 ] o.random() -[ 0, 5, 4, 1, 3, 2 ] +[ 0, 3, 1, 2, 4, 5 ] o.dispose() diff --git a/test/partitions.txt b/test/partitions.txt index f30d2d3..bb12936 100644 --- a/test/partitions.txt +++ b/test/partitions.txt @@ -1,4 +1,4 @@ -Abacus.Partitions (VERSION = 0.9.9) +Abacus.Partitions (VERSION = 0.9.10) --- o = Abacus.Partition(6) o.total() @@ -66,7 +66,7 @@ o.order("colex,reflected") o.order("colex,reversed") [ 6 ] o.random() -[ 3, 2, 1 ] +[ 3, 3 ] o.dispose() o = Abacus.Partition(8) o.total() @@ -172,7 +172,7 @@ o.order("lex,reversed") [ 2, 1, 1, 1, 1, 1, 1 ] [ 1, 1, 1, 1, 1, 1, 1, 1 ] o.random() -[ 2, 2, 2, 1, 1 ] +[ 5, 1, 1, 1 ] o.dispose() o = Abacus.Partition(12,{output:"packed"}) o.total() @@ -498,7 +498,7 @@ o.order("lex,reversed") [ [ 2, 1 ], [ 1, 10 ] ] [ [ 1, 12 ] ] o.random() -[ [ 7, 1 ], [ 2, 1 ], [ 1, 3 ] ] +[ [ 4, 1 ], [ 3, 1 ], [ 2, 1 ], [ 1, 3 ] ] o.dispose() o = Abacus.Partition(20,{output:"packed"}) o.total() @@ -3024,5 +3024,5 @@ o.order("lex,reversed") [ [ 2, 1 ], [ 1, 18 ] ] [ [ 1, 20 ] ] o.random() -[ [ 5, 1 ], [ 3, 1 ], [ 2, 2 ], [ 1, 8 ] ] +[ [ 4, 1 ], [ 3, 2 ], [ 2, 2 ], [ 1, 6 ] ] o.dispose() diff --git a/test/permutations-bigint.txt b/test/permutations-bigint.txt index e08837f..ed82d4a 100644 --- a/test/permutations-bigint.txt +++ b/test/permutations-bigint.txt @@ -1,4 +1,4 @@ -Abacus.Permutations (VERSION = 0.9.9) +Abacus.Permutations (VERSION = 0.9.10) --- o = Abacus.Permutation(50) o.dimension() @@ -6,7 +6,7 @@ o.dimension() o.total() 30414093201713378043612608166064768844377641568960512000000000000 o.random() -0,42,10,22,12,39,1,19,47,3,16,20,11,34,35,48,4,36,15,8,28,23,37,27,40,26,21,44,5,32,46,24,9,41,43,6,49,33,45,17,14,38,7,29,13,18,25,2,30,31 +45,1,48,23,5,49,20,19,43,15,41,22,27,35,7,33,2,46,6,8,0,18,21,16,31,25,32,29,28,11,12,47,44,42,4,39,9,10,24,34,30,38,37,13,36,17,14,3,40,26 o.item(78043612608166064768844377641568960512000000000000,"lex") 0,1,2,3,4,5,6,7,10,22,36,11,30,34,12,27,9,31,26,20,48,19,18,47,13,24,14,21,17,38,16,15,41,40,43,23,28,39,46,37,35,45,8,33,42,29,44,49,25,32 o.item(78043612608166064768844377641568960512000000000000,"colex") diff --git a/test/permutations.txt b/test/permutations.txt index 11b0944..d5b39c4 100644 --- a/test/permutations.txt +++ b/test/permutations.txt @@ -1,4 +1,4 @@ -Abacus.Permutations (VERSION = 0.9.9) +Abacus.Permutations (VERSION = 0.9.10) --- o = Abacus.Permutation(4) o.total() @@ -187,32 +187,32 @@ o.order("colex,reversed") [ 2, 3, 1, 0 ] [ 3, 2, 1, 0 ] o.order("random") -[ 2, 1, 0, 3 ] -[ 2, 1, 3, 0 ] -[ 0, 2, 1, 3 ] -[ 3, 2, 0, 1 ] +[ 1, 3, 2, 0 ] +[ 3, 1, 0, 2 ] [ 2, 0, 3, 1 ] +[ 1, 0, 3, 2 ] +[ 0, 1, 3, 2 ] +[ 1, 2, 0, 3 ] +[ 0, 2, 1, 3 ] +[ 0, 2, 3, 1 ] +[ 3, 0, 2, 1 ] +[ 1, 2, 3, 0 ] +[ 1, 3, 0, 2 ] +[ 3, 1, 2, 0 ] [ 2, 0, 1, 3 ] -[ 1, 3, 2, 0 ] +[ 2, 1, 0, 3 ] +[ 3, 0, 1, 2 ] +[ 2, 1, 3, 0 ] +[ 0, 1, 2, 3 ] +[ 1, 0, 2, 3 ] [ 0, 3, 2, 1 ] -[ 3, 1, 2, 0 ] -[ 3, 2, 1, 0 ] [ 0, 3, 1, 2 ] -[ 2, 3, 1, 0 ] -[ 1, 3, 0, 2 ] -[ 0, 1, 2, 3 ] [ 2, 3, 0, 1 ] -[ 1, 2, 3, 0 ] -[ 1, 2, 0, 3 ] -[ 0, 1, 3, 2 ] -[ 3, 0, 1, 2 ] -[ 0, 2, 3, 1 ] -[ 1, 0, 2, 3 ] -[ 1, 0, 3, 2 ] -[ 3, 1, 0, 2 ] -[ 3, 0, 2, 1 ] -o.random() [ 2, 3, 1, 0 ] +[ 3, 2, 0, 1 ] +[ 3, 2, 1, 0 ] +o.random() +[ 3, 2, 0, 1 ] o.order("colex").range(-5, -1) [ 1, 2, 0, 3 ] [ 2, 0, 1, 3 ] diff --git a/test/permutations_of_combinations.txt b/test/permutations_of_combinations.txt index ec903e2..6a9267d 100644 --- a/test/permutations_of_combinations.txt +++ b/test/permutations_of_combinations.txt @@ -1,4 +1,4 @@ -Abacus Algebraic Composition: Permutations OF Combinations (VERSION = 0.9.9) +Abacus Algebraic Composition: Permutations OF Combinations (VERSION = 0.9.10) --- o = Abacus.Permutation(Abacus.Combination(6,3)) o.dimension() @@ -256,7 +256,7 @@ o.rewind(-1) [ 0, 2, 1 ] [ 0, 1, 2 ] o.random() -[ 2, 1, 3 ] +[ 3, 4, 1 ] o.order("lex").range(-5, -1) [ 3, 5, 4 ] [ 4, 3, 5 ] diff --git a/test/permutations_of_permutations.txt b/test/permutations_of_permutations.txt index d311ed3..8502662 100644 --- a/test/permutations_of_permutations.txt +++ b/test/permutations_of_permutations.txt @@ -1,4 +1,4 @@ -Abacus Algebraic Composition: Permutations OF Permutations (VERSION = 0.9.9) +Abacus Algebraic Composition: Permutations OF Permutations (VERSION = 0.9.10) --- o = Abacus.Permutation(2).multiplyWith(Abacus.Permutation(2)) o.total() diff --git a/test/polynomials.txt b/test/polynomials.txt index aa76a9c..3de256d 100644 --- a/test/polynomials.txt +++ b/test/polynomials.txt @@ -131,7 +131,7 @@ o=Abacus.Polynomial([-4,0,-2,1]) o.toString() x^3-2*x^2-4 o.div(Abacus.Polynomial([-3,1])) -(x^3-2*x^2-4)/(x-3)=(x-3)*(x^2+x+3)+(5)=x^3-2*x^2-9*x+5 false +(x^3-2*x^2-4)/(x-3)=(x-3)*(x^2+x+3)+(5)=x^3-2*x^2-4 true o.d() 3*x^2-4*x o.toExpr() @@ -202,8 +202,8 @@ Abacus.Math.polygcd(Abacus.Polynomial([74]),Abacus.Polynomial([32]),Abacus.Polyn Polynomial Extended GCD, generalisation of xGCD of numbers --- Abacus.Math.polyxgcd(Abacus.Polynomial([2,0,1]),Abacus.Polynomial([6,12])) -(x^2+2)((4/9)) + (12*x+6)(-(1/27)*x+(1/54)) = 1 false -(x^{2}+2)(\frac{4}{9}) + (12x+6)(-\frac{1}{27}x+\frac{1}{54}) = 1 false +(x^2+2)((4/9)) + (12*x+6)(-(1/27)*x+(1/54)) = 1 true +(x^{2}+2)(\frac{4}{9}) + (12x+6)(-\frac{1}{27}x+\frac{1}{54}) = 1 true Abacus.Math.polyxgcd(Abacus.Polynomial([1,2]),Abacus.Polynomial([1,3,4])) (2*x+1)(-4*x-1) + (4*x^2+3*x+1)(2) = 1 true Abacus.Math.polyxgcd(Abacus.Polynomial([1,1,1,1,5]),Abacus.Polynomial([2,1,3])) diff --git a/test/primes.txt b/test/primes.txt index d5db9f8..d9355a7 100644 --- a/test/primes.txt +++ b/test/primes.txt @@ -1,4 +1,4 @@ -Abacus.Primes (VERSION = 0.9.9) +Abacus.Primes (VERSION = 0.9.10) --- Division Wheels Abacus.Util.wheel(2) diff --git a/test/progressions.txt b/test/progressions.txt index 19f0104..92b9400 100644 --- a/test/progressions.txt +++ b/test/progressions.txt @@ -1,4 +1,4 @@ -Abacus.Progressions (VERSION = 0.9.9) +Abacus.Progressions (VERSION = 0.9.10) --- o=Abacus.Progression(1,1,10) o.total() diff --git a/test/rationals.txt b/test/rationals.txt index 9292873..093755c 100644 --- a/test/rationals.txt +++ b/test/rationals.txt @@ -1,4 +1,4 @@ -Abacus.Rationals (VERSION = 0.9.9) +Abacus.Rationals (VERSION = 0.9.10) --- o=Abacus.Rational() o.toString() diff --git a/test/recursive_permutations.txt b/test/recursive_permutations.txt index bcba580..03fecb6 100644 --- a/test/recursive_permutations.txt +++ b/test/recursive_permutations.txt @@ -1,4 +1,4 @@ -Abacus.Combinatorics (VERSION = 0.9.9) +Abacus.Combinatorics (VERSION = 0.9.10) --- Another way to generate N-Permutations from appropriate (1,2,..,N-1,N)-Tensors o = Abacus.Tensor(1,2,3,{"output":"inversion"}) diff --git a/test/restricted_compositions.txt b/test/restricted_compositions.txt index 83869ad..5084949 100644 --- a/test/restricted_compositions.txt +++ b/test/restricted_compositions.txt @@ -1,4 +1,4 @@ -Abacus.Compositions (VERSION = 0.9.9) +Abacus.Compositions (VERSION = 0.9.10) --- o = Abacus.Partition(7,{type:"composition","max=":4}) o.total() @@ -26,7 +26,7 @@ o.order("colex,reflected") o.order("colex,reversed") [ 1, 1, 1, 4 ] o.random() -[ 2, 1, 4 ] +[ 1, 4, 2 ] o.dispose() o = Abacus.Partition(8,{type:"composition","max=":4}) o.total() @@ -48,7 +48,7 @@ o.order("lex,reflected") o.order("lex,reversed") [ 4, 4 ] o.random() -[ 4, 1, 1, 2 ] +[ 2, 4, 2 ] o.dispose() o = Abacus.Partition(8,{type:"composition","max=":3}) o.total() @@ -70,7 +70,7 @@ o.order("lex,reflected") o.order("lex,reversed") [ 3, 3, 2 ] o.random() -[ 2, 3, 1, 2 ] +[ 3, 1, 2, 2 ] o.dispose() o = Abacus.Partition(13,{type:"composition","max=":4}) o.total() @@ -92,7 +92,7 @@ o.order("lex,reflected") o.order("lex,reversed") [ 4, 4, 4, 1 ] o.random() -[ 1, 4, 1, 1, 2, 1, 1, 1, 1 ] +[ 3, 4, 4, 2 ] o.dispose() o = Abacus.Partition(7,{type:"composition","parts=":4}) o.total() @@ -253,7 +253,7 @@ o.order("colex,reversed") [ 3, 2, 1, 1 ] [ 4, 1, 1, 1 ] o.random() -[ 2, 2, 2, 1 ] +[ 1, 3, 1, 2 ] o.dispose() o = Abacus.Partition(8,{type:"composition","parts=":4}) o.total() @@ -411,5 +411,5 @@ o.order("lex,reversed") [ 1, 1, 2, 4 ] [ 1, 1, 1, 5 ] o.random() -[ 3, 2, 2, 1 ] +[ 3, 1, 3, 1 ] o.dispose() diff --git a/test/restricted_partitions.txt b/test/restricted_partitions.txt index 93b7f2b..0ec1a88 100644 --- a/test/restricted_partitions.txt +++ b/test/restricted_partitions.txt @@ -1,4 +1,4 @@ -Abacus.Partitions (VERSION = 0.9.9) +Abacus.Partitions (VERSION = 0.9.10) --- o = Abacus.Partition(7,{"max=":4}) o.total() @@ -60,7 +60,7 @@ o.order("lex,reversed") [ 4, 2, 1, 1 ] [ 4, 1, 1, 1, 1 ] o.random() -[ 4, 2, 2 ] +[ 4, 3, 1 ] o.dispose() o = Abacus.Partition(11,{"max=":5}) o.total() @@ -112,7 +112,7 @@ o.order("lex,reversed") [ 5, 2, 1, 1, 1, 1 ] [ 5, 1, 1, 1, 1, 1, 1 ] o.random() -[ 5, 2, 2, 2 ] +[ 5, 4, 2 ] o.dispose() o = Abacus.Partition(12,{"max=":4}) o.total() @@ -184,7 +184,7 @@ o.order("lex,reversed") [ 4, 2, 1, 1, 1, 1, 1, 1 ] [ 4, 1, 1, 1, 1, 1, 1, 1, 1 ] o.random() -[ 4, 2, 2, 2, 1, 1 ] +[ 4, 2, 2, 2, 2 ] o.dispose() o = Abacus.Partition(17,{"max=":4}) o.total() @@ -352,7 +352,7 @@ o.order("lex,reversed") [ 4, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] [ 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] o.random() -[ 4, 3, 3, 3, 2, 1, 1 ] +[ 4, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1 ] o.dispose() o = Abacus.Partition(7,{"parts=":4,output:"conjugate"}) o.total() @@ -375,7 +375,7 @@ o.order("lex,reversed") [ 3, 2, 1, 1 ] [ 4, 1, 1, 1 ] o.random() -[ 2, 2, 2, 1 ] +[ 3, 2, 1, 1 ] o.dispose() o = Abacus.Partition(8,{"parts=":4,output:"conjugate"}) o.total() @@ -458,7 +458,7 @@ o.order("lex,reversed") [ 6, 2, 1, 1, 1 ] [ 7, 1, 1, 1, 1 ] o.random() -[ 4, 2, 2, 2, 1 ] +[ 6, 2, 1, 1, 1 ] o.dispose() o = Abacus.Partition(12,{"parts=":4,output:"conjugate"}) o.total() @@ -529,7 +529,7 @@ o.order("lex,reversed") [ 8, 2, 1, 1 ] [ 9, 1, 1, 1 ] o.random() -[ 9, 1, 1, 1 ] +[ 5, 4, 2, 1 ] o.dispose() o = Abacus.Partition(20,{"parts=":4,output:"conjugate"}) o.total() @@ -796,7 +796,7 @@ o.order("lex,reversed") [ 16, 2, 1, 1 ] [ 17, 1, 1, 1 ] o.random() -[ 9, 5, 4, 2 ] +[ 14, 2, 2, 2 ] o.dispose() o = Abacus.Partition(12,{"parts=":4,"max=":4}) o.total() diff --git a/test/subsets.txt b/test/subsets.txt index 2f211ee..301a464 100644 --- a/test/subsets.txt +++ b/test/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 ] -[ 5, 2 ] +[ 4 ] [ 3, 1, 0 ] -[ 3, 2 ] +[ 4, 3, 2, 0 ] +[ 5, 3, 2 ] +[ 5, 2, 1 ] [ 4, 0 ] -[ 4 ] -[ 3, 2, 0 ] -[ 3, 2, 1 ] +[ 4, 3, 2, 1 ] +[ 2, 1 ] +[] +[ 4, 3, 2, 1, 0 ] +[ 5, 4, 2, 0 ] +[ 5, 4, 2 ] +[ 5, 4, 1 ] +[ 5 ] +[ 5, 2 ] +[ 5, 0 ] +[ 5, 4, 0 ] +[ 5, 4 ] +[ 5, 3, 2, 1, 0 ] +[ 5, 1 ] +[ 5, 3, 2, 1 ] +[ 5, 1, 0 ] o.random() -[ 5, 4, 1, 0 ] +[ 5, 4, 3, 2 ] o.order("colex").range(-5, -1) [ 0, 1, 3, 4, 5 ] [ 2, 3, 4, 5 ] diff --git a/test/tensors.txt b/test/tensors.txt index baa0bdc..4977f3e 100644 --- a/test/tensors.txt +++ b/test/tensors.txt @@ -1,4 +1,4 @@ -Abacus.Tensors (VERSION = 0.9.9) +Abacus.Tensors (VERSION = 0.9.10) --- o = Abacus.Tensor(1,2,3) o.total() @@ -61,14 +61,14 @@ o.order("colex,reversed") [ 1, 0, 0 ] [ 0, 0, 0 ] o.order("random") -[ 0, 1, 0 ] [ 0, 1, 1 ] -[ 0, 0, 2 ] [ 0, 1, 2 ] +[ 0, 1, 0 ] [ 0, 0, 0 ] [ 0, 0, 1 ] +[ 0, 0, 2 ] o.random() -[ 0, 1, 0 ] +[ 0, 0, 0 ] o.order("colex").range(-5, -1) [ 1, 0, 0 ] [ 2, 0, 0 ] diff --git a/test/tuples.txt b/test/tuples.txt index f558f88..8d1a1e0 100644 --- a/test/tuples.txt +++ b/test/tuples.txt @@ -1,4 +1,4 @@ -Abacus.Tuples (VERSION = 0.9.9) +Abacus.Tuples (VERSION = 0.9.10) --- o = Abacus.Tensor(3,3,{type:"tuple",output:"gray"}) o.total() @@ -208,35 +208,35 @@ o.order("colex,reversed") [ 1, 2, 0 ] [ 0, 0, 0 ] o.order("random") -[ 0, 1, 1 ] -[ 2, 1, 2 ] +[ 1, 1, 1 ] +[ 0, 0, 0 ] +[ 1, 0, 1 ] +[ 2, 1, 0 ] +[ 1, 2, 1 ] +[ 1, 0, 2 ] +[ 1, 2, 0 ] +[ 1, 1, 2 ] [ 0, 0, 2 ] -[ 0, 2, 0 ] -[ 0, 1, 0 ] [ 0, 2, 2 ] -[ 1, 2, 1 ] -[ 1, 1, 0 ] +[ 0, 0, 1 ] +[ 0, 1, 1 ] +[ 2, 2, 1 ] +[ 0, 2, 1 ] +[ 2, 0, 1 ] [ 2, 0, 2 ] -[ 1, 1, 1 ] +[ 2, 2, 0 ] +[ 2, 0, 0 ] +[ 1, 1, 0 ] [ 0, 1, 2 ] -[ 1, 2, 2 ] +[ 2, 1, 1 ] [ 1, 0, 0 ] -[ 0, 2, 1 ] -[ 1, 2, 0 ] -[ 2, 1, 0 ] -[ 0, 0, 1 ] -[ 1, 1, 2 ] -[ 1, 0, 1 ] +[ 1, 2, 2 ] +[ 0, 2, 0 ] +[ 2, 1, 2 ] +[ 0, 1, 0 ] [ 2, 2, 2 ] -[ 1, 0, 2 ] -[ 2, 1, 1 ] -[ 0, 0, 0 ] -[ 2, 2, 0 ] -[ 2, 2, 1 ] -[ 2, 0, 0 ] -[ 2, 0, 1 ] o.random() -[ 2, 2, 0 ] +[ 1, 1, 0 ] o.order("colex").range(-5, -1) [ 1, 0, 1 ] [ 2, 2, 1 ]