libMesh::TypeVector< T > Class Template Reference

#include <tensor_tools.h>

Inheritance diagram for libMesh::TypeVector< T >:

Public Types

typedef T value_type
 

Public Member Functions

template<typename T2 >
 TypeVector (const TypeVector< T2 > &p)
 
 ~TypeVector ()
 
template<typename T2 >
void assign (const TypeVector< T2 > &)
 
template<typename Scalar >
boostcopy::enable_if_c< ScalarTraits< Scalar >::value, TypeVector & >::type operator= (const Scalar &libmesh_dbg_var(p))
 
const T & operator() (const unsigned int i) const
 
const T & slice (const unsigned int i) const
 
T & operator() (const unsigned int i)
 
T & slice (const unsigned int i)
 
template<typename T2 >
TypeVector< typename CompareTypes< T, T2 >::supertype > operator+ (const TypeVector< T2 > &) const
 
template<typename T2 >
const TypeVector< T > & operator+= (const TypeVector< T2 > &)
 
template<typename T2 >
void add (const TypeVector< T2 > &)
 
template<typename T2 >
void add_scaled (const TypeVector< T2 > &, const T)
 
template<typename T2 >
TypeVector< typename CompareTypes< T, T2 >::supertype > operator- (const TypeVector< T2 > &) const
 
template<typename T2 >
const TypeVector< T > & operator-= (const TypeVector< T2 > &)
 
template<typename T2 >
void subtract (const TypeVector< T2 > &)
 
template<typename T2 >
void subtract_scaled (const TypeVector< T2 > &, const T)
 
TypeVector< T > operator- () const
 
template<typename Scalar >
boostcopy::enable_if_c< ScalarTraits< Scalar >::value, TypeVector< typename CompareTypes< T, Scalar >::supertype > >::type operator* (const Scalar) const
 
const TypeVector< T > & operator*= (const T)
 
template<typename Scalar >
boostcopy::enable_if_c< ScalarTraits< Scalar >::value, TypeVector< typename CompareTypes< T, Scalar >::supertype > >::type operator/ (const Scalar) const
 
const TypeVector< T > & operator/= (const T)
 
template<typename T2 >
CompareTypes< T, T2 >::supertype operator* (const TypeVector< T2 > &) const
 
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 ()
 
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
 
bool operator<= (const TypeVector< T > &rhs) const
 
bool operator> (const TypeVector< T > &rhs) const
 
bool operator>= (const TypeVector< T > &rhs) const
 
void print (std::ostream &os=libMesh::out) const
 
void write_unformatted (std::ostream &out, const bool newline=true) const
 
template<>
bool operator< (const TypeVector< Complex > &rhs) const
 
template<>
bool operator<= (const TypeVector< Complex > &rhs) const
 
template<>
bool operator> (const TypeVector< Complex > &rhs) const
 
template<>
bool operator>= (const TypeVector< Complex > &rhs) const
 

Protected Member Functions

 TypeVector ()
 
 TypeVector (const T x, const T y=0, const T z=0)
 
template<typename Scalar1 , typename Scalar2 , typename Scalar3 >
 TypeVector (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)
 
template<typename Scalar >
 TypeVector (const Scalar x, typename boostcopy::enable_if_c< ScalarTraits< Scalar >::value, const Scalar >::type *sfinae=libmesh_nullptr)
 

Protected Attributes

_coords [LIBMESH_DIM]
 

Friends

template<typename T2 >
class TypeVector
 
class TypeTensor< T >
 
std::ostream & operator<< (std::ostream &os, const TypeVector< T > &t)
 

Detailed Description

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

This class defines a vector in LIBMESH_DIM dimensional space of type T. T may either be Real or Complex. The default constructor for this class is protected, suggesting that you should not instantiate one of these directly. Instead use one of the derived types such as Point or Node.

Author
Benjamin S. Kirk
Date
2003

Definition at line 30 of file tensor_tools.h.

Member Typedef Documentation

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

Helper typedef for C++98 generic programming

Definition at line 107 of file type_vector.h.

Constructor & Destructor Documentation

template<typename T >
libMesh::TypeVector< T >::TypeVector ( )
inlineprotected

Empty constructor. Gives the vector 0 in LIBMESH_DIM dimensions.

Definition at line 414 of file type_vector.h.

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

Referenced by libMesh::TypeVector< T >::operator-().

415 {
416  _coords[0] = 0;
417 
418 #if LIBMESH_DIM > 1
419  _coords[1] = 0;
420 #endif
421 
422 #if LIBMESH_DIM > 2
423  _coords[2] = 0;
424 #endif
425 }
T _coords[LIBMESH_DIM]
Definition: type_vector.h:402
template<typename T>
libMesh::TypeVector< T >::TypeVector ( const T  x,
const T  y = 0,
const T  z = 0 
)
inlineprotected

Constructor-from-T. By default sets higher dimensional entries to 0.

Definition at line 431 of file type_vector.h.

References libMesh::TypeVector< T >::_coords, and libMesh::x.

434 {
435  _coords[0] = x;
436 
437 #if LIBMESH_DIM > 1
438  _coords[1] = y;
439 #else
440  libmesh_assert_equal_to (y, 0);
441 #endif
442 
443 #if LIBMESH_DIM > 2
444  _coords[2] = z;
445 #else
446  libmesh_assert_equal_to (z, 0);
447 #endif
448 }
T _coords[LIBMESH_DIM]
Definition: type_vector.h:402
PetscErrorCode Vec x
template<typename T >
template<typename Scalar1 , typename Scalar2 , typename Scalar3 >
libMesh::TypeVector< T >::TypeVector ( 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 
)
inlineprotected

Constructor-from-scalars. By default sets higher dimensional entries to 0.

Definition at line 454 of file type_vector.h.

References libMesh::TypeVector< T >::_coords, and libMesh::x.

463 {
464  _coords[0] = x;
465 
466 #if LIBMESH_DIM > 1
467  _coords[1] = y;
468 #else
469  libmesh_assert_equal_to (y, 0);
470 #endif
471 
472 #if LIBMESH_DIM > 2
473  _coords[2] = z;
474 #else
475  libmesh_assert_equal_to (z, 0);
476 #endif
477 }
T _coords[LIBMESH_DIM]
Definition: type_vector.h:402
PetscErrorCode Vec x
template<typename T >
template<typename Scalar >
libMesh::TypeVector< T >::TypeVector ( const Scalar  x,
typename boostcopy::enable_if_c< ScalarTraits< Scalar >::value, const Scalar >::type *  sfinae = libmesh_nullptr 
)
inlineprotected

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 TypeVector<Complex> v = 0;

Definition at line 484 of file type_vector.h.

References libMesh::TypeVector< T >::_coords, and libMesh::x.

488 {
489  _coords[0] = x;
490 
491 #if LIBMESH_DIM > 1
492  _coords[1] = 0;
493 #endif
494 
495 #if LIBMESH_DIM > 2
496  _coords[2] = 0;
497 #endif
498 }
T _coords[LIBMESH_DIM]
Definition: type_vector.h:402
PetscErrorCode Vec x
template<typename T >
template<typename T2 >
libMesh::TypeVector< T >::TypeVector ( const TypeVector< T2 > &  p)
inline

Copy-constructor.

Definition at line 505 of file type_vector.h.

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

506 {
507  // copy the nodes from vector p to me
508  for (unsigned int i=0; i<LIBMESH_DIM; i++)
509  _coords[i] = p._coords[i];
510 }
T _coords[LIBMESH_DIM]
Definition: type_vector.h:402
template<typename T >
libMesh::TypeVector< T >::~TypeVector ( )
inline

Destructor.

Definition at line 516 of file type_vector.h.

517 {
518 }

Member Function Documentation

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

Definition at line 954 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::UnstructuredMesh::find_neighbors(), libMesh::Elem::parent_bracketing_nodes(), libMesh::TypeVector< T >::relative_fuzzy_equals(), libMesh::TypeVector< Real >::slice(), and libMesh::ReplicatedMesh::stitching_helper().

955 {
956 #if LIBMESH_DIM == 1
957  return (std::abs(_coords[0] - rhs._coords[0])
958  <= tol);
959 #endif
960 
961 #if LIBMESH_DIM == 2
962  return (std::abs(_coords[0] - rhs._coords[0]) +
963  std::abs(_coords[1] - rhs._coords[1])
964  <= tol);
965 #endif
966 
967 #if LIBMESH_DIM == 3
968  return (std::abs(_coords[0] - rhs._coords[0]) +
969  std::abs(_coords[1] - rhs._coords[1]) +
970  std::abs(_coords[2] - rhs._coords[2])
971  <= tol);
972 #endif
973 }
T _coords[LIBMESH_DIM]
Definition: type_vector.h:402
double abs(double a)
template<typename T >
template<typename T2 >
void libMesh::TypeVector< T >::add ( const TypeVector< T2 > &  p)
inline

Add to this vector without creating a temporary.

Definition at line 596 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().

597 {
598 #if LIBMESH_DIM == 1
599  _coords[0] += p._coords[0];
600 #endif
601 
602 #if LIBMESH_DIM == 2
603  _coords[0] += p._coords[0];
604  _coords[1] += p._coords[1];
605 #endif
606 
607 #if LIBMESH_DIM == 3
608  _coords[0] += p._coords[0];
609  _coords[1] += p._coords[1];
610  _coords[2] += p._coords[2];
611 #endif
612 
613 }
T _coords[LIBMESH_DIM]
Definition: type_vector.h:402
template<typename T>
template<typename T2 >
void libMesh::TypeVector< T >::add_scaled ( const TypeVector< T2 > &  p,
const T  factor 
)
inline
template<typename T >
template<typename T2 >
void libMesh::TypeVector< T >::assign ( const TypeVector< T2 > &  p)
inline

Assign to this vector without creating a temporary.

Definition at line 525 of file type_vector.h.

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

526 {
527  for (unsigned int i=0; i<LIBMESH_DIM; i++)
528  _coords[i] = p._coords[i];
529 }
T _coords[LIBMESH_DIM]
Definition: type_vector.h:402
template<typename T >
template<typename T2 >
CompareTypes< T, T2 >::supertype libMesh::TypeVector< T >::contract ( const TypeVector< T2 > &  p) const
inline
Returns
The result of TypeVector::operator*().

Definition at line 865 of file type_vector.h.

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

866 {
867  return (*this)*(p);
868 }
template<typename T >
template<typename T2 >
TypeVector< typename CompareTypes< T, T2 >::supertype > libMesh::TypeVector< T >::cross ( const TypeVector< T2 > &  v) const
Returns
The cross product of this vector with v.

Definition at line 875 of file type_vector.h.

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

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

876 {
877  typedef typename CompareTypes<T, T2>::supertype TS;
878  libmesh_assert_equal_to (LIBMESH_DIM, 3);
879 
880  // | i j k |
881  // |(*this)(0) (*this)(1) (*this)(2)|
882  // | p(0) p(1) p(2) |
883 
884  return TypeVector<TS>( _coords[1]*p._coords[2] - _coords[2]*p._coords[1],
885  -_coords[0]*p._coords[2] + _coords[2]*p._coords[0],
886  _coords[0]*p._coords[1] - _coords[1]*p._coords[0]);
887 }
T _coords[LIBMESH_DIM]
Definition: type_vector.h:402
template<typename T>
bool libMesh::TypeVector< T >::operator!= ( const TypeVector< T > &  rhs) const
inline
Returns
!(*this == rhs)

Definition at line 1026 of file type_vector.h.

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

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

Definition at line 535 of file type_vector.h.

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

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

536 {
537  libmesh_assert_less (i, LIBMESH_DIM);
538 
539  return _coords[i];
540 }
T _coords[LIBMESH_DIM]
Definition: type_vector.h:402
template<typename T >
T & libMesh::TypeVector< T >::operator() ( const unsigned int  i)
inline
Returns
A writable reference to the $ i^{th} $ entry of the vector.

Definition at line 546 of file type_vector.h.

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

547 {
548  libmesh_assert_less (i, LIBMESH_DIM);
549 
550  return _coords[i];
551 }
T _coords[LIBMESH_DIM]
Definition: type_vector.h:402
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
inline

Multiply this vector by a scalar value.

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

Definition at line 732 of file type_vector.h.

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

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

733 {
734  typedef typename CompareTypes<T, Scalar>::supertype SuperType;
735 
736 #if LIBMESH_DIM == 1
737  return TypeVector<SuperType>(_coords[0]*factor);
738 #endif
739 
740 #if LIBMESH_DIM == 2
741  return TypeVector<SuperType>(_coords[0]*factor,
742  _coords[1]*factor);
743 #endif
744 
745 #if LIBMESH_DIM == 3
746  return TypeVector<SuperType>(_coords[0]*factor,
747  _coords[1]*factor,
748  _coords[2]*factor);
749 #endif
750 }
T _coords[LIBMESH_DIM]
Definition: type_vector.h:402
template<typename T >
template<typename T2 >
CompareTypes< T, T2 >::supertype libMesh::TypeVector< T >::operator* ( const TypeVector< T2 > &  p) const
inline
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 843 of file type_vector.h.

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

844 {
845 #if LIBMESH_DIM == 1
846  return _coords[0]*p._coords[0];
847 #endif
848 
849 #if LIBMESH_DIM == 2
850  return (_coords[0]*p._coords[0] +
851  _coords[1]*p._coords[1]);
852 #endif
853 
854 #if LIBMESH_DIM == 3
855  return (_coords[0]*p(0) +
856  _coords[1]*p(1) +
857  _coords[2]*p(2));
858 #endif
859 }
T _coords[LIBMESH_DIM]
Definition: type_vector.h:402
template<typename T>
const TypeVector< T > & libMesh::TypeVector< T >::operator*= ( const T  factor)
inline

Multiply this vector by a scalar value.

Returns
A reference to *this.

Definition at line 769 of file type_vector.h.

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

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

770 {
771 #if LIBMESH_DIM == 1
772  _coords[0] *= factor;
773 #endif
774 
775 #if LIBMESH_DIM == 2
776  _coords[0] *= factor;
777  _coords[1] *= factor;
778 #endif
779 
780 #if LIBMESH_DIM == 3
781  _coords[0] *= factor;
782  _coords[1] *= factor;
783  _coords[2] *= factor;
784 #endif
785 
786  return *this;
787 }
T _coords[LIBMESH_DIM]
Definition: type_vector.h:402
template<typename T >
template<typename T2 >
TypeVector< typename CompareTypes< T, T2 >::supertype > libMesh::TypeVector< T >::operator+ ( const TypeVector< T2 > &  p) const
inline

Add two vectors.

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

Definition at line 559 of file type_vector.h.

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

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

560 {
561  typedef typename CompareTypes<T, T2>::supertype TS;
562 #if LIBMESH_DIM == 1
563  return TypeVector<TS> (_coords[0] + p._coords[0]);
564 #endif
565 
566 #if LIBMESH_DIM == 2
567  return TypeVector<TS> (_coords[0] + p._coords[0],
568  _coords[1] + p._coords[1]);
569 #endif
570 
571 #if LIBMESH_DIM == 3
572  return TypeVector<TS> (_coords[0] + p._coords[0],
573  _coords[1] + p._coords[1],
574  _coords[2] + p._coords[2]);
575 #endif
576 
577 }
T _coords[LIBMESH_DIM]
Definition: type_vector.h:402
template<typename T >
template<typename T2 >
const TypeVector< T > & libMesh::TypeVector< T >::operator+= ( const TypeVector< T2 > &  p)
inline

Add to this vector.

Returns
A reference to *this.

Definition at line 584 of file type_vector.h.

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

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

585 {
586  this->add (p);
587 
588  return *this;
589 }
void add(const TypeVector< T2 > &)
Definition: type_vector.h:596
template<typename T >
template<typename T2 >
TypeVector< typename CompareTypes< T, T2 >::supertype > libMesh::TypeVector< T >::operator- ( const TypeVector< T2 > &  p) const
inline

Subtract from this vector.

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

Definition at line 645 of file type_vector.h.

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

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

Definition at line 704 of file type_vector.h.

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

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

705 {
706 
707 #if LIBMESH_DIM == 1
708  return TypeVector(-_coords[0]);
709 #endif
710 
711 #if LIBMESH_DIM == 2
712  return TypeVector(-_coords[0],
713  -_coords[1]);
714 #endif
715 
716 #if LIBMESH_DIM == 3
717  return TypeVector(-_coords[0],
718  -_coords[1],
719  -_coords[2]);
720 #endif
721 
722 }
T _coords[LIBMESH_DIM]
Definition: type_vector.h:402
template<typename T >
template<typename T2 >
const TypeVector< T > & libMesh::TypeVector< T >::operator-= ( const TypeVector< T2 > &  p)
inline

Subtract from this vector.

Returns
A reference to *this.

Definition at line 671 of file type_vector.h.

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

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

672 {
673  this->subtract (p);
674 
675  return *this;
676 }
void subtract(const TypeVector< T2 > &)
Definition: type_vector.h:683
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
inline

Divide each entry of this vector by scalar value.

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

Definition at line 797 of file type_vector.h.

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

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

798 {
799  libmesh_assert_not_equal_to (factor, static_cast<T>(0.));
800 
801  typedef typename CompareTypes<T, Scalar>::supertype TS;
802 
803 #if LIBMESH_DIM == 1
804  return TypeVector<TS>(_coords[0]/factor);
805 #endif
806 
807 #if LIBMESH_DIM == 2
808  return TypeVector<TS>(_coords[0]/factor,
809  _coords[1]/factor);
810 #endif
811 
812 #if LIBMESH_DIM == 3
813  return TypeVector<TS>(_coords[0]/factor,
814  _coords[1]/factor,
815  _coords[2]/factor);
816 #endif
817 
818 }
T _coords[LIBMESH_DIM]
Definition: type_vector.h:402
template<typename T>
const TypeVector< T > & libMesh::TypeVector< T >::operator/= ( const T  factor)
inline

Divide each entry of this vector by scalar value.

Returns
A reference to *this.

Definition at line 826 of file type_vector.h.

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

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

827 {
828  libmesh_assert_not_equal_to (factor, static_cast<T>(0.));
829 
830  for (unsigned int i=0; i<LIBMESH_DIM; i++)
831  _coords[i] /= factor;
832 
833  return *this;
834 }
T _coords[LIBMESH_DIM]
Definition: type_vector.h:402
template<>
bool libMesh::TypeVector< Complex >::operator< ( const TypeVector< Complex > &  rhs) const

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
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

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
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, TypeVector &>::type libMesh::TypeVector< T >::operator= ( const Scalar &  libmesh_dbg_varp)
inline

Assignment-from-scalar operator. Used only to zero out vectors.

Definition at line 133 of file type_vector.h.

134  { libmesh_assert_equal_to (p, Scalar(0)); this->zero(); return *this; }
template<typename T>
bool libMesh::TypeVector< T >::operator== ( const TypeVector< T > &  rhs) const
inline
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 1004 of file type_vector.h.

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

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

1005 {
1006 #if LIBMESH_DIM == 1
1007  return (_coords[0] == rhs._coords[0]);
1008 #endif
1009 
1010 #if LIBMESH_DIM == 2
1011  return (_coords[0] == rhs._coords[0] &&
1012  _coords[1] == rhs._coords[1]);
1013 #endif
1014 
1015 #if LIBMESH_DIM == 3
1016  return (_coords[0] == rhs._coords[0] &&
1017  _coords[1] == rhs._coords[1] &&
1018  _coords[2] == rhs._coords[2]);
1019 #endif
1020 }
T _coords[LIBMESH_DIM]
Definition: type_vector.h:402
template<>
bool libMesh::TypeVector< Complex >::operator> ( const TypeVector< Complex > &  rhs) const

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
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

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
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

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
inline
Returns
true if two vectors are equal to within a relative tolerance of tol.

Definition at line 979 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::Prism6::has_affine_map(), libMesh::Quad8::has_affine_map(), libMesh::Quad9::has_affine_map(), libMesh::Hex8::has_affine_map(), libMesh::Hex27::has_affine_map(), libMesh::Hex20::has_affine_map(), libMesh::Prism15::has_affine_map(), libMesh::Prism18::has_affine_map(), libMesh::TypeVector< Real >::slice(), libMesh::Quad4::volume(), and libMesh::Tri6::volume().

980 {
981 #if LIBMESH_DIM == 1
982  return this->absolute_fuzzy_equals(rhs, tol *
983  (std::abs(_coords[0]) + std::abs(rhs._coords[0])));
984 #endif
985 
986 #if LIBMESH_DIM == 2
987  return this->absolute_fuzzy_equals(rhs, tol *
988  (std::abs(_coords[0]) + std::abs(rhs._coords[0]) +
989  std::abs(_coords[1]) + std::abs(rhs._coords[1])));
990 #endif
991 
992 #if LIBMESH_DIM == 3
993  return this->absolute_fuzzy_equals(rhs, tol *
994  (std::abs(_coords[0]) + std::abs(rhs._coords[0]) +
995  std::abs(_coords[1]) + std::abs(rhs._coords[1]) +
996  std::abs(_coords[2]) + std::abs(rhs._coords[2])));
997 #endif
998 }
T _coords[LIBMESH_DIM]
Definition: type_vector.h:402
double abs(double a)
bool absolute_fuzzy_equals(const TypeVector< T > &rhs, Real tol=TOLERANCE) const
Definition: type_vector.h:954
template<typename T >
Real libMesh::TypeVector< T >::size ( ) const
inline
Returns
The magnitude of the vector, i.e. the square-root of the sum of the elements squared.
Deprecated:
Use the norm() function instead.

Definition at line 893 of file type_vector.h.

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

Referenced by libMesh::DofMap::allgather_recursive_constraints(), libMesh::DofMap::get_info(), libMesh::FEInterface::inverse_map(), libMesh::FE< Dim, T >::inverse_map(), libMesh::InfFE< Dim, T_radial, T_map >::inverse_map(), libMesh::DofMap::scatter_constraints(), libMesh::TypeVector< Real >::slice(), and libMesh::EnsightIO::write_geometry_ascii().

894 {
895  libmesh_deprecated();
896  return this->norm();
897 }
Real norm() const
Definition: type_vector.h:903
template<typename T >
Real libMesh::TypeVector< T >::size_sq ( ) const
inline
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 922 of file type_vector.h.

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

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

923 {
924  libmesh_deprecated();
925  return this->norm_sq();
926 }
Real norm_sq() const
Definition: type_vector.h:932
template<typename T>
const T& libMesh::TypeVector< T >::slice ( const unsigned int  i) const
inline

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)
inline

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)
inline

Subtract from this vector without creating a temporary.

Definition at line 683 of file type_vector.h.

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

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

684 {
685  for (unsigned int i=0; i<LIBMESH_DIM; i++)
686  _coords[i] -= p._coords[i];
687 }
T _coords[LIBMESH_DIM]
Definition: type_vector.h:402
template<typename T>
template<typename T2 >
void libMesh::TypeVector< T >::subtract_scaled ( const TypeVector< T2 > &  p,
const T  factor 
)
inline

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

Definition at line 694 of file type_vector.h.

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

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

695 {
696  for (unsigned int i=0; i<LIBMESH_DIM; i++)
697  _coords[i] -= factor*p(i);
698 }
T _coords[LIBMESH_DIM]
Definition: type_vector.h:402
template<typename T >
TypeVector< T > libMesh::TypeVector< T >::unit ( ) const
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(), 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]
Definition: type_vector.h:402
Real norm() const
Definition: type_vector.h:903
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

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 ( )
inline

Set all entries of the vector to 0.

Definition at line 912 of file type_vector.h.

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

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

913 {
914  for (unsigned int i=0; i<LIBMESH_DIM; i++)
915  _coords[i] = 0.;
916 }
T _coords[LIBMESH_DIM]
Definition: type_vector.h:402

Friends And Related Function Documentation

template<typename T>
std::ostream& operator<< ( std::ostream &  os,
const TypeVector< T > &  t 
)
friend

Formatted print as above but supports the syntax:

Point p(1,2,3);
std::cout << p << std::endl;

Definition at line 383 of file type_vector.h.

384  {
385  t.print(os);
386  return os;
387  }
template<typename T>
friend class TypeTensor< T >
friend

Definition at line 57 of file type_vector.h.

template<typename T>
template<typename T2 >
friend class TypeVector
friend

Definition at line 55 of file type_vector.h.

Member Data Documentation


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