MathTL
algebra/tridiagonal_matrix.h
00001 // -*- c++ -*-
00002 
00003 // +--------------------------------------------------------------------+
00004 // | This file is part of MathTL - the Mathematical Template Library    |
00005 // |                                                                    |
00006 // | Copyright (c) 2002-2009                                            |
00007 // | Thorsten Raasch, Manuel Werner                                     |
00008 // +--------------------------------------------------------------------+
00009 
00010 #ifndef _MATHTL_TRIDIAGONAL_MATRIX_H
00011 #define _MATHTL_TRIDIAGONAL_MATRIX_H
00012 
00013 #include <iostream>
00014 #include <algebra/vector.h>
00015 
00016 namespace MathTL
00017 {
00026   template <class C>
00027   class TridiagonalMatrix
00028   {
00029   public:
00033     typedef typename Vector<C>::size_type size_type;
00034 
00038     explicit TridiagonalMatrix(const size_type n = 1);
00039 
00043     TridiagonalMatrix(const TridiagonalMatrix<C>& M);
00044 
00048     const size_type row_dimension() const;
00049     
00053     const size_type column_dimension() const;
00054     
00058     const size_type size() const;
00059     
00063     void resize(const size_type rows);
00064 
00068     const size_type memory_consumption() const;
00069     
00073     bool empty() const;
00074     
00078     const C operator () (const size_type row, const size_type column) const;
00079     
00083     const C get_entry(const size_type row, const size_type column) const;
00084 
00088     C& operator () (const size_type row, const size_type column);
00089     
00093     void set_entry(const size_type row, const size_type column, const C value);
00094 
00098     template <class C2>
00099     bool operator == (const TridiagonalMatrix<C2>& M) const;
00100 
00104     template <class C2>
00105     bool operator != (const TridiagonalMatrix<C2>& M) const;
00106 
00110     TridiagonalMatrix<C>& operator = (const TridiagonalMatrix<C>& M);
00111 
00117     template <class VECTOR>
00118     void apply(const VECTOR& x, VECTOR& Mx) const;
00119 
00125     template <class VECTOR>
00126     void apply_transposed(const VECTOR& x, VECTOR& Mtx) const;
00127 
00132     void print(std::ostream& os,
00133                const unsigned int tabwidth = 5,
00134                const unsigned int precision = 2) const;
00135 
00136   protected:
00142     Vector<C> a_, b_, c_;
00143 
00147     size_type rowdim_;
00148   };
00149 
00153   template <class C>
00154   std::ostream& operator << (std::ostream& os, const TridiagonalMatrix<C>& M);
00155 }
00156 
00157 // include implementation of inline functions
00158 #include <algebra/tridiagonal_matrix.cpp>
00159 
00160 #endif
 All Classes Functions Variables Typedefs Enumerations