## Implementation stuff for the external computer algebra system Maple.
#################################### # # global variables: # ####################################
BindGlobal( "HOMALG_IO_Maple",
rec(
cas := "maple", ## normalized name on which the user should have no control
name := "Maple",
executable := [ "maple_for_homalg", "maple14", "maple13", "maple12", "maple11", "maple10", "maple9", "maple" ], ## this list is processed from left to right
options := [ "-q" ],
BUFSIZE := 1024,
READY := "!$%&/(",
CUT_POS_BEGIN := 1, ## these are the most
CUT_POS_END := 4, ## delicate values!
eoc_verbose := ";",
eoc_quiet := ":",
error_stdout := "Error, ", ## a Maple specific
normalized_white_space := NormalizedWhitespace, ## a Maple specific
trim_display := function( str ) return str{ [ 1 .. Length( str ) - 36 ] }; end, ## a Maple specific
setring := _MapleHomalg_SetRing, ## a MapleHomalg specific define := ":=", delete := function( var, stream ) homalgSendBlocking( [ var, " := '", var, "'" ], "need_command", stream, "delete" ); end,
multiple_delete := _Maple_multiple_delete,
garbage_collector := function( stream ) homalgSendBlocking( [ "gc()" ], "need_command", stream, "garbage_collector" ); end,
prompt := "\033[01mmaple>\033[0m ",
output_prompt := "\033[1;34;47m<maple\033[0m ",
display_color := "\033[0;34m", #banner := function( s ) Print( s.lines{ [ 1 .. Length( s.lines ) - 36 ] } ); end, ## this line is commented since we must start Maple using the -q option, which unfortunately also suppresses the Maple banner
banner := "\
|\\^/| Launching Maple\n\
._|\\| |/|_. Copyright (c) Maplesoft, a division of Waterloo Maple Inc.\n\
\\ MAPLE / All rights reserved. Maple is a trademark of\n\
<____ ____> Waterloo Maple Inc.\n\
| ",
InitializeCASMacros := InitializeMapleMacros,
UseJacobsonNormalForm := false,
time := function( stream, t ) return Int( homalgSendBlocking( [ "floor(time() * 1000)" ], "need_output", stream, "time" ) ) - t; end,
)
);
#################################### # # global functions and variables: # ####################################
##
InstallGlobalFunction( _MapleHomalg_SetRing, function( R )
local stream;
stream := homalgStream( R );
## since _MapleHomalg_SetRing might be called from homalgSendBlocking, ## we first set the new active ring to avoid infinite loops:
stream.active_ring := R;
if IsBound( R!.MapleHomalgOptions ) then
homalgSendBlocking( [ R!.MapleHomalgOptions[1], "(\"set\",", R!.MapleHomalgOptions[2], ")" ], "need_command", "initialize" ); fi;
if IsBound( HOMALG_IO_Maple.setring_post ) then
homalgSendBlocking( HOMALG_IO_Maple.setring_post, "need_command", stream, "initialize" ); fi;
end );
##
InstallGlobalFunction( _Maple_multiple_delete, function( var_list, stream )
local str;
str := [ "for _del in ", String( var_list ), " do unassign(convert(_del,symbol)) od" ];
#################################### # # constructor functions and methods: # ####################################
##
InstallGlobalFunction( RingForHomalgInMapleUsingPIR, function( arg )
local nargs, stream, o, display_color, homalg_version, package_version,
ar, ext_obj, R, RP;
nargs := Length( arg );
if nargs > 1then if IsRecord( arg[nargs] ) and IsBound( arg[nargs].lines ) and IsBound( arg[nargs].pid ) then
stream := arg[nargs]; elif IshomalgExternalObjectRep( arg[nargs] ) or IsHomalgExternalRingRep( arg[nargs] ) then
stream := homalgStream( arg[nargs] ); fi; fi;
if not IsBound( stream ) then
stream := LaunchCAS( "HOMALG_IO_Maple" ); if not IsBound( stream.path_to_maple_packages ) then## each component in HOMALG_IO_Maple is now in the stream
stream.path_to_maple_packages := Concatenation( PackageInfo( "RingsForHomalg" )[1].InstallationPath, "/maple" ); fi;
homalgSendBlocking( [ "libname := \"", stream.path_to_maple_packages, "\",libname" ], "need_command", stream, "initialize" );
o := 0; else
o := 1; fi;
if ( not ( IsBound( HOMALG_IO.show_banners ) and HOMALG_IO.show_banners = false )
and not ( IsBound( HOMALG_IO.show_maple_package_banner ) and HOMALG_IO.show_maple_package_banner = false )
and not ( IsBound( stream.show_banner ) and stream.show_banner = false ) )
and not ( IsBound( stream.show_banner_PIR ) and stream.show_banner_PIR = false ) then
if IsBound( stream.color_display ) then
display_color := stream.color_display; else
display_color := ""; fi;
## leave the below indentation untouched!
Print( display_color, "\
PIR - Maple package loaded (version: ", package_version, ")\n\
Copyright (C) (2004-2006)\n\
Lehrstuhl B fuer Mathematik, RWTH Aachen, Germany\n\
(will be used as a ring package via Maple's homalg (ver: ", homalg_version, "))\033[0m\n\
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
##
InstallGlobalFunction( RingForHomalgInMapleUsingInvolutive, function( arg )
local nargs, stream, o, display_color, homalg_version, package_version,
var, ar, ext_obj, R, RP;
nargs := Length( arg );
if nargs > 1then if IsRecord( arg[nargs] ) and IsBound( arg[nargs].lines ) and IsBound( arg[nargs].pid ) then
stream := arg[nargs]; elif IshomalgExternalObjectRep( arg[nargs] ) or IsHomalgExternalRingRep( arg[nargs] ) then
stream := homalgStream( arg[nargs] ); fi; fi;
if not IsBound( stream ) then
stream := LaunchCAS( "HOMALG_IO_Maple" ); if not IsBound( stream.path_to_maple_packages ) then## each component in HOMALG_IO_Maple is now in the stream
stream.path_to_maple_packages := Concatenation( PackageInfo( "RingsForHomalg" )[1].InstallationPath, "/maple" ); fi;
homalgSendBlocking( [ "libname := \"", stream.path_to_maple_packages, "\",libname" ], "need_command", stream, "initialize" );
o := 0; else
o := 1; fi;
if ( not ( IsBound( HOMALG_IO.show_banners ) and HOMALG_IO.show_banners = false )
and not ( IsBound( HOMALG_IO.show_maple_package_banner ) and HOMALG_IO.show_maple_package_banner = false )
and not ( IsBound( stream.show_banner ) and stream.show_banner = false ) )
and not ( IsBound( stream.show_banner_Involutive ) and stream.show_banner_Involutive = false ) then
if IsBound( stream.color_display ) then
display_color := stream.color_display; else
display_color := ""; fi;
## leave the below indentation untouched!
Print( display_color, "\
Involutive - Maple package loaded (version: ", package_version, ")\n\
Copyright (C) (2000-2009) Carlos F. Cid and Daniel Robertz\n\
Lehrstuhl B fuer Mathematik, RWTH Aachen, Germany\n\
(will be used as a ring package via Maple's homalg (ver: ", homalg_version, "))\033[0m\n\
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
if ( not ( IsBound( HOMALG_IO.show_banners ) and HOMALG_IO.show_banners = false )
and not ( IsBound( HOMALG_IO.show_maple_package_banner ) and HOMALG_IO.show_maple_package_banner = false )
and not ( IsBound( stream.show_banner ) and stream.show_banner = false ) )
and not ( IsBound( stream.show_banner_QuillenSuslin ) and stream.show_banner_QuillenSuslin = false ) then
if IsBound( stream.color_display ) then
display_color := stream.color_display; else
display_color := ""; fi;
Print( display_color, "\
QuillenSuslin - Maple package loaded (version: ", package_version, ")\n\
Copyright (C) (2003-2008) Anna Fabianska\n\
Lehrstuhl B fuer Mathematik, RWTH Aachen, Germany\n\
(will be used as a ring package via Maple's homalg (ver: ", homalg_version, "))\033[0m\n\
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
stream.show_banner_QuillenSuslin := false;
fi;
if IsString( arg[1] ) then
var := arg[1]; else
var := Flat( [ "[", JoinStringsWithSeparator( arg[1] ), "]" ] ); fi;
ar := [ [ var, ",", "copy(`Involutive/homalg`)" ], TheTypeHomalgExternalRingObjectInMapleUsingInvolutive, IsCommutative, stream, "CreateHomalgRing" ];
if nargs > 1then
ar := Concatenation( ar, arg{[ 2 .. nargs - o ]} ); fi;
ext_obj := CallFuncList( homalgSendBlocking, ar );
R := CreateHomalgExternalRing( ext_obj, TheTypeHomalgExternalRingInMaple, IsCommutative );
## we need homalg_options(matrix,...) until `homalg/Involutive/BasisQS` is fixed
homalgSendBlocking( [ "`homalg/homalg_options`(matrix,", R, "[-1])" ], "need_command", "initialize" );
homalgSendBlocking( [ R, "[-1][BestBasis]:=`InvolutiveQS/homalg`[BestBasis]" ], "need_command", "initialize" );
_MapleHomalg_SetRing( R );
LetWeakPointerListOnExternalObjectsContainRingCreationNumbers( R );
##
InstallGlobalFunction( RingForHomalgInMapleUsingJanet, function( arg )
local nargs, stream, o, display_color, homalg_version, package_version,
var, ar, ext_obj, R, RP_BestBasis, RP;
nargs := Length( arg );
if nargs > 1then if IsRecord( arg[nargs] ) and IsBound( arg[nargs].lines ) and IsBound( arg[nargs].pid ) then
stream := arg[nargs]; elif IshomalgExternalObjectRep( arg[nargs] ) or IsHomalgExternalRingRep( arg[nargs] ) then
stream := homalgStream( arg[nargs] ); fi; fi;
if not IsBound( stream ) then
stream := LaunchCAS( "HOMALG_IO_Maple" ); if not IsBound( stream.path_to_maple_packages ) then## each component in HOMALG_IO_Maple is now in the stream
stream.path_to_maple_packages := Concatenation( PackageInfo( "RingsForHomalg" )[1].InstallationPath, "/maple" ); fi;
homalgSendBlocking( [ "libname := \"", stream.path_to_maple_packages, "\",libname" ], "need_command", stream, "initialize" );
o := 0; else
o := 1; fi;
if ( not ( IsBound( HOMALG_IO.show_banners ) and HOMALG_IO.show_banners = false )
and not ( IsBound( HOMALG_IO.show_maple_package_banner ) and HOMALG_IO.show_maple_package_banner = false )
and not ( IsBound( stream.show_banner ) and stream.show_banner = false ) )
and not ( IsBound( stream.show_banner_Janet ) and stream.show_banner_Janet = false ) then
if IsBound( stream.color_display ) then
display_color := stream.color_display; else
display_color := ""; fi;
## leave the below indentation untouched!
Print( display_color, "\
Janet - Maple package loaded (version: ", package_version, ")\n\
Copyright (C) (2000-2009) Carlos F. Cid and Daniel Robertz\n\
Lehrstuhl B fuer Mathematik, RWTH Aachen, Germany\n\
(will be used as a ring package via Maple's homalg (ver: ", homalg_version, "))\033[0m\n\
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
stream.show_banner_Janet := false;
fi;
if IsString( arg[1] ) then
var := arg[1]; else
var := Flat( [ "[", JoinStringsWithSeparator( arg[1] ), "]" ] ); fi;
ar := [ [ var, ",", "copy(`Janet/homalg`)" ], TheTypeHomalgExternalRingObjectInMapleUsingJanet, stream, "CreateHomalgRing" ];
if nargs > 1then
ar := Concatenation( ar, arg{[ 2 .. nargs - o ]} ); fi;
ext_obj := CallFuncList( homalgSendBlocking, ar );
R := CreateHomalgExternalRing( ext_obj, TheTypeHomalgExternalRingInMaple );
if IsBound( HOMALG_IO_Maple.UseJacobsonNormalForm ) and
HOMALG_IO_Maple.UseJacobsonNormalForm = true and
homalgSendBlocking( [ "nops(", R, "[1])" ], "need_output" ) = "1"then
homalgSendBlocking( [ R, "[-1][BestBasis]:=`Janet1/homalg`[BestBasis]" ], "need_command", "initialize" );
RP := homalgTable( R );
RP_BestBasis := ShallowCopy( CommonHomalgTableForMapleHomalgBestBasis );
Perform( NamesOfComponents( RP_BestBasis ), function( component ) RP!.(component) := RP_BestBasis.(component); end ); fi;
SetIsLocalizedWeylRing( R, true );
SetRingProperties( R, var );
return R;
end );
##
InstallGlobalFunction( RingForHomalgInMapleUsingJanetOre, function( arg )
local nargs, stream, o, display_color, homalg_version, package_version,
ar, ext_obj, R, RP;
nargs := Length( arg );
if nargs > 1then if IsRecord( arg[nargs] ) and IsBound( arg[nargs].lines ) and IsBound( arg[nargs].pid ) then
stream := arg[nargs]; elif IshomalgExternalObjectRep( arg[nargs] ) or IsHomalgExternalRingRep( arg[nargs] ) then
stream := homalgStream( arg[nargs] ); fi; fi;
if not IsBound( stream ) then
stream := LaunchCAS( "HOMALG_IO_Maple" ); if not IsBound( stream.path_to_maple_packages ) then## each component in HOMALG_IO_Maple is now in the stream
stream.path_to_maple_packages := Concatenation( PackageInfo( "RingsForHomalg" )[1].InstallationPath, "/maple" ); fi;
homalgSendBlocking( [ "libname := \"", stream.path_to_maple_packages, "\",libname" ], "need_command", stream, "initialize" );
o := 0; else
o := 1; fi;
if ( not ( IsBound( HOMALG_IO.show_banners ) and HOMALG_IO.show_banners = false )
and not ( IsBound( HOMALG_IO.show_maple_package_banner ) and HOMALG_IO.show_maple_package_banner = false )
and not ( IsBound( stream.show_banner ) and stream.show_banner = false ) )
and not ( IsBound( stream.show_banner_JanetOre ) and stream.show_banner_JanetOre = false ) then
if IsBound( stream.color_display ) then
display_color := stream.color_display; else
display_color := ""; fi;
## leave the below indentation untouched!
Print( display_color, "\
JanetOre - Maple package loaded (version: ", package_version, ")\n\
Copyright (C) (2003-2009) Daniel Robertz\n\
Lehrstuhl B fuer Mathematik, RWTH Aachen, Germany\n\
(will be used as a ring package via Maple's homalg (ver: ", homalg_version, "))\033[0m\n\
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
return homalgSendBlocking( [ a, "+(", b, ")" ], "Sum" );
end;
return R;
end );
##
InstallGlobalFunction( RingForHomalgInMapleUsingOreModules, function( arg )
local nargs, stream, o, display_color, homalg_version, package_version,
ar, ext_obj, R, RP;
nargs := Length( arg );
if nargs > 1then if IsRecord( arg[nargs] ) and IsBound( arg[nargs].lines ) and IsBound( arg[nargs].pid ) then
stream := arg[nargs]; elif IshomalgExternalObjectRep( arg[nargs] ) or IsHomalgExternalRingRep( arg[nargs] ) then
stream := homalgStream( arg[nargs] ); fi; fi;
if not IsBound( stream ) then
stream := LaunchCAS( "HOMALG_IO_Maple" ); if not IsBound( stream.path_to_maple_packages ) then## each component in HOMALG_IO_Maple is now in the stream
stream.path_to_maple_packages := Concatenation( PackageInfo( "RingsForHomalg" )[1].InstallationPath, "/maple" ); fi;
homalgSendBlocking( [ "libname := \"", stream.path_to_maple_packages, "\",libname" ], "need_command", stream, "initialize" );
o := 0; else
o := 1; fi;
if ( not ( IsBound( HOMALG_IO.show_banners ) and HOMALG_IO.show_banners = false )
and not ( IsBound( HOMALG_IO.show_maple_package_banner ) and HOMALG_IO.show_maple_package_banner = false )
and not ( IsBound( stream.show_banner ) and stream.show_banner = false ) )
and not ( IsBound( stream.show_banner_OreModules ) and stream.show_banner_OreModules = false ) then
if IsBound( stream.color_display ) then
display_color := stream.color_display; else
display_color := ""; fi;
## leave the below indentation untouched!
Print( display_color, "\
OreModules - Maple package loaded (version: ", package_version, ")\n\
F. Chyzak, A. Quadrat, D. Robertz\033[0m\n\
(will be used as a ring package via Maple's homalg (ver: ", homalg_version, "))\033[0m\n\
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
function( R, indets )
local ar, r, var, nr_var, properties, param, c, stream, show_banner, S, l, RP;
ar := _PrepareInputForPolynomialRing( R, indets );
r := ar[1];
var := ar[2]; ## all indeterminates, relative and base
nr_var := ar[3]; ## the number of relative indeterminates
properties := ar[4];
param := ar[5];
c := Characteristic( R );
if Length( var ) = 1 and HasIsFieldForHomalg( R ) and IsFieldForHomalg( R ) then
stream := homalgStream( R ); if IsBound( stream.show_banner ) then
show_banner := stream.show_banner; fi;
stream.show_banner := false;
S := RingForHomalgInMapleUsingPIR( Flat( [ "[", Flat( var ), ",", String( c ), "]" ] ), R );
if IsBound( show_banner ) then
stream.show_banner := show_banner; else
Unbind( stream.show_banner ); fi; else if HasIndeterminatesOfPolynomialRing( R ) then
r := CoefficientsRing( R ); fi;
S := RingForHomalgInMapleUsingInvolutive( var, R );
if c > 0then if IsPrime( c ) then
homalgSendBlocking( [ "`Involutive/InvolutiveOptions`(\"char\",", c, ")" ], "need_command", R, "initialize" ); else
Error( "the coefficient ring Z/", c, "Z (", c, " non-prime) is not directly supported by Involutive yet\nYou can use the generic residue class ring constructor '/' provided by homalg after defining the ambient ring over the integers\nfor help type: ?homalg: constructor for residue class rings\n" ); fi; elif HasIsIntegersForHomalg( r ) and IsIntegersForHomalg( r ) then
homalgSendBlocking( [ "`Involutive/InvolutiveOptions`(\"rational\",false)" ], "need_command", R, "initialize" ); fi;
## we need to save the global options again after setting some of them
S!.MapleHomalgOptions :=
[ "`Involutive/InvolutiveOptions`",
homalgSendBlocking( [ "`Involutive/InvolutiveOptions`(\"get\")" ], R, "initialize" )
];
fi;
var := List( var, a -> HomalgExternalRingElement( a, S ) );
l := Length( var );
Perform( var, Name );
SetIsFreePolynomialRing( S, true );
if HasIndeterminatesOfPolynomialRing( R ) and IndeterminatesOfPolynomialRing( R ) <> [ ] then
SetBaseRing( S, R );
SetRelativeIndeterminatesOfPolynomialRing( S, var{[ l - nr_var + 1 .. l ]} ); fi;
if IsBound( R!.AssociatedPolynomialRing ) then
S!.AssociatedPolynomialRing := R!.AssociatedPolynomialRing * List( var{[ l - nr_var + 1 .. l ]}, Name ); fi;
function( R, indets )
local var, nr_var, der, nr_der, properties, stream, ar, r, c, S, RP;
#check whether base ring is polynomial and then extract needed data if HasIndeterminatesOfPolynomialRing( R ) and IsCommutative( R ) then
var := IndeterminatesOfPolynomialRing( R );
nr_var := Length( var ); else
Error( "base ring is not a polynomial ring" ); fi;
##compute the new indeterminates (the derivatives) for the ring and save them in der if IsString( indets ) and indets <> ""then
der := SplitString( indets, "," ); elif indets <> [ ] and ForAll( indets, i -> IsString( i ) and i <> "" ) then
der := indets; else
Error( "either a non-empty list of indeterminates or a comma separated string of them must be provided as the second argument\n" ); fi;
nr_der := Length( der );
if not(nr_var=nr_der) then
Error( "number of indeterminates in base ring does not equal the number of given derivations" ); fi;
if Intersection2( der , var ) <> [ ] then
Error( "the following indeterminates are already elements of the base ring: ", Intersection2( der , var ), "\n" ); fi;
properties := [ ];
stream := homalgStream( R );
ar := JoinStringsWithSeparator( Concatenation( der, List( var, Name ) ) );
ar := Concatenation( "[ [ ", ar, " ], [ ], [ " );
ar := Concatenation( ar, JoinStringsWithSeparator( List( [ 1 .. nr_var ], i -> Concatenation( "weyl(", der[i], ",", Name( var[i] ), ")" ) ) ), " ] ]" );
c := Characteristic( R );
r := R;
if HasIndeterminatesOfPolynomialRing( R ) then
r := CoefficientsRing( R ); fi;
S := RingForHomalgInMapleUsingJanetOre( ar, stream );
if c > 0then if IsPrime( c ) then
homalgSendBlocking( [ "`JanetOre/JanetOreOptions`(\"char\",", c, ")" ], "need_command", R, "initialize" ); else
Error( "the coefficient ring Z/", c, "Z (", c, " non-prime) is not directly supported by JanetOre yet\nYou can use the generic residue class ring constructor '/' provided by homalg after defining the ambient ring over the integers\nfor help type: ?homalg: constructor for residue class rings\n" ); fi; elif HasIsIntegersForHomalg( r ) and IsIntegersForHomalg( r ) then
homalgSendBlocking( [ "`JanetOre/JanetOreOptions`(\"rational\",false)" ], "need_command", R, "initialize" ); fi;
## we need to save the global options again after setting some of them
S!.MapleHomalgOptions :=
[ "`JanetOre/JanetOreOptions`",
homalgSendBlocking( [ "`JanetOre/JanetOreOptions`(\"get\")" ], R, "initialize" )
];
der := List( der , a -> HomalgExternalRingElement( a, S ) );
function( R, indets )
local ar, r, var, shift, param, base, stream, display_color, switch, ext_obj,
alg, b, n, steps, d, Y, RP, Ds, S, B, T;
ar := _PrepareInputForShiftAlgebra( R, indets );
r := ar[1];
var := ar[2];
shift := ar[3];
param := ar[4];
base := ar[5];
stream := homalgStream( R );
switch := ValueOption( "switch" );
b := Length( base );
n := Length( shift );
steps := ValueOption( "steps" );
if IsRat( steps ) then
steps := ListWithIdenticalEntries( n, steps ); elif not ( IsList( steps ) and Length( steps ) = n and ForAll( steps, IsRat ) ) then
steps := ListWithIdenticalEntries( n, 1 ); fi;
Ds := shift;
if IsIdenticalObj( switch, true ) then
Error( "not supported in Maple\n" );
else
if HasIsIntegersForHomalg( r ) and IsIntegersForHomalg( r ) then
Error( "not supported in Maple\n" );
else
ext_obj := ListN( Ds, var, {a,c} -> [ a, c ] );
if Set( steps ) = [ 1 ] then
ext_obj := List( ext_obj, a -> Concatenation( "`shift`=[", JoinStringsWithSeparator( a ), "], " ) ); elif Set( steps ) = [ -1 ] then
ext_obj := List( ext_obj, a -> Concatenation( "`dual_shift`=[", JoinStringsWithSeparator( a ), "], " ) ); else
Error( "these steps = ", steps, " are not yet supported\n" ); fi;
## as we are not yet done we cannot call CreateHomalgExternalRing ## to create a HomalgRing, and only then would homalgSendBlocking call stream.setring, ## so till then we have to prevent the garbage collector from stepping in
stream.DeletePeriod_save := stream.DeletePeriod;
stream.DeletePeriod := false;
Y := RingForHomalgInMapleUsingOreModules( ext_obj, R );
SetName( Y,
Concatenation(
Concatenation( RingName( r ), "(", JoinStringsWithSeparator( base ), ")(", JoinStringsWithSeparator( var ), ")" ), "<", JoinStringsWithSeparator( shift ), ">" ) );
## now it is safe to call the garbage collector
stream.DeletePeriod := stream.DeletePeriod_save;
Unbind( stream.DeletePeriod_save );
var := List( var , a -> HomalgExternalRingElement( a, Y ) );
Perform( var, Name );
shift := List( shift , a -> HomalgExternalRingElement( a, Y ) );
Perform( shift, Name );
SetIsRationalShiftAlgebra( Y, true );
SetBaseRing( Y, R );
SetRingProperties( Y, R, shift );
RP := homalgTable( Y );
if not ( HasIsFieldForHomalg( r ) and IsFieldForHomalg( r ) ) then
Unbind( RP!.IsUnit );
Unbind( RP!.GetColumnIndependentUnitPositions );
Unbind( RP!.GetRowIndependentUnitPositions );
Unbind( RP!.GetUnitPosition ); fi;
if HasIsIntegersForHomalg( r ) and IsIntegersForHomalg( r ) then
RP!.IsUnit := RP!.IsUnit_Z;
RP!.GetColumnIndependentUnitPositions := RP!.GetColumnIndependentUnitPositions_Z;
RP!.GetRowIndependentUnitPositions := RP!.GetRowIndependentUnitPositions_Z;
RP!.GetUnitPosition := RP!.GetUnitPosition_Z;
RP!.PrimaryDecomposition := RP!.PrimaryDecomposition_Z;
RP!.RadicalSubobject := RP!.RadicalSubobject_Z;
RP!.RadicalDecomposition := RP!.RadicalDecomposition_Z;
Unbind( RP!.CoefficientsOfUnreducedNumeratorOfWeightedHilbertPoincareSeries );
Unbind( RP!.MaximalDegreePart ); fi;
shift := List( shift, String );
## the "commutative" shift algebra
S := R * shift;
## does not reduce elements instantaneously ## S := HomalgQRingInSingular( AmbientRing( S ), RingRelations( S ) );
Y!.CommutativeShiftAlgebra := S;
## the Laurent algebra
B := BaseRing( R );
T := B * shift;
Y!.LaurentAlgebra := T;
#if not IsIdenticalObj( switch, true ) then # P!.SwitchedPseudoShiftAlgebra := PseudoShiftAlgebra( R, indets : switch := true ); #fi;
function( R, indets )
local ar, r, var, shift, param, base, stream, display_color, switch, ext_obj,
alg, b, n, steps, pairs, d, P, RP, Ds, D_s, S, B, T, Y;
ar := _PrepareInputForPseudoDoubleShiftAlgebra( R, indets );
r := ar[1];
var := ar[2];
shift := ar[3];
param := ar[4];
base := ar[5];
stream := homalgStream( R );
switch := ValueOption( "switch" );
b := Length( base );
n := Length( shift ) / 2;
steps := ValueOption( "steps" );
if IsRat( steps ) then
steps := ListWithIdenticalEntries( n, steps ); elif not ( IsList( steps ) and Length( steps ) = n and ForAll( steps, IsRat ) ) then
steps := ListWithIdenticalEntries( n, 1 ); fi;
pairs := ValueOption( "pairs" );
if IsIdenticalObj( pairs, true ) then
Ds := shift{List( [ 1 .. n ], i -> 2 * i - 1 )};
D_s := shift{List( [ 1 .. n ], i -> 2 * i )}; else
Ds := shift{[ 1 .. n ]};
D_s := shift{[ n + 1 .. 2 * n ]}; fi;
if IsIdenticalObj( switch, true ) then
Error( "not supported in Maple\n" );
else
if HasIsIntegersForHomalg( r ) and IsIntegersForHomalg( r ) then
Error( "not supported in Maple\n" );
else
if Set( steps ) = [ 1 ] then
ext_obj := ListN( Ds, D_s, var, {a,b,c} -> [ a, b, c ] ); elif Set( steps ) = [ -1 ] then
ext_obj := ListN( Ds, D_s, var, {a,b,c} -> [ b, a, c ] ); else
Error( "these steps = ", steps, " are not yet supported\n" ); fi;
ext_obj := List( ext_obj, a -> Concatenation( "`shift+dual_shift`=[", JoinStringsWithSeparator( a ), "], " ) );
ext_obj := Concatenation( ext_obj );
ext_obj := Concatenation( ext_obj, "characteristic=", String( Characteristic( R ) ), ", comm=[", JoinStringsWithSeparator( base ), "]" );
## as we are not yet done we cannot call CreateHomalgExternalRing ## to create a HomalgRing, and only then would homalgSendBlocking call stream.setring, ## so till then we have to prevent the garbage collector from stepping in
stream.DeletePeriod_save := stream.DeletePeriod;
stream.DeletePeriod := false;
P := RingForHomalgInMapleUsingOreModules( ext_obj, R );
SetName( P,
Concatenation(
Concatenation( RingName( r ), "(", JoinStringsWithSeparator( base ), ")(", JoinStringsWithSeparator( var ), ")" ), "<", JoinStringsWithSeparator( shift ), ">" ) );
## now it is safe to call the garbage collector
stream.DeletePeriod := stream.DeletePeriod_save;
Unbind( stream.DeletePeriod_save );
var := List( var , a -> HomalgExternalRingElement( a, P ) );
Perform( var, Name );
shift := List( shift , a -> HomalgExternalRingElement( a, P ) );
Perform( shift, Name );
SetIsRationalPseudoDoubleShiftAlgebra( P, true );
SetBaseRing( P, R );
SetRingProperties( P, R, shift );
RP := homalgTable( P );
if not ( HasIsFieldForHomalg( r ) and IsFieldForHomalg( r ) ) then
Unbind( RP!.IsUnit );
Unbind( RP!.GetColumnIndependentUnitPositions );
Unbind( RP!.GetRowIndependentUnitPositions );
Unbind( RP!.GetUnitPosition ); fi;
if HasIsIntegersForHomalg( r ) and IsIntegersForHomalg( r ) then
RP!.IsUnit := RP!.IsUnit_Z;
RP!.GetColumnIndependentUnitPositions := RP!.GetColumnIndependentUnitPositions_Z;
RP!.GetRowIndependentUnitPositions := RP!.GetRowIndependentUnitPositions_Z;
RP!.GetUnitPosition := RP!.GetUnitPosition_Z;
RP!.PrimaryDecomposition := RP!.PrimaryDecomposition_Z;
RP!.RadicalSubobject := RP!.RadicalSubobject_Z;
RP!.RadicalDecomposition := RP!.RadicalDecomposition_Z;
Unbind( RP!.CoefficientsOfUnreducedNumeratorOfWeightedHilbertPoincareSeries );
Unbind( RP!.MaximalDegreePart ); fi;
shift := List( shift, String );
## the "commutative" double-shift algebra
S := R * shift;
## does not reduce elements instantaneously ## S := HomalgQRingInSingular( AmbientRing( S ), RingRelations( S ) );
P!.CommutativeDoubleShiftAlgebra := S / ListN( Ds, D_s, {d, d_} -> ( d / S ) * ( d_ / S ) - 1 );
## the Laurent algebra
B := BaseRing( R );
T := B * shift;
P!.LaurentAlgebra := T / ListN( Ds, D_s, {d, d_} -> ( d / T ) * ( d_ / T ) - 1 );
## the double-shift algebra
Y := P / ListN( Ds, D_s, {d, d_} -> ( d / P ) * ( d_ / P ) - 1 );
if not IsHomalgExternalRingInMapleRep( R ) then
Error( "the last argument must be an external ring residing in Maple\n" ); fi;
s := "";
for ar in arg{[ 1 .. nargs-1 ]} do if IsString( ar ) then
s := Concatenation( s, ar, "," ); elif IsList( ar ) and Length( ar ) = 2 and ForAll( ar, IsString ) then
s := Concatenation( s, "\"", ar[1], "\"=", ar[2] , "," ); else
Error( "wrong argument: ", ar, "\n" ); fi;
od;
return homalgSendBlocking( [ "map(i->op(map(j->if ", M, "[i,j]<>", Zero( R ), " then [i,j,convert(", M, "[i,j],symbol)] fi, [$1..", NumberColumns( M ),"])), [$1..", NumberRows( M ),"])" ], "need_output", "GetSparseListOfHomalgMatrixAsString" );
end );
#################################### # # transfer methods: # ####################################
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.