libMesh::LaspackVector< T > Class Template Reference

#include <laspack_vector.h>

Inheritance diagram for libMesh::LaspackVector< T >:

List of all members.

Public Member Functions

 LaspackVector (const ParallelType=AUTOMATIC)
 LaspackVector (const numeric_index_type n, const ParallelType=AUTOMATIC)
 LaspackVector (const numeric_index_type n, const numeric_index_type n_local, const ParallelType=AUTOMATIC)
 LaspackVector (const numeric_index_type N, const numeric_index_type n_local, const std::vector< numeric_index_type > &ghost, const ParallelType=AUTOMATIC)
 ~LaspackVector ()
void close ()
void clear ()
void zero ()
virtual AutoPtr< NumericVector
< T > > 
zero_clone () const
AutoPtr< NumericVector< T > > clone () const
void init (const numeric_index_type N, const numeric_index_type n_local, const bool fast=false, const ParallelType ptype=AUTOMATIC)
void init (const numeric_index_type N, const bool fast=false, const ParallelType ptype=AUTOMATIC)
void init (const numeric_index_type, const numeric_index_type, const std::vector< numeric_index_type > &, const bool=false, const ParallelType=AUTOMATIC)
virtual void init (const NumericVector< T > &other, const bool fast=false)
NumericVector< T > & operator= (const T s)
NumericVector< T > & operator= (const NumericVector< T > &V)
LaspackVector< T > & operator= (const LaspackVector< T > &V)
NumericVector< T > & operator= (const std::vector< T > &v)
Real min () const
Real max () const
sum () const
Real l1_norm () const
Real l2_norm () const
Real linfty_norm () const
numeric_index_type size () const
numeric_index_type local_size () const
numeric_index_type first_local_index () const
numeric_index_type last_local_index () const
operator() (const numeric_index_type i) const
NumericVector< T > & operator+= (const NumericVector< T > &V)
NumericVector< T > & operator-= (const NumericVector< T > &V)
virtual void reciprocal ()
void set (const numeric_index_type i, const T value)
void add (const numeric_index_type i, const T value)
void add (const T s)
void add (const NumericVector< T > &V)
void add (const T a, const NumericVector< T > &v)
void add_vector (const std::vector< T > &v, const std::vector< numeric_index_type > &dof_indices)
void add_vector (const NumericVector< T > &V, const std::vector< numeric_index_type > &dof_indices)
void add_vector (const NumericVector< T > &, const SparseMatrix< T > &)
void add_vector (const DenseVector< T > &V, const std::vector< numeric_index_type > &dof_indices)
void add_vector_transpose (const NumericVector< T > &, const SparseMatrix< T > &)
virtual void insert (const std::vector< T > &v, const std::vector< numeric_index_type > &dof_indices)
virtual void insert (const NumericVector< T > &V, const std::vector< numeric_index_type > &dof_indices)
virtual void insert (const DenseVector< T > &V, const std::vector< numeric_index_type > &dof_indices)
virtual void insert (const DenseSubVector< T > &V, const std::vector< numeric_index_type > &dof_indices)
void scale (const T factor)
virtual void abs ()
virtual T dot (const NumericVector< T > &V) const
void localize (std::vector< T > &v_local) const
void localize (NumericVector< T > &v_local) const
void localize (NumericVector< T > &v_local, const std::vector< numeric_index_type > &send_list) const
void localize (const numeric_index_type first_local_idx, const numeric_index_type last_local_idx, const std::vector< numeric_index_type > &send_list)
void localize_to_one (std::vector< T > &v_local, const processor_id_type proc_id=0) const
virtual void pointwise_mult (const NumericVector< T > &vec1, const NumericVector< T > &vec2)
virtual void swap (NumericVector< T > &v)
virtual bool initialized () const
ParallelType type () const
ParallelType & type ()
virtual bool closed () const
virtual void init (const NumericVector< T > &other, const bool fast=false)=0
virtual Real subset_l1_norm (const std::set< numeric_index_type > &indices) const
virtual Real subset_l2_norm (const std::set< numeric_index_type > &indices) const
virtual Real subset_linfty_norm (const std::set< numeric_index_type > &indices) const
virtual T el (const numeric_index_type i) const
virtual void get (const std::vector< numeric_index_type > &index, std::vector< T > &values) const
virtual NumericVector< T > & operator+= (const NumericVector< T > &V)=0
virtual NumericVector< T > & operator-= (const NumericVector< T > &V)=0
NumericVector< T > & operator*= (const T a)
NumericVector< T > & operator/= (const T a)
virtual void add (const NumericVector< T > &V)=0
virtual void add (const T a, const NumericVector< T > &v)=0
virtual void add_vector (const NumericVector< T > &V, const std::vector< numeric_index_type > &dof_indices)=0
virtual void add_vector (const NumericVector< T > &, const SparseMatrix< T > &)=0
void add_vector (const NumericVector< T > &v, const ShellMatrix< T > &a)
virtual void add_vector_transpose (const NumericVector< T > &, const SparseMatrix< T > &)=0
virtual void insert (const NumericVector< T > &V, const std::vector< numeric_index_type > &dof_indices)=0
virtual T dot (const NumericVector< T > &) const =0
virtual void localize (NumericVector< T > &v_local) const =0
virtual void localize (NumericVector< T > &v_local, const std::vector< numeric_index_type > &send_list) const =0
virtual int compare (const NumericVector< T > &other_vector, const Real threshold=TOLERANCE) const
virtual int local_relative_compare (const NumericVector< T > &other_vector, const Real threshold=TOLERANCE) const
virtual int global_relative_compare (const NumericVector< T > &other_vector, const Real threshold=TOLERANCE) const
virtual void pointwise_mult (const NumericVector< T > &vec1, const NumericVector< T > &vec2)=0
virtual void print (std::ostream &os=libMesh::out) const
template<>
void print (std::ostream &os) const
virtual void print_global (std::ostream &os=libMesh::out) const
template<>
void print_global (std::ostream &os) const
virtual void print_matlab (const std::string name="NULL") const
virtual void create_subvector (NumericVector< T > &, const std::vector< numeric_index_type > &) const
virtual void swap (NumericVector< T > &v)

Static Public Member Functions

static AutoPtr< NumericVector
< T > > 
build (const SolverPackage solver_package=libMesh::default_solver_package())
static std::string get_info ()
static void print_info (std::ostream &out=libMesh::out)
static unsigned int n_objects ()
static void enable_print_counter_info ()
static void disable_print_counter_info ()

Protected Types

typedef std::map< std::string,
std::pair< unsigned int,
unsigned int > > 
Counts

Protected Member Functions

void increment_constructor_count (const std::string &name)
void increment_destructor_count (const std::string &name)

Protected Attributes

bool _is_closed
bool _is_initialized
ParallelType _type

Static Protected Attributes

static Counts _counts
static Threads::atomic
< unsigned int > 
_n_objects
static Threads::spin_mutex _mutex
static bool _enable_print_counter = true

Private Attributes

QVector _vec

Friends

class LaspackLinearSolver< T >
std::ostream & operator<< (std::ostream &os, const NumericVector< T > &v)

Detailed Description

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

Laspack vector. Provides a nice interface to the Laspack C-based data structures for serial vectors.

Author:
Benjamin S. Kirk, 2002

Definition at line 57 of file laspack_vector.h.


Member Typedef Documentation

typedef std::map<std::string, std::pair<unsigned int, unsigned int> > libMesh::ReferenceCounter::Counts [protected, inherited]

Data structure to log the information. The log is identified by the class name.

Definition at line 113 of file reference_counter.h.


Constructor & Destructor Documentation

template<typename T >
libMesh::LaspackVector< T >::LaspackVector ( const ParallelType  ptype = AUTOMATIC  )  [inline, explicit]

Dummy-Constructor. Dimension=0

Definition at line 466 of file laspack_vector.h.

References libMesh::NumericVector< T >::_type.

00467 {
00468   this->_type = ptype;
00469 }

template<typename T >
libMesh::LaspackVector< T >::LaspackVector ( const numeric_index_type  n,
const ParallelType  ptype = AUTOMATIC 
) [inline, explicit]

Constructor. Set dimension to n and initialize all elements with zero.

Definition at line 475 of file laspack_vector.h.

References libMesh::LaspackVector< T >::init().

00477 {
00478   this->init(n, n, false, ptype);
00479 }

template<typename T >
libMesh::LaspackVector< T >::LaspackVector ( const numeric_index_type  n,
const numeric_index_type  n_local,
const ParallelType  ptype = AUTOMATIC 
) [inline]

Constructor. Set local dimension to n_local, the global dimension to n, and initialize all elements with zero.

Definition at line 485 of file laspack_vector.h.

References libMesh::LaspackVector< T >::init().

00488 {
00489   this->init(n, n_local, false, ptype);
00490 }

