failing evaluation under vectorize()

failing evaluation under vectorize() - Сообщения

#1 Опубликовано: 22.11.2023 01:22:45
Martin Kraska

Martin Kraska

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

Группа: Moderator

Why does the vectorize operation fail while it seems to be safe to use an explicit loop?

6-2-Bug.sm (27 КиБ) скачан 67 раз(а).
2023-11-21 18_18_50-SMath Solver - [6-2-Bug.sm_].png
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
#2 Опубликовано: 22.11.2023 02:41:12
Alvaro Diaz Falconi

Alvaro Diaz Falconi

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

Группа: User

Wrote

Why does the vectorize operation fail while it seems to be safe to use an explicit loop?


Hi Martin. Because you have just only one function which can't be vectorized: the norme or dot product of vectors.

vec.png

Best regards.
Alvaro
3 пользователям понравился этот пост
sergio 22.11.2023 04:05:00, Martin Kraska 22.11.2023 04:36:00, ioan92 22.11.2023 04:58:00
#3 Опубликовано: 22.11.2023 04:35:34
Martin Kraska

Martin Kraska

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

Группа: Moderator

Is that just by observation or is there a fundamental obstacle?
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
#4 Опубликовано: 22.11.2023 06:57:58
Alvaro Diaz Falconi

Alvaro Diaz Falconi

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

Группа: User

Wrote

Is that just by observation or is there a fundamental obstacle?



Hi. I guess that it is fundamental.

Some notes about how other CAS handle this issue.

Pretty old matlab version, from its symbolic toolbox

v1.png

The help page from the newest version

v2.png

So, it looks like they have some issues with automatic vectorization.

With maple it is very uncomfortable, you need to use map even for simple cases

map.png

Wolfram's solution is very practical: Function with attribute 'Listable' expands over lists

math.png

But for make a table you actually need a loop or the Mathematica's Map function.

Best regards.
Alvaro.
2 пользователям понравился этот пост
ioan92 23.11.2023 19:35:00, Martin Kraska 25.11.2023 23:04:00
#5 Опубликовано: 25.11.2023 20:15:21
Jean Giraud

Jean Giraud

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

Группа: User

Wrote

Why does the vectorize operation fail while it seems to be safe to use an explicit loop ?


Set the demand in local definition mode ...
new(t):=|a(t)
vectorize and equate


6-2-Bug Doctored.sm (29 КиБ) скачан 51 раз(а).
1 пользователям понравился этот пост
Martin Kraska 25.11.2023 23:04:00
#6 Опубликовано: 25.11.2023 23:17:47
Martin Kraska

Martin Kraska

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

Группа: Moderator

Thanks Alvaro and Jean. Here is a reduced working example.

When a scalar function involves scalar products then it must be defined in a line()-block in order to be vectorize()able.

Worksheet13.png
Worksheet13.sm (5 КиБ) скачан 53 раз(а).
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
1 пользователям понравился этот пост
Oscar Campo 26.11.2023 18:21:00
  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений