libmesh解析
本工作只是尝试解析原libmesh的代码,供学习使用
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 
Public 成员函数 | Private 属性 | 所有成员列表
libMesh::DenseVector< T > 模板类 参考

定义用于有限元计算的稠密向量类。该类基本上是为了补充 DenseMatrix 类而设计的。 它相对于 std::vector 具有额外的功能,使其在有限元中特别有用,特别是对于方程组。 所有重写的虚拟函数都在 dense_vector_base.h 中有文档说明。 更多...

#include <dof_map.h>

类 libMesh::DenseVector< T > 继承关系图:
[图例]

Public 成员函数

 DenseVector (const unsigned int n=0)
 构造函数。创建一个维数为 n 的稠密向量。 更多...
 
 DenseVector (const unsigned int n, const T &val)
 构造函数。创建一个维数为 n,所有条目值为 val 的稠密向量。 更多...
 
template<typename T2 >
 DenseVector (const DenseVector< T2 > &other_vector)
 复制构造函数。 更多...
 
template<typename T2 >
 DenseVector (const std::vector< T2 > &other_vector)
 std::vector 复制构造函数。 更多...
 
template<typename T2 >
 DenseVector (std::initializer_list< T2 > init_list)
 初始值列表构造函数。 更多...
 
 DenseVector (DenseVector &&)=default
 这五个特殊函数可以在该类中默认实现,因为它本身不管理任何内存。 更多...
 
 DenseVector (const DenseVector &)=default
 
DenseVectoroperator= (const DenseVector &)=default
 
DenseVectoroperator= (DenseVector &&)=default
 
virtual ~DenseVector ()=default
 
virtual unsigned int size () const overridefinal
 
virtual bool empty () const overridefinal
 
virtual void zero () overridefinal
 将向量中的每个元素设置为0。由于派生类中的存储方法可能不同,需要将其声明为纯虚函数。 更多...
 
const T & operator() (const unsigned int i) const
 
T & operator() (const unsigned int i)
 
virtual T el (const unsigned int i) const overridefinal
 
virtual T & el (const unsigned int i) overridefinal
 
template<typename T2 >
DenseVector< T > & operator= (const DenseVector< T2 > &other_vector)
 赋值运算符。 更多...
 
void swap (DenseVector< T > &other_vector)
 STL 风格的交换方法。 更多...
 
void resize (const unsigned int n)
 调整向量的大小。将所有元素设置为0。 更多...
 
template<typename T2 >
void append (const DenseVector< T2 > &other_vector)
 将其他向量的额外条目附加到(调整大小但不改变)向量。 更多...
 
void scale (const T factor)
 将向量中的每个元素乘以 factor。 更多...
 
DenseVector< T > & operator*= (const T factor)
 将向量中的每个元素乘以 factor。 更多...
 
template<typename T2 , typename T3 >
boostcopy::enable_if_c
< ScalarTraits< T2 >::value,
void >::type 
add (const T2 factor, const DenseVector< T3 > &vec)
 factor 乘以 vec 添加到该向量。这应该仅在 T += T2 * T3 是有效的 C++ 且 T2 是标量的情况下起作用。 返回类型是 void。 更多...
 
template<typename T2 >
CompareTypes< T, T2 >::supertype dot (const DenseVector< T2 > &vec) const
 
template<typename T2 >
CompareTypes< T, T2 >::supertype indefinite_dot (const DenseVector< T2 > &vec) const
 
template<typename T2 >
bool operator== (const DenseVector< T2 > &vec) const
 
template<typename T2 >
bool operator!= (const DenseVector< T2 > &vec) const
 
template<typename T2 >
DenseVector< T > & operator+= (const DenseVector< T2 > &vec)
 vec 添加到该向量。 更多...
 
template<typename T2 >
DenseVector< T > & operator-= (const DenseVector< T2 > &vec)
 从该向量中减去 vec。 更多...
 
Real min () const
 
Real max () const
 
Real l1_norm () const
 
Real l2_norm () const
 
Real linfty_norm () const
 
void get_principal_subvector (unsigned int sub_n, DenseVector< T > &dest) const
 将大小为 sub_n(即前 sub_n 个条目)的主子向量放入 dest。 更多...
 
std::vector< T > & get_values ()
 
const std::vector< T > & get_values () const
 
void print (std::ostream &os) const
 将向量漂亮地打印到 stdout。 更多...
 
void print_scientific (std::ostream &os, unsigned precision=8) const
 以科学计数法在额外的小数位数下打印向量的条目。 更多...
 

Private 属性

std::vector< T > _val
 实际数据值,存储为一维数组。 更多...
 

详细描述

template<typename T>
class libMesh::DenseVector< T >

定义用于有限元计算的稠密向量类。该类基本上是为了补充 DenseMatrix 类而设计的。 它相对于 std::vector 具有额外的功能,使其在有限元中特别有用,特别是对于方程组。 所有重写的虚拟函数都在 dense_vector_base.h 中有文档说明。

作者
Benjamin S. Kirk
日期
2003

在文件 dof_map.h64 行定义.

构造及析构函数说明

template<typename T >
libMesh::DenseVector< T >::DenseVector ( const unsigned int  n = 0)
inlineexplicit

构造函数。创建一个维数为 n 的稠密向量。

参数
n向量的维数。

在文件 dense_vector.h319 行定义.

319  :
320  _val (n, T{})
321 {
322 }
std::vector< T > _val
实际数据值,存储为一维数组。
Definition: dense_vector.h:310
template<typename T>
libMesh::DenseVector< T >::DenseVector ( const unsigned int  n,
const T &  val 
)
inlineexplicit

构造函数。创建一个维数为 n,所有条目值为 val 的稠密向量。

参数
n向量的维数。
val所有条目的初始值。

在文件 dense_vector.h327 行定义.

328  :
329  _val (n, val)
330 {
331 }
std::vector< T > _val
实际数据值,存储为一维数组。
Definition: dense_vector.h:310
template<typename T >
template<typename T2 >
libMesh::DenseVector< T >::DenseVector ( const DenseVector< T2 > &  other_vector)
inline

复制构造函数。

参数
other_vector要复制的另一个向量。

在文件 dense_vector.h338 行定义.

参考 libMesh::DenseVector< T >::_val.

338  :
339  DenseVectorBase<T>()
340 {
341  const std::vector<T2> & other_vals = other_vector.get_values();
342 
343  _val.clear();
344 
345  const int N = cast_int<int>(other_vals.size());
346  _val.reserve(N);
347 
348  for (int i=0; i<N; i++)
349  _val.push_back(other_vals[i]);
350 }
std::vector< T > _val
实际数据值,存储为一维数组。
Definition: dense_vector.h:310
template<typename T >
template<typename T2 >
libMesh::DenseVector< T >::DenseVector ( const std::vector< T2 > &  other_vector)
inline

std::vector 复制构造函数。

参数
other_vector要复制的另一个向量。

在文件 dense_vector.h357 行定义.

357  :
358  _val(other_vector)
359 {
360 }
std::vector< T > _val
实际数据值,存储为一维数组。
Definition: dense_vector.h:310
template<typename T >
template<typename T2 >
libMesh::DenseVector< T >::DenseVector ( std::initializer_list< T2 >  init_list)
inline

初始值列表构造函数。

参数
init_list初始化值列表。

在文件 dense_vector.h366 行定义.

366  :
367  _val(init_list.begin(), init_list.end())
368 {
369 }
std::vector< T > _val
实际数据值,存储为一维数组。
Definition: dense_vector.h:310
template<typename T>
libMesh::DenseVector< T >::DenseVector ( DenseVector< T > &&  )
default

这五个特殊函数可以在该类中默认实现,因为它本身不管理任何内存。

template<typename T>
libMesh::DenseVector< T >::DenseVector ( const DenseVector< T > &  )
default
template<typename T>
virtual libMesh::DenseVector< T >::~DenseVector ( )
virtualdefault

成员函数说明

template<typename T >
template<typename T2 , typename T3 >
boostcopy::enable_if_c< ScalarTraits< T2 >::value, void >::type libMesh::DenseVector< T >::add ( const T2  factor,
const DenseVector< T3 > &  vec 
)
inline

factor 乘以 vec 添加到该向量。这应该仅在 T += T2 * T3 是有效的 C++ 且 T2 是标量的情况下起作用。 返回类型是 void。

返回
对 *this 的引用。
参数
factor乘法因子。
vec与该向量相乘的向量。

在文件 dense_vector.h485 行定义.

参考自 libMesh::DenseMatrix< T >::vector_mult_add().

487 {
488  libmesh_assert_equal_to (this->size(), vec.size());
489 
490  const int N = cast_int<int>(_val.size());
491  for (int i=0; i<N; i++)
492  (*this)(i) += static_cast<T>(factor)*vec(i);
493 }
std::vector< T > _val
实际数据值,存储为一维数组。
Definition: dense_vector.h:310
virtual unsigned int size() const overridefinal
Definition: dense_vector.h:111
template<typename T >
template<typename T2 >
void libMesh::DenseVector< T >::append ( const DenseVector< T2 > &  other_vector)
inline

将其他向量的额外条目附加到(调整大小但不改变)向量。

参数
other_vector要附加的其他向量。

在文件 dense_vector.h416 行定义.

417 {
418  const std::vector<T2> & other_vals = other_vector.get_values();
419 
420  _val.reserve(this->size() + other_vals.size());
421  _val.insert(_val.end(), other_vals.begin(), other_vals.end());
422 }
std::vector< T > _val
实际数据值,存储为一维数组。
Definition: dense_vector.h:310
virtual unsigned int size() const overridefinal
Definition: dense_vector.h:111
template<typename T >
template<typename T2 >
CompareTypes< T, T2 >::supertype libMesh::DenseVector< T >::dot ( const DenseVector< T2 > &  vec) const
inline
返回
*this 与 vec 的点积。

在复数值的情况下,使用 vec 的复共轭。

参数
vec与 *this 相乘的向量。

在文件 dense_vector.h500 行定义.

参考 libMesh::libmesh_conj().

501 {
502  if (!_val.size())
503  return 0.;
504 
505  libmesh_assert_equal_to (this->size(), vec.size());
506 
507 #ifdef LIBMESH_HAVE_EIGEN
508  // We reverse the order of the arguments to dot() here since
509  // the convention in Eigen is to take the complex conjugate of the
510  // *first* argument, while ours is to take the complex conjugate of
511  // the second.
512  return Eigen::Map<const typename Eigen::Matrix<T2, Eigen::Dynamic, 1>>(vec.get_values().data(), vec.size())
513  .dot(Eigen::Map<const typename Eigen::Matrix<T, Eigen::Dynamic, 1>>(_val.data(), _val.size()));
514 #else
515  typename CompareTypes<T, T2>::supertype val = 0.;
516 
517  const int N = cast_int<int>(_val.size());
518  // The following pragma tells clang's vectorizer that it is safe to
519  // reorder floating point operations for this loop.
520 #ifdef __clang__
521 #pragma clang loop vectorize(enable)
522 #endif
523  for (int i=0; i<N; i++)
524  val += (*this)(i)*libmesh_conj(vec(i));
525 
526  return val;
527 #endif
528 }
T libmesh_conj(T a)
CompareTypes< T, T2 >::supertype dot(const DenseVector< T2 > &vec) const
Definition: dense_vector.h:500
std::vector< T > _val
实际数据值,存储为一维数组。
Definition: dense_vector.h:310
virtual unsigned int size() const overridefinal
Definition: dense_vector.h:111
template<typename T>
virtual T libMesh::DenseVector< T >::el ( const unsigned int  i) const
inlinefinaloverridevirtual
返回
向量的 (i) 元素。
参数
i元素的索引。

实现了 libMesh::DenseVectorBase< T >.

在文件 dense_vector.h135 行定义.

136  { return (*this)(i); }
template<typename T>
virtual T& libMesh::DenseVector< T >::el ( const unsigned int  i)
inlinefinaloverridevirtual
返回
向量的 (i) 元素的可写引用。
参数
i元素的索引。

实现了 libMesh::DenseVectorBase< T >.

在文件 dense_vector.h138 行定义.

139  { return (*this)(i); }
template<typename T>
virtual bool libMesh::DenseVector< T >::empty ( ) const
inlinefinaloverridevirtual
返回
如果 size() 为 0,则为 true。

重载 libMesh::DenseVectorBase< T > .

在文件 dense_vector.h116 行定义.

参考自 libMesh::NumericVector< T >::add_vector() , 以及 libMesh::NumericVector< T >::insert().

117  { return _val.empty(); }
std::vector< T > _val
实际数据值,存储为一维数组。
Definition: dense_vector.h:310
template<typename T>
void libMesh::DenseVector< T >::get_principal_subvector ( unsigned int  sub_n,
DenseVector< T > &  dest 
) const
inline

将大小为 sub_n(即前 sub_n 个条目)的主子向量放入 dest。

参数
sub_n主子向量的大小。
dest存储主子向量的目标向量。

在文件 dense_vector.h721 行定义.

723 {
724  libmesh_assert_less_equal ( sub_n, this->size() );
725 
726  dest.resize(sub_n);
727  const int N = cast_int<int>(sub_n);
728  for (int i=0; i<N; i++)
729  dest(i) = _val[i];
730 }
std::vector< T > _val
实际数据值,存储为一维数组。
Definition: dense_vector.h:310
virtual unsigned int size() const overridefinal
Definition: dense_vector.h:111
template<typename T>
std::vector<T>& libMesh::DenseVector< T >::get_values ( )
inline
返回
对底层数据存储向量的引用。

注意:这应该谨慎使用(即不应更改向量的大小等),但用于与期望简单数组的低级 BLAS 例程进行交互时很有用。

在文件 dense_vector.h298 行定义.

参考自 libMesh::DenseMatrix< T >::_evd_lapack(), libMesh::DenseMatrix< T >::_lu_back_substitute_lapack(), libMesh::DenseMatrix< T >::_matvec_blas() , 以及 libMesh::DenseMatrix< T >::_svd_solve_lapack().

298 { return _val; }
std::vector< T > _val
实际数据值,存储为一维数组。
Definition: dense_vector.h:310
template<typename T>
const std::vector<T>& libMesh::DenseVector< T >::get_values ( ) const
inline
返回
对底层数据存储向量的常量引用。

在文件 dense_vector.h303 行定义.

303 { return _val; }
std::vector< T > _val
实际数据值,存储为一维数组。
Definition: dense_vector.h:310
template<typename T >
template<typename T2 >
CompareTypes< T, T2 >::supertype libMesh::DenseVector< T >::indefinite_dot ( const DenseVector< T2 > &  vec) const
inline
返回
*this 与 vec 的点积。

在复数值的情况下,不使用 vec 的复共轭。

参数
vec与 *this 相乘的向量。

在文件 dense_vector.h533 行定义.

534 {
535  libmesh_assert_equal_to (this->size(), vec.size());
536 
537  typename CompareTypes<T, T2>::supertype val = 0.;
538 
539  const int N = cast_int<int>(_val.size());
540  for (int i=0; i<N; i++)
541  val += (*this)(i)*(vec(i));
542 
543  return val;
544 }
std::vector< T > _val
实际数据值,存储为一维数组。
Definition: dense_vector.h:310
virtual unsigned int size() const overridefinal
Definition: dense_vector.h:111
template<typename T >
Real libMesh::DenseVector< T >::l1_norm ( ) const
inline
返回
向量的 $l_1$-范数,即条目的绝对值之和。

在文件 dense_vector.h650 行定义.

参考 std::abs() , 以及 libMesh::Real.

651 {
652  if (!_val.size())
653  return 0.;
654 
655 #ifdef LIBMESH_HAVE_EIGEN
656  return Eigen::Map<const typename Eigen::Matrix<T, Eigen::Dynamic, 1>>(_val.data(), _val.size()).template lpNorm<1>();
657 #else
658  Real my_norm = 0.;
659  const int N = cast_int<int>(_val.size());
660  for (int i=0; i!=N; i++)
661  my_norm += std::abs((*this)(i));
662 
663  return my_norm;
664 #endif
665 }
ADRealEigenVector< T, D, asd > abs(const ADRealEigenVector< T, D, asd > &)
计算自动微分实数向量的绝对值。
Definition: type_vector.h:112
std::vector< T > _val
实际数据值,存储为一维数组。
Definition: dense_vector.h:310
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
template<typename T >
Real libMesh::DenseVector< T >::l2_norm ( ) const
inline
返回
向量的 $l_2$-范数,即条目平方和的平方根。

在文件 dense_vector.h671 行定义.

参考 std::norm(), libMesh::TensorTools::norm_sq(), libMesh::Real , 以及 std::sqrt().

672 {
673  if (!_val.size())
674  return 0.;
675 
676 #ifdef LIBMESH_HAVE_EIGEN
677  return Eigen::Map<const typename Eigen::Matrix<T, Eigen::Dynamic, 1>>(_val.data(), _val.size()).norm();
678 #else
679  Real my_norm = 0.;
680  const int N = cast_int<int>(_val.size());
681  // The following pragma tells clang's vectorizer that it is safe to
682  // reorder floating point operations for this loop.
683 #ifdef __clang__
684 #pragma clang loop vectorize(enable)
685 #endif
686  for (int i=0; i!=N; i++)
687  my_norm += TensorTools::norm_sq((*this)(i));
688 
689  return sqrt(my_norm);
690 #endif
691 }
ADRealEigenVector< T, D, asd > sqrt(const ADRealEigenVector< T, D, asd > &)
计算自动微分实数向量的平方根。
Definition: type_vector.h:88
T norm_sq(std::complex< T > a)
Definition: tensor_tools.h:74
std::vector< T > _val
实际数据值,存储为一维数组。
Definition: dense_vector.h:310
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
ADRealEigenVector< T, D, asd > norm(const ADRealEigenVector< T, D, asd > &)
计算自动微分实数向量的范数。
Definition: type_vector.h:64
template<typename T >
Real libMesh::DenseVector< T >::linfty_norm ( ) const
inline
返回
向量的 $l_\infty$-范数,即条目的最大绝对值。

在文件 dense_vector.h697 行定义.

参考 libMesh::TensorTools::norm_sq(), libMesh::Real , 以及 std::sqrt().

698 {
699  if (!_val.size())
700  return 0.;
701 
702 #ifdef LIBMESH_HAVE_EIGEN
703  return Eigen::Map<const typename Eigen::Matrix<T, Eigen::Dynamic, 1>>(_val.data(), _val.size()).template lpNorm<Eigen::Infinity>();
704 #else
705  Real my_norm = TensorTools::norm_sq((*this)(0));
706 
707  const int N = cast_int<int>(_val.size());
708  for (int i=1; i!=N; i++)
709  {
710  Real current = TensorTools::norm_sq((*this)(i));
711  my_norm = (my_norm > current? my_norm : current);
712  }
713  return sqrt(my_norm);
714 #endif
715 }
ADRealEigenVector< T, D, asd > sqrt(const ADRealEigenVector< T, D, asd > &)
计算自动微分实数向量的平方根。
Definition: type_vector.h:88
T norm_sq(std::complex< T > a)
Definition: tensor_tools.h:74
std::vector< T > _val
实际数据值,存储为一维数组。
Definition: dense_vector.h:310
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
template<typename T >
Real libMesh::DenseVector< T >::max ( ) const
inline
返回
向量的最大条目,或者在复数的情况下是最大的实部。

在文件 dense_vector.h632 行定义.

参考 libMesh::libmesh_real() , 以及 libMesh::Real.

633 {
634  libmesh_assert (this->size());
635  Real my_max = libmesh_real((*this)(0));
636 
637  const int N = cast_int<int>(_val.size());
638  for (int i=1; i!=N; i++)
639  {
640  Real current = libmesh_real((*this)(i));
641  my_max = (my_max > current? my_max : current);
642  }
643  return my_max;
644 }
T libmesh_real(T a)
std::vector< T > _val
实际数据值,存储为一维数组。
Definition: dense_vector.h:310
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual unsigned int size() const overridefinal
Definition: dense_vector.h:111
template<typename T >
Real libMesh::DenseVector< T >::min ( ) const
inline
返回
向量的最小条目,或者在复数的情况下是最小的实部。

在文件 dense_vector.h614 行定义.

参考 libMesh::libmesh_real() , 以及 libMesh::Real.

615 {
616  libmesh_assert (this->size());
617  Real my_min = libmesh_real((*this)(0));
618 
619  const int N = cast_int<int>(_val.size());
620  for (int i=1; i!=N; i++)
621  {
622  Real current = libmesh_real((*this)(i));
623  my_min = (my_min < current? my_min : current);
624  }
625  return my_min;
626 }
T libmesh_real(T a)
std::vector< T > _val
实际数据值,存储为一维数组。
Definition: dense_vector.h:310
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual unsigned int size() const overridefinal
Definition: dense_vector.h:111
template<typename T >
template<typename T2 >
bool libMesh::DenseVector< T >::operator!= ( const DenseVector< T2 > &  vec) const
inline
返回
如果 vec 与该向量不完全相等,则为 true,否则为 false。
参数
vec与 *this 进行比较的向量。

在文件 dense_vector.h566 行定义.

567 {
568  libmesh_assert_equal_to (this->size(), vec.size());
569 
570  const int N = cast_int<int>(_val.size());
571  for (int i=0; i<N; i++)
572  if ((*this)(i) != vec(i))
573  return true;
574 
575  return false;
576 }
std::vector< T > _val
实际数据值,存储为一维数组。
Definition: dense_vector.h:310
virtual unsigned int size() const overridefinal
Definition: dense_vector.h:111
template<typename T >
const T & libMesh::DenseVector< T >::operator() ( const unsigned int  i) const
inline
返回
向量的第 i 个条目的常量引用。
参数
i条目的索引。

在文件 dense_vector.h439 行定义.

440 {
441  libmesh_assert_less (i, _val.size());
442 
443  return _val[i];
444 }
std::vector< T > _val
实际数据值,存储为一维数组。
Definition: dense_vector.h:310
template<typename T >
T & libMesh::DenseVector< T >::operator() ( const unsigned int  i)
inline
返回
向量的第 i 个条目的可写引用。
参数
i条目的索引。

在文件 dense_vector.h450 行定义.

451 {
452  libmesh_assert_less (i, _val.size());
453 
454  return _val[i];
455 }
std::vector< T > _val
实际数据值,存储为一维数组。
Definition: dense_vector.h:310
template<typename T>
DenseVector< T > & libMesh::DenseVector< T >::operator*= ( const T  factor)
inline

将向量中的每个元素乘以 factor。

返回
对 *this 的引用。
参数
factor缩放因子。

在文件 dense_vector.h472 行定义.

473 {
474  this->scale(factor);
475  return *this;
476 }
void scale(const T factor)
将向量中的每个元素乘以 factor。
Definition: dense_vector.h:461
template<typename T >
template<typename T2 >
DenseVector< T > & libMesh::DenseVector< T >::operator+= ( const DenseVector< T2 > &  vec)
inline

vec 添加到该向量。

返回
对 *this 的引用。
参数
vec要添加的向量。

在文件 dense_vector.h583 行定义.

584 {
585  libmesh_assert_equal_to (this->size(), vec.size());
586 
587  const int N = cast_int<int>(_val.size());
588  for (int i=0; i<N; i++)
589  (*this)(i) += vec(i);
590 
591  return *this;
592 }
std::vector< T > _val
实际数据值,存储为一维数组。
Definition: dense_vector.h:310
virtual unsigned int size() const overridefinal
Definition: dense_vector.h:111
template<typename T >
template<typename T2 >
DenseVector< T > & libMesh::DenseVector< T >::operator-= ( const DenseVector< T2 > &  vec)
inline

从该向量中减去 vec。

返回
对 *this 的引用。
参数
vec要减去的向量。

在文件 dense_vector.h599 行定义.

600 {
601  libmesh_assert_equal_to (this->size(), vec.size());
602 
603  const int N = cast_int<int>(_val.size());
604  for (int i=0; i<N; i++)
605  (*this)(i) -= vec(i);
606 
607  return *this;
608 }
std::vector< T > _val
实际数据值,存储为一维数组。
Definition: dense_vector.h:310
virtual unsigned int size() const overridefinal
Definition: dense_vector.h:111
template<typename T>
DenseVector& libMesh::DenseVector< T >::operator= ( const DenseVector< T > &  )
default
template<typename T>
DenseVector& libMesh::DenseVector< T >::operator= ( DenseVector< T > &&  )
default
template<typename T >
template<typename T2 >
DenseVector< T > & libMesh::DenseVector< T >::operator= ( const DenseVector< T2 > &  other_vector)
inline

赋值运算符。

返回
对 *this 的引用。
参数
other_vector要复制的另一个向量。

在文件 dense_vector.h376 行定义.

377 {
378  const std::vector<T2> & other_vals = other_vector.get_values();
379 
380  _val.clear();
381 
382  const int N = cast_int<int>(other_vals.size());
383  _val.reserve(N);
384 
385  for (int i=0; i<N; i++)
386  _val.push_back(other_vals[i]);
387 
388  return *this;
389 }
std::vector< T > _val
实际数据值,存储为一维数组。
Definition: dense_vector.h:310
template<typename T >
template<typename T2 >
bool libMesh::DenseVector< T >::operator== ( const DenseVector< T2 > &  vec) const
inline
返回
如果 vec 与该向量完全相等,则为 true,否则为 false。
参数
vec与 *this 进行比较的向量。

在文件 dense_vector.h549 行定义.

550 {
551  libmesh_assert_equal_to (this->size(), vec.size());
552 
553  const int N = cast_int<int>(_val.size());
554  for (int i=0; i<N; i++)
555  if ((*this)(i) != vec(i))
556  return false;
557 
558  return true;
559 }
std::vector< T > _val
实际数据值,存储为一维数组。
Definition: dense_vector.h:310
virtual unsigned int size() const overridefinal
Definition: dense_vector.h:111
template<typename T >
void libMesh::DenseVectorBase< T >::print ( std::ostream &  os) const
inherited

将向量漂亮地打印到 stdout。

参数
os输出流。

在文件 dense_vector_base.C51 行定义.

52 {
53  for (auto i : make_range(this->size()))
54  os << std::setw(8)
55  << this->el(i)
56  << std::endl;
57 }
virtual unsigned int size() const =0
virtual T el(const unsigned int i) const =0
template<typename T >
void libMesh::DenseVectorBase< T >::print_scientific ( std::ostream &  os,
unsigned  precision = 8 
) const
inherited

以科学计数法在额外的小数位数下打印向量的条目。

参数
os输出流。
precision小数点后的精度。

在文件 dense_vector_base.C31 行定义.

32 {
33  // save the initial format flags
34  std::ios_base::fmtflags os_flags = os.flags();
35 
36  // Print the vector entries.
37  for (auto i : make_range(this->size()))
38  os << std::setw(10)
39  << std::scientific
40  << std::setprecision(precision)
41  << this->el(i)
42  << std::endl;
43 
44  // reset the original format flags
45  os.flags(os_flags);
46 }
virtual unsigned int size() const =0
virtual T el(const unsigned int i) const =0
template<typename T >
void libMesh::DenseVector< T >::resize ( const unsigned int  n)
inline

调整向量的大小。将所有元素设置为0。

参数
n新的向量大小。

在文件 dense_vector.h404 行定义.

参考 libMesh::zero.

参考自 libMesh::DenseMatrix< T >::_cholesky_back_substitute(), libMesh::DenseMatrix< T >::_evd_lapack(), libMesh::DenseMatrix< T >::_lu_back_substitute(), libMesh::DenseMatrix< T >::_svd_lapack(), libMesh::DenseMatrix< T >::_svd_solve_lapack(), libMesh::DofMap::build_constraint_matrix_and_vector(), libMesh::CompositeFEMFunction< Output >::operator()(), libMesh::CompositeFunction< Output >::operator()(), libMesh::DenseMatrix< T >::vector_mult(), libMesh::DenseMatrix< T >::vector_mult_add() , 以及 libMesh::DenseMatrix< T >::vector_mult_transpose().

405 {
406  _val.resize(n);
407 
408  zero();
409 }
std::vector< T > _val
实际数据值,存储为一维数组。
Definition: dense_vector.h:310
virtual void zero() overridefinal
将向量中的每个元素设置为0。由于派生类中的存储方法可能不同,需要将其声明为纯虚函数。
Definition: dense_vector.h:428
template<typename T>
void libMesh::DenseVector< T >::scale ( const T  factor)
inline

将向量中的每个元素乘以 factor。

参数
factor缩放因子。

在文件 dense_vector.h461 行定义.

462 {
463  const int N = cast_int<int>(_val.size());
464  for (int i=0; i<N; i++)
465  _val[i] *= factor;
466 }
std::vector< T > _val
实际数据值,存储为一维数组。
Definition: dense_vector.h:310
template<typename T>
virtual unsigned int libMesh::DenseVector< T >::size ( ) const
inlinefinaloverridevirtual
返回
向量的大小。

实现了 libMesh::DenseVectorBase< T >.

在文件 dense_vector.h111 行定义.

参考自 libMesh::DenseMatrix< T >::_lu_back_substitute(), libMesh::DenseMatrix< T >::_matvec_blas(), libMesh::DenseMatrix< T >::_svd_lapack(), libMesh::DenseMatrix< T >::_svd_solve_lapack(), libMesh::NumericVector< T >::add_vector(), libMesh::DofMap::constrain_element_dyad_matrix(), libMesh::DofMap::constrain_element_matrix_and_vector(), libMesh::DofMap::constrain_element_residual(), libMesh::DofMap::constrain_element_vector(), libMesh::DofMap::heterogeneously_constrain_element_jacobian_and_residual(), libMesh::DofMap::heterogeneously_constrain_element_matrix_and_vector(), libMesh::DofMap::heterogeneously_constrain_element_residual(), libMesh::DofMap::heterogeneously_constrain_element_vector(), libMesh::NumericVector< T >::insert(), libMesh::ConstFunction< Output >::operator()(), libMesh::CompositeFEMFunction< Output >::operator()(), libMesh::ParsedFEMFunction< Output >::operator()(), libMesh::CompositeFunction< Output >::operator()(), libMesh::DenseMatrix< T >::outer_product(), MetaPhysicL::RawType< libMesh::DenseVector< T > >::value(), libMesh::DenseMatrix< T >::vector_mult(), libMesh::DenseMatrix< T >::vector_mult_add() , 以及 libMesh::DenseMatrix< T >::vector_mult_transpose().

112  {
113  return cast_int<unsigned int>(_val.size());
114  }
std::vector< T > _val
实际数据值,存储为一维数组。
Definition: dense_vector.h:310
template<typename T>
void libMesh::DenseVector< T >::swap ( DenseVector< T > &  other_vector)
inline

STL 风格的交换方法。

参数
other_vector要交换的另一个向量。

在文件 dense_vector.h395 行定义.

396 {
397  _val.swap(other_vector._val);
398 }
std::vector< T > _val
实际数据值,存储为一维数组。
Definition: dense_vector.h:310
template<typename T >
void libMesh::DenseVector< T >::zero ( )
inlinefinaloverridevirtual

将向量中的每个元素设置为0。由于派生类中的存储方法可能不同,需要将其声明为纯虚函数。

注解
这是一个纯虚函数,需要在派生类中实现。

实现了 libMesh::DenseVectorBase< T >.

在文件 dense_vector.h428 行定义.

参考自 libMesh::CompositeFEMFunction< Output >::operator()() , 以及 libMesh::CompositeFunction< Output >::operator()().

429 {
430  std::fill (_val.begin(),
431  _val.end(),
432  T{});
433 }
std::vector< T > _val
实际数据值,存储为一维数组。
Definition: dense_vector.h:310

类成员变量说明

template<typename T>
std::vector<T> libMesh::DenseVector< T >::_val
private

该类的文档由以下文件生成: