The Museum of HP Calculators

HP Forum Archive 21

[ Return to Index | Top of Index ]

HP Prime: matrices in programs, in need of help
Message #1 Posted by Alberto Candel on 25 Nov 2013, 6:45 p.m.

Hi, I am not sure what I am doing wrong, but a program that I am writing starts by making a 2x3 matrix out of 2 numbers:

EXPORT EU(p,q)
BEGIN
LOCAL m;
m:=[[0,1,p],[0,1,q]];
//other stuff
END;

This produces a syntax error right after the last "]"

However, this is fine

EXPORT EU(p,q)
BEGIN
LOCAL m;
m:=[[0,1],[0,1]];
//other stuff
END;

but this is not

EXPORT EU(p,q)
BEGIN
LOCAL m;
m:=[[0,p],[0,q]];
//other stuff
END;

Thanks!

      
Re: HP Prime: matrices in programs, in need of help
Message #2 Posted by Han on 25 Nov 2013, 6:50 p.m.,
in response to message #1 by Alberto Candel

Quote:
Hi, I am not sure what I am doing wrong, but a program that I am writing starts by making a 2x3 matrix out of 2 numbers:

EXPORT EU(p,q)
BEGIN
LOCAL m;
m:=[[0,1,p],[0,1,q]];
//other stuff
END;

This produces a syntax error right after the last "]"

However, this is fine

EXPORT EU(p,q)
BEGIN
LOCAL m;
m:=[[0,1],[0,1]];
//other stuff
END;

but this is not

EXPORT EU(p,q)
BEGIN
LOCAL m;
m:=[[0,p],[0,q]];
//other stuff
END;

Thanks!


Are you using "comma (,)" mode? If so, this is currently bugged because "," is treated as the new decimal point, and ";" becomes the new comma. Therefore the parser is incorrectly treating the ";" as a comma. The result is a syntax error.

            
Re: HP Prime: matrices in programs, in need of help
Message #3 Posted by Alberto Candel on 25 Nov 2013, 6:59 p.m.,
in response to message #2 by Han

Hi Han, No, I have Dot(.) in Home Settings

Thank you.

      
Re: HP Prime: matrices in programs, in need of help
Message #4 Posted by Patrice on 25 Nov 2013, 7:23 p.m.,
in response to message #1 by Alberto Candel

Non constant matrix is not supported directly on Prime 1.0
build a string with your matrix , replacing variables by their values and then use EXPR to convert the string to a matrix with right values.

m:=EXPR("[[0,1,"+p+"],[0,1,"+q+"]]");
rather dirty trick but it works.

            
Re: HP Prime: matrices in programs, in need of help
Message #5 Posted by Alberto Candel on 25 Nov 2013, 7:35 p.m.,
in response to message #4 by Patrice

Well, yes, it does work (but.. who would have thought of that). BTW, what is the purpose, if any, of the "+" signs?

Thank you!

                  
Re: HP Prime: matrices in programs, in need of help
Message #6 Posted by Han on 25 Nov 2013, 7:41 p.m.,
in response to message #5 by Alberto Candel

Quote:
Well, yes, it does work (but.. who would have thought of that). BTW, what is the purpose, if any, of the "+" signs?

Thank you!


It's just addition. He's creating a string which the command EXPR() converts into an expression. The current firmware does not support local variables inside matrices.

                        
Re: HP Prime: matrices in programs, in need of help
Message #7 Posted by Alberto Candel on 25 Nov 2013, 7:59 p.m.,
in response to message #6 by Han

Oh, I see. Thank you for the explanation. That is probably why the rest of my program, while syntax error free, makes my HP to crash.

It is unfortunate that matrices cannot be handled in programs. I was rewriting a version of the euclidean algorithm that uses matrices for a number theory class, but ... it works wonderfully on the TI89!

                              
Re: HP Prime: matrices in programs, in need of help
Message #8 Posted by Han on 25 Nov 2013, 8:12 p.m.,
in response to message #7 by Alberto Candel

Quote:
Oh, I see. Thank you for the explanation. That is probably why the rest of my program, while syntax error free, makes my HP to crash.

It is unfortunate that matrices cannot be handled in programs. I was rewriting a version of the euclidean algorithm that uses matrices for a number theory class, but ... it works wonderfully on the TI89!


I am fairly certain that this issue is well known at this point (to the developers, that is) as there were many discussions in this forum on it not long after the Prime became available for purchase.

                                    
Re: HP Prime: matrices in programs, in need of help
Message #9 Posted by Alberto Candel on 25 Nov 2013, 8:39 p.m.,
in response to message #8 by Han

Hi again, and thank you.

Do you know if lists are subject to the same issue as matrices in programs? Thank you.

                                          
Re: HP Prime: matrices in programs, in need of help
Message #10 Posted by cyrille de Brébisson on 26 Nov 2013, 1:33 a.m.,
in response to message #9 by Alberto Candel

hello,

no, lists do not have the same restriction.

cyrille


[ Return to Index | Top of Index ]

Go back to the main exhibit hall