/** * Implementation of {@link #testSingle()} and {@link #testSingleWithScale()} for the given base. */ private void testSingle(final double base, final double scale) throws TransformException { transform = ExponentialTransform1D.create(base, scale); run(ExponentialTransform1D.class, base, scale, false, false); }
/** * Tests the general pass-through transform. * This test uses a non-linear sub-transform for preventing the factory method to optimize. * * @throws TransformException should never happen. */ @Test public void testPassthrough() throws TransformException { runTest(ExponentialTransform1D.create(10, 2), PassThroughTransform.class); }
/** * Implementation of {@link #testAffinePostConcatenation()} for the given base. */ private void testAffinePostConcatenation(final double base) throws TransformException { transform = MathTransforms.concatenate(ExponentialTransform1D.create(base, SCALE), LinearTransform1D.create(C1, C0)); run(ConcatenatedTransformDirect1D.class, base, SCALE, false, true); }
/** * Implementation of {@link #testAffineConcatenations()} for the given base. */ private void testAffineConcatenations(final double base) throws TransformException { final LinearTransform1D linear = LinearTransform1D.create(C1, C0); transform = MathTransforms.concatenate(linear, ExponentialTransform1D.create(base, SCALE), linear); run(ConcatenatedTransformDirect1D.class, base, SCALE, true, true); }
mt = LinearTransform1D.create(scale, offset); } else if (TransferFunctionType.EXPONENTIAL.equals(type)) { mt = ExponentialTransform1D.create(base, scale); if (offset != 0) { // Rarely occurs in practice. mt = MathTransforms.concatenate(mt, LinearTransform1D.create(0, offset));
transform = LinearTransform1D.create(scale, offset); } else if (TransferFunctionType.EXPONENTIAL.equals(type)) { transform = ExponentialTransform1D.create(base, scale); if (offset != 0) { // Rarely occurs in practice. transform = MathTransforms.concatenate(transform, LinearTransform1D.create(0, offset));
mt = createAffineTransform(factory, true); } else if (TransferFunctionType.EXPONENTIAL.equals(type)) { mt = ExponentialTransform1D.create(base, scale); if (offset != 0) { mt = factory.createConcatenatedTransform(mt, createAffineTransform(factory, false));
/** * Creates a dummy transform for testing purpose. * The {@code scale} and {@code scap} arguments are initially identity matrices, * and will be written by this method with dummy coefficient values for testing purpose. * * <p><b>Implementation note:</b> we do not use {@code MathTransforms.concatenate(…)} for * preventing the optimization performed for the {@link PassThroughTransform} special case.</p> * * @param scale the matrix applying a scale along at least one axis. * @param swap the matrix swapping two matrices. */ private static MathTransform createConcatenateAndPassThrough(final Matrix4 scale, final Matrix4 swap) { scale.m11 = 3; swap.m00 = 0; swap.m01 = 1; swap.m10 = 1; swap.m11 = 0; MathTransform tr = ExponentialTransform1D.create(10, 1); tr = MathTransforms.passThrough(1, tr, 1); tr = new ConcatenatedTransformDirect(MathTransforms.linear(scale), tr); // See "implementation note" above. tr = new ConcatenatedTransformDirect(tr, MathTransforms.linear(swap)); return tr; }
/** * Implementation of {@link #testAffinePreConcatenation()} for the given base. */ private void testAffinePreConcatenation(final double base) throws TransformException { transform = MathTransforms.concatenate(LinearTransform1D.create(C1, C0), ExponentialTransform1D.create(base, SCALE)); run(ExponentialTransform1D.class, base, SCALE, true, false); /* * Find back the original linear coefficients as documented in the ExponentialTransform1D class javadoc. */ final double offset = -log(SCALE) / log(base); final MathTransform1D log = LogarithmicTransform1D.create(base, offset); transform = (LinearTransform1D) MathTransforms.concatenate(transform, log); assertEquals("C1", C1, ((LinearTransform1D) transform).scale, EPS); assertEquals("C0", C0, ((LinearTransform1D) transform).offset, EPS); }
/** * Tests the concatenation of a logarithmic operation with the exponential one. * * @throws TransformException should never happen. */ @Test @DependsOnMethod("testSingleWithOffset") public void testLogarithmicConcatenation() throws TransformException { transform = MathTransforms.concatenate( LogarithmicTransform1D.create(8, C0), ExponentialTransform1D.create(10, ExponentialTransform1DTest.SCALE)); validate(); final double lnBase = log(8); final double[] values = generateRandomCoordinates(CoordinateDomain.RANGE_10, 0); final double[] expected = new double[values.length]; for (int i=0; i<values.length; i++) { final double value = abs(values[i]) + 0.001; // Makes the values valid for logarithms. values[i] = value; expected[i] = ExponentialTransform1DTest.SCALE * pow(10, log(value) / lnBase + C0); } verifyTransform(values, expected); } }