home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.hp48
- Path: sparky!uunet!mcsun!sun4nl!wn1.sci.kun.nl!sci.kun.nl!jc
- From: jc@sci.kun.nl (Jan Christiaan van Winkel (ATC))
- Subject: array conversion question
- Message-ID: <1992Jul31.082043.15643@sci.kun.nl>
- Summary: conveting matrix to list of vectors
- Keywords: conversion, array, list
- Sender: news@sci.kun.nl (NUnet News Owner)
- Organization: University of Nijmegen, The Netherlands
- Date: Fri, 31 Jul 1992 08:20:43 GMT
- Lines: 65
-
- Hey y'all,
-
- I have a question regarding matrices:
-
- I want to convert a matrix to a list of vectors, and back again.
-
- So, I want to do:
- [[ 2 3 4 ]
- [ 9 5 1 ]
- [ 1 2 6 ]
- [ 2 6 3 ]]
-
- to
-
- {[ 2 3 4 ]
- [ 9 5 1 ]
- [ 1 2 6 ]
- [ 2 6 3 ]}
-
- and back again.
-
- I want to do this because
- 1) I want to be able to do arithmetic on just a ROW of data, which
- is fairly easy in a list (like DAT DUP 1 GET 2 * 1 PUT)
- 2) I want to be able to edit my data using the matrix editor
- 3) I want to be able to use the statistics stuff on my data.
-
- At the moment, I convert the array to a string (->STR), replace the [
- and ] char's by { and converting it back again (OBJ->). This takes an
- awfull lot of time, and may just work because of lucky FIX/SCI/STD
- settings. For conversion from list to array, I do it just the other
- way around. This also takes a lot of time.
-
- I have considered using OBJ-> and ->ARRY, but then I must assemble my
- row data piece by piece.
-
- I understand that the amount of work to be done for these conversions
- inside the HP48 is impressive as the internal datastructures for
- arrays and lists of arrays are totally different, but having to convert
- all data to ASCII strings is pushing it just too far.
-
- Thanks for any help.
- JC
-
- ps: for those who want to know what I use this for:
- My array contains 5 columns, and an arbitrary number of rows. The first
- column is a day number, and columns 2, 3, 4, and 5 are meterpositions
- for electricity, natural gas, water meters and so on. I want to calculate the
- amount of gas (etc) used per day for each period. So:
-
- daynr gasmeter watermeter .....
- [[ A B C D E ]
- F G H I J ]
- K L M N O ]]
-
- should become
- days gas/day water/day ...............
- [[ 0 0 0 0 0 ]
- [ F-A (G-B)/(F-A) (H-C)/(F-A) (I-D)/(F-A) (J-E)/(F-A) ]
- [ K-F (L-G)/(K-F) (M-H)/(K-F) (N-I)/(K-F) (O-J)/(K-F) ]]
- --
- ___ __ ____________________________________________________________________
- |/ \ Jan Christiaan van Winkel jc@sci.kun.nl
- | Alternative e-mail addresses: jc@oreo.atcmp.nl and jc@atcmp.nl
- __/ \__/ ____________________________________________________________________
-