25#include "libmesh/dense_subvector.h"
26#include "libmesh/dense_vector.h"
27#include "libmesh/eigen_sparse_vector.h"
28#include "libmesh/eigen_sparse_matrix.h"
29#include "libmesh/int_range.h"
31#ifdef LIBMESH_HAVE_EIGEN
53 return _vec.lpNorm<1>();
64 return _vec.lpNorm<2>();
75 return _vec.lpNorm<Eigen::Infinity>();
113 libmesh_assert_equal_to(size(), v_in.
size());
117 _vec = _vec.cwiseProduct(v.
_vec);
128 libmesh_assert_equal_to(size(), v_in.
size());
132 _vec = _vec.cwiseQuotient(v.
_vec);
148 libmesh_assert_not_equal_to ((*
this)(i), T(0));
151 _vec = _vec.cwiseInverse();
159 _vec = _vec.conjugate();
167 _vec += EigenSV::Constant(this->size(), v);
208 _vec += mat->_mat*e_vec->
_vec;
224 _vec += mat->_mat.transpose()*e_vec->
_vec;
247 this->set(i,std::abs((*
this)(i)));
261 return _vec.dot(v->
_vec);
286 cast_ptr<const EigenSparseVector<T> *>(&v_in);
303 libmesh_assert_equal_to (this->size(), v.
size());
307 this->_is_closed =
true;
322 if (this->size() == v.size())
327 libmesh_error_msg(
"this->size() = " << this->size() <<
" must be equal to v.size() = " << v.size());
338 cast_ptr<EigenSparseVector<T> *>(&v_local_in);
349 const std::vector<numeric_index_type> & libmesh_dbg_var(send_list))
const
353 cast_ptr<EigenSparseVector<T> *>(&v_local_in);
356 libmesh_assert_less_equal (send_list.size(), v_local->
size());
365 const std::vector<numeric_index_type> & indices)
const
368 v_local.resize(indices.size());
371 v_local[i] = (*
this)(indices[i]);
379 const std::vector<numeric_index_type> & libmesh_dbg_var(send_list))
381 libmesh_assert_equal_to (first_local_idx, 0);
382 libmesh_assert_equal_to (last_local_idx+1, this->size());
384 libmesh_assert_less_equal (send_list.size(), this->size());
386 this->_is_closed =
true;
395 v_local.resize(this->size());
398 v_local[i] = (*
this)(i);
407 libmesh_assert_equal_to (pid, 0);
409 this->localize (v_local);
418 libmesh_not_implemented();
425 libmesh_not_implemented();
432 const std::vector<numeric_index_type> & rows,
442 eigen_subvector->
init(rows.size());
444 eigen_subvector->
vec() = this->vec()(rows);
452std::unique_ptr<NumericVector<T>>
455 auto returnval = std::make_unique<EigenSparseVector<T>>(this->comm(), rows.size());
460 this->create_subvector(*returnval, rows);
462 this->_is_closed =
false;
470 const std::vector<numeric_index_type> & rows)
472 auto *
const eigen_subvector = cast_ptr<EigenSparseVector<T> *>(subvector.get());
474 this->vec()(rows) = eigen_subvector->vec();
475 this->_is_closed =
true;
485 return -std::numeric_limits<Real>::max();
487#ifdef LIBMESH_USE_COMPLEX_NUMBERS
508 return std::numeric_limits<Real>::max();
510#ifdef LIBMESH_USE_COMPLEX_NUMBERS
The EigenSparseMatrix class wraps a sparse matrix object from the Eigen library.
This class provides a nice interface to the Eigen C++-based data structures for serial vectors.
virtual NumericVector< T > & operator+=(const NumericVector< T > &v) override
Adds v to *this, .
virtual void add_vector(const NumericVector< T > &v, const SparseMatrix< T > &A) override
Computes , i.e.
virtual T sum() const override
virtual void restore_subvector(std::unique_ptr< NumericVector< T > > subvector, const std::vector< numeric_index_type > &rows) override
Restores a view into this vector using the indices in rows.
virtual Real max() const override
virtual NumericVector< T > & operator-=(const NumericVector< T > &v) override
Subtracts v from *this, .
virtual T dot(const NumericVector< T > &v) const override
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.
DataType _vec
Actual Eigen::SparseVector<> we are wrapping.
virtual Real l2_norm() const override
virtual void add(const numeric_index_type i, const T value) override
Adds value to the vector entry specified by i.
virtual void conjugate() override
Negates the imaginary component of each entry in the vector.
virtual void add_vector_transpose(const NumericVector< T > &v, const SparseMatrix< T > &A) override
Computes , i.e.
virtual Real min() const override
virtual void pointwise_divide(const NumericVector< T > &vec1, const NumericVector< T > &vec2) override
Computes (summation not implied) i.e.
virtual std::unique_ptr< NumericVector< T > > get_subvector(const std::vector< numeric_index_type > &rows) override
Creates a view into this vector using the indices in rows.
virtual numeric_index_type size() const override
virtual NumericVector< T > & operator/=(const NumericVector< T > &v_in) override
Computes the component-wise division of this vector's entries by another's, .
virtual Real linfty_norm() const override
virtual void pointwise_mult(const NumericVector< T > &vec1, const NumericVector< T > &vec2) override
Computes (summation not implied) i.e.
virtual void init(const numeric_index_type N, const numeric_index_type n_local, const bool fast=false, const ParallelType ptype=AUTOMATIC) override
Change the dimension of the vector to n.
virtual Real l1_norm() const override
virtual NumericVector< T > & operator*=(const NumericVector< T > &v_in) override
Computes the component-wise multiplication of this vector's entries by another's, .
virtual void reciprocal() override
Computes the component-wise reciprocal, .
DataType & vec()
References to the underlying Eigen data types.
virtual void scale(const T factor) override
Scale each element of the vector by the given factor.
virtual void abs() override
Sets for each entry in the vector.
EigenSparseVector< T > & operator=(const EigenSparseVector< T > &v)
Copy assignment operator.
virtual void create_subvector(NumericVector< T > &subvector, const std::vector< numeric_index_type > &rows, bool supplying_global_rows=true) const override
Fills in subvector from this vector using the indices in rows.
virtual void localize(std::vector< T > &v_local) const override
Creates a copy of the global vector in the local vector v_local.
Provides a uniform interface to vector storage schemes for different linear algebra libraries.
virtual bool initialized() const
virtual numeric_index_type size() const =0
bool _is_closed
Flag which tracks whether the vector's values are consistent on all processors after insertion or add...
virtual bool closed() const
The libMesh namespace provides an interface to certain functionality in the library.
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
bool closed()
Checks that the library has been closed.
dof_id_type numeric_index_type
bool initialized()
Checks that library initialization has been done.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
uint8_t processor_id_type