Using Matrix element in Boolean evaluation

Using Matrix element in Boolean evaluation - Messages

#1 Posted: 11/22/2017 3:06:57 PM
Arie

Arie

93 likes in 285 posts.

Group: User

I ran across this issue in one of my files. I'm not sure if this is a known issue or not.
It appears if I try to use an element of a matrix in a boolean operation, the evaluation fails.
However, if I first assign that matrix element to another variable, then use that variable in the boolean operation this works.


Edit: This is observed in both 0.98.6528 and 0.98.6484

Untitled.png
Feel free to join the SMath Studio Users Discord Channel: https://discord.gg/PayZpJW
#2 Posted: 11/22/2017 6:40:32 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Wrote

I'm not sure if this is a known issue or not.



There is no issue in there: the vectorize operator is a descending operator.
Example 2, it compares each successive value with a wild variable, the test is
true twice. Example 1, vectorize descends over two vectors of unequal length.
The indexed is not a wild variable to dispose, rather a vector of single element.

Just erroneous instruction.
1 users liked this post
Arie 11/22/2017 8:07:00 PM
#3 Posted: 11/22/2017 7:06:23 PM
Arie

Arie

93 likes in 285 posts.

Group: User

That is what appears to happen. But if that's true why does the assignment of a 1x1 vector evaluate to a single value as in V.OUT.


It seems inconsistent.

I should note that in the first expression, V.CLAMP]2 is surrounded by parenthesis, not the matrix brackets.
Feel free to join the SMath Studio Users Discord Channel: https://discord.gg/PayZpJW
#4 Posted: 11/22/2017 7:58:01 PM
Martin Kraska

Martin Kraska

1222 likes in 2150 posts.

Group: Moderator

vectorize checks for non-scalar variables and then loops over the elements of these variables. For this in order to work, all these variables need to have the same length.

The expression isn't further analyzed before this is done. In particular, there isn't any check if some of the subexpressions might evaluate to scalars (e.g. by applying the index function or absolute value or the like).
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
1 users liked this post
Arie 11/22/2017 8:07:00 PM
#5 Posted: 11/22/2017 9:44:14 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Wrote

That is what appears to happen. But if that's true why does the assignment of a 1x1 vector evaluate to a single value as in V.OUT.


It seems inconsistent.

I should note that in the first expression, V.CLAMP]2 is surrounded by parenthesis, not the matrix brackets.


That particular Bolean responds to universal rules. Most [if not all] Smath borrows
universal codes/functions. When you assign [1x] to var, you convert to "scalar".
At this point, the vectorize operator can descend and apply the Bolean test to each
of the elements in U. A "scalar" is a vanishing iterator, example: plot canvas.

BoleanTest.PNG

  • New Posts New Posts
  • No New Posts No New Posts