1 #ifndef DENSE_GEN_COMPLEX_SHIFT_SOLVE_H
2 #define DENSE_GEN_COMPLEX_SHIFT_SOLVE_H
16 template <
typename Scalar>
20 typedef Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> Matrix;
21 typedef Eigen::Map<const Matrix> MapMat;
22 typedef Eigen::Map< Eigen::Matrix<Scalar, Eigen::Dynamic, 1> > MapVec;
24 typedef std::complex<Scalar> Complex;
25 typedef Eigen::Matrix<Complex, Eigen::Dynamic, Eigen::Dynamic> ComplexMatrix;
26 typedef Eigen::Matrix<Complex, Eigen::Dynamic, 1> ComplexVector;
27 typedef Eigen::PartialPivLU<ComplexMatrix> ComplexSolver;
29 typedef const Eigen::Ref<const Matrix> ConstGenericMatrix;
34 ComplexVector x_cache;
46 mat(mat_.data(), mat_.
rows(), mat_.
cols()),
49 if(mat_.rows() != mat_.cols())
50 throw std::invalid_argument(
"DenseGenComplexShiftSolve: matrix must be square");
56 int rows() {
return dim_n; }
60 int cols() {
return dim_n; }
70 ComplexMatrix cmat = mat.template cast<Complex>();
71 cmat.diagonal().array() -= Complex(sigmar, sigmai);
73 x_cache.resize(dim_n);
87 x_cache.real() = MapVec(x_in, dim_n);
88 MapVec y(y_out, dim_n);
89 y.noalias() = solver.solve(x_cache).real();
94 #endif // DENSE_GEN_COMPLEX_SHIFT_SOLVE_H
void perform_op(Scalar *x_in, Scalar *y_out)
DenseGenComplexShiftSolve(ConstGenericMatrix &mat_)
void set_shift(Scalar sigmar, Scalar sigmai)