Loading [MathJax]/extensions/tex2jax.js
libMesh
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
Classes | Public Types | Public Member Functions | Protected Attributes | List of all members
libMesh::VectorValue< T > Class Template Reference

This class defines a vector in LIBMESH_DIM dimensional Real or Complex space. More...

#include <exact_solution.h>

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

Classes

struct  rebind
 

Public Types

typedef T value_type
 
typedef unsigned int index_type
 Helper typedef for generic index programming. More...
 

Public Member Functions

 VectorValue ()
 Empty constructor. More...
 
 VectorValue (const T &x, const T &y=0, const T &z=0)
 Constructor-from-T. More...
 
template<typename Scalar1 , typename Scalar2 , typename Scalar3 >
 VectorValue (typename boostcopy::enable_if_c< ScalarTraits< Scalar1 >::value, const Scalar1 >::type &x, typename boostcopy::enable_if_c< ScalarTraits< Scalar2 >::value, const Scalar2 >::type &y=0, typename boostcopy::enable_if_c< ScalarTraits< Scalar3 >::value, const Scalar3 >::type &z=0)
 Constructor-from-scalars. More...
 
template<typename Scalar >
 VectorValue (const Scalar &x, typename boostcopy::enable_if_c< ScalarTraits< Scalar >::value, const Scalar >::type *sfinae=nullptr)
 Constructor-from-scalar. More...
 
template<typename T2 >
 VectorValue (const VectorValue< T2 > &p)
 Copy-constructor. More...
 
template<typename T2 >
 VectorValue (const TypeVector< T2 > &p)
 Copy-constructor. More...
 
 VectorValue (const TypeVector< Real > &p_re, const TypeVector< Real > &p_im)
 Constructor that takes two TypeVector<Real> representing the real and imaginary part as arguments. More...
 
template<typename Scalar >
boostcopy::enable_if_c< ScalarTraits< Scalar >::value, VectorValue & >::type operator= (const Scalar &libmesh_dbg_var(p))
 Assignment-from-scalar operator. More...
 
template<typename T2 >
void assign (const TypeVector< T2 > &)
 Assign to this vector without creating a temporary. More...
 
const T & operator() (const unsigned int i) const
 
T & operator() (const unsigned int i)
 
const T & slice (const unsigned int i) const
 
T & slice (const unsigned int i)
 
template<typename T2 >
TypeVector< typename CompareTypes< T, T2 >::supertype > operator+ (const TypeVector< T2 > &) const
 Add two vectors. More...
 
template<typename T2 >
const TypeVector< T > & operator+= (const TypeVector< T2 > &)
 Add to this vector. More...
 
template<typename T2 >
void add (const TypeVector< T2 > &)
 Add to this vector without creating a temporary. More...
 
template<typename T2 >
void add_scaled (const TypeVector< T2 > &, const T &)
 Add a scaled value to this vector without creating a temporary. More...
 
template<typename T2 >
TypeVector< typename CompareTypes< T, T2 >::supertype > operator- (const TypeVector< T2 > &) const
 Subtract from this vector. More...
 
TypeVector< T > operator- () const
 
template<typename T2 >
const TypeVector< T > & operator-= (const TypeVector< T2 > &)
 Subtract from this vector. More...
 
template<typename T2 >
void subtract (const TypeVector< T2 > &)
 Subtract from this vector without creating a temporary. More...
 
template<typename T2 >
void subtract_scaled (const TypeVector< T2 > &, const T &)
 Subtract a scaled value from this vector without creating a temporary. More...
 
template<typename Scalar >
boostcopy::enable_if_c< ScalarTraits< Scalar >::value, TypeVector< typename CompareTypes< T, Scalar >::supertype > >::type operator* (const Scalar &) const
 Multiply this vector by a scalar value. More...
 
template<typename T2 >
CompareTypes< T, T2 >::supertype operator* (const TypeVector< T2 > &) const
 
const TypeVector< T > & operator*= (const T &)
 Multiply this vector by a scalar value. More...
 
template<typename Scalar >
boostcopy::enable_if_c< ScalarTraits< Scalar >::value, TypeVector< typename CompareTypes< T, Scalar >::supertype > >::type operator/ (const Scalar &) const
 Divide each entry of this vector by scalar value. More...
 
const TypeVector< T > & operator/= (const T &)
 Divide each entry of this vector by scalar value. More...
 
template<typename T2 >
CompareTypes< T, T2 >::supertype contract (const TypeVector< T2 > &) const
 
template<typename T2 >
TypeVector< typename CompareTypes< T, T2 >::supertype > cross (const TypeVector< T2 > &v) const
 
TypeVector< T > unit () const
 
auto norm () const -> decltype(std::norm(T()))
 
auto norm_sq () const -> decltype(std::norm(T()))
 
auto l1_norm () const
 
template<>
auto l1_norm () const
 
template<>
auto l1_norm () const
 
bool is_zero () const
 
void zero ()
 Set all entries of the vector to 0. More...
 
bool relative_fuzzy_equals (const TypeVector< T > &rhs, Real tol=TOLERANCE) const
 
bool absolute_fuzzy_equals (const TypeVector< T > &rhs, Real tol=TOLERANCE) const
 
bool operator== (const TypeVector< T > &rhs) const
 
bool operator!= (const TypeVector< T > &rhs) const
 
bool operator< (const TypeVector< T > &rhs) const
 
template<>
bool operator< (const TypeVector< Complex > &rhs) const
 
bool operator<= (const TypeVector< T > &rhs) const
 
template<>
bool operator<= (const TypeVector< Complex > &rhs) const
 
bool operator> (const TypeVector< T > &rhs) const
 
template<>
bool operator> (const TypeVector< Complex > &rhs) const
 
bool operator>= (const TypeVector< T > &rhs) const
 
template<>
bool operator>= (const TypeVector< Complex > &rhs) const
 
void print (std::ostream &os=libMesh::out) const
 Formatted print, by default to libMesh::out. More...
 
void write_unformatted (std::ostream &out_stream, const bool newline=true) const
 Unformatted print to the stream out. More...
 

Protected Attributes

_coords [LIBMESH_DIM]
 The coordinates of the TypeVector. More...
 

Detailed Description

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

This class defines a vector in LIBMESH_DIM dimensional Real or Complex space.

The typedef RealVectorValue always defines a real-valued vector, and NumberVectorValue defines a real or complex-valued vector depending on how the library was configured.

Author
Benjamin S. Kirk
Date
2003

Definition at line 47 of file exact_solution.h.

Member Typedef Documentation

◆ index_type

template<typename T>
typedef unsigned int libMesh::TypeVector< T >::index_type
inherited

Helper typedef for generic index programming.

Definition at line 120 of file type_vector.h.

◆ value_type

template<typename T>
typedef T libMesh::VectorValue< T >::value_type

Definition at line 50 of file vector_value.h.

Constructor & Destructor Documentation

◆ VectorValue() [1/7]

template<typename T >
libMesh::VectorValue< T >::VectorValue ( )
inline

Empty constructor.

Gives the vector 0 in LIBMESH_DIM dimensional T space.

Definition at line 150 of file vector_value.h.

150  :
151  TypeVector<T> ()
152 {
153 }

◆ VectorValue() [2/7]

template<typename T>
libMesh::VectorValue< T >::VectorValue ( const T &  x,
const T &  y = 0,
const T &  z = 0 
)
inline

Constructor-from-T.

By default sets higher dimensional entries to 0.

Definition at line 158 of file vector_value.h.

160  :
161  TypeVector<T> (x,y,z)
162 {
163 }

◆ VectorValue() [3/7]

template<typename T >
template<typename Scalar1 , typename Scalar2 , typename Scalar3 >
libMesh::VectorValue< T >::VectorValue ( typename boostcopy::enable_if_c< ScalarTraits< Scalar1 >::value, const Scalar1 >::type &  x,
typename boostcopy::enable_if_c< ScalarTraits< Scalar2 >::value, const Scalar2 >::type &  y = 0,
typename boostcopy::enable_if_c< ScalarTraits< Scalar3 >::value, const Scalar3 >::type &  z = 0 
)
inline

Constructor-from-scalars.

By default sets higher dimensional entries to 0.

Definition at line 170 of file vector_value.h.

178  :
179  TypeVector<T> (x,y,z)
180 {
181 }

◆ VectorValue() [4/7]

template<typename T >
template<typename Scalar >
libMesh::VectorValue< T >::VectorValue ( const Scalar &  x,
typename boostcopy::enable_if_c< ScalarTraits< Scalar >::value, const Scalar >::type *  sfinae = nullptr 
)
inline

Constructor-from-scalar.

Sets higher dimensional entries to 0. Necessary because for some reason the constructor-from-scalars alone is insufficient to let the compiler figure out VectorValue<Complex> v = 0;

Definition at line 187 of file vector_value.h.

190  :
191  TypeVector<T> (x)
192 {
193 }

◆ VectorValue() [5/7]

template<typename T >
template<typename T2 >
libMesh::VectorValue< T >::VectorValue ( const VectorValue< T2 > &  p)
inline

Copy-constructor.

Definition at line 198 of file vector_value.h.

198  :
199  TypeVector<T> (p)
200 {
201 }

◆ VectorValue() [6/7]

template<typename T >
template<typename T2 >
libMesh::VectorValue< T >::VectorValue ( const TypeVector< T2 > &  p)
inline

Copy-constructor.

Definition at line 208 of file vector_value.h.

208  :
209  TypeVector<T> (p)
210 {
211 }

◆ VectorValue() [7/7]

template<typename T>
libMesh::VectorValue< T >::VectorValue ( const TypeVector< Real > &  p_re,
const TypeVector< Real > &  p_im 
)
inline

Constructor that takes two TypeVector<Real> representing the real and imaginary part as arguments.

Definition at line 216 of file vector_value.h.

