using sqr root minus one as error code

APL-related discussions - a stream of APL consciousness.
Not sure where to start a discussion ? Here's the place to be
Forum rules
This forum is for discussing APL-related issues. If you think that the subject is off-topic, then the Chat forum is probably a better place for your thoughts !

using sqr root minus one as error code

Postby tclviii-dyalog on Thu Dec 15, 2011 6:15 pm

now that irrational numbers are here i figured i could use 1J1 as an error flag ''fill'' value
when i import historic oil prices from reuters and reuters returns a '#n/a' type XL error for
days that reuters didn't capture a price (such as not having an ''open'' price on some far in the
future oil contract that nobody traded that day, even though there is a ''settlement'' value)

i figured since 1J1 was a number, i could mult/divide/add/subtract two vectors, each of which
might have some missing days, and the ''errors'' would ''flow'' through as imaginary results

of course, i didn't count on two vectors BOTH having imaginary numbers, and the
sqr root -1(s) cancelling out when multiplied together

is there some flag for preserving the provenance of the result of an arithmetic operation
such that i can tell that a real number is the result of the operation on 2 imaginary numbers?
tclviii-dyalog
 
Posts: 28
Joined: Tue Mar 02, 2010 6:04 pm

Re: using sqr root minus one as error code

Postby DanB|Dyalog on Thu Dec 15, 2011 7:26 pm

There is no such flag but you can always use the numbers themselves as flag by extracting the irrational part using 11o, i.e.

      {⍵,[1.1]0≠11○⍵}n×*○0j.5×n←⍳9
0J01 1
¯2 0
0J¯3 1
4 0
0J05 1
¯6 0
0J¯7 1
8 0
0J09 1
DanB|Dyalog
 

Re: using sqr root minus one as error code

Postby Dick Bowman on Fri Dec 16, 2011 1:41 pm

I'm a bit puzzled, when you say "irrational number" - do you mean "complex number"?

Off the top of my head I wonder whether using zilde as the fill might be a useable alternative...

      ]displayr 1 2 ⍬ 4 + 5 ⍬ 7 8
┌4───────────────┐
│ ┌0─┐ ┌0─┐ │
│ 6 │ 0│ │ 0│ 12 │
│ └~─┘ └~─┘ │
└¯2──────────────┘


which is - loosely - what I've done in the past in similar contexts.

But I can see merit also in using complex numbers with real part for value and imaginary part as an indicator - depends on the application.
Visit http://apl.dickbowman.com to read more from Dick Bowman
User avatar
Dick Bowman
 
Posts: 235
Joined: Thu Jun 18, 2009 4:55 pm


Return to APL Chat

Who is online

Users browsing this forum: No registered users and 1 guest