libMesh
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_error_estimator.h>

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

Public Types

typedef T value_type
 Helper typedef for C++98 generic 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=libmesh_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
 
Real size () const
 
Real norm () const
 
Real size_sq () const
 
Real norm_sq () 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, 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 48 of file exact_error_estimator.h.

Member Typedef Documentation

template<typename T>
typedef T libMesh::TypeVector< T >::value_type
inherited

Helper typedef for C++98 generic programming.

Definition at line 107 of file type_vector.h.

Constructor & Destructor Documentation

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

Empty constructor.

Gives the vector 0 in LIBMESH_DIM dimensional T space.

Definition at line 139 of file vector_value.h.

139  :
140  TypeVector<T> ()
141 {
142 }
template<typename T>
libMesh::VectorValue< T >::VectorValue ( const T  x,
const T  y = 0,
const T  z = 0 
)

Constructor-from-T.

By default sets higher dimensional entries to 0.

Definition at line 147 of file vector_value.h.

149  :
150  TypeVector<T> (x,y,z)
151 {
152 }
PetscErrorCode Vec x
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 
)

Constructor-from-scalars.

By default sets higher dimensional entries to 0.

Definition at line 159 of file vector_value.h.

167  :
168  TypeVector<T> (x,y,z)
169 {
170 }
PetscErrorCode Vec x
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 = libmesh_nullptr 
)

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 176 of file vector_value.h.

179  :
180  TypeVector<T> (x)
181 {
182 }
PetscErrorCode Vec x
template<typename T >
template<typename T2 >
libMesh::VectorValue< T >::VectorValue ( const VectorValue< T2 > &  p)

Copy-constructor.

Definition at line 187 of file vector_value.h.

187  :
188  TypeVector<T> (p)
189 {
190 }
template<typename T >
template<typename T2 >
libMesh::VectorValue< T >::VectorValue ( const TypeVector< T2 > &  p)

Copy-constructor.

Definition at line 197 of file vector_value.h.

197  :
198  TypeVector<T> (p)
199 {
200 }
template<typename T>
libMesh::VectorValue< T >::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.

Definition at line 205 of file vector_value.h.

206  :
207  TypeVector<T> (Complex (p_re(0), p_im(0)),
208  Complex (p_re(1), p_im(1)),
209  Complex (p_re(2), p_im(2)))
210 {
211 }
std::complex< Real > Complex

Member Function Documentation

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

Definition at line 962 of file type_vector.h.

References libMesh::TypeVector< T >::_coords, and std::abs().

Referenced by libMesh::FEGenericBase< OutputType >::compute_periodic_constraints(), libMesh::LocationMap< T >::find(), libMesh::Elem::parent_bracketing_nodes(), libMesh::TypeVector< T >::relative_fuzzy_equals(), libMesh::TypeVector< Real >::slice(), libMesh::ReplicatedMesh::stitching_helper(), libMesh::BoundaryVolumeSolutionTransfer::transfer_boundary_volume(), and libMesh::BoundaryVolumeSolutionTransfer::transfer_volume_boundary().

963 {
964 #if LIBMESH_DIM == 1
965  return (std::abs(_coords[0] - rhs._coords[0])
966  <= tol);
967 #endif
968 
969 #if LIBMESH_DIM == 2
970  return (std::abs(_coords[0] - rhs._coords[0]) +
971  std::abs(_coords[1] - rhs._coords[1])
972  <= tol);
973 #endif
974 
975 #if LIBMESH_DIM == 3
976  return (std::abs(_coords[0] - rhs._coords[0]) +
977  std::abs(_coords[1] - rhs._coords[1]) +
978  std::abs(_coords[2] - rhs._coords[2])
979  <= tol);
980 #endif
981 }
T _coords[LIBMESH_DIM]
The coordinates of the TypeVector.
Definition: type_vector.h:406
double abs(double a)
template<typename T >
template<typename T2 >
void libMesh::TypeVector< T >::add ( const TypeVector< T2 > &  p)
inherited

Add to this vector without creating a temporary.

Definition at line 600 of file type_vector.h.

References libMesh::TypeVector< T >::_coords.

Referenced by libMesh::Elem::centroid(), libMesh::FE< Dim, T >::inverse_map(), libMesh::InfFE< Dim, T_radial, T_map >::inverse_map(), libMesh::TypeVector< T >::operator+=(), libMesh::TypeVector< Real >::slice(), libMesh::LaplaceMeshSmoother::smooth(), and libMesh::MeshTools::Modification::smooth().

601 {
602 #if LIBMESH_DIM == 1
603  _coords[0] += p._coords[0];
604 #endif
605 
606 #if LIBMESH_DIM == 2
607  _coords[0] += p._coords[0];
608  _coords[1] += p._coords[1];
609 #endif
610 
611 #if LIBMESH_DIM == 3
612  _coords[0] += p._coords[0];
613  _coords[1] += p._coords[1];
614  _coords[2] += p._coords[2];
615 #endif
616 
617 }
T _coords[LIBMESH_DIM]
The coordinates of the TypeVector.
Definition: type_vector.h:406
template<typename T>
template<typename T2 >
void libMesh::TypeVector< T >::add_scaled ( const TypeVector< T2 > &  p,
const T  factor 
)
inherited

Add a scaled value to this vector without creating a temporary.

Definition at line 624 of file type_vector.h.

References libMesh::TypeVector< T >::_coords.

Referenced by libMesh::MeshRefinement::add_node(), libMesh::HPCoarsenTest::add_projection(), assemble_cd(), assemble_stokes(), libMesh::System::calculate_norm(), libMesh::Elem::coarsen(), compute_stresses(), libMesh::MeshFunction::discontinuous_gradient(), SolidSystem::element_time_derivative(), libMesh::MeshFunction::gradient(), libMesh::InfFE< Dim, T_radial, T_map >::inverse_map(), libMesh::InfFE< Dim, T_radial, T_map >::map(), libMesh::FE< Dim, T >::map(), libMesh::FE< Dim, T >::map_eta(), libMesh::FE< Dim, T >::map_xi(), libMesh::FE< Dim, T >::map_zeta(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::Elem::parent_bracketing_nodes(), libMesh::System::point_gradient(), libMesh::HPCoarsenTest::select_refinement(), libMesh::TypeVector< Real >::slice(), libMesh::MeshTools::Modification::smooth(), and TypeVectorTestBase< VectorValue< Number > >::testVectorAddScaledBase().

625 {
626 #if LIBMESH_DIM == 1
627  _coords[0] += factor*p(0);
628 #endif
629 
630 #if LIBMESH_DIM == 2
631  _coords[0] += factor*p(0);
632  _coords[1] += factor*p(1);
633 #endif
634 
635 #if LIBMESH_DIM == 3
636  _coords[0] += factor*p(0);
637  _coords[1] += factor*p(1);
638  _coords[2] += factor*p(2);
639 #endif
640 
641 }
T _coords[LIBMESH_DIM]
The coordinates of the TypeVector.
Definition: type_vector.h:406
template<typename T >
template<typename T2 >
void libMesh::TypeVector< T >::assign ( const TypeVector< T2 > &  p)
inherited

Assign to this vector without creating a temporary.

Definition at line 529 of file type_vector.h.

References libMesh::TypeVector< T >::_coords.

530 {
531  for (unsigned int i=0; i<LIBMESH_DIM; i++)
532  _coords[i] = p._coords[i];
533 }
T _coords[LIBMESH_DIM]
The coordinates of the TypeVector.
Definition: type_vector.h:406
template<typename T >
template<typename T2 >
CompareTypes< T, T2 >::supertype libMesh::TypeVector< T >::contract ( const TypeVector< T2 > &  p) const
inherited
Returns
The result of TypeVector::operator*().

Definition at line 869 of file type_vector.h.

Referenced by libMesh::TypeVector< Real >::slice().

870 {
871  return (*this)*(p);
872 }
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 879 of file type_vector.h.

References libMesh::TypeVector< T >::_coords.

Referenced by assemble_shell(), libMesh::FEXYZMap::compute_face_map(), libMesh::FEMap::compute_face_map(), ContainsPointTest::containsPointTri3Helper(), libMesh::Plane::create_from_three_points(), libMesh::TypeVector< Real >::slice(), and libMesh::Quad4::volume().

880 {
881  typedef typename CompareTypes<T, T2>::supertype TS;
882  libmesh_assert_equal_to (LIBMESH_DIM, 3);
883 
884  // | i j k |
885  // |(*this)(0) (*this)(1) (*this)(2)|
886  // | p(0) p(1) p(2) |
887 
888  return TypeVector<TS>( _coords[1]*p._coords[2] - _coords[2]*p._coords[1],
889  -_coords[0]*p._coords[2] + _coords[2]*p._coords[0],
890  _coords[0]*p._coords[1] - _coords[1]*p._coords[0]);
891 }
T _coords[LIBMESH_DIM]
The coordinates of the TypeVector.
Definition: type_vector.h:406
template<typename T >
Real libMesh::TypeVector< T >::norm ( ) const
inherited
template<typename T >
Real libMesh::TypeVector< T >::norm_sq ( ) const
inherited
template<typename T>
bool libMesh::TypeVector< T >::operator!= ( const TypeVector< T > &  rhs) const
inherited
Returns
!(*this == rhs)

Definition at line 1034 of file type_vector.h.

Referenced by libMesh::TypeVector< Real >::slice().

1035 {
1036  return (!(*this == rhs));
1037 }
template<typename T >
const T & libMesh::TypeVector< T >::operator() ( const unsigned int  i) const
inherited
Returns
A const reference to the $ i^{th} $ entry of the vector.

Definition at line 539 of file type_vector.h.

References libMesh::TypeVector< T >::_coords.

Referenced by libMesh::TypeVector< Real >::operator=(), and libMesh::TypeVector< Real >::slice().

540 {
541  libmesh_assert_less (i, LIBMESH_DIM);
542 
543  return _coords[i];
544 }
T _coords[LIBMESH_DIM]
The coordinates of the TypeVector.
Definition: type_vector.h:406
template<typename T >
T & libMesh::TypeVector< T >::operator() ( const unsigned int  i)
inherited
Returns
A writable reference to the $ i^{th} $ entry of the vector.

Definition at line 550 of file type_vector.h.

References libMesh::TypeVector< T >::_coords.

551 {
552  libmesh_assert_less (i, LIBMESH_DIM);
553 
554  return _coords[i];
555 }
T _coords[LIBMESH_DIM]
The coordinates of the TypeVector.
Definition: type_vector.h:406
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
inherited

Multiply this vector by a scalar value.

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

Definition at line 736 of file type_vector.h.

References libMesh::TypeVector< T >::_coords.

Referenced by libMesh::TypeVector< Real >::slice().

737 {
738  typedef typename CompareTypes<T, Scalar>::supertype SuperType;
739 
740 #if LIBMESH_DIM == 1
741  return TypeVector<SuperType>(_coords[0]*factor);
742 #endif
743 
744 #if LIBMESH_DIM == 2
745  return TypeVector<SuperType>(_coords[0]*factor,
746  _coords[1]*factor);
747 #endif
748 
749 #if LIBMESH_DIM == 3
750  return TypeVector<SuperType>(_coords[0]*factor,
751  _coords[1]*factor,
752  _coords[2]*factor);
753 #endif
754 }
T _coords[LIBMESH_DIM]
The coordinates of the TypeVector.
Definition: type_vector.h:406
template<typename T >
template<typename T2 >
CompareTypes< T, T2 >::supertype libMesh::TypeVector< T >::operator* ( const TypeVector< T2 > &  p) const
inherited
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 847 of file type_vector.h.

References libMesh::TypeVector< T >::_coords.

848 {
849 #if LIBMESH_DIM == 1
850  return _coords[0]*p._coords[0];
851 #endif
852 
853 #if LIBMESH_DIM == 2
854  return (_coords[0]*p._coords[0] +
855  _coords[1]*p._coords[1]);
856 #endif
857 
858 #if LIBMESH_DIM == 3
859  return (_coords[0]*p(0) +
860  _coords[1]*p(1) +
861  _coords[2]*p(2));
862 #endif
863 }
T _coords[LIBMESH_DIM]
The coordinates of the TypeVector.
Definition: type_vector.h:406
template<typename T>
const TypeVector< T > & libMesh::TypeVector< T >::operator*= ( const T  factor)
inherited

Multiply this vector by a scalar value.

Returns
A reference to *this.

Definition at line 773 of file type_vector.h.

References libMesh::TypeVector< T >::_coords.

Referenced by libMesh::TypeVector< Real >::slice().

774 {
775 #if LIBMESH_DIM == 1
776  _coords[0] *= factor;
777 #endif
778 
779 #if LIBMESH_DIM == 2
780  _coords[0] *= factor;
781  _coords[1] *= factor;
782 #endif
783 
784 #if LIBMESH_DIM == 3
785  _coords[0] *= factor;
786  _coords[1] *= factor;
787  _coords[2] *= factor;
788 #endif
789 
790  return *this;
791 }
T _coords[LIBMESH_DIM]
The coordinates of the TypeVector.
Definition: type_vector.h:406
template<typename T >
template<typename T2 >
TypeVector< typename CompareTypes< T, T2 >::supertype > libMesh::TypeVector< T >::operator+ ( const TypeVector< T2 > &  p) const
inherited

Add two vectors.

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

Definition at line 563 of file type_vector.h.

References libMesh::TypeVector< T >::_coords.

Referenced by libMesh::TypeVector< Real >::slice().

564 {
565  typedef typename CompareTypes<T, T2>::supertype TS;
566 #if LIBMESH_DIM == 1
567  return TypeVector<TS> (_coords[0] + p._coords[0]);
568 #endif
569 
570 #if LIBMESH_DIM == 2
571  return TypeVector<TS> (_coords[0] + p._coords[0],
572  _coords[1] + p._coords[1]);
573 #endif
574 
575 #if LIBMESH_DIM == 3
576  return TypeVector<TS> (_coords[0] + p._coords[0],
577  _coords[1] + p._coords[1],
578  _coords[2] + p._coords[2]);
579 #endif
580 
581 }
T _coords[LIBMESH_DIM]
The coordinates of the TypeVector.
Definition: type_vector.h:406
template<typename T >
template<typename T2 >
const TypeVector< T > & libMesh::TypeVector< T >::operator+= ( const TypeVector< T2 > &  p)
inherited

Add to this vector.

Returns
A reference to *this.

Definition at line 588 of file type_vector.h.

References libMesh::TypeVector< T >::add().

Referenced by libMesh::TypeVector< Real >::slice().

589 {
590  this->add (p);
591 
592  return *this;
593 }
void add(const TypeVector< T2 > &)
Add to this vector without creating a temporary.
Definition: type_vector.h:600
template<typename T >
template<typename T2 >
TypeVector< typename CompareTypes< T, T2 >::supertype > libMesh::TypeVector< T >::operator- ( const TypeVector< T2 > &  p) const
inherited

Subtract from this vector.

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

Definition at line 649 of file type_vector.h.

References libMesh::TypeVector< T >::_coords.

650 {
651  typedef typename CompareTypes<T, T2>::supertype TS;
652 
653 #if LIBMESH_DIM == 1
654  return TypeVector<TS>(_coords[0] - p._coords[0]);
655 #endif
656 
657 #if LIBMESH_DIM == 2
658  return TypeVector<TS>(_coords[0] - p._coords[0],
659  _coords[1] - p._coords[1]);
660 #endif
661 
662 #if LIBMESH_DIM == 3
663  return TypeVector<TS>(_coords[0] - p._coords[0],
664  _coords[1] - p._coords[1],
665  _coords[2] - p._coords[2]);
666 #endif
667 
668 }
T _coords[LIBMESH_DIM]
The coordinates of the TypeVector.
Definition: type_vector.h:406
template<typename T >
TypeVector< T > libMesh::TypeVector< T >::operator- ( ) const
inherited
Returns
The negative of this vector in a separate copy.

Definition at line 708 of file type_vector.h.

References libMesh::TypeVector< T >::_coords, and libMesh::TypeVector< T >::TypeVector().

Referenced by libMesh::TypeVector< Real >::slice().

709 {
710 
711 #if LIBMESH_DIM == 1
712  return TypeVector(-_coords[0]);
713 #endif
714 
715 #if LIBMESH_DIM == 2
716  return TypeVector(-_coords[0],
717  -_coords[1]);
718 #endif
719 
720 #if LIBMESH_DIM == 3
721  return TypeVector(-_coords[0],
722  -_coords[1],
723  -_coords[2]);
724 #endif
725 
726 }
T _coords[LIBMESH_DIM]
The coordinates of the TypeVector.
Definition: type_vector.h:406
TypeVector()
Empty constructor.
Definition: type_vector.h:418
template<typename T >
template<typename T2 >
const TypeVector< T > & libMesh::TypeVector< T >::operator-= ( const TypeVector< T2 > &  p)
inherited

Subtract from this vector.

Returns
A reference to *this.

Definition at line 675 of file type_vector.h.

References libMesh::TypeVector< T >::subtract().

Referenced by libMesh::TypeVector< Real >::slice().

676 {
677  this->subtract (p);
678 
679  return *this;
680 }
void subtract(const TypeVector< T2 > &)
Subtract from this vector without creating a temporary.
Definition: type_vector.h:687
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
inherited

Divide each entry of this vector by scalar value.

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

Definition at line 801 of file type_vector.h.

References libMesh::TypeVector< T >::_coords.

Referenced by libMesh::TypeVector< Real >::slice().

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

Divide each entry of this vector by scalar value.

Returns
A reference to *this.

Definition at line 830 of file type_vector.h.

References libMesh::TypeVector< T >::_coords.

Referenced by libMesh::TypeVector< Real >::slice().

831 {
832  libmesh_assert_not_equal_to (factor, static_cast<T>(0.));
833 
834  for (unsigned int i=0; i<LIBMESH_DIM; i++)
835  _coords[i] /= factor;
836 
837  return *this;
838 }
T _coords[LIBMESH_DIM]
The coordinates of the TypeVector.
Definition: type_vector.h:406
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 false;
181 }
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 109 of file type_vector.C.

110 {
111  for (unsigned int i=0; i<LIBMESH_DIM; i++)
112  {
113  if ((*this)(i) < rhs(i))
114  return true;
115  if ((*this)(i) > rhs(i))
116  return false;
117  }
118  return false;
119 }
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 true;
200 }
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 123 of file type_vector.C.

124 {
125  for (unsigned int i=0; i<LIBMESH_DIM; i++)
126  {
127  if ((*this)(i) < rhs(i))
128  return true;
129  if ((*this)(i) > rhs(i))
130  return false;
131  }
132  return true;
133 }
template<typename T>
template<typename Scalar >
boostcopy::enable_if_c< ScalarTraits<Scalar>::value, VectorValue &>::type libMesh::VectorValue< T >::operator= ( const Scalar &  libmesh_dbg_varp)

Assignment-from-scalar operator.

Used only to zero out vectors.

Definition at line 117 of file vector_value.h.

118  { 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:918
template<typename T>
bool libMesh::TypeVector< T >::operator== ( const TypeVector< T > &  rhs) const
inherited
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 1012 of file type_vector.h.

References libMesh::TypeVector< T >::_coords.

Referenced by libMesh::TypeVector< Real >::slice().

1013 {
1014 #if LIBMESH_DIM == 1
1015  return (_coords[0] == rhs._coords[0]);
1016 #endif
1017 
1018 #if LIBMESH_DIM == 2
1019  return (_coords[0] == rhs._coords[0] &&
1020  _coords[1] == rhs._coords[1]);
1021 #endif
1022 
1023 #if LIBMESH_DIM == 3
1024  return (_coords[0] == rhs._coords[0] &&
1025  _coords[1] == rhs._coords[1] &&
1026  _coords[2] == rhs._coords[2]);
1027 #endif
1028 }
T _coords[LIBMESH_DIM]
The coordinates of the TypeVector.
Definition: type_vector.h:406
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 false;
219 }
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 138 of file type_vector.C.

Referenced by libMesh::TypeVector< Real >::slice().

139 {
140  for (unsigned int i=0; i<LIBMESH_DIM; i++)
141  {
142  if ((*this)(i) > rhs(i))
143  return true;
144  if ((*this)(i) < rhs(i))
145  return false;
146  }
147  return false;
148 }
template<>
bool libMesh::TypeVector< Complex >::operator>= ( const TypeVector< Complex > &  rhs) const
inherited

Definition at line 224 of file type_vector.C.

225 {
226  for (unsigned int i=0; i<LIBMESH_DIM; i++)
227  {
228  if ((*this)(i).real() > rhs(i).real())
229  return true;
230  if ((*this)(i).real() < rhs(i).real())
231  return false;
232  if ((*this)(i).imag() > rhs(i).imag())
233  return true;
234  if ((*this)(i).imag() < rhs(i).imag())
235  return false;
236  }
237  return true;
238 }
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 152 of file type_vector.C.

Referenced by libMesh::TypeVector< Real >::slice().

153 {
154  for (unsigned int i=0; i<LIBMESH_DIM; i++)
155  {
156  if ((*this)(i) > rhs(i))
157  return true;
158  if ((*this)(i) < rhs(i))
159  return false;
160  }
161  return true;
162 }
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 64 of file type_vector.C.

Referenced by libMesh::TypeVector< Real >::slice().

65 {
66 #if LIBMESH_DIM == 1
67 
68  os << "x=" << (*this)(0);
69 
70 #endif
71 #if LIBMESH_DIM == 2
72 
73  os << "(x,y)=("
74  << std::setw(8) << (*this)(0) << ", "
75  << std::setw(8) << (*this)(1) << ")";
76 
77 #endif
78 #if LIBMESH_DIM == 3
79 
80  os << "(x,y,z)=("
81  << std::setw(8) << (*this)(0) << ", "
82  << std::setw(8) << (*this)(1) << ", "
83  << std::setw(8) << (*this)(2) << ")";
84 #endif
85 }
template<typename T>
bool libMesh::TypeVector< T >::relative_fuzzy_equals ( const TypeVector< T > &  rhs,
Real  tol = TOLERANCE 
) const
inherited
Returns
true if two vectors are equal to within a relative tolerance of tol.

Definition at line 987 of file type_vector.h.

References libMesh::TypeVector< T >::_coords, std::abs(), and libMesh::TypeVector< T >::absolute_fuzzy_equals().

Referenced by libMesh::Quad4::has_affine_map(), libMesh::Quad8::has_affine_map(), libMesh::Quad9::has_affine_map(), libMesh::TypeVector< Real >::slice(), libMesh::Quad4::volume(), and libMesh::Tri6::volume().

988 {
989 #if LIBMESH_DIM == 1
990  return this->absolute_fuzzy_equals(rhs, tol *
991  (std::abs(_coords[0]) + std::abs(rhs._coords[0])));
992 #endif
993 
994 #if LIBMESH_DIM == 2
995  return this->absolute_fuzzy_equals(rhs, tol *
996  (std::abs(_coords[0]) + std::abs(rhs._coords[0]) +
997  std::abs(_coords[1]) + std::abs(rhs._coords[1])));
998 #endif
999 
1000 #if LIBMESH_DIM == 3
1001  return this->absolute_fuzzy_equals(rhs, tol *
1002  (std::abs(_coords[0]) + std::abs(rhs._coords[0]) +
1003  std::abs(_coords[1]) + std::abs(rhs._coords[1]) +
1004  std::abs(_coords[2]) + std::abs(rhs._coords[2])));
1005 #endif
1006 }
T _coords[LIBMESH_DIM]
The coordinates of the TypeVector.
Definition: type_vector.h:406
double abs(double a)
bool absolute_fuzzy_equals(const TypeVector< T > &rhs, Real tol=TOLERANCE) const
Definition: type_vector.h:962
template<typename T >
Real libMesh::TypeVector< T >::size ( ) const
inherited
template<typename T >
Real libMesh::TypeVector< T >::size_sq ( ) const
inherited
Returns
The magnitude of the vector squared, i.e. the sum of the element magnitudes squared.
Deprecated:
Use the norm_sq() function instead.

Definition at line 929 of file type_vector.h.

References libMesh::TypeVector< T >::norm_sq().

Referenced by libMesh::TypeVector< Real >::slice().

930 {
931  libmesh_deprecated();
932  return this->norm_sq();
933 }
Real norm_sq() const
Definition: type_vector.h:940
template<typename T>
const T& libMesh::TypeVector< T >::slice ( const unsigned int  i) const
inherited

Definition at line 140 of file type_vector.h.

140 { return (*this)(i); }
template<typename T>
T& libMesh::TypeVector< T >::slice ( const unsigned int  i)
inherited

Definition at line 146 of file type_vector.h.

146 { return (*this)(i); }
template<typename T >
template<typename T2 >
void libMesh::TypeVector< T >::subtract ( const TypeVector< T2 > &  p)
inherited

Subtract from this vector without creating a temporary.

Definition at line 687 of file type_vector.h.

References libMesh::TypeVector< T >::_coords.

Referenced by libMesh::TypeVector< T >::operator-=(), and libMesh::TypeVector< Real >::slice().

688 {
689  for (unsigned int i=0; i<LIBMESH_DIM; i++)
690  _coords[i] -= p._coords[i];
691 }
T _coords[LIBMESH_DIM]
The coordinates of the TypeVector.
Definition: type_vector.h:406
template<typename T>
template<typename T2 >
void libMesh::TypeVector< T >::subtract_scaled ( const TypeVector< T2 > &  p,
const T  factor 
)
inherited

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

Definition at line 698 of file type_vector.h.

References libMesh::TypeVector< T >::_coords.

Referenced by libMesh::HPCoarsenTest::select_refinement(), and libMesh::TypeVector< Real >::slice().

699 {
700  for (unsigned int i=0; i<LIBMESH_DIM; i++)
701  _coords[i] -= factor*p(i);
702 }
T _coords[LIBMESH_DIM]
The coordinates of the TypeVector.
Definition: type_vector.h:406
template<typename T >
TypeVector< T > libMesh::TypeVector< T >::unit ( ) const
inherited
Returns
A unit vector in the direction of *this.

Definition at line 37 of file type_vector.C.

References libMesh::Real.

Referenced by libMesh::FEXYZMap::compute_face_map(), libMesh::FEMap::compute_face_map(), ContainsPointTest::containsPointTri3Helper(), libMesh::Plane::create_from_point_normal(), libMesh::Plane::create_from_three_points(), libMesh::MeshTools::Modification::distort(), libMesh::TypeVector< Real >::slice(), and libMesh::Sphere::unit_normal().

38 {
39 
40  const Real length = norm();
41 
42  libmesh_assert_not_equal_to (length, static_cast<Real>(0.));
43 
44 #if LIBMESH_DIM == 1
45  return TypeVector<T>(_coords[0]/length);
46 #endif
47 
48 #if LIBMESH_DIM == 2
49  return TypeVector<T>(_coords[0]/length,
50  _coords[1]/length);
51 #endif
52 
53 #if LIBMESH_DIM == 3
54  return TypeVector<T>(_coords[0]/length,
55  _coords[1]/length,
56  _coords[2]/length);
57 #endif
58 
59 }
T _coords[LIBMESH_DIM]
The coordinates of the TypeVector.
Definition: type_vector.h:406
Real norm() const
Definition: type_vector.h:909
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
template<typename T >
void libMesh::TypeVector< T >::write_unformatted ( std::ostream &  out,
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 92 of file type_vector.C.

References libMesh::libmesh_assert().

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

94 {
95  libmesh_assert (os);
96 
97  os << std::setiosflags(std::ios::showpoint)
98  << (*this)(0) << " "
99  << (*this)(1) << " "
100  << (*this)(2) << " ";
101 
102  if (newline)
103  os << '\n';
104 }
libmesh_assert(j)
template<typename T >
void libMesh::TypeVector< T >::zero ( )
inherited

Set all entries of the vector to 0.

Definition at line 918 of file type_vector.h.

References libMesh::TypeVector< T >::_coords.

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

919 {
920  for (unsigned int i=0; i<LIBMESH_DIM; i++)
921  _coords[i] = 0.;
922 }
T _coords[LIBMESH_DIM]
The coordinates of the TypeVector.
Definition: type_vector.h:406

Member Data Documentation

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

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