[SciPy-User] problem with dot for complex matrices

Ryan Krauss ryanlists at gmail.com
Tue Mar 27 15:56:14 EDT 2012


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.

On Tue, Mar 27, 2012 at 2:49 PM, Ryan Krauss <ryanlists at gmail.com> wrote:
> Thanks for digging further.  I don't think I ever deliberately
> subclass ndarray....(let me look into it).
>
> On Tue, Mar 27, 2012 at 2:35 PM, Aronne Merrelli
> <aronne.merrelli at gmail.com> wrote:
>> On Tue, Mar 27, 2012 at 2:26 PM, Ryan Krauss <ryanlists at gmail.com> wrote:
>>> To further add to my own mystery, why does this fix the problem:
>>>
>>> In [37]: -1*numpy.dot(submat_inv_num, augcol_num)
>>> Out[37]:
>>> array([[  5.30985737e-05+0.00038316j],
>>>       [  1.72370377e-04+0.00115503j]])
>>>
>>
>>
>> It appears to be equal to:
>>
>> In [1]: M = array([[-0.22740265-1.63857451j, -0.07740957-0.55847886j],
>>   ...:       [-3.20602957-4.93959054j, -0.36746252-1.68352465j]])
>>
>> In [2]: x = array([[ -3.74729148e-05-0.0005937j ],
>>   ...:       [  7.96025801e-04+0.01137658j]])
>>
>> In [16]: -1 * (dot(M.real,x.real) + 1j*dot(M.imag,x.real))
>> Out[16]:
>> array([[  5.30985748e-05+0.00038316j],
>>       [  1.72370374e-04+0.00115503j]])
>>
>>
>> I don't have any idea why it is doing that. You've never posted what
>> the type of those arrays are, though - is it possible it is a subclass
>> of ndarray that is doing something strange to the dot method? I think
>> the call to copy might put it back into a "plain" ndarray.
>> _______________________________________________
>> SciPy-User mailing list
>> SciPy-User at scipy.org
>> http://mail.scipy.org/mailman/listinfo/scipy-user



More information about the SciPy-User mailing list