Skip to content

Commit c6abf5f

Browse files
committed
v.1.0.5
* update examplea and tests
1 parent ca5a829 commit c6abf5f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+38629
-11053
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ o.dispose()
642642
* support multivariate polynomial, multivariate operations **[DONE]**
643643
* implement groebner basis computations (`Buchberger` algorithm) **[DONE]**
644644
* support generic algebraic Rings and Fields (including rings of polynomials and fraction fields of polynomials) **[DONE]**
645-
* exact/symbolic `SVD` computation, faster numeric `SVD` computation (TODO)
645+
* faster numeric `SVD` computation (TODO)
646646
* implement `LLL` algorithm (TODO)
647647
* add efficient `rank`/`unrank` methods for `DerangementPermutation`, `InvolutionPermutation`, `ConnectedPermutation`, `Composition` & `Partition` (TODO)
648648
* full support for `colex` ordering `Composition` & `Partition` **[DONE PARTIALY]**

src/js/Abacus.js

+11-4
Original file line numberDiff line numberDiff line change
@@ -3903,15 +3903,15 @@ function solvelinears( a, b, with_param )
39033903
var symbol = is_string(with_param) && with_param.length ? with_param : 'z', apinv, bp, ns;
39043904

39053905
if ( !is_instance(a, Matrix) ) a = Matrix(Ring.Q(), a);
3906-
else a = Matrix(a.ring.associatedField(), a);
3906+
else if ( !a.ring.isField() ) a = Matrix(a.ring.associatedField(), a);
39073907
if ( !a.nr || !a.nc ) return null;
39083908
b = Matrix(a.ring, b);
39093909
apinv = a.ginv(); bp = apinv.mul(b);
39103910
if ( true===with_param ) return bp.col(0); // least squares solution
39113911
else if ( !a.mul(bp).equ(b) ) return null; // no solutions exist
39123912
if ( false===with_param )
39133913
{
3914-
// particular least-norm solution
3914+
// particular solution
39153915
return bp.col(0);
39163916
}
39173917
else
@@ -3920,8 +3920,8 @@ function solvelinears( a, b, with_param )
39203920
ns = Matrix.I(a.ring, bp.nr).sub(apinv.mul(a));
39213921
return array(bp.nr, function(i){
39223922
return Expr(array(ns.nc, function(j){
3923-
return MulTerm(SymbolTerm(with_param+'_'+(j+1)), ns.val[i][j]);
3924-
})).add(bp.val[j][0]);
3923+
return MulTerm(SymbolTerm(symbol+'_'+(j+1)), ns.val[i][j]);
3924+
})).add(bp.val[i][0]);
39253925
});
39263926
}
39273927
}
@@ -6189,6 +6189,13 @@ Abacus.Math = {
61896189
return solvepythag(Arithmetic.nums(a), with_param)
61906190
}
61916191
,linears: function( a, b, with_param ) {
6192+
var ring = Ring.Q();
6193+
if ( !is_instance(a, Matrix) && !is_array(a) && !is_args(a) ) return null;
6194+
if ( is_instance(a, Matrix) && (!a.nr || !a.nc) ) return null;
6195+
if ( !is_instance(a, Matrix) && !a.length ) return null;
6196+
//a = is_instance(a, Matrix) ? a : a;
6197+
if ( !is_instance(b, Matrix) && !is_array(b) && !is_args(b) ) b = array(is_instance(a, Matrix) ? a.nr : a.length, function(){return b||0;});
6198+
b = is_instance(b, Matrix) ? b : ring.cast(b);
61926199
return solvelinears( a, b, with_param );
61936200
}
61946201

src/js/Abacus.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/combination_subsets.txt

+25-25
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Abacus.Subsets via Abacus.Combinations (VERSION = 1.0.0)
1+
Abacus.Subsets via Abacus.Combinations (VERSION = 1.0.5)
22
---
33
o = Abacus.CombinatorialIterator([Abacus.Combination(5,0),Abacus.Combination(5,1),Abacus.Combination(5,2),Abacus.Combination(5,3),Abacus.Combination(5,4),Abacus.Combination(5,5)])
44
o.total()
@@ -243,38 +243,38 @@ o.order("colex,reversed")
243243
[ 0 ]
244244
[]
245245
o.order("random")
246+
[ 2, 4 ]
247+
[ 3, 4 ]
248+
[ 2 ]
249+
[ 3 ]
250+
[ 1, 2, 3 ]
246251
[ 2, 3 ]
247-
[ 3, 2 ]
248-
[ 4 ]
249-
[ 0, 3, 4 ]
250-
[ 3, 2 ]
251-
[ 1 ]
252+
[ 0, 1, 4 ]
253+
[ 1, 2, 4 ]
254+
[ 0, 2, 3, 4 ]
252255
[ 2, 3, 4 ]
256+
[ 0, 1 ]
257+
[ 3, 4 ]
258+
[ 4, 0 ]
259+
[ 4 ]
260+
[ 3, 4 ]
261+
[ 0, 1, 2, 3, 4 ]
253262
[ 0, 1, 4 ]
254-
[ 3, 2 ]
255-
[ 0, 1, 3, 4 ]
256-
[ 1, 2, 3, 4 ]
263+
[ 3 ]
257264
[ 1 ]
258-
[ 0 ]
259-
[ 2, 1 ]
260-
[ 0, 1, 4 ]
261265
[ 0, 1, 4 ]
262-
[ 0, 3 ]
263-
[ 2, 3 ]
264-
[ 0, 3, 4 ]
265266
[ 3, 1 ]
266-
[ 2, 3 ]
267-
[ 0, 3, 4 ]
268-
[ 0, 1, 2, 3 ]
269-
[ 0, 1, 2, 3 ]
270-
[ 4, 1 ]
267+
[ 1, 2 ]
271268
[ 3, 4 ]
272-
[ 0, 1 ]
273-
[ 0, 1, 4 ]
269+
[ 0, 1, 2, 3, 4 ]
270+
[ 3, 1 ]
274271
[ 0, 2, 4 ]
275-
[ 1, 4 ]
272+
[ 1, 2 ]
273+
[ 2 ]
276274
[ 3, 4 ]
277-
[ 0, 1, 4 ]
275+
[ 0, 2, 4 ]
276+
[ 2, 3, 4 ]
277+
[ 2, 3, 4 ]
278278
o.random()
279-
[ 3 ]
279+
[ 1, 2, 3, 4 ]
280280
o.dispose()

test/combinations.txt

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Abacus.Combinations (VERSION = 1.0.0)
1+
Abacus.Combinations (VERSION = 1.0.5)
22
---
33
o = Abacus.Combination(6,3)
44
o.total()
@@ -159,28 +159,28 @@ o.order("colex,reversed")
159159
[ 0, 1, 3 ]
160160
[ 0, 1, 2 ]
161161
o.order("random")
162+
[ 0, 1, 3 ]
163+
[ 2, 3, 4 ]
164+
[ 0, 1, 2 ]
165+
[ 1, 4, 5 ]
166+
[ 1, 2, 4 ]
167+
[ 0, 3, 5 ]
168+
[ 1, 3, 4 ]
162169
[ 0, 2, 5 ]
163-
[ 0, 1, 5 ]
170+
[ 2, 3, 5 ]
164171
[ 3, 4, 5 ]
165-
[ 0, 2, 3 ]
166-
[ 0, 2, 4 ]
167172
[ 0, 4, 5 ]
173+
[ 2, 4, 5 ]
168174
[ 0, 3, 4 ]
169-
[ 1, 2, 4 ]
170-
[ 0, 3, 5 ]
171-
[ 2, 3, 4 ]
172-
[ 0, 1, 4 ]
173-
[ 2, 3, 5 ]
174175
[ 1, 2, 3 ]
175-
[ 1, 2, 5 ]
176-
[ 1, 4, 5 ]
177-
[ 2, 4, 5 ]
178176
[ 1, 3, 5 ]
179-
[ 0, 1, 3 ]
180-
[ 0, 1, 2 ]
181-
[ 1, 3, 4 ]
177+
[ 1, 2, 5 ]
178+
[ 0, 2, 4 ]
179+
[ 0, 1, 4 ]
180+
[ 0, 1, 5 ]
181+
[ 0, 2, 3 ]
182182
o.random()
183-
[ 1, 2, 3 ]
183+
[ 2, 3, 4 ]
184184
o.order("colex").range(-5, -1)
185185
[ 2, 3, 5 ]
186186
[ 0, 4, 5 ]

test/combinations_repeats.txt

+50-50
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Abacus.CombinationRepeats (VERSION = 1.0.0)
1+
Abacus.CombinationRepeats (VERSION = 1.0.5)
22
---
33
o = Abacus.Combination(6,3,{type:"repeated"})
44
o.total()
@@ -411,64 +411,64 @@ o.order("colex,reversed")
411411
[ 0, 0, 1 ]
412412
[ 0, 0, 0 ]
413413
o.order("random")
414-
[ 0, 2, 4 ]
415-
[ 0, 4, 4 ]
416-
[ 5, 5, 5 ]
417-
[ 3, 3, 4 ]
418-
[ 0, 2, 5 ]
419-
[ 1, 4, 5 ]
420-
[ 0, 0, 1 ]
414+
[ 2, 3, 3 ]
415+
[ 2, 3, 5 ]
416+
[ 3, 4, 5 ]
417+
[ 1, 4, 4 ]
418+
[ 2, 3, 4 ]
419+
[ 1, 1, 5 ]
420+
[ 1, 2, 4 ]
421+
[ 0, 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 ]
457-
[ 0, 0, 3 ]
458-
[ 3, 5, 5 ]
459-
[ 0, 1, 5 ]
460-
[ 1, 2, 5 ]
461-
[ 1, 1, 5 ]
462-
[ 2, 3, 4 ]
463-
[ 1, 2, 2 ]
464-
[ 2, 2, 3 ]
465-
[ 1, 4, 4 ]
466-
[ 0, 4, 5 ]
467-
[ 1, 2, 3 ]
453+
[ 1, 3, 3 ]
454+
[ 2, 2, 2 ]
468455
[ 4, 4, 4 ]
469-
[ 1, 3, 5 ]
470-
o.random()
456+
[ 1, 3, 4 ]
457+
[ 0, 1, 5 ]
458+
[ 1, 1, 3 ]
459+
[ 2, 4, 4 ]
460+
[ 0, 5, 5 ]
461+
[ 3, 3, 3 ]
471462
[ 0, 2, 4 ]
463+
[ 4, 4, 5 ]
464+
[ 3, 4, 4 ]
465+
[ 1, 1, 2 ]
466+
[ 0, 2, 5 ]
467+
[ 1, 1, 1 ]
468+
[ 2, 4, 5 ]
469+
[ 0, 4, 4 ]
470+
o.random()
471+
[ 0, 2, 3 ]
472472
o.order("colex").range(-5, -1)
473473
[ 1, 5, 5 ]
474474
[ 2, 5, 5 ]

test/complex.txt

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Abacus.Complex (VERSION = 1.0.0)
1+
Abacus.Complex (VERSION = 1.0.5)
22
---
33
o=Abacus.Complex()
44
o.toString()
@@ -10,11 +10,11 @@ o.toDec()
1010

1111
o=Abacus.Complex.rnd("0", "1+i")
1212
o.toString()
13-
1/2+(221/256)*i
13+
(1/32)*i
1414
o.toDec()
15-
0.5+0.86328125i
15+
0.03125i
1616
o.rad(2).toString()
17-
4329443362913/5003173903488+(1438256679137/2883370983552)*i
17+
1/8+(1/8)*i
1818

1919
Abacus.Complex(1).rad(2)
2020
1

test/compositions.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ echo(o.next());
3737

3838
echo('default order is "lex", lexicographic-order');
3939
echo('o.rewind()');
40-
print_all( o.rewind() );
40+
print_all( o.rewind(), 1, function( item ){
41+
return [item.slice(), o.index()-(o.hasNext()?1:0), Abacus.Partition.rank(item, o.n, o.$)];
42+
});
4143

4244
echo('backwards');
4345
echo('o.rewind(-1)');
@@ -82,7 +84,9 @@ echo(o.next());
8284

8385
echo('default order is "lex", lexicographic-order');
8486
echo('o.rewind()');
85-
print_all( o.rewind() );
87+
print_all( o.rewind(), 1, function( item ){
88+
return [item.slice(), o.index()-(o.hasNext()?1:0), Abacus.Partition.rank(item, o.n, o.$)];
89+
});
8690

8791
echo('backwards');
8892
echo('o.rewind(-1)');
@@ -120,7 +124,9 @@ echo(o.next());
120124

121125
echo('default order is "lex", lexicographic-order');
122126
echo('o.rewind()');
123-
print_all( o.rewind() );
127+
print_all( o.rewind(), 1, function( item ){
128+
return [item.slice(), o.index()-(o.hasNext()?1:0), Abacus.Partition.rank(item, o.n, o.$)];
129+
});
124130

125131
echo('backwards');
126132
echo('o.rewind(-1)');

0 commit comments

Comments
 (0)