本文整理汇总了Java中org.apache.commons.math3.fraction.Fraction.TWO属性的典型用法代码示例。如果您正苦于以下问题:Java Fraction.TWO属性的具体用法?Java Fraction.TWO怎么用?Java Fraction.TWO使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.commons.math3.fraction.Fraction
的用法示例。
在下文中一共展示了Fraction.TWO属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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 SparseFieldVector<Fraction> v = new SparseFieldVector<Fraction>(field, 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);
}
示例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: 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 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 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);
}
示例5: 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));
}
}
示例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: testWalkInDefaultOrderChangingVisitor3
/** Visiting a valid subvector. */
@Test
public void testWalkInDefaultOrderChangingVisitor3() {
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 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(expectedStart, actualStart);
Assert.assertEquals(expectedEnd, actualEnd);
expectedIndex = expectedStart;
}
public Fraction end() {
return Fraction.ZERO;
}
};
v.walkInDefaultOrder(visitor, expectedStart, expectedEnd);
for (int i = expectedStart; i <= expectedEnd; i++) {
Assert.assertEquals("entry " + i, data[i].add(i), v.getEntry(i));
}
}
示例12: testWalkInOptimizedOrderChangingVisitor1
/** The whole vector is visited. */
@Test
public void testWalkInOptimizedOrderChangingVisitor1() {
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 final boolean[] visited = new boolean[data.length];
public Fraction visit(final int actualIndex, final Fraction actualValue) {
visited[actualIndex] = true;
Assert.assertEquals(Integer.toString(actualIndex),
data[actualIndex], actualValue);
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);
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);
for (int i = 0; i < data.length; i++) {
Assert.assertEquals("entry " + i, data[i].add(i), v.getEntry(i));
}
}
示例13: testWalkInOptimizedOrderChangingVisitor3
/** Visiting a valid subvector. */
@Test
public void testWalkInOptimizedOrderChangingVisitor3() {
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 FieldVectorChangingVisitor<Fraction> visitor;
visitor = new FieldVectorChangingVisitor<Fraction>() {
private final boolean[] visited = new boolean[data.length];
public Fraction visit(final int actualIndex, final Fraction actualValue) {
Assert.assertEquals(Integer.toString(actualIndex),
data[actualIndex], actualValue);
visited[actualIndex] = true;
return actualValue.add(actualIndex);
}
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);
for (int i = expectedStart; i <= expectedEnd; i++) {
Assert.assertEquals("entry " + i, data[i].add(i), v.getEntry(i));
}
}
示例14: testWalkInDefaultOrderChangingVisitor3
/** Visiting a valid subvector. */
@Test
public void testWalkInDefaultOrderChangingVisitor3() {
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 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(expectedStart, actualStart);
Assert.assertEquals(expectedEnd, actualEnd);
expectedIndex = expectedStart;
}
public Fraction end() {
return Fraction.ZERO;
}
};
v.walkInDefaultOrder(visitor, expectedStart, expectedEnd);
for (int i = expectedStart; i <= expectedEnd; i++) {
Assert.assertEquals("entry " + i, data[i].add(i), v.getEntry(i));
}
}
示例15: testWalkInOptimizedOrderChangingVisitor1
/** The whole vector is visited. */
@Test
public void testWalkInOptimizedOrderChangingVisitor1() {
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 final boolean[] visited = new boolean[data.length];
public Fraction visit(final int actualIndex, final Fraction actualValue) {
visited[actualIndex] = true;
Assert.assertEquals(Integer.toString(actualIndex),
data[actualIndex], actualValue);
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);
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);
for (int i = 0; i < data.length; i++) {
Assert.assertEquals("entry " + i, data[i].add(i), v.getEntry(i));
}
}