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


C++ MultiIndex类代码示例

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


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

示例1: evalOnTet

void Bernstein::evalOnTet(const Point& pt, 
  const MultiIndex& deriv,
  Array<double>& result) const
{
  ADReal x = ADReal(pt[0], 0, 3);
  ADReal y = ADReal(pt[1], 1, 3);
  ADReal z = ADReal(pt[2], 2, 3);
  ADReal one(1.0, 3);
  
  Array<ADReal> tmp(result.length());

  if(order_==0)
  {
    tmp.resize(1);
    result.resize(1);
    tmp[0] = one;
  }
  else
  {
  }

  for (int i=0; i<tmp.length(); i++)
  {
    if (deriv.order()==0) result[i] = tmp[i].value();
    else 
      result[i] = tmp[i].gradient()[deriv.firstOrderDirection()];
  }
}
开发者ID:coyigg,项目名称:trilinos,代码行数:28,代码来源:SundanceBernstein.cpp

示例2: applyTx

Set<MultipleDeriv> applyTx(const Set<MultipleDeriv>& s,
  const MultiIndex& x)
{
  Set<MultipleDeriv> rtn;

  for (Set<MultipleDeriv>::const_iterator i=s.begin(); i!=s.end(); i++)
  {
    const MultipleDeriv& md = *i;
    for (MultipleDeriv::const_iterator j=md.begin(); j!=md.end(); j++)
    {
      const Deriv& d = *j;
      if (d.isFunctionalDeriv())
      {
        const MultiIndex& mi = d.opOnFunc().mi();
        MultiIndex miNew = mi+x;
        if (miNew.isValid())
        {
          Deriv dNew = d.derivWrtMultiIndex(miNew);
          MultipleDeriv mdNew = md;
          mdNew.erase(mdNew.find(d));
          mdNew.put(dNew);
          rtn.put(mdNew);
        }
      }
    }
  }
  return rtn;
}
开发者ID:00liujj,项目名称:trilinos,代码行数:28,代码来源:SundanceMultipleDeriv.cpp

示例3: applyZx

Set<MultipleDeriv> applyZx(const Set<MultipleDeriv>& W,
  const MultiIndex& x)
{
  Set<MultipleDeriv> rtn;

  TEUCHOS_TEST_FOR_EXCEPTION(x.order() < 0 || x.order() > 1, std::logic_error,
    "invalid multiindex " << x << " in this context");

  for (Set<MultipleDeriv>::const_iterator i=W.begin(); i!=W.end(); i++)
  {
    const MultipleDeriv& md = *i;
    TEUCHOS_TEST_FOR_EXCEPTION(md.order() != 1, std::logic_error,
      "Only first-order multiple functional derivatives "
      "should appear in this function. The derivative "
      << md << " is not first-order.");

    const Deriv& d = *(md.begin());

    if (d.isFunctionalDeriv())
    {
      /* */
      TEUCHOS_TEST_FOR_EXCEPTION(!d.canBeDifferentiated(),
        std::logic_error, "function signature " << d << " cannot be "
        "differentiated further spatially");
      /* accept a functional derivative if the associated function 
       * is not identically zero */
      const SymbolicFuncElement* sfe = d.symbFuncElem();
      TEUCHOS_TEST_FOR_EXCEPTION(sfe==0, std::logic_error, 
        "can't cast function in "
        << d << " to a SymbolicFuncElement");
      if (sfe && !sfe->evalPtIsZero()) rtn.put(md);
    }
  }
  return rtn;
}
开发者ID:00liujj,项目名称:trilinos,代码行数:35,代码来源:SundanceMultipleDeriv.cpp

示例4: evalOnTriangle

void EdgeLocalizedBasis::evalOnTriangle(const Point& pt, 
  const MultiIndex& deriv,
  Array<double>& result) const
{
  ADReal x = ADReal(pt[0], 0, 2);
	ADReal y = ADReal(pt[1], 1, 2);
	ADReal one(1.0, 2);
	ADReal zero(0.0, 2);

  Array<ADReal> tmp;

  SUNDANCE_OUT(this->verb() > 3, "x=" << x.value() << " y="
    << y.value());

  result.resize(3);
  tmp.resize(3);

  bool onEdge2 = std::fabs(pt[1]) < 1.0e-14;
  bool onEdge0 = std::fabs(1.0-pt[0]-pt[1]) < 1.0e-14;
  bool onEdge1 = std::fabs(pt[0]) < 1.0e-14;
  
  TEUCHOS_TEST_FOR_EXCEPTION(!(onEdge0 || onEdge1 || onEdge2),
    std::runtime_error,
    "EdgeLocalizedBasis should not be evaluated at points not on edges");
  
  TEUCHOS_TEST_FOR_EXCEPTION((onEdge0 && onEdge1) || (onEdge1 && onEdge2)
    || (onEdge2 && onEdge0), std::runtime_error,
    "Ambiguous edge in EdgeLocalizedBasis::evalOnTriangle()");

  if (onEdge0)
  {
    tmp[0] = one;
    tmp[1] = zero;
    tmp[2] = zero;
  }
  if (onEdge1)
  {
    tmp[0] = zero;
    tmp[1] = one;
    tmp[2] = zero;
  }
  if (onEdge2)
  {
    tmp[0] = zero;
    tmp[1] = zero;
    tmp[2] = one;
  }


	for (int i=0; i<tmp.length(); i++)
  {
    SUNDANCE_OUT(this->verb() > 3,
      "tmp[" << i << "]=" << tmp[i].value() 
      << " grad=" << tmp[i].gradient());
    if (deriv.order()==0) result[i] = tmp[i].value();
    else 
      result[i] = tmp[i].gradient()[deriv.firstOrderDirection()];
  }
  
}
开发者ID:cakeisalie,项目名称:oomphlib_003,代码行数:60,代码来源:SundanceEdgeLocalizedBasis.cpp

示例5: evalOnTriangle

void CubicHermite::evalOnTriangle(const Point& pt, 
  const MultiIndex& deriv,
  Array<double>& result) const

{
  result.resize(10);
  ADReal x = ADReal(pt[0], 0, 2);
  ADReal y = ADReal(pt[1], 1, 2);
  ADReal one(1.0, 2);
  
  Array<ADReal> tmp(10);

  SUNDANCE_OUT(this->verb() > 3, "x=" << x.value() << " y="
    << y.value());
 
  tmp[0] = 1 - 3*x*x + 2 * x*x*x - 13*x*y + 13*x*x*y - 3*y*y + 13 *x*y*y + 2 *y*y*y;
  tmp[1] = x - 2 *x*x + x*x*x - 3*x*y + 3*x*x*y + 2*x*y*y;
  tmp[2] = y - 3 *x *y + 2* x*x* y - 2* y*y + 3* x*y*y + y*y*y;
  tmp[3] = 3 * x*x - 2* x*x*x - 7* x* y + 7* x*x *y + 7* x*y*y;
  tmp[4] = -x*x + x*x*x + 2*x *y - 2* x*x* y - 2* x* y*y;
  tmp[5] = -x* y + 2* x*x* y + x* y*y;
  tmp[6] = -7* x* y + 7* x*x*y + 3* y*y + 7* x* y*y - 2* y*y*y;
  tmp[7] = -x *y + x*x* y + 2* x* y*y;
  tmp[8] = 2 *x *y - 2* x*x* y - y*y - 2* x* y*y + y*y*y;
  tmp[9] = 27* x *y - 27* x*x* y - 27* x* y*y;

  for (int i=0; i<tmp.length(); i++)
  {
    if (deriv.order()==0) result[i] = tmp[i].value();
    else 
      result[i] = tmp[i].gradient()[deriv.firstOrderDirection()];
  }
}
开发者ID:coyigg,项目名称:trilinos,代码行数:33,代码来源:SundanceCubicHermite.cpp

示例6: lexicographical_compare

 inline
 bool MultiIndex<I, DIMENSION>::lex (const MultiIndex<I, DIMENSION>& lambda) const
 {
     return std::lexicographical_compare(FixedArray1D<I, DIMENSION>::begin(),
                                         FixedArray1D<I, DIMENSION>::end(),
                                         lambda.begin(), lambda.end());
 }
开发者ID:kedingagnumerikunimarburg,项目名称:Marburg_Software_Library,代码行数:7,代码来源:multiindex.cpp

示例7: takeDeriv

Expr SpectralPreprocessor::takeDeriv(const Expr& f, const MultiIndex& mi)
{
  TEUCHOS_TEST_FOR_EXCEPT(mi.order() > 1);

  
  const SpectralExpr* se 
    = dynamic_cast<const SpectralExpr*>(f.ptr().get());

  Expr d = new Derivative(mi.firstOrderDirection());
  int n = se->getSpectralBasis().nterms();
  
  if (se)
  {
    Array<Expr> c(n);
    for (int i=0; i<n; i++)
    {
      c[i] = d*se->getCoeff(i);
    }
    return new SpectralExpr(se->getSpectralBasis(), c);
  }
  else
  {
    return d*f;
  }
}
开发者ID:cakeisalie,项目名称:oomphlib_003,代码行数:25,代码来源:SundanceSpectralPreprocessor.cpp

示例8:

JoinTips::JoinTips(MultiIndex& mind)
{
	limit = -1;
	count_only = false;
	for(int i = 0; i < mind.NoDimensions(); i++) {
		forget_now.push_back(mind.IsForgotten(i));
		distinct_only.push_back(false);
		null_only.push_back(false);
	}
}
开发者ID:Tsuiwiki,项目名称:infobright,代码行数:10,代码来源:Joiner.cpp

示例9: Xx

Set<MultipleDeriv> Xx(const MultiIndex& x)
{
  Set<MultipleDeriv> rtn;

  TEUCHOS_TEST_FOR_EXCEPTION(x.order() < 0 || x.order() > 1, std::logic_error,
    "invalid multiindex " << x << " in this context");

  MultipleDeriv xmd = makeMultiDeriv(coordDeriv(x.firstOrderDirection()));
  rtn.put(xmd);
  return rtn;
}
开发者ID:00liujj,项目名称:trilinos,代码行数:11,代码来源:SundanceMultipleDeriv.cpp

示例10: return

 inline
 bool MultiIndex<I, DIMENSION>::operator < (const MultiIndex& lambda) const
 {
        
     unsigned int r1(FixedArray1D<I,DIMENSION>::operator [] (0)),r2(multi_degree(lambda));
     for (unsigned int i(1); i < DIMENSION; i++)
     {
         r1 += FixedArray1D<I,DIMENSION>::operator [] (i);
     }
     return (r1<r2) || ((r1==r2) && (std::lexicographical_compare(FixedArray1D<I, DIMENSION>::begin(),
                                                                  FixedArray1D<I, DIMENSION>::end(),
                                                                  lambda.begin(), lambda.end()) ));
 }
开发者ID:kedingagnumerikunimarburg,项目名称:Marburg_Software_Library,代码行数:13,代码来源:multiindex.cpp

示例11: evalOnLine

void Legendre::evalOnLine(const Point& pt,
  const MultiIndex& deriv,
  Array<double>& result) const
{
  result.resize(2+nrDOF_edge_);
  ADReal x = ADReal(pt[0],0,1);

  Array<ADReal> refAll(7);

  refAll[0] = 1-x;
  refAll[1] = x;
  refAll[2] = 2.44948974278318 * ( (2*x-1)*(2*x-1) - 1 ) / 4;
  refAll[3] = 3.16227766016838 * ( (2*x-1)*(2*x-1) - 1 ) * (2*x-1) / 4;
  refAll[4] = 3.74165738677394 * ( 5*(2*x-1)*(2*x-1)*(2*x-1)*(2*x-1) - 6*(2*x-1)*(2*x-1) + 1) / 16;
  refAll[5] = 4.24264068711929 * (2*x-1) * (7*(2*x-1)*(2*x-1)*(2*x-1)*(2*x-1) - 10*(2*x-1)*(2*x-1) + 3) / 16;
  refAll[6] = 4.69041575982343 * (21*(2*x-1)*(2*x-1)*(2*x-1)*(2*x-1)*(2*x-1) -
		                          35*(2*x-1)*(2*x-1)*(2*x-1)*(2*x-1) + 15*(2*x-1)*(2*x-1) - 1) / 32;


  for (int i=0; i<result.length(); i++)
  {
    if (deriv.order()==0) 
    {
      result[i] = refAll[i].value();
    }
    else 
    {
      result[i] = refAll[i].gradient()[0];
    }
  }  
  //SUNDANCE_OUT( true , "Legendre::evalOnLine result.length():" << result.length() );
  return;
}
开发者ID:cakeisalie,项目名称:oomphlib_003,代码行数:33,代码来源:SundanceLegendre.cpp

