MathTL
algebra/atra.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_ATRA_H
00011 #define _MATHTL_ATRA_H
00012 
00013 namespace MathTL
00014 {
00016   template <class MATRIX>
00017   class AtrA
00018   {
00019   public:
00023     typedef typename MATRIX::size_type size_type;
00024 
00026     AtrA(const MATRIX& A) : A_(A) {}
00027 
00029     const size_type row_dimension() const { return A_.column_dimension(); }
00030     
00032     const size_type column_dimension() const { return A_.column_dimension(); }
00033     
00035     template <class VECTOR>
00036     void apply(const VECTOR& x, VECTOR& AtrAx) const;
00037     
00039     template <class VECTOR>
00040     void apply_transposed(const VECTOR& x, VECTOR& AtrAx) const { apply(x, AtrAx); }
00041 
00042   private:
00043     const MATRIX& A_;
00044   };
00045 
00046   template <class MATRIX> template <class VECTOR>
00047   void AtrA<MATRIX>::apply(const VECTOR& x, VECTOR& AtrAx) const
00048   {
00049     VECTOR y(A_.row_dimension(), false);
00050     A_.apply(x, y);
00051     A_.apply_transposed(y, AtrAx);
00052   }
00053 
00055   template <class MATRIX>
00056   class AAtr
00057   {
00058   public:
00062     typedef typename MATRIX::size_type size_type;
00063 
00065     AAtr(const MATRIX& A) : A_(A) {}
00066 
00068     const size_type row_dimension() const { return A_.row_dimension(); }
00069     
00071     const size_type column_dimension() const { return A_.row_dimension(); }
00072     
00074     template <class VECTOR>
00075     void apply(const VECTOR& x, VECTOR& AAtrx) const;
00076     
00078     template <class VECTOR>
00079     void apply_transposed(const VECTOR& x, VECTOR& AAtrx) const { apply(x, AAtrx); }
00080 
00081   private:
00082     const MATRIX& A_;
00083   };
00084 
00088   template <class MATRIX>
00089   std::ostream& operator << (std::ostream& os, const AAtr<MATRIX>& M);
00090 
00091   
00092   template <class MATRIX> template <class VECTOR>
00093   void AAtr<MATRIX>::apply(const VECTOR& x, VECTOR& AAtrx) const
00094   {
00095     VECTOR y(A_.column_dimension(), false);
00096     A_.apply_transposed(x, y);
00097     A_.apply(y, AAtrx);
00098   }
00099 }
00100 
00101 #endif
 All Classes Functions Variables Typedefs Enumerations