PageRenderTime 30ms CodeModel.GetById 15ms app.highlight 11ms RepoModel.GetById 2ms app.codeStats 0ms

/VectorField2D.h

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