Ejemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testNullTransform()
        public virtual void testNullTransform()
        {
            BitArray @fixed = new BitArray();

            @fixed.Set(0, true);
            DoubleArray start = DoubleArray.of(Math.PI / 4, 1);
            UncoupledParameterTransforms transforms = new UncoupledParameterTransforms(start, NULL_TRANSFORMS, @fixed);
            NonLinearTransformFunction   transFunc  = new NonLinearTransformFunction(FUNCTION, JACOBIAN, transforms);

            System.Func <DoubleArray, DoubleArray>  func    = transFunc.FittingFunction;
            System.Func <DoubleArray, DoubleMatrix> jacFunc = transFunc.FittingJacobian;

            DoubleArray x = DoubleArray.of(0.5);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final double rootHalf = Math.sqrt(0.5);
            double      rootHalf = Math.Sqrt(0.5);
            DoubleArray y        = func(x);

            assertEquals(3, y.size());
            assertEquals(rootHalf * Math.Cos(0.5), y.get(0), 1e-9);
            assertEquals(rootHalf * Math.Sin(0.5), y.get(1), 1e-9);
            assertEquals(rootHalf, y.get(2), 1e-9);

            DoubleMatrix jac = jacFunc(x);

            assertEquals(3, jac.rowCount());
            assertEquals(1, jac.columnCount());
            assertEquals(-rootHalf * Math.Sin(0.5), jac.get(0, 0), 1e-9);
            assertEquals(rootHalf * Math.Cos(0.5), jac.get(1, 0), 1e-9);
            assertEquals(0, jac.get(2, 0), 1e-9);
        }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testNonLinearTransform()
        public virtual void testNonLinearTransform()
        {
            BitArray    @fixed = new BitArray();
            DoubleArray start  = DoubleArray.filled(2);
            UncoupledParameterTransforms transforms = new UncoupledParameterTransforms(start, TRANSFORMS, @fixed);
            NonLinearTransformFunction   transFunc  = new NonLinearTransformFunction(FUNCTION, JACOBIAN, transforms);

            System.Func <DoubleArray, DoubleArray>  func    = transFunc.FittingFunction;
            System.Func <DoubleArray, DoubleMatrix> jacFunc = transFunc.FittingJacobian;

            VectorFieldFirstOrderDifferentiator diff = new VectorFieldFirstOrderDifferentiator();

            System.Func <DoubleArray, DoubleMatrix> jacFuncFD = diff.differentiate(func);

            DoubleArray  testPoint = DoubleArray.of(4.5, -2.1);
            DoubleMatrix jac       = jacFunc(testPoint);
            DoubleMatrix jacFD     = jacFuncFD(testPoint);

            assertEquals(3, jac.rowCount());
            assertEquals(2, jac.columnCount());

            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 2; j++)
                {
                    assertEquals(jacFD.get(i, j), jac.get(i, j), 1e-6);
                }
            }
        }
        public override bool Equals(object obj)
        {
            if (this == obj)
            {
                return(true);
            }
            if (obj == null)
            {
                return(false);
            }
            if (this.GetType() != obj.GetType())
            {
                return(false);
            }
            UncoupledParameterTransforms other = (UncoupledParameterTransforms)obj;

            if (!Arrays.Equals(_freeParameters, other._freeParameters))
            {
                return(false);
            }
            if (!Objects.Equals(_startValues, other._startValues))
            {
                return(false);
            }
            return(Arrays.Equals(_transforms, other._transforms));
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void test()
        public virtual void test()
        {
            assertEquals(PARAMS.NumberOfModelParameters, 4);
            assertEquals(PARAMS.NumberOfFittingParameters, 3);
            UncoupledParameterTransforms other = new UncoupledParameterTransforms(INIT, NULLS, FIXED);

            assertEquals(PARAMS, other);
            assertEquals(PARAMS.GetHashCode(), other.GetHashCode());
            other = new UncoupledParameterTransforms(DoubleArray.of(1, 2, 4, 5), NULLS, FIXED);
            assertFalse(other.Equals(PARAMS));
            other = new UncoupledParameterTransforms(INIT, new ParameterLimitsTransform[]
            {
                new DoubleRangeLimitTransform(1, 2),
                new NullTransform(),
                new NullTransform(),
                new NullTransform()
            }, FIXED);
            assertFalse(other.Equals(PARAMS));
            other = new UncoupledParameterTransforms(INIT, NULLS, new BitArray(4));
            assertFalse(other.Equals(PARAMS));
        }
 static TransformParametersTest()
 {
     FIXED.Set(0, true);
     PARAMS = new UncoupledParameterTransforms(INIT, NULLS, FIXED);
 }