javaapache-commons-math

initialize complex Sparse matrix


I have declared a Sparse complex matrix with the apache commons-math and I have absolutely no clue on how to initialize it, besides, the documentation seems quite poor.

import org.apache.commons.math3.linear.SparseFieldMatrix;

SparseFieldMatrix<Complex> Y;

if I try to set Y equal to a new instance it returns an error of no suitable constructor, and if I call the Y.CreateMatrix(int, int) it will tell that Y is Null.

So, how to initialize Y ?


Solution

  • I don't know the library, but looking at the Javadoc I think this should do the trick:

    SparseFieldMatrix Y = new SparseFieldMatrix<>(ComplexField.getInstance());