for (int pass=0; pass<5; pass++) {
/*
* Construct the reference matrix.
*/
final int dimension = 10;
final GeneralMatrix matrix = new GeneralMatrix(dimension+1, dimension+1);
for (int i=0; i<dimension; i++) {
matrix.setElement(i,i, 400*Math.random()-200);
matrix.setElement(i,dimension, 400*Math.random()-200);
}
assertTrue(matrix.isAffine());
/*
* Construct all math transforms.
*/
final MathTransform[] transforms = new MathTransform[dimension];
for (int i=1; i<=dimension; i++) {
final GeneralMatrix sub = new GeneralMatrix(i+1, i+1);
matrix.copySubMatrix(0, 0, i, i, 0, 0, sub); // Scale terms
matrix.copySubMatrix(0, dimension, i, 1, 0, i, sub); // Translation terms
final MathTransform transform = transforms[i-1] = factory.createAffineTransform(sub);
assertTrue (sub.isAffine());
assertEquals(sub, new GeneralMatrix(((LinearTransform) transform).getMatrix()));
assertInterfaced(transform);
assertTrue(i == transform.getSourceDimensions());
}
/*
* Check transformations and the inverse transformations.