From dc4dcdb154683cee014e21b41d20aa9d957ebc1e Mon Sep 17 00:00:00 2001 From: bangerth Date: Sun, 18 Nov 2007 23:58:36 +0000 Subject: [PATCH] Add the additional instantiations for std::complex and make the necessary adjustments. git-svn-id: https://svn.dealii.org/trunk@15521 0785d39b-7218-0410-832d-ea1e28bc413d --- .../lac/include/lac/full_matrix.templates.h | 32 ++--- deal.II/lac/source/full_matrix.float.cc | 114 ++++++++++++++++++ 2 files changed, 130 insertions(+), 16 deletions(-) diff --git a/deal.II/lac/include/lac/full_matrix.templates.h b/deal.II/lac/include/lac/full_matrix.templates.h index 54ab3a673b..ba2341b723 100644 --- a/deal.II/lac/include/lac/full_matrix.templates.h +++ b/deal.II/lac/include/lac/full_matrix.templates.h @@ -116,7 +116,7 @@ FullMatrix::all_zero () const const number* p = this->data(); const number* const e = this->data() + this->n_elements(); while (p!=e) - if (*p++ != 0.0) + if (*p++ != number(0.0)) return false; return true; @@ -153,7 +153,7 @@ FullMatrix::operator /= (const number factor) number *p = &this->el(0,0); const number *e = &this->el(0,0) + n()*m(); - const number factor_inv = 1./factor; + const number factor_inv = number(1.)/factor; Assert (numbers::is_finite(factor_inv), ExcMessage("The given value is not finite but either infinite or Not A Number (NaN)")); @@ -265,7 +265,7 @@ number FullMatrix::residual (Vector& dst, size_n = n(); for (unsigned int i=0; iel(i,j); dst(i) = s; @@ -290,7 +290,7 @@ void FullMatrix::forward (Vector &dst, unsigned int nu = ( (m()el(i,j); dst(i) = s/this->el(i,i); @@ -889,7 +889,7 @@ FullMatrix::symmetrize () for (unsigned int i=0; iel(i,j) + this->el(j,i)) / 2.; + const number t = (this->el(i,j) + this->el(j,i)) / number(2.); this->el(i,j) = this->el(j,i) = t; }; } @@ -1889,18 +1889,18 @@ FullMatrix::invert (const FullMatrix &M) switch (this->n_cols()) { case 1: - this->el(0,0) = 1.0/M.el(0,0); + this->el(0,0) = number(1.0)/M.el(0,0); return; case 2: // this is Maple output, // thus a bit unstructured { - const number t4 = 1.0/(M.el(0,0)*M.el(1,1)-M.el(0,1)*M.el(1,0)); - this->el(0,0) = M.el(1,1)*t4; - this->el(0,1) = -M.el(0,1)*t4; - this->el(1,0) = -M.el(1,0)*t4; - this->el(1,1) = M.el(0,0)*t4; - return; + const number t4 = number(1.0)/(M.el(0,0)*M.el(1,1)-M.el(0,1)*M.el(1,0)); + this->el(0,0) = M.el(1,1)*t4; + this->el(0,1) = -M.el(0,1)*t4; + this->el(1,0) = -M.el(1,0)*t4; + this->el(1,1) = M.el(0,0)*t4; + return; }; case 3: @@ -1911,7 +1911,7 @@ FullMatrix::invert (const FullMatrix &M) t00 = M.el(0,2)*M.el(1,0), t01 = M.el(0,1)*M.el(2,0), t04 = M.el(0,2)*M.el(2,0), - t07 = 1.0/(t4*M.el(2,2)-t6*M.el(2,1)-t8*M.el(2,2)+ + t07 = number(1.0)/(t4*M.el(2,2)-t6*M.el(2,1)-t8*M.el(2,2)+ t00*M.el(2,1)+t01*M.el(1,2)-t04*M.el(1,1)); this->el(0,0) = (M.el(1,1)*M.el(2,2)-M.el(1,2)*M.el(2,1))*t07; this->el(0,1) = -(M.el(0,1)*M.el(2,2)-M.el(0,2)*M.el(2,1))*t07; @@ -1964,7 +1964,7 @@ FullMatrix::invert (const FullMatrix &M) const number t63 = t43*t20-t43*t22-t46*t33+t46*t35+ t49*t50-t49*t52-t54*t25+t54*t27+ t57*t38-t57*t40-t60*t50+t60*t52; - const number t65 = 1./(t42+t63); + const number t65 = number(1.)/(t42+t63); const number t71 = M.el(0,2)*M.el(2,1); const number t73 = M.el(0,3)*M.el(2,1); const number t75 = M.el(0,2)*M.el(3,1); @@ -2095,7 +2095,7 @@ FullMatrix::print_formatted ( for (unsigned int j=0; jel(i,j)) > threshold) out << std::setw(width) - << this->el(i,j) * denominator << ' '; + << this->el(i,j) * number(denominator) << ' '; else out << std::setw(width) << zero_string << ' '; out << std::endl; @@ -2170,7 +2170,7 @@ FullMatrix::gauss_jordan () } // transformation - const number hr = 1./this->el(j,j); + const number hr = number(1.)/this->el(j,j); this->el(j,j) = hr; for (unsigned int k=0; k::precondition_Jacobi ( template TYPEMAT FullMatrix::residual( Vector&, const Vector&, const Vector&) const; + + + + + + + + + + + + +#undef TYPEMAT +#undef TYPEMAT2 +#undef TYPEVEC +#undef TYPERES + +#define TYPEMAT std::complex + +template class FullMatrix; + +template void FullMatrix::print( + LogStream&, const unsigned int, const unsigned int) const; +template void FullMatrix::print( + std::ostream&, const unsigned int, const unsigned int) const; + +template FullMatrix& FullMatrix::operator =( + const FullMatrix >&); + +#define TYPEMAT2 std::complex + +//template FullMatrix& FullMatrix::operator =<>(const FullMatrix&); +template void FullMatrix::fill ( + const FullMatrix&, unsigned, unsigned, unsigned, unsigned); +template void FullMatrix::add (const TYPEMAT, const FullMatrix&); +template void FullMatrix::add (const TYPEMAT, const FullMatrix&, + const TYPEMAT, const FullMatrix&); +template void FullMatrix::add (const TYPEMAT, const FullMatrix&, + const TYPEMAT, const FullMatrix&, + const TYPEMAT, const FullMatrix&); +template void FullMatrix::add ( + const FullMatrix&, TYPEMAT, unsigned, unsigned, unsigned, unsigned); +template void FullMatrix::Tadd (const TYPEMAT, const FullMatrix&); +template void FullMatrix::Tadd ( + const FullMatrix&, TYPEMAT, unsigned, unsigned, unsigned, unsigned); +template void FullMatrix::equ (const TYPEMAT, const FullMatrix&); +template void FullMatrix::equ (const TYPEMAT, const FullMatrix&, + const TYPEMAT, const FullMatrix&); +template void FullMatrix::equ (const TYPEMAT, const FullMatrix&, + const TYPEMAT, const FullMatrix&, + const TYPEMAT, const FullMatrix&); +template void FullMatrix::mmult (FullMatrix&, const FullMatrix&, const bool) const; +template void FullMatrix::Tmmult (FullMatrix&, const FullMatrix&, const bool) const; +template void FullMatrix::add_diag (const TYPEMAT, const FullMatrix&); +template void FullMatrix::invert (const FullMatrix&); + +#define TYPEVEC std::complex +#define TYPERES std::complex + +template void FullMatrix::fill_permutation ( + const FullMatrix&, + const std::vector&, + const std::vector&); +template void FullMatrix::vmult( + Vector&, const Vector&, bool) const; +template void FullMatrix::Tvmult( + Vector&, const Vector&, bool) const; +template TYPEMAT FullMatrix::residual( + Vector&, const Vector&, const Vector&) const; +template TYPEVEC FullMatrix::matrix_norm_square ( + const Vector &) const; +template TYPEVEC FullMatrix::matrix_scalar_product( + const Vector&, const Vector&) const; +template void FullMatrix::forward( + Vector&, const Vector&) const; +template void FullMatrix::backward( + Vector&, const Vector&) const; + +template +void FullMatrix::precondition_Jacobi ( + Vector &, const Vector &, const TYPEMAT) const; + +#undef TYPEVEC +#define TYPEVEC std::complex + +template void FullMatrix::fill_permutation ( + const FullMatrix&, + const std::vector&, + const std::vector&); +template void FullMatrix::vmult( + Vector&, const Vector&, bool) const; +template void FullMatrix::Tvmult( + Vector&, const Vector&, bool) const; +template TYPEMAT FullMatrix::residual( + Vector&, const Vector&, const Vector&) const; +template TYPEVEC FullMatrix::matrix_norm_square ( + const Vector &) const; +template TYPEVEC FullMatrix::matrix_scalar_product( + const Vector&, const Vector&) const; +template void FullMatrix::forward( + Vector&, const Vector&) const; +template void FullMatrix::backward( + Vector&, const Vector&) const; +template +void FullMatrix::precondition_Jacobi ( + Vector &, const Vector &, const TYPEMAT) const; + + +#undef TYPERES +#define TYPERES std::complex + +template TYPEMAT FullMatrix::residual( + Vector&, const Vector&, const Vector&) const; + DEAL_II_NAMESPACE_CLOSE -- 2.39.5