template<typename T >
libMesh::LaspackVector< T >::LaspackVector ( const numeric_index_type  N,
const numeric_index_type  n_local,
const std::vector< numeric_index_type > &  ghost,
const ParallelType  ptype = AUTOMATIC 
) [inline]

Constructor. Set local dimension to n_local, the global dimension to n, but additionally reserve memory for the indices specified by the ghost argument.

Definition at line 496 of file laspack_vector.h.

References libMesh::LaspackVector< T >::init().

00500 {
00501   this->init(N, n_local, ghost, false, ptype);
00502 }

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

Destructor, deallocates memory. Made virtual to allow for derived classes to behave properly.

Definition at line 508 of file laspack_vector.h.

References libMesh::LaspackVector< T >::clear().

00509 {
00510   this->clear ();
00511 }


Member Function Documentation

template<typename T >
void libMesh::LaspackVector< T >::abs (  )  [inline, virtual]

v = abs(v)... that is, each entry in v is replaced by its absolute value.

Implements libMesh::NumericVector< T >.

Definition at line 295 of file laspack_vector.C.

References std::abs(), libMesh::NumericVector< T >::initialized(), and libMesh::LaspackVector< T >::size().

00296 {
00297   libmesh_assert (this->initialized());
00298 
00299   const numeric_index_type n = this->size();
00300 
00301   for (numeric_index_type i=0; i!=n; ++i)
00302     this->set(i,std::abs((*this)(i)));
00303 }

template<typename T>
virtual void libMesh::NumericVector< T >::add ( const T  a,
const NumericVector< T > &  v 
) [pure virtual, inherited]

$U+=a*V$. Simple vector addition, equal to the operator +=.

template<typename T>
virtual void libMesh::NumericVector< T >::add ( const NumericVector< T > &  V  )  [pure virtual, inherited]

$U+=V$: Simple vector addition, equal to the operator +=.

template<typename T >
void libMesh::LaspackVector< T >::add ( const T  a,
const NumericVector< T > &  v 
) [inline]

$ U+=a*V $. Simple vector addition, equal to the operator +=.

Definition at line 152 of file laspack_vector.C.

References libMesh::NumericVector< T >::_is_closed, libMesh::LaspackVector< T >::add(), and libMesh::LaspackVector< T >::size().

00153 {
00154   // Make sure the vector passed in is really a LaspackVector
00155   const LaspackVector* v = libmesh_cast_ptr<const LaspackVector*>(&v_in);
00156 
00157 #ifndef NDEBUG
00158   const bool was_closed = this->_is_closed;
00159 #endif
00160 
00161   libmesh_assert(v);
00162   libmesh_assert_equal_to (this->size(), v->size());
00163 
00164   for (numeric_index_type i=0; i<v->size(); i++)
00165     this->add (i, a*(*v)(i));
00166 
00167 #ifndef NDEBUG
00168   this->_is_closed = was_closed;
00169 #endif
00170 }

template<typename T >
void libMesh::LaspackVector< T >::add ( const NumericVector< T > &  V  )  [inline]

$ U+=V $. Simple vector addition, equal to the operator +=.

Definition at line 144 of file laspack_vector.C.

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

00145 {
00146   this->add (1., v);
00147 }

template<typename T >
void libMesh::LaspackVector< T >::add ( const T  s  )  [inline, virtual]

$U(0-LIBMESH_DIM)+=s$. Addition of s to all components. Note that s is a scalar and not a vector.

Implements libMesh::NumericVector< T >.

Definition at line 128 of file laspack_vector.C.

References libMesh::NumericVector< T >::_is_closed, libMesh::LaspackVector< T >::add(), and libMesh::LaspackVector< T >::size().

00129 {
00130   const numeric_index_type n = this->size();
00131 
00132   for (numeric_index_type i=0; i<n; i++)
00133     this->add (i, v);
00134 
00135 #ifndef NDEBUG
00136   this->_is_closed = false;
00137 #endif
00138 }

template<typename T >
void libMesh::LaspackVector< T >::add ( const numeric_index_type  i,
const T  value 
) [inline, virtual]

v(i) += value

Implements libMesh::NumericVector< T >.

Definition at line 720 of file laspack_vector.h.

References libMesh::NumericVector< T >::_is_closed, libMesh::LaspackVector< T >::_vec, libMesh::NumericVector< T >::initialized(), and libMesh::LaspackVector< T >::size().

Referenced by libMesh::LaspackVector< T >::add(), libMesh::LaspackVector< T >::add_vector(), libMesh::LaspackVector< T >::operator+=(), and libMesh::LaspackVector< T >::operator-=().

00721 {
00722   libmesh_assert (this->initialized());
00723   libmesh_assert_less (i, this->size());
00724 
00725   V_AddCmp (&_vec, i+1, value);
00726 
00727 #ifndef NDEBUG
00728   this->_is_closed = false;
00729 #endif
00730 }

template<typename T>
void libMesh::NumericVector< T >::add_vector ( const NumericVector< T > &  v,
const ShellMatrix< T > &  a 
) [inline, inherited]

$U+=A*V$, add the product of a ShellMatrix A and a NumericVector V to this, where this=U.

Definition at line 358 of file numeric_vector.C.

References libMesh::ShellMatrix< T >::vector_mult_add().

00360 {
00361   a.vector_mult_add(*this,v);
00362 }

template<typename T>
virtual void libMesh::NumericVector< T >::add_vector ( const NumericVector< T > &  ,
const SparseMatrix< T > &   
) [pure virtual, inherited]

$U+=A*V$, add the product of a SparseMatrix A and a NumericVector V to this, where this=U.

template<typename T>
virtual void libMesh::NumericVector< T >::add_vector ( const NumericVector< T > &  V,
const std::vector< numeric_index_type > &  dof_indices 
) [pure virtual, inherited]

$U+=V$, where U and V are type NumericVector<T> and you want to specify WHERE to add the NumericVector<T> V

template<typename T >
void libMesh::LaspackVector< T >::add_vector ( const DenseVector< T > &  V,
const std::vector< numeric_index_type > &  dof_indices 
) [inline, virtual]

$U+=V $ where U and V are type DenseVector<T> and you want to specify WHERE to add the DenseVector<T> V

Implements libMesh::NumericVector< T >.

Definition at line 200 of file laspack_vector.C.

References libMesh::LaspackVector< T >::add(), and libMesh::DenseVector< T >::size().

00202 {
00203   libmesh_assert_equal_to (V.size(), dof_indices.size());
00204 
00205   for (unsigned int i=0; i<V.size(); i++)
00206     this->add (dof_indices[i], V(i));
00207 }

template<typename T >
void libMesh::LaspackVector< T >::add_vector ( const NumericVector< T > &  vec_in,
const SparseMatrix< T > &  mat_in 
) [inline]

$U+=A*V$, add the product of a SparseMatrix A and a NumericVector V to this, where this=U.

Definition at line 261 of file laspack_vector.C.

References libMesh::LaspackVector< T >::_vec.

00263 {
00264   // Make sure the data passed in are really in Laspack types
00265   const LaspackVector<T>* vec = libmesh_cast_ptr<const LaspackVector<T>*>(&vec_in);
00266   const LaspackMatrix<T>* mat = libmesh_cast_ptr<const LaspackMatrix<T>*>(&mat_in);
00267 
00268   libmesh_assert(vec);
00269   libmesh_assert(mat);
00270 
00271   // += mat*vec
00272   AddAsgn_VV (&_vec, Mul_QV(const_cast<QMatrix*>(&mat->_QMat),
00273                             const_cast<QVector*>(&vec->_vec)));
00274 }

template<typename T >
void libMesh::LaspackVector< T >::add_vector ( const NumericVector< T > &  V,
const std::vector< numeric_index_type > &  dof_indices 
) [inline]

$ U+=V $ where U and V are type NumericVector<T> and you want to specify WHERE to add the NumericVector<T> V

Definition at line 188 of file laspack_vector.C.

References libMesh::LaspackVector< T >::add(), and libMesh::NumericVector< T >::size().

00190 {
00191   libmesh_assert_equal_to (V.size(), dof_indices.size());
00192 
00193   for (numeric_index_type i=0; i<V.size(); i++)
00194     this->add (dof_indices[i], V(i));
00195 }

template<typename T >
void libMesh::LaspackVector< T >::add_vector ( const std::vector< T > &  v,
const std::vector< numeric_index_type > &  dof_indices 
) [inline, virtual]

$ U+=v $ where v is a std::vector<T> and you want to specify WHERE to add it

Implements libMesh::NumericVector< T >.

Definition at line 175 of file laspack_vector.C.

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

00177 {
00178   libmesh_assert (!v.empty());
00179   libmesh_assert_equal_to (v.size(), dof_indices.size());
00180 
00181   for (numeric_index_type i=0; i<v.size(); i++)
00182     this->add (dof_indices[i], v[i]);
00183 }

template<typename T>
virtual void libMesh::NumericVector< T >::add_vector_transpose ( const NumericVector< T > &  ,
const SparseMatrix< T > &   
) [pure virtual, inherited]

$U+=A^T*V$, add the product of the transpose of a SparseMatrix A_trans and a NumericVector V to this, where this=U.

template<typename T >
void libMesh::LaspackVector< T >::add_vector_transpose ( const NumericVector< T > &  ,
const SparseMatrix< T > &   
) [inline]

$U+=A^T*V$, add the product of the transpose of a SparseMatrix A_trans and a NumericVector V to this, where this=U.

Definition at line 278 of file laspack_vector.C.

00280 {
00281   libmesh_not_implemented();
00282 }

template<typename T >
AutoPtr< NumericVector< T > > libMesh::NumericVector< T >::build ( const SolverPackage  solver_package = libMesh::default_solver_package()  )  [inline, static, inherited]

Builds a NumericVector using the linear solver package specified by solver_package

Definition at line 45 of file numeric_vector.C.

References libMesh::LASPACK_SOLVERS, libMeshEnums::PETSC_SOLVERS, and libMesh::TRILINOS_SOLVERS.

Referenced by libMesh::ExactErrorEstimator::estimate_error().

00046 {
00047   // Build the appropriate vector
00048   switch (solver_package)
00049     {
00050 
00051 
00052 #ifdef LIBMESH_HAVE_LASPACK
00053     case LASPACK_SOLVERS:
00054       {
00055         AutoPtr<NumericVector<T> > ap(new LaspackVector<T>);
00056         return ap;
00057       }
00058 #endif
00059 
00060 
00061 #ifdef LIBMESH_HAVE_PETSC
00062     case PETSC_SOLVERS:
00063       {
00064         AutoPtr<NumericVector<T> > ap(new PetscVector<T>);
00065         return ap;
00066       }
00067 #endif
00068 
00069 
00070 #ifdef LIBMESH_HAVE_TRILINOS
00071     case TRILINOS_SOLVERS:
00072       {
00073         AutoPtr<NumericVector<T> > ap(new EpetraVector<T>);
00074         return ap;
00075       }
00076 #endif
00077 
00078 
00079     default:
00080       AutoPtr<NumericVector<T> > ap(new DistributedVector<T>);
00081       return ap;
00082     }
00083 
00084   AutoPtr<NumericVector<T> > ap(NULL);
00085   return ap;
00086 }

template<typename T >
void libMesh::LaspackVector< T >::clear (  )  [inline, virtual]
Returns:
the LaspackVector to a pristine state.

Reimplemented from libMesh::NumericVector< T >.

Definition at line 604 of file laspack_vector.h.

References libMesh::NumericVector< T >::_is_closed, libMesh::NumericVector< T >::_is_initialized, libMesh::LaspackVector< T >::_vec, and libMesh::NumericVector< T >::initialized().

Referenced by libMesh::LaspackVector< T >::~LaspackVector().

00605 {
00606   if (this->initialized())
00607     {
00608       V_Destr (&_vec);
00609     }
00610 
00611   this->_is_initialized = false;
00612 #ifndef NDEBUG
00613   this->_is_closed = false;
00614 #endif
00615 }

template<typename T >
AutoPtr< NumericVector< T > > libMesh::LaspackVector< T >::clone (  )  const [inline, virtual]

Creates a copy of this vector and returns it in an AutoPtr.

Implements libMesh::NumericVector< T >.

Definition at line 645 of file laspack_vector.h.

00646 {
00647   AutoPtr<NumericVector<T> > cloned_vector (new LaspackVector<T>);
00648 
00649   cloned_vector->init(*this, true);
00650 
00651   *cloned_vector = *this;
00652 
00653   return cloned_vector;
00654 }

template<typename T >
void libMesh::LaspackVector< T >::close (  )  [inline, virtual]

Call the assemble functions

Implements libMesh::NumericVector< T >.

Definition at line 591 of file laspack_vector.h.

References libMesh::NumericVector< T >::_is_closed, and libMesh::NumericVector< T >::initialized().

00592 {
00593   libmesh_assert (this->initialized());
00594 
00595 #ifndef NDEBUG
00596   this->_is_closed = true;
00597 #endif
00598 }

template<typename T>
int libMesh::NumericVector< T >::compare ( const NumericVector< T > &  other_vector,
const Real  threshold = TOLERANCE 
) const [inline, virtual, inherited]
Returns:
-1 when this is equivalent to other_vector, up to the given threshold. When differences occur, the return value contains the first index i where the difference (a[i]-b[i]) exceeded the threshold. When no threshold is given, the libMesh TOLERANCE is used.

Definition at line 90 of file numeric_vector.C.

References std::abs(), libMesh::CommWorld, libMesh::NumericVector< T >::first_local_index(), libMesh::NumericVector< T >::initialized(), libMesh::NumericVector< T >::last_local_index(), std::max(), libMesh::NumericVector< T >::max(), and libMesh::Parallel::Communicator::min().

00092 {
00093   libmesh_assert (this->initialized());
00094   libmesh_assert (other_vector.initialized());
00095   libmesh_assert_equal_to (this->first_local_index(), other_vector.first_local_index());
00096   libmesh_assert_equal_to (this->last_local_index(), other_vector.last_local_index());
00097 
00098   int first_different_i = std::numeric_limits<int>::max();
00099   numeric_index_type i = first_local_index();
00100 
00101   do
00102     {
00103       if ( std::abs( (*this)(i) - other_vector(i) ) > threshold )
00104         first_different_i = i;
00105       else
00106         i++;
00107     }
00108   while (first_different_i==std::numeric_limits<int>::max()
00109          && i<last_local_index());
00110 
00111   // Find the correct first differing index in parallel
00112   CommWorld.min(first_different_i);
00113 
00114   if (first_different_i == std::numeric_limits<int>::max())
00115     return -1;
00116 
00117   return first_different_i;
00118 }

template<typename T>
virtual void libMesh::NumericVector< T >::create_subvector ( NumericVector< T > &  ,
const std::vector< numeric_index_type > &   
) const [inline, virtual, inherited]

Creates the subvector "subvector" from the indices in the "rows" array. Similar to the create_submatrix routine for the SparseMatrix class, it is currently only implemented for PetscVectors.

Definition at line 608 of file numeric_vector.h.

00610   {
00611     libMesh::err << "ERROR: Not Implemented in base class yet!" << std::endl;
00612     libmesh_error();
00613   }

void libMesh::ReferenceCounter::disable_print_counter_info (  )  [static, inherited]

Definition at line 106 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter.

00107 {
00108   _enable_print_counter = false;
00109   return;
00110 }

template<typename T>
virtual T libMesh::NumericVector< T >::dot ( const NumericVector< T > &   )  const [pure virtual, inherited]
template<typename T >
T libMesh::LaspackVector< T >::dot ( const NumericVector< T > &  V  )  const [inline, virtual]

Computes the dot product, p = U.V

Definition at line 306 of file laspack_vector.C.

References libMesh::LaspackVector< T >::_vec, and libMesh::NumericVector< T >::initialized().

00307 {
00308   libmesh_assert (this->initialized());
00309 
00310   // Make sure the NumericVector passed in is really a LaspackVector
00311   const LaspackVector<T>* v = libmesh_cast_ptr<const LaspackVector<T>*>(&V);
00312   libmesh_assert(v);
00313 
00314   return Mul_VV (const_cast<QVector*>(&(this->_vec)),
00315                  const_cast<QVector*>(&(v->_vec)));
00316 }

template<typename T>
virtual T libMesh::NumericVector< T >::el ( const numeric_index_type  i  )  const [inline, virtual, inherited]
Returns:
the element U(i)

Definition at line 324 of file numeric_vector.h.

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

void libMesh::ReferenceCounter::enable_print_counter_info (  )  [static, inherited]

Methods to enable/disable the reference counter output from print_info()

Definition at line 100 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter.

00101 {
00102   _enable_print_counter = true;
00103   return;
00104 }

template<typename T >
numeric_index_type libMesh::LaspackVector< T >::first_local_index (  )  const [inline, virtual]
Returns:
the index of the first vector element actually stored on this processor

Implements libMesh::NumericVector< T >.

Definition at line 682 of file laspack_vector.h.

References libMesh::NumericVector< T >::initialized().

Referenced by libMesh::LaspackVector< T >::operator()().

00683 {
00684   libmesh_assert (this->initialized());
00685 
00686   return 0;
00687 }

template<typename T>
void libMesh::NumericVector< T >::get ( const std::vector< numeric_index_type > &  index,
std::vector< T > &  values 
) const [inline, virtual, inherited]

