00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef SELDON_FILE_VECTOR_VECTOR_3_CXX
00022
00023
00024 #include "Vector3.hxx"
00025
00026
00027 namespace Seldon
00028 {
00029
00030
00032
00034
00035
00036
00037
00038
00039
00040
00042
00045 template <class T, class Allocator0, class Allocator1, class Allocator2>
00046 Vector3<T, Allocator0, Allocator1, Allocator2>::Vector3()
00047 {
00048 }
00049
00050
00052
00056 template <class T, class Allocator0, class Allocator1, class Allocator2>
00057 Vector3<T, Allocator0, Allocator1, Allocator2>::Vector3(int length)
00058 {
00059 data_.Reallocate(length);
00060 }
00061
00062
00064
00070 template <class T, class Allocator0, class Allocator1, class Allocator2>
00071 Vector3<T, Allocator0, Allocator1, Allocator2>
00072 ::Vector3(Vector<int>& length)
00073 {
00074 data_.Clear();
00075 int n, m = length.GetSize();
00076 data_.Reallocate(m);
00077 for (int i = 0; i < m; i++)
00078 {
00079 n = length(i);
00080 data_(i).Reallocate(n);
00081 }
00082 }
00083
00084
00086
00092 template <class T, class Allocator0, class Allocator1, class Allocator2>
00093 template <class Allocator>
00094 Vector3<T, Allocator0, Allocator1, Allocator2>
00095 ::Vector3(Vector<Vector<int>, Vect_Full, Allocator>& length)
00096 {
00097 data_.Clear();
00098 int n, m = length.GetSize();
00099 data_.Reallocate(m);
00100 for (int i = 0; i < m; i++)
00101 {
00102 n = length(i).GetSize();
00103 data_(i).Reallocate(n);
00104 for (int j = 0; j < n; j++)
00105 data_(i)(j).Reallocate(length(i)(j));
00106 }
00107 }
00108
00109
00110
00111
00112
00113
00114
00116
00119 template <class T, class Allocator0, class Allocator1, class Allocator2>
00120 Vector3<T, Allocator0, Allocator1, Allocator2>::~Vector3()
00121 {
00122 }
00123
00124
00125
00126
00127
00128
00129
00131
00134 template <class T, class Allocator0, class Allocator1, class Allocator2>
00135 int Vector3<T, Allocator0, Allocator1, Allocator2>::GetLength() const
00136 {
00137 return data_.GetLength();
00138 }
00139
00140
00142
00145 template <class T, class Allocator0, class Allocator1, class Allocator2>
00146 int Vector3<T, Allocator0, Allocator1, Allocator2>::GetSize() const
00147 {
00148 return data_.GetSize();
00149 }
00150
00151
00153
00157 template <class T, class Allocator0, class Allocator1, class Allocator2>
00158 int Vector3<T, Allocator0, Allocator1, Allocator2>::GetLength(int i) const
00159 {
00160 return data_(i).GetLength();
00161 }
00162
00163
00165
00169 template <class T, class Allocator0, class Allocator1, class Allocator2>
00170 int Vector3<T, Allocator0, Allocator1, Allocator2>::GetSize(int i) const
00171 {
00172 return data_(i).GetSize();
00173 }
00174
00175
00177
00182 template <class T, class Allocator0, class Allocator1, class Allocator2>
00183 int Vector3<T, Allocator0, Allocator1, Allocator2>
00184 ::GetLength(int i, int j) const
00185 {
00186 return data_(i)(j).GetLength();
00187 }
00188
00189
00191
00196 template <class T, class Allocator0, class Allocator1, class Allocator2>
00197 int Vector3<T, Allocator0, Allocator1, Allocator2>
00198 ::GetSize(int i, int j) const
00199 {
00200 return data_(i)(j).GetSize();
00201 }
00202
00203
00205
00208 template <class T, class Allocator0, class Allocator1, class Allocator2>
00209 int Vector3<T, Allocator0, Allocator1, Allocator2>::GetNelement() const
00210 {
00211 int total = 0;
00212 for (int i = 0; i < GetLength(); i++)
00213 for (int j = 0; j < GetLength(i); j++ )
00214 total += GetLength(i, j);
00215 return total;
00216 }
00217
00218
00220
00227 template <class T, class Allocator0, class Allocator1, class Allocator2>
00228 int Vector3<T, Allocator0, Allocator1, Allocator2>
00229 ::GetNelement(int beg, int end) const
00230 {
00231 if (beg > end)
00232 throw WrongArgument("Vector3::GetNelement(int beg, int end)",
00233 "The lower bound of the range of inner vectors "
00234 "of vectors, [" + to_str(beg) + ", " + to_str(end)
00235 + "[, is strictly greater than its upper bound.");
00236 if (beg < 0 || end > GetLength())
00237 throw WrongArgument("Vector3::GetNelement(int beg, int end)",
00238 "The inner-vector of vectors indexes should be in "
00239 "[0," + to_str(GetLength()) + "] but ["
00240 + to_str(beg)
00241 + ", " + to_str(end) + "[ was provided.");
00242
00243 int total = 0;
00244 for (int i = beg; i < end; i++)
00245 for (int j = 0; j < GetLength(i); j++ )
00246 total += GetLength(i, j);
00247 return total;
00248 }
00249
00250
00252
00255 template <class T, class Allocator0, class Allocator1, class Allocator2>
00256 void Vector3<T, Allocator0, Allocator1, Allocator2>::Reallocate(int N)
00257 {
00258 data_.Reallocate(N);
00259 }
00260
00261
00263
00267 template <class T, class Allocator0, class Allocator1, class Allocator2>
00268 void Vector3<T, Allocator0, Allocator1, Allocator2>
00269 ::Reallocate(int i, int N)
00270 {
00271 data_(i).Reallocate(N);
00272 }
00273
00274
00276
00281 template <class T, class Allocator0, class Allocator1, class Allocator2>
00282 void Vector3<T, Allocator0, Allocator1, Allocator2>
00283 ::Reallocate(int i, int j, int N)
00284 {
00285 data_(i)(j).Reallocate(N);
00286 }
00287
00288
00290
00294 template <class T, class Allocator0, class Allocator1, class Allocator2>
00295 template <class Td, class Allocatord>
00296 void Vector3<T, Allocator0, Allocator1, Allocator2>
00297 ::Flatten(Vector<Td, VectFull, Allocatord>& data) const
00298 {
00299 data.Reallocate(GetNelement());
00300 int i, j, k, n(0);
00301 for (i = 0; i < GetLength(); i++)
00302 for (j = 0; j < GetLength(i); j++)
00303 for (k = 0; k < GetLength(i, j); k++)
00304 data(n++) = data_(i)(j)(k);
00305 }
00306
00307
00309
00317 template <class T, class Allocator0, class Allocator1, class Allocator2>
00318 template <class Td, class Allocatord>
00319 void Vector3<T, Allocator0, Allocator1, Allocator2>
00320 ::Flatten(int beg, int end, Vector<Td, VectFull, Allocatord>& data) const
00321 {
00322 if (beg > end)
00323 throw WrongArgument("Vector3:::Flatten(int beg, int end, Vector& data)",
00324 "The lower bound of the range of inner vectors "
00325 "of vectors, [" + to_str(beg) + ", " + to_str(end)
00326 + "[, is strictly greater than its upper bound.");
00327 if (beg < 0 || end > GetLength())
00328 throw WrongArgument("Vector3:::Flatten(int beg, int end, Vector& data)",
00329 "The inner-vector of vectors indexes should be in "
00330 "[0," + to_str(GetLength()) + "] but ["
00331 + to_str(beg)
00332 + ", " + to_str(end) + "[ was provided.");
00333
00334 data.Reallocate(GetNelement());
00335 int i, j, k, n(0);
00336 for (i = beg; i < end; i++)
00337 for (j = 0; j < GetLength(i); j++)
00338 for (k = 0; k < GetLength(i, j); k++)
00339 data(n++) = data_(i)(j)(k);
00340 }
00341
00342
00344
00349 template <class T, class Allocator0, class Allocator1, class Allocator2>
00350 void Vector3<T, Allocator0,
00351 Allocator1, Allocator2>::PushBack(int i, int j, const T& x)
00352 {
00353 data_(i)(j).PushBack(x);
00354 }
00355
00356
00358
00362 template <class T, class Allocator0, class Allocator1, class Allocator2>
00363 void Vector3<T, Allocator0, Allocator1, Allocator2>::
00364 PushBack(int i, const Vector<T, Vect_Full, Allocator0>& X)
00365 {
00366 data_(i).PushBack(X);
00367 }
00368
00369
00371
00374 template <class T, class Allocator0, class Allocator1, class Allocator2>
00375 void Vector3<T, Allocator0, Allocator1, Allocator2>
00376 ::PushBack(const Vector<Vector<T, Vect_Full, Allocator0>,
00377 Vect_Full, Allocator1>& X)
00378 {
00379 data_.PushBack(X);
00380 }
00381
00382
00384
00388 template <class T, class Allocator0, class Allocator1, class Allocator2>
00389 void Vector3<T, Allocator0, Allocator1, Allocator2>
00390 ::PushBack(const Vector<Vector<Vector<T, Vect_Full, Allocator0>,
00391 Vect_Full, Allocator1>, Vect_Full, Allocator2>& X)
00392 {
00393 for (int i = 0; i < X.GetLength(); i++)
00394 data_.PushBack(X(i));
00395 }
00396
00397
00399
00403 template <class T, class Allocator0, class Allocator1, class Allocator2>
00404 void Vector3<T, Allocator0, Allocator1, Allocator2>
00405 ::PushBack(const Vector3<T, Allocator0, Allocator1, Allocator2>& X)
00406 {
00407 for (int i = 0; i < X.GetLength(); i++)
00408 data_.PushBack(X.GetVector());
00409 }
00410
00411
00413 template <class T, class Allocator0, class Allocator1, class Allocator2>
00414 void Vector3<T, Allocator0, Allocator1, Allocator2>::Clear()
00415 {
00416 data_.Clear();
00417 }
00418
00419
00421
00424 template <class T, class Allocator0, class Allocator1, class Allocator2>
00425 void Vector3<T, Allocator0,
00426 Allocator1, Allocator2>::Clear(int i)
00427 {
00428 data_(i).Clear();
00429 }
00430
00431
00433
00437 template <class T, class Allocator0, class Allocator1, class Allocator2>
00438 void Vector3<T, Allocator0, Allocator1, Allocator2>::Clear(int i, int j)
00439 {
00440 data_(i)(j).Clear();
00441 }
00442
00443
00445
00448 template <class T, class Allocator0, class Allocator1, class Allocator2>
00449 void Vector3<T, Allocator0, Allocator1, Allocator2>::Fill(const T& x)
00450 {
00451 for (int i = 0; i < data_.GetSize(); i++)
00452 for (int j = 0; j < data_(i).GetSize(); j++)
00453 data_(i)(j).Fill(x);
00454 }
00455
00456
00458
00461 template <class T, class Allocator0, class Allocator1, class Allocator2>
00462 Vector<Vector<Vector<T, Vect_Full, Allocator0>, Vect_Full, Allocator1>,
00463 Vect_Full, Allocator2>&
00464 Vector3<T, Allocator0, Allocator1, Allocator2>::GetVector()
00465 {
00466 return data_;
00467 }
00468
00469
00471
00474 template <class T, class Allocator0, class Allocator1, class Allocator2>
00475 const Vector<Vector<Vector<T, Vect_Full, Allocator0>,
00476 Vect_Full, Allocator1>, Vect_Full, Allocator2>&
00477 Vector3<T, Allocator0, Allocator1, Allocator2>::GetVector() const
00478 {
00479 return data_;
00480 }
00481
00482
00484
00488 template <class T, class Allocator0, class Allocator1, class Allocator2>
00489 Vector<Vector<T, Vect_Full, Allocator0>, VectFull, Allocator1>&
00490 Vector3<T, Allocator0, Allocator1, Allocator2>::GetVector(int i)
00491 {
00492 return data_(i);
00493 }
00494
00495
00497
00501 template <class T, class Allocator0, class Allocator1, class Allocator2>
00502 const Vector<Vector<T, Vect_Full, Allocator0>, VectFull, Allocator1>&
00503 Vector3<T, Allocator0, Allocator1, Allocator2>::GetVector(int i) const
00504 {
00505 return data_(i);
00506 }
00507
00508
00510
00515 template <class T, class Allocator0, class Allocator1, class Allocator2>
00516 Vector<T, Vect_Full, Allocator0>&
00517 Vector3<T, Allocator0, Allocator1, Allocator2>::GetVector(int i, int j)
00518 {
00519 return data_(i)(j);
00520 }
00521
00522
00524
00529 template <class T, class Allocator0, class Allocator1, class Allocator2>
00530 const Vector<T, Vect_Full, Allocator0>&
00531 Vector3<T, Allocator0, Allocator1, Allocator2>::GetVector(int i, int j)
00532 const
00533 {
00534 return data_(i)(j);
00535 }
00536
00537
00538
00539
00540
00541
00542
00544
00548 template <class T, class Allocator0, class Allocator1, class Allocator2>
00549 const Vector<Vector<T, Vect_Full, Allocator0>, VectFull, Allocator1>&
00550 Vector3<T, Allocator0,
00551 Allocator1, Allocator2>::operator() (int i) const
00552 {
00553 return data_(i);
00554 }
00555
00556
00558
00562 template <class T, class Allocator0, class Allocator1, class Allocator2>
00563 Vector<Vector<T, Vect_Full, Allocator0>, VectFull, Allocator1>&
00564 Vector3<T, Allocator0, Allocator1, Allocator2>::operator() (int i)
00565 {
00566 return data_(i);
00567 }
00568
00569
00571
00576 template <class T, class Allocator0, class Allocator1, class Allocator2>
00577 const Vector<T, Vect_Full, Allocator0>&
00578 Vector3<T, Allocator0,
00579 Allocator1, Allocator2>::operator() (int i, int j) const
00580 {
00581 return data_(i)(j);
00582 }
00583
00584
00586
00591 template <class T, class Allocator0, class Allocator1, class Allocator2>
00592 Vector<T, Vect_Full, Allocator0>&
00593 Vector3<T, Allocator0, Allocator1, Allocator2>::operator() (int i, int j)
00594 {
00595 return data_(i)(j);
00596 }
00597
00598
00600
00606 template <class T, class Allocator0, class Allocator1, class Allocator2>
00607 typename Vector3<T, Allocator0, Allocator1, Allocator2>::const_reference
00608 Vector3<T, Allocator0,
00609 Allocator1, Allocator2>::operator() (int i, int j, int k) const
00610 {
00611 return data_(i)(j)(k);
00612 }
00613
00614
00616
00622 template <class T, class Allocator0, class Allocator1, class Allocator2>
00623 typename Vector3<T, Allocator0, Allocator1, Allocator2>::reference
00624 Vector3<T, Allocator0, Allocator1, Allocator2>::operator()
00625 (int i, int j, int k)
00626 {
00627 return data_(i)(j)(k);
00628 }
00629
00630
00631
00632
00633
00634
00635
00637 template <class T, class Allocator0, class Allocator1, class Allocator2>
00638 void Vector3<T, Allocator0, Allocator1, Allocator2>::Print() const
00639 {
00640 for (int i = 0; i < data_.GetSize(); i++)
00641 for(int j = 0; j < data_(i).GetSize(); j++)
00642 {
00643 cout << "Vector " << i << ", " << j << ": ";
00644 data_(i)(j).Print();
00645 }
00646 }
00647
00648
00649 }
00650
00651
00652 #define SELDON_FILE_VECTOR_VECTOR_3_CXX
00653 #endif