@Override public UnconstrainedLeastSquares<DMatrixRMaj> createAlgorithm() { return createAlg(); } }
/** * Makes sure the specified tolerances are copied into the configuration */ @Test public void initialize() { UnconLeastSqTrustRegion_F64<DMatrixRMaj> alg = createAlg(); alg.functionResiduals = new MockFunctionNtoM(new double[]{1,2,3},3); alg.initialize(new double[]{1,2,3},2e-3,6e-12); assertEquals(2e-3,alg.config.ftol, UtilEjml.TEST_F64); assertEquals(6e-12,alg.config.gtol, UtilEjml.TEST_F64); }
@Test public void costFunction() { UnconLeastSqTrustRegion_F64<DMatrixRMaj> alg = createAlg(); alg.functionResiduals = new MockFunctionNtoM(new double[]{-1,2,-3},1); alg.residuals.reshape(3,1); double expected = 0.5*(1+4+9); double found = alg.cost(new DMatrixRMaj(1,1)); assertEquals(expected,found, UtilEjml.TEST_F64); }