示例12: evalOnLine

void CubicHermite::evalOnLine(const Point& pt, 
  const MultiIndex& deriv,
  Array<double>& result) const
{
  result.resize(4);
  ADReal x = ADReal(pt[0],0,1);
  Array<ADReal> tmp(4);

  tmp[0] = 1 + x * x * ( -3 + 2 * x );
  tmp[1] = x * ( 1 + (x - 2 ) * x );
  tmp[2] = ( 3 - 2*x ) * x * x;
  tmp[3] = (-1+x)*x*x;

  for (int i=0; i<tmp.length(); i++)
  {
    if (deriv.order()==0) 
    {
      result[i] = tmp[i].value();
    }
    else 
    {
      result[i] = tmp[i].gradient()[0];
    }
  }  
  return;
}
开发者ID:coyigg,项目名称:trilinos,代码行数:26,代码来源:SundanceCubicHermite.cpp

示例13: evalOnLine

void EdgeLocalizedBasis::evalOnLine(const Point& pt, 
													const MultiIndex& deriv,
													Array<double>& result) const
{
	ADReal one(1.0, 1);
	result.resize(1);
	Array<ADReal> tmp(result.length());

  tmp[0] = one;

	for (int i=0; i<tmp.length(); i++)
		{
			if (deriv.order()==0) result[i] = tmp[i].value();
			else result[i] = tmp[i].gradient()[deriv.firstOrderDirection()];
		}
}
开发者ID:cakeisalie,项目名称:oomphlib_003,代码行数:16,代码来源:SundanceEdgeLocalizedBasis.cpp

示例14: evalDummyBasis

double TestEvalMediator::evalDummyBasis(int m, const MultiIndex& mi) const
{
  TEUCHOS_TEST_FOR_EXCEPTION(mi.order() > 1, std::runtime_error, 
                     "TestEvalMediator::evalDummyBasis found multiindex "
                     "order > 1. The bad multiindex was " << mi.toString());

  ADReal result = fields_[m].basis().evaluate(ADField::evalPoint());
  SUNDANCE_MSG3(verb(), "basis.value() " << result.value());
  SUNDANCE_MSG3(verb(), "basis.gradient() " << result.gradient());

  if (mi.order()==0)
    {
      return result.value();
    }
  else 
    {
      return result.gradient()[mi.firstOrderDirection()];
    }
}
开发者ID:cakeisalie,项目名称:oomphlib_003,代码行数:19,代码来源:SundanceTestEvalMediator.cpp

示例15: int

void R_s_k_2::draw_relevance(const float line_width, const int nb)
{
  MultiIndex mindex;
  FT min_value = (std::numeric_limits<FT>::max)();
  FT max_value = -(std::numeric_limits<FT>::max)();
  unsigned int nb_initial = 0;
  for (Finite_edges_iterator ei = m_dt.finite_edges_begin(); ei != m_dt.finite_edges_end(); ++ei)
  {
    Edge edge = *ei;
    if (m_dt.is_ghost(edge)) continue;
    FT value = m_dt.get_edge_relevance(edge); // >= 0

    nb_initial++;
    min_value = (std::min)(min_value, value);
    max_value = (std::max)(max_value, value);
    mindex.insert(PEdge(edge, value));
  }
  if (min_value == max_value) max_value += 1.0;

  viewer->glLineWidth(line_width);
  int nb_remove = (std::min)(nb, int(mindex.size()));

  viewer->glColor3d(0.5, 0.1, 0.1);
  for (int i = 0; i < nb_remove; ++i)
  {

    PEdge pedge = *(mindex.get<1>()).begin();
    (mindex.get<0>()).erase(pedge);
  }

  viewer->glColor3d(0.0, 0.5, 0.0);
  while (!mindex.empty())
  {
    PEdge pedge = *(mindex.get<1>()).begin();
    (mindex.get<0>()).erase(pedge);
    draw_edge(pedge.edge());
  }
}
开发者ID:CGAL,项目名称:releases,代码行数:38,代码来源:render.cpp


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