25 #ifdef LIBMESH_HAVE_EIGEN 49 libmesh_assert_equal_to (m_in, m_l);
50 libmesh_assert_equal_to (n_in, n_l);
51 libmesh_assert_equal_to (m_in, n_in);
52 libmesh_assert_greater (nnz, 0);
54 _mat.resize(m_in, n_in);
55 _mat.reserve(Eigen::Matrix<numeric_index_type, Eigen::Dynamic, 1>::Constant(m_in,nnz));
70 libmesh_assert(this->_dof_map);
87 libmesh_assert_equal_to (n_rows, n_cols);
88 libmesh_assert_equal_to (m_l, n_rows);
89 libmesh_assert_equal_to (n_l, n_cols);
91 const std::vector<numeric_index_type> & n_nz = this->_dof_map->get_n_nz();
96 const std::vector<numeric_index_type> & n_oz = this->_dof_map->get_n_oz();
100 libmesh_assert_equal_to (n_nz.size(), n_l);
101 libmesh_assert_equal_to (n_oz.size(), n_l);
109 _mat.resize(n_rows,n_cols);
114 libmesh_assert_equal_to (n_rows, this->m());
115 libmesh_assert_equal_to (n_cols, this->n());
120 template <
typename T>
122 const std::vector<numeric_index_type> & rows,
123 const std::vector<numeric_index_type> & cols)
127 unsigned int n_rows = cast_int<unsigned int>(rows.size());
128 unsigned int n_cols = cast_int<unsigned int>(cols.size());
129 libmesh_assert_equal_to (dm.
m(), n_rows);
130 libmesh_assert_equal_to (dm.
n(), n_cols);
133 for (
unsigned int i=0; i<n_rows; i++)
134 for (
unsigned int j=0; j<n_cols; j++)
135 this->add(rows[i],cols[j],dm(i,j));
140 template <
typename T>
145 dest.
_vec = _mat.diagonal();
150 template <
typename T>
155 dest.
_mat = _mat.transpose();
160 template <
typename T>
169 template <
typename T>
180 template <
typename T>
188 template <
typename T>
193 return cast_int<numeric_index_type>(_mat.rows());
198 template <
typename T>
203 return cast_int<numeric_index_type>(_mat.cols());
208 template <
typename T>
216 template <
typename T>
224 template <
typename T>
230 libmesh_assert_less (i, this->m());
231 libmesh_assert_less (j, this->n());
233 _mat.coeffRef(i,j) =
value;
238 template <
typename T>
244 libmesh_assert_less (i, this->m());
245 libmesh_assert_less (j, this->n());
247 _mat.coeffRef(i,j) +=
value;
252 template <
typename T>
254 const std::vector<numeric_index_type> & dof_indices)
256 this->add_matrix (dm, dof_indices, dof_indices);
261 template <
typename T>
265 libmesh_assert_equal_to (this->m(), X_in.
m());
266 libmesh_assert_equal_to (this->n(), X_in.
n());
269 cast_ref<const EigenSparseMatrix<T> &> (X_in);
277 template <
typename T>
282 libmesh_assert_less (i, this->m());
283 libmesh_assert_less (j, this->n());
285 return _mat.coeff(i,j);
290 template <
typename T>
297 std::vector<Real> abs_col_sums(this->n());
301 for (
unsigned row=0; row<this->m(); ++row)
303 EigenSM::InnerIterator it(_mat, row);
305 abs_col_sums[it.col()] +=
std::abs(it.value());
308 return *(std::max_element(abs_col_sums.begin(), abs_col_sums.end()));
313 template <
typename T>
316 Real max_abs_row_sum = 0.;
320 for (
unsigned row=0; row<this->m(); ++row)
322 Real current_abs_row_sum = 0.;
323 EigenSM::InnerIterator it(_mat, row);
325 current_abs_row_sum +=
std::abs(it.value());
327 max_abs_row_sum =
std::max(max_abs_row_sum, current_abs_row_sum);
330 return max_abs_row_sum;
341 #endif // #ifdef LIBMESH_HAVE_EIGEN
virtual void set(const numeric_index_type i, const numeric_index_type j, const T value) override
virtual void init() override
virtual void add(const numeric_index_type i, const numeric_index_type j, const T value) override
virtual numeric_index_type m() const override
virtual numeric_index_type row_stop() const override
Provides a uniform interface to vector storage schemes for different linear algebra libraries...
long double max(long double a, double b)
virtual void get_transpose(SparseMatrix< T > &dest) const override
virtual void zero() override
virtual numeric_index_type n() const override
virtual void get_diagonal(NumericVector< T > &dest) const override
dof_id_type numeric_index_type
EigenSparseMatrix(const Parallel::Communicator &comm)
virtual numeric_index_type m() const =0
virtual T operator()(const numeric_index_type i, const numeric_index_type j) const override
virtual numeric_index_type row_start() const override
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual Real linfty_norm() const override
virtual void clear() override
virtual Real l1_norm() const override
A matrix object used for finite element assembly and numerics.
virtual numeric_index_type n() const =0
virtual void add_matrix(const DenseMatrix< T > &dm, const std::vector< numeric_index_type > &rows, const std::vector< numeric_index_type > &cols) override