Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Access local ring elements outside the procedure
PostPosted: Thu Apr 11, 2019 8:36 am 

Joined: Sat Oct 01, 2005 11:40 am
Posts: 40
Location: IIT Guwahati, Guwahati, Assam, INDIA
I am writing a small procedure. I am defining a ring inside the procedure (depending upon the parameter to the proc). The some computations are done and then procedure returns objects in this ring. Here is a sample code:

Code:
    LIB "ring.lib";
    int p = 7; // primality of p or prime power is checked beforehand.
   
    proc mytest( int n )
    {
        ring Qz = (0,z),x,dp;
        minpoly = rootofUnity( n );
        poly i = z^(n-1);
        return (i);
    }
    ring dummy;
    mytest(7);

I am getting the following message:
Quote:
? ring change during procedure call test: dummy -> Qz (level 1)

I also tried with `export Qz`, just before return, but doesnt help. Any solution?

Not sure if this is relevant: It seems the command `test` is already defined!!!
Code:
> test(4);
// ** Gerhard, use the option command
>



-- VInay


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re: Access local ring elements outside the procedure
PostPosted: Thu Apr 11, 2019 4:34 pm 

Joined: Wed May 25, 2005 4:16 pm
Posts: 275
One can not return (from a procedure) an object belonging to a ring which did not exist at the start of the procedure.
What you can do:
inside your procedure:
- create a ring inside the procedure
- create an object in this ring
- export the object (so it will not destroyed at the end of the procedure)
- return the ring
after the return:
- change into the returned ring
- access the object
see for an example: solve from solve.lib


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 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 Fri May 13, 2022 10:57 am
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group