Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: using references to rings and preimage computing
PostPosted: Thu Jun 27, 2013 11:44 am 
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();



Report this post
Top
  
Reply with quote  
 Post subject: Re: using references to rings and preimage computing
PostPosted: Fri Jun 28, 2013 3:22 am 

Joined: Wed May 25, 2005 4:16 pm
Posts: 178
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re: using references to rings and preimage computing
PostPosted: Mon Jul 01, 2013 12:43 am 
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();


Report this post
Top
  
Reply with quote  
 Post subject: Re: using references to rings and preimage computing
PostPosted: Mon Jul 01, 2013 1:49 pm 
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?


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

It is currently Thu Dec 14, 2017 12:04 pm
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group