From f11c1fd56ac49a6fb0924f083715aba94eb4f836 Mon Sep 17 00:00:00 2001 From: Kamal Saleh Date: Fri, 7 Oct 2022 16:02:19 +0200 Subject: [PATCH] (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 --- MatricesForHomalg/PackageInfo.g | 2 +- MatricesForHomalg/gap/Tools.gi | 41 ++++++++++++++++++++++++++------- 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/MatricesForHomalg/PackageInfo.g b/MatricesForHomalg/PackageInfo.g index b3748b8d6..75945a316 100644 --- a/MatricesForHomalg/PackageInfo.g +++ b/MatricesForHomalg/PackageInfo.g @@ -11,7 +11,7 @@ SetPackageInfo( rec( PackageName := "MatricesForHomalg", Subtitle := "Matrices for the homalg project", -Version := "2022.10-03", +Version := "2022.10-04", Date := Concatenation( "01/", ~.Version{[ 6, 7 ]}, "/", ~.Version{[ 1 .. 4 ]} ), License := "GPL-2.0-or-later", diff --git a/MatricesForHomalg/gap/Tools.gi b/MatricesForHomalg/gap/Tools.gi index bae1f1d4d..a4e14590c 100644 --- a/MatricesForHomalg/gap/Tools.gi +++ b/MatricesForHomalg/gap/Tools.gi @@ -4518,6 +4518,11 @@ InstallMethod( GetRidOfRowsAndColumnsWithUnits, end ); +## +## L = [ min_deg, max_deg, zt, coeff ] +## min_deg and max_deg determine the minimal and maximal degree of the element +## zt determines the percentage of the zero terms in the element +## The non-trivial coefficients belong to the interval [ 1 .. coeffs ] ## InstallMethod( Random, "for a homalg ring and a list", @@ -4549,8 +4554,6 @@ InstallMethod( Random, end ); -if IsPackageMarkedForLoading( "utils", ">= 0.54" ) then - ## InstallMethod( Random, "for a homalg ring", @@ -4558,12 +4561,10 @@ InstallMethod( Random, function( R ) - return Random( R, RandomCombination( [ 0 .. 10 ], Random( [ 1 .. 11 ] ) ) ); + return Random( R, [ 0, Random( [ 0, 1, 1, 1, 2, 2, 2, 3 ] ), 80, 50 ] ); end ); -fi; - ## InstallMethod( Random, "for a homalg internal ring", @@ -5087,6 +5088,30 @@ InstallMethod( RandomMatrix, end ); +## +## params = [ min_deg,max_deg,ze,zt,coeffs ] +## +## min_deg and max_deg determine the minimal and maximal degree of an entry in the matrix +## ze determines the percentage of the zero entries in the matrix (The default value is 50) +## zt determines the percentage of the zero terms in each entry in the matrix (The default value is 80) +## The non-trivial coefficients of each entry belong to the interval [ 1 .. coeffs ] (The default value is 10) +## +InstallOtherMethod( RandomMatrix, + "for two integers, a homalg ring and a list", + [ IsInt, IsInt, IsHomalgRing, IsList ], + function( r, c, R, params ) + local RP; + + RP := homalgTable( R ); + + if IsBound(RP!.RandomMat) then + return HomalgMatrix( CallFuncList( RP!.RandomMat, Concatenation( [ R, r, c ], params ) ), r, c, R ); + else + TryNextMethod(); + fi; + +end ); + ## InstallMethod( RandomMatrix, "for two integers and a homalg ring", @@ -5104,11 +5129,11 @@ InstallMethod( RandomMatrix, RP := homalgTable( R ); - if IsBound(RP!.RandomMat) and IsPackageMarkedForLoading( "utils", ">= 0.54" ) then + if IsBound(RP!.RandomMat) then - params := ValueGlobal( "RandomCombination" )( [ 0 .. 10 ], Random( [ 1 .. 11 ] ) ); + params := [ 0, Random( [ 1, 1, 1, 2, 2, 2, 3 ] ), 50, 80, 50 ]; - return HomalgMatrix( CallFuncList( RP!.RandomMat, Concatenation( [ R, r, c ], params ) ), r, c, R ); + return RandomMatrix( r, c, R, params ); fi;