libMesh::TypeVector< T > Class Template Reference

#include <type_vector.h>

Inheritance diagram for libMesh::TypeVector< T >:

List of all members.

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 &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 > &) const
TypeVector< T > unit () const
Real size () const
Real size_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
template<>
bool operator!= (const TypeVector< Real > &rhs) const

Protected Member Functions

 TypeVector ()
 TypeVector (const T x, const T y=0, const T z=0)
template<typename Scalar >
 TypeVector (const Scalar x, const Scalar y=0, typename boostcopy::enable_if_c< ScalarTraits< Scalar >::value, const Scalar >::type z=0)

Protected Attributes

_coords [LIBMESH_DIM]

Friends

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: Point for a real-valued point in LIBMESH_DIM-space, or SpaceVector for a real or complex-valued vector in LIBMESH_DIM-space.

Author:
Benjamin S. Kirk, 2003.

Definition at line 53 of file type_vector.h.


Constructor & Destructor Documentation

template<typename T>
libMesh::TypeVector< T >::TypeVector (  )  [protected]

Empty constructor. Gives the vector 0 in LIBMESH_DIM dimensions.

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

template<typename T>
libMesh::TypeVector< T >::TypeVector ( const T  x,
const T  y = 0,
const T  z = 0 
) [inline, protected]

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

Definition at line 376 of file type_vector.h.

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

00379 {
00380   _coords[0] = x;
00381 
00382 #if LIBMESH_DIM > 1
00383   _coords[1] = y;
00384 #else
00385   libmesh_assert_equal_to (y, 0);
00386 #endif
00387 
00388 #if LIBMESH_DIM > 2
00389   _coords[2] = z;
00390 #else
00391   libmesh_assert_equal_to (z, 0);
00392 #endif
00393 }

template<typename T >
template<typename Scalar >
libMesh::TypeVector< T >::TypeVector ( const Scalar  x,
const Scalar  y = 0,
typename boostcopy::enable_if_c< ScalarTraits< Scalar >::value, const Scalar >::type  z = 0 
) [inline, protected]

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

Definition at line 399 of file type_vector.h.

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

00404 {
00405   _coords[0] = x;
00406 
00407 #if LIBMESH_DIM > 1
00408   _coords[1] = y;
00409 #else
00410   libmesh_assert_equal_to (y, 0);
00411 #endif
00412 
00413 #if LIBMESH_DIM > 2
00414   _coords[2] = z;
00415 #else
00416   libmesh_assert_equal_to (z, 0);
00417 #endif
00418 }

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

Copy-constructor.

Definition at line 425 of file type_vector.h.

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

00426 {
00427   // copy the nodes from vector p to me
00428   for (unsigned int i=0; i<LIBMESH_DIM; i++)
00429     _coords[i] = p._coords[i];
00430 }

template<typename T >
libMesh::TypeVector< T >::~TypeVector (  )  [inline]

Destructor.

Definition at line 436 of file type_vector.h.

00437 {
00438 }


Member Function Documentation

template<typename T>
bool libMesh::TypeVector< T >::absolute_fuzzy_equals ( const TypeVector< T > &  rhs,
Real  tol = TOLERANCE 
) const [inline]
Returns:
true iff two vectors occupy approximately the same physical location in space, to within an absolute tolerance of tol.

Definition at line 854 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(), and libMesh::TypeVector< T >::relative_fuzzy_equals().

00855 {
00856 #if LIBMESH_DIM == 1
00857   return (std::abs(_coords[0] - rhs._coords[0])
00858           <= tol);
00859 #endif
00860 
00861 #if LIBMESH_DIM == 2
00862   return (std::abs(_coords[0] - rhs._coords[0]) +
00863           std::abs(_coords[1] - rhs._coords[1])
00864           <= tol);
00865 #endif
00866 
00867 #if LIBMESH_DIM == 3
00868   return (std::abs(_coords[0] - rhs._coords[0]) +
00869           std::abs(_coords[1] - rhs._coords[1]) +
00870           std::abs(_coords[2] - rhs._coords[2])
00871           <= tol);
00872 #endif
00873 }

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 516 of file type_vector.h.

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

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

