Post a reply
Username:
Note:If not registered, provide any username. For more comfort, register here.
Subject:
Message body:
Enter your message here, it may contain no more than 60000 characters. 

Smilies
:D :) :( :o :shock: :? 8) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen:
Font size:
Font colour
Options:
BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON
Disable BBCode
Disable smilies
Do not automatically parse URLs
Confirmation of post
To prevent automated posts the board requires you to enter a confirmation code. The code is displayed in the image you should see below. If you are visually impaired or cannot otherwise read this code please contact the %sBoard Administrator%s.
Confirmation code:
Enter the code exactly as it appears. All letters are case insensitive, there is no zero.
   

Topic review - Procedure With External Parameters
Author Message
  Post subject:  Re: Procedure With External Parameters  Reply with quote
With execute the polynomial will just be displayed but you can't work with it.
Even an assignment afterwards like poly g = _; is not possible.

To have access, you must enclose the string (variable) nameofpoly into
the backticks ` ` . These are the delimiter for name substitution

See Special characters:
http://www.singular.uni-kl.de/Manual/la ... .htm#SEC63

Modified solution:
Code:
> ring R = 0, (x,y,z), dp;
> poly f = x+y+z;
> string s = "f";
> `s`;
x+y+z

> proc p1mod(def R, string nameofpoly)
{
    setring(R);
    poly g = `nameofpoly`;
    g = g+1;
    g;
}

> ring S = 0, x, dp;
> p1mod(R, "f");
x+y+z+1
Post Posted: Fri Sep 07, 2012 3:56 pm
  Post subject:  Re: Procedure With External Parameters  Reply with quote
One possibility is to define a procedure which takes the ring R as a parameter. Objects inside this ring can then be accessed by their names:

Code:
proc p1(def R, string nameofpoly)
{
    setring(R);
    execute(nameofpoly);
}

ring R = 0, (x,y,z), dp;
poly f = x+y+z;
ring S = 0, x, dp;
p1(R, "f");
x+y+z


Note that
Code:
proc p1(ring R, ...)

does not work, see http://www.singular.uni-kl.de/Manual/la ... .htm#SEC81.

Another possibility is to use user defined types ("newstructs"), see http://www.singular.uni-kl.de/Manual/la ... htm#SEC216.
Post Posted: Sat Sep 01, 2012 3:03 pm
  Post subject:  Procedure With External Parameters  Reply with quote
How can one define a procedure which may be called with parameters not in the current ring, such as "imap(R,f)", where the polynomial "f" belongs to the ring "R"?
Post Posted: Tue Aug 28, 2012 3:19 pm


It is currently Fri May 13, 2022 11:05 am
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group