Vectors
Brought to you by:
jrheinlaender
Can’t create a vector which is defined by several series. iMath creates a vector of vectors instead. Possible solution: change syntax. For this example:
x={1:3:1; 10:6:-2} - creates a vector x = (1, 2, 3, 10, 8, 6)
x={{1:3:1}; {10:6:-2}} - creates a vector x = ((1, 2, 3), (10, 8, 6)) (it’s working now)
This issue was found when I experimented with SUBSTV. This example is related to [#56]
Anonymous
I think this is a feature, not a bug. The { } brackets convert a list of expressions (separated by ;) into a vector.
Did you look at my example? Now this one
x={1:3:1; 10:6:-2}creates a vector x = ((1, 2, 3), (10, 8, 6))
My proposal is to change the syntax so it would be possible to define a vector as a piecewise linear function.
If someone wants to create a vector of vectors, he or she has to define it exactly like this:
x={{1:3:1}; {10:6:-2}}Last edit: zeon_account_will_be_deleted 2018-09-06
Hi zeon,
I'm afraid your proposed syntax introduces too many ambiguities for the parser to handle.
What about a concat() function that joins two vectors (or lists) together?
HI, Jan!
Concat() must take more than two arguments in this case. A list of arguments.
Maybe Concat() will be useful. For example, for Piecewise_linear_function and others.
Here is my suggestion for concat() function. It takes 2 arguments only. If you need to concat more vectors, you can do concat(concat(v1; v2);v3). The reason is that variable amount of arguments is not possible.
Let's make a shortcut for concat() function. Possible options: & | ;
For example we use & (like in LO calc and Excel). Concat() function is associative:
In iMath we could drop brackets and type this:
I see no issues for parser here. What do you think?
& and | are parsed by starmath into boolean AND OR symbols so they are not available. ";" is ambiguous because it is used to separate argument lists.
What is the difference between Vectors and Lists in iMath?
A vector is a mathematical entity and can be used for algebra (addition, multiplication etc.)
A list is mostly used for function arguments, and for constructing vectors. No algebra is possible with lists
Hi Jan!
I'd like to rewind it back. We have keywords, that can take a list of arguments, like SUBSTV, CHART. We do not have to use vectors (mathematical objects with appropriate properties). But there is no way to create and store a list of arguments in iMath now (of course we can input a sequence of elements one by one, but this is not enough in practice). But we can create and store vectors instead. And this is the point where the problems begin.
So my suggestions are (one of them):
Let's think about it.
Hi zeon!
I checked your suggestion 1. It does not work because GiNaC does not implement arithmetic for lists (e.g. (3;4;5) + (4;5;6) will not evaluate to (7;9;11) as expected).
So we have to consider 2. I suggest to implement the APPLY keyword
APPLY(sin(), {1:10:1})
because it is similar to Mathematica.
Hi zeon,
any feedback on this?