[SciPy-User] problem with dot for complex matrices

Ryan Krauss ryanlists at gmail.com
Wed Mar 28 15:04:20 EDT 2012


Saving and loading the arrays seems to lead to a reproducible error,
at least on my machine:

d = numpy.load('testing.npz')
submat_inv_num = d['submat_inv_num']; augcol_num = d['augcol_num']
-1*dot(submat_inv_num, augcol_num)

In [5]: -1*dot(submat_inv_num, augcol_num)
Out[5]:
array([[  5.30985737e-05+0.00038316j],
       [  1.72370377e-04+0.00115503j]])

On Wed, Mar 28, 2012 at 12:22 AM, Aronne Merrelli
<aronne.merrelli at gmail.com> wrote:
> On Tue, Mar 27, 2012 at 2:56 PM, Ryan Krauss <ryanlists at gmail.com> wrote:
>> The matrices are initially created by these lines:
>>
>>        matout=scipy.zeros((n,n),dtype=complex128)#+0j
>>        colout=scipy.zeros((n,1),dtype=complex128)#+0j
>>
>> They get assigned values from a matrix created using
>>
>> U=scipy.eye(self.maxsize+1,dtype=complex128)
>>
>> And when I ask for their types I get:
>>
>> In [15]: type(augcol_num)
>> Out[15]: <type 'numpy.ndarray'>
>>
>> In [16]: type(submat_inv_num)
>> Out[16]: <type 'numpy.ndarray'>
>>
>> So, I don't believe they are subtyped.
>>
>
> The only other idea I have is to check if you can save the "problem"
> arrays. Specifically, try this, with the arrays that give the
> incorrect dot product:
>
> In [6]: savez('testing.npz', submat_inv_num=submat_inv_num,
> augcol_num=augcol_num)
>
> Then load them into a new session:
>
> In [1]: d = load('testing.npz')
>
> In [2]: submat_inv_num = d['submat_inv_num']; augcol_num = d['augcol_num']
>
> Do the reloaded variables give the same incorrect dot product? It is
> probably a long shot, since I would imagine the save/load would be
> similar to copy... but if it works then others might be able to
> inspect the object to see what might be different. One last detail -
> it looks like the augcol is getting cast to a real number - (this is a
> clearer example than what I showed earlier):
>
> In [17]: dot(submat_inv_num,  augcol_num.real)
> Out[17]:
> array([[ -5.30985748e-05-0.00038316j],
>       [ -1.72370374e-04-0.00115503j]])
>
> That might be a clue that something is causing augcol_num to get cast
> into a "normal" float before the dot product is taken.
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testing.npz
Type: application/octet-stream
Size: 494 bytes
Desc: not available
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20120328/338670b5/attachment.obj>


More information about the SciPy-User mailing list