Access multiple components at once. values will be resized, if necessary, and filled. The default implementation calls operator() for each index, but some implementations may supply faster methods here.

Reimplemented in libMesh::PetscVector< T >.

Definition at line 760 of file numeric_vector.h.

00761 {
00762   const std::size_t num = index.size();
00763   values.resize(num);
00764   for(std::size_t i=0; i<num; i++)
00765     {
00766       values[i] = (*this)(index[i]);
00767     }
00768 }

std::string libMesh::ReferenceCounter::get_info (  )  [static, inherited]

Gets a string containing the reference information.

Definition at line 47 of file reference_counter.C.

References libMesh::ReferenceCounter::_counts, and libMesh::Quality::name().

Referenced by libMesh::ReferenceCounter::print_info().

00048 {
00049 #if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG)
00050 
00051   std::ostringstream oss;
00052 
00053   oss << '\n'
00054       << " ---------------------------------------------------------------------------- \n"
00055       << "| Reference count information                                                |\n"
00056       << " ---------------------------------------------------------------------------- \n";
00057 
00058   for (Counts::iterator it = _counts.begin();
00059        it != _counts.end(); ++it)
00060     {
00061       const std::string name(it->first);
00062       const unsigned int creations    = it->second.first;
00063       const unsigned int destructions = it->second.second;
00064 
00065       oss << "| " << name << " reference count information:\n"
00066           << "|  Creations:    " << creations    << '\n'
00067           << "|  Destructions: " << destructions << '\n';
00068     }
00069 
00070   oss << " ---------------------------------------------------------------------------- \n";
00071 
00072   return oss.str();
00073 
00074 #else
00075 
00076   return "";
00077 
00078 #endif
00079 }

template<typename T>
int libMesh::NumericVector< T >::global_relative_compare ( const NumericVector< T > &  other_vector,
const Real  threshold = TOLERANCE 
) const [inline, virtual, inherited]
Returns:
-1 when this is equivalent to other_vector, up to the given local relative threshold. When differences occur, the return value contains the first index where the difference (a[i]-b[i])/max_j(a[j],b[j]) exceeded the threshold. When no threshold is given, the libMesh TOLERANCE is used.

Definition at line 155 of file numeric_vector.C.

References std::abs(), libMesh::CommWorld, libMesh::NumericVector< T >::first_local_index(), libMesh::NumericVector< T >::initialized(), libMesh::NumericVector< T >::last_local_index(), libMesh::NumericVector< T >::linfty_norm(), std::max(), libMesh::NumericVector< T >::max(), libMesh::Parallel::Communicator::min(), and libMesh::Real.

00157 {
00158   libmesh_assert (this->initialized());
00159   libmesh_assert (other_vector.initialized());
00160   libmesh_assert_equal_to (this->first_local_index(), other_vector.first_local_index());
00161   libmesh_assert_equal_to (this->last_local_index(), other_vector.last_local_index());
00162 
00163   int first_different_i = std::numeric_limits<int>::max();
00164   numeric_index_type i = first_local_index();
00165 
00166   const Real my_norm = this->linfty_norm();
00167   const Real other_norm = other_vector.linfty_norm();
00168   const Real abs_threshold = std::max(my_norm, other_norm) * threshold;
00169 
00170   do
00171     {
00172       if ( std::abs( (*this)(i) - other_vector(i) ) > abs_threshold )
00173         first_different_i = i;
00174       else
00175         i++;
00176     }
00177   while (first_different_i==std::numeric_limits<int>::max()
00178          && i<last_local_index());
00179 
00180   // Find the correct first differing index in parallel
00181   CommWorld.min(first_different_i);
00182 
00183   if (first_different_i == std::numeric_limits<int>::max())
00184     return -1;
00185 
00186   return first_different_i;
00187 }

void libMesh::ReferenceCounter::increment_constructor_count ( const std::string &  name  )  [inline, protected, inherited]

Increments the construction counter. Should be called in the constructor of any derived class that will be reference counted.

Definition at line 163 of file reference_counter.h.

References libMesh::ReferenceCounter::_counts, and libMesh::Threads::spin_mtx.

Referenced by libMesh::ReferenceCountedObject< RBParametrized >::ReferenceCountedObject().

00164 {
00165   Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
00166   std::pair<unsigned int, unsigned int>& p = _counts[name];
00167 
00168   p.first++;
00169 }

void libMesh::ReferenceCounter::increment_destructor_count ( const std::string &  name  )  [inline, protected, inherited]

Increments the destruction counter. Should be called in the destructor of any derived class that will be reference counted.

Definition at line 176 of file reference_counter.h.

References libMesh::ReferenceCounter::_counts, and libMesh::Threads::spin_mtx.

Referenced by libMesh::ReferenceCountedObject< RBParametrized >::~ReferenceCountedObject().

00177 {
00178   Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
00179   std::pair<unsigned int, unsigned int>& p = _counts[name];
00180 
00181   p.second++;
00182 }

template<typename T>
virtual void libMesh::NumericVector< T >::init ( const NumericVector< T > &  other,
const bool  fast = false 
) [pure virtual, inherited]

Creates a vector that has the same dimension and storage type as other, including ghost dofs.

template<class T >
void libMesh::LaspackVector< T >::init ( const NumericVector< T > &  other,
const bool  fast = false 
) [inline, virtual]

Creates a vector that has the same dimension and storage type as other, including ghost dofs.

Definition at line 581 of file laspack_vector.h.

References libMesh::LaspackVector< T >::init(), libMesh::NumericVector< T >::local_size(), libMesh::NumericVector< T >::size(), and libMesh::NumericVector< T >::type().

00583 {
00584   this->init(other.size(),other.local_size(),fast,other.type());
00585 }

template<typename T>
void libMesh::LaspackVector< T >::init ( const   numeric_index_type,
const   numeric_index_type,
const std::vector< numeric_index_type > &  ,
const   bool = false,
const   ParallelType = AUTOMATIC 
) [virtual]

Create a vector that holds tha local indices plus those specified in the ghost argument.

Implements libMesh::NumericVector< T >.

template<typename T >
void libMesh::LaspackVector< T >::init ( const numeric_index_type  N,
const bool  fast = false,
const ParallelType  ptype = AUTOMATIC 
) [inline, virtual]

call init with n_local = N,

Implements libMesh::NumericVector< T >.

Definition at line 556 of file laspack_vector.h.

References libMesh::LaspackVector< T >::init().

00559 {
00560   this->init(n,n,fast,ptype);
00561 }

template<typename T>
void libMesh::LaspackVector< T >::init ( const numeric_index_type  N,
const numeric_index_type  n_local,
const bool  fast = false,
const ParallelType  ptype = AUTOMATIC 
) [virtual]

Change the dimension of the vector to N. The reserved memory for this vector remains unchanged if possible, to make things faster, but this may waste some memory, so take this in the back of your head. However, if N==0 all memory is freed, i.e. if you want to resize the vector and release the memory not needed, you have to first call init(0) and then init(N). This cited behaviour is analogous to that of the STL containers.

On fast==false, the vector is filled by zeros.

Implements libMesh::NumericVector< T >.

Referenced by libMesh::LaspackVector< T >::init(), and libMesh::LaspackVector< T >::LaspackVector().

template<typename T>
virtual bool libMesh::NumericVector< T >::initialized (  )  const [inline, virtual, inherited]
Returns:
true if the vector has been initialized, false otherwise.

Definition at line 111 of file numeric_vector.h.

