Exact items for a matrix from a program - 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: Exact items for a matrix from a program (/thread-4109.html) Exact items for a matrix from a program - salvomic - 06-07-2015 08:07 PM hi all, there is a way to get exact results for the items of a matrix, from a Home program (non CAS program)? For example, in my last program, if a matrix is returned it has [[1, 0.5], [0.5, 0.25]]and I would like to return also in CAS view [[1, 1/2], [1/1, ¼]] without hitting "a b/c". Something like the nice QPI (and QPImat) program by Han (inside the program)... I tried to use exact() but no luck for now... Thank you Salvo RE: Exact items for a matrix from a program - Joe Horn - 06-08-2015 06:56 AM (06-07-2015 08:07 PM)salvomic Wrote:  hi all, there is a way to get exact results for the items of a matrix, from a Home program (non CAS program)? For example, in my last program, if a matrix is returned it has [[1, 0.5], [0.5, 0.25]]and I would like to return also in CAS view [[1, 1/2], [1/1, ¼]] without hitting "a b/c". Something like the nice QPI (and QPImat) program by Han (inside the program)... I tried to use exact() but no luck for now... Thank you Salvo This isn't exactly what you seek, but the STRING function has an option to convert decimals into fractions. For example: STRING([[.1,.2],[.3,.4]],8) --> "[[1/10,1/5],[3/10,2/5]]" The output is ugly, not "Textbook" style, but at least the fractions are there. If you want to present the result in a pretty fashion, you'd have to loop through the matrix and STRING each entry separately, I suppose. RE: Exact items for a matrix from a program - salvomic - 06-08-2015 07:43 AM (06-08-2015 06:56 AM)Joe Horn Wrote:  This isn't exactly what you seek, but the STRING function has an option to convert decimals into fractions. For example: STRING([[.1,.2],[.3,.4]],8) --> "[[1/10,1/5],[3/10,2/5]]" The output is ugly, not "Textbook" style, but at least the fractions are there. If you want to present the result in a pretty fashion, you'd have to loop through the matrix and STRING each entry separately, I suppose. thank you Joe, this works, but I want to export numbers to be treated after the calculation... For example, ref() gives exact result, but exported from inside my program it doesn't export fractions but reals... (also using exact() command)... Salvo RE: Exact items for a matrix from a program - Joe Horn - 06-10-2015 05:50 AM Then I'd suggest using a loop that scans through the entire matrix (e.g. R goes from 1 to rowDim(M1), and C goes from 1 to colDim(M1)), and outputs exact(row(col(M1,C),R) at each iteration. Or something like that. Not a single command, but it works. RE: Exact items for a matrix from a program - salvomic - 06-10-2015 06:27 AM (06-10-2015 05:50 AM)Joe Horn Wrote:  Then I'd suggest using a loop that scans through the entire matrix (e.g. R goes from 1 to rowDim(M1), and C goes from 1 to colDim(M1)), and outputs exact(row(col(M1,C),R) at each iteration. Or something like that. Not a single command, but it works. thank you, I'll try it