-
Notifications
You must be signed in to change notification settings - Fork 0
/
myData.h
95 lines (80 loc) · 3.13 KB
/
myData.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//
// myData.h
// PDE
//
// Created by Ali Dorostkar on 4/8/12.
// Copyright (c) 2012 Uppsala. All rights reserved.
//
#include <iostream>
#include <stdlib.h>
#include <cstdio>
#include <cstring>
#include <stdexcept>
#include <cmath>
#ifndef PDE_myData_h
#define PDE_myData_h
enum direction {
X_DIR = 0,
Y_DIR = 1,
Z_DIR = 2
};
class myData {
private:
///// MEMBERS /////
unsigned int nx;
unsigned int ny;
unsigned int nz;
unsigned int d_size;
double D1P(int i, int j, int k, const double h, const int order, const int n1, const int n2, const int n3, const int c1, const int c2, const int c3) const;
double D2P(int i, int j, int k, const double h, const int order, const int n1, const int n2, const int n3, const int c1, const int c2, const int c3) const;
public:
int * dim;
double *data;
///// CONSTRUCTORS - DESTRUCTOR /////
myData(const unsigned int _nx = 1,const unsigned int _ny = 1, const unsigned int _nz = 1);
myData(bool init,const unsigned int _nx,const unsigned int _ny, const unsigned int _nz);
myData(const myData & md);
virtual ~myData();
///// OPERATORS /////
//index checking and bound correctness left to the user due to performance issue
const double & operator()(const unsigned int i,const unsigned int j /*= 0*/, const unsigned int k = 0) const
{ return data[i + j*nx + k*nx*ny];};
double & operator()(const unsigned int i,const unsigned int j /*= 0*/, const unsigned int k = 0)
{ return data[i + j*nx + k*nx*ny];};
myData & operator=(const myData &);
myData & operator+=(const myData &);
myData & operator-=(const myData &);
myData & operator*=(const myData &);
myData & operator/=(const myData &);
myData operator+(const myData &) const;
myData operator-(const myData &) const;
myData operator*(const myData &) const;
myData operator/(const myData &) const;
myData & operator+=(const double);
myData & operator-=(const double);
myData & operator*=(const double);
myData & operator/=(const double);
myData operator+(const double) const;
myData operator-(const double) const;
myData operator*(const double) const;
myData operator/(const double) const;
///// METHODS /////
const unsigned int Nx() const{return nx;};
const unsigned int Ny() const{return ny;};
const unsigned int Nz() const{return nz;};
const int Data_Size() const{return d_size;};
const double Norm();
const double NormSquare();
void Set_Data(const double * _data,const unsigned int _nx,const unsigned int _ny,const unsigned int _nz);
// First and second derivatives.
myData D1(double h,int order, direction d) const;
myData D2(double h, int order, direction d) const;
myData B_D1(double h,int order, direction d) const;
myData S1(double h,int order, direction d) const;
///// FRIENDS /////
friend myData operator*(const double a, const myData& m);
friend myData operator/(const double a, const myData& m);
friend myData operator+(const double a, const myData& m);
friend myData operator-(const double a, const myData& m);
};
#endif