failing evaluation under vectorize()

failing evaluation under vectorize() - Messages

#1 Posted: 11/22/2023 1:22:45 AM
Martin Kraska

Martin Kraska

1222 likes in 2150 posts.

Group: Moderator

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

6-2-Bug.sm (27 KiB) downloaded 66 time(s).
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 Posted: 11/22/2023 2:41:12 AM
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 likes in 1674 posts.

Group: 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 users liked this post
sergio 11/22/2023 4:05:00 AM, Martin Kraska 11/22/2023 4:36:00 AM, ioan92 11/22/2023 4:58:00 AM
#3 Posted: 11/22/2023 4:35:34 AM
Martin Kraska

Martin Kraska

1222 likes in 2150 posts.

Group: 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 Posted: 11/22/2023 6:57:58 AM
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 likes in 1674 posts.

Group: 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 users liked this post
ioan92 11/23/2023 7:35:00 PM, Martin Kraska 11/25/2023 11:04:00 PM
#5 Posted: 11/25/2023 8:15:21 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: 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 KiB) downloaded 51 time(s).
1 users liked this post
Martin Kraska 11/25/2023 11:04:00 PM
#6 Posted: 11/25/2023 11:17:47 PM
Martin Kraska

Martin Kraska

1222 likes in 2150 posts.

Group: 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 KiB) downloaded 48 time(s).
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
1 users liked this post
Oscar Campo 11/26/2023 6:21:00 PM
  • New Posts New Posts
  • No New Posts No New Posts