Referenced by libMesh::PetscVector< T >::_get_array(), libMesh::PetscVector< T >::_restore_array(), libMesh::LaspackVector< T >::abs(), libMesh::DistributedVector< T >::abs(), libMesh::LaspackVector< T >::add(), libMesh::DistributedVector< T >::add(), libMesh::DistributedVector< T >::add_vector(), libMesh::ImplicitSystem::assemble(), libMesh::EpetraVector< T >::clear(), libMesh::PetscVector< T >::clear(), libMesh::LaspackVector< T >::clear(), libMesh::EpetraVector< T >::close(), libMesh::LaspackVector< T >::close(), libMesh::DistributedVector< T >::close(), libMesh::NumericVector< T >::compare(), libMesh::PetscVector< T >::create_subvector(), libMesh::LaspackVector< T >::dot(), libMesh::EpetraVector< T >::first_local_index(), libMesh::PetscVector< T >::first_local_index(), libMesh::LaspackVector< T >::first_local_index(), libMesh::DistributedVector< T >::first_local_index(), libMesh::NumericVector< T >::global_relative_compare(), libMesh::PetscVector< T >::init(), libMesh::DistributedVector< T >::init(), libMesh::DistributedVector< T >::insert(), libMesh::DistributedVector< T >::l1_norm(), libMesh::DistributedVector< T >::l2_norm(), libMesh::EpetraVector< T >::last_local_index(), libMesh::PetscVector< T >::last_local_index(), libMesh::LaspackVector< T >::last_local_index(), libMesh::DistributedVector< T >::last_local_index(), libMesh::DistributedVector< T >::linfty_norm(), libMesh::NumericVector< T >::local_relative_compare(), libMesh::EpetraVector< T >::local_size(), libMesh::PetscVector< T >::local_size(), libMesh::LaspackVector< T >::local_size(), libMesh::DistributedVector< T >::local_size(), libMesh::DistributedVector< T >::localize(), libMesh::DistributedVector< T >::localize_to_one(), libMesh::PetscVector< T >::map_global_to_local_index(), libMesh::EpetraVector< T >::max(), libMesh::LaspackVector< T >::max(), libMesh::DistributedVector< T >::max(), libMesh::EpetraVector< T >::min(), libMesh::LaspackVector< T >::min(), libMesh::DistributedVector< T >::min(), libMesh::EpetraVector< T >::operator()(), libMesh::LaspackVector< T >::operator()(), libMesh::DistributedVector< T >::operator()(), libMesh::DistributedVector< T >::operator+=(), libMesh::DistributedVector< T >::operator-=(), libMesh::LaspackVector< T >::operator=(), libMesh::DistributedVector< T >::operator=(), libMesh::NumericVector< T >::print(), libMesh::NumericVector< T >::print_global(), libMesh::LaspackVector< T >::scale(), libMesh::DistributedVector< T >::scale(), libMesh::LaspackVector< T >::set(), libMesh::DistributedVector< T >::set(), libMesh::EpetraVector< T >::size(), libMesh::PetscVector< T >::size(), libMesh::LaspackVector< T >::size(), libMesh::DistributedVector< T >::size(), libMesh::DistributedVector< T >::sum(), libMesh::EpetraVector< T >::zero(), libMesh::LaspackVector< T >::zero(), and libMesh::DistributedVector< T >::zero().

00111 { return _is_initialized; }

template<typename T>
virtual void libMesh::NumericVector< T >::insert ( const NumericVector< T > &  V,
const std::vector< numeric_index_type > &  dof_indices 
) [pure virtual, inherited]

$U=V$, where U and V are type NumericVector<T> and you want to specify WHERE to insert the NumericVector<T> V

template<typename T >
void libMesh::LaspackVector< T >::insert ( const DenseSubVector< T > &  V,
const std::vector< numeric_index_type > &  dof_indices 
) [inline, virtual]

$ U=V $ where V is type DenseSubVector<T> and you want to specify WHERE to insert it

Implements libMesh::NumericVector< T >.

Definition at line 249 of file laspack_vector.C.

References libMesh::DenseVectorBase< T >::size().

00251 {
00252   libmesh_assert_equal_to (V.size(), dof_indices.size());
00253 
00254   for (unsigned int i=0; i<V.size(); i++)
00255     this->set (dof_indices[i], V(i));
00256 }

template<typename T >
void libMesh::LaspackVector< T >::insert ( const DenseVector< T > &  V,
const std::vector< numeric_index_type > &  dof_indices 
) [inline, virtual]

$ U=V $ where V is type DenseVector<T> and you want to specify WHERE to insert it

Implements libMesh::NumericVector< T >.

Definition at line 237 of file laspack_vector.C.

References libMesh::DenseVector< T >::size().

00239 {
00240   libmesh_assert_equal_to (V.size(), dof_indices.size());
00241 
00242   for (unsigned int i=0; i<V.size(); i++)
00243     this->set (dof_indices[i], V(i));
00244 }

template<typename T >
void libMesh::LaspackVector< T >::insert ( const NumericVector< T > &  V,
const std::vector< numeric_index_type > &  dof_indices 
) [inline, virtual]

$U=V$, where U and V are type NumericVector<T> and you want to specify WHERE to insert the NumericVector<T> V

Definition at line 225 of file laspack_vector.C.

References libMesh::NumericVector< T >::size().

00227 {
00228   libmesh_assert_equal_to (V.size(), dof_indices.size());
00229 
00230   for (numeric_index_type i=0; i<V.size(); i++)
00231    this->set (dof_indices[i], V(i));
00232 }

template<typename T >
void libMesh::LaspackVector< T >::insert ( const std::vector< T > &  v,
const std::vector< numeric_index_type > &  dof_indices 
) [inline, virtual]

$ U=v $ where v is a DenseVector<T> and you want to specify WHERE to insert it

Implements libMesh::NumericVector< T >.

Definition at line 212 of file laspack_vector.C.

00214 {
00215   libmesh_assert (!v.empty());
00216   libmesh_assert_equal_to (v.size(), dof_indices.size());
00217 
00218   for (numeric_index_type i=0; i<v.size(); i++)
00219     this->set (dof_indices[i], v[i]);
00220 }

template<typename T >
Real libMesh::LaspackVector< T >::l1_norm (  )  const [inline, virtual]
Returns:
the $l_1$-norm of the vector, i.e. the sum of the absolute values.

Implements libMesh::NumericVector< T >.

Definition at line 54 of file laspack_vector.C.

References libMesh::LaspackVector< T >::_vec, libMesh::NumericVector< T >::closed(), and libMesh::Real.

00055 {
00056   libmesh_assert (this->closed());
00057 
00058   return static_cast<Real>(l1Norm_V(const_cast<QVector*>(&_vec)));
00059 }

template<typename T >
Real libMesh::LaspackVector< T >::l2_norm (  )  const [inline, virtual]
Returns:
the $l_2$-norm of the vector, i.e. the square root of the sum of the squares of the elements.

Implements libMesh::NumericVector< T >.

Definition at line 64 of file laspack_vector.C.

References libMesh::LaspackVector< T >::_vec, libMesh::NumericVector< T >::closed(), and libMesh::Real.

00065 {
00066   libmesh_assert (this->closed());
00067 
00068   return static_cast<Real>(l2Norm_V(const_cast<QVector*>(&_vec)));
00069 }

template<typename T >
numeric_index_type libMesh::LaspackVector< T >::last_local_index (  )  const [inline, virtual]
Returns:
the index of the last vector element actually stored on this processor

Implements libMesh::NumericVector< T >.

Definition at line 693 of file laspack_vector.h.

References libMesh::NumericVector< T >::initialized(), and libMesh::LaspackVector< T >::size().

Referenced by libMesh::LaspackVector< T >::operator()().

00694 {
00695   libmesh_assert (this->initialized());
00696 
00697   return this->size();
00698 }

template<typename T >
Real libMesh::LaspackVector< T >::linfty_norm (  )  const [inline, virtual]
Returns:
the maximum absolute value of the elements of this vector, which is the $l_\infty$-norm of a vector.

Implements libMesh::NumericVector< T >.

Definition at line 74 of file laspack_vector.C.

References libMesh::LaspackVector< T >::_vec, libMesh::NumericVector< T >::closed(), and libMesh::Real.

00075 {
00076   libmesh_assert (this->closed());
00077 
00078   return static_cast<Real>(MaxNorm_V(const_cast<QVector*>(&_vec)));
00079 }

template<typename T>
int libMesh::NumericVector< T >::local_relative_compare ( const NumericVector< T > &  other_vector,
const Real  threshold = TOLERANCE 
) const [inline, virtual, inherited]
Returns:
-1 when this is equivalent to other_vector, up to the given local relative threshold. When differences occur, the return value contains the first index where the difference (a[i]-b[i])/max(a[i],b[i]) exceeded the threshold. When no threshold is given, the libMesh TOLERANCE is used.

Definition at line 122 of file numeric_vector.C.

References std::abs(), libMesh::CommWorld, libMesh::NumericVector< T >::first_local_index(), libMesh::NumericVector< T >::initialized(), libMesh::NumericVector< T >::last_local_index(), std::max(), libMesh::NumericVector< T >::max(), and libMesh::Parallel::Communicator::min().

00124 {
00125   libmesh_assert (this->initialized());
00126   libmesh_assert (other_vector.initialized());
00127   libmesh_assert_equal_to (this->first_local_index(), other_vector.first_local_index());
00128   libmesh_assert_equal_to (this->last_local_index(), other_vector.last_local_index());
00129 
00130   int first_different_i = std::numeric_limits<int>::max();
00131   numeric_index_type i = first_local_index();
00132 
00133   do
00134     {
00135       if ( std::abs( (*this)(i) - other_vector(i) ) > threshold *
00136            std::max(std::abs((*this)(i)), std::abs(other_vector(i))))
00137         first_different_i = i;
00138       else
00139         i++;
00140     }
00141   while (first_different_i==std::numeric_limits<int>::max()
00142          && i<last_local_index());
00143 
00144   // Find the correct first differing index in parallel
00145   CommWorld.min(first_different_i);
00146 
00147   if (first_different_i == std::numeric_limits<int>::max())
00148     return -1;
00149 
00150   return first_different_i;
00151 }

