mtj

Solve task using matrix toolkit java


I have matrix A and vector t. And I need to find vector x, so that A*x = t So there are just 2 steps, convert maxtrix A and vector t to triangle, and then find vector x (or mb it can be done just in one step using this library, idk). How can I do this using MTJ? There is really few documentation or information about MTJ.


Solution

  • I found how to do it:

    double[][] matrix = new double[n][n];
    double[] vector = new double[n];
    
    Matrix A = new DenseMatrix(matrix);
    Vector t = new DenseVector(vector);
    Vector x = new DenseVector(n);
    A.solve(t,x)
    

    And then we will have answer in x