orgMINT / MINT

MINT2 The latest version of MINT
GNU General Public License v3.0
16 stars 3 forks source link

feature request - Arrays #28

Open SteveJustin1963 opened 2 weeks ago

SteveJustin1963 commented 2 weeks ago

We should call arrays as vector, as a list that has one dimension. It is a row of data. An array is a list that is arranged in multiple dimensions. A two-dimensional array is a vector of vectors that are all of the same length. There are nxn and nxm arrays.

currently We can store an integer in a 1x1 vector > 12 b ! We can save a 1x3 vectors to a variable > [1 2 3] a ! We can > 1a! 3b! ab+. gives 4 We can recall values from vector with variable n? like > a 1?. gives 2

But we lack basic operations on 1xn vectors plus + and minus - Perhaps > [1 2 3]a! [1 2 3]b! ab+ c!
then c . gives [2 4 6] rather than each number on stack. not sure

Products More advanced maybe outside of MINT is products / Divide is avoided see notes below cross product ** // transpose needed, maybe > [1 2 3 t ] dot product * // transpose not needed

> [1 2 3]a! [1 2 3 t ]b! ab * c! c .
14
> ab d* c! c.
0 
> [1 2 3]a!  [4 5 6 ]b!  ab ** c! c.
[ -3  6  -3]
>

Vector-variables We can nest arrays in arrays [ n n [ m m ] n ] but variables cannot be placed in an array. [ a b [ 3 5 ] 7 ] If we could then we can do more

> [1 2 a 4]b!  
> 3a! b.
[1 2 3 4]
>

but how do we handle + and - with var in [ ] ?

Notes on / Primary reason we don't use the division operator / for vectors is the non-commutativity of vector multiplication.

Vector Multiplication: Dot product: Produces a scalar (a number). Cross product: Produces a vector perpendicular to both original vectors.

Non-Commutativity: Dot product: Commutative (a · b = b · a). Cross product: Non-commutative (a × b ≠ b × a).

Division: Division is essentially the inverse of multiplication. Since vector multiplication is non-commutative, it's difficult to define a consistent and meaningful inverse operation.