00517 {
00518 #if LIBMESH_DIM == 1
00519   _coords[0] += p._coords[0];
00520 #endif
00521 
00522 #if LIBMESH_DIM == 2
00523   _coords[0] += p._coords[0];
00524   _coords[1] += p._coords[1];
00525 #endif
00526 
00527 #if LIBMESH_DIM == 3
00528   _coords[0] += p._coords[0];
00529   _coords[1] += p._coords[1];
00530   _coords[2] += p._coords[2];
00531 #endif
00532 
00533 }

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 a vector without creating a temporary.

Definition at line 445 of file type_vector.h.

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

00446 {
00447   for (unsigned int i=0; i<LIBMESH_DIM; i++)
00448     _coords[i] = p._coords[i];
00449 }

template<typename T >
template<typename T2 >
CompareTypes< T, T2 >::supertype libMesh::TypeVector< T >::contract ( const TypeVector< T2 > &  p  )  const [inline]

Multiply 2 vectors together, i.e. dot-product. The vectors may be of different types.

Definition at line 785 of file type_vector.h.

00786 {
00787   return (*this)*(p);
00788 }

template<typename T >
template<typename T2 >
TypeVector< typename CompareTypes< T, T2 >::supertype > libMesh::TypeVector< T >::cross ( const TypeVector< T2 > &  p  )  const [inline]

Cross 2 vectors together, i.e. cross-product.

Definition at line 795 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::Tri3::volume(), libMesh::Quad4::volume(), libMesh::Tet4::volume(), libMesh::Pyramid5::volume(), libMesh::Prism6::volume(), and libMesh::Hex8::volume().

00796 {
00797   typedef typename CompareTypes<T, T2>::supertype TS;
00798   libmesh_assert_equal_to (LIBMESH_DIM, 3);
00799 
00800   // |     i          j          k    |
00801   // |(*this)(0) (*this)(1) (*this)(2)|
00802   // |   p(0)       p(1)       p(2)   |
00803 
00804   return TypeVector<TS>( _coords[1]*p._coords[2] - _coords[2]*p._coords[1],
00805                         -_coords[0]*p._coords[2] + _coords[2]*p._coords[0],
00806                          _coords[0]*p._coords[1] - _coords[1]*p._coords[0]);
00807 }

template<>
bool libMesh::TypeVector< Real >::operator!= ( const TypeVector< Real > &  rhs  )  const [inline]

Definition at line 926 of file type_vector.h.

00927 {
00928   return (!(*this == rhs));
00929 }

template<typename T>
bool libMesh::TypeVector< T >::operator!= ( const TypeVector< T > &  rhs  )  const
Returns:
true iff two vectors do not occupy approximately the same physical location in space.
template<typename T >
T & libMesh::TypeVector< T >::operator() ( const unsigned int  i  )  [inline]

Return a writeable reference to the $ i^{th} $ element of the vector.

Definition at line 466 of file type_vector.h.

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

00467 {
00468   libmesh_assert_less (i, LIBMESH_DIM);
00469 
00470   return _coords[i];
00471 }

template<typename T >
const T & libMesh::TypeVector< T >::operator() ( const unsigned int  i  )  const [inline]

Return the $ i^{th} $ element of the vector.

Definition at line 455 of file type_vector.h.

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

00456 {
00457   libmesh_assert_less (i, LIBMESH_DIM);
00458 
00459   return _coords[i];
00460 }

template<typename T >
template<typename T2 >
CompareTypes< T, T2 >::supertype libMesh::TypeVector< T >::operator* ( const TypeVector< T2 > &  p  )  const [inline]

Multiply 2 vectors together, i.e. dot-product. The vectors may be of different types.

Definition at line 763 of file type_vector.h.

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

00764 {
00765 #if LIBMESH_DIM == 1
00766   return _coords[0]*p._coords[0];
00767 #endif
00768 
00769 #if LIBMESH_DIM == 2
00770   return (_coords[0]*p._coords[0] +
00771           _coords[1]*p._coords[1]);
00772 #endif
00773 
00774 #if LIBMESH_DIM == 3
00775   return (_coords[0]*p(0) +
00776           _coords[1]*p(1) +
00777           _coords[2]*p(2));
00778 #endif
00779 }

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 a vector by a number, i.e. scale.

Definition at line 652 of file type_vector.h.

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

