From 1bacbf765d9adb00cca4a9044e0d48677288d3ee Mon Sep 17 00:00:00 2001 From: Mohamed Barakat Date: Thu, 2 Nov 2023 14:11:15 +0100 Subject: [PATCH 1/2] Row/ColumnEchelonForm now get rid of trailing zero rows/columns --- MatricesForHomalg/PackageInfo.g | 2 +- MatricesForHomalg/gap/Service.gi | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/MatricesForHomalg/PackageInfo.g b/MatricesForHomalg/PackageInfo.g index 807f39aa7..208a94dd3 100644 --- a/MatricesForHomalg/PackageInfo.g +++ b/MatricesForHomalg/PackageInfo.g @@ -11,7 +11,7 @@ SetPackageInfo( rec( PackageName := "MatricesForHomalg", Subtitle := "Matrices for the homalg project", -Version := "2023.10-01", +Version := "2023.11-01", Date := (function ( ) if IsBound( GAPInfo.SystemEnvironment.GAP_PKG_RELEASE_DATE ) then return GAPInfo.SystemEnvironment.GAP_PKG_RELEASE_DATE; else return Concatenation( ~.Version{[ 1 .. 4 ]}, "-", ~.Version{[ 6, 7 ]}, "-01" ); fi; end)( ), License := "GPL-2.0-or-later", diff --git a/MatricesForHomalg/gap/Service.gi b/MatricesForHomalg/gap/Service.gi index 83b972ac6..ed40a863c 100644 --- a/MatricesForHomalg/gap/Service.gi +++ b/MatricesForHomalg/gap/Service.gi @@ -172,7 +172,9 @@ InstallMethod( RowEchelonForm, B := RP!.RowEchelonForm( M ); - ColoredInfoForService( t, "RowEchelonForm", Length( NonZeroRows( B ) ) ); + B := CertainRows( B, NonZeroRows( B ) ); + + ColoredInfoForService( t, "RowEchelonForm", NumberRows( B ) ); return B; @@ -180,7 +182,9 @@ InstallMethod( RowEchelonForm, B := Involution( RP!.ColumnEchelonForm( Involution( M ) ) ); - ColoredInfoForService( t, "RowEchelonForm", Length( NonZeroRows( B ) ) ); + B := CertainRows( B, NonZeroRows( B ) ); + + ColoredInfoForService( t, "RowEchelonForm", NumberRows( B ) ); return B; @@ -252,7 +256,9 @@ InstallMethod( ColumnEchelonForm, B := RP!.ColumnEchelonForm( M ); - ColoredInfoForService( t, "ColumnEchelonForm", Length( NonZeroColumns( B ) ) ); + B := CertainColumns( B, NonZeroColumns( B ) ); + + ColoredInfoForService( t, "ColumnEchelonForm", NumberColumns( B ) ); return B; From c2583a10f9d39a65bcb7a1dedc943e8dd15cd3a5 Mon Sep 17 00:00:00 2001 From: Mohamed Barakat Date: Thu, 2 Nov 2023 14:19:22 +0100 Subject: [PATCH 2/2] RowEchelonForm now supported in Singular and Maple --- RingsForHomalg/PackageInfo.g | 2 +- RingsForHomalg/gap/MapleHomalgBasic.gi | 14 ++++++++++++++ RingsForHomalg/gap/SingularBasic.gi | 24 ++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/RingsForHomalg/PackageInfo.g b/RingsForHomalg/PackageInfo.g index 55c2260fb..ebca0a0c7 100644 --- a/RingsForHomalg/PackageInfo.g +++ b/RingsForHomalg/PackageInfo.g @@ -11,7 +11,7 @@ SetPackageInfo( rec( PackageName := "RingsForHomalg", Subtitle := "Dictionaries of external rings", -Version := "2023.09-01", +Version := "2023.11-01", Date := (function ( ) if IsBound( GAPInfo.SystemEnvironment.GAP_PKG_RELEASE_DATE ) then return GAPInfo.SystemEnvironment.GAP_PKG_RELEASE_DATE; else return Concatenation( ~.Version{[ 1 .. 4 ]}, "-", ~.Version{[ 6, 7 ]}, "-01" ); fi; end)( ), License := "GPL-2.0-or-later", diff --git a/RingsForHomalg/gap/MapleHomalgBasic.gi b/RingsForHomalg/gap/MapleHomalgBasic.gi index d4b8d57e2..6ee5ded3b 100644 --- a/RingsForHomalg/gap/MapleHomalgBasic.gi +++ b/RingsForHomalg/gap/MapleHomalgBasic.gi @@ -19,6 +19,20 @@ BindGlobal( "CommonHomalgTableForMapleHomalgBasic", ## Must only then be provided by the RingPackage in case the default ## "service" function does not match the Ring + RowEchelonForm := + function( M ) + local R, N; + + R := HomalgRing( M ); + + N := HomalgVoidMatrix( "unknown_number_of_rows", NumberColumns( M ), R ); + + homalgSendBlocking( [ N, " := ", R, "[-1][matrix](LinearAlgebra[GaussianElimination](Matrix(", M, "), 'method' = 'FractionFree'))" ], "need_command", "ReducedEchelonForm" ); + + return N; + + end, + BasisOfRowModule := function( M ) local R, N; diff --git a/RingsForHomalg/gap/SingularBasic.gi b/RingsForHomalg/gap/SingularBasic.gi index 01fa5916c..881ace6e0 100644 --- a/RingsForHomalg/gap/SingularBasic.gi +++ b/RingsForHomalg/gap/SingularBasic.gi @@ -18,6 +18,30 @@ BindGlobal( "CommonHomalgTableForSingularBasic", ## Must only then be provided by the RingPackage in case the default ## "service" function does not match the Ring + RowEchelonForm := + function( M ) + local R, v, N; + + R := HomalgRing( M ); + + v := homalgStream( R ).variable_name; + + N := HomalgVoidMatrix( "unknown_number_of_rows", NumberColumns( M ), R ); + + homalgSendBlocking( [ "intvec ", v, "option = option(get); option(none); option(prompt); option(intStrategy)" ], R, "need_command", "initialize" ); + + homalgSendBlocking( + [ "matrix ", N, " = BasisOfRowModule(", M, ")" ], + "need_command", + "ReducedEchelonForm" + ); + + homalgSendBlocking( [ "option(set,", v, "option)" ], R, "need_command", "initialize" ); + + return CertainRows( N, Reversed( [ 1 .. NumberRows( N ) ] ) ); + + end, + ## <#GAPDoc Label="BasisOfRowModule:Singular"> ## ##