Strange problem with units and range variables/implicit loops

Strange problem with units and range variables/implicit loops - Mensajes

#1 Publicado: 25/2/2019 15:30:20
Martin Kraska

Martin Kraska

1.361 me gusta en 2.275 mensajes.

Grupo: Moderator

if x is 1m, the loop fails, if x=1, it succeeds. Any idea, what is going on? How to explain?

unit-range.png
unit-range.sm (4,53 KiB) descargado 1389 vez(es).
Technische Mechanik mit SMath Studio: https://link.springer.com/book/10.1007/978-3-658-50592-9
#2 Publicado: 25/2/2019 16:07:55
Jean Giraud

Jean Giraud

983 me gusta en 6.866 mensajes.

Grupo: User

Wrote

Any idea, what is going on? How to explain?


Old style works OK.

mkUnits.PNG
#3 Publicado: 25/2/2019 16:17:36
Martin Kraska

Martin Kraska

1.361 me gusta en 2.275 mensajes.

Grupo: Moderator

vectorize also works independently of previous values of x. It is just the above example of implicit loops. I am not searching for alternatives but want to have robust implicit loops. They contribute to readable documents. Closer to pencil and paper handcalc than to algorithmic pseudocode.
Technische Mechanik mit SMath Studio: https://link.springer.com/book/10.1007/978-3-658-50592-9
A 1 usuarios les gustó este mensaje
frapuano 25/2/2019 16:35:00
#4 Publicado: 25/2/2019 16:33:07
overlord

overlord

600 me gusta en 1.381 mensajes.

Grupo: Moderator

when you assign 1m to x, it doesn't accept to be vectorized with range function afterwards.
making x a vector firstly, the problem is gone.
my diagnosis is; data type error. similar to C++, Basic, etc

regards

newstyle.png
A 1 usuarios les gustó este mensaje
sergio 25/2/2019 17:14:00
#5 Publicado: 25/2/2019 16:46:43
Martin Kraska

Martin Kraska

1.361 me gusta en 2.275 mensajes.

Grupo: Moderator

Wrote

when you assign 1m to x, it doesn't accept to be vectorized with range function afterwards.
making x a vector firstly, the problem is gone.
my diagnosis is; data type error. similar to C++, Basic, etc

regards



Sorry, but the problem is that the presence or absence of the unit in the existing value of x should not matter regardless what you are going to assign to x afterwards.

The failing implicit loop doesn't have any units involved, I would expect the loop to cleanly overwrite whatever pre-existing scalar value. I am well aware that pre-existing matrix values may proagate to the result if the dimensions are bigger than what is adressed in the loop.

Also, if there is some problem which can't be fixed, I'd vote for a better error message. In the given case, "Cannot calculate" will leave most users in frustration and dispair.

BTW, the first statement in your example just crushes the vectorize() function. It doesn't affect the actual value of y.
Technische Mechanik mit SMath Studio: https://link.springer.com/book/10.1007/978-3-658-50592-9
#6 Publicado: 25/2/2019 17:10:46
overlord

overlord

600 me gusta en 1.381 mensajes.

Grupo: Moderator

yeah Martin you are right a out my vectorize solution.
we expect to overwrite the values but somehow it doesn't.
we can use clear(x) before the new assignment temporarily, while this is inspected and corrected if necessary.

regards

ps: if x is a matrix then it seems this problem disappears also.

newstyle.png
A 1 usuarios les gustó este mensaje
frapuano 25/2/2019 17:42:00
#7 Publicado: 25/2/2019 18:59:58
Alvaro

Alvaro

1.139 me gusta en 1.805 mensajes.

Grupo: User

Hi. THis also fails too. Actually, it is a short form for the function NameVec in mathcad.

namevec.gif

Best regards.
Alvaro.

#8 Publicado: 25/2/2019 20:04:02
Jean Giraud

Jean Giraud

983 me gusta en 6.866 mensajes.

Grupo: User

Wrote

I'd vote for a better error message. In the given case, "Cannot calculate" will leave most users in frustration and dispair.


"can not calculate" because "syntax error"
"can not calculate" also appears in 6179 and 5346
resulting from more than a single "syntax error"

Syntax.PNG
#9 Publicado: 26/2/2019 7:27:45
Davide Carpi

Davide Carpi

1.443 me gusta en 2.936 mensajes.

Grupo: Moderator

Thank you we'll check it. I agree that the behavior should be the same regardless if there is an unit.

Wrote

Hi. THis also fails too.


There's no indexing in your LHS; the syntax you were looking for is the following:

2019-02-26 11_21_33-Window.png

Wrote

"can not calculate" because "syntax error"
"can not calculate" also appears in 6179 and 5346 resulting from more than a single "syntax error"


This is because implicit assignment loops by vectors are available since SMath Studio 0.99.6638, in previous versions it's invalid syntax.
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
A 3 usuarios les gustó este mensaje
sergio 26/2/2019 8:35:00, Radovan Omorjan 26/2/2019 9:11:00, Alvaro 26/2/2019 17:33:00
#10 Publicado: 26/2/2019 10:17:03
Jean Giraud

Jean Giraud

983 me gusta en 6.866 mensajes.

Grupo: User

Wrote

This is because implicit assignment loops by vectors are available since SMath Studio 0.99.6638, in previous versions it's invalid syntax.


Yes Davide, missing for local implicit previous 6638.
It turns red some of Ber7 & Alvaro stuff.
For the essentials, I don't miss local implicit loop.

Cheers ... Jean

idxVect.PNG
#11 Publicado: 26/2/2019 17:35:38
Alvaro

Alvaro

1.139 me gusta en 1.805 mensajes.

Grupo: User

Wrote



Wrote

Hi. THis also fails too.


There's no indexing in your LHS; the syntax you were looking for is the following:
...



Oh, yes, thanks. That's correct.

Best regards.
Alvaro.
  • Nuevos mensajes
  • Sin mensajes nuevos