[SciPy-user] conj and element-by-element multiplication
Scott Ransom
sransom at nrao.edu
Fri May 20 23:24:21 EDT 2005
Hi David,
You can prevent the upcasts using the .savespace() method. For
example:
In [8]:a = arange(10.0, typecode='F')
In [9]:a**2
Out[9]: array([ 0.+0.j, 1.+0.j, 4.+0.j, 9.+0.j, 16.+0.j,
25.+0.j, 36.+0.j, 49.+0.j, 64.+0.j, 81.+0.j])
In [10]:a.savespace()
In [11]:a**2
Out[11]: array([ 0.+0.j, 1.+0.j, 4.+0.j, 9.+0.j,
16.+0.j, 25.+0.j, 36.+0.j, 49.+0.j, 64.+0.j, 81.+0.j],'F')
This is _very_ useful when dealing with very large arrays...
Scott
> Curious. One more question: are these Complex32 matrices? I.e., are
> they matrices using C floats (single precision), as opposed to C
> doubles (double precision)? The reason is that if x is a vector of
> floats, x**2 upcasts x to doubles first (b/c 2 is an int -- ints are
> cast to doubles), so that kills the speed, and I can get timings like
> this. This isn't a good behaviour, and I'm going to see what I can do
> to fix this for the next version of Numeric.
>
--
Scott M. Ransom Address: NRAO
Phone: (434) 296-0320 520 Edgemont Rd.
email: sransom at nrao.edu Charlottesville, VA 22903 USA
GPG Fingerprint: 06A9 9553 78BE 16DB 407B FFCA 9BFA B6FF FFD3 2989
More information about the SciPy-User
mailing list