Inconsistency in matrixFromFunction when invoked from expression? #3370
gwhitney
started this conversation in
Design decisions
Replies: 1 comment
-
Ah and note the matrixFromFunction behavior is directly contradictory to |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Suppose I enter
matrixFromFunction([3], _(x) = x[1]^2)
in the expression parser on the homepage, trying to make a vector of the first three square numbers. It reports a value of[0, 1, 4]
, which seems inconsistent: from the perspective of the mathjs expression language, the three indices of that return matrix are[1], [2],
and[3]
. So from that point of view, this expression "should have" returned[1, 4, 9]
. (Because in the expression language, matrix indices are 1-based instead of 0-based).Should mathjs be modified so that when matrixFromFunction is invoked via the parser, it calls the callback with 1-based indices rather than 0-based indices?
I personally think so, for internal self-consistency, but ultimately Jos will have to decide if this consistency is worth the effort it will be.
Beta Was this translation helpful? Give feedback.
All reactions