< Back to IRCAM Forum

Matrix class in OM

I would like to define matrices A, B and perform matrix operations such as A.B (product) and A^(-1) (matrix inversion).
Is this currently implemented in OM or some toolbox?
Can matrices of numbers easily be represented using the ClassArray (OpenMusic Documentation - Array)?
Thank you

Follow-up

  • If you write matrices as lists, e.g., ((1 0) (0 2)), it is straightforward to write a loop to calculate a matrix multiplication.
  • But implementing the matrix inversion is more difficult in graphical programming. Is it possible to write a lisp function, using for instance the invert function mentioned here (Multidimensional arrays)?

Although @haddad can probably tell you exactly what the om:ClassArray type is useful for (also see here), it seems to me that if you want to do “serious” linear algebra, you’re going to have to pick priorities.

How important to you, relative to one another, are the following qualities:

  1. Ease of installation? Adding third-party tools to OM is possible, but it takes a bit of Lisp hacking. Some libraries aren’t tested on LispWorks.⁽¹⁾

  2. Ease of use? The ClassArray class is integrated with OM’s graphical language. Third-party tools will work better if, again, you can program directly in Common Lisp.

  3. Efficiency? The very fastest linear-algebra libraries delegate to BLAS and LAPACK; that’s an entirely different kettle of fish.

-Jonathan

ETA:
(1) File under ‘#Porting OpenMusic to #SBCL.’

Hi testmw,

As Jonathan states, it all depends on what you want to do. If it is just math calculation on matrices, you don’t need the Class classarray to do so. You can build lisp arrays and work from there.

Best
K

@testmw – I’m going to surmise, based on the fact that you were considering going about it with nested lists, that point 3 is not paramount.

Since you’ve expressed willingness to code, take a look at this list. If all you need is a reasonably complete matrix algebra interface, I would suggest starting with CLEM, because it does not depend on Fortran.