Ejemplo n.º 1
0
/**
 * Calculate the value, first and second derivatives of a RWP cost function
 * @param rwp :: The rwp cost func to calculate the value for
 * @param evalFunction :: Flag to evaluate the value of the cost function
 * @param evalDeriv :: Flag to evaluate the first derivatives
 * @param evalHessian :: Flag to evaluate the Hessian (second derivatives)
 */
void SeqDomain::rwpValDerivHessian(const CostFuncRwp& rwp, bool evalFunction, bool evalDeriv, bool evalHessian)
{
  API::FunctionDomain_sptr domain;
  API::FunctionValues_sptr values;
  const size_t n = getNDomains();
  for(size_t i = 0; i < n; ++i)
  {
    values.reset();
    getDomainAndValues( i, domain, values );
    if (!values)
    {
      throw std::runtime_error("Rwp: undefined FunctionValues.");
    }
    rwp.addValDerivHessian(rwp.getFittingFunction(),domain,values,evalFunction,evalDeriv,evalHessian);
  }
}
Ejemplo n.º 2
0
/**
 * Calculate the value of a least squares cost function
 * @param leastSquares :: The least squares cost func to calculate the value for
 */
void SeqDomain::leastSquaresVal(const CostFuncLeastSquares& leastSquares)
{
  API::FunctionDomain_sptr domain;
  API::FunctionValues_sptr values;
  const size_t n = getNDomains();
  for(size_t i = 0; i < n; ++i)
  {
    values.reset();
    getDomainAndValues( i, domain, values );
    if (!values)
    {
      throw std::runtime_error("LeastSquares: undefined FunctionValues.");
    }
    leastSquares.addVal( domain, values );
  }
}
Ejemplo n.º 3
0
/**
 * Calculate the value of a least squares cost function
 * @param rwp :: The RWP cost func to calculate the value for
 */
void SeqDomain::rwpVal(const CostFuncRwp& rwp)
{
  API::FunctionDomain_sptr domain;
  API::FunctionValues_sptr values;
  const size_t n = getNDomains();
  for(size_t i = 0; i < n; ++i)
  {
    values.reset();
    getDomainAndValues( i, domain, values );
    if (!values)
    {
      throw std::runtime_error("Rwp: undefined FunctionValues.");
    }
    rwp.addVal( domain, values );
  }
}