16#ifndef dealii_lac_utilities_h
17#define dealii_lac_utilities_h
64 template <
typename NumberType>
65 std::array<NumberType, 3>
94 template <
typename NumberType>
95 std::array<NumberType, 3>
133 template <
typename OperatorType,
typename VectorType>
136 const VectorType &
v0,
137 const unsigned int k,
188 template <
typename OperatorType,
typename VectorType>
192 const unsigned int n,
208 namespace UtilitiesImplementation
215 template <
typename Number>
232 template <
typename NumberType>
233 std::array<std::complex<NumberType>, 3>
235 const std::complex<NumberType> & )
238 std::array<NumberType, 3>
res;
244 template <
typename NumberType>
245 std::array<NumberType, 3>
249 const NumberType
tau =
g / f;
252 "real-valued Hyperbolic rotation does not exist for (" +
253 std::to_string(f) +
"," + std::to_string(
g) +
")"));
257 std::array<NumberType, 3>
csr;
266 template <
typename NumberType>
267 std::array<std::complex<NumberType>, 3>
269 const std::complex<NumberType> & )
272 std::array<NumberType, 3>
res;
278 template <
typename NumberType>
279 std::array<NumberType, 3>
282 std::array<NumberType, 3>
res;
296 if (
g == NumberType())
298 res[0] = std::copysign(1., f);
299 res[1] = NumberType();
302 else if (f == NumberType())
304 res[0] = NumberType();
305 res[1] = std::copysign(1.,
g);
310 const NumberType
tau =
g / f;
318 const NumberType
tau = f /
g;
330 template <
typename OperatorType,
typename VectorType>
333 const VectorType &
v0_,
334 const unsigned int k,
355 double a = v->l2_norm();
366 for (
unsigned int i = 1; i <
k; ++i)
369 const double b = f->l2_norm();
392 std::vector<double>
Z;
394 std::vector<double> work;
422 template <
typename OperatorType,
typename VectorType>
426 const unsigned int degree,
439 "Lower bound of the unwanted spectrum should be smaller than the upper bound."));
443 "Scaling point should be outside of the unwanted spectrum."));
453 VectorType &
y = *
p_y;
469 const double e = (
b - a) / 2.;
470 const double c = (a +
b) / 2.;
471 const double alpha = 1. /
e;
472 const double beta = -c /
e;
481 for (
unsigned int i = 2; i <= degree; ++i)
value_type * data() const noexcept
void reinit(value_type *starting_element, const std::size_t n_elements)
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcNotImplemented()
static ::ExceptionBase & ExcErrorCode(std::string arg1, types::blas_int arg2)
#define Assert(cond, exc)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcDivideByZero()
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
@ diagonal
Matrix is diagonal.
SymmetricTensor< 2, dim, Number > e(const Tensor< 2, dim, Number > &F)
SymmetricTensor< 2, dim, Number > b(const Tensor< 2, dim, Number > &F)
void chebyshev_filter(VectorType &x, const OperatorType &H, const unsigned int n, const std::pair< double, double > unwanted_spectrum, const double tau, VectorMemory< VectorType > &vector_memory)
std::array< NumberType, 3 > givens_rotation(const NumberType &x, const NumberType &y)
std::array< NumberType, 3 > hyperbolic_rotation(const NumberType &x, const NumberType &y)
double lanczos_largest_eigenvalue(const OperatorType &H, const VectorType &v0, const unsigned int k, VectorMemory< VectorType > &vector_memory, std::vector< double > *eigenvalues=nullptr)
void call_stev(const char jobz, const types::blas_int n, Number *d, Number *e, Number *z, const types::blas_int ldz, Number *work, types::blas_int *info)
bool is_finite(const double x)
::VectorizedArray< Number, width > sqrt(const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > abs(const ::VectorizedArray< Number, width > &)
std::array< Number, 1 > eigenvalues(const SymmetricTensor< 2, 1, Number > &T)