Search in sources :

Example 1 with SimpleMatrix

use of cbit.vcell.matrix.SimpleMatrix in project vcell by virtualcell.

the class SVDTest method findNullSpaceVCell.

/**
 * Insert the method's description here.
 * Creation date: (5/13/2003 4:37:34 PM)
 * @param matrix Jama.Matrix
 */
public static RationalMatrix findNullSpaceVCell(RationalMatrix rA) {
    try {
        SimpleMatrix A = new SimpleMatrix(getJamaMatrix(rA).getArrayCopy());
        SimpleMatrix ns = SimpleMatrix.findNullSpace(A);
        // ns.show();
        RationalMatrixFast nsRationalMatrix = getRationalMatrixFast(ns);
        // nsRationalMatrix.show();
        return nsRationalMatrix;
    } catch (Throwable e) {
        e.printStackTrace(System.out);
        throw new RuntimeException(e.getMessage());
    }
}
Also used : SimpleMatrix(cbit.vcell.matrix.SimpleMatrix) RationalMatrixFast(cbit.vcell.matrix.RationalMatrixFast)

Example 2 with SimpleMatrix

use of cbit.vcell.matrix.SimpleMatrix in project vcell by virtualcell.

the class SVDTest method main.

/**
 * Starts the application.
 * @param args an array of command-line arguments
 */
public static void main(java.lang.String[] args) {
    try {
        Jama.Matrix A = getJamaMatrix(getGEPASI_Brusselator());
        Jama.Matrix At = A.transpose();
        Jama.SingularValueDecomposition svdMatrix = new Jama.SingularValueDecomposition(At);
        Jama.Matrix U = svdMatrix.getU();
        Jama.Matrix V = svdMatrix.getV();
        double[] S = svdMatrix.getSingularValues();
        System.out.println("A' = U*S*V'");
        System.out.println("A' = ");
        At.print(8, 5);
        System.out.println("U = ");
        U.print(8, 5);
        System.out.println("V = ");
        V.print(8, 5);
        System.out.print("S = ");
        for (int i = 0; i < S.length; i++) {
            System.out.print(S[i] + " ");
        }
        System.out.println();
        int rank = svdMatrix.rank();
        System.out.println("rank = " + rank);
        Jama.Matrix Vt = V.transpose();
        Jama.Matrix nsMatrix = Vt.getMatrix(rank, Vt.getRowDimension() - 1, 0, Vt.getColumnDimension() - 1);
        System.out.println("NS = ");
        nsMatrix.print(8, 5);
        SimpleMatrix matrix = new SimpleMatrix(nsMatrix.getArrayCopy());
        matrix.show();
        SimpleMatrix.gaussianElimination(new SimpleMatrix(matrix.getNumRows(), matrix.getNumRows()), matrix);
        matrix.show();
        RationalMatrixFast nsRationalMatrix = getRationalMatrixFast(matrix);
        nsRationalMatrix.show();
    } catch (Throwable e) {
        e.printStackTrace(System.out);
    }
}
Also used : SimpleMatrix(cbit.vcell.matrix.SimpleMatrix) RationalMatrixFast(cbit.vcell.matrix.RationalMatrixFast)

Example 3 with SimpleMatrix

use of cbit.vcell.matrix.SimpleMatrix in project vcell by virtualcell.

the class SVDTest method findNullSpaceSVD.

/**
 * Insert the method's description here.
 * Creation date: (5/13/2003 4:37:34 PM)
 * @param matrix Jama.Matrix
 */
public static RationalMatrix findNullSpaceSVD(RationalMatrix rA) {
    try {
        Jama.Matrix A = getJamaMatrix(rA);
        Jama.Matrix At = A.transpose();
        Jama.SingularValueDecomposition svdMatrix = new Jama.SingularValueDecomposition(At);
        Jama.Matrix U = svdMatrix.getU();
        Jama.Matrix V = svdMatrix.getV();
        double[] S = svdMatrix.getSingularValues();
        // System.out.println("A' = U*S*V'");
        // System.out.println("A' = ");
        // At.print(8,5);
        // System.out.println("U = ");
        // U.print(8,5);
        // System.out.println("V = ");
        // V.print(8,5);
        // System.out.print("S = ");
        // for (int i = 0; i < S.length; i++){
        // System.out.print(S[i]+" ");
        // }
        // System.out.println();
        int rank = svdMatrix.rank();
        // System.out.println("rank = "+rank);
        Jama.Matrix Vt = V.transpose();
        Jama.Matrix nsMatrix = Vt.getMatrix(rank, Vt.getRowDimension() - 1, 0, Vt.getColumnDimension() - 1);
        // System.out.println("NS = ");
        // nsMatrix.print(8,5);
        SimpleMatrix matrix = new SimpleMatrix(nsMatrix.getArrayCopy());
        // matrix.show();
        SimpleMatrix.gaussianElimination(new SimpleMatrix(matrix.getNumRows(), matrix.getNumRows()), matrix);
        // matrix.show();
        RationalMatrixFast nsRationalMatrix = getRationalMatrixFast(matrix);
        // nsRationalMatrix.show();
        return nsRationalMatrix;
    } catch (Throwable e) {
        e.printStackTrace(System.out);
        throw new RuntimeException(e.getMessage());
    }
}
Also used : SimpleMatrix(cbit.vcell.matrix.SimpleMatrix) RationalMatrixFast(cbit.vcell.matrix.RationalMatrixFast)

Aggregations

RationalMatrixFast (cbit.vcell.matrix.RationalMatrixFast)3 SimpleMatrix (cbit.vcell.matrix.SimpleMatrix)3