Package org.jquantlib.math.matrixutilities

Examples of org.jquantlib.math.matrixutilities.Matrix$RangeCol


    @Override
    public final /*@Covariance*/ Matrix covariance(final /*@Time*/ double t0, final /*@Real*/ Array x0, final /*@Time*/ double dt) {
        QL.require(x0.size()==1 , ARRAY_1D_REQUIRED); // TODO: message
        final double v = discretization1D.varianceDiscretization(this, t0, x0.first(), dt);
        return new Matrix(1, 1).fill(v);
    }
View Full Code Here


        testToString(fFlags);
    }

    private void testToString(final Set<Address.Flags> flags) {

        final Matrix M1 = new Matrix(new double[][] {
              { 1.00.90.7 },
              { 0.91.00.4 },
              { 0.70.41.0 }
        }, flags);

        final Matrix M2 = new Matrix(new double[][] {
              { 1.00.90.7 },
              { 0.91.00.3 },
              { 0.70.31.0 }
        }, flags);

        final Matrix I = new Identity(3, flags);

        final Matrix M3 = new Matrix(new double[][] {
              { 1,   2,   3,   4 },
              { 2,   0,   2,   1 },
              { 0,   1,   0,   0 }
        }, flags);

        final Matrix M4 = new Matrix(new double[][] {
              {  1,   2,   400    },
              2,   0,     1    },
              { 30,   2,     0    },
              2,   0,     1.05 }
        }, flags);

        // from Higham - nearest correlation matrix
        final Matrix M5 = new Matrix(new double[][] {
              {  2,   -1,     0,    0 },
              { -1,    2,    -1,    0 },
              0,   -1,     2,   -1 },
              0,    0,    -1,    2 },
        }, flags);

        final Matrix matrices[] = { M1, M2, M3, M4, M5 };

//        for (final Matrix m : matrices) {
//            System.out.println(m);
//        }
    }
View Full Code Here

        toFortran(fFlags);
    }

    private void toFortran(final Set<Address.Flags> flags) {

        final Matrix M1 = new Matrix(new double[][] {
              { 1.00.90.7 },
              { 0.91.00.4 },
              { 0.70.41.0 }
        }, flags);

        final Matrix M2 = new Matrix(new double[][] {
              { 1.00.90.7 },
              { 0.91.00.3 },
              { 0.70.31.0 }
        }, flags);

        final Matrix I = new Identity(3, flags);

        final Matrix M3 = new Matrix(new double[][] {
              { 1,   2,   3,   4 },
              { 2,   0,   2,   1 },
              { 0,   1,   0,   0 }
        }, flags);

        final Matrix M4 = new Matrix(new double[][] {
              {  1,   2,   400    },
              2,   0,     1    },
              { 30,   2,     0    },
              2,   0,     1.05 }
        }, flags);

        // from Higham - nearest correlation matrix
        final Matrix M5 = new Matrix(new double[][] {
              {  2,   -1,     0,    0 },
              { -1,    2,    -1,    0 },
              0,   -1,     2,   -1 },
              0,    0,    -1,    2 },
        }, flags);

        final Matrix matrices[] = { M1, M2, M3, M4, M5 };

//        for (final Matrix m : matrices) {
//            System.out.println(m.toFortran());
//        }
    }
View Full Code Here

        toJava(fFlags);
    }

    private void toJava(final Set<Address.Flags> flags) {

        final Matrix M1 = new Matrix(new double[][] {
              { 1.00.90.7 },
              { 0.91.00.4 },
              { 0.70.41.0 }
        }, flags);

        final Matrix M2 = new Matrix(new double[][] {
              { 1.00.90.7 },
              { 0.91.00.3 },
              { 0.70.31.0 }
        }, flags);

        final Matrix I = new Identity(3, flags);

        final Matrix M3 = new Matrix(new double[][] {
              { 1,   2,   3,   4 },
              { 2,   0,   2,   1 },
              { 0,   1,   0,   0 }
        }, flags);

        final Matrix M4 = new Matrix(new double[][] {
              {  1,   2,   400    },
              2,   0,     1    },
              { 30,   2,     0    },
              2,   0,     1.05 }
        }, flags);

        // from Higham - nearest correlation matrix
        final Matrix M5 = new Matrix(new double[][] {
              {  2,   -1,     0,    0 },
              { -1,    2,    -1,    0 },
              0,   -1,     2,   -1 },
              0,    0,    -1,    2 },
        }, flags);

        final Matrix matrices[] = { M1, M2, M3, M4, M5 };

//        for (final Matrix m : matrices) {
//            System.out.println(m.toJava());
//        }
    }
View Full Code Here

        testClone(fFlags, jFlags);
        testClone(fFlags, fFlags);
    }

    private void testClone(final Set<Address.Flags> flagsA, final Set<Address.Flags> flagsB) {
        final Matrix mA = new Matrix(new double[][] {
                { 1.0, 2.0, 3.0, 4.0 },
                { 1.0, 2.0, 3.0, 4.0 },
                { 1.0, 2.0, 3.0, 4.0 },
        }, flagsA);

        final Matrix mB = new Matrix(new double[][] {
                { 1.0, 2.0, 3.0, 4.0 },
                { 1.0, 2.0, 3.0, 4.0 },
                { 1.0, 2.0, 3.0, 4.0 },
        }, flagsB);

        final Matrix m = mA.clone();
        if (m == mA) {
            fail("'clone' must return a new instance");
        }
        if (m == mB) {
            fail("'clone' must return a new instance");
View Full Code Here

        empty(jFlags);
        empty(fFlags);
    }

    private void empty(final Set<Address.Flags> flags) {
        final Matrix mA = new Matrix(new double[][] {
                { 1.0, 2.0, 3.0, 4.0 },
                { 1.0, 2.0, 3.0, 4.0 },
                { 1.0, 2.0, 3.0, 4.0 },
        }, flags);

        if (mA.empty()) {
            fail("'empty' failed");
        }
    }
View Full Code Here

        fill(jFlags);
        fill(fFlags);
    }

    private void fill(final Set<Address.Flags> flags) {
        final Matrix mA = new Matrix(new double[][] {
                { 2.0, 2.0, 2.0, 2.0 },
                { 2.0, 2.0, 2.0, 2.0 },
                { 2.0, 2.0, 2.0, 2.0 },
        }, flags);

        final Matrix m = new Matrix(3, 4).fill(2.0);
        if (!equals(m, mA)) {
            fail("'fill' failed");
        }
    }
View Full Code Here

        addAssign(fFlags, jFlags);
        addAssign(fFlags, fFlags);
    }

    private void addAssign(final Set<Address.Flags> flagsA, final Set<Address.Flags> flagsB) {
        final Matrix mA = new Matrix(new double[][] {
                { 1.0, 2.0, 3.0, 4.0 },
                { 1.0, 2.0, 3.0, 4.0 },
                { 1.0, 2.0, 3.0, 4.0 },
                { 1.0, 2.0, 3.0, 4.0 },
        }, flagsA);

        final Matrix mB = new Matrix(new double[][] {
                { 4.0, 3.0, 2.0, 1.0 },
                { 5.0, 4.0, 3.0, 2.0 },
                { 6.0, 5.0, 4.0, 3.0 },
                { 7.0, 6.0, 5.0, 4.0 },
        }, flagsB);


        final Matrix m = mA.addAssign(mB);
        if (m != mA) {
            fail("addAssign must return <this>");
        }

        final int offset = m.offset();
        for (int row=offset; row<m.rows()+offset; row++) {
            for (int col=offset; col<m.cols()+offset; col++) {
                if (m.get(row, col) != row-offset+5) {
                    fail("addAssign failed");
                }
            }
        }
    }
View Full Code Here

        subAssign(fFlags, jFlags);
        subAssign(fFlags, fFlags);
    }

    private void subAssign(final Set<Address.Flags> flagsA, final Set<Address.Flags> flagsB) {
        final Matrix mA = new Matrix(new double[][] {
                { 1.0, 2.0, 3.0, 4.0 },
                { 1.0, 2.0, 3.0, 4.0 },
                { 1.0, 2.0, 3.0, 4.0 },
                { 1.0, 2.0, 3.0, 4.0 },
        }, flagsA);

        final Matrix mB = new Matrix(new double[][] {
                { 4.0, 5.0, 6.07.0 },
                { 5.0, 6.0, 7.08.0 },
                { 6.0, 7.0, 8.09.0 },
                { 7.0, 8.0, 9.0, 10.0 },
        }, flagsB);


        final Matrix m = mB.subAssign(mA);
        if (m != mB) {
            fail("subAssign must return <this>");
        }

        final int offset = m.offset();
        for (int row=offset; row<m.rows()+offset; row++) {
            for (int col=offset; col<m.cols()+offset; col++) {
                if (m.get(row, col) != row-offset+3) {
                    fail("subAssign failed");
                }
            }
        }
    }
View Full Code Here

        mulAssign(jFlags);
        mulAssign(fFlags);
    }

    private void mulAssign(final Set<Address.Flags> flags) {
        final Matrix mA = new Matrix(new double[][] {
                { 1.0, 2.0, 3.0, 4.0 },
                { 1.0, 2.0, 3.0, 4.0 },
                { 1.0, 2.0, 3.0, 4.0 },
                { 1.0, 2.0, 3.0, 4.0 },
        }, flags);

        final Matrix m = mA.mulAssign(2.5);
        if (m != mA) {
            fail("mulAssign must return <this>");
        }

        final int offset = m.offset();
        for (int row=offset; row<m.rows()+offset; row++) {
            for (int col=offset; col<m.cols()+offset; col++) {
                if (!Closeness.isClose(m.get(row, col), (col-offset+1)*2.5)) {
                    fail("mulAssign failed");
                }
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.jquantlib.math.matrixutilities.Matrix$RangeCol

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.