diff --git a/README.md b/README.md index 3d1692f..8a3d092 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ A combinatorics library for Node.js / Browser / XPCOM Javascript, PHP, Python, C (php/python/java/c implementations in progress) -**version 0.9.2** (~ 69kB minified, ~ 22kB zipped) +**version 0.9.3** (~ 74kB minified, ~ 23kB zipped) ![abacus combinatorial numbers](/abacus.jpg) @@ -75,9 +75,9 @@ A combinatorics library for Node.js / Browser / XPCOM Javascript, PHP, Python, C * `LatinSquare` (`test/latin_squares.js`) * `MagicSquare` (`test/magic_squares.js`) * **algebraic composition** (of **fixed** dimensions at present) and **sequences** of combinatorial objects to construct new combinatorial objects (eg `all combinations` = `all permutations` **OF** `all unique combinations`, see `test/permutations_of_combinations.js` and `test/permutations_of_permutations.js`, `k-Derangements` = `(n,k) Combinations` **combined With** `(n-k) Derangements`, see `test/k-derangements.js` or `all subsets` = `(n,0)Combinations + (n,1)Combinations + .. + (n,n-1)Combinations + (n,n)Combinations`, see `test/combination_subsets.js`) -* custom (user-supplied callable) and/or built-in **filters** which can select and generate any custom and complex combinatorial object from filtering other combinatorial objects as efficiently as possible (e.g see `test/filtered.js`, `test/filtered_partitions.js`). Also **algebraic / boolean composition of filters** (i.e `.NOT()`, `.AND()`, `.OR()` and so on..) +* custom (user-supplied callable) and/or built-in **filters** which can select and generate any custom and complex combinatorial object from filtering other combinatorial objects as efficiently as possible (e.g see `test/filtered.js`, `test/filtered_partitions.js`). Also **algebraic / boolean composition of filters** (i.e `.NOT()`, `.AND()`, `.OR()` and so on..). **Note** that filtering should be **used with caution and only if no other method is currently possible** to generate the desired combinatorial object as **filtering is equivalent to exhaustive search** over the space of the original combinatorial object and as such can be an inefficient way to generate a combinatorial object (e.g see `test/filtered.js`). **Note2** with filtering applied some methods like `.total()`, `.hasNext()`, `.base()`, `.dimension()` still return data of the original object **not** the filtered object since that would require to pre-generate all the data and filter them afterwards instead of doing it one-by-one on each generation and would be impractical and unachievable for very large combinatorial objects, so be careful when using, for example, `.total()` with fitering applied * **multiple (combined) iterator orderings & traversals**: `lex`, `colex`, `random`, `reversed`, `reflected`, `minimal` (not implemented yet). For example: `"revlex"` (equivalent to `"lex,reversed"`), `"refcolex"` (equivalent to `"colex,reflected"`), and so on.. -* **arbitrary range** of combinatorial objects in a number of supported orderings (ie `lex`, `colex`, `random`,..). **Note** `rank`/`unrank` have to be implemented for this feature to work +* **arbitrary range** of combinatorial objects in a number of supported orderings (ie `lex`, `colex`, `random`,..) (and with filtering applied, if set). **Note** `rank`/`unrank` methods have to be implemented for this feature to work * **efficient and unbiased generation, (un)ranking, succession & random methods** for supported combinatorial objects (see below) * `big-integer arithmetic`, `PRNG`s and other `math` utilities can be **dynamicaly pluggable using external implementations**, making the lib very flexible especialy with respect to handling big-integers & (pseudo-)random number generators @@ -562,20 +562,21 @@ o.dispose() ### Todo -* apply built-in language `iterator`/`iterable` patterns (e.g ES6 `iterator` protocol, Python `__iter__` interface, PHP `Iterator` interface, ..). Combinatorial objects additionaly support a `doubly-linked list`-like interface, i.e `prev`/`next` accessors [DONE] -* support `biginteger` combinatorial computations e.g large factorials [DONE, the lib **does not support** biginteger arithmetic, but arithmetic routines have been made **dynamicaly pluggable** and one can use an external implementation to support combinatorics with bigintegers where needed as needed, see test examples for an example] -* support **multiple combined custom iterator orderings**, i.e `lex`, `colex`, `reversed`, `reflected`, `random` seamlessly and uniformly, both forward and backward [DONE, `random` ordering may be optimised further] -* support **efficient successor methods** (preferably `CAT/Loopless` methods) to generate next/prev object from current object [DONE] -* support **efficient ranking / unranking algorithms** and associated methods (preferably of `O(n)` or `O(nlgn)` complexity) for supported orderings [DONE] -* support multiple combinatorial orderings (ie `lex`, `colex`, `reflex`, `refcolex`, `minimal`, ..) **directly in the successor methods** instead of using post-transformations on object [DONE] -* support **unique and uniform random ordering traversals** for all combinatorial objects, so that the space of a combinatorial object can be traversed in **any random ordering uniquely and unbiasedly** (useful in some applications, eg backtracking) [DONE, see reference, used as custom iterator ordering, see above, may be optimised further] -* make sure the `.random` methods **uniformly and unbiasedly sample the combinatorial object space** (methods use unbiased sampling algorithms, however results in certain cases might depend on [quality of PRNGs](http://www0.cs.ucl.ac.uk/staff/d.jones/GoodPracticeRNG.pdf)) [DONE] -* support algebraic composition/cascading of combinatorial objects (of **fixed** dimensions at present) to construct new combinatorial objects (eg `all combinations` = `all permutations` **OF** `all unique combinations`) [DONE] -* support generation of supported combinatorial objects with additional **user-defined patterns/templates of constraints** to satisfy e.g *"only combinatorial objects matching `'(n)(m)(1){2}(){3}(0)((n+1))((n+m)){4}'`"* pattern.. [DONE] -* add `LatinSquare`, `MagicSquare` algorithms [DONE] +* apply built-in language `iterator`/`iterable` patterns (e.g ES6 `iterator` protocol, Python `__iter__` interface, PHP `Iterator` interface, ..). Combinatorial objects additionaly support a `doubly-linked list`-like interface, i.e `prev`/`next` accessors **[DONE]** +* support `biginteger` combinatorial computations e.g large factorials **[DONE]**, the lib **does not support** biginteger arithmetic, but arithmetic routines have been made **dynamicaly pluggable** and one can use an external implementation to support combinatorics with bigintegers where needed as needed, see test examples for an example +* support **multiple combined custom iterator orderings**, i.e `lex`, `colex`, `reversed`, `reflected`, `random` seamlessly and uniformly, both forward and backward **[DONE, `random` ordering may be optimised further]** +* support **efficient successor methods** (preferably `CAT/Loopless` methods) to generate next/prev object from current object **[DONE]** +* support **efficient ranking / unranking algorithms** and associated methods (preferably of `O(n)` or `O(nlgn)` complexity) for supported orderings **[DONE]** +* support multiple combinatorial orderings (ie `lex`, `colex`, `reflex`, `refcolex`, `minimal`, ..) **directly in the successor methods** instead of using post-transformations on object **[DONE]** +* support **unique and uniform random ordering traversals** for all combinatorial objects, so that the space of a combinatorial object can be traversed in **any random ordering uniquely and unbiasedly** (useful in some applications, eg backtracking) **[DONE, see reference, used as custom iterator ordering, see above, may be optimised further]** +* make sure the `.random` methods **uniformly and unbiasedly sample the combinatorial object space** (methods use unbiased sampling algorithms, however results in certain cases might depend on [quality of PRNGs](http://www0.cs.ucl.ac.uk/staff/d.jones/GoodPracticeRNG.pdf)) **[DONE]** +* support algebraic composition/cascading of combinatorial objects (of **fixed** dimensions at present) to construct new combinatorial objects (eg `all combinations` = `all permutations` **OF** `all unique combinations`) **[DONE]** +* support generation of supported combinatorial objects with additional **user-defined patterns/templates of constraints** to satisfy e.g *"only combinatorial objects matching `'(n)(m)(1){2}(){3}(0)((n+1))((n+m)){4}'`"* pattern.. **[DONE]** +* add `LatinSquare`, `MagicSquare` algorithms **[DONE]** +* add run-time/lazy custom and/or built-in filtering support (with support for filter composition as well) to generate and select custom and complex combinatorial objects from filtering other combinatorial objects as efficiently as possible **[DONE]** * add efficient `rank`/`unrank` methods for `DerangementPermutation`, `InvolutionPermutation`, `ConnectedPermutation`, `Composition` & `Partition` (TODO) -* full support for `colex` ordering `Composition` & `Partition` [DONE PARTIALY] +* full support for `colex` ordering `Composition` & `Partition` **[DONE PARTIALY]** * support `minimal`/`gray` ordering (and successor) for all supported combinatorial objects (TODO) * use numeric arrays (ie `Uint32`) to store combinatorial items and/or make faster `successor` methods and other numerical routines to `asm.js` (TODO?) -* support generation (and counting) of combinatorial objects (including the basic supported ones) based on **generic user-defined symbolic constraints / symmetries / rules** to satisfy, for example `permutations` defined symbolicaly and directly by their *symmetries / constraints* instead of being hardcoded as elementary objects (TODO?) +* support generation (and counting) of combinatorial objects (including the basic supported ones) based on **generic user-defined symbolic constraints / symmetries / rules** to satisfy, for example `permutations` defined symbolicaly and directly by their *symmetries / constraints* instead of being hardcoded as elementary objects (TODO?, see using `filtering` as a similar alternative to this approach) * support *graph-based* combinatorial objects like `Graph`, `Grammar`,.. (TODO?) (for regular grammars and expressions see [RegexAnalyzer](https://github.com/foo123/RegexAnalyzer) for an example) diff --git a/src/js/Abacus.js b/src/js/Abacus.js index a6f08b6..0ab59e5 100644 --- a/src/js/Abacus.js +++ b/src/js/Abacus.js @@ -2,7 +2,7 @@ * * Abacus * A combinatorics library for Node.js / Browser / XPCOM Javascript, PHP, Python, Java, C/C++ -* @version: 0.9.2 +* @version: 0.9.3 * https://github.com/foo123/Abacus **/ !function( root, name, factory ){ @@ -22,7 +22,7 @@ else if ( !(name in root) ) /* Browser/WebWorker/.. */ /* module factory */ function ModuleFactory__Abacus( undef ){ "use strict"; -var Abacus = {VERSION: "0.9.2"}, stdMath = Math, PROTO = 'prototype', CLASS = 'constructor' +var Abacus = {VERSION: "0.9.3"}, stdMath = Math, PROTO = 'prototype', CLASS = 'constructor' ,slice = Array.prototype.slice, HAS = Object[PROTO].hasOwnProperty, toString = Object[PROTO].toString ,log2 = stdMath.log2 || function(x) { return stdMath.log(x) / stdMath.LN2; } ,trim_re = /^\s+|\s+$/g @@ -1543,6 +1543,7 @@ function conditional_combinatorial_tensor( v, value_conditions, extra_conditions function gen_combinatorial_data( n, data, pos, value_conditions, options ) { options = options || {}; + pos = pos || array(data.length||0, 0, 1); // conditions: ALGEBRAIC(STRING EXPR) AND/OR BOOLEAN(POSITIVE / NEGATIVE) => [values] per position var min = null==options.min ? 0 : options.min, max = null==options.max ? n-1 : options.max, @@ -1692,9 +1693,27 @@ function gen_combinatorial_data( n, data, pos, value_conditions, options ) // check additional conditions additional_conditions = is_callable(options.extra_conditions) ? function(v,i0,i1){ - return (min<=v[i0] && v[i0]<=max) && options.extra_conditions(v,i0,i1); + var v0 = v[i0]; + if ( + // check in range + (min>v0 || v0>max) || + // when strictly increasing sequence then value at pos i cannot be less than i since it has to accomodate the rest values as well before it, complementary for strictly decreasing sequence (for strictly decreasing sequence we do not know the number of elements that come after unlike for strictly increasing sequence where we can know, but as a workaround we can add last possible position in conditions with all possible values simply as a hint/clue on what is last possible position) + // (assume values in range 0..n-1 for positions 0..n-1 or reverse) + (V_INC === value_conditions && pos[i0]>v0) || + (V_DEC === value_conditions && pos[pos.length-1]-pos[i0]>v0) + ) return false + return options.extra_conditions(v,i0,i1); } : function(v,i0,i1){ - return (min<=v[i0] && v[i0]<=max); + var v0 = v[i0]; + if ( + // check in range + (min>v0 || v0>max) || + // when strictly increasing sequence then value at pos i cannot be less than i since it has to accomodate the rest values as well before it, complementary for strictly decreasing sequence (for strictly decreasing sequence we do not know the number of elements that come after unlike for strictly increasing sequence where we can know, but as a workaround we can add last possible position in conditions with all possible values simply as a hint/clue on what is last possible position) + // (assume values in range 0..n-1 for positions 0..n-1 or reverse) + (V_INC === value_conditions && pos[i0]>v0) || + (V_DEC === value_conditions && pos[pos.length-1]-pos[i0]>v0) + ) return false + return true; }; // compute valid combinatorial data satisfying conditions @@ -2337,6 +2356,33 @@ function is_latin( square ) } return M; }*/ +function find( a, b, nested ) +{ + if ( nested ) + { + if ( !a || !a.length ) return -1; + var index, found, i, j, k, n = a.length, m = b.length; + for(i=0; i arguments.length || null == strict ) strict = true; + if ( is_string(dir) ) + { + if ( "<" === dir ) + { + dir = 1; + strict = true; + } + else if ( ">" === dir ) + { + dir = -1; + strict = true; + } + else if ( "<=" === dir || "=<" === dir ) + { + dir = 1; + strict = false; + } + else if ( ">=" === dir || "=>" === dir ) + { + dir = -1; + strict = false; + } + } + dir = +dir; + dir = -1 === dir ? -1 : 1; return Filter(-1 === dir ? function(item){ for(var item0=item[0],i=1,n=item.length; i=" === comp ) + if ( ">=" === comp || "=>" === comp ) { return Filter(function(item){ return 0<=pos && pos=val; }); } @@ -2422,7 +2492,7 @@ Filter = Abacus.Filter = Class({ { return Filter(function(item){ return 0<=pos && pos=" === comp ) + if ( ">=" === comp || "=>" === comp ) { return Filter(function(item){ return operate(function(M,i){ if ( item[i] > M ) M = item[i]; @@ -2459,7 +2529,7 @@ Filter = Abacus.Filter = Class({ return M; }, -Infinity, null, 0, item.length-1, 1) < val; }); } - else if ( "<=" === comp ) + else if ( "<=" === comp || "=<" === comp ) { return Filter(function(item){ return operate(function(M,i){ if ( item[i] > M ) M = item[i]; @@ -2484,7 +2554,7 @@ Filter = Abacus.Filter = Class({ ,MIN: function( val, comp ) { comp = comp || "=="; val = +val; - if ( ">=" === comp ) + if ( ">=" === comp || "=>" === comp ) { return Filter(function(item){ return operate(function(M,i){ if ( item[i] < M ) M = item[i]; @@ -2505,7 +2575,7 @@ Filter = Abacus.Filter = Class({ return M; }, Infinity, null, 0, item.length-1, 1) < val; }); } - else if ( "<=" === comp ) + else if ( "<=" === comp || "=<" === comp ) { return Filter(function(item){ return operate(function(M,i){ if ( item[i] < M ) M = item[i]; @@ -3600,7 +3670,6 @@ CombinatorialIterator = Abacus.CombinatorialIterator = Class({ else self._next = has_next; } }while($.filter && current && !$.filter.apply(current, self)); // if custom filter, reject if invalid, try next - return current; } @@ -3830,14 +3899,20 @@ Tensor = Abacus.Tensor = Class(CombinatorialIterator, { ,succ: function( item, index, n, $, dir, TI ) { if ( !n || (null == item) ) return null; var type = $ && $.type ? $.type : "tensor", - order = $ && null!=$.order ? $.order : LEX; + order = $ && null!=$.order ? $.order : LEX, + Arithmetic = Abacus.Arithmetic, ind; dir = -1 === dir ? -1 : 1; if ( "partial" === type ) { if ( !$.data || !$.data.length ) return null; - if ( REVERSED & order ) dir = -dir; - var i = null == index ? $.data.indexOf(item) : Abacus.Arithmetic.val(index); - return 0>dir ? (0<=i-1 ? $.data[i-1] : null) : (0<=i && i+1<$.data.length ? $.data[i+1] : null); + if ( REVERSED & order ) + { + dir = -dir; + if ( null != index ) index = Arithmetic.sub(Arithmetic.N($.data.length-1),index); + } + if ( null == index ) index = find($.data, item, true); + ind = Arithmetic.val(index); + return 0>dir ? (0<=ind-1 ? $.data[ind-1] : null) : (0<=ind && ind+1<$.data.length ? $.data[ind+1] : null); } return !n[0] || (0 >= n[0]) ? null : next_tensor(item, n, dir, type, order, TI); } @@ -3876,7 +3951,7 @@ Tensor = Abacus.Tensor = Class(CombinatorialIterator, { if ( "partial" === type ) { - index = Arithmetic.N($.data&&$.data.length ? $.data.indexOf(item) : -1); + index = Arithmetic.N(find($.data, item, true)); } else { diff --git a/src/js/Abacus.min.js b/src/js/Abacus.min.js index a387e03..d7db404 100644 --- a/src/js/Abacus.min.js +++ b/src/js/Abacus.min.js @@ -2,7 +2,7 @@ * * Abacus * A combinatorics library for Node.js / Browser / XPCOM Javascript, PHP, Python, Java, C/C++ -* @version: 0.9.2 +* @version: 0.9.3 * https://github.com/foo123/Abacus **/ -!function(n,t,e){"use strict";"undefined"!=typeof Components&&"object"==typeof Components.classes&&"object"==typeof Components.classesByID&&Components.utils&&"function"==typeof Components.utils.import?(n.$deps=n.$deps||{})&&(n.EXPORTED_SYMBOLS=[t])&&(n[t]=n.$deps[t]=e.call(n)):"object"==typeof module&&module.exports?(module.$deps=module.$deps||{})&&(module.exports=module.$deps[t]=e.call(n)):"undefined"!=typeof System&&"function"==typeof System.register&&"function"==typeof System.import?System.register(t,[],function(r){r(t,e.call(n))}):"function"==typeof define&&define.amd&&"function"==typeof require&&"function"==typeof require.specified&&require.specified(t)?define(t,["module"],function(t){return e.moduleUri=t.uri,e.call(n)}):t in n||(n[t]=e.call(n)||1)&&"function"==typeof define&&define.amd&&define(function(){return n[t]})}(this,"Abacus",function(n){"use strict";var t,e,r,u,o={VERSION:"0.9.2"},s=Math,a="prototype",f="constructor",c=Array.prototype.slice,h=Object[a].hasOwnProperty,d=Object[a].toString,m=s.log2||function(n){return s.log(n)/s.LN2},p=/^\s+|\s+$/g,_=(String.prototype.trim,/\[(\d+)\]/g),g=/^\{(\d+(?:(?:\.\.\d+)?|(?:,\d+)*))\}$/,b=/^!\{(\d+(?:(?:\.\.\d+)?|(?:,\d+)*))\}$/,v=Object.create,y=function(n,t){for(var e in t)h.call(t,e)&&(n[e]=t[e]);return n},x=function(n,t){1===arguments.length&&(t=n,n=Object);var e=t[f];return h.call(t,"__static__")&&(e=y(e,t.__static__),delete t.__static__),e[a]=y(v(n[a]),t),e},A=1,w=-1,O=3,M=-3,I=-2,S=2,q=1,L=2,E=4,C=8,k=16,$=32,D=E|C|k,R=D|$|q|L;function N(){throw new Error("Method not implemented!")}function U(n){return n instanceof Array||"[object Array]"===d.call(n)}function P(n){return n instanceof String||"[object String]"===d.call(n)}function j(n){return"function"==typeof n}function T(n,t,e,r,i,u,l){var o,a,f,c,h,d,m,p,_=t,g=null,b=e&&U(e);if(b&&(null==r&&(r=0),null==i&&(i=e.length-1)),null==u&&(u=r>i?-1:1),0===u||b&&!e.length||0>=s.floor((i-r)/u)+1)return _;if(0>u?((p=(r-i)%-u)&&(g=i),d=i+=p,m=r,c=-1,f=-(-u<<4)):((p=(i-r)%u)&&(g=i),d=r,m=i-=p,c=1,f=u<<4),h=r+u*(15&s.floor((i-r)/u+1)),b){for(d=s.max(0,d),m=s.min(e.length-1,m),o=r;d<=o&&o<=m&&00?new Array(n):[];if(0<(n=r.length)&&null!=t){e=e||0;var i=t;T(j(t)?function(n,e,r){return n[r]=t(r),n}:t===+t?function(n,t,r){return n[r]=i,i+=e,n}:function(n,e,r){return n[r]=t,n},r,r)}return r}function J(n,t,e){return T(function(n,t,r){return n[r]=t[e],n},n,t)}function V(n,t,e,r,i){return null==t?n:T(U(e)?function(n,t,r){return n[r]=e[r]-1-t,n}:function(n,t,r){return n[r]=e-1-t,n},n,t,r,i)}function B(n,t,e,r,i){if(null==t)return n;if(null==r&&(r=0),null==i&&(i=t.length-1),n!==t||r0?(t+u)%e[r]:0,u+=e[r]-n[r],n}:function(n,t,r){return n[r]=(t+u)%e,u+=e-n[r],n},n,t,r,i)}function W(n,t,e,r,i){return null==t?n:(null==i&&(i=t.length-1),null==r&&(r=0),n!==t||0!==e?T(function(n,t,r){return n[r+e]=t,n},n,t,0>e?r:i,0>e?i:r,0>e?1:-1):n)}function H(n,t,e,r,i,u,l,o){if(null==t)return null;null==e&&(e=1),null==r&&(r=0),null==i&&(i=0),null==u&&(u=t.length-1),null==l&&(l=i),null==o&&(o=u);var s=0,a=l>o?-1:1,f=l;return T(function(n,t,i){return t=r+e*t,n[f]=t-s,s=t,f+=a,n},n,t,i,u)}function Y(n,t,e,r,i,u,l,o){if(null==t)return null;null==e&&(e=1),null==r&&(r=0),null==i&&(i=0),null==u&&(u=t.length-1),null==l&&(l=i),null==o&&(o=u);var s=0,a=l>o?-1:1,f=l;return T(function(n,t,i){return s+=t,n[f]=r+e*s,f+=a,n},n,t,i,u)}function z(n,t,e,r,i,u,l,o,s){s=!0===s,r=-1===r?-1:1,null==i&&(i=0),null==u&&(u=t===+t?t-1:t.length-1),null==l&&(l=0),null==o&&(o=e?e.length-1:-1);var a=i>u?-1:1,f=l>o?-1:1,c=a*(u-i)+1,h=i,d=l,m=0;if(!e||!e.length)return t===+t?X(t,i,a):t?t.slice():t;if(null==n&&(n=new Array(s?2*c:c)),t===+t){for(;0<=a*(u-h)&&0<=f*(o-d);)h===e[d]?(s&&(n[m++]=h),h+=a,d+=f):1===r&&h>e[d]||-1===r&&he[d]||-1===r&&t[h]u?-1:1,h=l>o?-1:1,d=c*(u-i)+1+(h*(o-l)+1),m=i,p=l,_=0,g=null,b=!a;if(null==n&&(n=new Array(d)),0===n.length)return f?t:n;for(;0<=c*(u-m)&&0<=h*(o-p);){if(a&&_){if(t[m]===g){m+=c;continue}if(e[p]===g){p+=h;continue}}s?1===r&&t[m][0]e[p][0]?(n[_++]=g=t[m],m+=c):1===r&&t[m][0]>e[p][0]||-1===r&&t[m][0]e[p][1]?(n[_++]=g=t[m],b&&(n[_++]=e[p])):(n[_++]=g=e[p],b&&(n[_++]=t[m])),m+=c,p+=h):1===r&&t[m]e[p]?(n[_++]=g=t[m],m+=c):1===r&&t[m]>e[p]||-1===r&&t[m]c?u:i,_=0;_l){if(1===f){a=o-1;break}0===f&&(f=-1)}u=l}if(0===f&&(f=1),-1===a)a=e,r[0]=s,r[1]=a,r[2]=f;else{for(c=a+1,h=-1,u=i?n[c][0]:n[c],o=c+1;o<=e;o++){if(u<(l=i?n[o][0]:n[o])){if(-1===d){h=o-1;break}0===d&&(d=1)}else if(u>l){if(1===d){h=o-1;break}0===d&&(d=-1)}u=l}-1===h&&(h=e),0===d&&(d=1),r[0]=s,r[1]=a,r[2]=f,r[3]=c,r[4]=h,r[5]=d}}function Z(n,t,e,r,i,u){null==i&&(i=0),null==u&&(u=n.length-1);var l=i>u?-1:1,o=l*(u-i)+1;if(r=!0===r,1>=o)return r?1===o?[i]:[]:n;t=-1===t?-1:1;var a,f,c,h,d,m=o,p=1,_=2,g=s.min,b=new Array(o);if(r&&(n=T(function(n,t,e){return n[e-i]=[t,e],n},new Array(o),n,i,u,1),i=0,u=o-1),!0===e){h=i,d=-1,a=[-1,-1,0,-1,-1,0];do{K(n,i,u,a,r),-1===a[3]?(t!==a[2]&&i>=1;return r?J(n,n,1):n}function nn(n,t,e,r){var i,u,l,o=n.length;if(null==e&&(e=0),null==r&&(r=o-1),null==t||0===t){for(t=0,u=n[e],i=e+1;i<=r;i++){if(u<(l=n[i])){if(-1===t)return 0;0===t&&(t=1)}else if(u>l){if(1===t)return 0;0===t&&(t=-1)}u=l}return 0===t?1:t}if(t=-1===t?-1:1,e>=r)return t;if(-1===t)for(u=n[e],i=e+1;i<=r;i++){if(u<(l=n[i]))return 0;u=l}else for(u=n[e],i=e+1;i<=r;i++){if(u>(l=n[i]))return 0;u=l}return t}function tn(n,t,e,r){var i,u=o.Math.rndInt,l=!0===t?1:0;return U(e)?1<(i=e.length)&&T(function(n){if(l=0;f--)c=i[f],h=n[u+m],n[u+m]=n[u+c],n[u+c]=h,m++;return e&&Z(a),a}function rn(n,t){return n+t}function un(n,t,e,r){return T(o.Arithmetic.add,o.Arithmetic.O,n,t,e,r)}function ln(n){var t=o.Arithmetic;return t.shl(t.I,t.N(n))}function on(n,t){var e,r=o.Arithmetic,i=r.O,u=r.I,l=r.J,a=r.N,f=r.add,c=(r.sub,r.div),h=r.mul;return null==t?10>=n?0>n?i:0===n?u:a([1,2,6,24,120,720,5040,40320,362880,3628800][n-1]):(e=String(n),null==on.mem1[e]&&(on.mem1[e]=h(on(n-1),n)),on.mem1[e]):!1===t?10>=n?2>n?i:a([1,2,9,44,265,1854,14833,133496,1334961][n-2]):(e="!"+String(n),null==on.mem2[e]&&(on.mem2[e]=f(1&n?l:u,h(on(n-1,!1),n))),on.mem2[e]):!0===t?10>=n?0>n?i:0===n?u:a([1,2,4,10,26,76,232,764,2620,9496][n-1]):(e="I"+String(n),null==on.mem2[e]&&(on.mem2[e]=f(on(n-1,!0),h(on(n-2,!0),n-1))),on.mem2[e]):U(t)?t.length?0>n?i:(e=String(n)+"@"+Z(t.slice(),1,!0).join(","),null==on.mem3[e]&&(on.mem3[e]=c(on(n),T(function(n,t){return h(n,on(t))},on(t[t.length-1]),t,t.length-2,0))),on.mem3[e]):0>n?i:on(n):t===+t?0>t?-t>=n?-t===n?on(n):i:(e=String(n)+"@"+String(t),null==on.mem3[e]&&(on.mem3[e]=T(h,u,null,n+t+1,n)),on.mem3[e]):0>t||1>n||t>n?i:(t+t>n&&(t=n-t),0===t||1===n?u:1===t?a(n):(e=String(n)+"@"+String(t),null==on.mem3[e]&&(on.mem3[e]=r.isDefault()?s.round(T(function(t,e){return t*(1+n/e)},1+(n-=t),null,2,t)):f(on(n-1,t-1),on(n-1,t))),on.mem3[e])):i}function sn(n,t,e){var r,i=o.Arithmetic,u=i.O,l=i.I,s=i.V,a=i.add,f=i.mul;return 0>n||0>t?u:2===e?n===t||1===t&&0>n?l:0===n||0===t?u:(r=String(n)+","+String(t),null==sn.mem2[r]&&(sn.mem2[r]=a(sn(n-1,t-1,2),f(sn(n-1,t,2),t))),sn.mem2[r]):-1===e?t>n||0===t&&0>n?u:n===t?l:(r="-"+String(n)+","+String(t),null==sn.mem1[r]&&(sn.mem1[r]=a(sn(n-1,t-1,-1),f(sn(n-1,t,-1),1-n))),sn.mem1[r]):t>n||0===t&&0>n?u:n===t?l:1===t?on(n-1):n-t&1?s(sn(n,t,-1)):sn(n,t,-1)}function an(n,t,e,r){var i,u,l=o.Arithmetic,a=l.add,f=l.I,c=l.O;return 0>n||0>=t||e>r||e+t>n+1||t*rn||t&&e&&(t+e>n+1||t*en||t&&t>n?c:(e&&!t&&(l=0,s=1,a=e,f=e,t=e,e=null),r=String(n)+"|"+String(t)+"|"+String(e),null==fn.mem[r]&&(fn.mem[r]=T(function(t,e){return T(function(t,r){return u(t,an(n,e,1,r))},t,null,s,l||n-e+1,1)},c,null,a,f,1)),fn.mem[r])}function cn(n,t,e,r){var i,u=o.Arithmetic,l=u.add,a=u.O,f=u.I;return 0>n||0>=t||e>r||e*t>n||t*rn||t&&e&&(t+e>n+1||t*en||t&&t>n?c:(r=String(n)+"|"+String(t)+"|"+String(e),null==hn.mem[r]&&(hn.mem[r]=t&&e?t*e===n?l:f(cn(n-e,t-1,1,e),t):t?cn(n,t,1,n):e?n===e?l:T(function(t,r){return a(t,cn(n,r,1,e))},c,null,s.ceil(n/e),n-e+1,1):1<=n?ln(n-1):l),hn.mem[r])}function dn(n){var t,e=o.Arithmetic,r=e.O,i=e.N,u=e.div,l=e.mul;return 14>=n?0>n?r:i([1,1,2,5,14,42,132,429,1430,4862,16796,58786,208012,742900][n]):(t=String(n),null==dn.mem[t]&&(dn.mem[t]=u(l(dn(n-1),4*n-2),n+1)),dn.mem[t])}function mn(n){var t,e=o.Arithmetic,r=e.O,i=e.N,u=e.add,l=e.mul;return 12>=n?0>n?r:i([1,1,2,5,15,52,203,877,4140,21147,115975,678570][n]):(t=String(n),null==mn.mem[t]&&(mn.mem[t]=T(function(t,e){return u(t,l(on(n-1,e),mn(e)))},r,null,0,n-1,1)),mn.mem[t])}function pn(n){var t,e=o.Arithmetic,r=e.O,i=e.N,u=e.add;return 29>=n?0>n?r:i([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][n]):(t=String(n),null==pn.mem[t]&&(pn.mem[t]=u(pn(n-1),pn(n-2))),pn.mem[t])}function _n(n){if(!arguments.length||null==n)return E;var t=0;if(P(n)){for(var e=0,r=(n=n.toUpperCase().split(",")).length;e=t&&(t=E)}else t=R&n?R&n:E;return $&t&&D&t&&(t&=~D),k&t&&(C|E)&t&&(t&=~(C|E)),C&t&&E&t&&(t&=~E),$&t&&(t&=~q),t}function gn(){var n,t,e,r,i,u,l,o,s,a,f,c=arguments.length;if(!c)return[];if(!0===arguments[0]){for(a=arguments[1].length,n=2;n=0;t--)if(i=e%(r=arguments[t].length),e=~~(e/r),U(l=arguments[t][i]))for(u=l.length-1;u>=0;u--)o[c-++s]=l[u];else o[c-++s]=l;f[n]=o}}return f}function bn(n,t,e){var r,i,u,l,o,s,a,f,c,h,d,m,p,_,g,b,v,y,x,q,L,E,C,k,$=n.length,D=null,R=null;if(!$)return[];for(j(e)?(R=e,e=!0):e=!1,A!==t&&w!==t&&O!==t&&M!==t&&I!==t&&S!==t&&(t=!1),v=new Array($),b=[],i=1,r=0;r<$;r++)if(j(n[r][0]))null==v[n[r][1]]?v[n[r][1]]=[[n[r][0],r]]:v[n[r][1]].push([n[r][0],r]);else if(b.push(r),!(i*=n[r].length)||0>=i)return[];if(!b.length)return[];for(_=new Array(i),p=0,m=$-1,y=b.length-1,q=new Array($),L=0,r=0;r=0;u--)if(s=l%(o=n[g=b[u]].length),l=~~(l/o),h[g]=n[g][s],null!=v[g]){q[0]=g,L=1;do{for(E=v[g=q[--L]],a=h[g],C=0,k=E.length;C=0;d--){if(f=h[d],A===t&&c!==f||w===t&&1===D[f]||O===t&&f>=c||M===t&&f<=c||I===t&&fc||e&&!R(h,d,m)){x=!0;break}w===t&&(D[f]=1),c=f}x||(_[p++]=h)}return _.length>p&&(_.length=p),_}function vn(n,t,e){if(null==t||!t.length||1>=t.length)return 1===t.length?X(n-1,function(n){return n=t)return[];var e,r=X(t,0,0),i=n.length;for(t-=1,e=0;e=(r=T(rn,0,t))?i=t.slice():(0<(r-=T(rn,0,i=wn(vn(r-1,An(t,u-1,e)))))&&i.push(r),0>e&&B(i,i));else{var l,o,s,a,f,c=1,h=0,d=0,m="push";if(0>e&&(c=-c,h=u-1-h,m="unshift"),U(t[h]))for(i=[[(f=t[h])[1],f[0]]],l=0,s=1,a=c+h;se?0:l,(f=t[a])[1]===i[o][0]?i[o][1]+=f[0]:(i[m]([f[1],f[0]]),l++);else for(i=X(r=t[h],1,0),0>e&&(d=r-1-d),s=1,a=c+h;s0;)i[o]++,f--,l++,o+=c}return i}function Mn(n,t,e){var r=n?n.length:0,i=1,u=0,l=0,o=l=o&&(u+=i,o=++l>>1<<1]),l[r]+=1,r>>>=1;return l[r]+=1,n[e]=t,n},n||new Array(r),t)}function qn(n,t,e){var r,i,u,l=t.length,o=s.ceil(m(e||l)),a=1<=f[r<<=1]&&(t-=f[r],r++);return f[r]=0,n[e]=r-a,n},n||new Array(l),t)}function Ln(n,t,e){var r,i=n.length,u=null==t;if(i>1)for(u&&(t=new Array(i-1),e=0),r=i-1;r>=1;r--)t[e++]=[n[0],n[r]];else u&&(t=[]);return u?t:e}function En(n,t){var e,r,i,u,l=n.length,o=new Array(l),s=!0===t?1:0,a=new Array(l),f=0,c=0;for(e=0;es&&(i.length=u,o[c++]=i),i=new Array(l),u=0;fs&&(i.length=u,o[c++]=i),ci?function(e,r){return e[r]=r=t},lte:function(n,t){return n<=t},gt:function(n,t){return n>t},lt:function(n,t){return n=t&&n<=e:n>t&&ne?e:n},wrap:function(n,t,e){return ne?t:n},wrapR:function(n,t){return n<0?n+t:n},add:rn,sub:function(n,t){return n-t},mul:function(n,t){return n*t},div:function(n,t){return o.Math.floor(n/t)},mod:function(n,t){return n%t},pow:s.pow,shl:function(n,t){return n<>t},bor:function(n,t){return n|t},band:function(n,t){return n&t},xor:function(n,t){return n^t},abs:s.abs,min:s.min,max:s.max,floor:s.floor,ceil:s.ceil,round:s.round,num:function(n){return"number"==typeof n?o.Math.floor(n):parseInt(n,10)},val:function(n){return o.Math.floor(n.valueOf())},sum:un,product:function(n,t,e,r){return T(o.Arithmetic.mul,o.Arithmetic.I,n,t,e,r)},pow2:ln,exp:function(n,t){var e=o.Arithmetic,r=e.N;return e.pow(r(n),r(t))},factorial:on,stirling:sn,partitions:fn,compositions:hn,bell:mn,catalan:dn,fibonacci:pn},o.Arithmetic={isDefault:function(){return 0===o.Arithmetic.O&&o.Arithmetic.add===rn},O:0,I:1,J:-1,N:o.Math.N,V:o.Math.V,equ:o.Math.equ,gte:o.Math.gte,lte:o.Math.lte,gt:o.Math.gt,lt:o.Math.lt,inside:o.Math.inside,clamp:o.Math.clamp,wrap:o.Math.wrap,wrapR:o.Math.wrapR,add:o.Math.add,sub:o.Math.sub,mul:o.Math.mul,div:o.Math.div,mod:o.Math.mod,pow:o.Math.pow,shl:o.Math.shl,shr:o.Math.shr,bor:o.Math.bor,band:o.Math.band,xor:o.Math.xor,abs:o.Math.abs,min:o.Math.min,max:o.Math.max,floor:o.Math.floor,ceil:o.Math.ceil,round:o.Math.round,rnd:o.Math.rndInt,num:o.Math.num,val:o.Math.val},o.Util={array:X,operate:T,intersection:function(n,t,e,r,i,u,l,o){r=-1===r?-1:1,null==i&&(i=0),null==u&&(u=t.length-1),null==l&&(l=0),null==o&&(o=e.length-1);var a=i>u?-1:1,f=l>o?-1:1,c=a*(u-i)+1,h=f*(o-l)+1,d=i,m=l,p=0;if(null==n&&(n=new Array(s.min(c,h))),0===n.length)return n;for(;0<=a*(u-d)&&0<=f*(o-m);)1===r&&t[d]e[m]?d+=a:1===r&&t[d]>e[m]||-1===r&&t[d]u?-1:1,a=l>o?-1:1,f=s*(u-i)+1,c=i,h=l,d=0;if(!r||!r.length)return e?e.slice():e;for(null==n&&(n=new Array(f));0<=s*(u-c)&&0<=a*(o-h);)e[c]===r[h]?1r[h]?h+=a:(n[d++]=e[c],t[e[c]]--,c+=s);for(;0<=s*(u-c);)0>>1)]))return u;1===e&&nl?s=u-1:o=u+1}return-1},complementation:V,reflection:B,reversion:F,gray:G,finitedifference:H,partialsum:Y,sort:Z,shuffle:tn,pick:en,pluck:J},o.BitArray=x({constructor:function n(t){if(!(this instanceof n))return new n(t);this.length=t,this.bits=new Uint32Array(s.ceil(t/32))},length:0,bits:null,dispose:function(){return this.length=null,this.bits=null,this},clone:function(){var n=new o.BitArray(this.length);return n.bits=new Uint32Array(this.bits),n},fromArray:function(n){return this.bits=new Uint32Array(n),this},toArray:function(){return c.call(this.bits)},toString:function(){var n,t,e,r,i,u=this.toArray();for(n=0,t=u.length;n0?new Array(i+1).join("0")+r:r);return u.join("")},reset:function(){var n,t=this.bits,e=t.length;for(n=0;n>>5]&1<<(31&n))},set:function(n){return this.bits[n>>>5]|=1<<(31&n),this},unset:function(n){return this.bits[n>>>5]&=~(1<<(31&n)),this},toggle:function(n){return this.bits[n>>>5]^=1<<(31&n),this}}),u=o.Filter=x({constructor:function n(t){if(!(this instanceof n))return new n(t);this.filter=t||null},__static__:{UNIQUE:function(){return u(function(n){var t,e=n.length,r={};for(t=0;targuments.length||null==t)&&(t=!0),u(-1===n?function(n){for(var e=n[0],r=1,i=n.length;r=n[r]||!t&&e>n[r])return!1;e=n[r]}return!0})},LEN:function(n,t){return n=+n,u(">="===(t=t||"==")?function(t){return t.length>=n}:">"===t?function(t){return t.length>n}:"<"===t?function(t){return t.length="===(e=e||"==")?function(e){return 0<=n&&n=t}:">"===e?function(e){return 0<=n&&nt}:"<"===e?function(e){return 0<=n&&n="===(t=t||"==")?function(t){return T(function(n,e){return t[e]>n&&(n=t[e]),n},-1/0,null,0,t.length-1,1)>=n}:">"===t?function(t){return T(function(n,e){return t[e]>n&&(n=t[e]),n},-1/0,null,0,t.length-1,1)>n}:"<"===t?function(t){return T(function(n,e){return t[e]>n&&(n=t[e]),n},-1/0,null,0,t.length-1,1)n&&(n=t[e]),n},-1/0,null,0,t.length-1,1)<=n}:"!="===t?function(t){return T(function(n,e){return t[e]>n&&(n=t[e]),n},-1/0,null,0,t.length-1,1)!==n}:function(t){return T(function(n,e){return t[e]>n&&(n=t[e]),n},-1/0,null,0,t.length-1,1)===n})},MIN:function(n,t){return n=+n,u(">="===(t=t||"==")?function(t){return T(function(n,e){return t[e]=n}:">"===t?function(t){return T(function(n,e){return t[e]n}:"<"===t?function(t){return T(function(n,e){return t[e]l&&(l=e),ea&&(a=r),r(e=-1===e?-1:1)||q&(t&&null!=t.order?t.order:E)?t.seq[t.seq.length-1].item0(e):t.seq[0].item0(e):null},succ:function(n,t,e,r,i,u){if(null==e||null==n)return null;var l,s,a,f,c,h=o.Arithmetic;if(i=-1===i?-1:1,r&&"sequence"===r.type){if(!(c=r.seq)||!c.length)return null;for(q&(r&&null!=r.order?r.order:E)?(l=-1,s=c.length-1):(l=1,s=0),f=l*r.seq_curr+s,a=l*i;0<=f&&fi?h.J:h.I),e,r)},rand:function(n,t){var e,r,i,u,l,s=o.Arithmetic,a=s.O;if(t&&"sequence"===t.type){if(!(i=t.seq)||!i.length)return null;for(e=null!=t.last?t.last:s.sub(this.count(n,t),s.I),r=s.rnd(a,e),u=0,l=i.length;s.gte(r,i[u].total())&&(r=s.sub(r,i[u].total()),!(++u>=l||s.lt(r,a))););return u=i||u.lt(n,l))););return rs&&(s=t[n]+1),t[n]):s+e[n-t.length]}:function(n){return n=0;d--)b.splice(t[d],1);for(d=0,h=0;hn?u.seq.length-1:0:-1),$&c?("gen"===o.Options.RANDOM||1===u.rand[u.type]||s.gt(e,o.Options.MAXMEM)||s.isDefault()&&0>e?(this.__item=i.rand(l,u),this.__index=a):(this._traversed&&this._traversed.dispose(),this._traversed=new o.BitArray(s.val(e)),t=this.random("index"),this._traversed.set(+t),this.__item=i.unrank(t,l,u),null!=this.__item&&(this.__index=t)),this._index=a):(this.__item=i.initial(l,u,n,!0),null!=this.__item&&(this.__index=0>n?r:a,this._update()),this._index=this.__index),this._item=i.output(this.__item,this.__index,l,u),this._prev=!($&c||0n&&!($&c))&&null!=this.__item,this},_update:function(){return this.item__=null,this},order:function(n,t){if(!arguments.length)return this._order;var e,r,i,u,l,s,a=this[f],c=o.Arithmetic,h=(c.O,c.I,!0===n);if(t=-1===t,this.n,i=this.$,this._traversed&&(this._traversed.dispose(),this._traversed=null),h?n=i.order:P(n)&&-1<(r=n.indexOf("|"))?(e=n.substr(r+1),n=_n(n.substr(0,r))):e=n=_n(n),u=t?-1:1,i.order=n,i.sub?(h?i.sub.rewind(u):i.sub.order(e,u),this.__subindex=i.sub.index(),this.__subitem=i.sub.next(u),this._subindex=null,this._subitem=null):(this.__subindex=null,this.__subitem=null,this._subindex=null,this._subitem=null),"sequence"===i.type&&i.seq&&i.seq.length)for(l=0,s=i.seq.length;l(n=-1===n?-1:1)&&$&y)return null;t=0>n?g:_;do{if(c=null!=(a=v.sub?this._subitem:this._item),$&y)if(u=v.last,m.lt(this._index,u))if(e=this._traversed){for(r=this.random("index"),s=o.Math.rnd()>.5?g:_;e.isset(+r);)r=m.wrap(m.add(r,s),p,u);e.set(+r),this.__item=d.unrank(r,b,v),null!=this.__item&&(this.__index=r)}else this.__item=d.rand(b,v),this.__index=null;else this._item=this.__item=null,this._traversed&&(this._traversed.dispose(),this._traversed=null);else this.__item=d.succ(this.__item,this.__index,b,v,n,this.item__),null!=this.__item&&(this.__index=m.add(this.__index,t));if(h=null!=this.__item)this._index=m.add(this._index,t),null===this.__index&&(this.__index=this._index),0>n?(this._prev=h,this._next=c):(this._prev=c,this._next=h);else if(v.sub&&v.sub.hasNext(n)){if(this.__subindex=v.sub.index(),this.__subitem=v.sub.next(n),"sequence"===v.type&&v.seq&&v.seq.length)for(i=0,l=v.seq.length;in?(this._prev=h,this._next=c):(this._prev=c,this._next=h);this._item=d.output(this.__item,this.__index,b,v),v.sub&&(h=h&&null!=this.__subitem,this._subindex=h?m.add(m.mul(this.__subindex,x),this._index):null,this._subitem=h?d.fusion(v.submethod,this._item,this.__subitem,this.dimension(),this.base(),v.subpos,v.subcascade):null,0>n?this._prev=h:this._next=h)}while(v.filter&&a&&!v.filter.apply(a,this));return a},range:function(n,t){var e,r,i,u,l=this,s=o.Arithmetic,a=s.N,f=s.O,c=s.I,h=l.$,d=h.sub?h.subcount:h.count,m=h.sub?s.sub(d,c):h.last,p=1,_=arguments.length,g=!($&h.order);return _<1?(n=f,t=m):_<2?(n=a(n),t=m):(n=a(n),t=a(t)),n=s.wrapR(n,d),t=s.wrapR(t,d),s.gt(n,t)&&(e=n,n=t,t=e,p=-1),n=s.clamp(n,f,m),g&&(t=s.clamp(t,f,m)),s.lte(n,t)?(u=[l.$.order,l.__index,l._index,l.__item&&l.__item.slice(),l._item,l.__subindex,l._subindex,l.__subitem,l._subitem,l._prev,l._next],g&&l.index(n),i=s.val(s.sub(t,n)),r=T(function(n,t,e){return n[e]=l.next(),n},new Array(i+1),null,0>p?i:0,0>p?0:i,0>p?-1:1),l.$.order=u[0],l.__index=u[1],l._index=u[2],l.__item=u[3],l._item=u[4],l.__subindex=u[5],l._subindex=u[6],l.__subitem=u[7],l._subitem=u[8],l._prev=u[9],l._next=u[10],l._update()):r=[],r},__iter__:function(){return new t.Iterable(this)}}),"undefined"!=typeof Symbol&&void 0!==Symbol.iterator&&(t[a][Symbol.iterator]=t[a].__iter__),o.Tensor=x(t,{constructor:function n(){var e,r=null,i=c.call(arguments);if(e=!i.length||i[i.length-1]instanceof t||U(i[i.length-1])||i[i.length-1]===+i[i.length-1]?{}:i.pop()||{},i.length&&U(i[0])&&(i=i[0]),i&&i.length||(i=[]),!(this instanceof n))return new n(i,e);if(e.type=String(e.type||"tensor").toLowerCase(),e.order=e.order||E,e.rand=e.rand||{},"partial"===e.type){i=U(i)&&i.length?i[0]:i;var u=-1,l=e.data||[],o=e.position||null;i instanceof t?u=i=(r=i).base():r=e.sub,i=+(i||0)||0,l.length&&(P(l[0])||l[0].length&&(!0===l[0][0]||!1===l[0][0]))&&(u===i&&(i+=l.length,u=-1),l=n.generate(i,l,o,e.ordering||null)),u===i&&(i+=(l.length?l[0].length:0)||0,u=-1),e.data=l,e.position=o||X((l.length?l[0].length:0)||0,0,1),e.dimension=e.position.length,e.base=i,e.rand.partial=1}else if("tuple"===e.type)i[0]=i[0]||1,i[1]=i[1]||1,i[0]instanceof t?(r=i[0],i[0]=r.dimension()):i[1]instanceof t?(r=i[1],i[1]=r.base()):r=e.sub,e.base=i[1],e.dimension=i[0],"gray"===e.output&&(e.output=function(t,e){return n.gray(t,e[1])});else{var s=T(function(n,t){return tn[1]&&(n[1]=t),n},[1/0,0],i);if(e.base=i,e.minbase=s[0],e.maxbase=s[1],e.dimension=i.length,"gray"===e.output)e.output=function(t,e){return n.gray(t,e)};else if(U(e.output)){var a=e.output;e.output=function(t,e){return n.component(t,a)}}}t.call(this,"Tensor",i,e,r?{method:"partial"===e.type?e.submethod||"complete":e.submethod,iter:r,pos:"partial"===e.type?e.subpos||e.position:e.subpos,cascade:e.subcascade}:null)},__static__:{C:t.C,P:t.P,T:t.T,DUAL:t.DUAL,count:function(n,t){var e=o.Arithmetic.O,r=t&&t.type?t.type:"tensor";return"partial"===r?t.data&&t.data.length?o.Arithmetic.N(t.data.length):e:"tuple"===r?!n||0>=n[0]?e:o.Math.exp(n[1],n[0]):n&&n.length?o.Math.product(n):e},initial:function(n,t,e){var r,i=t&&t.type?t.type:"tensor",u=t&&t.order?t.order:E;return e=-1===e?-1:1,(!(C&u)&&q&u||C&u&&!(q&u))&&(e=-e),"partial"===i?r=t.data&&t.data.length?0>e?t.data[t.data.length-1]:t.data[0]:null:(r="tuple"===i?n[0]?X(n[0],0>e?n[1]-1:0,0):[]:n.length?0>e?X(n.length,function(t){return n[t]-1}):X(n.length,0,0):[],r=this.DUAL(r,n,t)),r},succ:function(n,t,e,r,i,u){if(!e||null==n)return null;var l=r&&r.type?r.type:"tensor",s=r&&null!=r.order?r.order:E;if(i=-1===i?-1:1,"partial"===l){if(!r.data||!r.data.length)return null;q&s&&(i=-i);var a=null==t?r.data.indexOf(n):o.Arithmetic.val(t);return 0>i?0<=a-1?r.data[a-1]:null:0<=a&&a+1=e[0]?null:function(n,t,e,r,i,u){var l,o,s,a,f,c,h,d,m,p=t;"tuple"===r?(l=p[0],p=p[1]):l=p.length;0,c=1,a=m=l-1,f=0,h=1,d=0,C&i&&(c=-c,a=m-a,f=m-f,h=-h,d=m-d);L&i&&(c=-c,a=m-a,f=m-f,h=-h,d=m-d);q&i&&(e=-e);if(0>e)if("tuple"===r){for(o=a;0<=o&&m>=o&&0===n[o];)o-=c;if(0<=o&&m>=o)for(p-=1,n[o]=n[o]-1,s=o+c;0<=s&&m>=s;s+=c)n[s]=p;else n=null}else{for(o=a;0<=o&&m>=o&&0===n[o];)o-=c;if(0<=o&&m>=o)for(n[o]=n[o]-1,s=o+c;0<=s&&m>=s;s+=c)n[s]=p[h*s+d]-1;else n=null}else if("tuple"===r){for(o=a;0<=o&&m>=o&&n[o]+1===p;)o-=c;if(0<=o&&m>=o)for(n[o]=n[o]+1,s=o+c;0<=s&&m>=s;s+=c)n[s]=0;else n=null}else{for(o=a;0<=o&&m>=o&&n[o]+1===p[h*o+d];)o-=c;if(0<=o&&m>=o)for(n[o]=n[o]+1,s=o+c;0<=s&&m>=s;s+=c)n[s]=0;else n=null}return n}(n,e,i,l,s)},rand:function(n,t){var e,r=o.Math.rndInt,i=t&&t.type?t.type:"tensor";return"partial"===i?e=t.data&&t.data.length?t.data[r(0,t.data.length-1)]:null:(e="tuple"===i?n[0]?X(n[0],function(t){return r(0,n[1]-1)}):[]:n.length?X(n.length,function(t){return r(0,n[t]-1)}):[],e=this.DUAL(e,n,t)),e},randu:t.rand,rank:function(n,t,e){var r,i,u=o.Arithmetic,l=e&&null!=e.order?e.order:E,s=e&&e.type?e.type:"tensor",a=u.add,f=u.sub,c=u.mul,h=u.O,d=u.J;if("partial"===s)h=u.N(e.data&&e.data.length?e.data.indexOf(n):-1);else if(n=this.DUAL(n,t,e),"tuple"===s){if(!(r=t[0]))return d;for(t=t[1],i=0;i=0;u--)l=m(r,i),r=p(r,i),s[u]=_(l)}else{if(!(a=t.length))return[];for(s=new Array(a),r=n,u=a-1;u>=0;u--)l=m(r,i=t[u]),r=p(r,i),s[u]=_(l)}s=this.DUAL(s,t,e)}return s},fusion:t.fusion,output:t.output,gray:function(n,t){return G(new Array(n.length),n,t)},product:gn,directsum:function(){var n,t,e=arguments,r=e.length,i=0;for(t=0;t=n+e[t].length&&(n+=e[t++].length),n+e[t][r-n]})},component:function(n,t){return null==n?null:null==t?n:X(n.length,function(e){return eu[1]?vn(n,X(u[0]-u[1]+1,u[1],1).filter(k)).reverse():vn(n,X(u[1]-u[0]+1,u[0],1).filter(k)):vn(n,u[1].split(",").map(Number).filter(k))).length){q=!0;break}t.push(s)}else if(u=l.match(g)){if(!(s=0u[1]?X(u[0]-u[1]+1,u[0],-1):X(u[1]-u[0]+1,u[0],1)).filter(k):u[1].split(",").map(Number).filter(k)).length){q=!0;break}t.push(s)}else{if(f=-1,c=null,h=null,l=l.replace(_,function(n,t){return null===c&&(f=parseInt(t,10),c="v"+String(f)),c}),!k(f)){e&&e.splice(a--,1);continue}try{h=new Function(c,"return Math.floor("+l+");")}catch(n){h=null}if(!j(h)){e&&e.splice(a--,1);continue}C[f]?C[f].push(h):C[f]=[h],0>e.indexOf(f)&&E.push(f),L.push([h,null,null,f,e[a]]),t.push(L[L.length-1])}else if(U(l)){if(!(s=!1===l[0]?vn(n,l.slice(1).filter(k)):l.slice(1).filter(k)).length){q=!0;break}t.push(s)}if(q&&(t=[]),E.length)for(o=0,x=E.length;ot||t>p)return!1;return!0})).length){q=!0;break}t[u[1]]=s}return q?[]:(r="="===r?A:"!="===r||"<>"===r?w:"<"===r?O:"<="===r||"=<"===r?S:">"===r?M:(">="===r||"=>"===r)&&I,d=j(i.extra_conditions)?function(n,t,e){return m<=n[t]&&n[t]<=p&&i.extra_conditions(n,t,e)}:function(n,t,e){return m<=n[t]&&n[t]<=p},!0===i.lazy?t:bn(t,r,d))}}}),o.Permutation=x(t,{constructor:function n(e,r){var i=null;if(!(this instanceof n))return new n(e,r);(r=r||{}).type=String(r.type||"permutation").toLowerCase(),(e=e||0)instanceof t?e=(i=e).dimension():i=r.sub,r.base=r.dimension=e,r.rand=r.rand||{},r.rand.derangement=1,r.rand.involution=1,r.rand.connected=1,"multiset"===r.type&&(r.multiplicity=U(r.multiplicity)&&r.multiplicity.length?r.multiplicity.slice():X(e,1,0),r.multiplicity=r.multiplicity.concat(X(e-T(rn,0,r.multiplicity),1,0)),r.base=r.multiplicity.length,r.multiset=Mn(r.multiplicity,e)),t.call(this,"Permutation",e,r,i?{method:r.submethod,iter:i,pos:r.subpos,cascade:r.subcascade}:null)},__static__:{C:t.C,P:t.P,T:t.T,DUAL:t.DUAL,count:function(n,t){var e=o.Arithmetic,r=e.O,i=o.Math.factorial,u=o.Math.stirling,l=t&&t.type?t.type:"permutation",s=t&&null!=t["cycles="]?0|t["cycles="]:null,a=t&&null!=t["fixed="]?0|t["fixed="]:null;return 0>n?r:"cyclic"===l?e.N(n):"multiset"===l?i(n,t.multiplicity):"derangement"===l?a?2>n-a?r:e.mul(i(n,a),i(n-a,!1)):2>n?r:i(n,!1):"involution"===l?i(n,!0):"connected"===l?i(n-1):s?u(n,s,1):i(n)},initial:function(n,t,e){var r,i=t&&t.type?t.type:"permutation",u=t&&null!=-t.order?t.order:E,l=t&&null!=t["cycles="]?0|t["cycles="]:null,o=t&&null!=t["fixed="]?0|t["fixed="]:null;if(0===n)return[];if(e=-1===e?-1:1,(!(C&u)&&q&u||C&u&&!(q&u))&&(e=-e),"cyclic"===i)r=0>e?[n-1].concat(X(n-1,0,1)):X(n,0,1);else if("derangement"===i){if(o||2>n)return null;if(1&n){var a=s.floor(n/2);r=0>e?X(n-a-1,n-1,-1).concat([a-1,a]).concat(X(a-1,a-2,-1)):X(n-3,function(n){return 1&n?n-1:n+1}).concat([n-2,n-1,n-3])}else r=0>e?X(n,n-1,-1):X(n,function(n){return 1&n?n-1:n+1})}else r="multiset"===i?0>e?t.multiset.slice().reverse():t.multiset.slice():"connected"===i?null:"involution"===i?0>e?X(n,n-1,-1):X(n,0,1):l?null:0>e?X(n,n-1,-1):X(n,0,1);return r=this.DUAL(r,n,t)},succ:function(n,t,e,r,i,u){if(!e||0>=e||null==n)return null;var l=r&&r.type?r.type:"permutation",o=r&&null!=r["cycles="]?0|r["cycles="]:null,s=r&&null!=r["fixed="]?0|r["fixed="]:null;return"derangement"===l&&s||"permutation"===l&&o?null:function(n,t,e,r,i,u,l){var o,s,a,f,c,h,d,m,p,_,g,b,v,y=t,x=null==u?y:u;0,m=1,d=v=y-1,p=1,_=0,g=1,b=0,C&i&&(m=-m,d=v-d,p=-p,_=x-1-_,e=-e);L&i&&(m=-m,d=v-d,g=-1,b=x-1);q&i&&(e=-e);if(0>e)if("cyclic"===r)if(p*n[o=v-d]+_>0)for(g=y-1,m=y+m,a=0;a0&&p*n[o]<=p*n[s];)s-=m;for(c=n[o],n[o]=n[s],n[s]=c,a=o+m,f=d;0<=a&&a<=v&&0<=f&&f<=v&&m*(f-a)>0;)c=n[a],n[a]=n[f],n[f]=c,h=h||g*a+b===n[a]||g*f+b===n[f],a+=m,f-=m;if("derangement"===r)for(0<=s&&s<=v&&(h=h||g*s+b===n[s]),0<=f&&f<=v&&(h=h||g*f+b===n[f]),h=h||g*o+b===n[o],a=o-m;!h&&0<=a&&a<=v;a-=m)h=g*a+b===n[a];else h=!1}else n=null}while(n&&h);else if("cyclic"===r)if(p*n[o=v-d]+_=p*n[o+m];)o-=m;if(0<=o&&o<=v){for(s=d;0<=s&&s<=v&&m*(s-o)>0&&p*n[o]>=p*n[s];)s-=m;for(c=n[o],n[o]=n[s],n[s]=c,a=o+m,f=d;0<=a&&a<=v&&0<=f&&f<=v&&m*(f-a)>0;)c=n[a],n[a]=n[f],n[f]=c,h=h||g*a+b===n[a]||g*f+b===n[f],a+=m,f-=m;if("derangement"===r)for(0<=s&&s<=v&&(h=h||g*s+b===n[s]),0<=f&&f<=v&&(h=h||g*f+b===n[f]),h=h||g*o+b===n[o],a=o-m;!h&&0<=a&&a<=v;a-=m)h=g*a+b===n[a];else h=!1}else n=null}while(n&&h);return n}(n,e,i=-1===i?-1:1,l,r&&null!=r.order?r.order:E,r&&null!=r.base?r.base:null)},rand:function(n,t){var e,r=o.Math.rndInt,i=t&&t.type?t.type:"permutation",u=t&&null!=t["cycles="]?0|t["cycles="]:null,l=t&&null!=t["fixed="]?0|t["fixed="]:null;if(0===n)return[];if("cyclic"===i){var s=r(0,n-1);e=0b&&(m=A[d=r(0,y-1)],--y,_=A[d],A[d]=A[y],A[y]=_,_=e[m],e[m]=e[h],e[h]=_)}else if("multiset"===i)e=tn(t.multiset.slice());else if("connected"===i)e=tn(X(n,0,1),!0);else{if(u)return null;e=tn(X(n,0,1))}return e=this.DUAL(e,n,t)},randu:t.rand,rank:function(n,t,e){var r,i,u,l,s,a=o.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:E),d=a.sub,m=a.add,p=a.mul,_=a.div,g=a.O,b=a.I,v=a.J;if(!(t=t||n.length))return g;if(n=this.DUAL(n,t,e),"cyclic"===f)g=a.NUM(n[0]);else{if("derangement"===f||"involution"===f||"connected"===f)return N();if("multiset"===f)for(s=e.multiplicity.slice(),l=e&&null!=e.count?e.count:o.Math.factorial(t,s),u=t-1,r=0;r=0;u--)a=_(i,s=t-u),i=g(i,s),r[u]=y(a);qn(r,r)}}return r=this.DUAL(r,t,e)},fusion:t.fusion,output:t.output,permute:Cn,shuffle:function(n,t){if("cyclic"===t){var e=n.length,r=o.Math.rndInt(0,e-1);return 0=t+r&&(t+=r,r=n[++e].length),t+n[e][i-t]})}(U(arguments[0])&&U(arguments[0][0])?arguments[0]:c.call(arguments)):null},cycles:function(n,t){return-1===t?cycles2permutation(n):En(n)},swaps:function(n,t){return-1===t?function(n,t){var e,r,i,u=n.length,l=new Array(t);for(e=0;e=l&&(i=0,r++);else for(r=0,i=0;r=l&&(i=0,r++);return n}(null,n,t):function(n,t,e){var r,i,u=t.length,l=u*u;for(n=n||new Array(l),r=0,i=0;r=u&&(i=0,r+=u);if(!0===e)for(r=0;r(r=n[e])||r>=t||0t)return!1;return!0!==e||r===t},is_involution:function(n){for(var t=n.length,e=0,r=n[e];er||t<=r||n[r]!==e)return!1;return!0},is_kthroot:function(n,t){if(1>(t=t||1))return!1;var e,r,i,u=n.length;for(e=0;e=t||0e&&(e=i),e<=r)return!1;return!0},is_kcycle:function(n,t,e,r){if(!n.length||0>=t)return!1;r=!1!==r;var i,u,l,o,s,a=n.length;for(i=0,l=0,s=0,o=new Array(a);s="===e?l>=t:l===t}},_update:function(){return this.item__=(this.__item,this.n,this.$.order,this.$.type,null),this}}),(e=o.Combination=x(t,{constructor:function n(e,r,i){var u=null;if(!(this instanceof n))return new n(e,r,i);if(U(e)?(i=r||{},r=e[1]||0,e=e[0]||0):(i=i||{},e=e||0,r=r||0),i.type=String(i.type||"combination").toLowerCase(),-1e?n[0]-1:0,0):"ordered"===i||"variation"===i?0>e?X(n[1],n[0]-1,-1):X(n[1],0,1):X(n[1],0>e?n[0]-n[1]:0,1),r=this.DUAL(r,n,t))},succ:function(n,t,e,r,i,u){return!e||!e[0]||0>=e[0]||0===e[1]||null==n?null:function(n,t,e,r,i,u){var l,o,s,a,f,c,h,d,m,p,_,g,b,v=t[1],y=t[0];0,c=1,f=h=v-1,d=1,m=0,p=1,_=0,C&i&&(d=-d,m=y-1-m,c=-c,f=h-f,p=-p,_=h-_);L&i&&(c=-c,f=h-f,p=-p,_=h-_);q&i&&(e=-e);if(0>e)if("ordered+repeated"===r||"variation+repeated"===r||"repeated+variation"===r){for(l=f;0<=l&&l<=h&&0===n[l];)l-=c;if(0<=l&&l<=h)for(y-=1,n[l]=n[l]-1,o=l+c;0<=o&&o<=h;o+=c)n[o]=y;else n=null}else if("ordered"===r||"variation"===r){for(null==u&&(u=kn(n,y,v,i,r)),l=f,s=-1;-1===s&&0<=l&&l<=h;){if(d*n[l]+m-d>=0)for(o=d*n[l]+m-d;0<=o&&o(c=-c)?0:h,!b&&n[o]+1>v||b&&n[o]>0){if(b)for(;0<=l&&l<=h&&0===n[l];)l+=c;else for(;0<=l&&l<=h&&p*l+_===n[l];)l+=c;for(n[l]-=1,l-=c;0<=l&&l<=h;)n[l]=n[l+c]-g,l-=c}else n=null;else{for(s=-1,l=f;0<=l-c&&l-c<=h;l-=c)if(n[l]>n[l-c]+g){s=l;break}if(!(0<=s&&s<=h)&&0c?h:0]&&(s=0>c?h:0),0<=s&&s<=h){for(a=y-1+g,l=f;0<=l&&l<=h&&0=0;a--)s=_(l,t),l=p(l,t),r[a]=y(s);else if("ordered"===A||"variation"===A){for(l=n,a=x-1;a>=0;a--)s=_(l,u=t-a),l=p(l,u),r[a]=y(s);qn(r,r,u)}else{u=(f="repeated"===A||"combination+repeated"===A)?t+x-1:t,n=m(m(i=e&&e.count?e.count:o.Math.factorial(u,x),d),n),i=p(g(i,u-x),u),s=u-x+1,l=x,a=u-1;do{b(i,n)?(r[x-l]=f?u-s-x+1:u-s-l+1,v(i,h)&&(n=m(n,i),i=p(g(i,l),a)),l--,a--):(i=p(g(i,a-l),a),s--,a--)}while(l>0)}return r=this.DUAL(r,t,e)},fusion:t.fusion,output:t.output,complement:function(n,t,e){return!0===e?tn(vn(t,n,!0)):vn(t,n)},binary:function(n,t,e){return-1===e?xn(n,t):yn(n,t)},pick:function(n,t,e){return 0e&&T(function(n,t){r[t]=t},null,null,0,n,1):0>e&&(r[0]=n-1,r[n]=1),r=this.DUAL(r,n,t,1)},succ:function(n,e,r,i,u,l){return null==n?null:i&&"binary"===i.type?t.succ.call(this,n,e,r,i,u):function(n,t,e,r){var i,u,l,o,s,a,f=t,c=t-1;if(o=1,1,0,C&r)return null;L&r&&(o=-o);q&r&&(e=-e);0>o?(i=t-(n[f]||1),s=u=t-1,a=i):(i=0,u=n[f]-1,s=i,a=u);0>e?00?1===n[f]||l>n[a-o]+1?(n[a]-=1,n[a+o]=c,n[f]++):n[f]--:n[f]=0:n=null:0===n[f]?(n[i]=0,n[f]=1):1*n[s]+0=0;u--)r(0,1)&&(i={len:i?i.len+1:1,k:u,next:i});return e=(e=i?X(i.len,function(n){var t=i.k;return i=i.next,t}):[]).concat(e.length=n||a&&o&&(a+o>n+1||a*on||o&&o>n?null:(e=-1===e?-1:1,(!(C&f)&&q&f||C&f&&!(q&f))&&(e=-e),(r=new Array(c+1))[c]=0,a&&o?(r[c]=a,1===a&&(r[0]=o),h?(r=T(function(n,t,e){return n[e]=t,n},r,[(n-o)%(u=s.min(o,s.ceil((n-o)/(a-1))))||u].concat(X(a-2,u,0)).concat([o])),0>e&&B(r,r,0,0,a-1)):0>e?(a-=i=s.min(a,s.floor(n/o)||1),0===(n-=i*o)&&0e&&B(r,r,0,0,a-1)):(i=n%(u=s.ceil(n/a))||u,r=T(function(n,t,e){return n[e]=t,n},r,0>e?[n-a+1].concat(X(a-1,1,0)):X(a-1,u,0).concat([i])))):o?(i=s.floor(n/o),u=n%o,r=T(function(n,t,e){return n[e]=t,n[c]++,n},r,h?0>e?X(i,o,0).concat(u?[u]:[]):X(n-o,1,0).concat([o]):0>e?X(i,o,0).concat(u?[u]:[]):[o].concat(X(n-o,1,0)))):r=T(function(n,t,e){return n[e]=t,n[c]++,n},r,0>e?[n]:X(n,1,0)),r=this.DUAL(r,n,t,1))},succ:function(n,t,e,r,i,u){if(null==e||null==n)return null;var l=r&&r.type?r.type:"partition",o=r&&r["max="]?0|r["max="]:null,a=r&&r["parts="]?0|r["parts="]:null;return 0>=e||a&&o&&(a+o>e+1||a*oe||o&&o>e?null:(i=-1===i?-1:1,"composition"===l?function(n,t,e,r,i,u,l){var o,s,a,f,c,h,d,m,p=t,_=r||(i?p-i+1:p);h=1,L&u&&(h=-h);q&u&&(e=-e);0>h?(d=_-(n[_]||1),s=m=_-1,a=d):(d=0,m=n[_]-1,s=d,a=m);if(0>e)if(r)if(i)n=null;else if(C&u)if(f=n[s],p-r+1>f){for(n[s]=1,o=s+h;d<=o&&o<=m&&1===n[o];)o+=h;n[o]--,d<=o-h&&o-h<=m&&(n[o-h]=1+f)}else n=null;else if(f=n[a],p-r+1>f){for(n[a]=1,o=a;d<=o&&o<=m&&1===n[o];)o-=h;n[o]--,d<=o+h&&o+h<=m&&(n[o+h]=1+f)}else n=null;else if(i)n=null;else if(C&u)n=null;else if(p>n[_]){for(o=a,c=0;d<=o&&o<=m&&1===n[o];)o-=h,c++;if(f=n[o]-1,n[o]=f,0<++c)if(d<=o+h&&o+h<=m)n[o+=h]=c,c=0,n[_]=0>h?_-o:o+1;else for(;0n[a]){for(o=s;d<=o&&o<=m&&1===n[o];)o+=h;f=n[o],n[o]=1,n[s]=f-1,d<=o+h&&o+h<=m&&n[o+h]++}else n=null;else if(p-r+1>n[s]){for(o=a;d<=o&&o<=m&&1===n[o];)o-=h;f=n[o],n[o]=1,n[a]=f-1,d<=o-h&&o-h<=m&&n[o-h]++}else n=null;else if(i)n=null;else if(C&u)n=null;else if(p>n[s])for(c=n[a],n[a-h]++,n[_]--,o=a-h,c--;0p?(_=v-(n[v]||1),f=g=v-1,c=_):(_=0,g=n[v]-1,f=_,c=g);if(0>e)if(r)n=null;else if(C&u)n=null;else if(_<=(a=i?f+p:f)&&a<=g&&n[a]>1){for(o=c,m=0;_<=o&&o<=g&&p*(o-a)>=0&&1===n[o];)m+=n[o],o-=p;if(d=n[o]-1,m++,n[o]=d,n[v]=0>p?v-o:o+1,dh||n[f+(h-1)*p]0&&n[o]===n[o-p];)m+=n[o],o-=p;for(n[o]++,m--,n[v]=0>p?v-o:o+1;0=n||h&&c&&(h+c>n+1||h*cn||c&&c>n)return null;if(h&&c)return null;if(c&&!h&&(h=c,g=!0),h)1===h?(r=[n],m=n):n===h?(r=X(h,1,0),m=n):(e={},i=n-2,X(r=Z(X(h-1,function(){for(l=a(0,i);1===e[l];)l=(l+1)%(i+1);return e[l]=1,l+1})),function(n){return l=r[n],u=l-d,d=l,m+=u,u}));else{for(e=null,l=1;l(r=n[0].indexOf(i))||0(r=n[0].indexOf(i))||0>>1,c=new Array(u);for(t=0;tu||t!==c[r-1][0]||0!==c[r-1][1])return!1;if(l=r,c[(r=n[0][t])-1]||(c[r-1]=[0,t]),r<1||r>u||0!==c[r-1][0]||t!==c[r-1][1])return!1;for(o=r,s+=n[t][t],a+=n[t][i-1-t],e=1;eu||t!==c[r-1][0]||e!==c[r-1][1])return!1;if(l+=r,c[(r=n[e][t])-1]||(c[r-1]=[e,t]),r<1||r>u||e!==c[r-1][0]||t!==c[r-1][1])return!1;o+=r}if(l!==f||o!==f)return!1}return s===f&&a===f},make:function n(t){if(0>=t||2===t)return null;if(1===t)return[[1]];var e,r,i,u,l,o,s,a,f,c,h,d,m,p,_,g=1&t,b=0==(3&t),v=t*t,y=t-g>>>1;for(_=new Array(t),e=0;e=t&&(e++,r=0),_[e][r]=(m+r-e)%t*t+(p+e+r)%t+1;else if(b)for(i=0,e=0,r=0;i=t&&(e++,r=0),_[e][r]=(e+1&3)>>>1==(r+1&3)>>>1?v-i:i+1;else{for(u=n(y),f=(a=(s=o=y*y)<<1)+o,i=0,e=0,r=0;i=y&&(e++,r=0),l=u[e][r],_[e][r]=l,_[e+y][r+y]=l+s,_[e+y][r]=l+a,_[e][r+y]=l+f;for(h=c=y>>>1,r=0;rt-h||e===c&&r===c)||0===e&&r===c||(d=_[e][r],_[e][r]=_[e][r+y],_[e][r+y]=d)}return _},product:function(){if(1>=arguments.length)return arguments[0];for(var n,t,e,r,i,u,l,o,s,a,f,c,h,d=arguments,m=d.length,p=d[0],_=1;_=i&&(h=0,++f>=i&&(s+=i,f=0,h=0,++c>=r&&(a++,o+=i,c=0,s=0,f=0,h=0),ai?-1:1),0===u||b&&!e.length||0>=s.floor((i-r)/u)+1)return g;if(0>u?((p=(r-i)%-u)&&(_=i),d=i+=p,m=r,c=-1,f=-(-u<<4)):((p=(i-r)%u)&&(_=i),d=r,m=i-=p,c=1,f=u<<4),h=r+u*(15&s.floor((i-r)/u+1)),b){for(d=s.max(0,d),m=s.min(e.length-1,m),o=r;d<=o&&o<=m&&00?new Array(n):[];if(0<(n=r.length)&&null!=t){e=e||0;var i=t;T(j(t)?function(n,e,r){return n[r]=t(r),n}:t===+t?function(n,t,r){return n[r]=i,i+=e,n}:function(n,e,r){return n[r]=t,n},r,r)}return r}function J(n,t,e){return T(function(n,t,r){return n[r]=t[e],n},n,t)}function V(n,t,e,r,i){return null==t?n:T(U(e)?function(n,t,r){return n[r]=e[r]-1-t,n}:function(n,t,r){return n[r]=e-1-t,n},n,t,r,i)}function B(n,t,e,r,i){if(null==t)return n;if(null==r&&(r=0),null==i&&(i=t.length-1),n!==t||r0?(t+u)%e[r]:0,u+=e[r]-n[r],n}:function(n,t,r){return n[r]=(t+u)%e,u+=e-n[r],n},n,t,r,i)}function W(n,t,e,r,i){return null==t?n:(null==i&&(i=t.length-1),null==r&&(r=0),n!==t||0!==e?T(function(n,t,r){return n[r+e]=t,n},n,t,0>e?r:i,0>e?i:r,0>e?1:-1):n)}function H(n,t,e,r,i,u,l,o){if(null==t)return null;null==e&&(e=1),null==r&&(r=0),null==i&&(i=0),null==u&&(u=t.length-1),null==l&&(l=i),null==o&&(o=u);var s=0,a=l>o?-1:1,f=l;return T(function(n,t,i){return t=r+e*t,n[f]=t-s,s=t,f+=a,n},n,t,i,u)}function Y(n,t,e,r,i,u,l,o){if(null==t)return null;null==e&&(e=1),null==r&&(r=0),null==i&&(i=0),null==u&&(u=t.length-1),null==l&&(l=i),null==o&&(o=u);var s=0,a=l>o?-1:1,f=l;return T(function(n,t,i){return s+=t,n[f]=r+e*s,f+=a,n},n,t,i,u)}function z(n,t,e,r,i,u,l,o,s){s=!0===s,r=-1===r?-1:1,null==i&&(i=0),null==u&&(u=t===+t?t-1:t.length-1),null==l&&(l=0),null==o&&(o=e?e.length-1:-1);var a=i>u?-1:1,f=l>o?-1:1,c=a*(u-i)+1,h=i,d=l,m=0;if(!e||!e.length)return t===+t?X(t,i,a):t?t.slice():t;if(null==n&&(n=new Array(s?2*c:c)),t===+t){for(;0<=a*(u-h)&&0<=f*(o-d);)h===e[d]?(s&&(n[m++]=h),h+=a,d+=f):1===r&&h>e[d]||-1===r&&he[d]||-1===r&&t[h]u?-1:1,h=l>o?-1:1,d=c*(u-i)+1+(h*(o-l)+1),m=i,p=l,g=0,_=null,b=!a;if(null==n&&(n=new Array(d)),0===n.length)return f?t:n;for(;0<=c*(u-m)&&0<=h*(o-p);){if(a&&g){if(t[m]===_){m+=c;continue}if(e[p]===_){p+=h;continue}}s?1===r&&t[m][0]e[p][0]?(n[g++]=_=t[m],m+=c):1===r&&t[m][0]>e[p][0]||-1===r&&t[m][0]e[p][1]?(n[g++]=_=t[m],b&&(n[g++]=e[p])):(n[g++]=_=e[p],b&&(n[g++]=t[m])),m+=c,p+=h):1===r&&t[m]e[p]?(n[g++]=_=t[m],m+=c):1===r&&t[m]>e[p]||-1===r&&t[m]c?u:i,g=0;gl){if(1===f){a=o-1;break}0===f&&(f=-1)}u=l}if(0===f&&(f=1),-1===a)a=e,r[0]=s,r[1]=a,r[2]=f;else{for(c=a+1,h=-1,u=i?n[c][0]:n[c],o=c+1;o<=e;o++){if(u<(l=i?n[o][0]:n[o])){if(-1===d){h=o-1;break}0===d&&(d=1)}else if(u>l){if(1===d){h=o-1;break}0===d&&(d=-1)}u=l}-1===h&&(h=e),0===d&&(d=1),r[0]=s,r[1]=a,r[2]=f,r[3]=c,r[4]=h,r[5]=d}}function Z(n,t,e,r,i,u){null==i&&(i=0),null==u&&(u=n.length-1);var l=i>u?-1:1,o=l*(u-i)+1;if(r=!0===r,1>=o)return r?1===o?[i]:[]:n;t=-1===t?-1:1;var a,f,c,h,d,m=o,p=1,g=2,_=s.min,b=new Array(o);if(r&&(n=T(function(n,t,e){return n[e-i]=[t,e],n},new Array(o),n,i,u,1),i=0,u=o-1),!0===e){h=i,d=-1,a=[-1,-1,0,-1,-1,0];do{K(n,i,u,a,r),-1===a[3]?(t!==a[2]&&i>=1;return r?J(n,n,1):n}function nn(n,t,e,r){var i,u,l,o=n.length;if(null==e&&(e=0),null==r&&(r=o-1),null==t||0===t){for(t=0,u=n[e],i=e+1;i<=r;i++){if(u<(l=n[i])){if(-1===t)return 0;0===t&&(t=1)}else if(u>l){if(1===t)return 0;0===t&&(t=-1)}u=l}return 0===t?1:t}if(t=-1===t?-1:1,e>=r)return t;if(-1===t)for(u=n[e],i=e+1;i<=r;i++){if(u<(l=n[i]))return 0;u=l}else for(u=n[e],i=e+1;i<=r;i++){if(u>(l=n[i]))return 0;u=l}return t}function tn(n,t,e,r){var i,u=o.Math.rndInt,l=!0===t?1:0;return U(e)?1<(i=e.length)&&T(function(n){if(l=0;f--)c=i[f],h=n[u+m],n[u+m]=n[u+c],n[u+c]=h,m++;return e&&Z(a),a}function rn(n,t){return n+t}function un(n,t,e,r){return T(o.Arithmetic.add,o.Arithmetic.O,n,t,e,r)}function ln(n){var t=o.Arithmetic;return t.shl(t.I,t.N(n))}function on(n,t){var e,r=o.Arithmetic,i=r.O,u=r.I,l=r.J,a=r.N,f=r.add,c=(r.sub,r.div),h=r.mul;return null==t?10>=n?0>n?i:0===n?u:a([1,2,6,24,120,720,5040,40320,362880,3628800][n-1]):(e=String(n),null==on.mem1[e]&&(on.mem1[e]=h(on(n-1),n)),on.mem1[e]):!1===t?10>=n?2>n?i:a([1,2,9,44,265,1854,14833,133496,1334961][n-2]):(e="!"+String(n),null==on.mem2[e]&&(on.mem2[e]=f(1&n?l:u,h(on(n-1,!1),n))),on.mem2[e]):!0===t?10>=n?0>n?i:0===n?u:a([1,2,4,10,26,76,232,764,2620,9496][n-1]):(e="I"+String(n),null==on.mem2[e]&&(on.mem2[e]=f(on(n-1,!0),h(on(n-2,!0),n-1))),on.mem2[e]):U(t)?t.length?0>n?i:(e=String(n)+"@"+Z(t.slice(),1,!0).join(","),null==on.mem3[e]&&(on.mem3[e]=c(on(n),T(function(n,t){return h(n,on(t))},on(t[t.length-1]),t,t.length-2,0))),on.mem3[e]):0>n?i:on(n):t===+t?0>t?-t>=n?-t===n?on(n):i:(e=String(n)+"@"+String(t),null==on.mem3[e]&&(on.mem3[e]=T(h,u,null,n+t+1,n)),on.mem3[e]):0>t||1>n||t>n?i:(t+t>n&&(t=n-t),0===t||1===n?u:1===t?a(n):(e=String(n)+"@"+String(t),null==on.mem3[e]&&(on.mem3[e]=r.isDefault()?s.round(T(function(t,e){return t*(1+n/e)},1+(n-=t),null,2,t)):f(on(n-1,t-1),on(n-1,t))),on.mem3[e])):i}function sn(n,t,e){var r,i=o.Arithmetic,u=i.O,l=i.I,s=i.V,a=i.add,f=i.mul;return 0>n||0>t?u:2===e?n===t||1===t&&0>n?l:0===n||0===t?u:(r=String(n)+","+String(t),null==sn.mem2[r]&&(sn.mem2[r]=a(sn(n-1,t-1,2),f(sn(n-1,t,2),t))),sn.mem2[r]):-1===e?t>n||0===t&&0>n?u:n===t?l:(r="-"+String(n)+","+String(t),null==sn.mem1[r]&&(sn.mem1[r]=a(sn(n-1,t-1,-1),f(sn(n-1,t,-1),1-n))),sn.mem1[r]):t>n||0===t&&0>n?u:n===t?l:1===t?on(n-1):n-t&1?s(sn(n,t,-1)):sn(n,t,-1)}function an(n,t,e,r){var i,u,l=o.Arithmetic,a=l.add,f=l.I,c=l.O;return 0>n||0>=t||e>r||e+t>n+1||t*rn||t&&e&&(t+e>n+1||t*en||t&&t>n?c:(e&&!t&&(l=0,s=1,a=e,f=e,t=e,e=null),r=String(n)+"|"+String(t)+"|"+String(e),null==fn.mem[r]&&(fn.mem[r]=T(function(t,e){return T(function(t,r){return u(t,an(n,e,1,r))},t,null,s,l||n-e+1,1)},c,null,a,f,1)),fn.mem[r])}function cn(n,t,e,r){var i,u=o.Arithmetic,l=u.add,a=u.O,f=u.I;return 0>n||0>=t||e>r||e*t>n||t*rn||t&&e&&(t+e>n+1||t*en||t&&t>n?c:(r=String(n)+"|"+String(t)+"|"+String(e),null==hn.mem[r]&&(hn.mem[r]=t&&e?t*e===n?l:f(cn(n-e,t-1,1,e),t):t?cn(n,t,1,n):e?n===e?l:T(function(t,r){return a(t,cn(n,r,1,e))},c,null,s.ceil(n/e),n-e+1,1):1<=n?ln(n-1):l),hn.mem[r])}function dn(n){var t,e=o.Arithmetic,r=e.O,i=e.N,u=e.div,l=e.mul;return 14>=n?0>n?r:i([1,1,2,5,14,42,132,429,1430,4862,16796,58786,208012,742900][n]):(t=String(n),null==dn.mem[t]&&(dn.mem[t]=u(l(dn(n-1),4*n-2),n+1)),dn.mem[t])}function mn(n){var t,e=o.Arithmetic,r=e.O,i=e.N,u=e.add,l=e.mul;return 12>=n?0>n?r:i([1,1,2,5,15,52,203,877,4140,21147,115975,678570][n]):(t=String(n),null==mn.mem[t]&&(mn.mem[t]=T(function(t,e){return u(t,l(on(n-1,e),mn(e)))},r,null,0,n-1,1)),mn.mem[t])}function pn(n){var t,e=o.Arithmetic,r=e.O,i=e.N,u=e.add;return 29>=n?0>n?r:i([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][n]):(t=String(n),null==pn.mem[t]&&(pn.mem[t]=u(pn(n-1),pn(n-2))),pn.mem[t])}function gn(n){if(!arguments.length||null==n)return E;var t=0;if(P(n)){for(var e=0,r=(n=n.toUpperCase().split(",")).length;e=t&&(t=E)}else t=N&n?N&n:E;return $&t&&D&t&&(t&=~D),k&t&&(C|E)&t&&(t&=~(C|E)),C&t&&E&t&&(t&=~E),$&t&&(t&=~q),t}function _n(){var n,t,e,r,i,u,l,o,s,a,f,c=arguments.length;if(!c)return[];if(!0===arguments[0]){for(a=arguments[1].length,n=2;n=0;t--)if(i=e%(r=arguments[t].length),e=~~(e/r),U(l=arguments[t][i]))for(u=l.length-1;u>=0;u--)o[c-++s]=l[u];else o[c-++s]=l;f[n]=o}}return f}function bn(n,t,e){var r,i,u,l,o,s,a,f,c,h,d,m,p,g,_,b,v,y,x,q,L,E,C,k,$=n.length,D=null,N=null;if(!$)return[];for(j(e)?(N=e,e=!0):e=!1,A!==t&&w!==t&&O!==t&&M!==t&&I!==t&&S!==t&&(t=!1),v=new Array($),b=[],i=1,r=0;r<$;r++)if(j(n[r][0]))null==v[n[r][1]]?v[n[r][1]]=[[n[r][0],r]]:v[n[r][1]].push([n[r][0],r]);else if(b.push(r),!(i*=n[r].length)||0>=i)return[];if(!b.length)return[];for(g=new Array(i),p=0,m=$-1,y=b.length-1,q=new Array($),L=0,r=0;r=0;u--)if(s=l%(o=n[_=b[u]].length),l=~~(l/o),h[_]=n[_][s],null!=v[_]){q[0]=_,L=1;do{for(E=v[_=q[--L]],a=h[_],C=0,k=E.length;C=0;d--){if(f=h[d],A===t&&c!==f||w===t&&1===D[f]||O===t&&f>=c||M===t&&f<=c||I===t&&fc||e&&!N(h,d,m)){x=!0;break}w===t&&(D[f]=1),c=f}x||(g[p++]=h)}return g.length>p&&(g.length=p),g}function vn(n,t,e){if(null==t||!t.length||1>=t.length)return 1===t.length?X(n-1,function(n){return n=t)return[];var e,r=X(t,0,0),i=n.length;for(t-=1,e=0;e=(r=T(rn,0,t))?i=t.slice():(0<(r-=T(rn,0,i=wn(vn(r-1,An(t,u-1,e)))))&&i.push(r),0>e&&B(i,i));else{var l,o,s,a,f,c=1,h=0,d=0,m="push";if(0>e&&(c=-c,h=u-1-h,m="unshift"),U(t[h]))for(i=[[(f=t[h])[1],f[0]]],l=0,s=1,a=c+h;se?0:l,(f=t[a])[1]===i[o][0]?i[o][1]+=f[0]:(i[m]([f[1],f[0]]),l++);else for(i=X(r=t[h],1,0),0>e&&(d=r-1-d),s=1,a=c+h;s0;)i[o]++,f--,l++,o+=c}return i}function Mn(n,t,e){var r=n?n.length:0,i=1,u=0,l=0,o=l=o&&(u+=i,o=++l>>1<<1]),l[r]+=1,r>>>=1;return l[r]+=1,n[e]=t,n},n||new Array(r),t)}function qn(n,t,e){var r,i,u,l=t.length,o=s.ceil(m(e||l)),a=1<=f[r<<=1]&&(t-=f[r],r++);return f[r]=0,n[e]=r-a,n},n||new Array(l),t)}function Ln(n,t,e){var r,i=n.length,u=null==t;if(i>1)for(u&&(t=new Array(i-1),e=0),r=i-1;r>=1;r--)t[e++]=[n[0],n[r]];else u&&(t=[]);return u?t:e}function En(n,t){var e,r,i,u,l=n.length,o=new Array(l),s=!0===t?1:0,a=new Array(l),f=0,c=0;for(e=0;es&&(i.length=u,o[c++]=i),i=new Array(l),u=0;fs&&(i.length=u,o[c++]=i),ci?function(e,r){return e[r]=r=t},lte:function(n,t){return n<=t},gt:function(n,t){return n>t},lt:function(n,t){return n=t&&n<=e:n>t&&ne?e:n},wrap:function(n,t,e){return ne?t:n},wrapR:function(n,t){return n<0?n+t:n},add:rn,sub:function(n,t){return n-t},mul:function(n,t){return n*t},div:function(n,t){return o.Math.floor(n/t)},mod:function(n,t){return n%t},pow:s.pow,shl:function(n,t){return n<>t},bor:function(n,t){return n|t},band:function(n,t){return n&t},xor:function(n,t){return n^t},abs:s.abs,min:s.min,max:s.max,floor:s.floor,ceil:s.ceil,round:s.round,num:function(n){return"number"==typeof n?o.Math.floor(n):parseInt(n,10)},val:function(n){return o.Math.floor(n.valueOf())},sum:un,product:function(n,t,e,r){return T(o.Arithmetic.mul,o.Arithmetic.I,n,t,e,r)},pow2:ln,exp:function(n,t){var e=o.Arithmetic,r=e.N;return e.pow(r(n),r(t))},factorial:on,stirling:sn,partitions:fn,compositions:hn,bell:mn,catalan:dn,fibonacci:pn},o.Arithmetic={isDefault:function(){return 0===o.Arithmetic.O&&o.Arithmetic.add===rn},O:0,I:1,J:-1,N:o.Math.N,V:o.Math.V,equ:o.Math.equ,gte:o.Math.gte,lte:o.Math.lte,gt:o.Math.gt,lt:o.Math.lt,inside:o.Math.inside,clamp:o.Math.clamp,wrap:o.Math.wrap,wrapR:o.Math.wrapR,add:o.Math.add,sub:o.Math.sub,mul:o.Math.mul,div:o.Math.div,mod:o.Math.mod,pow:o.Math.pow,shl:o.Math.shl,shr:o.Math.shr,bor:o.Math.bor,band:o.Math.band,xor:o.Math.xor,abs:o.Math.abs,min:o.Math.min,max:o.Math.max,floor:o.Math.floor,ceil:o.Math.ceil,round:o.Math.round,rnd:o.Math.rndInt,num:o.Math.num,val:o.Math.val},o.Util={array:X,operate:T,intersection:function(n,t,e,r,i,u,l,o){r=-1===r?-1:1,null==i&&(i=0),null==u&&(u=t.length-1),null==l&&(l=0),null==o&&(o=e.length-1);var a=i>u?-1:1,f=l>o?-1:1,c=a*(u-i)+1,h=f*(o-l)+1,d=i,m=l,p=0;if(null==n&&(n=new Array(s.min(c,h))),0===n.length)return n;for(;0<=a*(u-d)&&0<=f*(o-m);)1===r&&t[d]e[m]?d+=a:1===r&&t[d]>e[m]||-1===r&&t[d]u?-1:1,a=l>o?-1:1,f=s*(u-i)+1,c=i,h=l,d=0;if(!r||!r.length)return e?e.slice():e;for(null==n&&(n=new Array(f));0<=s*(u-c)&&0<=a*(o-h);)e[c]===r[h]?1r[h]?h+=a:(n[d++]=e[c],t[e[c]]--,c+=s);for(;0<=s*(u-c);)0>>1)]))return u;1===e&&nl?s=u-1:o=u+1}return-1},complementation:V,reflection:B,reversion:F,gray:G,finitedifference:H,partialsum:Y,sort:Z,shuffle:tn,pick:en,pluck:J},o.BitArray=x({constructor:function n(t){if(!(this instanceof n))return new n(t);this.length=t,this.bits=new Uint32Array(s.ceil(t/32))},length:0,bits:null,dispose:function(){return this.length=null,this.bits=null,this},clone:function(){var n=new o.BitArray(this.length);return n.bits=new Uint32Array(this.bits),n},fromArray:function(n){return this.bits=new Uint32Array(n),this},toArray:function(){return c.call(this.bits)},toString:function(){var n,t,e,r,i,u=this.toArray();for(n=0,t=u.length;n0?new Array(i+1).join("0")+r:r);return u.join("")},reset:function(){var n,t=this.bits,e=t.length;for(n=0;n>>5]&1<<(31&n))},set:function(n){return this.bits[n>>>5]|=1<<(31&n),this},unset:function(n){return this.bits[n>>>5]&=~(1<<(31&n)),this},toggle:function(n){return this.bits[n>>>5]^=1<<(31&n),this}}),u=o.Filter=x({constructor:function n(t){if(!(this instanceof n))return new n(t);this.filter=t||null},__static__:{UNIQUE:function(){return u(function(n){var t,e=n.length,r={};for(t=0;targuments.length||null==t)&&(t=!0),P(n)&&("<"===n?(n=1,t=!0):">"===n?(n=-1,t=!0):"<="===n||"=<"===n?(n=1,t=!1):">="!==n&&"=>"!==n||(n=-1,t=!1)),u(-1===(n=-1===(n=+n)?-1:1)?function(n){for(var e=n[0],r=1,i=n.length;r=n[r]||!t&&e>n[r])return!1;e=n[r]}return!0})},LEN:function(n,t){return n=+n,u(">="===(t=t||"==")?function(t){return t.length>=n}:">"===t?function(t){return t.length>n}:"<"===t?function(t){return t.length="===(e=e||"==")||"=>"===e?function(e){return 0<=n&&n=t}:">"===e?function(e){return 0<=n&&nt}:"<"===e?function(e){return 0<=n&&n="===(t=t||"==")||"=>"===t?function(t){return T(function(n,e){return t[e]>n&&(n=t[e]),n},-1/0,null,0,t.length-1,1)>=n}:">"===t?function(t){return T(function(n,e){return t[e]>n&&(n=t[e]),n},-1/0,null,0,t.length-1,1)>n}:"<"===t?function(t){return T(function(n,e){return t[e]>n&&(n=t[e]),n},-1/0,null,0,t.length-1,1)n&&(n=t[e]),n},-1/0,null,0,t.length-1,1)<=n}:"!="===t?function(t){return T(function(n,e){return t[e]>n&&(n=t[e]),n},-1/0,null,0,t.length-1,1)!==n}:function(t){return T(function(n,e){return t[e]>n&&(n=t[e]),n},-1/0,null,0,t.length-1,1)===n})},MIN:function(n,t){return n=+n,u(">="===(t=t||"==")||"=>"===t?function(t){return T(function(n,e){return t[e]=n}:">"===t?function(t){return T(function(n,e){return t[e]n}:"<"===t?function(t){return T(function(n,e){return t[e](t=+t)){var r=n;n=t,t=r}return(3>arguments.length||null==e)&&(e=!0),u(e?function(e){for(var r=0,i=e.length;rt)return!1;return!0}:function(e){for(var r=0,i=e.length;r=t)return!1;return!0})}},filter:null,dispose:function(){return this.filter=null,this},apply:function(n,t){var e=this.filter;return!e||!j(e)||Boolean(e.call(t||null,n))},NOT:function(){var n=this;return u(function(t){return!n.apply(t,this)})},OR:function(n){var t=this;return j(n)||n instanceof u?(n instanceof u||(n=u(n)),u(function(e){return t.apply(e,this)||n.apply(e,this)})):t},XOR:function(n){var t=this;return j(n)||n instanceof u?(n instanceof u||(n=u(n)),u(function(e){var r=t.apply(e,this),i=n.apply(e,this);return r&&!i||!r&&i})):t},AND:function(n){var t=this;return j(n)||n instanceof u?(n instanceof u||(n=u(n)),u(function(e){return t.apply(e,this)&&n.apply(e,this)})):t}}),t=o.CombinatorialIterator=x({constructor:function n(t,e,r,i){o.Arithmetic;if(!(this instanceof n))return new n(t,e,r,i);if(this[f],U(t)&&(t[0]instanceof n||t[t.length-1]instanceof n)){this.$=r=e||{},r.seq=t,t=null,this.n=e=r.seq.length,r.type="sequence",r.rand=r.rand||{},r.rand.sequence=1;var u=1/0,l=-1/0,s=1/0,a=-1/0;T(function(n,t){var e=t.base(),r=t.dimension();e>l&&(l=e),ea&&(a=r),r(e=-1===e?-1:1)||q&(t&&null!=t.order?t.order:E)?t.seq[t.seq.length-1].item0(e):t.seq[0].item0(e):null},succ:function(n,t,e,r,i,u){if(null==e||null==n)return null;var l,s,a,f,c,h=o.Arithmetic;if(i=-1===i?-1:1,r&&"sequence"===r.type){if(!(c=r.seq)||!c.length)return null;for(q&(r&&null!=r.order?r.order:E)?(l=-1,s=c.length-1):(l=1,s=0),f=l*r.seq_curr+s,a=l*i;0<=f&&fi?h.J:h.I),e,r)},rand:function(n,t){var e,r,i,u,l,s=o.Arithmetic,a=s.O;if(t&&"sequence"===t.type){if(!(i=t.seq)||!i.length)return null;for(e=null!=t.last?t.last:s.sub(this.count(n,t),s.I),r=s.rnd(a,e),u=0,l=i.length;s.gte(r,i[u].total())&&(r=s.sub(r,i[u].total()),!(++u>=l||s.lt(r,a))););return u=i||u.lt(n,l))););return rs&&(s=t[n]+1),t[n]):s+e[n-t.length]}:function(n){return n=0;d--)b.splice(t[d],1);for(d=0,h=0;hn?u.seq.length-1:0:-1),$&c?("gen"===o.Options.RANDOM||1===u.rand[u.type]||s.gt(e,o.Options.MAXMEM)||s.isDefault()&&0>e?(this.__item=i.rand(l,u),this.__index=a):(this._traversed&&this._traversed.dispose(),this._traversed=new o.BitArray(s.val(e)),t=this.random("index"),this._traversed.set(+t),this.__item=i.unrank(t,l,u),null!=this.__item&&(this.__index=t)),this._index=a):(this.__item=i.initial(l,u,n,!0),null!=this.__item&&(this.__index=0>n?r:a,this._update()),this._index=this.__index),this._item=i.output(this.__item,this.__index,l,u),this._prev=!($&c||0n&&!($&c))&&null!=this.__item,this},_update:function(){return this.item__=null,this},order:function(n,t){if(!arguments.length)return this._order;var e,r,i,u,l,s,a=this[f],c=o.Arithmetic,h=(c.O,c.I,!0===n);if(t=-1===t,this.n,i=this.$,this._traversed&&(this._traversed.dispose(),this._traversed=null),h?n=i.order:P(n)&&-1<(r=n.indexOf("|"))?(e=n.substr(r+1),n=gn(n.substr(0,r))):e=n=gn(n),u=t?-1:1,i.order=n,i.sub?(h?i.sub.rewind(u):i.sub.order(e,u),this.__subindex=i.sub.index(),this.__subitem=i.sub.next(u),this._subindex=null,this._subitem=null):(this.__subindex=null,this.__subitem=null,this._subindex=null,this._subitem=null),"sequence"===i.type&&i.seq&&i.seq.length)for(l=0,s=i.seq.length;l(n=-1===n?-1:1)&&$&y)return null;t=0>n?_:g;do{if(c=null!=(a=v.sub?this._subitem:this._item),$&y)if(u=v.last,m.lt(this._index,u))if(e=this._traversed){for(r=this.random("index"),s=o.Math.rnd()>.5?_:g;e.isset(+r);)r=m.wrap(m.add(r,s),p,u);e.set(+r),this.__item=d.unrank(r,b,v),null!=this.__item&&(this.__index=r)}else this.__item=d.rand(b,v),this.__index=null;else this._item=this.__item=null,this._traversed&&(this._traversed.dispose(),this._traversed=null);else this.__item=d.succ(this.__item,this.__index,b,v,n,this.item__),null!=this.__item&&(this.__index=m.add(this.__index,t));if(h=null!=this.__item)this._index=m.add(this._index,t),null===this.__index&&(this.__index=this._index),0>n?(this._prev=h,this._next=c):(this._prev=c,this._next=h);else if(v.sub&&v.sub.hasNext(n)){if(this.__subindex=v.sub.index(),this.__subitem=v.sub.next(n),"sequence"===v.type&&v.seq&&v.seq.length)for(i=0,l=v.seq.length;in?(this._prev=h,this._next=c):(this._prev=c,this._next=h);this._item=d.output(this.__item,this.__index,b,v),v.sub&&(h=h&&null!=this.__subitem,this._subindex=h?m.add(m.mul(this.__subindex,x),this._index):null,this._subitem=h?d.fusion(v.submethod,this._item,this.__subitem,this.dimension(),this.base(),v.subpos,v.subcascade):null,0>n?this._prev=h:this._next=h)}while(v.filter&&a&&!v.filter.apply(a,this));return a},range:function(n,t){var e,r,i,u,l=this,s=o.Arithmetic,a=s.N,f=s.O,c=s.I,h=l.$,d=h.sub?h.subcount:h.count,m=h.sub?s.sub(d,c):h.last,p=1,g=arguments.length,_=!($&h.order);return g<1?(n=f,t=m):g<2?(n=a(n),t=m):(n=a(n),t=a(t)),n=s.wrapR(n,d),t=s.wrapR(t,d),s.gt(n,t)&&(e=n,n=t,t=e,p=-1),n=s.clamp(n,f,m),_&&(t=s.clamp(t,f,m)),s.lte(n,t)?(u=[l.$.order,l.__index,l._index,l.__item&&l.__item.slice(),l._item,l.__subindex,l._subindex,l.__subitem,l._subitem,l._prev,l._next],_&&l.index(n),i=s.val(s.sub(t,n)),r=T(function(n,t,e){return n[e]=l.next(),n},new Array(i+1),null,0>p?i:0,0>p?0:i,0>p?-1:1),l.$.order=u[0],l.__index=u[1],l._index=u[2],l.__item=u[3],l._item=u[4],l.__subindex=u[5],l._subindex=u[6],l.__subitem=u[7],l._subitem=u[8],l._prev=u[9],l._next=u[10],l._update()):r=[],r},__iter__:function(){return new t.Iterable(this)}}),"undefined"!=typeof Symbol&&void 0!==Symbol.iterator&&(t[a][Symbol.iterator]=t[a].__iter__),o.Tensor=x(t,{constructor:function n(){var e,r=null,i=c.call(arguments);if(e=!i.length||i[i.length-1]instanceof t||U(i[i.length-1])||i[i.length-1]===+i[i.length-1]?{}:i.pop()||{},i.length&&U(i[0])&&(i=i[0]),i&&i.length||(i=[]),!(this instanceof n))return new n(i,e);if(e.type=String(e.type||"tensor").toLowerCase(),e.order=e.order||E,e.rand=e.rand||{},"partial"===e.type){i=U(i)&&i.length?i[0]:i;var u=-1,l=e.data||[],o=e.position||null;i instanceof t?u=i=(r=i).base():r=e.sub,i=+(i||0)||0,l.length&&(P(l[0])||l[0].length&&(!0===l[0][0]||!1===l[0][0]))&&(u===i&&(i+=l.length,u=-1),l=n.generate(i,l,o,e.ordering||null)),u===i&&(i+=(l.length?l[0].length:0)||0,u=-1),e.data=l,e.position=o||X((l.length?l[0].length:0)||0,0,1),e.dimension=e.position.length,e.base=i,e.rand.partial=1}else if("tuple"===e.type)i[0]=i[0]||1,i[1]=i[1]||1,i[0]instanceof t?(r=i[0],i[0]=r.dimension()):i[1]instanceof t?(r=i[1],i[1]=r.base()):r=e.sub,e.base=i[1],e.dimension=i[0],"gray"===e.output&&(e.output=function(t,e){return n.gray(t,e[1])});else{var s=T(function(n,t){return tn[1]&&(n[1]=t),n},[1/0,0],i);if(e.base=i,e.minbase=s[0],e.maxbase=s[1],e.dimension=i.length,"gray"===e.output)e.output=function(t,e){return n.gray(t,e)};else if(U(e.output)){var a=e.output;e.output=function(t,e){return n.component(t,a)}}}t.call(this,"Tensor",i,e,r?{method:"partial"===e.type?e.submethod||"complete":e.submethod,iter:r,pos:"partial"===e.type?e.subpos||e.position:e.subpos,cascade:e.subcascade}:null)},__static__:{C:t.C,P:t.P,T:t.T,DUAL:t.DUAL,count:function(n,t){var e=o.Arithmetic.O,r=t&&t.type?t.type:"tensor";return"partial"===r?t.data&&t.data.length?o.Arithmetic.N(t.data.length):e:"tuple"===r?!n||0>=n[0]?e:o.Math.exp(n[1],n[0]):n&&n.length?o.Math.product(n):e},initial:function(n,t,e){var r,i=t&&t.type?t.type:"tensor",u=t&&t.order?t.order:E;return e=-1===e?-1:1,(!(C&u)&&q&u||C&u&&!(q&u))&&(e=-e),"partial"===i?r=t.data&&t.data.length?0>e?t.data[t.data.length-1]:t.data[0]:null:(r="tuple"===i?n[0]?X(n[0],0>e?n[1]-1:0,0):[]:n.length?0>e?X(n.length,function(t){return n[t]-1}):X(n.length,0,0):[],r=this.DUAL(r,n,t)),r},succ:function(n,t,e,r,i,u){if(!e||null==n)return null;var l,s=r&&r.type?r.type:"tensor",a=r&&null!=r.order?r.order:E,f=o.Arithmetic;return i=-1===i?-1:1,"partial"===s?r.data&&r.data.length?(q&a&&(i=-i,null!=t&&(t=f.sub(f.N(r.data.length-1),t))),null==t&&(t=kn(r.data,n,!0)),l=f.val(t),0>i?0<=l-1?r.data[l-1]:null:0<=l&&l+1=e[0]?null:function(n,t,e,r,i,u){var l,o,s,a,f,c,h,d,m,p=t;"tuple"===r?(l=p[0],p=p[1]):l=p.length;0,c=1,a=m=l-1,f=0,h=1,d=0,C&i&&(c=-c,a=m-a,f=m-f,h=-h,d=m-d);L&i&&(c=-c,a=m-a,f=m-f,h=-h,d=m-d);q&i&&(e=-e);if(0>e)if("tuple"===r){for(o=a;0<=o&&m>=o&&0===n[o];)o-=c;if(0<=o&&m>=o)for(p-=1,n[o]=n[o]-1,s=o+c;0<=s&&m>=s;s+=c)n[s]=p;else n=null}else{for(o=a;0<=o&&m>=o&&0===n[o];)o-=c;if(0<=o&&m>=o)for(n[o]=n[o]-1,s=o+c;0<=s&&m>=s;s+=c)n[s]=p[h*s+d]-1;else n=null}else if("tuple"===r){for(o=a;0<=o&&m>=o&&n[o]+1===p;)o-=c;if(0<=o&&m>=o)for(n[o]=n[o]+1,s=o+c;0<=s&&m>=s;s+=c)n[s]=0;else n=null}else{for(o=a;0<=o&&m>=o&&n[o]+1===p[h*o+d];)o-=c;if(0<=o&&m>=o)for(n[o]=n[o]+1,s=o+c;0<=s&&m>=s;s+=c)n[s]=0;else n=null}return n}(n,e,i,s,a)},rand:function(n,t){var e,r=o.Math.rndInt,i=t&&t.type?t.type:"tensor";return"partial"===i?e=t.data&&t.data.length?t.data[r(0,t.data.length-1)]:null:(e="tuple"===i?n[0]?X(n[0],function(t){return r(0,n[1]-1)}):[]:n.length?X(n.length,function(t){return r(0,n[t]-1)}):[],e=this.DUAL(e,n,t)),e},randu:t.rand,rank:function(n,t,e){var r,i,u=o.Arithmetic,l=e&&null!=e.order?e.order:E,s=e&&e.type?e.type:"tensor",a=u.add,f=u.sub,c=u.mul,h=u.O,d=u.J;if("partial"===s)h=u.N(kn(e.data,n,!0));else if(n=this.DUAL(n,t,e),"tuple"===s){if(!(r=t[0]))return d;for(t=t[1],i=0;i=0;u--)l=m(r,i),r=p(r,i),s[u]=g(l)}else{if(!(a=t.length))return[];for(s=new Array(a),r=n,u=a-1;u>=0;u--)l=m(r,i=t[u]),r=p(r,i),s[u]=g(l)}s=this.DUAL(s,t,e)}return s},fusion:t.fusion,output:t.output,gray:function(n,t){return G(new Array(n.length),n,t)},product:_n,directsum:function(){var n,t,e=arguments,r=e.length,i=0;for(t=0;t=n+e[t].length&&(n+=e[t++].length),n+e[t][r-n]})},component:function(n,t){return null==n?null:null==t?n:X(n.length,function(e){return eu[1]?vn(n,X(u[0]-u[1]+1,u[1],1).filter(k)).reverse():vn(n,X(u[1]-u[0]+1,u[0],1).filter(k)):vn(n,u[1].split(",").map(Number).filter(k))).length){q=!0;break}t.push(s)}else if(u=l.match(_)){if(!(s=0u[1]?X(u[0]-u[1]+1,u[0],-1):X(u[1]-u[0]+1,u[0],1)).filter(k):u[1].split(",").map(Number).filter(k)).length){q=!0;break}t.push(s)}else{if(f=-1,c=null,h=null,l=l.replace(g,function(n,t){return null===c&&(f=parseInt(t,10),c="v"+String(f)),c}),!k(f)){e&&e.splice(a--,1);continue}try{h=new Function(c,"return Math.floor("+l+");")}catch(n){h=null}if(!j(h)){e&&e.splice(a--,1);continue}C[f]?C[f].push(h):C[f]=[h],0>e.indexOf(f)&&E.push(f),L.push([h,null,null,f,e[a]]),t.push(L[L.length-1])}else if(U(l)){if(!(s=!1===l[0]?vn(n,l.slice(1).filter(k)):l.slice(1).filter(k)).length){q=!0;break}t.push(s)}if(q&&(t=[]),E.length)for(o=0,x=E.length;ot||t>p)return!1;return!0})).length){q=!0;break}t[u[1]]=s}return q?[]:(r="="===r?A:"!="===r||"<>"===r?w:"<"===r?O:"<="===r||"=<"===r?S:">"===r?M:(">="===r||"=>"===r)&&I,d=j(i.extra_conditions)?function(n,t,u){var l=n[t];return!(m>l||l>p||O===r&&e[t]>l||M===r&&e[e.length-1]-e[t]>l)&&i.extra_conditions(n,t,u)}:function(n,t,i){var u=n[t];return!(m>u||u>p||O===r&&e[t]>u||M===r&&e[e.length-1]-e[t]>u)},!0===i.lazy?t:bn(t,r,d))}}}),o.Permutation=x(t,{constructor:function n(e,r){var i=null;if(!(this instanceof n))return new n(e,r);(r=r||{}).type=String(r.type||"permutation").toLowerCase(),(e=e||0)instanceof t?e=(i=e).dimension():i=r.sub,r.base=r.dimension=e,r.rand=r.rand||{},r.rand.derangement=1,r.rand.involution=1,r.rand.connected=1,"multiset"===r.type&&(r.multiplicity=U(r.multiplicity)&&r.multiplicity.length?r.multiplicity.slice():X(e,1,0),r.multiplicity=r.multiplicity.concat(X(e-T(rn,0,r.multiplicity),1,0)),r.base=r.multiplicity.length,r.multiset=Mn(r.multiplicity,e)),t.call(this,"Permutation",e,r,i?{method:r.submethod,iter:i,pos:r.subpos,cascade:r.subcascade}:null)},__static__:{C:t.C,P:t.P,T:t.T,DUAL:t.DUAL,count:function(n,t){var e=o.Arithmetic,r=e.O,i=o.Math.factorial,u=o.Math.stirling,l=t&&t.type?t.type:"permutation",s=t&&null!=t["cycles="]?0|t["cycles="]:null,a=t&&null!=t["fixed="]?0|t["fixed="]:null;return 0>n?r:"cyclic"===l?e.N(n):"multiset"===l?i(n,t.multiplicity):"derangement"===l?a?2>n-a?r:e.mul(i(n,a),i(n-a,!1)):2>n?r:i(n,!1):"involution"===l?i(n,!0):"connected"===l?i(n-1):s?u(n,s,1):i(n)},initial:function(n,t,e){var r,i=t&&t.type?t.type:"permutation",u=t&&null!=-t.order?t.order:E,l=t&&null!=t["cycles="]?0|t["cycles="]:null,o=t&&null!=t["fixed="]?0|t["fixed="]:null;if(0===n)return[];if(e=-1===e?-1:1,(!(C&u)&&q&u||C&u&&!(q&u))&&(e=-e),"cyclic"===i)r=0>e?[n-1].concat(X(n-1,0,1)):X(n,0,1);else if("derangement"===i){if(o||2>n)return null;if(1&n){var a=s.floor(n/2);r=0>e?X(n-a-1,n-1,-1).concat([a-1,a]).concat(X(a-1,a-2,-1)):X(n-3,function(n){return 1&n?n-1:n+1}).concat([n-2,n-1,n-3])}else r=0>e?X(n,n-1,-1):X(n,function(n){return 1&n?n-1:n+1})}else r="multiset"===i?0>e?t.multiset.slice().reverse():t.multiset.slice():"connected"===i?null:"involution"===i?0>e?X(n,n-1,-1):X(n,0,1):l?null:0>e?X(n,n-1,-1):X(n,0,1);return r=this.DUAL(r,n,t)},succ:function(n,t,e,r,i,u){if(!e||0>=e||null==n)return null;var l=r&&r.type?r.type:"permutation",o=r&&null!=r["cycles="]?0|r["cycles="]:null,s=r&&null!=r["fixed="]?0|r["fixed="]:null;return"derangement"===l&&s||"permutation"===l&&o?null:function(n,t,e,r,i,u,l){var o,s,a,f,c,h,d,m,p,g,_,b,v,y=t,x=null==u?y:u;0,m=1,d=v=y-1,p=1,g=0,_=1,b=0,C&i&&(m=-m,d=v-d,p=-p,g=x-1-g,e=-e);L&i&&(m=-m,d=v-d,_=-1,b=x-1);q&i&&(e=-e);if(0>e)if("cyclic"===r)if(p*n[o=v-d]+g>0)for(_=y-1,m=y+m,a=0;a0&&p*n[o]<=p*n[s];)s-=m;for(c=n[o],n[o]=n[s],n[s]=c,a=o+m,f=d;0<=a&&a<=v&&0<=f&&f<=v&&m*(f-a)>0;)c=n[a],n[a]=n[f],n[f]=c,h=h||_*a+b===n[a]||_*f+b===n[f],a+=m,f-=m;if("derangement"===r)for(0<=s&&s<=v&&(h=h||_*s+b===n[s]),0<=f&&f<=v&&(h=h||_*f+b===n[f]),h=h||_*o+b===n[o],a=o-m;!h&&0<=a&&a<=v;a-=m)h=_*a+b===n[a];else h=!1}else n=null}while(n&&h);else if("cyclic"===r)if(p*n[o=v-d]+g=p*n[o+m];)o-=m;if(0<=o&&o<=v){for(s=d;0<=s&&s<=v&&m*(s-o)>0&&p*n[o]>=p*n[s];)s-=m;for(c=n[o],n[o]=n[s],n[s]=c,a=o+m,f=d;0<=a&&a<=v&&0<=f&&f<=v&&m*(f-a)>0;)c=n[a],n[a]=n[f],n[f]=c,h=h||_*a+b===n[a]||_*f+b===n[f],a+=m,f-=m;if("derangement"===r)for(0<=s&&s<=v&&(h=h||_*s+b===n[s]),0<=f&&f<=v&&(h=h||_*f+b===n[f]),h=h||_*o+b===n[o],a=o-m;!h&&0<=a&&a<=v;a-=m)h=_*a+b===n[a];else h=!1}else n=null}while(n&&h);return n}(n,e,i=-1===i?-1:1,l,r&&null!=r.order?r.order:E,r&&null!=r.base?r.base:null)},rand:function(n,t){var e,r=o.Math.rndInt,i=t&&t.type?t.type:"permutation",u=t&&null!=t["cycles="]?0|t["cycles="]:null,l=t&&null!=t["fixed="]?0|t["fixed="]:null;if(0===n)return[];if("cyclic"===i){var s=r(0,n-1);e=0b&&(m=A[d=r(0,y-1)],--y,g=A[d],A[d]=A[y],A[y]=g,g=e[m],e[m]=e[h],e[h]=g)}else if("multiset"===i)e=tn(t.multiset.slice());else if("connected"===i)e=tn(X(n,0,1),!0);else{if(u)return null;e=tn(X(n,0,1))}return e=this.DUAL(e,n,t)},randu:t.rand,rank:function(n,t,e){var r,i,u,l,s,a=o.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:E),d=a.sub,m=a.add,p=a.mul,g=a.div,_=a.O,b=a.I,v=a.J;if(!(t=t||n.length))return _;if(n=this.DUAL(n,t,e),"cyclic"===f)_=a.NUM(n[0]);else{if("derangement"===f||"involution"===f||"connected"===f)return R();if("multiset"===f)for(s=e.multiplicity.slice(),l=e&&null!=e.count?e.count:o.Math.factorial(t,s),u=t-1,r=0;r=0;u--)a=g(i,s=t-u),i=_(i,s),r[u]=y(a);qn(r,r)}}return r=this.DUAL(r,t,e)},fusion:t.fusion,output:t.output,permute:Cn,shuffle:function(n,t){if("cyclic"===t){var e=n.length,r=o.Math.rndInt(0,e-1);return 0=t+r&&(t+=r,r=n[++e].length),t+n[e][i-t]})}(U(arguments[0])&&U(arguments[0][0])?arguments[0]:c.call(arguments)):null},cycles:function(n,t){return-1===t?cycles2permutation(n):En(n)},swaps:function(n,t){return-1===t?function(n,t){var e,r,i,u=n.length,l=new Array(t);for(e=0;e=l&&(i=0,r++);else for(r=0,i=0;r=l&&(i=0,r++);return n}(null,n,t):function(n,t,e){var r,i,u=t.length,l=u*u;for(n=n||new Array(l),r=0,i=0;r=u&&(i=0,r+=u);if(!0===e)for(r=0;r(r=n[e])||r>=t||0t)return!1;return!0!==e||r===t},is_involution:function(n){for(var t=n.length,e=0,r=n[e];er||t<=r||n[r]!==e)return!1;return!0},is_kthroot:function(n,t){if(1>(t=t||1))return!1;var e,r,i,u=n.length;for(e=0;e=t||0e&&(e=i),e<=r)return!1;return!0},is_kcycle:function(n,t,e,r){if(!n.length||0>=t)return!1;r=!1!==r;var i,u,l,o,s,a=n.length;for(i=0,l=0,s=0,o=new Array(a);s="===e?l>=t:l===t}},_update:function(){return this.item__=(this.__item,this.n,this.$.order,this.$.type,null),this}}),(e=o.Combination=x(t,{constructor:function n(e,r,i){var u=null;if(!(this instanceof n))return new n(e,r,i);if(U(e)?(i=r||{},r=e[1]||0,e=e[0]||0):(i=i||{},e=e||0,r=r||0),i.type=String(i.type||"combination").toLowerCase(),-1e?n[0]-1:0,0):"ordered"===i||"variation"===i?0>e?X(n[1],n[0]-1,-1):X(n[1],0,1):X(n[1],0>e?n[0]-n[1]:0,1),r=this.DUAL(r,n,t))},succ:function(n,t,e,r,i,u){return!e||!e[0]||0>=e[0]||0===e[1]||null==n?null:function(n,t,e,r,i,u){var l,o,s,a,f,c,h,d,m,p,g,_,b,v=t[1],y=t[0];0,c=1,f=h=v-1,d=1,m=0,p=1,g=0,C&i&&(d=-d,m=y-1-m,c=-c,f=h-f,p=-p,g=h-g);L&i&&(c=-c,f=h-f,p=-p,g=h-g);q&i&&(e=-e);if(0>e)if("ordered+repeated"===r||"variation+repeated"===r||"repeated+variation"===r){for(l=f;0<=l&&l<=h&&0===n[l];)l-=c;if(0<=l&&l<=h)for(y-=1,n[l]=n[l]-1,o=l+c;0<=o&&o<=h;o+=c)n[o]=y;else n=null}else if("ordered"===r||"variation"===r){for(null==u&&(u=$n(n,y,v,i,r)),l=f,s=-1;-1===s&&0<=l&&l<=h;){if(d*n[l]+m-d>=0)for(o=d*n[l]+m-d;0<=o&&o(c=-c)?0:h,!b&&n[o]+1>v||b&&n[o]>0){if(b)for(;0<=l&&l<=h&&0===n[l];)l+=c;else for(;0<=l&&l<=h&&p*l+g===n[l];)l+=c;for(n[l]-=1,l-=c;0<=l&&l<=h;)n[l]=n[l+c]-_,l-=c}else n=null;else{for(s=-1,l=f;0<=l-c&&l-c<=h;l-=c)if(n[l]>n[l-c]+_){s=l;break}if(!(0<=s&&s<=h)&&0c?h:0]&&(s=0>c?h:0),0<=s&&s<=h){for(a=y-1+_,l=f;0<=l&&l<=h&&0=0;a--)s=g(l,t),l=p(l,t),r[a]=y(s);else if("ordered"===A||"variation"===A){for(l=n,a=x-1;a>=0;a--)s=g(l,u=t-a),l=p(l,u),r[a]=y(s);qn(r,r,u)}else{u=(f="repeated"===A||"combination+repeated"===A)?t+x-1:t,n=m(m(i=e&&e.count?e.count:o.Math.factorial(u,x),d),n),i=p(_(i,u-x),u),s=u-x+1,l=x,a=u-1;do{b(i,n)?(r[x-l]=f?u-s-x+1:u-s-l+1,v(i,h)&&(n=m(n,i),i=p(_(i,l),a)),l--,a--):(i=p(_(i,a-l),a),s--,a--)}while(l>0)}return r=this.DUAL(r,t,e)},fusion:t.fusion,output:t.output,complement:function(n,t,e){return!0===e?tn(vn(t,n,!0)):vn(t,n)},binary:function(n,t,e){return-1===e?xn(n,t):yn(n,t)},pick:function(n,t,e){return 0e&&T(function(n,t){r[t]=t},null,null,0,n,1):0>e&&(r[0]=n-1,r[n]=1),r=this.DUAL(r,n,t,1)},succ:function(n,e,r,i,u,l){return null==n?null:i&&"binary"===i.type?t.succ.call(this,n,e,r,i,u):function(n,t,e,r){var i,u,l,o,s,a,f=t,c=t-1;if(o=1,1,0,C&r)return null;L&r&&(o=-o);q&r&&(e=-e);0>o?(i=t-(n[f]||1),s=u=t-1,a=i):(i=0,u=n[f]-1,s=i,a=u);0>e?00?1===n[f]||l>n[a-o]+1?(n[a]-=1,n[a+o]=c,n[f]++):n[f]--:n[f]=0:n=null:0===n[f]?(n[i]=0,n[f]=1):1*n[s]+0=0;u--)r(0,1)&&(i={len:i?i.len+1:1,k:u,next:i});return e=(e=i?X(i.len,function(n){var t=i.k;return i=i.next,t}):[]).concat(e.length=n||a&&o&&(a+o>n+1||a*on||o&&o>n?null:(e=-1===e?-1:1,(!(C&f)&&q&f||C&f&&!(q&f))&&(e=-e),(r=new Array(c+1))[c]=0,a&&o?(r[c]=a,1===a&&(r[0]=o),h?(r=T(function(n,t,e){return n[e]=t,n},r,[(n-o)%(u=s.min(o,s.ceil((n-o)/(a-1))))||u].concat(X(a-2,u,0)).concat([o])),0>e&&B(r,r,0,0,a-1)):0>e?(a-=i=s.min(a,s.floor(n/o)||1),0===(n-=i*o)&&0e&&B(r,r,0,0,a-1)):(i=n%(u=s.ceil(n/a))||u,r=T(function(n,t,e){return n[e]=t,n},r,0>e?[n-a+1].concat(X(a-1,1,0)):X(a-1,u,0).concat([i])))):o?(i=s.floor(n/o),u=n%o,r=T(function(n,t,e){return n[e]=t,n[c]++,n},r,h?0>e?X(i,o,0).concat(u?[u]:[]):X(n-o,1,0).concat([o]):0>e?X(i,o,0).concat(u?[u]:[]):[o].concat(X(n-o,1,0)))):r=T(function(n,t,e){return n[e]=t,n[c]++,n},r,0>e?[n]:X(n,1,0)),r=this.DUAL(r,n,t,1))},succ:function(n,t,e,r,i,u){if(null==e||null==n)return null;var l=r&&r.type?r.type:"partition",o=r&&r["max="]?0|r["max="]:null,a=r&&r["parts="]?0|r["parts="]:null;return 0>=e||a&&o&&(a+o>e+1||a*oe||o&&o>e?null:(i=-1===i?-1:1,"composition"===l?function(n,t,e,r,i,u,l){var o,s,a,f,c,h,d,m,p=t,g=r||(i?p-i+1:p);h=1,L&u&&(h=-h);q&u&&(e=-e);0>h?(d=g-(n[g]||1),s=m=g-1,a=d):(d=0,m=n[g]-1,s=d,a=m);if(0>e)if(r)if(i)n=null;else if(C&u)if(f=n[s],p-r+1>f){for(n[s]=1,o=s+h;d<=o&&o<=m&&1===n[o];)o+=h;n[o]--,d<=o-h&&o-h<=m&&(n[o-h]=1+f)}else n=null;else if(f=n[a],p-r+1>f){for(n[a]=1,o=a;d<=o&&o<=m&&1===n[o];)o-=h;n[o]--,d<=o+h&&o+h<=m&&(n[o+h]=1+f)}else n=null;else if(i)n=null;else if(C&u)n=null;else if(p>n[g]){for(o=a,c=0;d<=o&&o<=m&&1===n[o];)o-=h,c++;if(f=n[o]-1,n[o]=f,0<++c)if(d<=o+h&&o+h<=m)n[o+=h]=c,c=0,n[g]=0>h?g-o:o+1;else for(;0n[a]){for(o=s;d<=o&&o<=m&&1===n[o];)o+=h;f=n[o],n[o]=1,n[s]=f-1,d<=o+h&&o+h<=m&&n[o+h]++}else n=null;else if(p-r+1>n[s]){for(o=a;d<=o&&o<=m&&1===n[o];)o-=h;f=n[o],n[o]=1,n[a]=f-1,d<=o-h&&o-h<=m&&n[o-h]++}else n=null;else if(i)n=null;else if(C&u)n=null;else if(p>n[s])for(c=n[a],n[a-h]++,n[g]--,o=a-h,c--;0p?(g=v-(n[v]||1),f=_=v-1,c=g):(g=0,_=n[v]-1,f=g,c=_);if(0>e)if(r)n=null;else if(C&u)n=null;else if(g<=(a=i?f+p:f)&&a<=_&&n[a]>1){for(o=c,m=0;g<=o&&o<=_&&p*(o-a)>=0&&1===n[o];)m+=n[o],o-=p;if(d=n[o]-1,m++,n[o]=d,n[v]=0>p?v-o:o+1,dh||n[f+(h-1)*p]0&&n[o]===n[o-p];)m+=n[o],o-=p;for(n[o]++,m--,n[v]=0>p?v-o:o+1;0=n||h&&c&&(h+c>n+1||h*cn||c&&c>n)return null;if(h&&c)return null;if(c&&!h&&(h=c,_=!0),h)1===h?(r=[n],m=n):n===h?(r=X(h,1,0),m=n):(e={},i=n-2,X(r=Z(X(h-1,function(){for(l=a(0,i);1===e[l];)l=(l+1)%(i+1);return e[l]=1,l+1})),function(n){return l=r[n],u=l-d,d=l,m+=u,u}));else{for(e=null,l=1;l(r=n[0].indexOf(i))||0(r=n[0].indexOf(i))||0>>1,c=new Array(u);for(t=0;tu||t!==c[r-1][0]||0!==c[r-1][1])return!1;if(l=r,c[(r=n[0][t])-1]||(c[r-1]=[0,t]),r<1||r>u||0!==c[r-1][0]||t!==c[r-1][1])return!1;for(o=r,s+=n[t][t],a+=n[t][i-1-t],e=1;eu||t!==c[r-1][0]||e!==c[r-1][1])return!1;if(l+=r,c[(r=n[e][t])-1]||(c[r-1]=[e,t]),r<1||r>u||e!==c[r-1][0]||t!==c[r-1][1])return!1;o+=r}if(l!==f||o!==f)return!1}return s===f&&a===f},make:function n(t){if(0>=t||2===t)return null;if(1===t)return[[1]];var e,r,i,u,l,o,s,a,f,c,h,d,m,p,g,_=1&t,b=0==(3&t),v=t*t,y=t-_>>>1;for(g=new Array(t),e=0;e=t&&(e++,r=0),g[e][r]=(m+r-e)%t*t+(p+e+r)%t+1;else if(b)for(i=0,e=0,r=0;i=t&&(e++,r=0),g[e][r]=(e+1&3)>>>1==(r+1&3)>>>1?v-i:i+1;else{for(u=n(y),f=(a=(s=o=y*y)<<1)+o,i=0,e=0,r=0;i=y&&(e++,r=0),l=u[e][r],g[e][r]=l,g[e+y][r+y]=l+s,g[e+y][r]=l+a,g[e][r+y]=l+f;for(h=c=y>>>1,r=0;rt-h||e===c&&r===c)||0===e&&r===c||(d=g[e][r],g[e][r]=g[e][r+y],g[e][r+y]=d)}return g},product:function(){if(1>=arguments.length)return arguments[0];for(var n,t,e,r,i,u,l,o,s,a,f,c,h,d=arguments,m=d.length,p=d[0],g=1;g=i&&(h=0,++f>=i&&(s+=i,f=0,h=0,++c>=r&&(a++,o+=i,c=0,s=0,f=0,h=0),a",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() -[ 1, 5, 4, 0, 2, 3 ] +[ 1, 5, 0, 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)) @@ -96,5 +96,5 @@ o.rewind(-1) [ 0, 1, 2, 6, 5, 4, 3 ] [ 0, 1, 2, 5, 4, 3, 6 ] o.random() -[ 0, 1, 2, 6, 5, 4, 3 ] +[ 0, 1, 2, 5, 4, 3, 6 ] o.dispose() diff --git a/test/conditional_permutations_boolean.js b/test/conditional_permutations_boolean.js index bd152a8..9898ed9 100644 --- a/test/conditional_permutations_boolean.js +++ b/test/conditional_permutations_boolean.js @@ -57,3 +57,34 @@ echo('o.dispose()'); o.dispose(); +// Combinations w/ Partial Conditions = (n-c,k-c)-Combinations completed w/ c-Conditional values +echo('6,4-Combinations where values in 0th position ARE (0,1) and in 1st position [0]+1') +echo('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("<"))'); +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("<")); + +echo('o.dimension()'); +echo(o.dimension()); + +echo('o.total()'); +echo(o.total()); + +echo('default order is "lex", lexicographic-order'); +echo('o.rewind()'); +print_all( o.rewind()); + +echo('backwards'); +echo('o.rewind(-1)'); +print_all( o.rewind(-1), -1 ); + +echo('o.order("revlex|revlex")'); +print_all( o.order("revlex|revlex") ); + +echo('o.random()'); +echo(o.random()); + + +// dispose +echo('o.dispose()'); +o.dispose(); + + diff --git a/test/conditional_permutations_boolean.txt b/test/conditional_permutations_boolean.txt index 2569ab7..91f4e1b 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.2) +Abacus Algebraic Composition: Permutations w/ Partial Conditions (VERSION = 0.9.3) --- 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,5 +449,46 @@ o.rewind(-1) [ 0, 1, 3, 4, 2, 5 ] [ 0, 2, 3, 4, 1, 5 ] o.random() -[ 0, 4, 5, 3, 1, 2 ] +[ 1, 3, 2, 5, 0, 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("<")) +o.dimension() +4 +o.total() +12 +default order is "lex", lexicographic-order +o.rewind() +[ 0, 1, 2, 3 ] +[ 0, 1, 2, 4 ] +[ 0, 1, 2, 5 ] +[ 0, 1, 3, 4 ] +[ 1, 2, 3, 4 ] +[ 0, 1, 3, 5 ] +[ 1, 2, 3, 5 ] +[ 0, 1, 4, 5 ] +[ 1, 2, 4, 5 ] +backwards +o.rewind(-1) +[ 1, 2, 4, 5 ] +[ 0, 1, 4, 5 ] +[ 1, 2, 3, 5 ] +[ 0, 1, 3, 5 ] +[ 1, 2, 3, 4 ] +[ 0, 1, 3, 4 ] +[ 0, 1, 2, 5 ] +[ 0, 1, 2, 4 ] +[ 0, 1, 2, 3 ] +o.order("revlex|revlex") +[ 1, 2, 4, 5 ] +[ 0, 1, 4, 5 ] +[ 1, 2, 3, 5 ] +[ 0, 1, 3, 5 ] +[ 1, 2, 3, 4 ] +[ 0, 1, 3, 4 ] +[ 0, 1, 2, 5 ] +[ 0, 1, 2, 4 ] +[ 0, 1, 2, 3 ] +o.random() +[ 0, 1, 3, 5 ] o.dispose() diff --git a/test/connected_permutations.txt b/test/connected_permutations.txt index 603c146..b4342c9 100644 --- a/test/connected_permutations.txt +++ b/test/connected_permutations.txt @@ -1,4 +1,4 @@ -Abacus.Permutations (VERSION = 0.9.2) +Abacus.Permutations (VERSION = 0.9.3) --- o = Abacus.Permutation(2,{type:"connected"}) o.total() @@ -9,19 +9,19 @@ o = Abacus.Permutation(3,{type:"connected"}) o.total() 2 o.random() -[ 2, 0, 1 ] +[ 1, 2, 0 ] o = Abacus.Permutation(4,{type:"connected"}) o.total() 6 o.random() -[ 3, 2, 0, 1 ] +[ 1, 2, 3, 0 ] o = Abacus.Permutation(5,{type:"connected"}) o.total() 24 o.random() -[ 1, 2, 4, 0, 3 ] +[ 2, 4, 1, 0, 3 ] o = Abacus.Permutation(6,{type:"connected"}) o.total() 120 o.random() -[ 4, 0, 3, 1, 5, 2 ] +[ 4, 0, 5, 1, 2, 3 ] diff --git a/test/cyclic_permutations.txt b/test/cyclic_permutations.txt index 7d85183..aa051dd 100644 --- a/test/cyclic_permutations.txt +++ b/test/cyclic_permutations.txt @@ -1,4 +1,4 @@ -Abacus.Permutations (VERSION = 0.9.2) +Abacus.Permutations (VERSION = 0.9.3) --- 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") -[ 3, 0, 1, 2 ] -[ 2, 3, 0, 1 ] [ 0, 1, 2, 3 ] +[ 2, 3, 0, 1 ] [ 1, 2, 3, 0 ] +[ 3, 0, 1, 2 ] o.random() -[ 0, 1, 2, 3 ] +[ 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 f1bf4da..2a1d36d 100644 --- a/test/derangements.txt +++ b/test/derangements.txt @@ -1,4 +1,4 @@ -Abacus.Permutations (VERSION = 0.9.2) +Abacus.Permutations (VERSION = 0.9.3) --- o = Abacus.Permutation(2,{type:"derangement"}) o.total() @@ -53,7 +53,7 @@ o.order("random") [ 2, 0, 1 ] [ 2, 0, 1 ] o.random() -[ 1, 2, 0 ] +[ 2, 0, 1 ] o = Abacus.Permutation(4,{type:"derangement"}) o.total() 9 @@ -130,17 +130,17 @@ o.order("colex,reversed") [ 2, 3, 1, 0 ] [ 3, 2, 1, 0 ] o.order("random") -[ 1, 0, 3, 2 ] [ 2, 0, 3, 1 ] -[ 1, 3, 0, 2 ] -[ 2, 3, 0, 1 ] -[ 3, 2, 1, 0 ] +[ 3, 2, 0, 1 ] [ 2, 0, 3, 1 ] [ 3, 0, 1, 2 ] -[ 2, 3, 1, 0 ] +[ 3, 2, 1, 0 ] +[ 2, 0, 3, 1 ] [ 2, 0, 3, 1 ] -o.random() [ 3, 2, 0, 1 ] +[ 2, 3, 1, 0 ] +o.random() +[ 2, 0, 3, 1 ] o = Abacus.Permutation(5,{type:"derangement"}) o.total() 44 @@ -462,52 +462,52 @@ o.order("colex,reversed") [ 2, 4, 3, 1, 0 ] [ 4, 2, 3, 1, 0 ] o.order("random") -[ 1, 2, 4, 0, 3 ] -[ 3, 2, 1, 4, 0 ] -[ 1, 3, 4, 2, 0 ] -[ 3, 0, 4, 2, 1 ] -[ 4, 3, 0, 2, 1 ] -[ 3, 4, 0, 1, 2 ] -[ 1, 2, 3, 4, 0 ] -[ 2, 3, 1, 4, 0 ] -[ 1, 3, 0, 4, 2 ] -[ 4, 2, 1, 0, 3 ] +[ 3, 2, 4, 1, 0 ] +[ 2, 0, 3, 4, 1 ] [ 4, 0, 1, 2, 3 ] -[ 2, 3, 0, 4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 2, 4, 0, 1 ] -[ 3, 0, 1, 4, 2 ] -[ 3, 4, 1, 0, 2 ] -[ 1, 2, 4, 0, 3 ] -[ 4, 0, 1, 2, 3 ] -[ 2, 0, 3, 4, 1 ] [ 2, 0, 3, 4, 1 ] -[ 1, 0, 4, 2, 3 ] -[ 4, 2, 3, 0, 1 ] -[ 4, 3, 1, 2, 0 ] -o.random() +[ 3, 0, 4, 2, 1 ] +[ 2, 3, 4, 0, 1 ] [ 1, 0, 3, 4, 2 ] +o.random() +[ 2, 4, 0, 1, 3 ] 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() -[ 6, 3, 4, 2, 5, 1, 0 ] +[ 5, 6, 3, 1, 0, 2, 4 ] o.dispose() diff --git a/test/filtered.js b/test/filtered.js index 5bba5e2..8abba00 100644 --- a/test/filtered.js +++ b/test/filtered.js @@ -26,7 +26,7 @@ echo('Get all Permutations filtered from all possible Tuples (an inefficient way echo('o = Abacus.Tensor(3,3,{"type":"tuple"}).filterBy(Abacus.Filter.UNIQUE())'); o = Abacus.Tensor(3,3,{"type":"tuple"}).filterBy(Abacus.Filter.UNIQUE()); -echo('o.total() /* with filtering applied .total() and some other functions are in general not accurate */'); +echo('o.total() /* with filtering applied .total() and some other functions still return original data not the filtered ones */'); echo(o.total()); echo('default order is "lex", lexicographic-order'); @@ -41,10 +41,10 @@ o.dispose(); echo("\n"); echo('Get all Combinations filtered from all possible Tuples (an inefficient way to generate combinations)'); -echo('o = Abacus.Tensor(3,6,{"type":"tuple"}).filterBy(Abacus.Filter.SORTED(1,true))'); -o = Abacus.Tensor(3,6,{"type":"tuple"}).filterBy(Abacus.Filter.SORTED(1,true)); +echo('o = Abacus.Tensor(3,6,{"type":"tuple"}).filterBy(Abacus.Filter.SORTED("<"))'); +o = Abacus.Tensor(3,6,{"type":"tuple"}).filterBy(Abacus.Filter.SORTED("<")); -echo('o.total() /* with filtering applied .total() and some other functions are in general not accurate */'); +echo('o.total() /* with filtering applied .total() and some other functions still return original data not the filtered ones */'); echo(o.total()); echo('default order is "lex", lexicographic-order'); @@ -62,7 +62,7 @@ echo('Get all Combinations filtered from all possible Subsets (an inefficient wa echo('o = Abacus.Subset(6).filterBy(Abacus.Filter.LEN(3))'); o = Abacus.Subset(6).filterBy(Abacus.Filter.LEN(3)); -echo('o.total() /* with filtering applied .total() and some other functions are in general not accurate */'); +echo('o.total() /* with filtering applied .total() and some other functions still return original data not the filtered ones */'); echo(o.total()); echo('default order is "lex", lexicographic-order'); diff --git a/test/filtered.txt b/test/filtered.txt index 2cea344..dcbb52f 100644 --- a/test/filtered.txt +++ b/test/filtered.txt @@ -1,8 +1,8 @@ -Abacus.Combinatorics Filtered Combinatorial Objects (VERSION = 0.9.2) +Abacus.Combinatorics Filtered Combinatorial Objects (VERSION = 0.9.3) --- 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()) -o.total() /* with filtering applied .total() and some other functions are in general not accurate */ +o.total() /* with filtering applied .total() and some other functions still return original data not the filtered ones */ 27 default order is "lex", lexicographic-order [ 0, 1, 2 ] @@ -22,8 +22,8 @@ o.rewind(-1) Get all Combinations filtered from all possible Tuples (an inefficient way to generate combinations) -o = Abacus.Tensor(3,6,{"type":"tuple"}).filterBy(Abacus.Filter.SORTED(1,true)) -o.total() /* with filtering applied .total() and some other functions are in general not accurate */ +o = Abacus.Tensor(3,6,{"type":"tuple"}).filterBy(Abacus.Filter.SORTED("<")) +o.total() /* with filtering applied .total() and some other functions still return original data not the filtered ones */ 216 default order is "lex", lexicographic-order [ 0, 1, 2 ] @@ -72,7 +72,7 @@ o.rewind(-1) Get all Combinations filtered from all possible Subsets (an inefficient way to generate combinations) o = Abacus.Subset(6).filterBy(Abacus.Filter.LEN(3)) -o.total() /* with filtering applied .total() and some other functions are in general not accurate */ +o.total() /* with filtering applied .total() and some other functions still return original data not the filtered ones */ 64 default order is "lex", lexicographic-order [ 0, 1, 2 ] diff --git a/test/filtered_compositions.js b/test/filtered_compositions.js index 4e789ba..922e500 100644 --- a/test/filtered_compositions.js +++ b/test/filtered_compositions.js @@ -26,7 +26,7 @@ echo('---'); echo('o = Abacus.Partition(10,{type:"composition"}).filterBy(Abacus.Filter.UNIQUE())'); o = Abacus.Partition(10,{type:"composition"}).filterBy(Abacus.Filter.UNIQUE()); -echo('o.total() /* with filtering applied .total() and some other functions are in general not accurate */'); +echo('o.total() /* with filtering applied .total() and some other functions still return original data not the filtered ones */'); echo(o.total()); echo('default order is "lex", lexicographic-order'); @@ -61,7 +61,7 @@ o = Abacus.Partition(10,{type:"composition"}).filterBy(function(item){ }); */ -echo('o.total() /* with filtering applied .total() and some other functions are in general not accurate */'); +echo('o.total() /* with filtering applied .total() and some other functions still return original data not the filtered ones */'); echo(o.total()); echo('default order is "lex", lexicographic-order'); diff --git a/test/filtered_compositions.txt b/test/filtered_compositions.txt index f986f42..bd29e77 100644 --- a/test/filtered_compositions.txt +++ b/test/filtered_compositions.txt @@ -1,7 +1,7 @@ -Abacus.Compositions Filtered (VERSION = 0.9.2) +Abacus.Compositions Filtered (VERSION = 0.9.3) --- o = Abacus.Partition(10,{type:"composition"}).filterBy(Abacus.Filter.UNIQUE()) -o.total() /* with filtering applied .total() and some other functions are in general not accurate */ +o.total() /* with filtering applied .total() and some other functions still return original data not the filtered ones */ 512 default order is "lex", lexicographic-order [ 1, 2, 3, 4 ] @@ -121,7 +121,7 @@ o.rewind(-1) [ 1, 2, 4, 3 ] [ 1, 2, 3, 4 ] o = Abacus.Partition(10,{type:"composition"}).filterBy(Abacus.Filter.LEN(4).AND(Abacus.Filter.MAX(3))) -o.total() /* with filtering applied .total() and some other functions are in general not accurate */ +o.total() /* with filtering applied .total() and some other functions still return original data not the filtered ones */ 512 default order is "lex", lexicographic-order [ 1, 3, 3, 3 ] diff --git a/test/filtered_partitions.js b/test/filtered_partitions.js index 34ba943..1ef8b29 100644 --- a/test/filtered_partitions.js +++ b/test/filtered_partitions.js @@ -26,7 +26,7 @@ echo('---'); echo('o = Abacus.Partition(10).filterBy(Abacus.Filter.UNIQUE())'); o = Abacus.Partition(10).filterBy(Abacus.Filter.UNIQUE()); -echo('o.total() /* with filtering applied .total() and some other functions are in general not accurate */'); +echo('o.total() /* with filtering applied .total() and some other functions still return original data not the filtered ones */'); echo(o.total()); echo('default order is "lex", lexicographic-order'); @@ -60,7 +60,7 @@ o = Abacus.Partition(10).filterBy(function(item){ return true; }); */ -echo('o.total() /* with filtering applied .total() and some other functions are in general not accurate */'); +echo('o.total() /* with filtering applied .total() and some other functions still return original data not the filtered ones */'); echo(o.total()); echo('default order is "lex", lexicographic-order'); diff --git a/test/filtered_partitions.txt b/test/filtered_partitions.txt index 7603fe3..44022df 100644 --- a/test/filtered_partitions.txt +++ b/test/filtered_partitions.txt @@ -1,7 +1,7 @@ -Abacus.Partitions Filtered (VERSION = 0.9.2) +Abacus.Partitions Filtered (VERSION = 0.9.3) --- o = Abacus.Partition(10).filterBy(Abacus.Filter.UNIQUE()) -o.total() /* with filtering applied .total() and some other functions are in general not accurate */ +o.total() /* with filtering applied .total() and some other functions still return original data not the filtered ones */ 42 default order is "lex", lexicographic-order [ 4, 3, 2, 1 ] @@ -27,7 +27,7 @@ o.rewind(-1) [ 5, 3, 2 ] [ 4, 3, 2, 1 ] o = Abacus.Partition(10).filterBy(Abacus.Filter.LEN(4).AND(Abacus.Filter.MAX(3))) -o.total() /* with filtering applied .total() and some other functions are in general not accurate */ +o.total() /* with filtering applied .total() and some other functions still return original data not the filtered ones */ 42 default order is "lex", lexicographic-order [ 3, 3, 2, 2 ] diff --git a/test/involutions.js b/test/involutions.js index dcc625e..a341a0b 100644 --- a/test/involutions.js +++ b/test/involutions.js @@ -77,7 +77,7 @@ o.dispose(); echo('o = Abacus.Permutation(5).filterBy(Abacus.Permutation.is_involution)'); o = Abacus.Permutation(5).filterBy(Abacus.Permutation.is_involution); -echo('o.total() /* when filtering is applied .total() and some other functions are in general inaccurate */'); +echo('o.total() /* with filtering applied .total() and some other functions still return original data not the filtered ones */'); echo(o.total()); echo('default order is "lex", lexicographic-order'); @@ -94,7 +94,7 @@ o.dispose(); echo('o = Abacus.Permutation(6).filterBy(Abacus.Permutation.is_involution)'); o = Abacus.Permutation(6).filterBy(Abacus.Permutation.is_involution); -echo('o.total() /* when filtering is applied .total() and some other functions are in general inaccurate */'); +echo('o.total() /* with filtering applied .total() and some other functions still return original data not the filtered ones */'); echo(o.total()); echo('default order is "lex", lexicographic-order'); diff --git a/test/involutions.txt b/test/involutions.txt index e1e2e34..487bee5 100644 --- a/test/involutions.txt +++ b/test/involutions.txt @@ -1,4 +1,4 @@ -Abacus.Permutations (VERSION = 0.9.2) +Abacus.Permutations (VERSION = 0.9.3) --- o = Abacus.Permutation(2,{type:"involution"}) o.total() @@ -8,7 +8,7 @@ o.rewind() [ 0, 1 ] [ 1, 0 ] o.random() -[ 1, 0 ] +[ 0, 1 ] o = Abacus.Permutation(3,{type:"involution"}) o.total() 4 @@ -38,7 +38,7 @@ o.rewind() o.random() [ 2, 3, 0, 1 ] o = Abacus.Permutation(5).filterBy(Abacus.Permutation.is_involution) -o.total() /* when filtering is applied .total() and some other functions are in general inaccurate */ +o.total() /* with filtering applied .total() and some other functions still return original data not the filtered ones */ 120 default order is "lex", lexicographic-order o.rewind() @@ -69,9 +69,9 @@ o.rewind() [ 4, 2, 1, 3, 0 ] [ 4, 3, 2, 1, 0 ] o.random() -[ 2, 3, 0, 1, 4 ] +[ 4, 1, 2, 3, 0 ] o = Abacus.Permutation(6).filterBy(Abacus.Permutation.is_involution) -o.total() /* when filtering is applied .total() and some other functions are in general inaccurate */ +o.total() /* with filtering applied .total() and some other functions still return original data not the filtered ones */ 720 default order is "lex", lexicographic-order o.rewind() @@ -152,4 +152,4 @@ o.rewind() [ 5, 4, 2, 3, 1, 0 ] [ 5, 4, 3, 2, 1, 0 ] o.random() -[ 3, 2, 1, 0, 5, 4 ] +[ 4, 2, 1, 3, 0, 5 ] diff --git a/test/k-derangements.txt b/test/k-derangements.txt index fedd45a..dd6abf8 100644 --- a/test/k-derangements.txt +++ b/test/k-derangements.txt @@ -1,4 +1,4 @@ -Abacus Algebraic Composition: k-Derangements (VERSION = 0.9.2) +Abacus Algebraic Composition: k-Derangements (VERSION = 0.9.3) --- 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() -[ 0, 6, 2, 3, 4, 1, 7, 5 ] +[ 7, 1, 2, 3, 0, 5, 4, 6 ] 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 0d5d877..ec04735 100644 --- a/test/latin_squares.txt +++ b/test/latin_squares.txt @@ -1,4 +1,4 @@ -Abacus.LatinSquares (VERSION = 0.9.2) +Abacus.LatinSquares (VERSION = 0.9.3) --- 1 diff --git a/test/magic_squares.txt b/test/magic_squares.txt index 040c345..6d56484 100644 --- a/test/magic_squares.txt +++ b/test/magic_squares.txt @@ -1,4 +1,4 @@ -Abacus.MagicSquares (VERSION = 0.9.2) +Abacus.MagicSquares (VERSION = 0.9.3) --- 1 diff --git a/test/multiset_permutations.txt b/test/multiset_permutations.txt index d2e5226..a049fca 100644 --- a/test/multiset_permutations.txt +++ b/test/multiset_permutations.txt @@ -1,4 +1,4 @@ -Abacus.Permutations (VERSION = 0.9.2) +Abacus.Permutations (VERSION = 0.9.3) --- o = Abacus.Permutation(6,{type:"multiset",multiplicity:[1,2,2,1]}) o.total() @@ -1279,186 +1279,186 @@ o.order("colex,reversed") [ 2, 3,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 ] +[ 1, 2, 0, 3, 2, 1 ] +[ 2, 0, 3, 2, 1, 1 ] [ 1, 3, 1, 2, 0, 2 ] -[ 3, 2, 1, 2, 0, 1 ] -[ 1, 3, 2, 1, 0, 2 ] -[ 3, 2, 1, 1, 2, 0 ] -[ 3, 2, 1, 1, 0, 2 ] -[ 1, 3, 1, 2, 2, 0 ] -[ 1, 3, 2, 0, 1, 2 ] -[ 1, 3, 2, 0, 2, 1 ] -[ 3, 0, 1, 1, 2, 2 ] +[ 2, 3, 1, 0, 1, 2 ] +[ 2, 1, 3, 1, 2, 0 ] +[ 2, 3, 0, 2, 1, 1 ] +[ 1, 2, 1, 0, 3, 2 ] +[ 1, 2, 0, 2, 3, 1 ] +[ 1, 3, 2, 2, 1, 0 ] +[ 2, 1, 3, 2, 0, 1 ] +[ 2, 2, 0, 3, 1, 1 ] +[ 1, 2, 1, 0, 2, 3 ] +[ 2, 2, 1, 0, 1, 3 ] +[ 1, 2, 1, 2, 0, 3 ] +[ 2, 2, 1, 1, 3, 0 ] +[ 2, 3, 0, 1, 2, 1 ] o.random() -[ 2, 0, 1, 3, 2, 1 ] +[ 3, 1, 1, 2, 0, 2 ] o.dispose() diff --git a/test/ordered_combinations.txt b/test/ordered_combinations.txt index 54dcf22..2aaf51c 100644 --- a/test/ordered_combinations.txt +++ b/test/ordered_combinations.txt @@ -1,4 +1,4 @@ -Abacus.Combinations (VERSION = 0.9.2) +Abacus.Combinations (VERSION = 0.9.3) --- o = Abacus.Combination(6,3,{type:"variation"}) o.total() @@ -859,126 +859,126 @@ o.order("colex,reversed") [ 3, 1, 0 ] [ 2, 1, 0 ] o.order("random") -[ 5, 2, 0 ] -[ 0, 4, 1 ] -[ 3, 5, 0 ] -[ 1, 0, 5 ] -[ 4, 2, 5 ] -[ 2, 3, 5 ] -[ 2, 3, 4 ] -[ 2, 5, 1 ] -[ 3, 4, 1 ] -[ 0, 4, 5 ] -[ 2, 4, 0 ] -[ 5, 4, 0 ] -[ 3, 4, 5 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1, 1 ] -[ 1, 0, 0 ] -[ 0, 0, 1 ] -[ 1, 0, 1 ] -[ 4, 2, 4 ] -[ 2, 4, 4 ] -[ 1, 3, 1 ] -[ 4, 0, 3 ] -[ 4, 0, 4 ] -[ 4, 3, 2 ] -[ 2, 1, 0 ] -[ 1, 3, 2 ] +[ 2, 3, 4 ] +[ 3, 4, 1 ] +[ 2, 4, 1 ] +[ 1, 0, 3 ] +[ 4, 2, 2 ] +[ 0, 3, 4 ] +[ 4, 2, 3 ] +[ 0, 3, 3 ] o.random() -[ 1, 1, 3 ] +[ 4, 2, 1 ] 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 281f16d..0d3681e 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.2) +Abacus Algebraic Composition: Permutations w/ Fixed Partial Data (VERSION = 0.9.3) --- 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() -[ 2, 0, 5, 1, 3, 4 ] +[ 2, 4, 0, 1, 3, 5 ] o.dispose() diff --git a/test/partitions.txt b/test/partitions.txt index d4d5bad..f2a3336 100644 --- a/test/partitions.txt +++ b/test/partitions.txt @@ -1,4 +1,4 @@ -Abacus.Partitions (VERSION = 0.9.2) +Abacus.Partitions (VERSION = 0.9.3) --- o = Abacus.Partition(6) o.total() @@ -66,7 +66,7 @@ o.order("colex,reflected") o.order("colex,reversed") [ 6 ] o.random() -[ 4, 1, 1 ] +[ 1, 1, 1, 1, 1, 1 ] 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() -[ 3, 2, 1, 1, 1 ] +[ 3, 3, 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() -[ [ 4, 2 ], [ 2, 1 ], [ 1, 2 ] ] +[ [ 6, 1 ], [ 3, 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() -[ [ 4, 1 ], [ 3, 2 ], [ 2, 2 ], [ 1, 6 ] ] +[ [ 5, 1 ], [ 2, 3 ], [ 1, 9 ] ] o.dispose() diff --git a/test/permutations-bigint.txt b/test/permutations-bigint.txt index 82d057c..fe55aed 100644 --- a/test/permutations-bigint.txt +++ b/test/permutations-bigint.txt @@ -1,4 +1,4 @@ -Abacus.Permutations (VERSION = 0.9.2) +Abacus.Permutations (VERSION = 0.9.3) --- o = Abacus.Permutation(50) o.dimension() @@ -6,7 +6,7 @@ o.dimension() o.total() 30414093201713378043612608166064768844377641568960512000000000000 o.random() -43,8,30,20,0,44,24,14,26,34,3,37,46,49,9,35,13,11,48,27,45,7,29,15,6,5,28,31,19,38,10,18,22,42,40,41,25,12,23,32,4,2,16,21,17,33,1,36,47,39 +30,44,25,12,6,3,35,39,23,17,31,45,41,22,5,37,13,0,28,20,43,33,46,11,19,42,1,2,26,16,18,4,38,36,24,14,40,47,8,15,21,34,7,48,49,10,27,29,9,32 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 326a875..4187903 100644 --- a/test/permutations.txt +++ b/test/permutations.txt @@ -1,4 +1,4 @@ -Abacus.Permutations (VERSION = 0.9.2) +Abacus.Permutations (VERSION = 0.9.3) --- 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 ] [ 1, 2, 0, 3 ] -[ 3, 1, 0, 2 ] -[ 3, 0, 1, 2 ] -[ 2, 3, 0, 1 ] -[ 2, 0, 1, 3 ] -[ 1, 2, 3, 0 ] -[ 3, 2, 0, 1 ] -[ 1, 3, 0, 2 ] -[ 0, 3, 2, 1 ] -[ 2, 0, 3, 1 ] [ 1, 0, 3, 2 ] -[ 1, 3, 2, 0 ] -[ 0, 2, 1, 3 ] [ 3, 0, 2, 1 ] -[ 3, 1, 2, 0 ] -[ 2, 1, 3, 0 ] +[ 0, 3, 2, 1 ] +[ 2, 1, 0, 3 ] +[ 3, 2, 0, 1 ] +[ 2, 3, 0, 1 ] +[ 1, 0, 2, 3 ] [ 2, 3, 1, 0 ] -[ 0, 3, 1, 2 ] +[ 3, 1, 0, 2 ] [ 3, 2, 1, 0 ] +[ 3, 1, 2, 0 ] +[ 1, 2, 3, 0 ] +[ 3, 0, 1, 2 ] [ 0, 1, 2, 3 ] -[ 0, 1, 3, 2 ] +[ 1, 3, 0, 2 ] +[ 0, 3, 1, 2 ] [ 0, 2, 3, 1 ] -[ 1, 0, 2, 3 ] +[ 0, 2, 1, 3 ] +[ 0, 1, 3, 2 ] +[ 1, 3, 2, 0 ] +[ 2, 0, 3, 1 ] +[ 2, 0, 1, 3 ] o.random() -[ 3, 2, 0, 1 ] +[ 0, 2, 3, 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 e570734..8ae12f1 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.2) +Abacus Algebraic Composition: Permutations OF Combinations (VERSION = 0.9.3) --- o = Abacus.Permutation(Abacus.Combination(6,3)) o.dimension() @@ -256,7 +256,7 @@ o.rewind(-1) [ 0, 2, 1 ] [ 0, 1, 2 ] o.random() -[ 3, 5, 4 ] +[ 3, 2, 4 ] 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 68a1a2d..fa78f7e 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.2) +Abacus Algebraic Composition: Permutations OF Permutations (VERSION = 0.9.3) --- o = Abacus.Permutation(2).multiplyWith(Abacus.Permutation(2)) o.total() @@ -22,7 +22,7 @@ o.rewind(-1) [ 1, 0, 3, 2 ] [ 0, 1, 2, 3 ] o.random() -[ 2, 3, 0, 1 ] +[ 0, 1, 2, 3 ] o.order("lex|lex").range(1,-1) [ 1, 0, 3, 2 ] [ 0, 1, 2, 3 ] diff --git a/test/restricted_compositions.txt b/test/restricted_compositions.txt index a9f0948..75be379 100644 --- a/test/restricted_compositions.txt +++ b/test/restricted_compositions.txt @@ -1,4 +1,4 @@ -Abacus.Compositions (VERSION = 0.9.2) +Abacus.Compositions (VERSION = 0.9.3) --- 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() -[ 1, 2, 4 ] +[ 4, 1, 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, 1, 1 ] +[ 2, 1, 4, 1 ] 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() -[ 1, 1, 3, 2, 1 ] +[ 3, 2, 1, 1, 1 ] 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, 2, 1 ] +[ 3, 1, 2, 3, 4 ] 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() -[ 1, 2, 1, 3 ] +[ 2, 1, 3, 1 ] 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() -[ 1, 2, 1, 4 ] +[ 1, 2, 4, 1 ] o.dispose() diff --git a/test/restricted_partitions.txt b/test/restricted_partitions.txt index 073c85f..6ca5e3e 100644 --- a/test/restricted_partitions.txt +++ b/test/restricted_partitions.txt @@ -1,4 +1,4 @@ -Abacus.Partitions (VERSION = 0.9.2) +Abacus.Partitions (VERSION = 0.9.3) --- o = Abacus.Partition(7,{"max=":4}) 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, 4, 2 ] +[ 5, 3, 2, 1 ] 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, 1, 1, 1, 1 ] +[ 4, 3, 3, 1, 1 ] 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, 2, 2, 2, 2, 2 ] +[ 4, 4, 3, 3, 2, 1 ] o.dispose() o = Abacus.Partition(7,{"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() -[ 5, 3, 1, 1, 1 ] +[ 4, 3, 2, 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() -[ 7, 2, 2, 1 ] +[ 6, 3, 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() -[ 15, 2, 2, 1 ] +[ 9, 6, 3, 2 ] o.dispose() o = Abacus.Partition(12,{"parts=":4,"max=":4}) o.total() diff --git a/test/subsets.txt b/test/subsets.txt index ca5d437..73d17fe 100644 --- a/test/subsets.txt +++ b/test/subsets.txt @@ -1,4 +1,4 @@ -Abacus.Subsets (VERSION = 0.9.2) +Abacus.Subsets (VERSION = 0.9.3) --- o = Abacus.Subset(6) o.total() @@ -343,72 +343,72 @@ o.order("colex,reflected") o.order("colex,reversed") [ 5, 4, 3, 2, 1, 0 ] o.order("random") -[ 0, 1, 2, 5 ] -[ 2, 4 ] -[ 0, 1, 2, 3, 4 ] -[ 0, 2, 3, 4, 5 ] -[ 0, 1, 2, 3 ] -[ 0, 1, 5 ] -[ 0, 1, 2, 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 0 ] +[ 3, 2 ] +[ 5, 3 ] [ 3, 2, 1, 0 ] -[ 2, 1 ] -[ 3, 1, 0 ] -[ 2, 1, 0 ] -[ 3 ] +[ 5, 3, 1 ] +[ 4 ] +[ 5, 3, 2, 1 ] +[ 5, 4, 2 ] +[ 5, 4, 1, 0 ] o.random() -[ 5, 4, 3, 1 ] +[ 2, 1, 0 ] 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 9dc3150..3c1056b 100644 --- a/test/tensors.txt +++ b/test/tensors.txt @@ -1,4 +1,4 @@ -Abacus.Tensors (VERSION = 0.9.2) +Abacus.Tensors (VERSION = 0.9.3) --- 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, 0, 1 ] +[ 0, 0, 2 ] [ 0, 1, 1 ] [ 0, 1, 0 ] -[ 0, 0, 2 ] -[ 0, 1, 2 ] -[ 0, 0, 1 ] [ 0, 0, 0 ] +[ 0, 1, 2 ] o.random() -[ 0, 0, 0 ] +[ 0, 0, 1 ] o.order("colex").range(-5, -1) [ 1, 0, 0 ] [ 2, 0, 0 ] diff --git a/test/tuples.txt b/test/tuples.txt index d882422..6ee4d5f 100644 --- a/test/tuples.txt +++ b/test/tuples.txt @@ -1,4 +1,4 @@ -Abacus.Tuples (VERSION = 0.9.2) +Abacus.Tuples (VERSION = 0.9.3) --- 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, 2, 0 ] -[ 0, 0, 2 ] -[ 1, 2, 1 ] -[ 1, 2, 0 ] -[ 2, 2, 0 ] +[ 1, 1, 0 ] +[ 0, 1, 0 ] [ 1, 1, 1 ] +[ 2, 2, 0 ] +[ 2, 1, 2 ] [ 2, 0, 2 ] -[ 0, 2, 1 ] -[ 1, 0, 2 ] -[ 0, 1, 0 ] +[ 1, 1, 2 ] +[ 0, 1, 1 ] +[ 2, 1, 1 ] +[ 1, 2, 1 ] [ 2, 2, 2 ] [ 2, 0, 0 ] -[ 1, 1, 0 ] -[ 1, 0, 1 ] -[ 0, 1, 1 ] -[ 0, 2, 2 ] [ 0, 1, 2 ] -[ 1, 1, 2 ] -[ 2, 1, 1 ] [ 2, 1, 0 ] -[ 2, 1, 2 ] -[ 1, 2, 2 ] +[ 0, 2, 1 ] +[ 2, 2, 1 ] +[ 1, 0, 2 ] +[ 1, 0, 1 ] [ 2, 0, 1 ] -[ 1, 0, 0 ] [ 0, 0, 0 ] +[ 0, 0, 2 ] +[ 0, 2, 0 ] [ 0, 0, 1 ] -[ 2, 2, 1 ] +[ 1, 2, 0 ] +[ 1, 0, 0 ] +[ 1, 2, 2 ] +[ 0, 2, 2 ] o.random() -[ 1, 2, 1 ] +[ 1, 0, 0 ] o.order("colex").range(-5, -1) [ 1, 0, 1 ] [ 2, 2, 1 ]