template<typename T >
numeric_index_type libMesh::LaspackVector< T >::local_size (  )  const [inline, virtual]
Returns:
the local size of the vector (index_stop-index_start)

Implements libMesh::NumericVector< T >.

Definition at line 671 of file laspack_vector.h.

References libMesh::NumericVector< T >::initialized(), and libMesh::LaspackVector< T >::size().

00672 {
00673   libmesh_assert (this->initialized());
00674 
00675   return this->size();
00676 }

template<typename T>
virtual void libMesh::NumericVector< T >::localize ( NumericVector< T > &  v_local,
const std::vector< numeric_index_type > &  send_list 
) const [pure virtual, inherited]

Creates a local vector v_local containing only information relevant to this processor, as defined by the send_list.

template<typename T>
virtual void libMesh::NumericVector< T >::localize ( NumericVector< T > &  v_local  )  const [pure virtual, inherited]

Same, but fills a NumericVector<T> instead of a std::vector.

template<typename T>
void libMesh::LaspackVector< T >::localize ( const numeric_index_type  first_local_idx,
const numeric_index_type  last_local_idx,
const std::vector< numeric_index_type > &  send_list 
) [virtual]

Updates a local vector with selected values from neighboring processors, as defined by send_list.

Implements libMesh::NumericVector< T >.

template<typename T>
void libMesh::LaspackVector< T >::localize ( NumericVector< T > &  v_local,
const std::vector< numeric_index_type > &  send_list 
) const

Creates a local vector v_local containing only information relevant to this processor, as defined by the send_list.

template<typename T >
void libMesh::LaspackVector< T >::localize ( NumericVector< T > &  v_local  )  const [inline]

Same, but fills a NumericVector<T> instead of a std::vector.

Definition at line 393 of file laspack_vector.C.

00394 {
00395   // Make sure the NumericVector passed in is really a LaspackVector
00396   LaspackVector<T>* v_local =
00397     libmesh_cast_ptr<LaspackVector<T>*>(&v_local_in);
00398 
00399   libmesh_assert(v_local);
00400 
00401   *v_local = *this;
00402 }

template<typename T >
void libMesh::LaspackVector< T >::localize ( std::vector< T > &  v_local  )  const [inline, virtual]

Creates a copy of the global vector in the local vector v_local.

Implements libMesh::NumericVector< T >.

Definition at line 440 of file laspack_vector.C.

References libMesh::LaspackVector< T >::size().

00442 {
00443   v_local.resize(this->size());
00444 
00445   for (numeric_index_type i=0; i<v_local.size(); i++)
00446     v_local[i] = (*this)(i);
00447 }

template<typename T>
void libMesh::LaspackVector< T >::localize_to_one ( std::vector< T > &  v_local,
const processor_id_type  proc_id = 0 
) const [virtual]

Creates a local copy of the global vector in v_local only on processor proc_id. By default the data is sent to processor 0. This method is useful for outputting data from one processor.

Implements libMesh::NumericVector< T >.

template<typename T >
Real libMesh::LaspackVector< T >::max (  )  const [inline, virtual]
Returns:
the maximum element in the vector. In case of complex numbers, this returns the maximum Real part.

Implements libMesh::NumericVector< T >.

Definition at line 472 of file laspack_vector.C.

References libMesh::NumericVector< T >::initialized(), libMesh::libmesh_real(), std::max(), libMesh::Real, and libMesh::LaspackVector< T >::size().

Referenced by libMesh::LaspackVector< T >::min().

00473 {
00474   libmesh_assert (this->initialized());
00475   if (!this->size())
00476     return -std::numeric_limits<Real>::max();
00477 
00478   Real the_max = libmesh_real((*this)(0));
00479 
00480   const numeric_index_type n = this->size();
00481 
00482   for (numeric_index_type i=1; i<n; i++)
00483     the_max = std::max (the_max, libmesh_real((*this)(i)));
00484 
00485   return the_max;
00486 }

template<typename T >
Real libMesh::LaspackVector< T >::min (  )  const [inline, virtual]
Returns:
the minimum element in the vector. In case of complex numbers, this returns the minimum Real part.

Implements libMesh::NumericVector< T >.

Definition at line 491 of file laspack_vector.C.

References libMesh::NumericVector< T >::initialized(), libMesh::libmesh_real(), libMesh::LaspackVector< T >::max(), std::min(), libMesh::Real, and libMesh::LaspackVector< T >::size().

00492 {
00493   libmesh_assert (this->initialized());
00494   if (!this->size())
00495     return std::numeric_limits<Real>::max();
00496 
00497   Real the_min = libmesh_real((*this)(0));
00498 
00499   const numeric_index_type n = this->size();
00500 
00501   for (numeric_index_type i=1; i<n; i++)
00502     the_min = std::min (the_min, libmesh_real((*this)(i)));
00503 
00504   return the_min;
00505 }

static unsigned int libMesh::ReferenceCounter::n_objects (  )  [inline, static, inherited]

Prints the number of outstanding (created, but not yet destroyed) objects.

Definition at line 79 of file reference_counter.h.

References libMesh::ReferenceCounter::_n_objects.

00080   { return _n_objects; }

template<typename T >
T libMesh::LaspackVector< T >::operator() ( const numeric_index_type  i  )  const [inline, virtual]

Access components, returns U(i).

Implements libMesh::NumericVector< T >.

Definition at line 736 of file laspack_vector.h.

References libMesh::LaspackVector< T >::_vec, libMesh::LaspackVector< T >::first_local_index(), libMesh::NumericVector< T >::initialized(), and libMesh::LaspackVector< T >::last_local_index().

00737 {
00738   libmesh_assert (this->initialized());
00739   libmesh_assert ( ((i >= this->first_local_index()) &&
00740             (i <  this->last_local_index())) );
00741 
00742 
00743   return static_cast<T>(V_GetCmp(const_cast<QVector*>(&_vec), i+1));
00744 }

template<typename T>
NumericVector<T>& libMesh::NumericVector< T >::operator*= ( const T  a  )  [inline, inherited]

Multiplication operator. Equivalent to U.scale(a)

Definition at line 350 of file numeric_vector.h.

00350 { this->scale(a); return *this; }

template<typename T>
virtual NumericVector<T>& libMesh::NumericVector< T >::operator+= ( const NumericVector< T > &  V  )  [pure virtual, inherited]

Addition operator. Fast equivalent to U.add(1, V).

template<typename T >
NumericVector< T > & libMesh::LaspackVector< T >::operator+= ( const NumericVector< T > &  V  )  [inline]

Addition operator. Fast equivalent to U.add(1, V).

Definition at line 84 of file laspack_vector.C.

References libMesh::LaspackVector< T >::add(), and libMesh::NumericVector< T >::closed().

00085 {
00086   libmesh_assert (this->closed());
00087 
00088   this->add(1., v);
00089 
00090   return *this;
00091 }

template<typename T>
virtual NumericVector<T>& libMesh::NumericVector< T >::operator-= ( const NumericVector< T > &  V  )  [pure virtual, inherited]

Subtraction operator. Fast equivalent to U.add(-1, V).

template<typename T >
NumericVector< T > & libMesh::LaspackVector< T >::operator-= ( const NumericVector< T > &  V  )  [inline]

Subtraction operator. Fast equivalent to U.add(-1, V).

Definition at line 97 of file laspack_vector.C.

References libMesh::LaspackVector< T >::add(), and libMesh::NumericVector< T >::closed().

00098 {
00099   libmesh_assert (this->closed());
00100 
00101   this->add(-1., v);
00102 
00103   return *this;
00104 }

template<typename T>
NumericVector<T>& libMesh::NumericVector< T >::operator/= ( const T  a  )  [inline, inherited]

Division operator. Equivalent to U.scale(1./a)

Definition at line 356 of file numeric_vector.h.

00356 { this->scale(1./a); return *this; }

template<typename T >
NumericVector< T > & libMesh::LaspackVector< T >::operator= ( const std::vector< T > &  v  )  [inline, virtual]

$U = V$: copy all components.

Case 1: The vector is the same size of The global vector. Only add the local components.

Implements libMesh::NumericVector< T >.

Definition at line 375 of file laspack_vector.C.

References libMesh::LaspackVector< T >::size().

00376 {
00381   if (this->size() == v.size())
00382     for (numeric_index_type i=0; i<v.size(); i++)
00383       this->set (i, v[i]);
00384 
00385   else
00386     libmesh_error();
00387 
00388   return *this;
00389 }

template<typename T >
LaspackVector< T > & libMesh::LaspackVector< T >::operator= ( const LaspackVector< T > &  V  )  [inline, virtual]

$U = V$: copy all components.

Implements libMesh::NumericVector< T >.

Definition at line 353 of file laspack_vector.C.

References libMesh::NumericVector< T >::_is_closed, libMesh::LaspackVector< T >::_vec, libMesh::NumericVector< T >::closed(), libMesh::NumericVector< T >::initialized(), and libMesh::LaspackVector< T >::size().

00354 {
00355   libmesh_assert (this->initialized());
00356   libmesh_assert (v.closed());
00357   libmesh_assert_equal_to (this->size(), v.size());
00358 
00359   if (v.size() != 0)
00360     Asgn_VV (const_cast<QVector*>(&_vec),
00361              const_cast<QVector*>(&v._vec)
00362              );
00363 
00364 #ifndef NDEBUG
00365   this->_is_closed = true;
00366 #endif
00367 
00368   return *this;
00369 }

template<typename T >
NumericVector< T > & libMesh::LaspackVector< T >::operator= ( const NumericVector< T > &  V  )  [inline]

$U = V$: copy all components.

Definition at line 336 of file laspack_vector.C.

00337 {
00338   // Make sure the NumericVector passed in is really a LaspackVector
00339   const LaspackVector<T>* v =
00340     libmesh_cast_ptr<const LaspackVector<T>*>(&v_in);
00341 
00342   libmesh_assert(v);
00343 
00344   *this = *v;
00345 
00346   return *this;
00347 }

template<typename T >
NumericVector< T > & libMesh::LaspackVector< T >::operator= ( const T  s  )  [inline, virtual]

$U(0-N) = s$: fill all components.

Implements libMesh::NumericVector< T >.

Definition at line 322 of file laspack_vector.C.

References libMesh::LaspackVector< T >::_vec, libMesh::NumericVector< T >::closed(), and libMesh::NumericVector< T >::initialized().

00323 {
00324   libmesh_assert (this->initialized());
00325   libmesh_assert (this->closed());
00326 
00327   V_SetAllCmp (&_vec, s);
00328 
00329   return *this;
00330 }

template<typename T>
virtual void libMesh::NumericVector< T >::pointwise_mult ( const NumericVector< T > &  vec1,
const NumericVector< T > &  vec2 
) [pure virtual, inherited]

Computes the pointwise (i.e. component-wise) product of vec1 and vec2 and stores the result in *this.

Referenced by libMesh::TensorShellMatrix< T >::get_diagonal().

template<typename T >
void libMesh::LaspackVector< T >::pointwise_mult ( const NumericVector< T > &  vec1,
const NumericVector< T > &  vec2 
) [inline, virtual]

Computes the pointwise (i.e. component-wise) product of vec1 and vec2 and stores the result in *this.

Definition at line 463 of file laspack_vector.C.

00465 {
00466   libmesh_not_implemented();
00467 }

template<>
void libMesh::NumericVector< Complex >::print ( std::ostream &  os  )  const [inline, inherited]

Definition at line 777 of file numeric_vector.h.

References libMesh::NumericVector< T >::first_local_index(), libMesh::NumericVector< T >::initialized(), libMesh::NumericVector< T >::last_local_index(), libMesh::NumericVector< T >::local_size(), and libMesh::NumericVector< T >::size().

00778 {
00779   libmesh_assert (this->initialized());
00780   os << "Size\tglobal =  " << this->size()
00781      << "\t\tlocal =  " << this->local_size() << std::endl;
00782 
00783   // std::complex<>::operator<<() is defined, but use this form
00784   os << "#\tReal part\t\tImaginary part" << std::endl;
00785   for (numeric_index_type i=this->first_local_index(); i<this->last_local_index(); i++)
00786     os << i << "\t"
00787        << (*this)(i).real() << "\t\t"
00788        << (*this)(i).imag() << std::endl;
00789 }

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

Prints the local contents of the vector, by default to libMesh::out

Definition at line 795 of file numeric_vector.h.

References libMesh::NumericVector< T >::first_local_index(), libMesh::NumericVector< T >::initialized(), libMesh::NumericVector< T >::last_local_index(), libMesh::NumericVector< T >::local_size(), and libMesh::NumericVector< T >::size().

00796 {
00797   libmesh_assert (this->initialized());
00798   os << "Size\tglobal =  " << this->size()
00799      << "\t\tlocal =  " << this->local_size() << std::endl;
00800 
00801   os << "#\tValue" << std::endl;
00802   for (numeric_index_type i=this->first_local_index(); i<this->last_local_index(); i++)
00803     os << i << "\t" << (*this)(i) << std::endl;
00804 }

template<>
void libMesh::NumericVector< Complex >::print_global ( std::ostream &  os  )  const [inline, inherited]

Definition at line 810 of file numeric_vector.h.

References libMesh::NumericVector< T >::initialized(), libMesh::NumericVector< T >::localize(), libMesh::processor_id(), and libMesh::NumericVector< T >::size().

00811 {
00812   libmesh_assert (this->initialized());
00813 
00814   std::vector<Complex> v(this->size());
00815   this->localize(v);
00816 
00817   // Right now we only want one copy of the output
00818   if (libMesh::processor_id())
00819     return;
00820 
00821   os << "Size\tglobal =  " << this->size() << std::endl;
00822   os << "#\tReal part\t\tImaginary part" << std::endl;
00823   for (numeric_index_type i=0; i!=v.size(); i++)
00824     os << i << "\t"
00825        << v[i].real() << "\t\t"
00826        << v[i].imag() << std::endl;
00827 }

template<typename T >
void libMesh::NumericVector< T >::print_global ( std::ostream &  os = libMesh::out  )  const [inline, virtual, inherited]

Prints the global contents of the vector, by default to libMesh::out

Definition at line 832 of file numeric_vector.h.

References libMesh::NumericVector< T >::initialized(), libMesh::NumericVector< T >::localize(), libMesh::processor_id(), and libMesh::NumericVector< T >::size().

00833 {
00834   libmesh_assert (this->initialized());
00835 
00836   std::vector<T> v(this->size());
00837   this->localize(v);
00838 
00839   // Right now we only want one copy of the output
00840   if (libMesh::processor_id())
00841     return;
00842 
00843   os << "Size\tglobal =  " << this->size() << std::endl;
00844   os << "#\tValue" << std::endl;
00845   for (numeric_index_type i=0; i!=v.size(); i++)
00846     os << i << "\t" << v[i] << std::endl;
00847 }

void libMesh::ReferenceCounter::print_info ( std::ostream &  out = libMesh::out  )  [static, inherited]

Prints the reference information, by default to libMesh::out.

Definition at line 88 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter, and libMesh::ReferenceCounter::get_info().

00089 {
00090   if( _enable_print_counter ) out_stream << ReferenceCounter::get_info();
00091 }

template<typename T>
virtual void libMesh::NumericVector< T >::print_matlab ( const std::string  name = "NULL"  )  const [inline, virtual, inherited]

Print the contents of the matrix in Matlab's sparse matrix format. Optionally prints the matrix to the file named name. If name is not specified it is dumped to the screen.

Reimplemented in libMesh::PetscVector< T >, and libMesh::EpetraVector< T >.

Definition at line 595 of file numeric_vector.h.

00596   {
00597     libMesh::err << "ERROR: Not Implemented in base class yet!" << std::endl;
00598     libMesh::err << "ERROR writing MATLAB file " << name << std::endl;
00599     libmesh_error();
00600   }

template<typename T >
void libMesh::LaspackVector< T >::reciprocal (  )  [inline, virtual]

Replace each entry v_i of this vector by its reciprocal, 1/v_i.

Implements libMesh::NumericVector< T >.

Definition at line 109 of file laspack_vector.C.

References libMesh::LaspackVector< T >::size().

00110 {
00111   const numeric_index_type n = this->size();
00112 
00113   for (numeric_index_type i=0; i<n; i++)
00114     {
00115       T v = (*this)(i);
00116 
00117       // Don't divide by zero!
00118       libmesh_assert_not_equal_to (v, T(0));
00119 
00120       this->set(i, 1. / v);
00121     }
00122 }

template<typename T >
void libMesh::LaspackVector< T >::scale ( const T  factor  )  [inline, virtual]

Scale each element of the vector by the given factor.

Implements libMesh::NumericVector< T >.

Definition at line 287 of file laspack_vector.C.

References libMesh::LaspackVector< T >::_vec, and libMesh::NumericVector< T >::initialized().

00288 {
00289   libmesh_assert (this->initialized());
00290 
00291   Asgn_VV(&_vec, Mul_SV (factor, &_vec));
00292 }

template<typename T >
void libMesh::LaspackVector< T >::set ( const numeric_index_type  i,
const T  value 
) [inline, virtual]

v(i) = value

Implements libMesh::NumericVector< T >.

Definition at line 704 of file laspack_vector.h.

