Skip to content

Commit

Permalink
v.1.0.5
Browse files Browse the repository at this point in the history
* update examplea and tests
  • Loading branch information
foo123 committed Aug 26, 2020
1 parent ca5a829 commit c6abf5f
Show file tree
Hide file tree
Showing 55 changed files with 38,629 additions and 11,053 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ o.dispose()
* support multivariate polynomial, multivariate operations **[DONE]**
* implement groebner basis computations (`Buchberger` algorithm) **[DONE]**
* support generic algebraic Rings and Fields (including rings of polynomials and fraction fields of polynomials) **[DONE]**
* exact/symbolic `SVD` computation, faster numeric `SVD` computation (TODO)
* faster numeric `SVD` computation (TODO)
* implement `LLL` algorithm (TODO)
* add efficient `rank`/`unrank` methods for `DerangementPermutation`, `InvolutionPermutation`, `ConnectedPermutation`, `Composition` & `Partition` (TODO)
* full support for `colex` ordering `Composition` & `Partition` **[DONE PARTIALY]**
Expand Down
15 changes: 11 additions & 4 deletions src/js/Abacus.js
Original file line number Diff line number Diff line change
Expand Up @@ -3903,15 +3903,15 @@ function solvelinears( a, b, with_param )
var symbol = is_string(with_param) && with_param.length ? with_param : 'z', apinv, bp, ns;

if ( !is_instance(a, Matrix) ) a = Matrix(Ring.Q(), a);
else a = Matrix(a.ring.associatedField(), a);
else if ( !a.ring.isField() ) a = Matrix(a.ring.associatedField(), a);
if ( !a.nr || !a.nc ) return null;
b = Matrix(a.ring, b);
apinv = a.ginv(); bp = apinv.mul(b);
if ( true===with_param ) return bp.col(0); // least squares solution
else if ( !a.mul(bp).equ(b) ) return null; // no solutions exist
if ( false===with_param )
{
// particular least-norm solution
// particular solution
return bp.col(0);
}
else
Expand All @@ -3920,8 +3920,8 @@ function solvelinears( a, b, with_param )
ns = Matrix.I(a.ring, bp.nr).sub(apinv.mul(a));
return array(bp.nr, function(i){
return Expr(array(ns.nc, function(j){
return MulTerm(SymbolTerm(with_param+'_'+(j+1)), ns.val[i][j]);
})).add(bp.val[j][0]);
return MulTerm(SymbolTerm(symbol+'_'+(j+1)), ns.val[i][j]);
})).add(bp.val[i][0]);
});
}
}
Expand Down Expand Up @@ -6189,6 +6189,13 @@ Abacus.Math = {
return solvepythag(Arithmetic.nums(a), with_param)
}
,linears: function( a, b, with_param ) {
var ring = Ring.Q();
if ( !is_instance(a, Matrix) && !is_array(a) && !is_args(a) ) return null;
if ( is_instance(a, Matrix) && (!a.nr || !a.nc) ) return null;
if ( !is_instance(a, Matrix) && !a.length ) return null;
//a = is_instance(a, Matrix) ? a : a;
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;});
b = is_instance(b, Matrix) ? b : ring.cast(b);
return solvelinears( a, b, with_param );
}

Expand Down
4 changes: 2 additions & 2 deletions src/js/Abacus.min.js

Large diffs are not rendered by default.

50 changes: 25 additions & 25 deletions test/combination_subsets.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Abacus.Subsets via Abacus.Combinations (VERSION = 1.0.0)
Abacus.Subsets via Abacus.Combinations (VERSION = 1.0.5)
---
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)])
o.total()
Expand Down Expand Up @@ -243,38 +243,38 @@ o.order("colex,reversed")
[ 0 ]
[]
o.order("random")
[ 2, 4 ]
[ 3, 4 ]
[ 2 ]
[ 3 ]
[ 1, 2, 3 ]
[ 2, 3 ]
[ 3, 2 ]
[ 4 ]
[ 0, 3, 4 ]
[ 3, 2 ]
[ 1 ]
[ 0, 1, 4 ]
[ 1, 2, 4 ]
[ 0, 2, 3, 4 ]
[ 2, 3, 4 ]
[ 0, 1 ]
[ 3, 4 ]
[ 4, 0 ]
[ 4 ]
[ 3, 4 ]
[ 0, 1, 2, 3, 4 ]
[ 0, 1, 4 ]
[ 3, 2 ]
[ 0, 1, 3, 4 ]
[ 1, 2, 3, 4 ]
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complex.rnd("0", "1+i")
o.toString()
1/2+(221/256)*i
(1/32)*i
o.toDec()
0.5+0.86328125i
0.03125i
o.rad(2).toString()
4329443362913/5003173903488+(1438256679137/2883370983552)*i
1/8+(1/8)*i

Abacus.Complex(1).rad(2)
1
Expand Down
12 changes: 9 additions & 3 deletions test/compositions.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ echo(o.next());

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

echo('backwards');
echo('o.rewind(-1)');
Expand Down Expand Up @@ -82,7 +84,9 @@ echo(o.next());

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

echo('backwards');
echo('o.rewind(-1)');
Expand Down Expand Up @@ -120,7 +124,9 @@ echo(o.next());

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

echo('backwards');
echo('o.rewind(-1)');
Expand Down
Loading

0 comments on commit c6abf5f

Please sign in to comment.