Menu

#58 Vectors

Next_Release
open
nobody
None
1
2021-04-05
2018-08-20
No

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]

1 Attachments

Related

Feature Requests: #56

Discussion

  • Anonymous

    Anonymous - 2018-09-03

    I think this is a feature, not a bug. The { } brackets convert a list of expressions (separated by ;) into a vector.

     
    • zeon_account_will_be_deleted

      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
  • Jan Rheinlaender

    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?

     
    • zeon_account_will_be_deleted

      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.

       
      • Jan Rheinlaender

        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.

         
        • zeon_account_will_be_deleted

          Let's make a shortcut for concat() function. Possible options: & | ;

          For example we use & (like in LO calc and Excel). Concat() function is associative:

          a & (b & c) = (a & b) & c = "abc"
          

          In iMath we could drop brackets and type this:

          a & b & c
          

          I see no issues for parser here. What do you think?

           
          • Jan Rheinlaender

            & 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.

             
    • zeon_account_will_be_deleted

      What is the difference between Vectors and Lists in iMath?

       
      • Jan Rheinlaender

        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

         
  • zeon_account_will_be_deleted

    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):

    1. Create a way to define vectors and lists. They should be different objects to avoid ambiguity. In this case we could calculate functions like sin(<list>), but not sin(<vector>). Some functions and keywords could take both vectors and lists. Maybe in this case we will need a keyword to convert vectors <-> lists.</vector></list>
    2. Leave everything as is. But make more options for defining vectors. And make sin(x_1; x_2;...x_n) work like (sin(x_1); sin(x_2)... sin(x_n)). In this case we still have some ambiguity for functions taking vectors as arguments and we have to solve it somehow.

    Let's think about it.

     
  • Jan Rheinlaender

    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.

     
    • Jan Rheinlaender

      Hi zeon,

      any feedback on this?

       

Anonymous
Anonymous

Add attachments
Cancel





MongoDB Logo MongoDB