References libMesh::NumericVector< T >::_is_closed, libMesh::LaspackVector< T >::_vec, libMesh::NumericVector< T >::initialized(), and libMesh::LaspackVector< T >::size().

00705 {
00706   libmesh_assert (this->initialized());
00707   libmesh_assert_less (i, this->size());
00708 
00709   V_SetCmp (&_vec, i+1, value);
00710 
00711 #ifndef NDEBUG
00712   this->_is_closed = false;
00713 #endif
00714 }

template<typename T >
numeric_index_type libMesh::LaspackVector< T >::size (  )  const [inline, virtual]
template<class T >
Real libMesh::NumericVector< T >::subset_l1_norm ( const std::set< numeric_index_type > &  indices  )  const [inline, virtual, inherited]
Returns:
the $l_1$-norm of the vector, i.e. the sum of the absolute values for the specified entries in the vector.

Note that the indices must necessary live on this processor.

Definition at line 298 of file numeric_vector.C.

References std::abs(), libMesh::CommWorld, libMesh::Real, and libMesh::Parallel::Communicator::sum().

Referenced by libMesh::System::discrete_var_norm().

00299 {
00300   const NumericVector<T> & v = *this;
00301 
00302   std::set<numeric_index_type>::const_iterator it = indices.begin();
00303   const std::set<numeric_index_type>::const_iterator it_end = indices.end();
00304 
00305   Real norm = 0;
00306 
00307   for(; it!=it_end; ++it)
00308     norm += std::abs(v(*it));
00309 
00310   CommWorld.sum(norm);
00311 
00312   return norm;
00313 }

template<class T >
Real libMesh::NumericVector< T >::subset_l2_norm ( const std::set< numeric_index_type > &  indices  )  const [inline, virtual, inherited]
Returns:
the $l_2$-norm of the vector, i.e. the square root of the sum of the squares of the elements for the specified entries in the vector.

Note that the indices must necessary live on this processor.

Definition at line 316 of file numeric_vector.C.

References libMesh::CommWorld, libMesh::TensorTools::norm_sq(), libMesh::Real, and libMesh::Parallel::Communicator::sum().

Referenced by libMesh::System::discrete_var_norm().

00317 {
00318   const NumericVector<T> & v = *this;
00319 
00320   std::set<numeric_index_type>::const_iterator it = indices.begin();
00321   const std::set<numeric_index_type>::const_iterator it_end = indices.end();
00322 
00323   Real norm = 0;
00324 
00325   for(; it!=it_end; ++it)
00326     norm += TensorTools::norm_sq(v(*it));
00327 
00328   CommWorld.sum(norm);
00329 
00330   return std::sqrt(norm);
00331 }

template<class T >
Real libMesh::NumericVector< T >::subset_linfty_norm ( const std::set< numeric_index_type > &  indices  )  const [inline, virtual, inherited]
Returns:
the maximum absolute value of the specified entries of this vector, which is the $l_\infty$-norm of a vector.

Note that the indices must necessary live on this processor.

Definition at line 334 of file numeric_vector.C.

References libMesh::NumericVector< T >::abs(), libMesh::CommWorld, libMesh::Parallel::Communicator::max(), and libMesh::Real.

Referenced by libMesh::System::discrete_var_norm().

00335 {
00336   const NumericVector<T> & v = *this;
00337 
00338   std::set<numeric_index_type>::const_iterator it = indices.begin();
00339   const std::set<numeric_index_type>::const_iterator it_end = indices.end();
00340 
00341   Real norm = 0;
00342 
00343   for(; it!=it_end; ++it)
00344     {
00345       Real value = std::abs(v(*it));
00346       if(value > norm)
00347         norm = value;
00348     }
00349 
00350   CommWorld.max(norm);
00351 
00352   return norm;
00353 }

template<typename T >
T libMesh::LaspackVector< T >::sum (  )  const [inline, virtual]
Returns:
the sum of values in a vector

Implements libMesh::NumericVector< T >.

Definition at line 37 of file laspack_vector.C.

References libMesh::NumericVector< T >::closed(), and libMesh::LaspackVector< T >::size().

00038 {
00039   libmesh_assert (this->closed());
00040 
00041   T _sum = 0;
00042 
00043   const numeric_index_type n = this->size();
00044 
00045   for (numeric_index_type i=0; i!=n; ++i)
00046     _sum += (*this)(i);
00047 
00048   return _sum;
00049 }

template<typename T>
void libMesh::NumericVector< T >::swap ( NumericVector< T > &  v  )  [inline, virtual, inherited]

Exchanges the values/sizes of two vectors. There should be enough indirection in subclasses to make this an O(1) header-swap operation.

Definition at line 853 of file numeric_vector.h.

References libMesh::NumericVector< T >::_is_closed, libMesh::NumericVector< T >::_is_initialized, and libMesh::NumericVector< T >::_type.

Referenced by libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), and libMesh::AdjointRefinementEstimator::estimate_error().

00854 {
00855   std::swap(_is_closed, v._is_closed);
00856   std::swap(_is_initialized, v._is_initialized);
00857   std::swap(_type, v._type);
00858 }

template<typename T >
void libMesh::LaspackVector< T >::swap ( NumericVector< T > &  v  )  [inline, virtual]

Swaps the raw QVector contents.

Definition at line 750 of file laspack_vector.h.

References libMesh::LaspackVector< T >::_vec.

00751 {
00752   LaspackVector<T>& v = libmesh_cast_ref<LaspackVector<T>&>(other);
00753 
00754   // This is all grossly dependent on Laspack version...
00755 
00756   std::swap(_vec.Name, v._vec.Name);
00757   std::swap(_vec.Dim, v._vec.Dim);
00758   std::swap(_vec.Instance, v._vec.Instance);
00759   std::swap(_vec.LockLevel, v._vec.LockLevel);
00760   std::swap(_vec.Multipl, v._vec.Multipl);
00761   std::swap(_vec.OwnData, v._vec.OwnData);
00762 
00763   // This should still be O(1), since _vec.Cmp is just a pointer to
00764   // data on the heap
00765 
00766   std::swap(_vec.Cmp, v._vec.Cmp);
00767 }

template<typename T>
ParallelType& libMesh::NumericVector< T >::type (  )  [inline, inherited]
Returns:
the type (SERIAL, PARALLEL, GHOSTED) of the vector.

Definition at line 121 of file numeric_vector.h.

00121 { return _type; }

template<typename T >
void libMesh::LaspackVector< T >::zero (  )  [inline, virtual]

Set all entries to zero. Equivalent to v = 0, but more obvious and faster.

Implements libMesh::NumericVector< T >.

Definition at line 620 of file laspack_vector.h.

References libMesh::LaspackVector< T >::_vec, libMesh::NumericVector< T >::closed(), and libMesh::NumericVector< T >::initialized().

00621 {
00622   libmesh_assert (this->initialized());
00623   libmesh_assert (this->closed());
00624 
00625   V_SetAllCmp (&_vec, 0.);
00626 }

template<typename T >
AutoPtr< NumericVector< T > > libMesh::LaspackVector< T >::zero_clone (  )  const [inline, virtual]

Creates a vector which has the same type, size and partitioning as this vector, but whose data is all zero. Returns it in an AutoPtr.

Implements libMesh::NumericVector< T >.

Definition at line 632 of file laspack_vector.h.

00633 {
00634   AutoPtr<NumericVector<T> > cloned_vector (new LaspackVector<T>);
00635 
00636   cloned_vector->init(*this);
00637 
00638   return cloned_vector;
00639 }


Friends And Related Function Documentation

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

Make other Laspack datatypes friends

Definition at line 457 of file laspack_vector.h.

template<typename T>
std::ostream& operator<< ( std::ostream &  os,
const NumericVector< T > &  v 
) [friend, inherited]

Same as above but allows you to use stream syntax.

Definition at line 583 of file numeric_vector.h.

00584   {
00585     v.print_global(os);
00586     return os;
00587   }


Member Data Documentation

bool libMesh::ReferenceCounter::_enable_print_counter = true [static, protected, inherited]

Flag to control whether reference count information is printed when print_info is called.

Definition at line 137 of file reference_counter.h.

Referenced by libMesh::ReferenceCounter::disable_print_counter_info(), libMesh::ReferenceCounter::enable_print_counter_info(), and libMesh::ReferenceCounter::print_info().

Mutual exclusion object to enable thread-safe reference counting.

Definition at line 131 of file reference_counter.h.

Threads::atomic< unsigned int > libMesh::ReferenceCounter::_n_objects [static, protected, inherited]

The number of objects. Print the reference count information when the number returns to 0.

Definition at line 126 of file reference_counter.h.

Referenced by libMesh::ReferenceCounter::n_objects(), libMesh::ReferenceCounter::ReferenceCounter(), and libMesh::ReferenceCounter::~ReferenceCounter().


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

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

Hosted By:
SourceForge.net Logo