当前位置: 首页>>代码示例>>Java>>正文


Java Fraction.ZERO属性代码示例

本文整理汇总了Java中org.apache.commons.math3.fraction.Fraction.ZERO属性的典型用法代码示例。如果您正苦于以下问题:Java Fraction.ZERO属性的具体用法?Java Fraction.ZERO怎么用?Java Fraction.ZERO使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.commons.math3.fraction.Fraction的用法示例。


在下文中一共展示了Fraction.ZERO属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testNonSquare

/** test non-square matrix */
@Test
public void testNonSquare() {
    try {
        // we don't use FractionField.getInstance() for testing purposes
        new FieldLUDecomposition<Fraction>(new Array2DRowFieldMatrix<Fraction>(new Fraction[][] {
                { Fraction.ZERO, Fraction.ZERO },
                { Fraction.ZERO, Fraction.ZERO },
                { Fraction.ZERO, Fraction.ZERO }
        }));
        Assert.fail("Expected NonSquareMatrixException");
    } catch (NonSquareMatrixException ime) {
        // expected behavior
    }
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:15,代码来源:FieldLUDecompositionTest.java

示例2: testWalkInDefaultOrderPreservingVisitor3

/** Visiting a valid subvector. */
@Test
public void testWalkInDefaultOrderPreservingVisitor3() {
    final Fraction[] data = new Fraction[] {
        Fraction.ZERO, Fraction.ONE, Fraction.ZERO,
        Fraction.ZERO, Fraction.TWO, Fraction.ZERO,
        Fraction.ZERO, Fraction.ZERO, new Fraction(3)
    };
    final SparseFieldVector<Fraction> v = new SparseFieldVector<Fraction>(field, data);
    final int expectedStart = 2;
    final int expectedEnd = 7;
    final FieldVectorPreservingVisitor<Fraction> visitor;
    visitor = new FieldVectorPreservingVisitor<Fraction>() {

        private int expectedIndex;

        public void visit(final int actualIndex, final Fraction actualValue) {
            Assert.assertEquals(expectedIndex, actualIndex);
            Assert.assertEquals(Integer.toString(actualIndex),
                                data[actualIndex], actualValue);
            ++expectedIndex;
        }

        public void start(final int actualSize, final int actualStart,
                          final int actualEnd) {
            Assert.assertEquals(data.length, actualSize);
            Assert.assertEquals(expectedStart, actualStart);
            Assert.assertEquals(expectedEnd, actualEnd);
            expectedIndex = expectedStart;
        }

        public Fraction end() {
            return Fraction.ZERO;
        }
    };
    v.walkInDefaultOrder(visitor, expectedStart, expectedEnd);
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:37,代码来源:SparseFieldVectorTest.java

示例3: testWalkInOptimizedOrderPreservingVisitor1

/** The whole vector is visited. */
@Test
public void testWalkInOptimizedOrderPreservingVisitor1() {
    final Fraction[] data = new Fraction[] {
        Fraction.ZERO, Fraction.ONE, Fraction.ZERO,
        Fraction.ZERO, Fraction.TWO, Fraction.ZERO,
        Fraction.ZERO, Fraction.ZERO, new Fraction(3)
    };
    final SparseFieldVector<Fraction> v = new SparseFieldVector<Fraction>(field, data);
    final FieldVectorPreservingVisitor<Fraction> visitor;
    visitor = new FieldVectorPreservingVisitor<Fraction>() {
        private final boolean[] visited = new boolean[data.length];

        public void visit(final int actualIndex, final Fraction actualValue) {
            visited[actualIndex] = true;
            Assert.assertEquals(Integer.toString(actualIndex),
                                data[actualIndex], actualValue);
        }

        public void start(final int actualSize, final int actualStart,
                          final int actualEnd) {
            Assert.assertEquals(data.length, actualSize);
            Assert.assertEquals(0, actualStart);
            Assert.assertEquals(data.length - 1, actualEnd);
            Arrays.fill(visited, false);
        }

        public Fraction end() {
            for (int i = 0; i < data.length; i++) {
                Assert.assertTrue("entry " + i + "has not been visited",
                                  visited[i]);
            }
            return Fraction.ZERO;
        }
    };
    v.walkInOptimizedOrder(visitor);
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:37,代码来源:SparseFieldVectorTest.java

示例4: testWalkInDefaultOrderChangingVisitor1

/** The whole vector is visited. */
@Test
public void testWalkInDefaultOrderChangingVisitor1() {
    final Fraction[] data = new Fraction[] {
        Fraction.ZERO, Fraction.ONE, Fraction.ZERO,
        Fraction.ZERO, Fraction.TWO, Fraction.ZERO,
        Fraction.ZERO, Fraction.ZERO, new Fraction(3)
    };
    final SparseFieldVector<Fraction> v = new SparseFieldVector<Fraction>(field, data);
    final FieldVectorChangingVisitor<Fraction> visitor;
    visitor = new FieldVectorChangingVisitor<Fraction>() {

        private int expectedIndex;

        public Fraction visit(final int actualIndex, final Fraction actualValue) {
            Assert.assertEquals(expectedIndex, actualIndex);
            Assert.assertEquals(Integer.toString(actualIndex),
                                data[actualIndex], actualValue);
            ++expectedIndex;
            return actualValue.add(actualIndex);
        }

        public void start(final int actualSize, final int actualStart,
                          final int actualEnd) {
            Assert.assertEquals(data.length, actualSize);
            Assert.assertEquals(0, actualStart);
            Assert.assertEquals(data.length - 1, actualEnd);
            expectedIndex = 0;
        }

        public Fraction end() {
            return Fraction.ZERO;
        }
    };
    v.walkInDefaultOrder(visitor);
    for (int i = 0; i < data.length; i++) {
        Assert.assertEquals("entry " + i, data[i].add(i), v.getEntry(i));
    }
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:39,代码来源:SparseFieldVectorTest.java

示例5: create

private SparseFieldVector<Fraction> create(int n) {
    Fraction[] t = new Fraction[n];
    for (int i = 0; i < n; ++i) {
        t[i] = Fraction.ZERO;
    }
    return new SparseFieldVector<Fraction>(field, t);
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:7,代码来源:SparseFieldVectorTest.java

示例6: testWalkInDefaultOrderPreservingVisitor1

/** The whole vector is visited. */
@Test
public void testWalkInDefaultOrderPreservingVisitor1() {
    final Fraction[] data = new Fraction[] {
        Fraction.ZERO, Fraction.ONE, Fraction.ZERO,
        Fraction.ZERO, Fraction.TWO, Fraction.ZERO,
        Fraction.ZERO, Fraction.ZERO, new Fraction(3)
    };
    final ArrayFieldVector<Fraction> v = new ArrayFieldVector<Fraction>(data);
    final FieldVectorPreservingVisitor<Fraction> visitor;
    visitor = new FieldVectorPreservingVisitor<Fraction>() {

        private int expectedIndex;

        public void visit(final int actualIndex, final Fraction actualValue) {
            Assert.assertEquals(expectedIndex, actualIndex);
            Assert.assertEquals(Integer.toString(actualIndex),
                                data[actualIndex], actualValue);
            ++expectedIndex;
        }

        public void start(final int actualSize, final int actualStart,
                          final int actualEnd) {
            Assert.assertEquals(data.length, actualSize);
            Assert.assertEquals(0, actualStart);
            Assert.assertEquals(data.length - 1, actualEnd);
            expectedIndex = 0;
        }

        public Fraction end() {
            return Fraction.ZERO;
        }
    };
    v.walkInDefaultOrder(visitor);
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:35,代码来源:ArrayFieldVectorTest.java

示例7: testWalkInDefaultOrderPreservingVisitor3

/** Visiting a valid subvector. */
@Test
public void testWalkInDefaultOrderPreservingVisitor3() {
    final Fraction[] data = new Fraction[] {
        Fraction.ZERO, Fraction.ONE, Fraction.ZERO,
        Fraction.ZERO, Fraction.TWO, Fraction.ZERO,
        Fraction.ZERO, Fraction.ZERO, new Fraction(3)
    };
    final ArrayFieldVector<Fraction> v = new ArrayFieldVector<Fraction>(data);
    final int expectedStart = 2;
    final int expectedEnd = 7;
    final FieldVectorPreservingVisitor<Fraction> visitor;
    visitor = new FieldVectorPreservingVisitor<Fraction>() {

        private int expectedIndex;

        public void visit(final int actualIndex, final Fraction actualValue) {
            Assert.assertEquals(expectedIndex, actualIndex);
            Assert.assertEquals(Integer.toString(actualIndex),
                                data[actualIndex], actualValue);
            ++expectedIndex;
        }

        public void start(final int actualSize, final int actualStart,
                          final int actualEnd) {
            Assert.assertEquals(data.length, actualSize);
            Assert.assertEquals(expectedStart, actualStart);
            Assert.assertEquals(expectedEnd, actualEnd);
            expectedIndex = expectedStart;
        }

        public Fraction end() {
            return Fraction.ZERO;
        }
    };
    v.walkInDefaultOrder(visitor, expectedStart, expectedEnd);
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:37,代码来源:ArrayFieldVectorTest.java

示例8: testWalkInOptimizedOrderPreservingVisitor1

/** The whole vector is visited. */
@Test
public void testWalkInOptimizedOrderPreservingVisitor1() {
    final Fraction[] data = new Fraction[] {
        Fraction.ZERO, Fraction.ONE, Fraction.ZERO,
        Fraction.ZERO, Fraction.TWO, Fraction.ZERO,
        Fraction.ZERO, Fraction.ZERO, new Fraction(3)
    };
    final ArrayFieldVector<Fraction> v = new ArrayFieldVector<Fraction>(data);
    final FieldVectorPreservingVisitor<Fraction> visitor;
    visitor = new FieldVectorPreservingVisitor<Fraction>() {
        private final boolean[] visited = new boolean[data.length];

        public void visit(final int actualIndex, final Fraction actualValue) {
            visited[actualIndex] = true;
            Assert.assertEquals(Integer.toString(actualIndex),
                                data[actualIndex], actualValue);
        }

        public void start(final int actualSize, final int actualStart,
                          final int actualEnd) {
            Assert.assertEquals(data.length, actualSize);
            Assert.assertEquals(0, actualStart);
            Assert.assertEquals(data.length - 1, actualEnd);
            Arrays.fill(visited, false);
        }

        public Fraction end() {
            for (int i = 0; i < data.length; i++) {
                Assert.assertTrue("entry " + i + "has not been visited",
                                  visited[i]);
            }
            return Fraction.ZERO;
        }
    };
    v.walkInOptimizedOrder(visitor);
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:37,代码来源:ArrayFieldVectorTest.java

示例9: testWalkInOptimizedOrderPreservingVisitor3

/** Visiting a valid subvector. */
@Test
public void testWalkInOptimizedOrderPreservingVisitor3() {
    final Fraction[] data = new Fraction[] {
        Fraction.ZERO, Fraction.ONE, Fraction.ZERO,
        Fraction.ZERO, Fraction.TWO, Fraction.ZERO,
        Fraction.ZERO, Fraction.ZERO, new Fraction(3)
    };
    final ArrayFieldVector<Fraction> v = new ArrayFieldVector<Fraction>(data);
    final int expectedStart = 2;
    final int expectedEnd = 7;
    final FieldVectorPreservingVisitor<Fraction> visitor;
    visitor = new FieldVectorPreservingVisitor<Fraction>() {
        private final boolean[] visited = new boolean[data.length];

        public void visit(final int actualIndex, final Fraction actualValue) {
            Assert.assertEquals(Integer.toString(actualIndex),
                                data[actualIndex], actualValue);
            visited[actualIndex] = true;
        }

        public void start(final int actualSize, final int actualStart,
                          final int actualEnd) {
            Assert.assertEquals(data.length, actualSize);
            Assert.assertEquals(expectedStart, actualStart);
            Assert.assertEquals(expectedEnd, actualEnd);
            Arrays.fill(visited, true);
        }

        public Fraction end() {
            for (int i = expectedStart; i <= expectedEnd; i++) {
                Assert.assertTrue("entry " + i + "has not been visited",
                                  visited[i]);
            }
            return Fraction.ZERO;
        }
    };
    v.walkInOptimizedOrder(visitor, expectedStart, expectedEnd);
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:39,代码来源:ArrayFieldVectorTest.java

示例10: testWalkInDefaultOrderChangingVisitor1

/** The whole vector is visited. */
@Test
public void testWalkInDefaultOrderChangingVisitor1() {
    final Fraction[] data = new Fraction[] {
        Fraction.ZERO, Fraction.ONE, Fraction.ZERO,
        Fraction.ZERO, Fraction.TWO, Fraction.ZERO,
        Fraction.ZERO, Fraction.ZERO, new Fraction(3)
    };
    final ArrayFieldVector<Fraction> v = new ArrayFieldVector<Fraction>(data);
    final FieldVectorChangingVisitor<Fraction> visitor;
    visitor = new FieldVectorChangingVisitor<Fraction>() {

        private int expectedIndex;

        public Fraction visit(final int actualIndex, final Fraction actualValue) {
            Assert.assertEquals(expectedIndex, actualIndex);
            Assert.assertEquals(Integer.toString(actualIndex),
                                data[actualIndex], actualValue);
            ++expectedIndex;
            return actualValue.add(actualIndex);
        }

        public void start(final int actualSize, final int actualStart,
                          final int actualEnd) {
            Assert.assertEquals(data.length, actualSize);
            Assert.assertEquals(0, actualStart);
            Assert.assertEquals(data.length - 1, actualEnd);
            expectedIndex = 0;
        }

        public Fraction end() {
            return Fraction.ZERO;
        }
    };
    v.walkInDefaultOrder(visitor);
    for (int i = 0; i < data.length; i++) {
        Assert.assertEquals("entry " + i, data[i].add(i), v.getEntry(i));
    }
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:39,代码来源:ArrayFieldVectorTest.java

示例11: create

private ArrayFieldVector<Fraction> create(int n) {
    Fraction[] t = new Fraction[n];
    for (int i = 0; i < n; ++i) {
        t[i] = Fraction.ZERO;
    }
    return new ArrayFieldVector<Fraction>(t);
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:7,代码来源:ArrayFieldVectorTest.java

示例12: FractionMatrixConverter

/** Simple constructor. */
FractionMatrixConverter() {
    super(Fraction.ZERO);
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:4,代码来源:MatrixUtils.java

示例13: FractionMatrixConverter

/** Simple constructor. */
public FractionMatrixConverter() {
    super(Fraction.ZERO);
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:4,代码来源:MatrixUtils.java

示例14: SetVisitor

public SetVisitor() {
    super(Fraction.ZERO);
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:3,代码来源:BlockFieldMatrixTest.java

示例15: GetVisitor

public GetVisitor() {
    super(Fraction.ZERO);
    count = 0;
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:4,代码来源:FieldMatrixImplTest.java


注:本文中的org.apache.commons.math3.fraction.Fraction.ZERO属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。