slow extraction of matrix elements

slow extraction of matrix elements - Сообщения

#1 Опубликовано: 14.09.2021 06:13:45
Johannes Piel

Johannes Piel

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

Группа: User

Hallo,
Thanks to PTC's weird policy, I'm now trying to switch completely to Smath and have started rebuilding my main sheets.
Now I'm running into a problem here that I can't solve:
I build a matrix in half a second, but I can't display it. Even displaying a single element doesn't finish unless I shrink the matrix w.
The optimization of all equations is set to "numerical", the matrix elements should then be ready calculated, right? Does anyone know such a behavior?
The complete sm file and the data for it will come tomorrow.
Best regards,
Johannes

Extract Matrix element.png
#2 Опубликовано: 14.09.2021 08:43:02
Johannes Piel

Johannes Piel

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

Группа: User

Putting eval() around the matrix definition solved this.

But what is then the setting "numerical" good for?
#3 Опубликовано: 14.09.2021 09:46:12
Jean Giraud

Jean Giraud

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

Группа: User

Wrote

But what is then the setting "numerical" good for?


You are in the learning curve of Smath.
It toke me ~ 6 years to convert most of my MCD 11.
Wait to glance your promised document ... Jean

#4 Опубликовано: 14.09.2021 10:49:38
Oscar Campo

Oscar Campo

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

Группа: Moderator

Wrote

Hallo,
Thanks to PTC's weird policy, I'm now trying to switch completely to Smath and have started rebuilding my main sheets.
Now I'm running into a problem here that I can't solve:
I build a matrix in half a second, but I can't display it. Even displaying a single element doesn't finish unless I shrink the matrix w.
The optimization of all equations is set to "numerical", the matrix elements should then be ready calculated, right? Does anyone know such a behavior?
The complete sm file and the data for it will come tomorrow.
Best regards,
Johannes

Extract Matrix element.png



Please, can you share your .sm file?

Oscar
#5 Опубликовано: 15.09.2021 04:57:37
Johannes Piel

Johannes Piel

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

Группа: User

Here is the file.
I have inserted a random source matrix, that needs a longer calculation time than my original.
But the effect is the same.


Extract matrix element.sm (10 КиБ) скачан 51 раз(а).
#6 Опубликовано: 15.09.2021 09:14:57
Jean Giraud

Jean Giraud

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

Группа: User

Wrote

Here is the file.
I have inserted a random source matrix, that needs a longer calculation time than my original.
But the effect is the same.


Sorry Collab, I don't quite understand your matrix wrt Smath code.

Random [rnd(n)] LAMDA.sm (5 КиБ) скачан 32 раз(а).
Random Scatter 3D.sm (19 КиБ) скачан 37 раз(а).
Random_5 Matrix [RGB].sm (102 КиБ) скачан 37 раз(а).
#7 Опубликовано: 15.09.2021 09:42:20
overlord

overlord

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

Группа: Moderator

Wrote

Here is the file.
I have inserted a random source matrix, that needs a longer calculation time than my original.
But the effect is the same.


2021-09-15_15-32.png

This product evaluation may seem small on paper.
But actually it is a huge calculation.
And it gets bigger if t.max/i.max gets higher.
It takes 26s on my pc and my CPU is i7 6700k.
Not one of the fastest but not a slow one either.

Obviously you have to wait until that product is finished.
After that you can display elements of matrix w individually, and in an instant.
SMath is smart, it won't recalculate if you try to display an element of matrix after it is finished.
It will take microseconds to show the elements of matrix.
Unless you don't change something before "the long process calculation" of course.

Regards

2021-09-15_15-39.png
#8 Опубликовано: 15.09.2021 10:10:12
Jean Giraud

Jean Giraud

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

Группа: User

The classical Iterated Product.

Lagrange.PNG
#9 Опубликовано: 15.09.2021 11:18:16
Johannes Piel

Johannes Piel

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

Группа: User

Thank you for your answers.

My concern was NOT that the evaluation of
Matrix := complicated definition
took a long time, it was about the extraction of a single element,
Matrix[x,y]=
As i noted above, with a different definition:
Matrix := eval(complicated definition)
the following
Matrix[x,y]=
performed as expected in milliseconds.

I did not expect that a calculation, that is set to "numerical optimization", needs this additional eval() to calculate to the numerical end.

My original matrix is times bigger, but includes a lot of zeros. It now performs in a second.

Thank you , Johannes
#10 Опубликовано: 15.09.2021 14:12:43
overlord

overlord

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

Группа: Moderator

Wrote

I did not expect that a calculation, that is set to "numerical optimization", needs this additional eval() to calculate to the numerical end.


Because that is what eval() "may" does, usually.
Simplify expression, reduce calculation time.
I didn't get what you mentioned earlier, sorry.
I thought you were complaining about you couldn't
display elements, unless you shrink the matrix w.

Regards

2021-09-15_20-07.png
1 пользователям понравился этот пост
Oscar Campo 15.09.2021 14:15:00
#11 Опубликовано: 15.09.2021 14:26:08
Oscar Campo

Oscar Campo

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

Группа: Moderator

Wrote

Here is the file.
I have inserted a random source matrix, that needs a longer calculation time than my original.
But the effect is the same.


Extract matrix element.sm (10 КиБ) скачан 51 раз(а).



If you define your matrix as a function, you have an alternative and faster "extraction of a matrix element":

FasterEvaluation.png

#12 Опубликовано: 15.09.2021 15:02:30
Jean Giraud

Jean Giraud

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

Группа: User

Random.PNG
  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений