HP Forums
Multi-Dimensional Matrices - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: Multi-Dimensional Matrices (/thread-8151.html)



Multi-Dimensional Matrices - toml_12953 - 04-12-2017 05:48 PM

The code below checks OK but doesn't run. Is it possible to have n-dimensional tables? If so, how do you access them?

Tom L

PHP Code:
EXPORT mattest()
BEGIN
local a
:=[[[1,2,3],[2,3,4],[19,20,21]],[[4,5,6],[7,8,9],[-1,-2,-3]],[[10,11,12],[13,14,15],[-5,-6,-7]]];
print(
a(2,1,1));
END



RE: Multi-Dimensional Matrices - compsystems - 04-12-2017 06:31 PM

The hp-prime supports only up to 2D,

In a next firmware the compiler should detect the validity of an array (maximum 2D)

You can work with n-dimensional arrays as a list

PHP Code:
EXPORT mattest()
BEGIN
    L1
:= { {{1,2,3},{2,3,4},{19,20,21}}, {{4,5,6},{7,8,9},{-1,-2,-3}}, {{10,11,12},{13,14,15},{-5,-6,-7}}};
    print(
L1(2,1,3)); // 6
END



RE: Multi-Dimensional Matrices - Han - 04-12-2017 06:42 PM

You can either use lists for non-CAS programs, or you can create a CAS program that will do what you want if you specifically want to use the [ ] delimiters for your data.


RE: Multi-Dimensional Matrices - toml_12953 - 04-12-2017 06:43 PM

(04-12-2017 06:31 PM)compsystems Wrote:  The hp-prime supports only up to 2D,

In a next firmware the compiler should detect the validity of an array (maximum 2D)

You can work with n-dimensional arrays as a list

PHP Code:
EXPORT mattest()
BEGIN
    L1
:= { {{1,2,3},{2,3,4},{19,20,21}}, {{4,5,6},{7,8,9},{-1,-2,-3}}, {{10,11,12},{13,14,15},{-5,-6,-7}}};
    print(
L1(2,1,3)); // 6
END

Thanks! Now if only MAKELIST was extended to create multi-dimensional lists, it'd be great! Creating a 20x10x30 list will be a challenge the way it is now.

Tom L


RE: Multi-Dimensional Matrices - Han - 04-12-2017 06:45 PM

(04-12-2017 06:43 PM)toml_12953 Wrote:  Thanks! Now if only MAKELIST was extended to create multi-dimensional lists, it'd be great!

Tom L

Create a program that outputs the desired contents of a list, and have MAKELIST call that program.


RE: Multi-Dimensional Matrices - webmasterpdx - 08-31-2017 04:44 AM

I'm surprised it's limited at 2D. Tensor analysis is used in a lot of engineering applications (especially mechanical engineering)....so being able to get the inverse, multiplication, etc, etc...of multidimensional arrays shouldn't be that difficult to add to the firmware...


RE: Multi-Dimensional Matrices - webmasterpdx - 08-31-2017 05:22 AM

Actually, I take that back....multidimensional array operations can get very complex and are dependent on what you want to do. Classical matrix algebra doesn't go beyond 2D anyways.