Complex matrix computation

Hi qbies,

May I know if there is any existing libraries to perform computation with complex matrices (matrices whose elements are complex numbers)?

q can perform real number matrix arithmetic natively. Libraries like qml can help with performing more complex calculations with real matrices.

While it’s trivial to implement simple complex number arithmetic in q, doing so for complex number matrices is tedious. So I wonder if there is any prior work in this area.

Best regards,

Freddie

Hi Freddie,

Unfortunately I do not believe there is currently anything available that will do what you want.

Kind Regards,

Andrew

what arithmetic/calculations do you need?

Operands: complex numbers, complex vectors, complex matrices (vectors/matrices whose elements are complex numbers)
Operations: plus/minus, multiplication, matrix inversion

there’s a trick to code complex numbers as real matrices   http://www.sosmath.com/matrix/complex/complex.html

using a+bi is like (a;b;-b;a) we can do addition and multiplication as

q)x:(0 1.;-1 0.)  /0+i

q)y:(1 2.;-2 1.)  /1+2i

q)x+y  /complex addition

1  3

-3 1
q)x mmu y  /complex multiplication

-2 1 

-1 -2

x div y is x mmu inv y

complex matrix multiplication: i shouldn’t really publish this as i haven’t checked it

q)cmmu:{x{sum(mmu).'flip(x;y)}/::flip y}

q)0N!cmmu[((p;y);(x;y));((x;y);(p:(4 4.;-4 4.);y))];

(((-8 16f;-16 -8f);(-7 16f;-16 -7f));((-5 12f;-12 -5f);(-5 5f;-5 -5f)))

Thanks for the pointer, effbiae!

I’ll give it a try and see how far I can get the problem solved without a messy introduction of binary libs.