HP Prime: matrices in programs, in need of help « Next Oldest | Next Newest »

 ▼ Alberto Candel Member Posts: 72 Threads: 16 Joined: Sep 2013 11-25-2013, 06:45 PM 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! ▼ Han Senior Member Posts: 709 Threads: 104 Joined: Nov 2005 11-25-2013, 06:50 PM 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. ▼ Alberto Candel Member Posts: 72 Threads: 16 Joined: Sep 2013 11-25-2013, 06:59 PM Hi Han, No, I have Dot(.) in Home Settings Thank you. Patrice Senior Member Posts: 274 Threads: 23 Joined: Sep 2007 11-25-2013, 07:23 PM 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. ▼ Alberto Candel Member Posts: 72 Threads: 16 Joined: Sep 2013 11-25-2013, 07:35 PM Well, yes, it does work (but.. who would have thought of that). BTW, what is the purpose, if any, of the "+" signs? Thank you! ▼ Han Senior Member Posts: 709 Threads: 104 Joined: Nov 2005 11-25-2013, 07:41 PM 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. ▼ Alberto Candel Member Posts: 72 Threads: 16 Joined: Sep 2013 11-25-2013, 07:59 PM 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! ▼ Han Senior Member Posts: 709 Threads: 104 Joined: Nov 2005 11-25-2013, 08:12 PM 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. ▼ Alberto Candel Member Posts: 72 Threads: 16 Joined: Sep 2013 11-25-2013, 08:39 PM Hi again, and thank you. Do you know if lists are subject to the same issue as matrices in programs? Thank you. ▼ cyrille de Brébisson Member Posts: 193 Threads: 10 Joined: Mar 2008 11-26-2013, 01:33 AM hello, no, lists do not have the same restriction. cyrille

 Possibly Related Threads... Thread Author Replies Views Last Post Does the HP Prime really compiles the user programs? CompSystems 3 1,562 12-13-2013, 01:55 PM Last Post: Mike Morrow HP Prime Matrices curiosity bluesun08 0 931 12-09-2013, 06:44 PM Last Post: bluesun08 [HP-Prime CAS] "Warning, ^ (Command) Is ambiguous on non square matrices"?? CompSystems 1 1,288 12-07-2013, 07:15 PM Last Post: CompSystems HP Prime: Lists in programs Alberto Candel 7 2,295 12-04-2013, 02:16 AM Last Post: Alberto Candel HP Prime: FLOOR, iPart , and their use in programs Alberto Candel 6 1,666 12-01-2013, 10:17 PM Last Post: Alberto Candel HP Prime: password protection for programs Davi Ribeiro de Oliveira 2 1,007 11-22-2013, 12:45 PM Last Post: Geoff Quickfall Prime: Scope of Variable and functions within programs Thomas Chrapkiewicz 9 2,234 11-18-2013, 03:39 PM Last Post: Thomas Chrapkiewicz Question about transfering programs to the HP Prime Namir 10 2,179 11-17-2013, 04:01 PM Last Post: Namir [Download] PrimeComm: Alternative small utility to upload/download programs to the HP Prime Erwin Ried 6 1,596 11-17-2013, 10:18 AM Last Post: Erwin Ried HP 50g - question about matrices arrays vectors etc. Sean Freeman 6 1,685 11-14-2013, 01:44 PM Last Post: peacecalc

Forum Jump: