libMesh
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | Friends | List of all members
libMesh::DenseVector< T > Class Template Reference

Defines a dense vector for use in Finite Element-type computations. More...

#include <dense_vector.h>

Inheritance diagram for libMesh::DenseVector< T >:
[legend]

Public Member Functions

 DenseVector (const unsigned int n=0)
 Constructor.
 
 DenseVector (const unsigned int n, const T &val)
 Constructor.
 
template<typename T2 >
 DenseVector (const DenseVector< T2 > &other_vector)
 Copy-constructor.
 
template<typename T2 >
 DenseVector (const std::vector< T2 > &other_vector)
 Copy-constructor, from a std::vector.
 
template<typename T2 >
 DenseVector (std::initializer_list< T2 > init_list)
 Initializer list constructor.
 
 DenseVector (DenseVector &&)=default
 The 5 special functions can be defaulted for this class, as it does not manage any memory itself.
 
 DenseVector (const DenseVector &)=default
 
DenseVector & operator= (const DenseVector &)=default
 
DenseVector & operator= (DenseVector &&)=default
 
virtual ~DenseVector ()=default
 
virtual unsigned int size () const override final
 
virtual bool empty () const override final
 
virtual void zero () override final
 Set every element in the vector to 0.
 
const T & operator() (const unsigned int i) const
 
T & operator() (const unsigned int i)
 
const T & operator[] (const unsigned int i) const
 
T & operator[] (const unsigned int i)
 
virtual T el (const unsigned int i) const override final
 
virtual T & el (const unsigned int i) override final
 
template<typename T2 >
DenseVector< T > & operator= (const DenseVector< T2 > &other_vector)
 Assignment operator.
 
void swap (DenseVector< T > &other_vector)
 STL-like swap method.
 
void resize (const unsigned int n)
 Resize the vector.
 
template<typename T2 >
void append (const DenseVector< T2 > &other_vector)
 Append additional entries to (resizing, but unchanging) the vector.
 
void scale (const T factor)
 Multiplies every element in the vector by factor.
 
DenseVector< T > & operator*= (const T factor)
 Multiplies every element in the vector by factor.
 
template<typename T2 , typename T3 >
std::enable_if< ScalarTraits< T2 >::value, void >::type add (const T2 factor, const DenseVector< T3 > &vec)
 Adds factor times vec to this vector.
 
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)
 Adds vec to this vector.
 
template<typename T2 >
DenseVector< T > & operator-= (const DenseVector< T2 > &vec)
 Subtracts vec from this vector.
 
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
 Puts the principal subvector of size sub_n (i.e.
 
std::vector< T > & get_values ()
 
const std::vector< T > & get_values () const
 
std::vector< T >::const_iterator begin () const
 
std::vector< T >::iterator begin ()
 
std::vector< T >::const_iterator end () const
 
std::vector< T >::iterator end ()
 
void print (std::ostream &os) const
 Pretty-print the vector to stdout.
 
void print_scientific (std::ostream &os, unsigned precision=8) const
 Prints the entries of the vector with additional decimal places in scientific notation.
 

Private Attributes

std::vector< T > _val
 The actual data values, stored as a 1D array.
 

Friends

bool isfinite (const DenseVector< T > &var)
 Returns true iff every entry is finite.
 
bool isinf (const DenseVector< T > &var)
 Returns true iff no entry is NaN and any entry is infinite.
 
bool isnan (const DenseVector< T > &var)
 Returns true iff any entry is NaN.
 

Detailed Description

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

Defines a dense vector for use in Finite Element-type computations.

This class is to basically compliment the DenseMatrix class. It has additional capabilities over the std::vector that make it useful for finite elements, particularly for systems of equations. All overridden virtual functions are documented in dense_vector_base.h.

Author
Benjamin S. Kirk
Date
2003

Definition at line 60 of file dense_vector.h.

Constructor & Destructor Documentation

◆ DenseVector() [1/7]

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

Constructor.

Creates a dense vector of dimension n.

Definition at line 369 of file dense_vector.h.

369 :
370 _val (n, T{})
371{
372}
std::vector< T > _val
The actual data values, stored as a 1D array.

◆ DenseVector() [2/7]

template<typename T >
libMesh::DenseVector< T >::DenseVector ( const unsigned int  n,
const T &  val 
)
inlineexplicit

Constructor.

Creates a dense vector of dimension n where all entries have value val.

Definition at line 377 of file dense_vector.h.

378 :
379 _val (n, val)
380{
381}

◆ DenseVector() [3/7]

template<typename T >
template<typename T2 >
libMesh::DenseVector< T >::DenseVector ( const DenseVector< T2 > &  other_vector)
inline

Copy-constructor.

Definition at line 388 of file dense_vector.h.

388 :
389 DenseVectorBase<T>()
390{
391 const std::vector<T2> & other_vals = other_vector.get_values();
392
393 _val.assign(other_vals.begin(), other_vals.end());
394}

References libMesh::DenseVector< T >::_val, and libMesh::DenseVector< T >::get_values().

◆ DenseVector() [4/7]

template<typename T >
template<typename T2 >
libMesh::DenseVector< T >::DenseVector ( const std::vector< T2 > &  other_vector)
inline

Copy-constructor, from a std::vector.

Definition at line 401 of file dense_vector.h.

401 :
402 _val(other_vector)
403{
404}

◆ DenseVector() [5/7]

template<typename T >
template<typename T2 >
libMesh::DenseVector< T >::DenseVector ( std::initializer_list< T2 >  init_list)
inline

Initializer list constructor.

Definition at line 410 of file dense_vector.h.

410 :
411 _val(init_list.begin(), init_list.end())
412{
413}

◆ DenseVector() [6/7]

template<typename T >
libMesh::DenseVector< T >::DenseVector ( DenseVector< T > &&  )
default

The 5 special functions can be defaulted for this class, as it does not manage any memory itself.

◆ DenseVector() [7/7]

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

◆ ~DenseVector()

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

Member Function Documentation

◆ add()

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

Adds factor times vec to this vector.

This should only work if T += T2 * T3 is valid C++ and if T2 is scalar. Return type is void

Returns
A reference to *this.

Definition at line 520 of file dense_vector.h.

522{
523 libmesh_assert_equal_to (this->size(), vec.size());
524
525 const int N = cast_int<int>(_val.size());
526 for (int i=0; i<N; i++)
527 (*this)(i) += static_cast<T>(factor)*vec(i);
528}
virtual unsigned int size() const override final

References libMesh::DenseVector< T >::size().

Referenced by libMesh::NewmarkSolver::_general_residual(), libMesh::EulerSolver::_general_residual(), libMesh::TransientRBEvaluation::rb_solve(), libMesh::RBEvaluation::rb_solve(), libMesh::TransientRBEvaluation::rb_solve_again(), and libMesh::DenseMatrix< Real >::svd().

◆ append()

template<typename T >
template<typename T2 >
void libMesh::DenseVector< T >::append ( const DenseVector< T2 > &  other_vector)
inline

Append additional entries to (resizing, but unchanging) the vector.

Definition at line 452 of file dense_vector.h.

453{
454 const std::vector<T2> & other_vals = other_vector.get_values();
455
456 _val.reserve(this->size() + other_vals.size());
457 _val.insert(_val.end(), other_vals.begin(), other_vals.end());
458}

References libMesh::DenseVector< T >::get_values().

Referenced by libMesh::FEGenericBase< OutputType >::coarsened_dof_values().

◆ begin() [1/2]

template<typename T >
std::vector< T >::iterator libMesh::DenseVector< T >::begin ( )
inline

Definition at line 291 of file dense_vector.h.

291{ return _val.begin(); }

References libMesh::DenseVector< T >::_val.

◆ begin() [2/2]

template<typename T >
std::vector< T >::const_iterator libMesh::DenseVector< T >::begin ( ) const
inline
Returns
An iterator pointing to the beginning of the vector

Definition at line 290 of file dense_vector.h.

290{ return _val.begin(); }

References libMesh::DenseVector< T >::_val.

◆ dot()

template<typename T >
template<typename T2 >
CompareTypes< T, T2 >::supertype libMesh::DenseVector< T >::dot ( const DenseVector< T2 > &  vec) const
inline
Returns
The dot product of *this with vec.

In the complex-valued case, uses the complex conjugate of vec.

Definition at line 535 of file dense_vector.h.

536{
537 if (!_val.size())
538 return 0.;
539
540 libmesh_assert_equal_to (this->size(), vec.size());
541
542#ifdef LIBMESH_HAVE_EIGEN
543 // We reverse the order of the arguments to dot() here since
544 // the convention in Eigen is to take the complex conjugate of the
545 // *first* argument, while ours is to take the complex conjugate of
546 // the second.
547 return Eigen::Map<const typename Eigen::Matrix<T2, Eigen::Dynamic, 1>>(vec.get_values().data(), vec.size())
548 .dot(Eigen::Map<const typename Eigen::Matrix<T, Eigen::Dynamic, 1>>(_val.data(), _val.size()));
549#else
550 typename CompareTypes<T, T2>::supertype val = 0.;
551
552 const int N = cast_int<int>(_val.size());
553 // The following pragma tells clang's vectorizer that it is safe to
554 // reorder floating point operations for this loop.
555#ifdef __clang__
556#pragma clang loop vectorize(enable)
557#endif
558 for (int i=0; i<N; i++)
559 val += (*this)(i)*libmesh_conj(vec(i));
560
561 return val;
562#endif
563}
CompareTypes< T, T2 >::supertype dot(const DenseVector< T2 > &vec) const
LIBMESH_DEVICE_INLINE T libmesh_conj(T a)

References libMesh::DenseVector< T >::get_values(), libMesh::libmesh_conj(), and libMesh::DenseVector< T >::size().

Referenced by libMesh::TransientRBConstruction::assemble_affine_expansion(), libMesh::TransientRBEvaluation::compute_residual_dual_norm(), libMesh::RBEIMEvaluation::get_eim_error_indicator(), libMesh::TransientRBEvaluation::rb_solve(), libMesh::RBEvaluation::rb_solve(), libMesh::TransientRBConstruction::set_error_temporal_data(), and libMesh::TransientRBConstruction::update_RB_initial_condition_all_N().

◆ el() [1/2]

template<typename T >
virtual T libMesh::DenseVector< T >::el ( const unsigned int  i) const
inlinefinaloverridevirtual
Returns
The (i) element of the vector.

Implements libMesh::DenseVectorBase< T >.

Definition at line 136 of file dense_vector.h.

137 { return (*this)(i); }

◆ el() [2/2]

template<typename T >
virtual T & libMesh::DenseVector< T >::el ( const unsigned int  i)
inlinefinaloverridevirtual
Returns
The (i) element of the vector as a writable reference.

Implements libMesh::DenseVectorBase< T >.

Definition at line 139 of file dense_vector.h.

140 { return (*this)(i); }

◆ empty()

template<typename T >
virtual bool libMesh::DenseVector< T >::empty ( ) const
inlinefinaloverridevirtual

◆ end() [1/2]

template<typename T >
std::vector< T >::iterator libMesh::DenseVector< T >::end ( )
inline

Definition at line 297 of file dense_vector.h.

297{ return _val.end(); }

References libMesh::DenseVector< T >::_val.

◆ end() [2/2]

template<typename T >
std::vector< T >::const_iterator libMesh::DenseVector< T >::end ( ) const
inline
Returns
An iterator pointing to the end of the vector

Definition at line 296 of file dense_vector.h.

296{ return _val.end(); }

References libMesh::DenseVector< T >::_val.

◆ get_principal_subvector()

template<typename T >
void libMesh::DenseVector< T >::get_principal_subvector ( unsigned int  sub_n,
DenseVector< T > &  dest 
) const
inline

Puts the principal subvector of size sub_n (i.e.

first sub_n entries) into dest.

Definition at line 733 of file dense_vector.h.

735{
736 libmesh_assert_less_equal ( sub_n, this->size() );
737
738 dest.resize(sub_n);
739 const int N = cast_int<int>(sub_n);
740 for (int i=0; i<N; i++)
741 dest(i) = _val[i];
742}

References libMesh::DenseVector< T >::resize().

Referenced by libMesh::RBEIMEvaluation::get_eim_error_indicator(), libMesh::RBEIMEvaluation::rb_eim_solves(), libMesh::TransientRBEvaluation::rb_solve(), libMesh::RBEvaluation::rb_solve(), and libMesh::TransientRBConstruction::update_RB_initial_condition_all_N().

◆ get_values() [1/2]

template<typename T >
std::vector< T > & libMesh::DenseVector< T >::get_values ( )
inline

◆ get_values() [2/2]

template<typename T >
const std::vector< T > & libMesh::DenseVector< T >::get_values ( ) const
inline
Returns
A constant reference to the underlying data storage vector.

Definition at line 285 of file dense_vector.h.

285{ return _val; }

References libMesh::DenseVector< T >::_val.

◆ indefinite_dot()

template<typename T >
template<typename T2 >
CompareTypes< T, T2 >::supertype libMesh::DenseVector< T >::indefinite_dot ( const DenseVector< T2 > &  vec) const
inline
Returns
The dot product of *this with vec.

In the complex-valued case, does not use the complex conjugate of vec.

Definition at line 568 of file dense_vector.h.

569{
570 libmesh_assert_equal_to (this->size(), vec.size());
571
572 typename CompareTypes<T, T2>::supertype val = 0.;
573
574 const int N = cast_int<int>(_val.size());
575 for (int i=0; i<N; i++)
576 val += (*this)(i)*(vec(i));
577
578 return val;
579}

References libMesh::DenseVector< T >::size().

◆ l1_norm()

template<typename T >
Real libMesh::DenseVector< T >::l1_norm ( ) const
inline
Returns
The \(l_1\)-norm of the vector, i.e. the sum of the absolute values of the entries.

Definition at line 677 of file dense_vector.h.

678{
679 if (!_val.size())
680 return 0.;
681
682#ifdef LIBMESH_HAVE_EIGEN
683 return Eigen::Map<const typename Eigen::Matrix<T, Eigen::Dynamic, 1>>(_val.data(), _val.size()).template lpNorm<1>();
684#else
686 (_val.begin(), _val.end(), Real(0), std::plus<>(),
687 [](const T & v){using std::abs; return abs(v);});
688#endif
689}
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
T libmesh_transform_reduce(InputIt begin, InputIt end, T init, BinaryOp reduce, UnaryOp transform)

References libmesh_transform_reduce(), and libMesh::Real.

Referenced by DenseMatrixTest::testNorms().

◆ l2_norm()

template<typename T >
Real libMesh::DenseVector< T >::l2_norm ( ) const
inline
Returns
The \(l_2\)-norm of the vector, i.e. the square root of the sum of the squares of the entries.

Definition at line 695 of file dense_vector.h.

696{
697 if (!_val.size())
698 return 0.;
699
700#ifdef LIBMESH_HAVE_EIGEN
701 return Eigen::Map<const typename Eigen::Matrix<T, Eigen::Dynamic, 1>>(_val.data(), _val.size()).norm();
702#else
703 using std::sqrt;
704 return sqrt(libmesh_transform_reduce
705 (_val.begin(), _val.end(), Real(0), std::plus<>(),
706 [](const T & v){return TensorTools::norm_sq(v);}));
707#endif
708}
LIBMESH_DEVICE_INLINE auto norm_sq(const T &a)
LIBMESH_DEVICE_INLINE auto norm(const T &a)

References libmesh_transform_reduce(), libMesh::TensorTools::norm_sq(), and libMesh::Real.

Referenced by DenseMatrixTest::testNorms().

◆ linfty_norm()

template<typename T >
Real libMesh::DenseVector< T >::linfty_norm ( ) const
inline
Returns
The \(l_\infty\)-norm of the vector, i.e. the maximum absolute value of the entries.

Definition at line 714 of file dense_vector.h.

715{
716 if (!_val.size())
717 return 0.;
718
719#ifdef LIBMESH_HAVE_EIGEN
720 return Eigen::Map<const typename Eigen::Matrix<T, Eigen::Dynamic, 1>>(_val.data(), _val.size()).template lpNorm<Eigen::Infinity>();
721#else
723 (_val.begin(), _val.end(), Real(0),
724 [](const auto & a, const auto & b){using std::max; return max(a,b);},
725 [](const T & v){using std::abs; return abs(v);});
726#endif
727}
static const Real b

References b, libmesh_transform_reduce(), and libMesh::Real.

Referenced by libMesh::RBEIMEvaluation::get_eim_error_indicator(), and DenseMatrixTest::testNorms().

◆ max()

template<typename T >
Real libMesh::DenseVector< T >::max ( ) const
inline
Returns
The maximum entry of the vector, or the maximum real part in the case of complex numbers.

Definition at line 663 of file dense_vector.h.

664{
665 libmesh_assert (this->size());
666 typedef decltype(libmesh_real(T(0))) realfromT;
668 (_val.begin(), _val.end(), std::numeric_limits<realfromT>::lowest(),
669 [](const auto & a, const auto & b){using std::max; return max(a,b);},
670 [](const T & v){return libmesh_real(v);});
671}
libmesh_assert(ctx)
LIBMESH_DEVICE_INLINE T libmesh_real(T a)

References b, libMesh::libmesh_assert(), libMesh::libmesh_real(), and libmesh_transform_reduce().

◆ min()

template<typename T >
Real libMesh::DenseVector< T >::min ( ) const
inline
Returns
The minimum entry of the vector, or the minimum real part in the case of complex numbers.

Definition at line 649 of file dense_vector.h.

650{
651 libmesh_assert (this->size());
652 typedef decltype(libmesh_real(T(0))) realfromT;
654 (_val.begin(), _val.end(), std::numeric_limits<realfromT>::max(),
655 [](const auto & a, const auto & b){using std::min; return min(a,b);},
656 [](const T & v){return libmesh_real(v);});
657}

References b, libMesh::libmesh_assert(), libMesh::libmesh_real(), and libmesh_transform_reduce().

◆ operator!=()

template<typename T >
template<typename T2 >
bool libMesh::DenseVector< T >::operator!= ( const DenseVector< T2 > &  vec) const
inline
Returns
true if vec is not exactly equal to this vector, false otherwise.

Definition at line 601 of file dense_vector.h.

602{
603 libmesh_assert_equal_to (this->size(), vec.size());
604
605 const int N = cast_int<int>(_val.size());
606 for (int i=0; i<N; i++)
607 if ((*this)(i) != vec(i))
608 return true;
609
610 return false;
611}

References libMesh::DenseVector< T >::size().

◆ operator()() [1/2]

template<typename T >
T & libMesh::DenseVector< T >::operator() ( const unsigned int  i)
inline
Returns
Entry i of the vector as a writable reference.

Definition at line 486 of file dense_vector.h.

487{
488 libmesh_assert_less (i, _val.size());
489
490 return _val[i];
491}

◆ operator()() [2/2]

template<typename T >
const T & libMesh::DenseVector< T >::operator() ( const unsigned int  i) const
inline
Returns
Entry i of the vector as a const reference.

Definition at line 475 of file dense_vector.h.

476{
477 libmesh_assert_less (i, _val.size());
478
479 return _val[i];
480}

◆ operator*=()

template<typename T >
DenseVector< T > & libMesh::DenseVector< T >::operator*= ( const T  factor)
inline

Multiplies every element in the vector by factor.

Returns
A reference to *this.

Definition at line 507 of file dense_vector.h.

508{
509 this->scale(factor);
510 return *this;
511}
void scale(const T factor)
Multiplies every element in the vector by factor.

◆ operator+=()

template<typename T >
template<typename T2 >
DenseVector< T > & libMesh::DenseVector< T >::operator+= ( const DenseVector< T2 > &  vec)
inline

Adds vec to this vector.

Returns
A reference to *this.

Definition at line 618 of file dense_vector.h.

619{
620 libmesh_assert_equal_to (this->size(), vec.size());
621
622 const int N = cast_int<int>(_val.size());
623 for (int i=0; i<N; i++)
624 (*this)(i) += vec(i);
625
626 return *this;
627}

References libMesh::DenseVector< T >::size().

◆ operator-=()

template<typename T >
template<typename T2 >
DenseVector< T > & libMesh::DenseVector< T >::operator-= ( const DenseVector< T2 > &  vec)
inline

Subtracts vec from this vector.

Returns
A reference to *this.

Definition at line 634 of file dense_vector.h.

635{
636 libmesh_assert_equal_to (this->size(), vec.size());
637
638 const int N = cast_int<int>(_val.size());
639 for (int i=0; i<N; i++)
640 (*this)(i) -= vec(i);
641
642 return *this;
643}

References libMesh::DenseVector< T >::size().

◆ operator=() [1/3]

template<typename T >
DenseVector & libMesh::DenseVector< T >::operator= ( const DenseVector< T > &  )
default

◆ operator=() [2/3]

template<typename T >
template<typename T2 >
DenseVector< T > & libMesh::DenseVector< T >::operator= ( const DenseVector< T2 > &  other_vector)
inline

Assignment operator.

Returns
A reference to *this.

Definition at line 420 of file dense_vector.h.

421{
422 const std::vector<T2> & other_vals = other_vector.get_values();
423 _val.assign(other_vals.begin(), other_vals.end());
424 return *this;
425}

References libMesh::DenseVector< T >::get_values().

◆ operator=() [3/3]

template<typename T >
DenseVector & libMesh::DenseVector< T >::operator= ( DenseVector< T > &&  )
default

◆ operator==()

template<typename T >
template<typename T2 >
bool libMesh::DenseVector< T >::operator== ( const DenseVector< T2 > &  vec) const
inline
Returns
true if vec is exactly equal to this vector, false otherwise.

Definition at line 584 of file dense_vector.h.

585{
586 libmesh_assert_equal_to (this->size(), vec.size());
587
588 const int N = cast_int<int>(_val.size());
589 for (int i=0; i<N; i++)
590 if ((*this)(i) != vec(i))
591 return false;
592
593 return true;
594}

References libMesh::DenseVector< T >::size().

◆ operator[]() [1/2]

template<typename T >
T & libMesh::DenseVector< T >::operator[] ( const unsigned int  i)
inline
Returns
Entry i of the vector as a writable reference.

Definition at line 134 of file dense_vector.h.

134{ return (*this)(i); }

◆ operator[]() [2/2]

template<typename T >
const T & libMesh::DenseVector< T >::operator[] ( const unsigned int  i) const
inline
Returns
Entry i of the vector as a const reference.

Definition at line 129 of file dense_vector.h.

129{ return (*this)(i); }

◆ print()

template<typename T >
void libMesh::DenseVectorBase< T >::print ( std::ostream &  os) const
inherited

Pretty-print the vector to stdout.

Definition at line 110 of file dense_vector_base.h.

111{
112 for (auto i : make_range(this->size()))
113 os << std::setw(8)
114 << this->el(i)
115 << std::endl;
116}
virtual T el(const unsigned int i) const =0
virtual unsigned int size() const =0
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition int_range.h:176

References libMesh::make_range().

◆ print_scientific()

template<typename T >
void libMesh::DenseVectorBase< T >::print_scientific ( std::ostream &  os,
unsigned  precision = 8 
) const
inherited

Prints the entries of the vector with additional decimal places in scientific notation.

Definition at line 31 of file dense_vector_base.C.

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}

References libMesh::make_range().

◆ resize()

template<typename T >
void libMesh::DenseVector< T >::resize ( const unsigned int  n)
inline

Resize the vector.

Sets all elements to 0.

Definition at line 440 of file dense_vector.h.

441{
442 _val.resize(n);
443
444 zero();
445}
virtual void zero() override final
Set every element in the vector to 0.

References libMesh::zero.

Referenced by libMesh::DenseMatrix< T >::_cholesky_back_substitute(), libMesh::DenseMatrix< T >::_lu_back_substitute(), libMesh::DenseMatrix< T >::_svd_lapack(), libMesh::DenseMatrix< T >::_svd_lapack(), libMesh::DenseMatrix< T >::_svd_solve_lapack(), libMesh::HPCoarsenTest::add_projection(), libMesh::TransientRBConstruction::allocate_data_structures(), alternative_fe_assembly(), LinearElasticity::assemble(), assemble(), assemble(), assemble_1D(), AssembleOptimization::assemble_A_and_F(), assemble_biharmonic(), assemble_cd(), assemble_cd(), assemble_divgrad(), assemble_elasticity(), assemble_ellipticdg(), assemble_func(), assemble_graddiv(), assemble_helmholtz(), assemble_laplace(), assemble_matrix_and_rhs(), assemble_poisson(), assemble_poisson(), assemble_poisson(), assemble_shell(), assemble_shell(), assemble_stokes(), assemble_temperature_jump(), assemble_wave(), assemble_wave(), Biharmonic::JR::bounds(), libMesh::DofMap::build_constraint_matrix_and_vector(), libMesh::TransientRBEvaluation::cache_online_residual_terms(), libMesh::FEGenericBase< OutputType >::coarsened_dof_values(), libMesh::FEGenericBase< OutputType >::coarsened_dof_values(), compute_enriched_soln(), libMesh::FEGenericBase< OutputType >::compute_periodic_constraints(), libMesh::FEGenericBase< OutputType >::compute_proj_constraints(), compute_residual(), SolidSystem::element_time_derivative(), fe_assembly(), form_functionA(), form_functionB(), libMesh::DenseVector< T >::get_principal_subvector(), libMesh::DGFEMContext::neighbor_side_fe_reinit(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::SmoothnessEstimator::EstimateSmoothness::operator()(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::BoundaryProjectSolution::operator()(), libMesh::CompositeFEMFunction< Output >::operator()(), libMesh::MeshfreeInterpolationFunction::operator()(), libMesh::MeshFunction::operator()(), libMesh::CompositeFunction< Output >::operator()(), libMesh::AutoAreaFunction::operator()(), BdyFunction::operator()(), SkewFunc::operator()(), libMesh::MeshTools::Generation::Private::GaussLobattoRedistributionFunction::operator()(), periodic_bc_test_poisson(), libMesh::FEMContext::pre_fe_reinit(), libMesh::TransientRBEvaluation::rb_solve(), libMesh::RBEvaluation::rb_solve(), libMesh::TransientRBEvaluation::rb_solve_again(), LargeDeformationElasticity::residual(), LaplaceYoung::residual(), libMesh::HDGProblem::residual(), LinearElasticityWithContact::residual_and_jacobian(), Biharmonic::JR::residual_and_jacobian(), libMesh::TransientRBEvaluation::resize_data_structures(), libMesh::HPCoarsenTest::select_refinement(), libMesh::DenseMatrix< Real >::svd(), libMesh::DenseMatrix< T >::vector_mult(), libMesh::DenseMatrix< T >::vector_mult_add(), and libMesh::DenseMatrix< T >::vector_mult_transpose().

◆ scale()

template<typename T >
void libMesh::DenseVector< T >::scale ( const T  factor)
inline

Multiplies every element in the vector by factor.

Definition at line 497 of file dense_vector.h.

498{
499 for (auto & v : _val)
500 v *= factor;
501}

Referenced by SolidSystem::element_time_derivative().

◆ size()

template<typename T >
virtual unsigned int libMesh::DenseVector< T >::size ( ) const
inlinefinaloverridevirtual
Returns
The size of the vector.

Implements libMesh::DenseVectorBase< T >.

Definition at line 106 of file dense_vector.h.

107 {
108 return cast_int<unsigned int>(_val.size());
109 }

References libMesh::DenseVector< T >::_val.

Referenced by libMesh::NewmarkSolver::_general_residual(), libMesh::Euler2Solver::_general_residual(), libMesh::EulerSolver::_general_residual(), libMesh::MeshFunction::_gradient_on_elem(), libMesh::DenseMatrix< T >::_matvec_blas(), libMesh::DenseMatrix< T >::_svd_lapack(), libMesh::DenseMatrix< T >::_svd_lapack(), libMesh::DenseMatrix< T >::_svd_solve_lapack(), libMesh::DenseVector< T >::add(), libMesh::HPCoarsenTest::add_projection(), libMesh::RBDataSerialization::add_rb_eim_evaluation_data_to_builder(), libMesh::NumericVector< T >::add_vector(), libMesh::FEMSystem::assembly(), libMesh::DofMap::constrain_element_residual(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubProjector::construct_projection(), libMesh::RBEIMEvaluation::decrement_vector(), libMesh::MeshFunction::discontinuous_value(), libMesh::DenseVector< T >::dot(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::ExactErrorEstimator::find_squared_element_error(), libMesh::RBEIMEvaluation::get_eim_error_indicator(), libMesh::MeshFunction::hessian(), libMesh::DofMap::heterogeneously_constrain_element_jacobian_and_residual(), libMesh::DofMap::heterogeneously_constrain_element_residual(), libMesh::DenseVector< T >::indefinite_dot(), libMesh::NumericVector< T >::insert(), libMesh::VectorSetAction< Val >::insert(), libMesh::LaplacianErrorEstimator::internal_side_integration(), libMesh::TransientRBConstruction::load_rb_solution(), libMesh::RBEIMEvaluation::node_decrement_vector(), libMesh::DenseVector< T >::operator!=(), libMesh::SmoothnessEstimator::EstimateSmoothness::operator()(), libMesh::FDMGradient< GradType >::operator()(), SlitFunc::operator()(), libMesh::CompositeFEMFunction< Output >::operator()(), libMesh::ParsedFEMFunction< Output >::operator()(), ExampleOneFunction::operator()(), libMesh::ConstFunction< Output >::operator()(), libMesh::MeshFunction::operator()(), libMesh::CompositeFunction< Output >::operator()(), libMesh::WrappedFunction< Output >::operator()(), SolutionFunction< dim >::operator()(), PeriodicQuadFunction::operator()(), TripleFunction::operator()(), libMesh::DenseVector< T >::operator+=(), libMesh::DenseVector< T >::operator-=(), libMesh::DenseVector< T >::operator==(), periodic_bc_test_poisson(), libMesh::RBEIMEvaluation::rb_eim_solve(), libMesh::TransientRBEvaluation::rb_solve_again(), libMesh::DenseMatrix< Real >::right_multiply_transpose(), libMesh::RBEIMEvaluation::side_decrement_vector(), libMesh::DenseMatrix< Real >::svd(), libMesh::DenseMatrix< Real >::svd_solve(), DenseMatrixTest::testComplexSVD(), DenseMatrixTest::testEVD_helper(), DenseMatrixTest::testOuterProduct(), InfFERadialTest::testRefinement(), DenseMatrixTest::testSVD(), MetaPhysicL::RawType< libMesh::DenseVector< T > >::value(), libMesh::DenseMatrix< T >::vector_mult(), libMesh::DenseMatrix< T >::vector_mult(), libMesh::DenseMatrix< T >::vector_mult_add(), and libMesh::DenseMatrix< T >::vector_mult_transpose().

◆ swap()

template<typename T >
void libMesh::DenseVector< T >::swap ( DenseVector< T > &  other_vector)
inline

STL-like swap method.

Definition at line 431 of file dense_vector.h.

432{
433 _val.swap(other_vector._val);
434}

References libMesh::DenseVector< T >::_val.

Referenced by libMesh::Euler2Solver::_general_residual(), and libMesh::EulerSolver::_general_residual().

◆ zero()

template<typename T >
void libMesh::DenseVector< T >::zero ( )
inlinefinaloverridevirtual

Friends And Related Symbol Documentation

◆ isfinite

template<typename T >
bool isfinite ( const DenseVector< T > &  var)
friend

Returns true iff every entry is finite.

Definition at line 302 of file dense_vector.h.

303 {
304 using std::isfinite;
305 using libMesh::isfinite; // for T==complex
306 for (const T & v : var._val)
307 if (!isfinite(v))
308 return false;
309 return true;
310 }
friend bool isfinite(const DenseVector< T > &var)
Returns true iff every entry is finite.
LIBMESH_DEVICE_INLINE bool isfinite(std::complex< T > a)

◆ isinf

template<typename T >
bool isinf ( const DenseVector< T > &  var)
friend

Returns true iff no entry is NaN and any entry is infinite.

This is arguably inconsistent with our std::complex overload (and the C99 Annex G recommendations for _Complex, and C++ std::complex arithmetic), which treats mixed (inf,NaN) pairs as infinite, but this is probably safer for users.

Definition at line 320 of file dense_vector.h.

321 {
322 using std::isinf;
323 using libMesh::isinf; // for T==complex
324 using std::isnan;
325 using libMesh::isnan;
326 bool has_inf = false;
327 for (const T & v : var._val)
328 {
329 // NaN anywhere makes us NaN, not inf
330 if (isnan(v))
331 return false;
332 has_inf = has_inf || isinf(v);
333 }
334 return has_inf;
335 }
friend bool isinf(const DenseVector< T > &var)
Returns true iff no entry is NaN and any entry is infinite.
friend bool isnan(const DenseVector< T > &var)
Returns true iff any entry is NaN.
LIBMESH_DEVICE_INLINE bool isnan(std::complex< T > a)
LIBMESH_DEVICE_INLINE bool isinf(std::complex< T > a)

◆ isnan

template<typename T >
bool isnan ( const DenseVector< T > &  var)
friend

Returns true iff any entry is NaN.

This is arguably inconsistent with our std::complex overload (and the C99 Annex G recommendations for _Complex, and C++ std::complex arithmetic), which treats mixed (inf,NaN) pairs as infinite, but this is probably safer for users.

Definition at line 345 of file dense_vector.h.

346 {
347 using std::isnan;
348 using libMesh::isnan; // for T==complex
349 for (const T & v : var._val)
350 if (isnan(v))
351 return true;
352 return false;
353 }

Member Data Documentation

◆ _val

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

The documentation for this class was generated from the following files: