Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
| Download
GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
Project: cocalc-sagemath-dev-slelievre
Views: 4183461[1XE [33X[0;0YDebugging [5XMatricesForHomalg[105X[101X[1X[133X[101X23[33X[0;0YBeside the [5XGAP[105X builtin debugging facilities (--> [14X'Reference: Debugging and4Profiling Facilities'[114X) [5XMatricesForHomalg[105X provides two ways to debug the5computations.[133X678[1XE.1 [33X[0;0YIncrease the assertion level[133X[101X910[33X[0;0Y[5XMatricesForHomalg[105X comes with numerous builtin assertion checks. They are11activated if the user increases the assertion level using[133X12[33X[0;0Y[10XSetAssertionLevel[110X( [3Xlevel[103X );[133X13[33X[0;0Y(--> [14X'Reference: SetAssertionLevel'[114X), where [3Xlevel[103X is one of the values14below:[133X1516[3Xlevel[103X │ description17──────┼──────────────────────────────────────────────────────────────────────18│190 │ no assertion checks whatsoever20│214 │ assertions about basic matrix operations are checked (--> Appendix [14XA[114X)22│ (these are among the operations often delegated to external systems)23│24──────┴──────────────────────────────────────────────────────────────────────2526[33X[0;0YIn particular, if [5XMatricesForHomalg[105X delegates matrix operations to an27external system then [10XSetAssertionLevel[110X( 4 ); can be used to let28[5XMatricesForHomalg[105X debug the external system.[133X29[33X[0;0YBelow you can find the record of the available level-4 assertions, which is30a [5XGAP[105X-component of every [5Xhomalg[105X ring. Each assertion can thus be overwritten31by package developers or even ordinary users.[133X3233[4X[32X Code [32X[104X34[4Xasserts :=[104X35[4X rec([104X36[4X BasisOfRowModule :=[104X37[4X function( B ) return ( NrRows( B ) = 0 ) = IsZero( B ); end,[104X38[4X [104X39[4X BasisOfColumnModule :=[104X40[4X function( B ) return ( NrColumns( B ) = 0 ) = IsZero( B ); end,[104X41[4X [104X42[4X BasisOfRowsCoeff :=[104X43[4X function( B, T, M ) return B = T * M; end,[104X44[4X [104X45[4X BasisOfColumnsCoeff :=[104X46[4X function( B, M, T ) return B = M * T; end,[104X47[4X [104X48[4X DecideZeroRows_Effectively :=[104X49[4X function( M, A, B ) return M = DecideZeroRows( A, B ); end,[104X50[4X [104X51[4X DecideZeroColumns_Effectively :=[104X52[4X function( M, A, B ) return M = DecideZeroColumns( A, B ); end,[104X53[4X [104X54[4X DecideZeroRowsEffectively :=[104X55[4X function( M, A, T, B ) return M = A + T * B; end,[104X56[4X [104X57[4X DecideZeroColumnsEffectively :=[104X58[4X function( M, A, B, T ) return M = A + B * T; end,[104X59[4X [104X60[4X DecideZeroRowsWRTNonBasis :=[104X61[4X function( B )[104X62[4X local R;[104X63[4X R := HomalgRing( B );[104X64[4X if not ( HasIsBasisOfRowsMatrix( B ) and[104X65[4X IsBasisOfRowsMatrix( B ) ) and[104X66[4X IsBound( R!.DecideZeroWRTNonBasis ) then[104X67[4X if R!.DecideZeroWRTNonBasis = "warn" then[104X68[4X Info( InfoWarning, 1,[104X69[4X "about to reduce with respect to a matrix",[104X70[4X "with IsBasisOfRowsMatrix not set to true" );[104X71[4X elif R!.DecideZeroWRTNonBasis = "error" then[104X72[4X Error( "about to reduce with respect to a matrix",[104X73[4X "with IsBasisOfRowsMatrix not set to true\n" );[104X74[4X fi;[104X75[4X fi;[104X76[4X end,[104X77[4X [104X78[4X DecideZeroColumnsWRTNonBasis :=[104X79[4X function( B )[104X80[4X local R;[104X81[4X R := HomalgRing( B );[104X82[4X if not ( HasIsBasisOfColumnsMatrix( B ) and[104X83[4X IsBasisOfColumnsMatrix( B ) ) and[104X84[4X IsBound( R!.DecideZeroWRTNonBasis ) then[104X85[4X if R!.DecideZeroWRTNonBasis = "warn" then[104X86[4X Info( InfoWarning, 1,[104X87[4X "about to reduce with respect to a matrix",[104X88[4X "with IsBasisOfColumnsMatrix not set to true" );[104X89[4X elif R!.DecideZeroWRTNonBasis = "error" then[104X90[4X Error( "about to reduce with respect to a matrix",[104X91[4X "with IsBasisOfColumnsMatrix not set to true\n" );[104X92[4X fi;[104X93[4X fi;[104X94[4X end,[104X95[4X [104X96[4X ReducedBasisOfRowModule :=[104X97[4X function( M, B )[104X98[4X return GenerateSameRowModule( B, BasisOfRowModule( M ) );[104X99[4X end,[104X100[4X [104X101[4X ReducedBasisOfColumnModule :=[104X102[4X function( M, B )[104X103[4X return GenerateSameColumnModule( B, BasisOfColumnModule( M ) );[104X104[4X end,[104X105[4X [104X106[4X ReducedSyzygiesGeneratorsOfRows :=[104X107[4X function( M, S )[104X108[4X return GenerateSameRowModule( S, SyzygiesGeneratorsOfRows( M ) );[104X109[4X end,[104X110[4X [104X111[4X ReducedSyzygiesGeneratorsOfColumns :=[104X112[4X function( M, S )[104X113[4X return GenerateSameColumnModule( S, SyzygiesGeneratorsOfColumns( M ) );[104X114[4X end,[104X115[4X [104X116[4X );[104X117[4X[32X[104X118119120[1XE.2 [33X[0;0Y[10XUsing homalgMode[110X[101X[1X[133X[101X121122[1XE.2-1 homalgMode[101X123124[29X[2XhomalgMode[102X( [3Xstr[103X[, [3Xstr2[103X] ) [32X method125126[33X[0;0YThis function sets different modes which influence how much of the basic127matrix operations and the logical matrix methods become visible (-->128Appendices [14XA[114X, [14XC[114X). Handling the string [3Xstr[103X is [13Xnot[113X case-sensitive. If a second129string [3Xstr2[103X is given, then [10XhomalgMode[110X( [3Xstr2[103X ) is invoked at the end. In case130you let [5Xhomalg[105X delegate matrix operations to an external system the you131might also want to check [10XhomalgIOMode[110X in the [5XHomalgToCAS[105X package manual.[133X132133[3Xstr[103X │ [3Xstr[103X (long form) │ mode description134────┼─────────────────┼────────────────────────────────────────────────────────────────────135│ │136"" │ "" │ the default mode, i.e. the computation protocol won't be visible137│ │ ([10XhomalgMode[110X( ) is a short form for [10XhomalgMode[110X( "" ))138│ │139"b" │ "basic" │ make the basic matrix operations visible + [10XhomalgMode[110X( "logic" )140│ │141"d" │ "debug" │ same as "basic" but also makes [10XRow/ColumnReducedEchelonForm[110X visible142│ │143"l" │ "logic" │ make the logical methods in [5XLIMAT[105X and [5XCOLEM[105X visible144│ │145────┴─────────────────┴────────────────────────────────────────────────────────────────────146147[33X[0;0YAll modes other than the "default"-mode only set their specific values and148leave the other values untouched, which allows combining them to some149extent. This also means that in order to get from one mode to a new mode150(without the aim to combine them) one needs to reset to the "default"-mode151first. This can be done using [10XhomalgMode[110X( "", new_mode );[133X152153[4X[32X Code [32X[104X154[4XInstallGlobalFunction( homalgMode,[104X155[4X function( arg )[104X156[4X local nargs, mode, s;[104X157[4X [104X158[4X nargs := Length( arg );[104X159[4X [104X160[4X if nargs = 0 or ( IsString( arg[1] ) and arg[1] = "" ) then[104X161[4X mode := "default";[104X162[4X elif IsString( arg[1] ) then ## now we know, the string is not empty[104X163[4X s := arg[1];[104X164[4X if LowercaseString( s{[1]} ) = "b" then[104X165[4X mode := "basic";[104X166[4X elif LowercaseString( s{[1]} ) = "d" then[104X167[4X mode := "debug";[104X168[4X elif LowercaseString( s{[1]} ) = "l" then[104X169[4X mode := "logic";[104X170[4X else[104X171[4X mode := "";[104X172[4X fi;[104X173[4X else[104X174[4X Error( "the first argument must be a string\n" );[104X175[4X fi;[104X176[4X [104X177[4X if mode = "default" then[104X178[4X HOMALG_MATRICES.color_display := false;[104X179[4X for s in HOMALG_MATRICES.matrix_logic_infolevels do[104X180[4X SetInfoLevel( s, 1 );[104X181[4X od;[104X182[4X SetInfoLevel( InfoHomalgBasicOperations, 1 );[104X183[4X elif mode = "basic" then[104X184[4X SetInfoLevel( InfoHomalgBasicOperations, 3 );[104X185[4X homalgMode( "logic" );[104X186[4X elif mode = "debug" then[104X187[4X SetInfoLevel( InfoHomalgBasicOperations, 4 );[104X188[4X homalgMode( "logic" );[104X189[4X elif mode = "logic" then[104X190[4X HOMALG_MATRICES.color_display := true;[104X191[4X for s in HOMALG_MATRICES.matrix_logic_infolevels do[104X192[4X SetInfoLevel( s, 2 );[104X193[4X od;[104X194[4X fi;[104X195[4X [104X196[4X if nargs > 1 and IsString( arg[2] ) then[104X197[4X homalgMode( arg[2] );[104X198[4X fi;[104X199[4X [104X200[4Xend );[104X201[4X[32X[104X202203204205