Singular https://www.singular.uni-kl.de/forum/ |
|
Access local ring elements outside the procedure https://www.singular.uni-kl.de/forum/viewtopic.php?f=10&t=2850 |
Page 1 of 1 |
Author: | vinay [ Thu Apr 11, 2019 8:36 am ] |
Post subject: | Access local ring elements outside the procedure |
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 |
Author: | hannes [ Thu Apr 11, 2019 4:34 pm ] |
Post subject: | Re: Access local ring elements outside the procedure |
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 |
Page 1 of 1 | All times are UTC + 1 hour [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |