예제 #1
0
/**
 * Derivatives of function with respect to active parameters
 * @param domain :: Function domain to get the arguments from.
 * @param jacobian :: A Jacobian to store the derivatives.
 */
void CompositeFunction::functionDeriv(const FunctionDomain &domain,
                                      Jacobian &jacobian) {
  if (getAttribute("NumDeriv").asBool()) {
    calNumericalDeriv(domain, jacobian);
  } else {
    for (size_t iFun = 0; iFun < nFunctions(); ++iFun) {
      PartialJacobian J(&jacobian, paramOffset(iFun));
      getFunction(iFun)->functionDeriv(domain, J);
    }
  }
}
예제 #2
0
/// Derivatives of function with respect to active parameters
void MultiDomainFunction::functionDeriv(const FunctionDomain &domain,
                                        Jacobian &jacobian) {
  // works only on CompositeDomain
  if (!dynamic_cast<const CompositeDomain *>(&domain)) {
    throw std::invalid_argument(
        "Non-CompositeDomain passed to MultiDomainFunction.");
  }

  if (getAttribute("NumDeriv").asBool()) {
    calNumericalDeriv(domain, jacobian);
  } else {
    const CompositeDomain &cd = dynamic_cast<const CompositeDomain &>(domain);
    // domain must not have less parts than m_maxIndex
    if (cd.getNParts() < m_maxIndex) {
      throw std::invalid_argument(
          "CompositeDomain has too few parts (" +
          boost::lexical_cast<std::string>(cd.getNParts()) +
          ") for MultiDomainFunction (max index " +
          boost::lexical_cast<std::string>(m_maxIndex) + ").");
    }

    countValueOffsets(cd);
    // evaluate member functions derivatives
    for (size_t iFun = 0; iFun < nFunctions(); ++iFun) {
      // find the domains member function must be applied to
      std::vector<size_t> domains;
      getDomainIndices(iFun, cd.getNParts(), domains);

      for (auto i = domains.begin(); i != domains.end(); ++i) {
        const FunctionDomain &d = cd.getDomain(*i);
        PartialJacobian J(&jacobian, m_valueOffsets[*i], paramOffset(iFun));
        getFunction(iFun)->functionDeriv(d, J);
      }
    }
  }
}
예제 #3
0
/// Derivatives of function with respect to active parameters
void FunctionComposition::functionDeriv(const FunctionDomain& domain, Jacobian& jacobian)
{
  calNumericalDeriv( domain, jacobian );
}
예제 #4
0
 /*
  * Using numerical derivative
  */
 void LeBailFunction::functionDeriv(const API::FunctionDomain &domain, API::Jacobian &jacobian)
 {
   calNumericalDeriv(domain, jacobian);
   return;
 }
예제 #5
0
/// Derivatives of function with respect to active parameters
void ProductFunction::functionDeriv(const FunctionDomain& domain, Jacobian& jacobian)
{
  calNumericalDeriv( domain, jacobian );
}
예제 #6
0
void IkedaCarpenterPV::functionDeriv(const API::FunctionDomain &domain,
                                     API::Jacobian &jacobian) {
  calNumericalDeriv(domain, jacobian);
}
예제 #7
0
void IFunction1DSpectrum::functionDeriv1DSpectrum(const FunctionDomain1DSpectrum &domain, Jacobian &jacobian)
{
    calNumericalDeriv(domain, jacobian);
}
예제 #8
0
 /** 
 * @param domain :: the space on which the function acts
 * @param jacobian :: the set of partial derivatives of the function with respect to the
 * fitting parameters
 */
 void UserFunction::functionDeriv(const API::FunctionDomain& domain, API::Jacobian& jacobian)
 {
   calNumericalDeriv(domain,jacobian);
 }