What package do you recommend to work with matrix polynomials, i.e., expressions of the form A(x) = A_0 + A_1 x + \dots + A_d x^d?
I will use mainly the coefficients to do linear algebra, so I am interested in a package that keeps the coefficients A_i stored in contiguous arrays: a Matrix{Polynomial} wouldn’t be convenient.
After a quick search I found these packages, but they all have some drawbacks:
GitHub - jagot/MatrixPolynomials.jl : despite the encouraging name, it deals with a completely different concept (polynomials with scalar coefficients evaluated in a matrix, as in Krylov subspaces and matrix functions).
GitHub - andreasvarga/MatrixPencils.jl: Matrix pencil manipulations using Julia : while it has many useful decompositions implemented, it does not contain good Julian syntactic sugar to work with matrix polynomials: there isn’t even a convenience type for matrix polynomials to define A * B to compute A(x)B(x), for instance.
What operations do you want to perform? The Polynomials.jl package can do simple computations with these already, since from its perspective matrices are just a particular kind of coefficient:
Of course, if if you want to compute A(x) v where v is a vector, then it is inefficient to add all of the matrices first — better to multiply each term by v and accumulate them in-place. I don’t think Polynomials.jl has a specialized method for this but it would be easy to add.
But if you need more specialized linear-algebra functions (which?) they would be better off in another package (maybe built-in top of Polynomials).
Thanks, that should work! I had incorrectly assumed that Polynomials.jl wouldn’t work for matrix coefficients, as Google took me to an older version of the docs which had a constraint T <: Number.
I don’t need complicated operations, mostly it’s enough to have a a container type that supports sums / poly-poly products / pretty-printing, so Polynomials.jl should do the job.