Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 78 additions & 20 deletions gap/singular.g
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,32 @@



BindGlobal( "ParseGapIntmatToSingBigintmat", function ( mat )
local str, dim, i, j;
dim := DimensionsMat( mat );
str := "(x->{bigintmat m[";
Append( str, String( dim[1] ) );
Append( str, "][");
Append( str, String( dim[2] ) );
Append( str, "] = " );
for i in [ 1 .. dim[1] ] do
Append( str, "\n" );
for j in [ 1 .. dim[2] ] do
Append( str, String( mat[i][j] ) );
if not (i = dim[1] and j = dim[2]) then
Append( str, "," );
fi;
if j mod 50 = 0 then
Append( str, "\n" );

Check warning on line 1163 in gap/singular.g

View check run for this annotation

Codecov / codecov/patch

gap/singular.g#L1163

Added line #L1163 was not covered by tests
fi;
od;
od;
Append( str, "; m})(0)" );
return str;
end );



BindGlobal( "ParseGapIntvecToSingIntvec", function ( vec )
local str, dim, i;
dim := Length( vec );
Expand All @@ -1163,6 +1189,24 @@



BindGlobal( "ParseGapIntvecToSingBigintvec", function ( vec )
local str, dim, i;
dim := Length( vec );
str := "bigintvec(";
for i in [ 1 .. dim ] do
Append( str, String( vec[i] ) );
if not i = dim then
Append( str, "," );
fi;
if i mod 50 = 0 then
Append( str, "\n" );
fi;
od;
Append( str, ")" );
return str;

Check warning on line 1206 in gap/singular.g

View check run for this annotation

Codecov / codecov/patch

gap/singular.g#L1194-L1206

Added lines #L1194 - L1206 were not covered by tests
end );



BindGlobal( "ParseGapModuleToSingModule", function ( M )

Expand Down Expand Up @@ -1851,10 +1895,37 @@
intvec := [ "Variables of type intvec are lists of integers.",
obj -> IsRowVector( obj ) and ForAll( obj, IsSingularInt ),
ParseGapIntvecToSingIntvec,
obj -> List( SplitString( obj, ',' ), Int ),
obj -> List( SplitString( obj, ',', ' ' ), Int ),
],


bigint := [ "Variables of type bigint represent arbitrarily long integers.",
obj -> IsInt( obj ) and ( SingularVersion >= 4000 or
# because it may be still unknown
SingularVersion = 0 ),
String,
Int
],


bigintmat := [ "Variables of type bigintmat are matrices with arbitrarily \
long integer entries.",
obj -> IsMatrix( obj ) and
ForAll( obj, x -> ForAll( x, IsInt ) ) and
( SingularVersion >= 4000 or SingularVersion = 0 ),
ParseGapIntmatToSingBigintmat,
],


bigintvec := [ "Variables of type bigintvec are lists of arbitrarily long \
integers.",
obj -> IsRowVector( obj ) and ForAll( obj, IsInt ) and
( SingularVersion >= 4400 or SingularVersion = 0 ),
ParseGapIntvecToSingBigintvec,
obj -> List( SplitString( obj, ',', ' ' ), Int ),
],


link := [ "Links are the communication channels of SINGULAR, i.e., \
something SINGULAR can write to and/or read from.",
ReturnFalse, # not implemented
Expand Down Expand Up @@ -2004,19 +2075,6 @@
],


bigint := [ "Variables of type bigint represent the arbitrary long \
integers. They can only be constructed from other types (int, number).",
# obj -> IsInt( obj ) and ( SingularVersion >= 3002 or
# # because it may be still unknown
# SingularVersion = 0 ),
# obj -> Concatenation( "bigint(", String( obj ), ")" ),
ReturnFalse,
,
Int
],



package := [ "The data type package is used to group identifiers into \
collections. Introduced in Singular 3.0.0.",
ReturnFalse, # makes no sense in Gap
Expand All @@ -2030,10 +2088,10 @@
# the record entries in the order that we have given them (a change introduced
# in GAP 4.5). So we here list the order in which they should be tested

SingularDataTypeTestOrder := [ "def", "ideal", "int", "intmat", "intvec", "link",
"map", "matrix", "module", "number", "poly", "proc", "qring", "resolution",
"ring", "string", "vector", "list", "?unknown type?", "none", "bigint",
"package" ];
SingularDataTypeTestOrder := [ "def", "ideal", "int", "intmat", "intvec",
"bigint", "bigintvec", "bigintmat", "link", "map", "matrix", "module",
"number", "poly", "proc", "qring", "resolution", "ring", "string", "vector",
"list", "?unknown type?", "none", "package" ];

# And check for sanity that this set is same as the names in the record
if Set(SingularDataTypeTestOrder) <> Set(RecNames(SingularDataTypes)) then
Expand Down Expand Up @@ -2160,8 +2218,8 @@
return ideal;


# intmat
elif type_output = "intmat" then
# intmat / bigintmat
elif type_output = "intmat" or type_output = "bigintmat" then
list:= List( SplitString( obj, ',' ,' '), Int );
command := Concatenation( "nrows( ", singname, " );" );
nrows := Int( SingCommandInStreamOutStream( "", command ) );
Expand Down
21 changes: 14 additions & 7 deletions tst/testall.tst
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,10 @@ gap> intmat:=[[12,34],[56,78]];
[ [ 12, 34 ], [ 56, 78 ] ]
gap> intvec:=[98765,4321];
[ 98765, 4321 ]
gap> bigint:=18446744073709551616;
18446744073709551616
gap> bigintmat:=[[18446744073709551616,34],[56,432109876543210]];
[ [ 18446744073709551616, 34 ], [ 56, 432109876543210 ] ]
gap> map:=AlgebraGeneralMappingByImages(ring,ring,[x,y],[x+y,x-y]);
[ x, y ] -> [ x+y, x-y ]
gap> matrix:=[[x+y, x*y],[x+y+x*y,x^2+y^2]];
Expand All @@ -557,27 +561,29 @@ gap> vector:=[x^3+y^3,+(5)^3*x^2+Z(5)^3,x*y+y^2+Z(5)^3*y];

#
gap> list1 := [ ideal, int, intmat, intvec, map, matrix, module, number,
> poly, proc, ring, string, vector];
> poly, proc, ring, string, vector, bigint, bigintmat ];
[ <two-sided ideal in GF(5)[x,y], (2 generators)>, 123456,
[ [ 12, 34 ], [ 56, 78 ] ], [ 98765, 4321 ], [ x, y ] -> [ x+y, x-y ],
[ [ x+y, x*y ], [ x*y+x+y, x^2+y^2 ] ],
<free left module over PolynomialRing( GF(5), ["x", "y"] ), with
2 generators>, Z(5)^3, x^3+y^3+Z(5)^3*x^2+Z(5)^3*x*y+y^2+Z(5)^3*y,
function( ) ... end, GF(5)[x,y], "ciao",
[ x^3+y^3, Z(5)^3, x*y+y^2+Z(5)^3*y ] ]
[ x^3+y^3, Z(5)^3, x*y+y^2+Z(5)^3*y ], 18446744073709551616,
[ [ 18446744073709551616, 34 ], [ 56, 432109876543210 ] ] ]
gap> List( list1, SingularType);
[ "ideal", "int", "intmat", "intvec", "map", "matrix", "module", "number",
"poly", "proc", "ring", "string", "vector" ]
"poly", "proc", "ring", "string", "vector", "bigint", "bigintmat" ]