00653 {
00654   typedef typename CompareTypes<T, Scalar>::supertype SuperType;
00655 
00656 #if LIBMESH_DIM == 1
00657   return TypeVector<SuperType>(_coords[0]*factor);
00658 #endif
00659 
00660 #if LIBMESH_DIM == 2
00661   return TypeVector<SuperType>(_coords[0]*factor,
00662                         _coords[1]*factor);
00663 #endif
00664 
00665 #if LIBMESH_DIM == 3
00666   return TypeVector<SuperType>(_coords[0]*factor,
00667                         _coords[1]*factor,
00668                         _coords[2]*factor);
00669 #endif
00670 }

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

Multiply this vector by a number, i.e. scale.

Definition at line 689 of file type_vector.h.

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

00690 {
00691 #if LIBMESH_DIM == 1
00692   _coords[0] *= factor;
00693 #endif
00694 
00695 #if LIBMESH_DIM == 2
00696   _coords[0] *= factor;
00697   _coords[1] *= factor;
00698 #endif
00699 
00700 #if LIBMESH_DIM == 3
00701   _coords[0] *= factor;
00702   _coords[1] *= factor;
00703   _coords[2] *= factor;
00704 #endif
00705 
00706   return *this;
00707 }

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.

Definition at line 479 of file type_vector.h.

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

00480 {
00481   typedef typename CompareTypes<T, T2>::supertype TS;
00482 #if LIBMESH_DIM == 1
00483   return TypeVector<TS> (_coords[0] + p._coords[0]);
00484 #endif
00485 
00486 #if LIBMESH_DIM == 2
00487   return TypeVector<TS> (_coords[0] + p._coords[0],
00488                          _coords[1] + p._coords[1]);
00489 #endif
00490 
00491 #if LIBMESH_DIM == 3
00492   return TypeVector<TS> (_coords[0] + p._coords[0],
00493                          _coords[1] + p._coords[1],
00494                          _coords[2] + p._coords[2]);
00495 #endif
00496 
00497 }

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

Add to this vector.

Definition at line 504 of file type_vector.h.

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

00505 {
00506   this->add (p);
00507 
00508   return *this;
00509 }

template<typename T >
TypeVector< T > libMesh::TypeVector< T >::operator- (  )  const [inline]

Return the opposite of a vector

Definition at line 624 of file type_vector.h.

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

00625 {
00626 
00627 #if LIBMESH_DIM == 1
00628   return TypeVector(-_coords[0]);
00629 #endif
00630 
00631 #if LIBMESH_DIM == 2
00632   return TypeVector(-_coords[0],
00633                     -_coords[1]);
00634 #endif
00635 
00636 #if LIBMESH_DIM == 3
00637   return TypeVector(-_coords[0],
00638                     -_coords[1],
00639                     -_coords[2]);
00640 #endif
00641 
00642 }

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

Subtract two vectors.

Definition at line 565 of file type_vector.h.

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

00566 {
00567   typedef typename CompareTypes<T, T2>::supertype TS;
00568 
00569 #if LIBMESH_DIM == 1
00570   return TypeVector<TS>(_coords[0] - p._coords[0]);
00571 #endif
00572 
00573 #if LIBMESH_DIM == 2
00574   return TypeVector<TS>(_coords[0] - p._coords[0],
00575                         _coords[1] - p._coords[1]);
00576 #endif
00577 
00578 #if LIBMESH_DIM == 3
00579   return TypeVector<TS>(_coords[0] - p._coords[0],
00580                         _coords[1] - p._coords[1],
00581                         _coords[2] - p._coords[2]);
00582 #endif
00583 
00584 }

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

Subtract from this vector.

Definition at line 591 of file type_vector.h.

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

00592 {
00593   this->subtract (p);
00594 
00595   return *this;
00596 }

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 a vector by a number, i.e. scale.

Definition at line 717 of file type_vector.h.

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

00718 {
00719   libmesh_assert_not_equal_to (factor, static_cast<T>(0.));
00720 
00721   typedef typename CompareTypes<T, Scalar>::supertype TS;
00722 
00723 #if LIBMESH_DIM == 1
00724   return TypeVector<TS>(_coords[0]/factor);
00725 #endif
00726 
00727 #if LIBMESH_DIM == 2
00728   return TypeVector<TS>(_coords[0]/factor,
00729                         _coords[1]/factor);
00730 #endif
00731 
00732 #if LIBMESH_DIM == 3
00733   return TypeVector<TS>(_coords[0]/factor,
00734                         _coords[1]/factor,
00735                         _coords[2]/factor);
00736 #endif
00737 
00738 }

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

Divide this vector by a number, i.e. scale.

Definition at line 746 of file type_vector.h.

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

00747 {
00748   libmesh_assert_not_equal_to (factor, static_cast<T>(0.));
00749 
00750   for (unsigned int i=0; i<LIBMESH_DIM; i++)
00751     _coords[i] /= factor;
00752 
00753   return *this;
00754 }

template<>
bool libMesh::TypeVector< Complex >::operator< ( const TypeVector< Complex > &  rhs  )  const [inline]

Definition at line 167 of file type_vector.C.

00168 {
00169   for (unsigned int i=0; i<LIBMESH_DIM; i++)
00170     {
00171       if ((*this)(i).real() < rhs(i).real())
00172         return true;
00173       if ((*this)(i).real() > rhs(i).real())
00174         return false;
00175       if ((*this)(i).imag() < rhs(i).imag())
00176         return true;
00177       if ((*this)(i).imag() > rhs(i).imag())
00178         return false;
00179     }
00180   return false;
00181 }

template<typename T>
bool libMesh::TypeVector< T >::operator< ( const TypeVector< T > &  rhs  )  const [inline]
Returns:
true if this vector is "less" than another. Useful for sorting. Also used for choosing some arbitrary basis function orientations

Definition at line 109 of file type_vector.C.

00110 {
00111   for (unsigned int i=0; i<LIBMESH_DIM; i++)
00112     {
00113       if ((*this)(i) < rhs(i))
00114         return true;
00115       if ((*this)(i) > rhs(i))
00116         return false;
00117     }
00118   return false;
00119 }

template<>
bool libMesh::TypeVector< Complex >::operator<= ( const TypeVector< Complex > &  rhs  )  const [inline]

Definition at line 186 of file type_vector.C.

00187 {
00188   for (unsigned int i=0; i<LIBMESH_DIM; i++)
00189     {
00190       if ((*this)(i).real() < rhs(i).real())
00191         return true;
00192       if ((*this)(i).real() > rhs(i).real())
00193         return false;
00194       if ((*this)(i).imag() < rhs(i).imag())
00195         return true;
00196       if ((*this)(i).imag() > rhs(i).imag())
00197         return false;
00198     }
00199   return true;
00200 }

template<typename T>
bool libMesh::TypeVector< T >::operator<= ( const TypeVector< T > &  rhs  )  const [inline]
Returns:
true if this vector is "less" than or equal to another. Useful for sorting. Also used for choosing some arbitrary constraint equation directions

Definition at line 123 of file type_vector.C.

00124 {
00125   for (unsigned int i=0; i<LIBMESH_DIM; i++)
00126     {
00127       if ((*this)(i) < rhs(i))
00128         return true;
00129       if ((*this)(i) > rhs(i))
00130         return false;
00131     }
00132   return true;
00133 }

template<typename T>
template<typename Scalar >
boostcopy::enable_if_c< ScalarTraits<Scalar>::value, TypeVector&>::type libMesh::TypeVector< T >::operator= ( const Scalar &  p  )  [inline]

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

Reimplemented in libMesh::VectorValue< T >, and libMesh::VectorValue< Real >.

Definition at line 115 of file type_vector.h.

00116   { 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 iff two vectors occupy approximately the same physical location in space, to within an absolute tolerance of TOLERANCE.

Reimplemented in libMesh::Node.

Definition at line 904 of file type_vector.h.

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

00905 {
00906 #if LIBMESH_DIM == 1
00907   return (_coords[0] == rhs._coords[0]);
00908 #endif
00909 
00910 #if LIBMESH_DIM == 2
00911   return (_coords[0] == rhs._coords[0] &&
00912           _coords[1] == rhs._coords[1]);
00913 #endif
00914 
00915 #if LIBMESH_DIM == 3
00916   return (_coords[0] == rhs._coords[0] &&
00917           _coords[1] == rhs._coords[1] &&
00918           _coords[2] == rhs._coords[2]);
00919 #endif
00920 }

template<>
bool libMesh::TypeVector< Complex >::operator> ( const TypeVector< Complex > &  rhs  )  const [inline]

Definition at line 205 of file type_vector.C.

00206 {
00207   for (unsigned int i=0; i<LIBMESH_DIM; i++)
00208     {
00209       if ((*this)(i).real() > rhs(i).real())
00210         return true;
00211       if ((*this)(i).real() < rhs(i).real())
00212         return false;
00213       if ((*this)(i).imag() > rhs(i).imag())
00214         return true;
00215       if ((*this)(i).imag() < rhs(i).imag())
00216         return false;
00217     }
00218   return false;
00219 }

template<typename T>
bool libMesh::TypeVector< T >::operator> ( const TypeVector< T > &  rhs  )  const [inline]
Returns:
true if this vector is "greater" than another. Useful for sorting. Also used for choosing some arbitrary basis function orientations

Definition at line 138 of file type_vector.C.

00139 {
00140   for (unsigned int i=0; i<LIBMESH_DIM; i++)
00141     {
00142       if ((*this)(i) > rhs(i))
00143         return true;
00144       if ((*this)(i) < rhs(i))
00145         return false;
00146     }
00147   return false;
00148 }

template<>
bool libMesh::TypeVector< Complex >::operator>= ( const TypeVector< Complex > &  rhs  )  const [inline]

Definition at line 224 of file type_vector.C.

00225 {
00226   for (unsigned int i=0; i<LIBMESH_DIM; i++)
00227     {
00228       if ((*this)(i).real() > rhs(i).real())
00229         return true;
00230       if ((*this)(i).real() < rhs(i).real())
00231         return false;
00232       if ((*this)(i).imag() > rhs(i).imag())
00233         return true;
00234       if ((*this)(i).imag() < rhs(i).imag())
00235         return false;
00236     }
00237   return true;
00238 }

template<typename T>
bool libMesh::TypeVector< T >::operator>= ( const TypeVector< T > &  rhs  )  const [inline]
Returns:
true if this vector is "greater" than or equal to another. Useful for sorting. Also used for choosing some arbitrary constraint equation directions

Definition at line 152 of file type_vector.C.

00153 {
00154   for (unsigned int i=0; i<LIBMESH_DIM; i++)
00155     {
00156       if ((*this)(i) > rhs(i))
00157         return true;
00158       if ((*this)(i) < rhs(i))
00159         return false;
00160     }
00161   return true;
00162 }

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

Formatted print, by default to libMesh::out.

Definition at line 64 of file type_vector.C.

00065 {
00066 #if LIBMESH_DIM == 1
00067 
00068   os << "x=" << (*this)(0);
00069 
00070 #endif
00071 #if LIBMESH_DIM == 2
00072 
00073   os << "(x,y)=("
00074      << std::setw(8) << (*this)(0) << ", "
00075      << std::setw(8) << (*this)(1) << ")";
00076 
00077 #endif
00078 #if LIBMESH_DIM == 3
00079 
00080   os <<  "(x,y,z)=("
00081      << std::setw(8) << (*this)(0) << ", "
00082      << std::setw(8) << (*this)(1) << ", "
00083      << std::setw(8) << (*this)(2) << ")";
00084 #endif
00085 }

template<typename T>
bool libMesh::TypeVector< T >::relative_fuzzy_equals ( const TypeVector< T > &  rhs,
Real  tol = TOLERANCE 
) const [inline]
Returns:
true iff two vectors occupy approximately the same physical location in space, to within a relative tolerance of tol.

Definition at line 879 of file type_vector.h.

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

Referenced by libMesh::Quad9::has_affine_map(), libMesh::Quad8::has_affine_map(), libMesh::Quad4::has_affine_map(), libMesh::Prism6::has_affine_map(), libMesh::Prism18::has_affine_map(), libMesh::Prism15::has_affine_map(), libMesh::Hex8::has_affine_map(), libMesh::Hex27::has_affine_map(), and libMesh::Hex20::has_affine_map().

00880 {
00881 #if LIBMESH_DIM == 1
00882   return this->absolute_fuzzy_equals(rhs, tol *
00883                                      (std::abs(_coords[0]) + std::abs(rhs._coords[0])));
00884 #endif
00885 
00886 #if LIBMESH_DIM == 2
00887   return this->absolute_fuzzy_equals(rhs, tol *
00888                                      (std::abs(_coords[0]) + std::abs(rhs._coords[0]) +
00889                                       std::abs(_coords[1]) + std::abs(rhs._coords[1])));
00890 #endif
00891 
00892 #if LIBMESH_DIM == 3
00893   return this->absolute_fuzzy_equals(rhs, tol *
00894                                      (std::abs(_coords[0]) + std::abs(rhs._coords[0]) +
00895                                       std::abs(_coords[1]) + std::abs(rhs._coords[1]) +
00896                                       std::abs(_coords[2]) + std::abs(rhs._coords[2])));
00897 #endif
00898 }

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.

Definition at line 832 of file type_vector.h.

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

Referenced by libMesh::ExactSolution::_compute_error(), libMesh::System::calculate_norm(), libMesh::ExactErrorEstimator::find_squared_element_error(), libMesh::TensorTools::norm_sq(), libMesh::HPCoarsenTest::select_refinement(), libMesh::TypeVector< T >::size(), libMesh::Sphere::Sphere(), and libMesh::Edge3::volume().

00833 {
00834 #if LIBMESH_DIM == 1
00835   return (TensorTools::norm_sq(_coords[0]));
00836 #endif
00837 
00838 #if LIBMESH_DIM == 2
00839   return (TensorTools::norm_sq(_coords[0]) +
00840           TensorTools::norm_sq(_coords[1]));
00841 #endif
00842 
00843 #if LIBMESH_DIM == 3
00844   return (TensorTools::norm_sq(_coords[0]) +
00845           TensorTools::norm_sq(_coords[1]) +
00846           TensorTools::norm_sq(_coords[2]));
00847 #endif
00848 }

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

Definition at line 130 of file type_vector.h.

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

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

Definition at line 123 of file type_vector.h.

00123 { 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 603 of file type_vector.h.

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

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

00604 {
00605   for (unsigned int i=0; i<LIBMESH_DIM; i++)
00606     _coords[i] -= p._coords[i];
00607 }

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 614 of file type_vector.h.

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

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

00615 {
00616   for (unsigned int i=0; i<LIBMESH_DIM; i++)
00617     _coords[i] -= factor*p(i);
00618 }

template<typename T >
TypeVector< T > libMesh::TypeVector< T >::unit (  )  const [inline]

Think of a vector as a dim dimensional vector. This will return a unit vector aligned in that direction.

Definition at line 37 of file type_vector.C.

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

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(), and libMesh::Sphere::unit_normal().

00038 {
00039 
00040   const Real length = size();
00041 
00042   libmesh_assert_not_equal_to (length, static_cast<Real>(0.));
00043 
00044 #if LIBMESH_DIM == 1
00045   return TypeVector<T>(_coords[0]/length);
00046 #endif
00047 
00048 #if LIBMESH_DIM == 2
00049   return TypeVector<T>(_coords[0]/length,
00050                        _coords[1]/length);
00051 #endif
00052 
00053 #if LIBMESH_DIM == 3
00054   return TypeVector<T>(_coords[0]/length,
00055                        _coords[1]/length,
00056                        _coords[2]/length);
00057 #endif
00058 
00059 }

template<typename T >
void libMesh::TypeVector< T >::write_unformatted ( std::ostream &  out,
const bool  newline = true 
) const [inline]

Unformatted print to the stream out. Simply prints the elements of the vector separated by spaces. Optionally prints a newline, which it does by default.

Definition at line 92 of file type_vector.C.

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

00094 {
00095   libmesh_assert (os);
00096 
00097   os << std::setiosflags(std::ios::showpoint)
00098       << (*this)(0) << " "
00099       << (*this)(1) << " "
00100       << (*this)(2) << " ";
00101 
00102   if (newline)
00103     os << '\n';
00104 }

template<typename T >
void libMesh::TypeVector< T >::zero (  )  [inline]

Zero the vector in any dimension.

Definition at line 822 of file type_vector.h.

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

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

00823 {
00824   for (unsigned int i=0; i<LIBMESH_DIM; i++)
00825     _coords[i] = 0.;
00826 }


Friends And Related Function Documentation

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

Formatted print as above but allows you to do Point p(1,2,3); std::cout << p << std::endl;

Definition at line 329 of file type_vector.h.

00330   {
00331     t.print(os);
00332     return os;
00333   }

template<typename T>
friend class TypeTensor< T > [friend]

Definition at line 58 of file type_vector.h.

template<typename T>
libMesh::TypeVector< T >::TypeVector [friend]

Definition at line 56 of file type_vector.h.


Member Data Documentation


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

Site Created By: libMesh Developers
Last modified: February 05 2013 19:55:42 UTC

Hosted By:
SourceForge.net Logo