16 #ifndef dealii__householder_h 17 #define dealii__householder_h 21 #include <deal.II/base/config.h> 22 #include <deal.II/lac/full_matrix.h> 23 #include <deal.II/lac/vector_memory.h> 27 DEAL_II_NAMESPACE_OPEN
31 template<
typename number>
class Vector;
55 template<
typename number>
72 template<
typename number2>
78 template<
typename number2>
92 template<
typename number2>
99 template<
typename number2>
107 template<
class VectorType>
108 void vmult (VectorType &dst,
const VectorType &src)
const;
110 template<
class VectorType>
111 void Tvmult (VectorType &dst,
const VectorType &src)
const;
128 template <
typename number>
134 template <
typename number>
135 template <
typename number2>
139 const size_type m = M.n_rows(), n = M.n_cols();
146 Assert (this->n_cols() <= this->n_rows(),
149 for (size_type j=0 ; j<n ; ++j)
154 for (i=j ; i<m ; ++i)
155 sigma += this->el(i,j)*this->el(i,j);
158 if (std::fabs(sigma) < 1.e-15)
return;
160 number2 s = (this->el(j,j) < 0) ? std::sqrt(sigma) : -std::sqrt(sigma);
162 number2 beta = std::sqrt(1./(sigma-s*this->el(j,j)));
167 diagonal[j] = beta*(this->el(j,j) - s);
170 for (i=j+1 ; i<m ; ++i)
171 this->el(i,j) *= beta;
176 for (size_type k=j+1 ; k<n ; ++k)
178 number2
sum = diagonal[j]*this->el(j,k);
179 for (i=j+1 ; i<m ; ++i)
180 sum += this->el(i,j)*this->el(i,k);
182 this->el(j,k) -=
sum*this->diagonal[j];
183 for (i=j+1 ; i<m ; ++i)
184 this->el(i,k) -=
sum*this->el(i,j);
190 template <
typename number>
191 template <
typename number2>
198 template <
typename number>
199 template <
typename number2>
208 const size_type m = this->m(), n = this->n();
218 for (size_type j=0; j<n; ++j)
221 number2
sum = diagonal[j]* (*aux)(j);
222 for (size_type i=j+1 ; i<m ; ++i)
223 sum += static_cast<number2>(this->el(i,j))*(*aux)(i);
225 (*aux)(j) -=
sum*diagonal[j];
226 for (size_type i=j+1 ; i<m ; ++i)
227 (*aux)(i) -=
sum*static_cast<number2>(this->el(i,j));
231 for (size_type i=n ; i<m ; ++i)
232 sum += (*aux)(i) * (*aux)(i);
236 this->backward(dst, *aux);
240 return std::sqrt(
sum);
243 template <
typename number>
244 template <
typename number2>
253 const size_type m = this->m(), n = this->n();
263 for (size_type j=0; j<n; ++j)
266 number2
sum = diagonal[j]* (*aux)(j);
267 for (size_type i=j+1 ; i<m ; ++i)
268 sum += this->el(i,j)*(*aux)(i);
270 (*aux)(j) -=
sum*diagonal[j];
271 for (size_type i=j+1 ; i<m ; ++i)
272 (*aux)(i) -=
sum*this->el(i,j);
276 for (size_type i=n ; i<m ; ++i)
277 sum += (*aux)(i) * (*aux)(i);
287 this->backward(v_dst, v_aux);
294 return std::sqrt(
sum);
298 template <
typename number>
299 template <
class VectorType>
303 least_squares (dst, src);
307 template <
typename number>
308 template <
class VectorType>
319 DEAL_II_NAMESPACE_CLOSE
types::global_dof_index size_type
#define AssertDimension(dim1, dim2)
types::global_dof_index size_type
unsigned int global_dof_index
virtual VectorType * alloc()
#define Assert(cond, exc)
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
void vmult(VectorType &dst, const VectorType &src) const
virtual void free(const VectorType *const)
void reinit(const unsigned int n_blocks, const size_type block_size=0, const bool omit_zeroing_entries=false)
SymmetricTensor< rank, dim, Number > sum(const SymmetricTensor< rank, dim, Number > &local, const MPI_Comm &mpi_communicator)
std::vector< number > diagonal
virtual void reinit(const size_type N, const bool omit_zeroing_entries=false)
double least_squares(Vector< number2 > &dst, const Vector< number2 > &src) const
static ::ExceptionBase & ExcNotImplemented()
void initialize(const FullMatrix< number2 > &)
#define AssertIsFinite(number)