MFEM v2.0
operator.hpp
Go to the documentation of this file.
00001 // Copyright (c) 2010, Lawrence Livermore National Security, LLC. Produced at
00002 // the Lawrence Livermore National Laboratory. LLNL-CODE-443211. All Rights
00003 // reserved. See file COPYRIGHT for details.
00004 //
00005 // This file is part of the MFEM library. For more information and source code
00006 // availability see http://mfem.googlecode.com.
00007 //
00008 // MFEM is free software; you can redistribute it and/or modify it under the
00009 // terms of the GNU Lesser General Public License (as published by the Free
00010 // Software Foundation) version 2.1 dated February 1999.
00011 
00012 #ifndef MFEM_OPERATOR
00013 #define MFEM_OPERATOR
00014 
00015 #include "vector.hpp"
00016 
00018 class Operator
00019 {
00020 protected:
00021    int size;
00022 
00023 public:
00025    explicit Operator (int s = 0) { size = s; }
00026 
00028    inline int Size() const { return size; }
00029 
00031    virtual void Mult (const Vector & x, Vector & y) const = 0;
00032 
00034    virtual void MultTranspose (const Vector & x, Vector & y) const
00035    { mfem_error ("Operator::MultTranspose() is not overloaded!"); }
00036 
00038    void PrintMatlab (ostream & out, int n = 0, int m = 0);
00039 
00040    virtual ~Operator() { }
00041 };
00042 
00043 
00045 class IdentityOperator : public Operator
00046 {
00047 public:
00049    explicit IdentityOperator (int n) { size = n; }
00050 
00052    virtual void Mult (const Vector & x, Vector & y) const { y = x; }
00053 
00054    ~IdentityOperator() { }
00055 };
00056 
00057 
00059 class TransposeOperator : public Operator
00060 {
00061 private:
00062    Operator * A;
00063 
00064 public:
00066    TransposeOperator (Operator * a) : A(a) { size = A -> Size(); }
00067 
00069    virtual void Mult (const Vector & x, Vector & y) const
00070    { A -> MultTranspose(x,y); }
00071 
00072    virtual void MultTranspose (const Vector & x, Vector & y) const
00073    { A -> Mult(x,y); }
00074 
00075    ~TransposeOperator() { }
00076 };
00077 
00078 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines