Post Reply 
Vector or list to Number "conversion" (SOLVED.)
03-20-2015, 03:38 AM (This post was last modified: 03-21-2015 06:42 AM by Spybot.)
Post: #1
Vector or list to Number "conversion" (SOLVED.)

Hi Guys!
I'm trying to compare the numeric value of two objects, one is a vector with only one numeric value and the other is a real number; [1/2]==0.5 the Hp Prime returns a zero.

I searched
this forum and the UG. for a command that takes the [1/2] out of the brackets so I can compare them, but I found nothing.

this vector [1/2] is the result of solving an equation using the SOLVE command.

what can I do to make the caparison a true statement?

Thank you.

Spybot.
Find all posts by this user
Quote this message in a reply
03-20-2015, 09:46 AM (This post was last modified: 03-20-2015 09:48 AM by Angus.)
Post: #2
RE: Vector or list to Number "conversion"
If I define

result:=[1/2]

and do result(1)==0.5 it works on my emulator. You can access a list or vector by round brackets. First element index 1.
Find all posts by this user
Quote this message in a reply
03-20-2015, 10:34 AM
Post: #3
RE: Vector or list to Number "conversion"
Hello,

Are you in CAS or Home?

In home, assuming that your vector is stored in a variable (vec for example), doing EVAL(vec(1))==0.5 will do the trick.

Cyrille
Find all posts by this user
Quote this message in a reply
03-20-2015, 10:59 AM
Post: #4
RE: Vector or list to Number "conversion"
Perhaps a "List" approach might be useful?

mat2list([1/2]) == 1/2 => {1}

mat2list([1/2, 1/4, 1/2]} == 1/2 => {1, 0, 1}

Using the list facility the test applies to one (or more) elements, without referencing a specific element number.

-Dale-
Find all posts by this user
Quote this message in a reply
03-20-2015, 11:24 AM
Post: #5
RE: Vector or list to Number "conversion"
(03-20-2015 03:38 AM)Spybot Wrote:  [size=large]
Hi Guys!
I'm trying to compare the numeric value of two objects, one is a vector with only one numeric value and the other is a real number; [1/2]==0.5 the Hp Prime returns a zero.
...

(03-20-2015 09:46 AM)Angus Wrote:  If I define

result:=[1/2]

and do result(1)==0.5 it works on my emulator. You can access a list or vector by round brackets. First element index 1.

rigorously speaking, a vector with only one component is always a vector, non a real...
So, TYPE([½])= 4 (matrix or vector), and type([½]) = DOM_LIST, and in fact is also a list)

You must use [½](1) to get a value 0.5, and then
type([½](1)) = DOM_RAT and TYPE(...) = 0, a real

I hope this could help you.

Salvo

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
Visit this user's website Find all posts by this user
Quote this message in a reply
03-21-2015, 06:40 AM (This post was last modified: 03-21-2015 02:21 PM by Spybot.)
Post: #6
RE: Vector or list to Number "conversion"
All You Guys provided Great solutions!

PROBLEM SOLVE!!!

Thank you Guys!

Spybot.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)