Rank: Advanced Member Groups: Registered, Advanced Member Joined: 13/01/2012(UTC) Posts: 2,647 Location: Italy Was thanked: 1329 time(s) in 875 post(s)
|
Hi someone can confirm this issue? seem that: - it's not related with optimization - appears only when you redefine an internal variable inside a line() in a user-function, making them dimensionless best regards, w3b5urf3r Edited by user 09 July 2012 12:07:52(UTC)
| Reason: Not specified File Attachment(s): Davide Carpi attached the following image(s): |
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects |
|
|
|
Rank: Administration Groups: Registered, Advanced Member Joined: 23/06/2009(UTC) Posts: 1,740 Was thanked: 318 time(s) in 268 post(s)
|
Hello w3b5urf3r,
This is related to changing the function arguments. As your function is defined as f1(x) and you actually change x then if you call your function with f1(A) then A will change as well. Your function f4(x) actually changed its argument too.
Regards, Radovan
|
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!" |
1 user thanked omorr for this useful post.
|
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 13/01/2012(UTC) Posts: 2,647 Location: Italy Was thanked: 1329 time(s) in 875 post(s)
|
Originally Posted by: omorr Hello w3b5urf3r,
This is related to changing the function arguments. As your function is defined as f1(x) and you actually change x then if you call your function with f1(A) then A will change as well. Your function f4(x) actually changed its argument too.
Regards, Radovan
Hi Omorr you're right, f4(x) cause the same issue... I don't know if it's a bug or a feature, but it's quite strange for me... In my mind I think that the input variable should not be modified, unless the change it's invoked directly (A:=something) best regards, w3b5urf3r Edited by user 14 July 2012 01:14:17(UTC)
| Reason: Not specified |
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects |
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 30/03/2011(UTC) Posts: 393
Was thanked: 132 time(s) in 113 post(s)
|
yes i don't like it either, i mean this global redefinition from within a function, i think this was a change introduced by Andrey for something related to future animation capabilities of smath
|
|
|
|
Rank: Administration Groups: Developers, Registered, Knovel Developers, Administrators, Advanced Member Joined: 11/07/2008(UTC) Posts: 1,616 Was thanked: 1978 time(s) in 666 post(s)
|
Hello.
Yes, this is by design. This feature called Output Arguments and it can be used within procedures (functions defined with line(..) at right). This allows to return any number of values from the function. One just should remember that changing value for the variable of the same name as defined in function's arguments for such functions will also override global value of that variable.
Regards.
|
1 user thanked Andrey Ivashov for this useful post.
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 05/03/2009(UTC) Posts: 433 Location: USA Was thanked: 17 time(s) in 15 post(s)
|
I don't get this Originally Posted by: smath One just should remember that changing value for the variable of the same name as defined in function's arguments for such functions will also override global value of that variable. I am running into a problem where I have f(x,y):=2x+y When I define x:=? and y:=? I get the correct result. However, WHEN I re-define x and y and reuse the function, the answer is ALL over the place. Can someone give an example explaining what Aundrey ment (see quote)
|
|
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 13/01/2012(UTC) Posts: 2,647 Location: Italy Was thanked: 1329 time(s) in 875 post(s)
|
Originally Posted by: ElSid I don't get this Originally Posted by: smath One just should remember that changing value for the variable of the same name as defined in function's arguments for such functions will also override global value of that variable. I am running into a problem where I have f(x,y):=2x+y When I define x:=? and y:=? I get the correct result. However, WHEN I re-define x and y and reuse the function, the answer is ALL over the place. Can someone give an example explaining what Aundrey ment (see quote) Hi, I think that the image below could be useful to explain the behavior Using f(a) the input variable - x, will be modified by the function; Using g(a) the input variable - y, doesn't change. regards, w3b5urf3r Edited by user 23 October 2012 21:22:52(UTC)
| Reason: Not specified Davide Carpi attached the following image(s): |
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects |
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 05/03/2009(UTC) Posts: 433 Location: USA Was thanked: 17 time(s) in 15 post(s)
|
w3b5urf3r See file I attached while you responded. See the grey non print area for page 2 and 3
|
|
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 13/01/2012(UTC) Posts: 2,647 Location: Italy Was thanked: 1329 time(s) in 875 post(s)
|
Originally Posted by: ElSid w3b5urf3r See file I attached while you responded. See the grey non print area for page 2 and 3 I see It's not related with the behavior of this topic, but with this: local and global variablesSimply change your function giving as input all variable parameters - so add: k.ins, k.pipe (and others, if needed) regards, w3b5urf3r Edited by user 23 October 2012 23:28:09(UTC)
| Reason: Not specified Davide Carpi attached the following image(s): |
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects |
1 user thanked Davide Carpi for this useful post.
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 05/03/2009(UTC) Posts: 433 Location: USA Was thanked: 17 time(s) in 15 post(s)
|
Quote:Simply change your function giving as input all variable parameters I had combined various sheets into one sheet and totally spaced the fact that the other variables were changing. Originally, the k's were fixed.
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.