Array3D_Inline.cxx
1 // Copyright (C) 2001-2009 Vivien Mallet
2 // Copyright (C) 2003-2009 Marc DuruflĂ©
3 //
4 // This file is part of the linear-algebra library Seldon,
5 // http://seldon.sourceforge.net/.
6 //
7 // Seldon is free software; you can redistribute it and/or modify it under the
8 // terms of the GNU Lesser General Public License as published by the Free
9 // Software Foundation; either version 2.1 of the License, or (at your option)
10 // any later version.
11 //
12 // Seldon is distributed in the hope that it will be useful, but WITHOUT ANY
13 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
15 // more details.
16 //
17 // You should have received a copy of the GNU Lesser General Public License
18 // along with Seldon. If not, see http://www.gnu.org/licenses/.
19 
20 
21 #ifndef SELDON_FILE_ARRAY3D_INLINE_CXX
22 
23 #include "Array3D.hxx"
24 
25 namespace Seldon
26 {
27 
28  /**************
29  * DESTRUCTOR *
30  **************/
31 
32 
34  template <class T, class Allocator>
36  {
37  Clear();
38  }
39 
40 
41  /*****************
42  * BASIC METHODS *
43  *****************/
44 
45 
47 
50  template <class T, class Allocator>
52  {
53  return length1_;
54  }
55 
56 
58 
61  template <class T, class Allocator>
63  {
64  return length2_;
65  }
66 
67 
69 
72  template <class T, class Allocator>
74  {
75  return length3_;
76  }
77 
78 
80 
85  template <class T, class Allocator>
86  inline long Array3D<T, Allocator>::GetSize() const
87  {
88  return length1_ * length23_;
89  }
90 
91 
93 
99  template <class T, class Allocator>
101  {
102  return length1_ * length23_;
103  }
104 
105 
107 
112  template <class T, class Allocator>
113  inline typename Array3D<T, Allocator>::pointer Array3D<T, Allocator>
114  ::GetData() const
115  {
116  return data_;
117  }
118 
119 
121 
128  template <class T, class Allocator>
129  inline typename Array3D<T, Allocator>::pointer Array3D<T, Allocator>
130  ::GetDataPointer(int i, int j, int k) const
131  {
132  return data_ + i * length23_ + j * length3_ + k;
133  }
134 
135 
136  /**********************************
137  * ELEMENT ACCESS AND AFFECTATION *
138  **********************************/
139 
140 
142 
149  template <class T, class Allocator>
150  inline typename Array3D<T, Allocator>::reference
152  {
153 
154 #ifdef SELDON_CHECK_BOUNDS
155  CheckBounds(i, j, k, length1_, length2_, length3_, "Array3D");
156 #endif
157 
158  return data_[i * length23_ + j * length3_ + k];
159  }
160 
161 
163 
170  template <class T, class Allocator>
171  inline typename Array3D<T, Allocator>::const_reference
172  Array3D<T, Allocator>::operator() (int i, int j, int k) const
173  {
174 
175 #ifdef SELDON_CHECK_BOUNDS
176  CheckBounds(i, j, k, length1_, length2_, length3_, "Array3D");
177 #endif
178 
179  return data_[i*length23_ + j*length3_ + k];
180  }
181 
183 
188  template <class T, class Allocator>
191  {
192  Copy(A);
193 
194  return *this;
195  }
196 
198 
203  template <class T, class Allocator>
205  {
206  Reallocate(A.GetLength1(), A.GetLength2(), A.GetLength3());
207 
208  Allocator::memorycpy(data_, A.GetData(), GetDataSize());
209  }
210 
211 } // namespace Seldon.
212 
213 #define SELDON_FILE_ARRAY3D_INLINE_CXX
214 #endif
Seldon::Array3D::GetLength2
int GetLength2() const
Returns the length in dimension #2.
Definition: Array3D_Inline.cxx:62
Seldon::Array3D::Copy
void Copy(const Array3D< T, Allocator > &A)
Duplicates a 3D array.
Definition: Array3D_Inline.cxx:204
Seldon::Array3D::GetLength1
int GetLength1() const
Returns the length in dimension #1.
Definition: Array3D_Inline.cxx:51
Seldon::Array3D::GetDataPointer
pointer GetDataPointer(int i, int j, int k) const
Returns a pointer to an element of data array.
Definition: Array3D_Inline.cxx:130
Seldon::Array3D::~Array3D
~Array3D()
Destructor.
Definition: Array3D_Inline.cxx:35
Seldon::Array3D::GetSize
long GetSize() const
Returns the number of elements in the 3D array.
Definition: Array3D_Inline.cxx:86
Seldon::Array3D::operator()
reference operator()(int i, int j, int k)
Access operator.
Definition: Array3D_Inline.cxx:151
Seldon::Array3D::GetLength3
int GetLength3() const
Returns the length in dimension #3.
Definition: Array3D_Inline.cxx:73
Seldon::Array3D::GetDataSize
long GetDataSize() const
Returns the number of elements stored in memory.
Definition: Array3D_Inline.cxx:100
Seldon::Array3D::GetData
pointer GetData() const
Returns a pointer to the data array.
Definition: Array3D_Inline.cxx:114
Seldon::Array3D
3D array.
Definition: Array3D.hxx:38
Seldon
Seldon namespace.
Definition: Array.cxx:24