217  :
218  TypeVector<T> (Complex (p_re(0), p_im(0)),
219  Complex (p_re(1), p_im(1)),
220  Complex (p_re(2), p_im(2)))
221 {
222 }
std::complex< Real > Complex

Member Function Documentation

◆ absolute_fuzzy_equals()

template<typename T>
bool libMesh::TypeVector< T >::absolute_fuzzy_equals ( const TypeVector< T > &  rhs,
Real  tol = TOLERANCE 
) const
inlineinherited
Returns
true if two vectors are equal to within an absolute tolerance of tol.

Definition at line 970 of file type_vector.h.

Referenced by libMesh::FEGenericBase< FEOutputType< T >::type >::compute_periodic_constraints(), libMesh::LocationMap< T >::find(), libMesh::Pyramid::local_singular_node(), libMesh::Elem::parent_bracketing_nodes(), VolumeTest::test_true_centroid_and_volume(), MeshTriangulationTest::testFoundCenters(), and VolumeTest::testQuad4TrueCentroid().

971 {
972  return libMesh::absolute_fuzzy_equals(*this, rhs, tol);
973 }
bool absolute_fuzzy_equals(const T &var1, const T2 &var2, const Real tol=TOLERANCE *TOLERANCE)
Function to check whether two variables are equal within an absolute tolerance.
Definition: fuzzy_equals.h:64

◆ add()

template<typename T >
template<typename T2 >
void libMesh::TypeVector< T >::add ( const TypeVector< T2 > &  p)
inlineinherited

Add to this vector without creating a temporary.

Definition at line 603 of file type_vector.h.

Referenced by libMesh::FEMap::inverse_map(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::MeshTools::Modification::smooth(), and libMesh::Elem::vertex_average().

604 {
605 #if LIBMESH_DIM == 1
606  _coords[0] += p._coords[0];
607 #endif
608 
609 #if LIBMESH_DIM == 2
610  _coords[0] += p._coords[0];
611  _coords[1] += p._coords[1];
612 #endif
613 
614 #if LIBMESH_DIM == 3
615  _coords[0] += p._coords[0];
616  _coords[1] += p._coords[1];
617  _coords[2] += p._coords[2];
618 #endif
619 
620 }
T _coords[LIBMESH_DIM]
The coordinates of the TypeVector.
Definition: type_vector.h:415

◆ add_scaled()

template<typename T>
template<typename T2 >
void libMesh::TypeVector< T >::add_scaled ( const TypeVector< T2 > &  p,
const T &  factor 
)
inlineinherited

◆ assign()

template<typename T >
template<typename T2 >
void libMesh::TypeVector< T >::assign ( const TypeVector< T2 > &  p)
inlineinherited

Assign to this vector without creating a temporary.

Definition at line 532 of file type_vector.h.

533 {
534  for (unsigned int i=0; i<LIBMESH_DIM; i++)
535  _coords[i] = p._coords[i];
536 }
T _coords[LIBMESH_DIM]
The coordinates of the TypeVector.
Definition: type_vector.h:415

◆ contract()

template<typename T >
template<typename T2 >
CompareTypes< T, T2 >::supertype libMesh::TypeVector< T >::contract ( const TypeVector< T2 > &  p) const
inlineinherited
Returns
The result of TypeVector::operator*().

Definition at line 872 of file type_vector.h.

873 {
874  return (*this)*(p);
875 }

◆ cross()

template<typename T >
template<typename T2 >
TypeVector< typename CompareTypes< T, T2 >::supertype > libMesh::TypeVector< T >::cross ( const TypeVector< T2 > &  v) const
inherited
Returns
The cross product of this vector with v.

Definition at line 882 of file type_vector.h.

Referenced by libMesh::TriangulatorInterface::Hole::areavec(), assemble_shell(), libMesh::InfFE< Dim, T_radial, T_map >::compute_face_functions(), libMesh::FEMap::compute_face_map(), libMesh::InfFE< Dim, T_radial, T_map >::compute_shape_functions(), ContainsPointTest::containsPointTri3Helper(), libMesh::Plane::create_from_three_points(), libMesh::Quad4::has_invertible_map(), libMesh::TriangulatorInterface::MeshedHole::MeshedHole(), libMesh::Quad::quality(), libMesh::Face::quasicircumcenter(), and libMesh::Quad4::volume().

883 {
884  typedef typename CompareTypes<T, T2>::supertype TS;
885  libmesh_assert_equal_to (LIBMESH_DIM, 3);
886 
887  // | i j k |
888  // |(*this)(0) (*this)(1) (*this)(2)|
889  // | p(0) p(1) p(2) |
890 
891 #if LIBMESH_DIM == 3
892  return TypeVector<TS>( _coords[1]*p._coords[2] - _coords[2]*p._coords[1],
893  -_coords[0]*p._coords[2] + _coords[2]*p._coords[0],
894  _coords[0]*p._coords[1] - _coords[1]*p._coords[0]);
895 #else
896  libmesh_ignore(p);
897  return TypeVector<TS>(0);
898 #endif
899 }
T _coords[LIBMESH_DIM]
The coordinates of the TypeVector.
Definition: type_vector.h:415
void libmesh_ignore(const Args &...)

◆ is_zero()

template<typename T >
bool libMesh::TypeVector< T >::is_zero ( ) const
inlineinherited
Returns
True if all values in the vector are zero

Definition at line 945 of file type_vector.h.

946 {
947  for (const auto & val : _coords)
948  if (val != T(0))
949  return false;
950  return true;
951 }
T _coords[LIBMESH_DIM]
The coordinates of the TypeVector.
Definition: type_vector.h:415

◆ l1_norm() [1/3]

template<>
auto libMesh::TypeVector< bool >::l1_norm ( ) const
inherited

Definition at line 227 of file type_vector.C.

228 {
229  bool ret{};
230  for (const auto i : make_range(libmesh_dim))
231  ret += _coords[i];
232 
233  return ret;
234 }
T _coords[LIBMESH_DIM]
The coordinates of the TypeVector.
Definition: type_vector.h:415
static constexpr std::size_t libmesh_dim
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:140

◆ l1_norm() [2/3]

template<typename T >
auto libMesh::TypeVector< T >::l1_norm ( ) const
inherited
Returns
The L1 norm of the vector

Definition at line 959 of file type_vector.h.

960 {
961  decltype(std::abs(T())) ret{};
962  for (const auto i : make_range(libmesh_dim))
963  ret += std::abs(_coords[i]);
964 
965  return ret;
966 }
T _coords[LIBMESH_DIM]
The coordinates of the TypeVector.
Definition: type_vector.h:415
static constexpr std::size_t libmesh_dim
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:140

◆ l1_norm() [3/3]

template<>
auto libMesh::TypeVector< bool >::l1_norm ( ) const
inherited

◆ norm()

template<typename T>
auto libMesh::TypeVector< T >::norm ( ) const -> decltype(std::norm(T()))
inlineinherited

◆ norm_sq()

template<typename T>
auto libMesh::TypeVector< T >::norm_sq ( ) const -> decltype(std::norm(T()))
inlineinherited

◆ operator!=()

template<typename T>
bool libMesh::TypeVector< T >::operator!= ( const TypeVector< T > &  rhs) const
inlineinherited
Returns
!(*this == rhs)

Definition at line 1010 of file type_vector.h.

1011 {
1012  return (!(*this == rhs));
1013 }

◆ operator()() [1/2]

template<typename T >
const T & libMesh::TypeVector< T >::operator() ( const unsigned int  i) const
inlineinherited
Returns
A const reference to the \( i^{th} \) entry of the vector.

Definition at line 542 of file type_vector.h.

543 {
544  libmesh_assert_less (i, LIBMESH_DIM);
545 
546  return _coords[i];
547 }
T _coords[LIBMESH_DIM]
The coordinates of the TypeVector.
Definition: type_vector.h:415

◆ operator()() [2/2]

template<typename T >
T & libMesh::TypeVector< T >::operator() ( const unsigned int  i)
inlineinherited
Returns
A writable reference to the \( i^{th} \) entry of the vector.

Definition at line 553 of file type_vector.h.

554 {
555  libmesh_assert_less (i, LIBMESH_DIM);
556 
557  return _coords[i];
558 }
T _coords[LIBMESH_DIM]
The coordinates of the TypeVector.
Definition: type_vector.h:415

◆ operator*() [1/2]

template<typename T >
template<typename Scalar >
boostcopy::enable_if_c< ScalarTraits< Scalar >::value, TypeVector< typename CompareTypes< T, Scalar >::supertype > >::type libMesh::TypeVector< T >::operator* ( const Scalar &  factor) const
inlineinherited

Multiply this vector by a scalar value.

Returns
A copy of the result, this vector is unchanged.

Definition at line 739 of file type_vector.h.

740 {
741  typedef typename CompareTypes<T, Scalar>::supertype SuperType;
742 
743 #if LIBMESH_DIM == 1
744  return TypeVector<SuperType>(_coords[0]*factor);
745 #endif
746 
747 #if LIBMESH_DIM == 2
748  return TypeVector<SuperType>(_coords[0]*factor,
749  _coords[1]*factor);
750 #endif
751 
752 #if LIBMESH_DIM == 3
753  return TypeVector<SuperType>(_coords[0]*factor,
754  _coords[1]*factor,
755  _coords[2]*factor);
756 #endif
757 }
T _coords[LIBMESH_DIM]
The coordinates of the TypeVector.
Definition: type_vector.h:415

◆ operator*() [2/2]

template<typename T >
template<typename T2 >
CompareTypes< T, T2 >::supertype libMesh::TypeVector< T >::operator* ( const TypeVector< T2 > &  p) const
inlineinherited
Returns
The dot-product of this vector with another vector.
Note
The complex conjugate is not taken in the complex-valued case.
The vectors may contain different numeric types.

Definition at line 850 of file type_vector.h.

851 {
852 #if LIBMESH_DIM == 1
853  return _coords[0]*p._coords[0];
854 #endif
855 
856 #if LIBMESH_DIM == 2
857  return (_coords[0]*p._coords[0] +
858  _coords[1]*p._coords[1]);
859 #endif
860 
861 #if LIBMESH_DIM == 3
862  return (_coords[0]*p(0) +
863  _coords[1]*p(1) +
864  _coords[2]*p(2));
865 #endif
866 }
T _coords[LIBMESH_DIM]
The coordinates of the TypeVector.
Definition: type_vector.h:415

◆ operator*=()

template<typename T>
const TypeVector< T > & libMesh::TypeVector< T >::operator*= ( const T &  factor)
inlineinherited

Multiply this vector by a scalar value.

Returns
A reference to *this.

Definition at line 776 of file type_vector.h.

777 {
778 #if LIBMESH_DIM == 1
779  _coords[0] *= factor;
780 #endif
781 
782 #if LIBMESH_DIM == 2
783  _coords[0] *= factor;
784  _coords[1] *= factor;
785 #endif
786 
787 #if LIBMESH_DIM == 3
788  _coords[0] *= factor;
789  _coords[1] *= factor;
790  _coords[2] *= factor;
791 #endif
792 
793  return *this;
794 }
T _coords[LIBMESH_DIM]
The coordinates of the TypeVector.
Definition: type_vector.h:415

◆ operator+()

template<typename T >
template<typename T2 >
TypeVector< typename CompareTypes< T, T2 >::supertype > libMesh::TypeVector< T >::operator+ ( const TypeVector< T2 > &  p) const
inlineinherited

Add two vectors.

Returns
A copy of the result, this vector is unchanged.

Definition at line 566 of file type_vector.h.

567 {
568  typedef typename CompareTypes<T, T2>::supertype TS;
569 #if LIBMESH_DIM == 1
570  return TypeVector<TS> (_coords[0] + p._coords[0]);
571 #endif
572 
573 #if LIBMESH_DIM == 2
574  return TypeVector<TS> (_coords[0] + p._coords[0],
575  _coords[1] + p._coords[1]);
576 #endif
577 
578 #if LIBMESH_DIM == 3
579  return TypeVector<TS> (_coords[0] + p._coords[0],
580  _coords[1] + p._coords[1],
581  _coords[2] + p._coords[2]);
582 #endif
583 
584 }
T _coords[LIBMESH_DIM]
The coordinates of the TypeVector.
Definition: type_vector.h:415

◆ operator+=()

template<typename T >
template<typename T2 >
const TypeVector< T > & libMesh::TypeVector< T >::operator+= ( const TypeVector< T2 > &  p)
inlineinherited

Add to this vector.

Returns
A reference to *this.

Definition at line 591 of file type_vector.h.

592 {
593  this->add (p);
594 
595  return *this;
596 }
void add(const TypeVector< T2 > &)
Add to this vector without creating a temporary.
Definition: type_vector.h:603

◆ operator-() [1/2]

template<typename T >
template<typename T2 >
TypeVector< typename CompareTypes< T, T2 >::supertype > libMesh::TypeVector< T >::operator- ( const TypeVector< T2 > &  p) const
inlineinherited

Subtract from this vector.

Returns
A copy of the result, this vector is unchanged.

Definition at line 652 of file type_vector.h.

653 {
654  typedef typename CompareTypes<T, T2>::supertype TS;
655 
656 #if LIBMESH_DIM == 1
657  return TypeVector<TS>(_coords[0] - p._coords[0]);
658 #endif
659 
660 #if LIBMESH_DIM == 2
661  return TypeVector<TS>(_coords[0] - p._coords[0],
662  _coords[1] - p._coords[1]);
663 #endif
664 
665 #if LIBMESH_DIM == 3
666  return TypeVector<TS>(_coords[0] - p._coords[0],
667  _coords[1] - p._coords[1],
668  _coords[2] - p._coords[2]);
669 #endif
670 
671 }
T _coords[LIBMESH_DIM]
The coordinates of the TypeVector.
Definition: type_vector.h:415

◆ operator-() [2/2]

template<typename T >
TypeVector< T > libMesh::TypeVector< T >::operator- ( ) const
inlineinherited
Returns
The negative of this vector in a separate copy.

Definition at line 711 of file type_vector.h.

712 {
713 
714 #if LIBMESH_DIM == 1
715  return TypeVector(-_coords[0]);
716 #endif
717 
718 #if LIBMESH_DIM == 2
719  return TypeVector(-_coords[0],
720  -_coords[1]);
721 #endif
722 
723 #if LIBMESH_DIM == 3
724  return TypeVector(-_coords[0],
725  -_coords[1],
726  -_coords[2]);
727 #endif
728 
729 }
T _coords[LIBMESH_DIM]
The coordinates of the TypeVector.
Definition: type_vector.h:415
TypeVector()
Empty constructor.
Definition: type_vector.h:427

◆ operator-=()

template<typename T >
template<typename T2 >
const TypeVector< T > & libMesh::TypeVector< T >::operator-= ( const TypeVector< T2 > &  p)
inlineinherited

Subtract from this vector.

Returns
A reference to *this.

Definition at line 678 of file type_vector.h.

679 {
680  this->subtract (p);
681 
682  return *this;
683 }
void subtract(const TypeVector< T2 > &)
Subtract from this vector without creating a temporary.
Definition: type_vector.h:690

◆ operator/()

template<typename T >
template<typename Scalar >
boostcopy::enable_if_c< ScalarTraits< Scalar >::value, TypeVector< typename CompareTypes< T, Scalar >::supertype > >::type libMesh::TypeVector< T >::operator/ ( const Scalar &  factor) const
inlineinherited

Divide each entry of this vector by scalar value.

Returns
A copy of the result, this vector is unchanged.

Definition at line 804 of file type_vector.h.

805 {
806  libmesh_assert_not_equal_to (factor, static_cast<T>(0.));
807 
808  typedef typename CompareTypes<T, Scalar>::supertype TS;
809 
810 #if LIBMESH_DIM == 1
811  return TypeVector<TS>(_coords[0]/factor);
812 #endif
813 
814 #if LIBMESH_DIM == 2
815  return TypeVector<TS>(_coords[0]/factor,
816  _coords[1]/factor);
817 #endif
818 
819 #if LIBMESH_DIM == 3
820  return TypeVector<TS>(_coords[0]/factor,
821  _coords[1]/factor,
822  _coords[2]/factor);
823 #endif
824 
825 }
T _coords[LIBMESH_DIM]
The coordinates of the TypeVector.
Definition: type_vector.h:415

◆ operator/=()

template<typename T>
const TypeVector< T > & libMesh::TypeVector< T >::operator/= ( const T &  factor)
inlineinherited

Divide each entry of this vector by scalar value.

Returns
A reference to *this.

Definition at line 833 of file type_vector.h.

834 {
835  libmesh_assert_not_equal_to (factor, static_cast<T>(0.));
836 
837  for (unsigned int i=0; i<LIBMESH_DIM; i++)
838  _coords[i] /= factor;
839 
840  return *this;
841 }
T _coords[LIBMESH_DIM]
The coordinates of the TypeVector.
Definition: type_vector.h:415

◆ operator<() [1/2]

template<>
bool libMesh::TypeVector< Complex >::operator< ( const TypeVector< Complex > &  rhs) const
inherited

Definition at line 148 of file type_vector.C.

149 {
150  for (unsigned int i=0; i<LIBMESH_DIM; i++)
151  {
152  if ((*this)(i).real() < rhs(i).real())
153  return true;
154  if ((*this)(i).real() > rhs(i).real())
155  return false;
156  if ((*this)(i).imag() < rhs(i).imag())
157  return true;
158  if ((*this)(i).imag() > rhs(i).imag())
159  return false;
160  }
161  return false;
162 }
boost::multiprecision::float128 real(const boost::multiprecision::float128 in)
boost::multiprecision::float128 imag(const boost::multiprecision::float128)

◆ operator<() [2/2]

template<typename T>
bool libMesh::TypeVector< T >::operator< ( const TypeVector< T > &  rhs) const
inherited
Returns
true if this vector is "less" than rhs.

Useful for sorting. Also used for choosing some arbitrary basis function orientations.

Definition at line 90 of file type_vector.C.

91 {
92  for (unsigned int i=0; i<LIBMESH_DIM; i++)
93  {
94  if ((*this)(i) < rhs(i))
95  return true;
96  if ((*this)(i) > rhs(i))
97  return false;
98  }
99  return false;
100 }

◆ operator<=() [1/2]

template<>
bool libMesh::TypeVector< Complex >::operator<= ( const TypeVector< Complex > &  rhs) const
inherited

Definition at line 167 of file type_vector.C.

168 {
169  for (unsigned int i=0; i<LIBMESH_DIM; i++)
170  {
171  if ((*this)(i).real() < rhs(i).real())
172  return true;
173  if ((*this)(i).real() > rhs(i).real())
174  return false;
175  if ((*this)(i).imag() < rhs(i).imag())
176  return true;
177  if ((*this)(i).imag() > rhs(i).imag())
178  return false;
179  }
180  return true;
181 }
boost::multiprecision::float128 real(const boost::multiprecision::float128 in)
boost::multiprecision::float128 imag(const boost::multiprecision::float128)

◆ operator<=() [2/2]

template<typename T>
bool libMesh::TypeVector< T >::operator<= ( const TypeVector< T > &  rhs) const
inherited
Returns
true if this vector is <= to rhs.

Useful for sorting. Also used for choosing some arbitrary constraint equation directions.

Definition at line 104 of file type_vector.C.

105 {
106  for (unsigned int i=0; i<LIBMESH_DIM; i++)
107  {
108  if ((*this)(i) < rhs(i))
109  return true;
110  if ((*this)(i) > rhs(i))
111  return false;
112  }
113  return true;
114 }

◆ operator=()

template<typename T>
template<typename Scalar >
boostcopy::enable_if_c< ScalarTraits<Scalar>::value, VectorValue &>::type libMesh::VectorValue< T >::operator= ( const Scalar &  libmesh_dbg_varp)
inline

Assignment-from-scalar operator.

Used only to zero out vectors.

Definition at line 130 of file vector_value.h.

131  { libmesh_assert_equal_to (p, Scalar(0)); this->zero(); return *this; }
void zero()
Set all entries of the vector to 0.
Definition: type_vector.h:914

◆ operator==()

template<typename T>
bool libMesh::TypeVector< T >::operator== ( const TypeVector< T > &  rhs) const
inlineinherited
Returns
true if this(i)==rhs(i) for each component of the vector.
Note
For floating point types T, the function absolute_fuzzy_equals() may be a more appropriate choice.

Definition at line 988 of file type_vector.h.

989 {
990 #if LIBMESH_DIM == 1
991  return (_coords[0] == rhs._coords[0]);
992 #endif
993 
994 #if LIBMESH_DIM == 2
995  return (_coords[0] == rhs._coords[0] &&
996  _coords[1] == rhs._coords[1]);
997 #endif
998 
999 #if LIBMESH_DIM == 3
1000  return (_coords[0] == rhs._coords[0] &&
1001  _coords[1] == rhs._coords[1] &&
1002  _coords[2] == rhs._coords[2]);
1003 #endif
1004 }
T _coords[LIBMESH_DIM]
The coordinates of the TypeVector.
Definition: type_vector.h:415

◆ operator>() [1/2]

template<>
bool libMesh::TypeVector< Complex >::operator> ( const TypeVector< Complex > &  rhs) const
inherited

Definition at line 186 of file type_vector.C.

187 {
188  for (unsigned int i=0; i<LIBMESH_DIM; i++)
189  {
190  if ((*this)(i).real() > rhs(i).real())
191  return true;
192  if ((*this)(i).real() < rhs(i).real())
193  return false;
194  if ((*this)(i).imag() > rhs(i).imag())
195  return true;
196  if ((*this)(i).imag() < rhs(i).imag())
197  return false;
198  }
199  return false;
200 }
boost::multiprecision::float128 real(const boost::multiprecision::float128 in)
boost::multiprecision::float128 imag(const boost::multiprecision::float128)

◆ operator>() [2/2]

template<typename T>
bool libMesh::TypeVector< T >::operator> ( const TypeVector< T > &  rhs) const
inherited
Returns
true if this vector is "greater" than rhs.

Useful for sorting. Also used for choosing some arbitrary basis function orientations.

Definition at line 119 of file type_vector.C.

120 {
121  for (unsigned int i=0; i<LIBMESH_DIM; i++)
122  {
123  if ((*this)(i) > rhs(i))
124  return true;
125  if ((*this)(i) < rhs(i))
126  return false;
127  }
128  return false;
129 }

◆ operator>=() [1/2]

template<>
bool libMesh::TypeVector< Complex >::operator>= ( const TypeVector< Complex > &  rhs) const
inherited

Definition at line 205 of file type_vector.C.

206 {
207  for (unsigned int i=0; i<LIBMESH_DIM; i++)
208  {
209  if ((*this)(i).real() > rhs(i).real())
210  return true;
211  if ((*this)(i).real() < rhs(i).real())
212  return false;
213  if ((*this)(i).imag() > rhs(i).imag())
214  return true;
215  if ((*this)(i).imag() < rhs(i).imag())
216  return false;
217  }
218  return true;
219 }
boost::multiprecision::float128 real(const boost::multiprecision::float128 in)
boost::multiprecision::float128 imag(const boost::multiprecision::float128)

◆ operator>=() [2/2]

template<typename T>
bool libMesh::TypeVector< T >::operator>= ( const TypeVector< T > &  rhs) const
inherited
Returns
true if this vector is >= rhs.

Useful for sorting. Also used for choosing some arbitrary constraint equation directions.

Definition at line 133 of file type_vector.C.

134 {
135  for (unsigned int i=0; i<LIBMESH_DIM; i++)
136  {
137  if ((*this)(i) > rhs(i))
138  return true;
139  if ((*this)(i) < rhs(i))
140  return false;
141  }
142  return true;
143 }

◆ print()

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

Formatted print, by default to libMesh::out.

Definition at line 47 of file type_vector.C.

48 {
49 #if LIBMESH_DIM == 1
50 
51  os << "x=" << (*this)(0);
52 
53 #endif
54 #if LIBMESH_DIM == 2
55 
56  os << "(x,y)=("
57  << std::setw(8) << (*this)(0) << ", "
58  << std::setw(8) << (*this)(1) << ")";
59 
60 #endif
61 #if LIBMESH_DIM == 3
62 
63  os << "(x,y,z)=("
64  << std::setw(8) << (*this)(0) << ", "
65  << std::setw(8) << (*this)(1) << ", "
66  << std::setw(8) << (*this)(2) << ")";
67 #endif
68 }

◆ relative_fuzzy_equals()

template<typename T>
bool libMesh::TypeVector< T >::relative_fuzzy_equals ( const TypeVector< T > &  rhs,
Real  tol = TOLERANCE 
) const
inlineinherited

◆ slice() [1/2]

template<typename T>
const T& libMesh::TypeVector< T >::slice ( const unsigned int  i) const
inlineinherited

Definition at line 158 of file type_vector.h.

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

◆ slice() [2/2]

template<typename T>
T& libMesh::TypeVector< T >::slice ( const unsigned int  i)
inlineinherited

Definition at line 164 of file type_vector.h.

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

◆ subtract()

template<typename T >
template<typename T2 >
void libMesh::TypeVector< T >::subtract ( const TypeVector< T2 > &  p)
inlineinherited

Subtract from this vector without creating a temporary.

Definition at line 690 of file type_vector.h.

691 {
692  for (unsigned int i=0; i<LIBMESH_DIM; i++)
693  _coords[i] -= p._coords[i];
694 }
T _coords[LIBMESH_DIM]
The coordinates of the TypeVector.
Definition: type_vector.h:415

◆ subtract_scaled()

template<typename T>
template<typename T2 >
void libMesh::TypeVector< T >::subtract_scaled ( const TypeVector< T2 > &  p,
const T &  factor 
)
inlineinherited

Subtract a scaled value from this vector without creating a temporary.

Definition at line 701 of file type_vector.h.

Referenced by libMesh::HPCoarsenTest::select_refinement().

702 {
703  for (unsigned int i=0; i<LIBMESH_DIM; i++)
704  _coords[i] -= factor*p(i);
705 }
T _coords[LIBMESH_DIM]
The coordinates of the TypeVector.
Definition: type_vector.h:415

◆ unit()

template<typename T >
TypeVector< T > libMesh::TypeVector< T >::unit ( ) const
inlineinherited
Returns
A unit vector in the direction of *this.

Definition at line 1079 of file type_vector.h.

Referenced by libMesh::InfFE< Dim, T_radial, T_map >::compute_face_functions(), libMesh::FEMap::compute_face_map(), ContainsPointTest::containsPointTri3Helper(), libMesh::Plane::create_from_point_normal(), libMesh::Plane::create_from_three_points(), libMesh::MeshTools::Modification::distort(), libMesh::Elem::quality(), AzimuthalPeriodicBoundary::set_up_rotation_matrix(), and libMesh::Sphere::unit_normal().

1080 {
1081 
1082  auto && length = norm();
1083 
1084  libmesh_assert_not_equal_to (length, static_cast<Real>(0.));
1085 
1086 #if LIBMESH_DIM == 1
1087  return TypeVector<T>(_coords[0]/length);
1088 #endif
1089 
1090 #if LIBMESH_DIM == 2
1091  return TypeVector<T>(_coords[0]/length,
1092  _coords[1]/length);
1093 #endif
1094 
1095 #if LIBMESH_DIM == 3
1096  return TypeVector<T>(_coords[0]/length,
1097  _coords[1]/length,
1098  _coords[2]/length);
1099 #endif
1100 
1101 }
T _coords[LIBMESH_DIM]
The coordinates of the TypeVector.
Definition: type_vector.h:415
auto norm() const -> decltype(std::norm(T()))
Definition: type_vector.h:905

◆ write_unformatted()

template<typename T >
void libMesh::TypeVector< T >::write_unformatted ( std::ostream &  out_stream,
const bool  newline = true 
) const
inherited

Unformatted print to the stream out.

Simply prints the elements of the vector separated by spaces. Also prints a newline by default, however, this behavior can be controlled with the newline parameter.

Definition at line 75 of file type_vector.C.

Referenced by libMesh::InfElemBuilder::build_inf_elem(), and libMesh::TecplotIO::write_ascii().

77 {
78  os << std::setiosflags(std::ios::showpoint)
79  << (*this)(0) << " "
80  << (*this)(1) << " "
81  << (*this)(2) << " ";
82 
83  if (newline)
84  os << '\n';
85 }

◆ zero()

template<typename T >
void libMesh::TypeVector< T >::zero ( )
inlineinherited

Set all entries of the vector to 0.

Definition at line 914 of file type_vector.h.

Referenced by libMesh::VectorValue< Real >::operator=(), libMesh::TypeVector< Real >::operator=(), and TypeVectorTestBase< VectorValue< Number > >::testZeroBase().

915 {
916  for (unsigned int i=0; i<LIBMESH_DIM; i++)
917  _coords[i] = 0.;
918 }
T _coords[LIBMESH_DIM]
The coordinates of the TypeVector.
Definition: type_vector.h:415

Member Data Documentation

◆ _coords

template<typename T>
T libMesh::TypeVector< T >::_coords[LIBMESH_DIM]
protectedinherited

The coordinates of the TypeVector.

Definition at line 415 of file type_vector.h.

Referenced by libMesh::TypeTensor< T >::column(), and libMesh::TypeTensor< T >::row().


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