com.opengamma.strata.math.impl.minimization.NonLinearTransformFunction Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of strata-math Show documentation
Show all versions of strata-math Show documentation
Mathematic support for Strata
/*
* Copyright (C) 2011 - present by OpenGamma Inc. and the OpenGamma group of companies
*
* Please see distribution for license.
*/
package com.opengamma.strata.math.impl.minimization;
import java.util.function.Function;
import com.opengamma.strata.collect.array.DoubleArray;
import com.opengamma.strata.collect.array.DoubleMatrix;
import com.opengamma.strata.math.impl.matrix.MatrixAlgebra;
import com.opengamma.strata.math.impl.matrix.OGMatrixAlgebra;
/**
*
*/
//CSOFF: JavadocMethod
public class NonLinearTransformFunction {
private static final MatrixAlgebra MA = new OGMatrixAlgebra();
private final NonLinearParameterTransforms _transform;
private final Function _func;
private final Function _jac;
public NonLinearTransformFunction(
Function func,
Function jac,
NonLinearParameterTransforms transform) {
_transform = transform;
_func = new Function() {
@SuppressWarnings("synthetic-access")
@Override
public DoubleArray apply(DoubleArray yStar) {
DoubleArray y = _transform.inverseTransform(yStar);
return func.apply(y);
}
};
_jac = new Function() {
@SuppressWarnings("synthetic-access")
@Override
public DoubleMatrix apply(DoubleArray yStar) {
DoubleArray y = _transform.inverseTransform(yStar);
DoubleMatrix h = jac.apply(y);
DoubleMatrix invJ = _transform.inverseJacobian(yStar);
return (DoubleMatrix) MA.multiply(h, invJ);
}
};
}
public Function getFittingFunction() {
return _func;
}
public Function getFittingJacobian() {
return _jac;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy