MathTL
|
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_GRID_H 00011 #define _MATHTL_GRID_H 00012 00013 #include <geometry/point.h> 00014 #include <utils/array1d.h> 00015 #include <algebra/matrix.h> 00016 #include <io/matrix_io.h> 00017 00018 namespace MathTL 00019 { 00030 template <unsigned int DIM> 00031 class Grid 00032 { 00033 public: 00037 Grid() {} 00038 00042 unsigned int size() const; 00043 00047 void matlab_output(std::ostream& os) const; 00048 }; 00049 00054 template <> 00055 class Grid<1> 00056 { 00057 public: 00061 Grid(); 00062 00066 Grid(const Array1D<double>& grid); 00067 00071 Grid(const double a, const double b, const unsigned int N); 00072 00076 inline unsigned int size() const { return grid_.size(); } 00077 00081 inline const Array1D<double>& points() const { return grid_; } 00082 00086 void matlab_output(std::ostream& os) const; 00087 00088 protected: 00092 Array1D<double> grid_; 00093 }; 00094 00100 template <> 00101 class Grid<2> 00102 { 00103 public: 00107 Grid(); 00108 00112 Grid(const Matrix<double>& gridx, const Matrix<double>& gridy); 00113 00117 Grid(const Grid<1>& gridx, const Grid<1>& gridy); 00118 00122 Grid(const Point<2>& a, const Point<2>& b, 00123 const unsigned N_x, const unsigned N_y); 00124 00128 Grid(const Point<2>& a, const Point<2>& b, 00129 const unsigned int N); 00130 00134 inline unsigned int size() const { return gridx_.size() * gridy_.size(); } 00135 00139 Grid<2>& operator = (const Grid<2>& grid); 00140 00144 void matlab_output(std::ostream& os) const; 00145 00149 void octave_output(std::ostream& os) const; 00150 00151 protected: 00156 Matrix<double> gridx_, gridy_; 00157 }; 00158 } 00159 00160 #include <geometry/grid.cpp> 00161 00162 #endif