Package org.jquantlib.math.matrixutilities

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


        divAssign(jFlags);
        divAssign(fFlags);
    }

    private void divAssign(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.divAssign(2.5);
        if (m != mA) {
            fail("divAssign 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("divAssign failed");
                }
            }
        }
    }
View Full Code Here


        add(fFlags, jFlags);
        add(fFlags, fFlags);
    }

    private void add(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.add(mB);
        if (m == mA) {
            fail("'add' must return a new instance");
        }
        if (m.rows() != mA.rows() || m.cols() != mA.cols()) {
            fail("'add' failed");
        }

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

        sub(fFlags, fFlags);
    }

    private void sub(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.sub(mA);
        if (m == mB) {
            fail("'sub' must return a new instance");
        }
        if (m.rows() != mB.rows() || m.cols() != mB.cols()) {
            fail("'sub' failed");
        }

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

        mulScalar(fFlags);
    }

    private void mulScalar(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.mul(2.5);
        if (m == mA) {
            fail("'sub' must return a new instance");
        }
        if (m.rows() != mA.rows() || m.cols() != mA.cols()) {
            fail("'sub' failed");
        }

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

        mulArray(fFlags, fFlags);
    }

    private void mulArray(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 },
                { 1.0, 2.0, 3.0, 4.0 },
        }, flagsA);

        final Array aD = new Array(new double[] { 1.0, 1.0, 1.0, 1.0 }, flagsB);

        final Array a = mA.mul(aD);
        if (a.size() != mA.rows()) {
            fail("'mul' failed");
        }

        final int offset = a.flags().contains(Address.Flags.FORTRAN) ? 1 : 0;
        for (int col=offset; col<a.cols()+offset; col++) {
View Full Code Here

        mulMatrix(fFlags, jFlags);
        mulMatrix(fFlags, fFlags);
    }

    private void mulMatrix(final Set<Address.Flags> flagsA, final Set<Address.Flags> flagsB) {
        final Matrix mI = new Matrix(new double[][] {
                { 1, 0, 0, 0 },
                { 0, 1, 0, 0 },
                { 0, 0, 1, 0 },
                { 0, 0, 0, 1 },
        }, flagsA);

        final Matrix mA = 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 = mI.mul(mA);
        if (m == mI) {
            fail("'mul' must return a new instance");
        }
        if (m == mA) {
            fail("'mul' must return a new instance");
View Full Code Here

        divScalar(jFlags);
        divScalar(fFlags);
    }

    private void divScalar(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 },
        });

        final Matrix m = mA.div(2.5);
        if (m == mA) {
            fail("'div' must return a new instance");
        }
        if (m.rows() != mA.rows() || m.cols() != mA.cols()) {
            fail("'add' failed");
        }

        for (int row=0; row<m.rows(); row++) {
            for (int col=0; col<m.cols(); col++) {
                if (!Closeness.isClose(m.get(row, col), (col+1)/2.5)) {
                    fail("'div' failed");
                }
            }
        }
    }
View Full Code Here

        swap(fFlags, jFlags);
        swap(fFlags, fFlags);
    }

    private void swap(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 mAclone = mA.clone();
        final Matrix mBclone = mB.clone();

        mA.swap(mB);
        if (!equals(mA, mBclone)) {
            fail("'swap' failed");
        }
View Full Code Here

        transpose(fFlags, jFlags);
        transpose(fFlags, fFlags);
    }

    private void transpose(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, 1.0, 1.0 },
                { 2.0, 2.0, 2.0 },
                { 3.0, 3.0, 3.0 },
                { 4.0, 4.0, 4.0 },
        }, flagsB);

        final Matrix m = mA.transpose();

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

        diagonal(fFlags, jFlags);
        diagonal(fFlags, fFlags);
    }

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

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

        if (!ArrayTest.equals(mA.diagonal(), aA)) {
            fail("'diagonal' failed");
        }
    }
View Full Code Here

TOP

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

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.