AlgebraicMultigrid 0.1
C++ algebraic multigrid.
Loading...
Searching...
No Matches
common.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <Eigen/Core>
4#include <Eigen/Sparse>
5
6namespace AMG {
7
17template <class EleType>
18EleType rss(const Eigen::SparseMatrix<EleType>& A,
19 const Eigen::Matrix<EleType, -1, 1>& u,
20 const Eigen::Matrix<EleType, -1, 1>& b) {
21 auto bhat = A * u;
22 EleType error = 0.0;
23 for (size_t i = 0; i < b.size(); ++i) {
24 error += (b[i] - bhat[i]) * (b[i] - bhat[i]);
25 }
26 return error;
27}
28
29} // end namespace AMG
Definition common.hpp:6
EleType rss(const Eigen::SparseMatrix< EleType > &A, const Eigen::Matrix< EleType, -1, 1 > &u, const Eigen::Matrix< EleType, -1, 1 > &b)
Return residual sum of squares of bhat from Au and rhs b.
Definition common.hpp:18