PageRenderTime 11ms CodeModel.GetById 2ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/ScalarField2D.h

http://nscow.googlecode.com/
C++ Header | 64 lines | 42 code | 16 blank | 6 comment | 0 complexity | ee7c3f501e839024d3c56f82c64993e8 MD5 | raw file
 1/*
 2 * ScalarField2D.h
 3 *
 4 *  Created on: Apr 25, 2010
 5 *      Author: wto
 6 */
 7
 8#ifndef SCALARFIELD2D_H_
 9#define SCALARFIELD2D_H_
10
11class ScalarField2D {
12public:
13        ScalarField2D(int xdim, int ydim, double boundryScale = 1, double* data = 0);
14	~ScalarField2D();
15
16
17        ScalarField2D(const ScalarField2D&);
18        ScalarField2D& operator=(const ScalarField2D&);
19
20	double& value(int x, int y);
21	double value(int x, int y) const;
22        double checkBoundry(int x, int y) const;
23
24        void print() const;
25
26        double *begin() const;
27        double *end() const;
28        int size() const;
29
30        double min() const;
31        double max() const;
32        double mean() const;
33        void fill(double val);
34
35	const int xdim;
36	const int ydim;
37
38private:
39	double *itsData;
40	bool ownsData;
41        double itsBoundryScale;
42};
43
44inline double *ScalarField2D::begin() const {
45    return itsData;
46}
47
48inline double *ScalarField2D::end() const {
49    return itsData+size();
50}
51
52inline int ScalarField2D::size() const {
53    return xdim*ydim;
54}
55
56inline double& ScalarField2D::value(int x, int y) {
57	return itsData[(y * xdim) + x];
58}
59
60inline double ScalarField2D::value(int x, int y) const {
61	return itsData[(y * xdim) + x];
62}
63
64#endif /* SCALARFIELD2D_H_ */