#
gap> list2 := [ ideal, int, intmat, intvec, matrix, module, number,
> poly, string, vector];
> poly, string, vector, bigint, bigintmat ];
[ <two-sided ideal in GF(5)[x,y], (2 generators)>, 123456,
[ [ 12, 34 ], [ 56, 78 ] ], [ 98765, 4321 ],
[ [ x+y, x*y ], [ x*y+x+y, x^2+y^2 ] ],
<free left module over PolynomialRing( GF(5), ["x", "y"] ), with
2 generators>, Z(5)^3, x^3+y^3+Z(5)^3*x^2+Z(5)^3*x*y+y^2+Z(5)^3*y,
"ciao", [ x^3+y^3, Z(5)^3, x*y+y^2+Z(5)^3*y ] ]
"ciao", [ x^3+y^3, Z(5)^3, x*y+y^2+Z(5)^3*y ], 18446744073709551616,
[ [ 18446744073709551616, 34 ], [ 56, 432109876543210 ] ] ]
gap> list3 := SingularInterface( "id_func", [list2], "def" );
#I running SingularInterface( "id_func", [ "list" ], "def" )...
#I done SingularInterface.
Expand All @@ -591,7 +597,8 @@ gap> list3 := SingularInterface( "id_func", [list2], "def" );
[ [ x+y, x*y ], [ x*y+x+y, x^2+y^2 ] ],
<free left module over PolynomialRing( GF(5), ["x", "y"] ), with
2 generators>, Z(5)^3, x^3+y^3+Z(5)^3*x^2+Z(5)^3*x*y+y^2+Z(5)^3*y,
"ciao", [ x^3+y^3, Z(5)^3, x*y+y^2+Z(5)^3*y ] ]
"ciao", [ x^3+y^3, Z(5)^3, x*y+y^2+Z(5)^3*y ], 18446744073709551616,
[ [ 18446744073709551616, 34 ], [ 56, 432109876543210 ] ] ]

#
gap> for i in [2,3,4,5,7,8,9,10] do
Expand Down Expand Up @@ -619,7 +626,7 @@ gap> SingularCommand("","transpose(mm2)==mm");
# this should be at the end of the test file:
#
gap> [ SingularNr.Process, SingularNr.Input, SingularNr.Output ];
[ 0, 1136, 1136 ]
[ 0, 1156, 1156 ]
gap> SingularBaseRing;
GF(5)[x,y]
gap> CoefficientsRing( SingularBaseRing );
Expand Down