Page MenuHomec4science

grid.h
No OneTemporary

File Metadata

Created
Thu, Nov 7, 22:49
//
// Created by Arnaud Pannatier on 06.05.18.
// Based on the code of :
// - Nicolas Richart <nicolas.richart@epfl.ch>
// - Vincent Keller <vincent.keller@epfl.ch>
// - Vittoria Rezzonico <vittoria.rezzonico@epfl.ch>
// See the files AUTHORS and COPYRIGHT for the concerning information
//
#ifndef PHPCTSUNAMIPROJECT_GRID_H
#define PHPCTSUNAMIPROJECT_GRID_H
#include <vector>
#include <iostream>
class Grid {
public:
Grid(std::size_t m, std::size_t n);
inline double & get(std::size_t i, std::size_t j){ return m_grid[i * m_x + j]; };
inline const double & get(std::size_t i, std::size_t j) const { return m_grid[i * m_x + j]; };
/// access the value [i][j] of the grid
inline double & operator()(std::size_t i, std::size_t j) { return get(i,j); }
inline const double & operator()(std::size_t i, std::size_t j) const {
return get(i,j);
}
Grid& operator*= (const double a);
Grid& operator*= (Grid const& b);
Grid& operator+= (const double a);
Grid& operator+= (Grid const& b);
Grid operator-() const;
Grid inv() const;
/// set the grid to 0
void clear();
void applyBoundaryConditions();
void imposeTolerances(double tol, double value, const Grid&);
std::size_t m() const;
std::size_t n() const;
friend std::ostream& operator<<(std::ostream& os, const Grid&);
private:
std::size_t m_x, m_y;
std::vector<double> m_grid;
};
Grid operator*(double a, Grid const& g);
inline Grid operator*(Grid const& g, double a) { return a*g; }
Grid operator*(Grid const& a, Grid const& b);
Grid operator+(double a, Grid const& g);
inline Grid operator+(Grid const& g,double a){ return a+g; };
Grid operator+(Grid const& a, Grid const& b);
inline Grid operator-(double a, Grid const& g){ return a+(-g);};
inline Grid operator-(Grid const& g,double a){ return a-g; };
inline Grid operator-(Grid const& a, Grid const& b){ return a+(-b); };
inline Grid operator/(double a, Grid const& g){ return a*g.inv(); };
inline Grid operator/(Grid const& g,double a){ return a/g; };
inline Grid operator/(Grid const& a, Grid const& b){ return a * b.inv(); };
Grid sqrt(Grid const& a);
Grid pow(Grid const& a, double p);
double max(Grid const& a);
Grid maxAbs(Grid const&, Grid const&);
#endif //PHPCTSUNAMIPROJECT_GRID_H

Event Timeline