MATH-622
Default is now to print 10 fractional digits. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1366821 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0ed64edde5
commit
72779b2300
|
@ -52,6 +52,9 @@ If the output is not quite correct, check for invisible trailing spaces!
|
||||||
<body>
|
<body>
|
||||||
<release version="3.1" date="TBD" description="
|
<release version="3.1" date="TBD" description="
|
||||||
">
|
">
|
||||||
|
<action dev="erans" type="fix" issue="MATH-622">
|
||||||
|
Raised (to 10) the default number of fractional digits to print out.
|
||||||
|
</action>
|
||||||
<action dev="erans" type="fix" issue="MATH-762">
|
<action dev="erans" type="fix" issue="MATH-762">
|
||||||
Removed duplicate code.
|
Removed duplicate code.
|
||||||
</action>
|
</action>
|
||||||
|
|
|
@ -89,8 +89,8 @@ public class LUDecomposition {
|
||||||
matrix.getColumnDimension());
|
matrix.getColumnDimension());
|
||||||
}
|
}
|
||||||
|
|
||||||
final int m = matrix.getColumnDimension();
|
|
||||||
lu = matrix.getData();
|
lu = matrix.getData();
|
||||||
|
final int m = lu.length;
|
||||||
pivot = new int[m];
|
pivot = new int[m];
|
||||||
cachedL = null;
|
cachedL = null;
|
||||||
cachedU = null;
|
cachedU = null;
|
||||||
|
@ -105,15 +105,20 @@ public class LUDecomposition {
|
||||||
|
|
||||||
// Loop over columns
|
// Loop over columns
|
||||||
for (int col = 0; col < m; col++) {
|
for (int col = 0; col < m; col++) {
|
||||||
|
final double[] luColumnCol = new double[m];
|
||||||
|
for (int i = 0; i < m; i++) {
|
||||||
|
luColumnCol[i] = lu[i][col];
|
||||||
|
}
|
||||||
|
|
||||||
// upper
|
// upper
|
||||||
for (int row = 0; row < col; row++) {
|
for (int row = 0; row < col; row++) {
|
||||||
final double[] luRow = lu[row];
|
final double[] luRow = lu[row];
|
||||||
double sum = luRow[col];
|
double sum = luRow[col];
|
||||||
for (int i = 0; i < row; i++) {
|
for (int i = 0; i < row; i++) {
|
||||||
sum -= luRow[i] * lu[i][col];
|
sum -= luRow[i] * luColumnCol[i];
|
||||||
}
|
}
|
||||||
luRow[col] = sum;
|
luRow[col] = sum;
|
||||||
|
luColumnCol[row] = sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
// lower
|
// lower
|
||||||
|
@ -123,9 +128,10 @@ public class LUDecomposition {
|
||||||
final double[] luRow = lu[row];
|
final double[] luRow = lu[row];
|
||||||
double sum = luRow[col];
|
double sum = luRow[col];
|
||||||
for (int i = 0; i < col; i++) {
|
for (int i = 0; i < col; i++) {
|
||||||
sum -= luRow[i] * lu[i][col];
|
sum -= luRow[i] * luColumnCol[i];
|
||||||
}
|
}
|
||||||
luRow[col] = sum;
|
luRow[col] = sum;
|
||||||
|
luColumnCol[row] = sum;
|
||||||
|
|
||||||
// maintain best permutation choice
|
// maintain best permutation choice
|
||||||
if (FastMath.abs(sum) > largest) {
|
if (FastMath.abs(sum) > largest) {
|
||||||
|
@ -135,22 +141,21 @@ public class LUDecomposition {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Singularity check
|
// Singularity check
|
||||||
if (FastMath.abs(lu[max][col]) < singularityThreshold) {
|
if (FastMath.abs(luColumnCol[max]) < singularityThreshold) {
|
||||||
singular = true;
|
singular = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pivot if necessary
|
// Pivot if necessary
|
||||||
if (max != col) {
|
if (max != col) {
|
||||||
double tmp = 0;
|
|
||||||
final double[] luMax = lu[max];
|
final double[] luMax = lu[max];
|
||||||
final double[] luCol = lu[col];
|
final double[] luCol = lu[col];
|
||||||
for (int i = 0; i < m; i++) {
|
for (int i = 0; i < m; i++) {
|
||||||
tmp = luMax[i];
|
final double tmp = luMax[i];
|
||||||
luMax[i] = luCol[i];
|
luMax[i] = luCol[i];
|
||||||
luCol[i] = tmp;
|
luCol[i] = tmp;
|
||||||
}
|
}
|
||||||
int temp = pivot[max];
|
final int temp = pivot[max];
|
||||||
pivot[max] = pivot[col];
|
pivot[max] = pivot[col];
|
||||||
pivot[col] = temp;
|
pivot[col] = temp;
|
||||||
even = !even;
|
even = !even;
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class CompositeFormat {
|
||||||
*/
|
*/
|
||||||
public static NumberFormat getDefaultNumberFormat(final Locale locale) {
|
public static NumberFormat getDefaultNumberFormat(final Locale locale) {
|
||||||
final NumberFormat nf = NumberFormat.getInstance(locale);
|
final NumberFormat nf = NumberFormat.getInstance(locale);
|
||||||
nf.setMaximumFractionDigits(2);
|
nf.setMaximumFractionDigits(10);
|
||||||
return nf;
|
return nf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,48 +84,48 @@ public abstract class ComplexFormatAbstractTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSimpleWithDecimalsTrunc() {
|
public void testSimpleWithDecimalsTrunc() {
|
||||||
Complex c = new Complex(1.2323, 1.4343);
|
Complex c = new Complex(1.232323232323, 1.434343434343);
|
||||||
String expected = "1" + getDecimalCharacter() + "23 + 1" + getDecimalCharacter() + "43i";
|
String expected = "1" + getDecimalCharacter() + "2323232323 + 1" + getDecimalCharacter() + "4343434343i";
|
||||||
String actual = complexFormat.format(c);
|
String actual = complexFormat.format(c);
|
||||||
Assert.assertEquals(expected, actual);
|
Assert.assertEquals(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNegativeReal() {
|
public void testNegativeReal() {
|
||||||
Complex c = new Complex(-1.2323, 1.4343);
|
Complex c = new Complex(-1.232323232323, 1.43);
|
||||||
String expected = "-1" + getDecimalCharacter() + "23 + 1" + getDecimalCharacter() + "43i";
|
String expected = "-1" + getDecimalCharacter() + "2323232323 + 1" + getDecimalCharacter() + "43i";
|
||||||
String actual = complexFormat.format(c);
|
String actual = complexFormat.format(c);
|
||||||
Assert.assertEquals(expected, actual);
|
Assert.assertEquals(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNegativeImaginary() {
|
public void testNegativeImaginary() {
|
||||||
Complex c = new Complex(1.2323, -1.4343);
|
Complex c = new Complex(1.23, -1.434343434343);
|
||||||
String expected = "1" + getDecimalCharacter() + "23 - 1" + getDecimalCharacter() + "43i";
|
String expected = "1" + getDecimalCharacter() + "23 - 1" + getDecimalCharacter() + "4343434343i";
|
||||||
String actual = complexFormat.format(c);
|
String actual = complexFormat.format(c);
|
||||||
Assert.assertEquals(expected, actual);
|
Assert.assertEquals(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNegativeBoth() {
|
public void testNegativeBoth() {
|
||||||
Complex c = new Complex(-1.2323, -1.4343);
|
Complex c = new Complex(-1.232323232323, -1.434343434343);
|
||||||
String expected = "-1" + getDecimalCharacter() + "23 - 1" + getDecimalCharacter() + "43i";
|
String expected = "-1" + getDecimalCharacter() + "2323232323 - 1" + getDecimalCharacter() + "4343434343i";
|
||||||
String actual = complexFormat.format(c);
|
String actual = complexFormat.format(c);
|
||||||
Assert.assertEquals(expected, actual);
|
Assert.assertEquals(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testZeroReal() {
|
public void testZeroReal() {
|
||||||
Complex c = new Complex(0.0, -1.4343);
|
Complex c = new Complex(0.0, -1.434343434343);
|
||||||
String expected = "0 - 1" + getDecimalCharacter() + "43i";
|
String expected = "0 - 1" + getDecimalCharacter() + "4343434343i";
|
||||||
String actual = complexFormat.format(c);
|
String actual = complexFormat.format(c);
|
||||||
Assert.assertEquals(expected, actual);
|
Assert.assertEquals(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testZeroImaginary() {
|
public void testZeroImaginary() {
|
||||||
Complex c = new Complex(30.233, 0);
|
Complex c = new Complex(30.23333333333, 0);
|
||||||
String expected = "30" + getDecimalCharacter() + "23";
|
String expected = "30" + getDecimalCharacter() + "2333333333";
|
||||||
String actual = complexFormat.format(c);
|
String actual = complexFormat.format(c);
|
||||||
Assert.assertEquals(expected, actual);
|
Assert.assertEquals(expected, actual);
|
||||||
}
|
}
|
||||||
|
@ -143,8 +143,8 @@ public abstract class ComplexFormatAbstractTest {
|
||||||
Locale defaultLocal = Locale.getDefault();
|
Locale defaultLocal = Locale.getDefault();
|
||||||
Locale.setDefault(getLocale());
|
Locale.setDefault(getLocale());
|
||||||
|
|
||||||
Complex c = new Complex(232.222, -342.33);
|
Complex c = new Complex(232.22222222222, -342.3333333333);
|
||||||
String expected = "232" + getDecimalCharacter() + "22 - 342" + getDecimalCharacter() + "33i";
|
String expected = "232" + getDecimalCharacter() + "2222222222 - 342" + getDecimalCharacter() + "3333333333i";
|
||||||
String actual = (new ComplexFormat()).format(c);
|
String actual = (new ComplexFormat()).format(c);
|
||||||
Assert.assertEquals(expected, actual);
|
Assert.assertEquals(expected, actual);
|
||||||
|
|
||||||
|
@ -193,32 +193,32 @@ public abstract class ComplexFormatAbstractTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testParseSimpleWithDecimalsTrunc() {
|
public void testParseSimpleWithDecimalsTrunc() {
|
||||||
String source = "1" + getDecimalCharacter() + "2323 + 1" + getDecimalCharacter() + "4343i";
|
String source = "1" + getDecimalCharacter() + "232323232323 + 1" + getDecimalCharacter() + "434343434343i";
|
||||||
Complex expected = new Complex(1.2323, 1.4343);
|
Complex expected = new Complex(1.232323232323, 1.434343434343);
|
||||||
Complex actual = complexFormat.parse(source);
|
Complex actual = complexFormat.parse(source);
|
||||||
Assert.assertEquals(expected, actual);
|
Assert.assertEquals(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testParseNegativeReal() {
|
public void testParseNegativeReal() {
|
||||||
String source = "-1" + getDecimalCharacter() + "2323 + 1" + getDecimalCharacter() + "4343i";
|
String source = "-1" + getDecimalCharacter() + "232323232323 + 1" + getDecimalCharacter() + "4343i";
|
||||||
Complex expected = new Complex(-1.2323, 1.4343);
|
Complex expected = new Complex(-1.232323232323, 1.4343);
|
||||||
Complex actual = complexFormat.parse(source);
|
Complex actual = complexFormat.parse(source);
|
||||||
Assert.assertEquals(expected, actual);
|
Assert.assertEquals(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testParseNegativeImaginary() {
|
public void testParseNegativeImaginary() {
|
||||||
String source = "1" + getDecimalCharacter() + "2323 - 1" + getDecimalCharacter() + "4343i";
|
String source = "1" + getDecimalCharacter() + "2323 - 1" + getDecimalCharacter() + "434343434343i";
|
||||||
Complex expected = new Complex(1.2323, -1.4343);
|
Complex expected = new Complex(1.2323, -1.434343434343);
|
||||||
Complex actual = complexFormat.parse(source);
|
Complex actual = complexFormat.parse(source);
|
||||||
Assert.assertEquals(expected, actual);
|
Assert.assertEquals(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testParseNegativeBoth() {
|
public void testParseNegativeBoth() {
|
||||||
String source = "-1" + getDecimalCharacter() + "2323 - 1" + getDecimalCharacter() + "4343i";
|
String source = "-1" + getDecimalCharacter() + "232323232323 - 1" + getDecimalCharacter() + "434343434343i";
|
||||||
Complex expected = new Complex(-1.2323, -1.4343);
|
Complex expected = new Complex(-1.232323232323, -1.434343434343);
|
||||||
Complex actual = complexFormat.parse(source);
|
Complex actual = complexFormat.parse(source);
|
||||||
Assert.assertEquals(expected, actual);
|
Assert.assertEquals(expected, actual);
|
||||||
}
|
}
|
||||||
|
@ -298,7 +298,7 @@ public abstract class ComplexFormatAbstractTest {
|
||||||
ComplexFormat cf = ComplexFormat.getInstance(getLocale());
|
ComplexFormat cf = ComplexFormat.getInstance(getLocale());
|
||||||
Double pi = Double.valueOf(FastMath.PI);
|
Double pi = Double.valueOf(FastMath.PI);
|
||||||
String text = cf.format(pi);
|
String text = cf.format(pi);
|
||||||
Assert.assertEquals("3" + getDecimalCharacter() + "14", text);
|
Assert.assertEquals("3" + getDecimalCharacter() + "1415926536", text);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -64,22 +64,22 @@ public abstract class Vector3DFormatAbstractTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSimpleWithDecimalsTrunc() {
|
public void testSimpleWithDecimalsTrunc() {
|
||||||
Vector3D c = new Vector3D(1.2323, 1.4343, 1.6333);
|
Vector3D c = new Vector3D(1.232323232323, 1.434343434343, 1.633333333333);
|
||||||
String expected =
|
String expected =
|
||||||
"{1" + getDecimalCharacter() +
|
"{1" + getDecimalCharacter() +
|
||||||
"23; 1" + getDecimalCharacter() +
|
"2323232323; 1" + getDecimalCharacter() +
|
||||||
"43; 1" + getDecimalCharacter() +
|
"4343434343; 1" + getDecimalCharacter() +
|
||||||
"63}";
|
"6333333333}";
|
||||||
String actual = vector3DFormat.format(c);
|
String actual = vector3DFormat.format(c);
|
||||||
Assert.assertEquals(expected, actual);
|
Assert.assertEquals(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNegativeX() {
|
public void testNegativeX() {
|
||||||
Vector3D c = new Vector3D(-1.2323, 1.4343, 1.6333);
|
Vector3D c = new Vector3D(-1.232323232323, 1.43, 1.63);
|
||||||
String expected =
|
String expected =
|
||||||
"{-1" + getDecimalCharacter() +
|
"{-1" + getDecimalCharacter() +
|
||||||
"23; 1" + getDecimalCharacter() +
|
"2323232323; 1" + getDecimalCharacter() +
|
||||||
"43; 1" + getDecimalCharacter() +
|
"43; 1" + getDecimalCharacter() +
|
||||||
"63}";
|
"63}";
|
||||||
String actual = vector3DFormat.format(c);
|
String actual = vector3DFormat.format(c);
|
||||||
|
@ -88,11 +88,11 @@ public abstract class Vector3DFormatAbstractTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNegativeY() {
|
public void testNegativeY() {
|
||||||
Vector3D c = new Vector3D(1.2323, -1.4343, 1.6333);
|
Vector3D c = new Vector3D(1.23, -1.434343434343, 1.63);
|
||||||
String expected =
|
String expected =
|
||||||
"{1" + getDecimalCharacter() +
|
"{1" + getDecimalCharacter() +
|
||||||
"23; -1" + getDecimalCharacter() +
|
"23; -1" + getDecimalCharacter() +
|
||||||
"43; 1" + getDecimalCharacter() +
|
"4343434343; 1" + getDecimalCharacter() +
|
||||||
"63}";
|
"63}";
|
||||||
String actual = vector3DFormat.format(c);
|
String actual = vector3DFormat.format(c);
|
||||||
Assert.assertEquals(expected, actual);
|
Assert.assertEquals(expected, actual);
|
||||||
|
@ -100,12 +100,12 @@ public abstract class Vector3DFormatAbstractTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNegativeZ() {
|
public void testNegativeZ() {
|
||||||
Vector3D c = new Vector3D(1.2323, 1.4343, -1.6333);
|
Vector3D c = new Vector3D(1.23, 1.43, -1.633333333333);
|
||||||
String expected =
|
String expected =
|
||||||
"{1" + getDecimalCharacter() +
|
"{1" + getDecimalCharacter() +
|
||||||
"23; 1" + getDecimalCharacter() +
|
"23; 1" + getDecimalCharacter() +
|
||||||
"43; -1" + getDecimalCharacter() +
|
"43; -1" + getDecimalCharacter() +
|
||||||
"63}";
|
"6333333333}";
|
||||||
String actual = vector3DFormat.format(c);
|
String actual = vector3DFormat.format(c);
|
||||||
Assert.assertEquals(expected, actual);
|
Assert.assertEquals(expected, actual);
|
||||||
}
|
}
|
||||||
|
@ -123,12 +123,12 @@ public abstract class Vector3DFormatAbstractTest {
|
||||||
Locale defaultLocal = Locale.getDefault();
|
Locale defaultLocal = Locale.getDefault();
|
||||||
Locale.setDefault(getLocale());
|
Locale.setDefault(getLocale());
|
||||||
|
|
||||||
Vector3D c = new Vector3D(232.222, -342.33, 432.444);
|
Vector3D c = new Vector3D(232.22222222222, -342.3333333333, 432.44444444444);
|
||||||
String expected =
|
String expected =
|
||||||
"{232" + getDecimalCharacter() +
|
"{232" + getDecimalCharacter() +
|
||||||
"22; -342" + getDecimalCharacter() +
|
"2222222222; -342" + getDecimalCharacter() +
|
||||||
"33; 432" + getDecimalCharacter() +
|
"3333333333; 432" + getDecimalCharacter() +
|
||||||
"44}";
|
"4444444444}";
|
||||||
String actual = (new Vector3DFormat()).format(c);
|
String actual = (new Vector3DFormat()).format(c);
|
||||||
Assert.assertEquals(expected, actual);
|
Assert.assertEquals(expected, actual);
|
||||||
|
|
||||||
|
|
|
@ -68,64 +68,64 @@ public abstract class RealMatrixFormatAbstractTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSimpleWithDecimalsTrunc() {
|
public void testSimpleWithDecimalsTrunc() {
|
||||||
RealMatrix m = MatrixUtils.createRealMatrix(new double[][] {{1.2323, 1.4343, 1.6333},
|
RealMatrix m = MatrixUtils.createRealMatrix(new double[][] {{1.232323232323, 1.43, 1.63},
|
||||||
{2.4666, 2.4666, 2.6666}});
|
{2.46, 2.46, 2.666666666666}});
|
||||||
String expected =
|
String expected =
|
||||||
"{{1" + getDecimalCharacter() +
|
"{{1" + getDecimalCharacter() +
|
||||||
"23,1" + getDecimalCharacter() +
|
"2323232323,1" + getDecimalCharacter() +
|
||||||
"43,1" + getDecimalCharacter() +
|
"43,1" + getDecimalCharacter() +
|
||||||
"63},{2" + getDecimalCharacter() +
|
"63},{2" + getDecimalCharacter() +
|
||||||
"47,2" + getDecimalCharacter() +
|
"46,2" + getDecimalCharacter() +
|
||||||
"47,2" + getDecimalCharacter() +
|
"46,2" + getDecimalCharacter() +
|
||||||
"67}}";
|
"6666666667}}";
|
||||||
String actual = realMatrixFormat.format(m);
|
String actual = realMatrixFormat.format(m);
|
||||||
Assert.assertEquals(expected, actual);
|
Assert.assertEquals(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNegativeComponent() {
|
public void testNegativeComponent() {
|
||||||
RealMatrix m = MatrixUtils.createRealMatrix(new double[][] {{-1.2323, 1.4343, 1.6333},
|
RealMatrix m = MatrixUtils.createRealMatrix(new double[][] {{-1.232323232323, 1.43, 1.63},
|
||||||
{2.4666, 2.4666, 2.6666}});
|
{2.46, 2.46, 2.66}});
|
||||||
String expected =
|
String expected =
|
||||||
"{{-1" + getDecimalCharacter() +
|
"{{-1" + getDecimalCharacter() +
|
||||||
"23,1" + getDecimalCharacter() +
|
"2323232323,1" + getDecimalCharacter() +
|
||||||
"43,1" + getDecimalCharacter() +
|
"43,1" + getDecimalCharacter() +
|
||||||
"63},{2" + getDecimalCharacter() +
|
"63},{2" + getDecimalCharacter() +
|
||||||
"47,2" + getDecimalCharacter() +
|
"46,2" + getDecimalCharacter() +
|
||||||
"47,2" + getDecimalCharacter() +
|
"46,2" + getDecimalCharacter() +
|
||||||
"67}}";
|
"66}}";
|
||||||
String actual = realMatrixFormat.format(m);
|
String actual = realMatrixFormat.format(m);
|
||||||
Assert.assertEquals(expected, actual);
|
Assert.assertEquals(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNegativeComponent2() {
|
public void testNegativeComponent2() {
|
||||||
RealMatrix m = MatrixUtils.createRealMatrix(new double[][] {{1.2323, -1.4343, 1.6333},
|
RealMatrix m = MatrixUtils.createRealMatrix(new double[][] {{1.23, -1.434343434343, 1.63},
|
||||||
{2.4666, 2.4666, 2.6666}});
|
{2.46, 2.46, 2.66}});
|
||||||
String expected =
|
String expected =
|
||||||
"{{1" + getDecimalCharacter() +
|
"{{1" + getDecimalCharacter() +
|
||||||
"23,-1" + getDecimalCharacter() +
|
"23,-1" + getDecimalCharacter() +
|
||||||
"43,1" + getDecimalCharacter() +
|
"4343434343,1" + getDecimalCharacter() +
|
||||||
"63},{2" + getDecimalCharacter() +
|
"63},{2" + getDecimalCharacter() +
|
||||||
"47,2" + getDecimalCharacter() +
|
"46,2" + getDecimalCharacter() +
|
||||||
"47,2" + getDecimalCharacter() +
|
"46,2" + getDecimalCharacter() +
|
||||||
"67}}";
|
"66}}";
|
||||||
String actual = realMatrixFormat.format(m);
|
String actual = realMatrixFormat.format(m);
|
||||||
Assert.assertEquals(expected, actual);
|
Assert.assertEquals(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNegativeSecondRow() {
|
public void testNegativeSecondRow() {
|
||||||
RealMatrix m = MatrixUtils.createRealMatrix(new double[][] {{1.2323, 1.4343, 1.6333},
|
RealMatrix m = MatrixUtils.createRealMatrix(new double[][] {{1.23, 1.43, 1.63},
|
||||||
{-2.4666, 2.4666, 2.6666}});
|
{-2.66666666666, 2.46, 2.66}});
|
||||||
String expected =
|
String expected =
|
||||||
"{{1" + getDecimalCharacter() +
|
"{{1" + getDecimalCharacter() +
|
||||||
"23,1" + getDecimalCharacter() +
|
"23,1" + getDecimalCharacter() +
|
||||||
"43,1" + getDecimalCharacter() +
|
"43,1" + getDecimalCharacter() +
|
||||||
"63},{-2" + getDecimalCharacter() +
|
"63},{-2" + getDecimalCharacter() +
|
||||||
"47,2" + getDecimalCharacter() +
|
"6666666667,2" + getDecimalCharacter() +
|
||||||
"47,2" + getDecimalCharacter() +
|
"46,2" + getDecimalCharacter() +
|
||||||
"67}}";
|
"66}}";
|
||||||
String actual = realMatrixFormat.format(m);
|
String actual = realMatrixFormat.format(m);
|
||||||
Assert.assertEquals(expected, actual);
|
Assert.assertEquals(expected, actual);
|
||||||
}
|
}
|
||||||
|
@ -143,12 +143,12 @@ public abstract class RealMatrixFormatAbstractTest {
|
||||||
Locale defaultLocale = Locale.getDefault();
|
Locale defaultLocale = Locale.getDefault();
|
||||||
Locale.setDefault(getLocale());
|
Locale.setDefault(getLocale());
|
||||||
|
|
||||||
RealMatrix m = MatrixUtils.createRealMatrix(new double[][] {{232.222, -342.33, 432.444}});
|
RealMatrix m = MatrixUtils.createRealMatrix(new double[][] {{232.2222222222, -342.33333333333, 432.44444444444}});
|
||||||
String expected =
|
String expected =
|
||||||
"{{232" + getDecimalCharacter() +
|
"{{232" + getDecimalCharacter() +
|
||||||
"22,-342" + getDecimalCharacter() +
|
"2222222222,-342" + getDecimalCharacter() +
|
||||||
"33,432" + getDecimalCharacter() +
|
"3333333333,432" + getDecimalCharacter() +
|
||||||
"44}}";
|
"4444444444}}";
|
||||||
String actual = (new RealMatrixFormat()).format(m);
|
String actual = (new RealMatrixFormat()).format(m);
|
||||||
Assert.assertEquals(expected, actual);
|
Assert.assertEquals(expected, actual);
|
||||||
|
|
||||||
|
|
|
@ -64,22 +64,22 @@ public abstract class RealVectorFormatAbstractTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSimpleWithDecimalsTrunc() {
|
public void testSimpleWithDecimalsTrunc() {
|
||||||
ArrayRealVector c = new ArrayRealVector(new double[] {1.2323, 1.4343, 1.6333});
|
ArrayRealVector c = new ArrayRealVector(new double[] {1.232323232323, 1.43434343434343, 1.633333333333});
|
||||||
String expected =
|
String expected =
|
||||||
"{1" + getDecimalCharacter() +
|
"{1" + getDecimalCharacter() +
|
||||||
"23; 1" + getDecimalCharacter() +
|
"2323232323; 1" + getDecimalCharacter() +
|
||||||
"43; 1" + getDecimalCharacter() +
|
"4343434343; 1" + getDecimalCharacter() +
|
||||||
"63}";
|
"6333333333}";
|
||||||
String actual = realVectorFormat.format(c);
|
String actual = realVectorFormat.format(c);
|
||||||
Assert.assertEquals(expected, actual);
|
Assert.assertEquals(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNegativeX() {
|
public void testNegativeX() {
|
||||||
ArrayRealVector c = new ArrayRealVector(new double[] {-1.2323, 1.4343, 1.6333});
|
ArrayRealVector c = new ArrayRealVector(new double[] {-1.232323232323, 1.43, 1.63});
|
||||||
String expected =
|
String expected =
|
||||||
"{-1" + getDecimalCharacter() +
|
"{-1" + getDecimalCharacter() +
|
||||||
"23; 1" + getDecimalCharacter() +
|
"2323232323; 1" + getDecimalCharacter() +
|
||||||
"43; 1" + getDecimalCharacter() +
|
"43; 1" + getDecimalCharacter() +
|
||||||
"63}";
|
"63}";
|
||||||
String actual = realVectorFormat.format(c);
|
String actual = realVectorFormat.format(c);
|
||||||
|
@ -88,11 +88,11 @@ public abstract class RealVectorFormatAbstractTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNegativeY() {
|
public void testNegativeY() {
|
||||||
ArrayRealVector c = new ArrayRealVector(new double[] {1.2323, -1.4343, 1.6333});
|
ArrayRealVector c = new ArrayRealVector(new double[] {1.23, -1.434343434343, 1.63});
|
||||||
String expected =
|
String expected =
|
||||||
"{1" + getDecimalCharacter() +
|
"{1" + getDecimalCharacter() +
|
||||||
"23; -1" + getDecimalCharacter() +
|
"23; -1" + getDecimalCharacter() +
|
||||||
"43; 1" + getDecimalCharacter() +
|
"4343434343; 1" + getDecimalCharacter() +
|
||||||
"63}";
|
"63}";
|
||||||
String actual = realVectorFormat.format(c);
|
String actual = realVectorFormat.format(c);
|
||||||
Assert.assertEquals(expected, actual);
|
Assert.assertEquals(expected, actual);
|
||||||
|
@ -100,12 +100,12 @@ public abstract class RealVectorFormatAbstractTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNegativeZ() {
|
public void testNegativeZ() {
|
||||||
ArrayRealVector c = new ArrayRealVector(new double[] {1.2323, 1.4343, -1.6333});
|
ArrayRealVector c = new ArrayRealVector(new double[] {1.23, 1.43, -1.633333333333});
|
||||||
String expected =
|
String expected =
|
||||||
"{1" + getDecimalCharacter() +
|
"{1" + getDecimalCharacter() +
|
||||||
"23; 1" + getDecimalCharacter() +
|
"23; 1" + getDecimalCharacter() +
|
||||||
"43; -1" + getDecimalCharacter() +
|
"43; -1" + getDecimalCharacter() +
|
||||||
"63}";
|
"6333333333}";
|
||||||
String actual = realVectorFormat.format(c);
|
String actual = realVectorFormat.format(c);
|
||||||
Assert.assertEquals(expected, actual);
|
Assert.assertEquals(expected, actual);
|
||||||
}
|
}
|
||||||
|
@ -123,12 +123,12 @@ public abstract class RealVectorFormatAbstractTest {
|
||||||
Locale defaultLocal = Locale.getDefault();
|
Locale defaultLocal = Locale.getDefault();
|
||||||
Locale.setDefault(getLocale());
|
Locale.setDefault(getLocale());
|
||||||
|
|
||||||
ArrayRealVector c = new ArrayRealVector(new double[] {232.222, -342.33, 432.444});
|
ArrayRealVector c = new ArrayRealVector(new double[] {232.22222222222, -342.3333333333, 432.44444444444});
|
||||||
String expected =
|
String expected =
|
||||||
"{232" + getDecimalCharacter() +
|
"{232" + getDecimalCharacter() +
|
||||||
"22; -342" + getDecimalCharacter() +
|
"2222222222; -342" + getDecimalCharacter() +
|
||||||
"33; 432" + getDecimalCharacter() +
|
"3333333333; 432" + getDecimalCharacter() +
|
||||||
"44}";
|
"4444444444}";
|
||||||
String actual = (new RealVectorFormat()).format(c);
|
String actual = (new RealVectorFormat()).format(c);
|
||||||
Assert.assertEquals(expected, actual);
|
Assert.assertEquals(expected, actual);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue