[Matrix-SIG] To make NaN work on NT (was) Multipack on Windows with mingw32
Yoon, Hoon (CICG - NY Program Trading)
HYoon@exchange.ml.com
Tue, 8 Jun 1999 15:53:11 -0400
Has anyone made CXX work with mingw32?
Plus:
I made slight improvement on Janko's NaN finding syntax to make the thing
work for NT and Win platform. Somehow INF trick below works.
comparA = not_equal(d,INF)
Not sure why, but it works and I am happy.
----------------------
from Numeric import *
import sys
INF = 1e1000**1000000
NA = (INF/INF)
def packr( M, axis=1):
"""
Returns only rows or colums, which is Not NaN (Packr is Gauss by
Aptech func)
I am not sure this works for n-dim matrix, but works for 2d. axis
is bit confusing for a Gauss person
"""
return take( M, isanx(M))
def isanx(d, axis=1):
if sys.platform == 'win32':
comparA = not_equal(d,INF)
if len(d.shape) == 2:
return nonzero(equal(add.reduce(comparA,axis),
d.shape[axis]))
elif len(d.shape) == 1:
return nonzero(ComparA)
else:
raise IndexError, "function : packr is for up to 2D
matrix only"
else:
if len(d.shape) == 2:
return nonzero(equal(add.reduce(equal(d,d),axis),
d.shape[axis]))
elif len(d.shape) == 1: return nonzero(equal(d,d))
else: raise IndexError, "function : packr is for up to 2D
matrix only"
if __name__ == '__main__':
x = zeros((3,6),'f')
x[2,4] = NA
print x
print packr(x)
**************************************************************
S. Hoon Yoon (Quant) Merrill Lynch
Equity Trading
yelled@yahoo.com hoon@bigfoot.com(w)
"Miracle is always only few standard deviations away, but so is
catastrophe."
* Expressed opinions are often my own, but NOT my employer's.
"I feel like a fugitive from the law of averages." Mauldin
**************************************************************