MathTL
algebra/symmetric_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_SYMMETRIC_MATRIX_H
00011 #define _MATHTL_SYMMETRIC_MATRIX_H
00012 
00013 #include <iostream>
00014 #include <algebra/triangular_matrix.h>
00015 
00016 namespace MathTL
00017 {
00026   template <class C>
00027   class SymmetricMatrix
00028     : public LowerTriangularMatrix<C>
00029   {
00030   public:
00034     typedef typename LowerTriangularMatrix<C>::size_type size_type;
00035 
00039     explicit SymmetricMatrix(const size_type n = 0);
00040 
00044     SymmetricMatrix(const SymmetricMatrix<C>& M);
00045 
00054     SymmetricMatrix(const size_type n,
00055                     const char* str,
00056                     const bool byrow = true);
00057 
00061     void resize(const size_type n);
00062 
00066     const C operator () (const size_type row, const size_type column) const;
00067     
00071     const C get_entry(const size_type row, const size_type column) const;
00072 
00077     C& operator () (const size_type row, const size_type column);
00078 
00083     void set_entry(const size_type row, const size_type column, const C value);
00084 
00088     template <class C2>
00089     bool operator == (const SymmetricMatrix<C2>& M) const;
00090 
00094     template <class C2>
00095     bool operator != (const SymmetricMatrix<C2>& M) const;
00096 
00100     SymmetricMatrix<C>& operator = (const SymmetricMatrix<C>& M);
00101 
00107     template <class VECTOR>
00108     void apply(const VECTOR& x, VECTOR& Mx) const;
00109 
00116     template <class VECTOR>
00117     void apply_transposed(const VECTOR& x, VECTOR& Mtx) const;
00118 
00123     void print(std::ostream& os,
00124                const unsigned int tabwidth = 5,
00125                const unsigned int precision = 2) const;
00126   };
00127 
00131   template <class C>
00132   std::ostream& operator << (std::ostream& os, const SymmetricMatrix<C>& M);
00133 }
00134 
00135 // include implementation of inline functions
00136 #include <algebra/symmetric_matrix.cpp>
00137 
00138 #endif
 All Classes Functions Variables Typedefs Enumerations