Using core.matrix.complex for complex matrix arithmetic

55 views
Skip to first unread message

Willem Price

unread,
Mar 7, 2016, 1:42:54 PM3/7/16
to Numerical Clojure
Hello,

I am trying to use the core.matrix.complex library to do matrix multiplication and such with complex numbers, but I cannot get it to work. The library uses complex.core to define and manipulate complex numbers, and core.matrix to do matrix arithmetic. I saw it talked about in a couple of posts, but there was not much information on how complete it is, and how to use it.

Using matrix multiplication, mmul, as an example, I can require core.matrix as mat, and then do (mat/mmul matrix1 matrix2) and it works no problem. However, if I require core.matrix.complex and then try to do mmul, the function is undefined. Naturally, I tried requiring them both and using them together, but if I do (mat/mmul cmat1 cmat2), where cmat means a complex matrix, I get a "ClassCastException org.apache.commons.math3.complex.Complex cannot be cast to java.lang.Number"

I am not that familiar with protocols and deftype, so I haven't been able to decipher the library and how it's supposed to be used. Can anyone help me?

Thanks in advance,

Will

Mike Anderson

unread,
Mar 7, 2016, 7:48:23 PM3/7/16
to Numerical Clojure
Haven't looked at the library in a while, it was always a bit experimental and it is possible that dependencies need updating.

Just had a quick look and mmul doesn't yet support complex numbers, but you should be able to use "inner-product" instead which I think is working OK (and it does the same thing for matrix arguments)
Reply all
Reply to author
Forward
0 new messages