25 #include "libmesh/dense_subvector.h" 26 #include "libmesh/dense_vector.h" 27 #include "libmesh/laspack_vector.h" 28 #include "libmesh/laspack_matrix.h" 29 #include "libmesh/int_range.h" 31 #ifdef LIBMESH_HAVE_LASPACK 58 return static_cast<Real>(l1Norm_V(const_cast<QVector*>(&_vec)));
68 return static_cast<Real>(l2Norm_V(const_cast<QVector*>(&_vec)));
78 return static_cast<Real>(MaxNorm_V(const_cast<QVector*>(&_vec)));
108 template <
typename T>
111 libmesh_assert_equal_to(size(), v.
size());
114 const bool was_closed = this->_is_closed;
120 this->
set(i, (*
this)(i) * v(i));
125 this->_is_closed = was_closed;
133 template <
typename T>
136 libmesh_assert_equal_to(size(), v.
size());
139 const bool was_closed = this->_is_closed;
145 this->
set(i, (*
this)(i) / v(i));
150 this->_is_closed = was_closed;
158 template <
typename T>
164 const bool was_closed = this->_is_closed;
172 libmesh_assert_not_equal_to (v, T(0));
174 this->
set(i, 1. / v);
180 this->_is_closed = was_closed;
186 template <
typename T>
192 const bool was_closed = this->_is_closed;
205 this->_is_closed = was_closed;
210 template <
typename T>
214 const bool was_closed = this->_is_closed;
225 this->_is_closed = was_closed;
232 template <
typename T>
240 template <
typename T>
244 const LaspackVector * v = cast_ptr<const LaspackVector *>(&v_in);
247 const bool was_closed = this->_is_closed;
251 libmesh_assert_equal_to (this->size(), v->
size());
254 this->add (i, a*(*v)(i));
257 this->_is_closed = was_closed;
263 template <
typename T>
275 AddAsgn_VV (&_vec, Mul_QV(const_cast<QMatrix*>(&mat->_QMat),
276 const_cast<QVector*>(&vec->
_vec)));
280 template <
typename T>
284 libmesh_not_implemented();
289 template <
typename T>
294 Asgn_VV(&_vec, Mul_SV (factor, &_vec));
297 template <
typename T>
305 this->
set(i,std::abs((*
this)(i)));
308 template <
typename T>
317 return Mul_VV (const_cast<QVector*>(&(this->_vec)),
318 const_cast<QVector*>(&(v->
_vec)));
323 template <
typename T>
330 V_SetAllCmp (&_vec, s);
337 template <
typename T>
343 cast_ptr<const LaspackVector<T> *>(&v_in);
354 template <
typename T>
360 libmesh_assert_equal_to (this->size(), v.
size());
363 Asgn_VV (const_cast<QVector*>(&_vec),
364 const_cast<QVector*
>(&v.
_vec)
368 this->_is_closed =
true;
376 template <
typename T>
384 if (this->size() == v.size())
389 libmesh_error_msg(
"this->size() = " << this->size() <<
" must be equal to v.size() = " << v.size());
395 template <
typename T>
400 cast_ptr<LaspackVector<T> *>(&v_local_in);
409 template <
typename T>
411 const std::vector<numeric_index_type> & libmesh_dbg_var(send_list))
const 415 cast_ptr<LaspackVector<T> *>(&v_local_in);
418 libmesh_assert_less_equal (send_list.size(), v_local->
size());
425 template <
typename T>
427 const std::vector<numeric_index_type> & indices)
const 430 v_local.resize(indices.size());
433 v_local[i] = (*
this)(indices[i]);
438 template <
typename T>
441 const std::vector<numeric_index_type> & libmesh_dbg_var(send_list))
443 libmesh_assert_equal_to (first_local_idx, 0);
444 libmesh_assert_equal_to (last_local_idx+1, this->size());
446 libmesh_assert_less_equal (send_list.size(), this->size());
449 this->_is_closed =
true;
455 template <
typename T>
459 v_local.resize(this->size());
462 v_local[i] = (*this)(i);
467 template <
typename T>
471 libmesh_assert_equal_to (pid, 0);
473 this->localize (v_local);
478 template <
typename T>
482 libmesh_not_implemented();
485 template <
typename T>
489 libmesh_not_implemented();
492 template <
typename T>
497 return -std::numeric_limits<Real>::max();
511 template <
typename T>
516 return std::numeric_limits<Real>::max();
536 #endif // #ifdef LIBMESH_HAVE_LASPACK
virtual void add_vector(const NumericVector< T > &v, const SparseMatrix< T > &A) override
Computes , i.e.
bool closed()
Checks that the library has been closed.
virtual numeric_index_type size() const override
virtual NumericVector< T > & operator-=(const NumericVector< T > &v) override
Subtracts v from *this, .
virtual void abs() override
Sets for each entry in the vector.
virtual void scale(const T factor) override
Scale each element of the vector by the given factor.
virtual void add_vector_transpose(const NumericVector< T > &v, const SparseMatrix< T > &A) override
Computes , i.e.
virtual T dot(const NumericVector< T > &v) const override
virtual numeric_index_type size() const =0
LaspackVector< T > & operator=(const LaspackVector< T > &v)
Copy assignment operator.
virtual void pointwise_mult(const NumericVector< T > &vec1, const NumericVector< T > &vec2) override
Computes (summation not implied) i.e.
Provides a uniform interface to vector storage schemes for different linear algebra libraries...
The libMesh namespace provides an interface to certain functionality in the library.
virtual NumericVector< T > & operator+=(const NumericVector< T > &v) override
Adds v to *this, .
virtual NumericVector< T > & operator*=(const NumericVector< T > &v) override
Computes the component-wise multiplication of this vector's entries by another's, ...
uint8_t processor_id_type
virtual Real max() const override
virtual Real l2_norm() const override
dof_id_type numeric_index_type
virtual void add(const numeric_index_type i, const T value) override
Adds value to the vector entry specified by i.
virtual Real min() const override
virtual void localize(std::vector< T > &v_local) const override
Creates a copy of the global vector in the local vector v_local.
virtual void localize_to_one(std::vector< T > &v_local, const processor_id_type proc_id=0) const override
Creates a local copy of the global vector in v_local only on processor proc_id.
virtual bool closed() const
This class provides a nice interface to the Laspack C-based data structures for serial vectors...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual void conjugate() override
Negates the imaginary component of each entry in the vector.
virtual Real linfty_norm() const override
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
bool initialized()
Checks that library initialization has been done.
virtual NumericVector< T > & operator/=(const NumericVector< T > &v) override
Computes the component-wise division of this vector's entries by another's, .
virtual T sum() const override
QVector _vec
Actual Laspack vector datatype to hold vector entries.
The LaspackMatrix class wraps a QMatrix object from the Laspack library.
virtual void reciprocal() override
Computes the component-wise reciprocal, .
virtual Real l1_norm() const override
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
virtual void pointwise_divide(const NumericVector< T > &vec1, const NumericVector< T > &vec2) override
Computes (summation not implied) i.e.