16 #ifndef dealii_precondition_block_base_h
17 #define dealii_precondition_block_base_h
36 template <
typename number>
38 template <
typename number>
60 template <
typename number>
113 reinit(
unsigned int nblocks,
151 template <
typename number2>
154 Vector<number2> & dst,
155 const Vector<number2> &src)
const;
160 template <
typename number2>
163 Vector<number2> & dst,
164 const Vector<number2> &src)
const;
305 template <
typename number>
309 , n_diagonal_blocks(0)
310 , var_store_diagonals(store)
311 , var_same_diagonal(false)
312 , var_inverses_ready(false)
316 template <
typename number>
320 if (var_inverse_full.size() != 0)
321 var_inverse_full.erase(var_inverse_full.begin(), var_inverse_full.end());
322 if (var_inverse_householder.size() != 0)
323 var_inverse_householder.erase(var_inverse_householder.begin(),
324 var_inverse_householder.end());
325 if (var_inverse_svd.size() != 0)
326 var_inverse_svd.erase(var_inverse_svd.begin(), var_inverse_svd.end());
327 if (var_diagonal.size() != 0)
328 var_diagonal.erase(var_diagonal.begin(), var_diagonal.end());
329 var_same_diagonal =
false;
330 var_inverses_ready =
false;
331 n_diagonal_blocks = 0;
334 template <
typename number>
343 var_inverses_ready =
false;
344 n_diagonal_blocks = n;
351 var_inverse_full.resize(1);
352 var_inverse_full[0].reinit(
b,
b);
355 var_inverse_householder.resize(1);
358 var_inverse_svd.resize(1);
359 var_inverse_svd[0].reinit(
b,
b);
365 if (store_diagonals())
367 var_diagonal.resize(1);
368 var_diagonal[0].reinit(
b,
b);
381 if (store_diagonals())
384 var_diagonal.swap(tmp);
392 var_inverse_full.swap(tmp);
396 var_inverse_householder.resize(n);
400 std::vector<LAPACKFullMatrix<number>> tmp(
402 var_inverse_svd.swap(tmp);
412 template <
typename number>
416 return n_diagonal_blocks;
419 template <
typename number>
420 template <
typename number2>
423 Vector<number2> & dst,
424 const Vector<number2> &src)
const
426 const size_type ii = same_diagonal() ? 0
U : i;
432 var_inverse_full[ii].vmult(dst, src);
436 var_inverse_householder[ii].vmult(dst, src);
440 var_inverse_svd[ii].vmult(dst, src);
448 template <
typename number>
449 template <
typename number2>
452 Vector<number2> & dst,
453 const Vector<number2> &src)
const
455 const size_type ii = same_diagonal() ? 0
U : i;
461 var_inverse_full[ii].Tvmult(dst, src);
465 var_inverse_householder[ii].Tvmult(dst, src);
469 var_inverse_svd[ii].Tvmult(dst, src);
477 template <
typename number>
482 return var_inverse_full[0];
485 return var_inverse_full[i];
489 template <
typename number>
494 return var_inverse_householder[0];
497 return var_inverse_householder[i];
501 template <
typename number>
506 return var_inverse_svd[0];
509 return var_inverse_svd[i];
513 template <
typename number>
517 Assert(store_diagonals(), ExcDiagonalsNotStored());
520 return var_diagonal[0];
523 return var_diagonal[i];
527 template <
typename number>
531 Assert(var_inverse_full.size() != 0, ExcInverseNotAvailable());
534 return var_inverse_full[0];
537 return var_inverse_full[i];
541 template <
typename number>
545 Assert(var_inverse_householder.size() != 0, ExcInverseNotAvailable());
548 return var_inverse_householder[0];
551 return var_inverse_householder[i];
555 template <
typename number>
559 Assert(var_inverse_svd.size() != 0, ExcInverseNotAvailable());
562 return var_inverse_svd[0];
565 return var_inverse_svd[i];
569 template <
typename number>
573 Assert(store_diagonals(), ExcDiagonalsNotStored());
576 return var_diagonal[0];
579 return var_diagonal[i];
583 template <
typename number>
587 return var_same_diagonal;
591 template <
typename number>
595 return var_store_diagonals;
599 template <
typename number>
603 var_inverses_ready = x;
607 template <
typename number>
611 return var_inverses_ready;
615 template <
typename number>
619 deallog <<
"PreconditionBlockBase: " << size() <<
" blocks; ";
621 if (inversion ==
svd)
623 unsigned int kermin = 100000000, kermax = 0;
624 double sigmin = 1.e300, sigmax = -1.e300;
625 double kappamin = 1.e300, kappamax = -1.e300;
631 while (k <=
matrix.n_cols() &&
634 const double s0 =
matrix.singular_value(0);
635 const double sm =
matrix.singular_value(
matrix.n_cols() - k);
636 const double co = sm / s0;
651 deallog <<
"dim ker [" << kermin <<
':' << kermax <<
"] sigma [" << sigmin
652 <<
':' << sigmax <<
"] kappa [" << kappamin <<
':' << kappamax
655 else if (inversion == householder)
657 else if (inversion == gauss_jordan)
666 template <
typename number>
670 std::size_t mem =
sizeof(*this);
671 for (
size_type i = 0; i < var_inverse_full.size(); ++i)
673 for (
size_type i = 0; i < var_diagonal.size(); ++i)