当前位置: 首页>>代码示例>>C++>>正文


C++ Arg::dimension方法代码示例

本文整理汇总了C++中Arg::dimension方法的典型用法代码示例。如果您正苦于以下问题:C++ Arg::dimension方法的具体用法?C++ Arg::dimension怎么用?C++ Arg::dimension使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Arg的用法示例。


在下文中一共展示了Arg::dimension方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: solver

/** Solving nonlinear system of the function "GenFunc"
 *  @see IEqSolver.h
 *  @return StatusCode
 */
StatusCode EqSolver::solver (const Equations&  funcs ,
                             Arg&              arg   ) const
//=============================================================================
{
  using namespace Genfun;

  gsl_vector_view vect = gsl_vector_view_array ( &arg[0] ,
                                                 arg.dimension() );
  MsgStream log( msgSvc(), name() );

  EqSolverMisc local (funcs, arg);

  const gsl_multiroot_fdfsolver_type *T = m_type;
  gsl_multiroot_fdfsolver *s;
  int    status = 0 ;
  size_t iter   = 0 ;

  gsl_multiroot_function_fdf function;

  function.f = &fun_gsl;
  function.df = &dfun_gsl;
  function.fdf = &fdfun_gsl;
  function.n = vect.vector.size;
  function.params = (void*) &local;

  s = gsl_multiroot_fdfsolver_alloc(T, vect.vector.size);
  gsl_multiroot_fdfsolver_set (s, &function, &vect.vector);

  for (iter = 0; iter < m_max_iter; ++iter)
    {
      status = gsl_multiroot_fdfsolver_iterate (s);
      if (status)
        {
          return Error
            ("Error from gsl_gsl_multiroot_fdfsolver_iterate '"
             + std::string(gsl_strerror(status)) + "'") ;
        }

      status = gsl_multiroot_test_residual (s->f,
                                            m_norm_residual);

      if ( status != GSL_CONTINUE ) { break; }
    }

  for (unsigned int i = 0; i < vect.vector.size; ++i)
    {
      gsl_vector_set (&vect.vector, i, gsl_vector_get (s->x, i));
    }

  if (status == GSL_SUCCESS)
    {
      log << MSG::DEBUG
          << "We stopped in the method on the " << iter
          << " iteration (we have maximum "     << m_max_iter
          << " iterations)"                     << endmsg;
    }
  else if (status == GSL_CONTINUE && iter <= m_max_iter )
    {
      return Error ( "Method finished with '"
                     + std::string(gsl_strerror(status))
                     +  "' error" );
    }
  else
    {
      return Error ( "Method finished with '" +
                     std::string(gsl_strerror(status))
                     +  "' error" );
    }

  gsl_multiroot_fdfsolver_free (s);

  if (status)
    {
      return Error ( "Method finished with '"
                     + std::string(gsl_strerror(status))
                     +  "' error" );
    }

  return GSL_SUCCESS;
}
开发者ID:atlas-org,项目名称:gaudi,代码行数:84,代码来源:EqSolver.cpp


注:本文中的Arg::dimension方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。