NAMD
MathArray.h
Go to the documentation of this file.
1 
7 #ifndef MATHARRAY_H
8 #define MATHARRAY_H
9 
10 #include "Array.h"
11 
12 template <class Elem, int Size> class MathArray : public Array<Elem,Size> {
13 
14  public:
15  // constructor
16  MathArray(void) : Array<Elem,Size>(0) { ; }
17 
18  // destructor
19  ~MathArray(void) { ; }
20 
21  // copy constructor
22  MathArray(const Array<Elem,Size> &a2) : Array<Elem,Size>(a2) { ; }
23 
24  // assignment operator
27  return (*this);
28  }
29 
30  // set all elements to a given value (like 0)
31  MathArray(const Elem &v) : Array<Elem,Size>(v) { ; }
32  MathArray<Elem,Size> & operator= (const Elem &v) {
34  return (*this);
35  }
36 
37  // bulk mathematical operations
39  for ( int i = 0; i < Size; ++i ) { this->data[i] += a2.data[i]; }
40  return (*this);
41  }
42  MathArray<Elem,Size> & operator+= (const Elem &v) {
43  for ( int i = 0; i < Size; ++i ) { this->data[i] += v; }
44  return (*this);
45  }
47  for ( int i = 0; i < Size; ++i ) { this->data[i] -= a2.data[i]; }
48  return (*this);
49  }
50  MathArray<Elem,Size> & operator-= (const Elem &v) {
51  for ( int i = 0; i < Size; ++i ) { this->data[i] -= v; }
52  return (*this);
53  }
55  for ( int i = 0; i < Size; ++i ) { this->data[i] *= a2.data[i]; }
56  return (*this);
57  }
58  MathArray<Elem,Size> & operator*= (const Elem &v) {
59  for ( int i = 0; i < Size; ++i ) { this->data[i] *= v; }
60  return (*this);
61  }
63  for ( int i = 0; i < Size; ++i ) { this->data[i] /= a2.data[i]; }
64  return (*this);
65  }
66  MathArray<Elem,Size> & operator/= (const Elem &v) {
67  for ( int i = 0; i < Size; ++i ) { this->data[i] /= v; }
68  return (*this);
69  }
71  const Array<Elem,Size> &a1, const Array<Elem,Size> &a2 ) {
72  return (MathArray<Elem,Size>(a1) += a2);
73  }
75  const Array<Elem,Size> &a1, const Elem &v2 ) {
76  return (MathArray<Elem,Size>(a1) += v2);
77  }
79  const Elem & v1, const Array<Elem,Size> &a2 ) {
80  return (MathArray<Elem,Size>(v1) += a2);
81  }
83  const Array<Elem,Size> &a1, const Array<Elem,Size> &a2 ) {
84  return (MathArray<Elem,Size>(a1) -= a2);
85  }
87  const Array<Elem,Size> &a1, const Elem &v2 ) {
88  return (MathArray<Elem,Size>(a1) -= v2);
89  }
91  const Elem & v1, const Array<Elem,Size> &a2 ) {
92  return (MathArray<Elem,Size>(v1) -= a2);
93  }
95  const Array<Elem,Size> &a1, const Array<Elem,Size> &a2 ) {
96  return (MathArray<Elem,Size>(a1) *= a2);
97  }
99  const Array<Elem,Size> &a1, const Elem &v2 ) {
100  return (MathArray<Elem,Size>(a1) *= v2);
101  }
103  const Elem & v1, const Array<Elem,Size> &a2 ) {
104  return (MathArray<Elem,Size>(v1) *= a2);
105  }
107  const Array<Elem,Size> &a1, const Array<Elem,Size> &a2 ) {
108  return (MathArray<Elem,Size>(a1) /= a2);
109  }
111  const Array<Elem,Size> &a1, const Elem &v2 ) {
112  return (MathArray<Elem,Size>(a1) /= v2);
113  }
115  const Elem & v1, const Array<Elem,Size> &a2 ) {
116  return (MathArray<Elem,Size>(v1) /= a2);
117  }
118 
119 };
120 
121 #endif
122 
Array< Elem, Size > & operator=(const Array< Elem, Size > &a2)
Definition: Array.h:27
MathArray(const Elem &v)
Definition: MathArray.h:31
MathArray(void)
Definition: MathArray.h:16
Elem data[Size]
Definition: Array.h:13
friend MathArray< Elem, Size > operator-(const Array< Elem, Size > &a1, const Array< Elem, Size > &a2)
Definition: MathArray.h:82
MathArray< Elem, Size > & operator*=(const Array< Elem, Size > &a2)
Definition: MathArray.h:54
MathArray< Elem, Size > & operator+=(const Array< Elem, Size > &a2)
Definition: MathArray.h:38
MathArray< Elem, Size > & operator=(const Array< Elem, Size > &a2)
Definition: MathArray.h:25
friend MathArray< Elem, Size > operator/(const Array< Elem, Size > &a1, const Array< Elem, Size > &a2)
Definition: MathArray.h:106
MathArray(const Array< Elem, Size > &a2)
Definition: MathArray.h:22
MathArray< Elem, Size > & operator/=(const Array< Elem, Size > &a2)
Definition: MathArray.h:62
friend MathArray< Elem, Size > operator+(const Array< Elem, Size > &a1, const Array< Elem, Size > &a2)
Definition: MathArray.h:70
Definition: Array.h:10
MathArray< Elem, Size > & operator-=(const Array< Elem, Size > &a2)
Definition: MathArray.h:46
~MathArray(void)
Definition: MathArray.h:19
friend MathArray< Elem, Size > operator*(const Array< Elem, Size > &a1, const Array< Elem, Size > &a2)
Definition: MathArray.h:94