Back to Forum | View unanswered posts | View active topics
Topic review - using references to rings and preimage computing |
Author |
Message |
|
|
Post subject: |
Re: using references to rings and preimage computing |
|
|
hannes wrote: If you want to fix it, export parentRing.
To avoid usage of global variables, my solution was to define a local map object in the procedure instead utilizing the 'mapIdeal'. What amount of overhead is produced by creating a map object? Are the entries of 'mapIdeal' copied each time?
[quote="hannes"] If you want to fix it, export parentRing. [/quote] To avoid usage of global variables, my solution was to define a local map object in the procedure instead utilizing the 'mapIdeal'.
What amount of overhead is produced by creating a map object? Are the entries of 'mapIdeal' copied each time?
|
|
|
|
Posted: Mon Jul 01, 2013 1:49 pm |
|
|
|
|
|
Post subject: |
Re: using references to rings and preimage computing |
|
|
hannes wrote: [...] Another point: assignment of rings is always via reference, no need to use system(reference) or system(shared) for that. Are you sure, that there is no need for ring references? It was for me impossible to set ring attributes without using references: Code: system("reference");
proc setAttrib( rng, attrubuteName, attributeVal) { attrib( rng, attrubuteName, attributeVal); }
proc setAttribOfRef( pRngRef, attrubuteName, attributeVal) { attrib( pRngRef ,attrubuteName, attributeVal); }
proc minimalExample() { string attributeName = "name"; string attributeVal = "it works!";
ring parentRing = integer,(x,y,z),dp; setAttrib( parentRing,attributeName,attributeVal); if ( attrib( parentRing, attributeName )<> attributeVal ) { print("setting attrubute by passing ordinary copy failed"); } else { print("setting attrubute by passing ordinary copy succeeded"); }
reference rngRef = parentRing;
setAttribOfRef( rngRef,attributeName,attributeVal); if ( attrib( parentRing, attributeName )<> attributeVal ) { print("setting attrubute by passing reference failed"); } else { print("setting attrubute by passing reference succeeded !"); } }
minimalExample();
[quote="hannes"][...] Another point: assignment of rings is always via reference, no need to use system(reference) or system(shared) for that.[/quote]
Are you sure, that there is no need for ring references?
It was for me impossible to set ring attributes without using references:
[code] system("reference");
proc setAttrib( rng, attrubuteName, attributeVal) { attrib( rng, attrubuteName, attributeVal); }
proc setAttribOfRef( pRngRef, attrubuteName, attributeVal) { attrib( pRngRef ,attrubuteName, attributeVal); }
proc minimalExample() { string attributeName = "name"; string attributeVal = "it works!";
ring parentRing = integer,(x,y,z),dp; setAttrib( parentRing,attributeName,attributeVal); if ( attrib( parentRing, attributeName )<> attributeVal ) { print("setting attrubute by passing ordinary copy failed"); } else { print("setting attrubute by passing ordinary copy succeeded"); }
reference rngRef = parentRing;
setAttribOfRef( rngRef,attributeName,attributeVal); if ( attrib( parentRing, attributeName )<> attributeVal ) { print("setting attrubute by passing reference failed"); } else { print("setting attrubute by passing reference succeeded !"); } }
minimalExample(); [/code]
|
|
|
|
Posted: Mon Jul 01, 2013 12:43 am |
|
|
|
|
|
Post subject: |
Re: using references to rings and preimage computing |
|
|
The preimage ring of phi (parentRing) is a local variable of testPreimage1 and therefore not available in computeImage.
If you want to fix it, export parentRing.
Another point: assignment of rings is always via reference, no need to use system(reference) or system(shared) for that.
The preimage ring of phi (parentRing) is a local variable of testPreimage1 and therefore not available in computeImage.
If you want to fix it, export parentRing.
Another point: assignment of rings is always via reference, no need to use system(reference) or system(shared) for that.
|
|
|
|
Posted: Fri Jun 28, 2013 3:22 am |
|
|
|
|
|
Post subject: |
using references to rings and preimage computing |
|
|
What is the best way to fix the following failing preimage computation, define in 'computePreimage' a local map lphi? Code: system("reference"); system("shared");
proc computeImage( parentRingRef, childRingRef, srcIdealName, dstIdealName ) { def refRing = basering;
def localChildRing = link(childRingRef); def localParentRing = link(parentRingRef); setring localChildRing;
string mapCmd = "def " + dstIdealName + " = phi("+srcIdealName+");"; execute(mapCmd);
string exportCmd = "export( "+dstIdealName+");"; execute( exportCmd );
setring refRing; kill localChildRing; kill localParentRing; return (0); }
proc computePreimage (parentRingRef,childRingRef, srcIdealName, dstIdealName) { def localParentRing = link (parentRingRef); def localChildRing = link (childRingRef); def refRing = basering;
setring localParentRing; string mapCmd = "def " + dstIdealName + " = preimage( localChildRing, phi, " + srcIdealName + ");"; execute( mapCmd ); string exportCmd = "export( " + dstIdealName + " );"; execute( exportCmd );
setring refRing; kill localChildRing; kill localParentRing; return ( 0 ); }
proc testPreimage1() { ring parentRing = integer,(x,y,z),dp; reference parentRingRef = parentRing; ideal I = x^3+y;
ring childRing = integer,(X(1),X(2)),dp; reference childRingRef = childRing;
setring childRing;
ideal cX = X(1)^3+X(2);
ideal mapIdeal = X(1),X(2); export(mapIdeal); map phi = parentRing, mapIdeal; export(phi); computeImage(parentRingRef, childRingRef, "I", "mappedI");
computePreimage(parentRingRef, childRingRef, "cX", "pX"); }
// fails: testPreimage1();
What is the best way to fix the following failing preimage computation, define in 'computePreimage' a local map lphi?
[code] system("reference"); system("shared");
proc computeImage( parentRingRef, childRingRef, srcIdealName, dstIdealName ) { def refRing = basering;
def localChildRing = link(childRingRef); def localParentRing = link(parentRingRef); setring localChildRing;
string mapCmd = "def " + dstIdealName + " = phi("+srcIdealName+");"; execute(mapCmd);
string exportCmd = "export( "+dstIdealName+");"; execute( exportCmd );
setring refRing; kill localChildRing; kill localParentRing; return (0); }
proc computePreimage (parentRingRef,childRingRef, srcIdealName, dstIdealName) { def localParentRing = link (parentRingRef); def localChildRing = link (childRingRef); def refRing = basering;
setring localParentRing; string mapCmd = "def " + dstIdealName + " = preimage( localChildRing, phi, " + srcIdealName + ");"; execute( mapCmd ); string exportCmd = "export( " + dstIdealName + " );"; execute( exportCmd );
setring refRing; kill localChildRing; kill localParentRing; return ( 0 ); }
proc testPreimage1() { ring parentRing = integer,(x,y,z),dp; reference parentRingRef = parentRing; ideal I = x^3+y;
ring childRing = integer,(X(1),X(2)),dp; reference childRingRef = childRing;
setring childRing;
ideal cX = X(1)^3+X(2);
ideal mapIdeal = X(1),X(2); export(mapIdeal); map phi = parentRing, mapIdeal; export(phi); computeImage(parentRingRef, childRingRef, "I", "mappedI");
computePreimage(parentRingRef, childRingRef, "cX", "pX"); }
// fails: testPreimage1();
[/code]
|
|
|
|
Posted: Thu Jun 27, 2013 11:44 am |
|
|
|
|
|
It is currently Fri May 13, 2022 10:58 am
|
|