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


C++ NumericVector::first_local_index方法代码示例

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


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

示例1: while

int NumericVector<T>::global_relative_compare (const NumericVector<T> &other_vector,
			                       const Real threshold) const
{
  libmesh_assert (this->initialized());
  libmesh_assert (other_vector.initialized());
  libmesh_assert_equal_to (this->first_local_index(), other_vector.first_local_index());
  libmesh_assert_equal_to (this->last_local_index(), other_vector.last_local_index());

  int first_different_i = std::numeric_limits<int>::max();
  numeric_index_type i = first_local_index();

  const Real my_norm = this->linfty_norm();
  const Real other_norm = other_vector.linfty_norm();
  const Real abs_threshold = std::max(my_norm, other_norm) * threshold;

  do
    {
      if ( std::abs( (*this)(i) - other_vector(i) ) > abs_threshold )
	first_different_i = i;
      else
	i++;
    }
  while (first_different_i==std::numeric_limits<int>::max()
         && i<last_local_index());

  // Find the correct first differing index in parallel
  CommWorld.min(first_different_i);

  if (first_different_i == std::numeric_limits<int>::max())
    return -1;

  return first_different_i;
}
开发者ID:guyer,项目名称:libmesh,代码行数:33,代码来源:numeric_vector.C

示例2: inequality_constraints

void AssembleOptimization::inequality_constraints (const NumericVector<Number> & X,
                                                   NumericVector<Number> & C_ineq,
                                                   OptimizationSystem & /*sys*/)
{
  C_ineq.zero();

  std::unique_ptr<NumericVector<Number>> X_localized =
    NumericVector<Number>::build(X.comm());
  X_localized->init(X.size(), false, SERIAL);
  X.localize(*X_localized);

  std::vector<Number> constraint_values(1);
  constraint_values[0] = (*X_localized)(200)*(*X_localized)(200) + (*X_localized)(201) - 5.;

  for (std::size_t i=0; i<constraint_values.size(); i++)
    if ((C_ineq.first_local_index() <= i) && (i < C_ineq.last_local_index()))
      C_ineq.set(i, constraint_values[i]);
}
开发者ID:balborian,项目名称:libmesh,代码行数:18,代码来源:optimization_ex2.C

示例3: compare

//--------------------------------------------------------------------------------------------
int NumericVector::compare (const NumericVector &other_vector,
                             const double threshold) const {
  assert (this->initialized());
  assert (other_vector.initialized());
  assert (this->first_local_index() == other_vector.first_local_index());
  assert (this->last_local_index()  == other_vector.last_local_index());

  int rvalue     = -1;
  int i = first_local_index();

  do {
    if ( std::abs( (*this)(i) - other_vector(i) ) > threshold )
      rvalue = i;
    else
      i++;
  } while (rvalue==-1 && i<last_local_index());

  return rvalue;
}
开发者ID:gcapodag,项目名称:MyFEMuS,代码行数:20,代码来源:NumericVector.cpp

示例4: equality_constraints

void AssembleOptimization::equality_constraints (const NumericVector<Number> & X,
                                                 NumericVector<Number> & C_eq,
                                                 OptimizationSystem & /*sys*/)
{
  C_eq.zero();

  UniquePtr<NumericVector<Number> > X_localized =
    NumericVector<Number>::build(X.comm());
  X_localized->init(X.size(), false, SERIAL);
  X.localize(*X_localized);

  std::vector<Number> constraint_values(3);
  constraint_values[0] = (*X_localized)(17);
  constraint_values[1] = (*X_localized)(23);
  constraint_values[2] = (*X_localized)(98) + (*X_localized)(185);

  for (unsigned int i=0; i<constraint_values.size(); i++)
    if ((C_eq.first_local_index() <= i) &&
        (i < C_eq.last_local_index()))
      C_eq.set(i, constraint_values[i]);
}
开发者ID:borisboutkov,项目名称:libmesh,代码行数:21,代码来源:optimization_ex2.C


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