$extrastylesheet
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.

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::x.

{
  _coords[0] = x;

#if LIBMESH_DIM > 1
  _coords[1] = y;
#else
  libmesh_assert_equal_to (y, 0);
#endif

#if LIBMESH_DIM > 2
  _coords[2] = z;
#else
  libmesh_assert_equal_to (z, 0);
#endif
}
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::x.

{
  _coords[0] = x;

#if LIBMESH_DIM > 1
  _coords[1] = y;
#else
  libmesh_assert_equal_to (y, 0);
#endif

#if LIBMESH_DIM > 2
  _coords[2] = z;
#else
  libmesh_assert_equal_to (z, 0);
#endif
}
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.

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

Destructor.

Definition at line 436 of file type_vector.h.

{
}

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::SerialMesh::stitching_helper().

{
#if LIBMESH_DIM == 1
  return (std::abs(_coords[0] - rhs._coords[0])
          <= tol);
#endif

#if LIBMESH_DIM == 2
  return (std::abs(_coords[0] - rhs._coords[0]) +
          std::abs(_coords[1] - rhs._coords[1])
          <= tol);
#endif

#if LIBMESH_DIM == 3
  return (std::abs(_coords[0] - rhs._coords[0]) +
          std::abs(_coords[1] - rhs._coords[1]) +
          std::abs(_coords[2] - rhs._coords[2])
          <= tol);
#endif
}
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::FE< Dim, T >::inverse_map(), libMesh::InfFE< Dim, T_radial, T_map >::inverse_map(), libMesh::LaplaceMeshSmoother::smooth(), and libMesh::MeshTools::Modification::smooth().

{
#if LIBMESH_DIM == 1
  _coords[0] += p._coords[0];
#endif

#if LIBMESH_DIM == 2
  _coords[0] += p._coords[0];
  _coords[1] += p._coords[1];
#endif

#if LIBMESH_DIM == 3
  _coords[0] += p._coords[0];
  _coords[1] += p._coords[1];
  _coords[2] += p._coords[2];
#endif

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

{
  for (unsigned int i=0; i<LIBMESH_DIM; i++)
    _coords[i] = p._coords[i];
}
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.

{
  return (*this)*(p);
}
template<typename T >
template<typename T2 >
TypeVector< typename CompareTypes< T, T2 >::supertype > libMesh::TypeVector< T >::cross ( const TypeVector< T2 > &  p) const

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

{
  typedef typename CompareTypes<T, T2>::supertype TS;
  libmesh_assert_equal_to (LIBMESH_DIM, 3);

  // |     i          j          k    |
  // |(*this)(0) (*this)(1) (*this)(2)|
  // |   p(0)       p(1)       p(2)   |

  return TypeVector<TS>( _coords[1]*p._coords[2] - _coords[2]*p._coords[1],
                         -_coords[0]*p._coords[2] + _coords[2]*p._coords[0],
                         _coords[0]*p._coords[1] - _coords[1]*p._coords[0]);
}
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<>
bool libMesh::TypeVector< Real >::operator!= ( const TypeVector< Real > &  rhs) const [inline]

Definition at line 926 of file type_vector.h.

{
  return (!(*this == rhs));
}
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.

{
  libmesh_assert_less (i, LIBMESH_DIM);

  return _coords[i];
}
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.

{
  libmesh_assert_less (i, LIBMESH_DIM);

  return _coords[i];
}
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.

{
  typedef typename CompareTypes<T, Scalar>::supertype SuperType;

#if LIBMESH_DIM == 1
  return TypeVector<SuperType>(_coords[0]*factor);
#endif

#if LIBMESH_DIM == 2
  return TypeVector<SuperType>(_coords[0]*factor,
                               _coords[1]*factor);
#endif

#if LIBMESH_DIM == 3
  return TypeVector<SuperType>(_coords[0]*factor,
                               _coords[1]*factor,
                               _coords[2]*factor);
#endif
}
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.

{
#if LIBMESH_DIM == 1
  return _coords[0]*p._coords[0];
#endif

#if LIBMESH_DIM == 2
  return (_coords[0]*p._coords[0] +
          _coords[1]*p._coords[1]);
#endif

#if LIBMESH_DIM == 3
  return (_coords[0]*p(0) +
          _coords[1]*p(1) +
          _coords[2]*p(2));
#endif
}
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.

{
#if LIBMESH_DIM == 1
  _coords[0] *= factor;
#endif

#if LIBMESH_DIM == 2
  _coords[0] *= factor;
  _coords[1] *= factor;
#endif

#if LIBMESH_DIM == 3
  _coords[0] *= factor;
  _coords[1] *= factor;
  _coords[2] *= factor;
#endif

  return *this;
}
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.

{
  typedef typename CompareTypes<T, T2>::supertype TS;
#if LIBMESH_DIM == 1
  return TypeVector<TS> (_coords[0] + p._coords[0]);
#endif

#if LIBMESH_DIM == 2
  return TypeVector<TS> (_coords[0] + p._coords[0],
                         _coords[1] + p._coords[1]);
#endif

#if LIBMESH_DIM == 3
  return TypeVector<TS> (_coords[0] + p._coords[0],
                         _coords[1] + p._coords[1],
                         _coords[2] + p._coords[2]);
#endif

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

{
  this->add (p);

  return *this;
}
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.

{
  typedef typename CompareTypes<T, T2>::supertype TS;

#if LIBMESH_DIM == 1
  return TypeVector<TS>(_coords[0] - p._coords[0]);
#endif

#if LIBMESH_DIM == 2
  return TypeVector<TS>(_coords[0] - p._coords[0],
                        _coords[1] - p._coords[1]);
#endif

#if LIBMESH_DIM == 3
  return TypeVector<TS>(_coords[0] - p._coords[0],
                        _coords[1] - p._coords[1],
                        _coords[2] - p._coords[2]);
#endif

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

{

#if LIBMESH_DIM == 1
  return TypeVector(-_coords[0]);
#endif

#if LIBMESH_DIM == 2
  return TypeVector(-_coords[0],
                    -_coords[1]);
#endif

#if LIBMESH_DIM == 3
  return TypeVector(-_coords[0],
                    -_coords[1],
                    -_coords[2]);
#endif

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

{
  this->subtract (p);

  return *this;
}
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.

{
  libmesh_assert_not_equal_to (factor, static_cast<T>(0.));

  typedef typename CompareTypes<T, Scalar>::supertype TS;

#if LIBMESH_DIM == 1
  return TypeVector<TS>(_coords[0]/factor);
#endif

#if LIBMESH_DIM == 2
  return TypeVector<TS>(_coords[0]/factor,
                        _coords[1]/factor);
#endif

#if LIBMESH_DIM == 3
  return TypeVector<TS>(_coords[0]/factor,
                        _coords[1]/factor,
                        _coords[2]/factor);
#endif

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

{
  libmesh_assert_not_equal_to (factor, static_cast<T>(0.));

  for (unsigned int i=0; i<LIBMESH_DIM; i++)
    _coords[i] /= factor;

  return *this;
}
template<>
bool libMesh::TypeVector< Complex >::operator< ( const TypeVector< Complex > &  rhs) const

Definition at line 167 of file type_vector.C.

{
  for (unsigned int i=0; i<LIBMESH_DIM; i++)
    {
      if ((*this)(i).real() < rhs(i).real())
        return true;
      if ((*this)(i).real() > rhs(i).real())
        return false;
      if ((*this)(i).imag() < rhs(i).imag())
        return true;
      if ((*this)(i).imag() > rhs(i).imag())
        return false;
    }
  return false;
}
template<typename T>
bool libMesh::TypeVector< T >::operator< ( const TypeVector< T > &  rhs) const
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.

{
  for (unsigned int i=0; i<LIBMESH_DIM; i++)
    {
      if ((*this)(i) < rhs(i))
        return true;
      if ((*this)(i) > rhs(i))
        return false;
    }
  return false;
}
template<>
bool libMesh::TypeVector< Complex >::operator<= ( const TypeVector< Complex > &  rhs) const

Definition at line 186 of file type_vector.C.

{
  for (unsigned int i=0; i<LIBMESH_DIM; i++)
    {
      if ((*this)(i).real() < rhs(i).real())
        return true;
      if ((*this)(i).real() > rhs(i).real())
        return false;
      if ((*this)(i).imag() < rhs(i).imag())
        return true;
      if ((*this)(i).imag() > rhs(i).imag())
        return false;
    }
  return true;
}
template<typename T>
bool libMesh::TypeVector< T >::operator<= ( const TypeVector< T > &  rhs) const
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.

{
  for (unsigned int i=0; i<LIBMESH_DIM; i++)
    {
      if ((*this)(i) < rhs(i))
        return true;
      if ((*this)(i) > rhs(i))
        return false;
    }
  return true;
}
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.

Definition at line 115 of file type_vector.h.

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

Definition at line 904 of file type_vector.h.

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

{
#if LIBMESH_DIM == 1
  return (_coords[0] == rhs._coords[0]);
#endif

#if LIBMESH_DIM == 2
  return (_coords[0] == rhs._coords[0] &&
          _coords[1] == rhs._coords[1]);
#endif

#if LIBMESH_DIM == 3
  return (_coords[0] == rhs._coords[0] &&
          _coords[1] == rhs._coords[1] &&
          _coords[2] == rhs._coords[2]);
#endif
}
template<>
bool libMesh::TypeVector< Complex >::operator> ( const TypeVector< Complex > &  rhs) const

Definition at line 205 of file type_vector.C.

{
  for (unsigned int i=0; i<LIBMESH_DIM; i++)
    {
      if ((*this)(i).real() > rhs(i).real())
        return true;
      if ((*this)(i).real() < rhs(i).real())
        return false;
      if ((*this)(i).imag() > rhs(i).imag())
        return true;
      if ((*this)(i).imag() < rhs(i).imag())
        return false;
    }
  return false;
}
template<typename T>
bool libMesh::TypeVector< T >::operator> ( const TypeVector< T > &  rhs) const
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.

{
  for (unsigned int i=0; i<LIBMESH_DIM; i++)
    {
      if ((*this)(i) > rhs(i))
        return true;
      if ((*this)(i) < rhs(i))
        return false;
    }
  return false;
}
template<>
bool libMesh::TypeVector< Complex >::operator>= ( const TypeVector< Complex > &  rhs) const

Definition at line 224 of file type_vector.C.

{
  for (unsigned int i=0; i<LIBMESH_DIM; i++)
    {
      if ((*this)(i).real() > rhs(i).real())
        return true;
      if ((*this)(i).real() < rhs(i).real())
        return false;
      if ((*this)(i).imag() > rhs(i).imag())
        return true;
      if ((*this)(i).imag() < rhs(i).imag())
        return false;
    }
  return true;
}
template<typename T>
bool libMesh::TypeVector< T >::operator>= ( const TypeVector< T > &  rhs) const
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.

{
  for (unsigned int i=0; i<LIBMESH_DIM; i++)
    {
      if ((*this)(i) > rhs(i))
        return true;
      if ((*this)(i) < rhs(i))
        return false;
    }
  return true;
}
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.

{
#if LIBMESH_DIM == 1

  os << "x=" << (*this)(0);

#endif
#if LIBMESH_DIM == 2

  os << "(x,y)=("
     << std::setw(8) << (*this)(0) << ", "
     << std::setw(8) << (*this)(1) << ")";

#endif
#if LIBMESH_DIM == 3

  os <<  "(x,y,z)=("
     << std::setw(8) << (*this)(0) << ", "
     << std::setw(8) << (*this)(1) << ", "
     << std::setw(8) << (*this)(2) << ")";
#endif
}
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, and std::abs().

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

{
#if LIBMESH_DIM == 1
  return this->absolute_fuzzy_equals(rhs, tol *
                                     (std::abs(_coords[0]) + std::abs(rhs._coords[0])));
#endif

#if LIBMESH_DIM == 2
  return this->absolute_fuzzy_equals(rhs, tol *
                                     (std::abs(_coords[0]) + std::abs(rhs._coords[0]) +
                                      std::abs(_coords[1]) + std::abs(rhs._coords[1])));
#endif

#if LIBMESH_DIM == 3
  return this->absolute_fuzzy_equals(rhs, tol *
                                     (std::abs(_coords[0]) + std::abs(rhs._coords[0]) +
                                      std::abs(_coords[1]) + std::abs(rhs._coords[1]) +
                                      std::abs(_coords[2]) + std::abs(rhs._coords[2])));
#endif
}
template<typename T>
const T& libMesh::TypeVector< T >::slice ( const unsigned int  i) const [inline]

Definition at line 123 of file type_vector.h.

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

Definition at line 130 of file type_vector.h.

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

{
  for (unsigned int i=0; i<LIBMESH_DIM; i++)
    _coords[i] -= p._coords[i];
}
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.

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

{
  for (unsigned int i=0; i<LIBMESH_DIM; i++)
    _coords[i] -= factor*p(i);
}
template<typename T >
TypeVector< T > libMesh::TypeVector< T >::unit ( ) const

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

{

  const Real length = size();

  libmesh_assert_not_equal_to (length, static_cast<Real>(0.));

#if LIBMESH_DIM == 1
  return TypeVector<T>(_coords[0]/length);
#endif

#if LIBMESH_DIM == 2
  return TypeVector<T>(_coords[0]/length,
                       _coords[1]/length);
#endif

#if LIBMESH_DIM == 3
  return TypeVector<T>(_coords[0]/length,
                       _coords[1]/length,
                       _coords[2]/length);
#endif

}
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. Optionally prints a newline, which it does by default.

Definition at line 92 of file type_vector.C.

References libMesh::libmesh_assert().

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

{
  libmesh_assert (os);

  os << std::setiosflags(std::ios::showpoint)
     << (*this)(0) << " "
     << (*this)(1) << " "
     << (*this)(2) << " ";

  if (newline)
    os << '\n';
}
template<typename T >
void libMesh::TypeVector< T >::zero ( ) [inline]

Zero the vector in any dimension.

Definition at line 822 of file type_vector.h.

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

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

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.

  {
    t.print(os);
    return os;
  }
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: