American-transaction costs 1.0.0.0
American option pricer under proportional transaction costs
final.h
Go to the documentation of this file.
00001 /*
00002     American option pricer under proportional transaction costs
00003     Copyright (C) 2011 Alet Roux alet.roux@york.ac.uk
00004 
00005     This program is free software: you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation, either version 3 of the License, or
00008     (at your option) any later version.
00009 
00010     This program is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with this program.  If not, see <http://www.gnu.org/licenses/>.
00017 
00018 */
00019 
00020 #ifndef STATISTICSGATHERER_FINAL_H
00021 #define STATISTICSGATHERER_FINAL_H
00022 
00023 //#include <vector>
00024 //#include <ostream>
00025 
00027 template<class T>
00028 class StatisticsGathererFinal : public StatisticsGatherer<T>
00029 {
00030 public:
00035         StatisticsGathererFinal (const size_t N) : _N (N) {};
00036 
00037         operator T() const
00038         {
00039                 return _object[0][0];
00040         }
00041 
00042         virtual void dump_result (const size_t t, const size_t k, const T& object)
00043         {
00044                 if (t == _N)
00045                   _object[k] = object;
00046         }
00047 
00048         std::vector<T> operator[] (const size_t k) const
00049         {
00050                 return _object[k];
00051         };
00052 
00053         std::vector<T>& operator[] (const size_t k)
00054         {
00055                 return _object[k];
00056         };
00057 
00058         T operator() (const size_t k) const
00059         {
00060                 return _object[k];
00061         };
00062 
00063         T& operator() (const size_t k)
00064         {
00065                 return _object[k];
00066         };
00067 
00069         size_t size() const
00070         {
00071                 return _object.size();
00072         }
00073 
00074 private:
00075         size_t _N;
00076         std::vector<T> _object;
00077 };
00078 
00079 template<class T>
00080 inline std::ostream& operator<< (std::ostream& output, const StatisticsGathererFinal<T>& function)
00081 {
00082                 for (size_t k = 0; k < function.size(); k++)
00083                         output << "(" << k << "): " << function (k) << std::endl;
00084         return output;
00085 }
00086 
00087 #endif // STATISTICSGATHERER_FINAL_H
 All Classes Namespaces Files Functions Variables Typedefs Defines