本文整理汇总了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
}
}
示例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);
}
示例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);
}
示例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));
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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));
}
}
示例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);
}
示例12: FractionMatrixConverter
/** Simple constructor. */
FractionMatrixConverter() {
super(Fraction.ZERO);
}
示例13: FractionMatrixConverter
/** Simple constructor. */
public FractionMatrixConverter() {
super(Fraction.ZERO);
}
示例14: SetVisitor
public SetVisitor() {
super(Fraction.ZERO);
}
示例15: GetVisitor
public GetVisitor() {
super(Fraction.ZERO);
count = 0;
}