Summ(1) bug

Summ(1) bug - Сообщения

#1 Опубликовано: 05.03.2014 13:15:21
Igor Skarine

Igor Skarine

14 сообщений из 97 понравились пользователям.

Группа: User

This is an example of the code that indicates 2 possible bugs in Smath or in the plugins.
The idea of the program is to sort roots of polinomial so, that standard algotithm of
calculating polinomial coefficients produces numerically correct result.
The implementation is very similar to Matlab leja(x) function.

What was found:
1) Vector Summ "summ(1)" operator doesn't work
if another function(x) is used as an argument, despite of the GetType(function(x)) displays
correct type "matrix".

2) I often put 2 or 3 operators in a "matrix row" like ( c[n]:=0 c[1]:=1 ) instead of using "line".
Usually it works fine (Old Mathcad habit).
But in this example matrix of 3 operators produces wrong result with no error indication.
The problem is that "matrix" implementation
(t:=a[k][1]) a[k][1]:=a[k][ii] a[k][ii]:=t) - doesn't work,
but standatd implementation with "line" works.
Am I using some undocumented features ?
f_poly.sm (21 КиБ) скачан 41 раз(а).
#2 Опубликовано: 05.03.2014 16:24:57
Martin Kraska

Martin Kraska

1222 сообщений из 2150 понравились пользователям.

Группа: Moderator

Wrote

I often put 2 or 3 operators in a "matrix row" like ( c[n]:=0 c[1]:=1 ) instead of using "line".
Usually it works fine (Old Mathcad habit).
But in this example matrix of 3 operators produces wrong result with no error indication.
The problem is that "matrix" implementation
(t:=a[k][1]) a[k][1]:=a[k][ii] a[k][ii]:=t) - doesn't work,
but standatd implementation with "line" works.
Am I using some undocumented features ?


As I understand, the expressions in a row matrix are executed from right to left. Is that consistent with your observations?
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
#3 Опубликовано: 05.03.2014 16:31:59
Davide Carpi

Davide Carpi

1415 сообщений из 2872 понравились пользователям.

Группа: Moderator

Take care about known bugs:
- linear indexing vs transposed matrics
- linear indexing and the assignments

Цитата

I often put 2 or 3 operators in a "matrix row" like ( c[n]:=0 c[1]:=1 ) instead of using "line"
[...]
Am I using some undocumented features ?


Yes, even if I remember that someone else has used it in the past...


Цитата

As I understand, the expressions in a row matrix are executed from right to left.


Correct, this comes from the Reverse Polish notation used at low-level...
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#4 Опубликовано: 05.03.2014 16:41:52
Igor Skarine

Igor Skarine

14 сообщений из 97 понравились пользователям.

Группа: User

Yes, Martin, Smath executes expressions in a "matrix row" in right->left order, opposite to Mathcad and common sense.
I've just checked it. Yet another "featurebug" :d

Цитата

Correct, this comes from the Reverse Polish notation used at low-level...


If you think it is correct, than use LISP instead of Smath.
The only point of Smath vs LISP is a good user interface.
#5 Опубликовано: 05.03.2014 17:48:20
Davide Carpi

Davide Carpi

1415 сообщений из 2872 понравились пользователям.

Группа: Moderator

Wrote

If you think it is correct, than use LISP instead of Smath.


What I meant to say is that the Martin's explaination is correct; about the SMath behavior I think it's "not the best" if you use the features that you have used or some others similar.

I think that the right to left parsing should be better as general solution, but I don't know if the actual implementation was done to fit something important in the SMath code or if is just a bug (the RPN sometimes can causes confusion writing the algorithms, and a bug is easier to find in undocumented features such as those you have used).


best regards,

Davide
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#6 Опубликовано: 07.03.2014 12:02:23
Igor Skarine

Igor Skarine

14 сообщений из 97 понравились пользователям.

Группа: User

Summ(1) bug/feature update.
Vector/matrix summ doesn't work if it's argument equal to mwabs(f_poly(r)).
But it works if I use eval(mwabs(f_poly(r))) instead.
One more similar observation:
I wrote a simple function
logspace(a,b,N):=mwexp((a+{b-a}/{N-1}*(range(0,N-1)))*ln(10))
to generate logarithmic frequency grid.
The execution of the entire worksheet become suspiciously slow ~ 10 sec.
In order to clarify the issue I tried
logspace(a,b,N):=eval(mwexp((a+{b-a}/{N-1}*(range(0,N-1)))*ln(10)))
and execution time became just 0.5 sec.
What is puzzling me, is that result of mwexp((a+{b-a}/{N-1}*(range(0,N-1)))*ln(10))=
pops on the screen instantly, but somehow the result of logspace() when used, delays the rest of the worksheet execution.
not a logspace() itself. Why eval(mwexp()) is not equivalent to numerical function mwexp() ?
#7 Опубликовано: 26.04.2014 05:52:33
Davide Carpi

Davide Carpi

1415 сообщений из 2872 понравились пользователям.

Группа: Moderator

Mentioned here, added in the BTS:

- linear indexing vs transpose (SS-76)
- linear indexing vs assignments (SS-129)
- order of assignments inside matrices (SS-130)
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#8 Опубликовано: 29.04.2014 16:04:04
Andrey Ivashov

Andrey Ivashov

2269 сообщений из 3729 понравились пользователям.

Группа: Super Administrator

Thank you! I will handle issues reported in BTS.
1 пользователям понравился этот пост
Davide Carpi 29.04.2014 17:14:00
  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений