Skip to content

Commit f11c1fd

Browse files
committed
(1) add a method Random(r,c,ring,params) which makes
constructing random matrices over singular more flexible (2) change the hard coded parameters from RandomCombination( [ 0 .. 10 ], Random( [ 1 .. 11 ] ) ) to [ 0, Random( [ 0, 1, 1, 1, 2, 2, 2, 3 ] ), 50, 80, 50 ] For polynomial and exterior rings - 0 is the minimal allowed degree - Random( [ 1, 1, 1, 2, 2, 2, 3 ] ) is the maximal allowd degree - 50% of the entries are zero - 80% of the terms in each entry are zero - The coefficient of each monomial is less than 50 (3) bump the version of MatricesForHomalg to 2022.10-04
1 parent 45869a8 commit f11c1fd

File tree

2 files changed

+34
-9
lines changed

2 files changed

+34
-9
lines changed

MatricesForHomalg/PackageInfo.g

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ SetPackageInfo( rec(
1111

1212
PackageName := "MatricesForHomalg",
1313
Subtitle := "Matrices for the homalg project",
14-
Version := "2022.10-03",
14+
Version := "2022.10-04",
1515
Date := Concatenation( "01/", ~.Version{[ 6, 7 ]}, "/", ~.Version{[ 1 .. 4 ]} ),
1616
License := "GPL-2.0-or-later",
1717

MatricesForHomalg/gap/Tools.gi

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4518,6 +4518,11 @@ InstallMethod( GetRidOfRowsAndColumnsWithUnits,
45184518

45194519
end );
45204520

4521+
##
4522+
## L = [ min_deg, max_deg, zt, coeff ]
4523+
## min_deg and max_deg determine the minimal and maximal degree of the element
4524+
## zt determines the percentage of the zero terms in the element
4525+
## The non-trivial coefficients belong to the interval [ 1 .. coeffs ]
45214526
##
45224527
InstallMethod( Random,
45234528
"for a homalg ring and a list",
@@ -4549,21 +4554,17 @@ InstallMethod( Random,
45494554

45504555
end );
45514556

4552-
if IsPackageMarkedForLoading( "utils", ">= 0.54" ) then
4553-
45544557
##
45554558
InstallMethod( Random,
45564559
"for a homalg ring",
45574560
[ IsHomalgRing ],
45584561

45594562
function( R )
45604563

4561-
return Random( R, RandomCombination( [ 0 .. 10 ], Random( [ 1 .. 11 ] ) ) );
4564+
return Random( R, [ 0, Random( [ 0, 1, 1, 1, 2, 2, 2, 3 ] ), 80, 50 ] );
45624565

45634566
end );
45644567

4565-
fi;
4566-
45674568
##
45684569
InstallMethod( Random,
45694570
"for a homalg internal ring",
@@ -5087,6 +5088,30 @@ InstallMethod( RandomMatrix,
50875088

50885089
end );
50895090

5091+
##
5092+
## params = [ min_deg,max_deg,ze,zt,coeffs ]
5093+
##
5094+
## min_deg and max_deg determine the minimal and maximal degree of an entry in the matrix
5095+
## ze determines the percentage of the zero entries in the matrix (The default value is 50)
5096+
## zt determines the percentage of the zero terms in each entry in the matrix (The default value is 80)
5097+
## The non-trivial coefficients of each entry belong to the interval [ 1 .. coeffs ] (The default value is 10)
5098+
##
5099+
InstallOtherMethod( RandomMatrix,
5100+
"for two integers, a homalg ring and a list",
5101+
[ IsInt, IsInt, IsHomalgRing, IsList ],
5102+
function( r, c, R, params )
5103+
local RP;
5104+
5105+
RP := homalgTable( R );
5106+
5107+
if IsBound(RP!.RandomMat) then
5108+
return HomalgMatrix( CallFuncList( RP!.RandomMat, Concatenation( [ R, r, c ], params ) ), r, c, R );
5109+
else
5110+
TryNextMethod();
5111+
fi;
5112+
5113+
end );
5114+
50905115
##
50915116
InstallMethod( RandomMatrix,
50925117
"for two integers and a homalg ring",
@@ -5104,11 +5129,11 @@ InstallMethod( RandomMatrix,
51045129

51055130
RP := homalgTable( R );
51065131

5107-
if IsBound(RP!.RandomMat) and IsPackageMarkedForLoading( "utils", ">= 0.54" ) then
5132+
if IsBound(RP!.RandomMat) then
51085133

5109-
params := ValueGlobal( "RandomCombination" )( [ 0 .. 10 ], Random( [ 1 .. 11 ] ) );
5134+
params := [ 0, Random( [ 1, 1, 1, 2, 2, 2, 3 ] ), 50, 80, 50 ];
51105135

5111-
return HomalgMatrix( CallFuncList( RP!.RandomMat, Concatenation( [ R, r, c ], params ) ), r, c, R );
5136+
return RandomMatrix( r, c, R, params );
51125137

51135138
fi;
51145139

0 commit comments

Comments
 (0)