21 #ifndef SELDON_FILE_ARRAY_CXX
36 template <
class T,
int N,
class Allocator>
39 if (N < ARRAY_MINRANK || N > ARRAY_MAXRANK)
41 string msg = string(
"Array dimension should be in [") +
42 to_str(ARRAY_MINRANK) + string(
", ") +
to_str(ARRAY_MAXRANK) +
"].";
43 throw WrongDim(
"Array<T, N, Allocator>::Array(int, ...)", msg);
47 for (
int k = 0; k < N; k++)
61 template <
class T,
int N,
class Allocator>
65 throw WrongDim(
"Array<T, N, Allocator>::Array(int, ...)",
66 "Array dimension should be 3.");
68 long nb_elt = long(i) * long(j) * long(k);
70 #ifdef SELDON_CHECK_MEMORY
75 data_ = Allocator::allocate(nb_elt,
this);
77 #ifdef SELDON_CHECK_MEMORY
83 if (data_ == NULL && i != 0 && j != 0 && k != 0)
84 throw NoMemory(
"Array::Array(int, ...)",
85 string(
"Unable to allocate memory for an array of size ")
86 +
to_str(
static_cast<long int>(i)
87 *
static_cast<long int>(j)
88 *
static_cast<long int>(k)
89 *
static_cast<long int>(
sizeof(T)))
91 +
" x " +
to_str(k) +
" elements).");
97 offset_[0] = long(j) * long(k);
111 template <
class T,
int N,
class Allocator>
115 throw WrongDim(
"Array<T, N, Allocator>::Array(int, ...)",
116 "Array dimension should be 4.");
118 long nb_elt = long(i) * long(j) * long(k) * long(l);
120 #ifdef SELDON_CHECK_MEMORY
125 data_ = Allocator::allocate(nb_elt,
this);
127 #ifdef SELDON_CHECK_MEMORY
133 if (data_ == NULL && i != 0 && j != 0 && k != 0 && l != 0)
134 throw NoMemory(
"Array::Array(int, ...)",
135 string(
"Unable to allocate memory for an array of size ")
136 +
to_str(
static_cast<long int>(i)
137 *
static_cast<long int>(j)
138 *
static_cast<long int>(k)
139 *
static_cast<long int>(l)
140 *
static_cast<long int>(
sizeof(T)))
142 +
" x " +
to_str(k) +
" x " +
to_str(l) +
" elements).");
149 offset_[0] = long(j) * long(k) * long(l);
150 offset_[1] = long(k) * long(l);
151 offset_[2] = long(l);
165 template <
class T,
int N,
class Allocator>
169 throw WrongDim(
"Array<T, N, Allocator>::Array(int, ...)",
170 "Array dimension should be 5.");
172 long nb_elt = long(i) * long(j) * long(k) * long(l) * long(m);
174 #ifdef SELDON_CHECK_MEMORY
179 data_ = Allocator::allocate(nb_elt,
this);
181 #ifdef SELDON_CHECK_MEMORY
187 if (data_ == NULL && i != 0 && j != 0 && k != 0 && l != 0 && m != 0)
188 throw NoMemory(
"Array::Array(int, ...)",
189 string(
"Unable to allocate memory for an array of size ")
190 +
to_str(
static_cast<long int>(i)
191 *
static_cast<long int>(j)
192 *
static_cast<long int>(k)
193 *
static_cast<long int>(l)
194 *
static_cast<long int>(m)
195 *
static_cast<long int>(
sizeof(T)))
198 +
to_str(m) +
" elements).");
206 offset_[0] = long(j) * long(k) * long(l) * long(m);
207 offset_[1] = long(k) * long(l) * long(m);
208 offset_[2] = long(l) * long(m);
224 template <
class T,
int N,
class Allocator>
226 ::Array(
int i,
int j,
int k,
int l,
int m,
int n)
229 throw WrongDim(
"Array<T, N, Allocator>::Array(int, ...)",
230 "Array dimension should be 6.");
232 long nb_elt = long(i) * long(j) * long(k) * long(l) * long(m) * long(n);
234 #ifdef SELDON_CHECK_MEMORY
239 data_ = Allocator::allocate(nb_elt,
this);
241 #ifdef SELDON_CHECK_MEMORY
248 if (data_ == NULL && i != 0 && j != 0 && k != 0 && l != 0 && m != 0 &&
250 throw NoMemory(
"Array::Array(int, ...)",
251 string(
"Unable to allocate memory for an array of size ")
252 +
to_str(
static_cast<long int>(i)
253 *
static_cast<long int>(j)
254 *
static_cast<long int>(k)
255 *
static_cast<long int>(l)
256 *
static_cast<long int>(m)
257 *
static_cast<long int>(n)
258 *
static_cast<long int>(
sizeof(T)))
272 offset_[3] = long(m) * long(n);
273 offset_[2] = long(l) * offset_[3];
274 offset_[1] = long(k) * offset_[2];
275 offset_[0] = long(j) * offset_[1];
292 template <
class T,
int N,
class Allocator>
294 ::Array(
int i,
int j,
int k,
int l,
int m,
int n,
int o)
297 throw WrongDim(
"Array<T, N, Allocator>::Array(int, ...)",
298 "Array dimension should be 7.");
300 long nb_elt = long(i) * long(j) * long(k) * long(l) * long(m)
303 #ifdef SELDON_CHECK_MEMORY
308 data_ = Allocator::allocate(nb_elt,
this);
310 #ifdef SELDON_CHECK_MEMORY
316 if (data_ == NULL && i != 0 && j != 0 && k != 0 && l != 0 && m != 0 &&
318 throw NoMemory(
"Array::Array(int, ...)",
319 string(
"Unable to allocate memory for an array of size ")
320 +
to_str(
static_cast<long int>(i)
321 *
static_cast<long int>(j)
322 *
static_cast<long int>(k)
323 *
static_cast<long int>(l)
324 *
static_cast<long int>(m)
325 *
static_cast<long int>(n)
326 *
static_cast<long int>(o)
327 *
static_cast<long int>(
sizeof(T)))
343 offset_[4] = long(n) * long(o);
344 offset_[3] = long(m) * offset_[4];
345 offset_[2] = long(l) * offset_[3];
346 offset_[1] = long(k) * offset_[2];
347 offset_[0] = long(j) * offset_[1];
364 template <
class T,
int N,
class Allocator>
366 ::Array(
int i,
int j,
int k,
int l,
int m,
int n,
int o,
int p)
369 throw WrongDim(
"Array<T, N, Allocator>::Array(int, ...)",
370 "Array dimension should be 8.");
372 long nb_elt = long(i) * long(j) * long(k) * long(l) * long(m)
373 * long(n) * long(o) * long(p);
375 #ifdef SELDON_CHECK_MEMORY
380 data_ = Allocator::allocate(nb_elt,
this);
382 #ifdef SELDON_CHECK_MEMORY
388 if (data_ == NULL && i != 0 && j != 0 && k != 0 && l != 0 && m != 0 &&
389 n != 0 && o != 0 && p != 0)
390 throw NoMemory(
"Array::Array(int, ...)",
391 string(
"Unable to allocate memory for an array of size ")
392 +
to_str(
static_cast<long int>(i)
393 *
static_cast<long int>(j)
394 *
static_cast<long int>(k)
395 *
static_cast<long int>(l)
396 *
static_cast<long int>(m)
397 *
static_cast<long int>(n)
398 *
static_cast<long int>(o)
399 *
static_cast<long int>(p)
400 *
static_cast<long int>(
sizeof(T)))
404 +
" x " +
to_str(p) +
" elements).");
417 offset_[5] = long(o) * long(p);
418 offset_[4] = long(n) * offset_[5];
419 offset_[3] = long(m) * offset_[4];
420 offset_[2] = long(l) * offset_[3];
421 offset_[1] = long(k) * offset_[2];
422 offset_[0] = long(j) * offset_[1];
441 template <
class T,
int N,
class Allocator>
443 ::Array(
int i,
int j,
int k,
int l,
int m,
int n,
int o,
int p,
int q)
446 throw WrongDim(
"Array<T, N, Allocator>::Array(int, ...)",
447 "Array dimension should be 9.");
449 long nb_elt = long(i) * long(j) * long(k) * long(l) * long(m)
450 * long(n) * long(o) * long(p) * long(q);
452 #ifdef SELDON_CHECK_MEMORY
457 data_ = Allocator::allocate(nb_elt,
this);
459 #ifdef SELDON_CHECK_MEMORY
465 if (data_ == NULL && i != 0 && j != 0 && k != 0 && l != 0 && m != 0 &&
466 n != 0 && o != 0 && p != 0 && q != 0)
467 throw NoMemory(
"Array::Array(int, ...)",
468 string(
"Unable to allocate memory for an array of size ")
469 +
to_str(
static_cast<long int>(i)
470 *
static_cast<long int>(j)
471 *
static_cast<long int>(k)
472 *
static_cast<long int>(l)
473 *
static_cast<long int>(m)
474 *
static_cast<long int>(n)
475 *
static_cast<long int>(o)
476 *
static_cast<long int>(p)
477 *
static_cast<long int>(q)
478 *
static_cast<long int>(
sizeof(T)))
496 offset_[6] = long(p) * long(q);
497 offset_[5] = long(o) * offset_[6];
498 offset_[4] = long(n) * offset_[5];
499 offset_[3] = long(m) * offset_[4];
500 offset_[2] = long(l) * offset_[3];
501 offset_[1] = long(k) * offset_[2];
502 offset_[0] = long(j) * offset_[1];
509 template <
class T,
int N,
class Allocator>
531 template <
class T,
int N,
class Allocator>
535 throw WrongDim(
"Array::Reallocate(int, ...)",
536 "Array dimension should be 3.");
538 long nb_elt = long(i) * long(j) * long(k);
540 if (length_ == NULL || i != length_[0] || j != length_[1]
544 #ifdef SELDON_CHECK_MEMORY
550 reinterpret_cast<pointer
>(Allocator::reallocate(data_,
554 #ifdef SELDON_CHECK_MEMORY
560 if (data_ == NULL && i != 0 && j != 0 && k != 0)
561 throw NoMemory(
"Array::Reallocate(int, ...)",
562 string(
"Unable to reallocate memory")
563 +
" for an array of size "
564 +
to_str(
static_cast<long int>(i)
565 *
static_cast<long int>(j)
566 *
static_cast<long int>(k)
567 *
static_cast<long int>(
sizeof(T)))
569 +
" x " +
to_str(k) +
" elements).");
575 offset_[0] = long(j) * long(k);
591 template <
class T,
int N,
class Allocator>
595 throw WrongDim(
"Array::Reallocate(int, ...)",
596 "Array dimension should be 4.");
598 long nb_elt = long(i) * long(j) * long(k) * long(l);
600 if (length_ == NULL || i != length_[0] || j != length_[1]
601 || k != length_[2] || l != length_[3])
604 #ifdef SELDON_CHECK_MEMORY
610 reinterpret_cast<pointer
>(Allocator::reallocate(data_,
614 #ifdef SELDON_CHECK_MEMORY
620 if (data_ == NULL && i != 0 && j != 0 && k != 0 && l != 0)
621 throw NoMemory(
"Array::Reallocate(int, ...)",
622 string(
"Unable to reallocate memory")
623 +
" for an array of size "
624 +
to_str(
static_cast<long int>(i)
625 *
static_cast<long int>(j)
626 *
static_cast<long int>(k)
627 *
static_cast<long int>(l)
628 *
static_cast<long int>(
sizeof(T)))
638 offset_[0] = long(j) * long(k) * long(l);
639 offset_[1] = long(k) * long(l);
640 offset_[2] = long(l);
656 template <
class T,
int N,
class Allocator>
661 throw WrongDim(
"Array::Reallocate(int, ...)",
662 "Array dimension should be 5.");
664 long nb_elt = long(i) * long(j) * long(k) * long(l) * long(m);
666 if (length_ == NULL || i != length_[0] || j != length_[1]
667 || k != length_[2] || l != length_[3] || m != length_[4])
670 #ifdef SELDON_CHECK_MEMORY
676 reinterpret_cast<pointer
>(Allocator::reallocate(data_,
680 #ifdef SELDON_CHECK_MEMORY
686 if (data_ == NULL && i != 0 && j != 0 && k != 0 && l != 0 && m != 0)
687 throw NoMemory(
"Array::Reallocate(int, ...)",
688 string(
"Unable to reallocate memory")
689 +
" for an array of size "
690 +
to_str(
static_cast<long int>(i)
691 *
static_cast<long int>(j)
692 *
static_cast<long int>(k)
693 *
static_cast<long int>(l)
694 *
static_cast<long int>(m)
695 *
static_cast<long int>(
sizeof(T)))
698 +
" x " +
to_str(m) +
" elements).");
706 offset_[0] = long(j) * long(k) * long(l) * long(m);
707 offset_[1] = long(k) * long(l) * long(m);
708 offset_[2] = long(l) * long(m);
726 template <
class T,
int N,
class Allocator>
731 throw WrongDim(
"Array::Reallocate(int, ...)",
732 "Array dimension should be 6.");
734 long nb_elt = long(i) * long(j) * long(k) * long(l) * long(m) * long(n);
736 if (length_ == NULL || i != length_[0] || j != length_[1]
737 || k != length_[2] || l != length_[3] || m != length_[4]
741 #ifdef SELDON_CHECK_MEMORY
747 reinterpret_cast<pointer
>(Allocator::reallocate(data_,
751 #ifdef SELDON_CHECK_MEMORY
757 if (data_ == NULL && i != 0 && j != 0 && k != 0 && l != 0 && m != 0 &&
759 throw NoMemory(
"Array::Reallocate(int, ...)",
760 string(
"Unable to reallocate memory")
761 +
" for an array of size "
762 +
to_str(
static_cast<long int>(i)
763 *
static_cast<long int>(j)
764 *
static_cast<long int>(k)
765 *
static_cast<long int>(l)
766 *
static_cast<long int>(m)
767 *
static_cast<long int>(n)
768 *
static_cast<long int>(
sizeof(T)))
783 offset_[3] = long(m) * long(n);
784 offset_[2] = long(l) * offset_[3];
785 offset_[1] = long(k) * offset_[2];
786 offset_[0] = long(j) * offset_[1];
804 template <
class T,
int N,
class Allocator>
809 throw WrongDim(
"Array::Reallocate(int, ...)",
810 "Array dimension should be 7.");
812 long nb_elt = long(i) * long(j) * long(k) * long(l) * long(m)
815 if (length_ == NULL || i != length_[0] || j != length_[1]
816 || k != length_[2] || l != length_[3] || m != length_[4]
817 || n != length_[5] || o != length_[6])
820 #ifdef SELDON_CHECK_MEMORY
826 reinterpret_cast<pointer
>(Allocator::reallocate(data_, nb_elt,
this));
828 #ifdef SELDON_CHECK_MEMORY
834 if (data_ == NULL && i != 0 && j != 0 && k != 0 && l != 0 && m != 0 &&
836 throw NoMemory(
"Array::Reallocate(int, ...)",
837 string(
"Unable to reallocate memory")
838 +
" for an array of size "
839 +
to_str(
static_cast<long int>(i)
840 *
static_cast<long int>(j)
841 *
static_cast<long int>(k)
842 *
static_cast<long int>(l)
843 *
static_cast<long int>(m)
844 *
static_cast<long int>(n)
845 *
static_cast<long int>(o)
846 *
static_cast<long int>(
sizeof(T)))
850 +
" x " +
to_str(o) +
" elements).");
862 offset_[4] = long(n) * long(o);
863 offset_[3] = long(m) * offset_[4];
864 offset_[2] = long(l) * offset_[3];
865 offset_[1] = long(k) * offset_[2];
866 offset_[0] = long(j) * offset_[1];
885 template <
class T,
int N,
class Allocator>
890 throw WrongDim(
"Array::Reallocate(int, ...)",
891 "Array dimension should be 8.");
893 long nb_elt = long(i) * long(j) * long(k) * long(l) * long(m)
894 * long(n) * long(o) * long(p);
896 if (length_ == NULL || i != length_[0] || j != length_[1]
897 || k != length_[2] || l != length_[3] || m != length_[4]
898 || n != length_[5] || o != length_[6] || p != length_[7])
901 #ifdef SELDON_CHECK_MEMORY
906 reinterpret_cast<pointer
>(Allocator::reallocate(data_, nb_elt,
this));
909 #ifdef SELDON_CHECK_MEMORY
915 if (data_ == NULL && i != 0 && j != 0 && k != 0 && l != 0 && m != 0 &&
916 n != 0 && o != 0 && p != 0)
917 throw NoMemory(
"Array::Reallocate(int, ...)",
918 string(
"Unable to reallocate memory")
919 +
" for an array of size "
920 +
to_str(
static_cast<long int>(i)
921 *
static_cast<long int>(j)
922 *
static_cast<long int>(k)
923 *
static_cast<long int>(l)
924 *
static_cast<long int>(m)
925 *
static_cast<long int>(n)
926 *
static_cast<long int>(o)
927 *
static_cast<long int>(p)
928 *
static_cast<long int>(
sizeof(T)))
946 offset_[5] = long(o) * long(p);
947 offset_[4] = long(n) * offset_[5];
948 offset_[3] = long(m) * offset_[4];
949 offset_[2] = long(l) * offset_[3];
950 offset_[1] = long(k) * offset_[2];
951 offset_[0] = long(j) * offset_[1];
971 template <
class T,
int N,
class Allocator>
973 ::Reallocate(
int i,
int j,
int k,
int l,
int m,
int n,
int o,
int p,
int q)
976 throw WrongDim(
"Array::Reallocate(int, ...)",
977 "Array dimension should be 9.");
979 long nb_elt = long(i) * long(j) * long(k) * long(l) * long(m)
980 * long(n) * long(o) * long(p) * long(q);
982 if (length_ == NULL || i != length_[0] || j != length_[1]
983 || k != length_[2] || l != length_[3] || m != length_[4]
984 || n != length_[5] || o != length_[6] || p != length_[7]
988 #ifdef SELDON_CHECK_MEMORY
994 reinterpret_cast<pointer
>(Allocator::reallocate(data_, nb_elt,
this));
996 #ifdef SELDON_CHECK_MEMORY
1002 if (data_ == NULL && i != 0 && j != 0 && k != 0 && l != 0 && m != 0 &&
1003 n != 0 && o != 0 && p != 0 && q != 0)
1004 throw NoMemory(
"Array::Reallocate(int, ...)",
1005 string(
"Unable to reallocate memory")
1006 +
" for an array of size "
1007 +
to_str(
static_cast<long int>(i)
1008 *
static_cast<long int>(j)
1009 *
static_cast<long int>(k)
1010 *
static_cast<long int>(l)
1011 *
static_cast<long int>(m)
1012 *
static_cast<long int>(n)
1013 *
static_cast<long int>(o)
1014 *
static_cast<long int>(p)
1015 *
static_cast<long int>(q)
1016 *
static_cast<long int>(
sizeof(T)))
1021 +
" x " +
to_str(q) +
" elements).");
1035 offset_[6] = long(p) * long(q);
1036 offset_[5] = long(o) * offset_[6];
1037 offset_[4] = long(n) * offset_[5];
1038 offset_[3] = long(m) * offset_[4];
1039 offset_[2] = long(l) * offset_[3];
1040 offset_[1] = long(k) * offset_[2];
1041 offset_[0] = long(j) * offset_[1];
1042 offset_[8] = nb_elt;
1052 template <
class T,
int N,
class Allocator>
1056 #ifdef SELDON_CHECK_MEMORY
1063 Allocator::deallocate(data_, offset_[N-1]);
1067 #ifdef SELDON_CHECK_MEMORY
1084 template <
class T,
int N,
class Allocator>
1111 Allocator::memorycpy(data_, A.
GetData(), GetDataSize());
1125 template <
class T,
int N,
class Allocator>
1128 size_t taille =
sizeof(*this);
1129 taille += size_t(
sizeof(T))*GetDataSize();
1139 template <
class T,
int N,
class Allocator>
1142 Allocator::memoryset(data_,
char(0),
1143 GetDataSize()*
sizeof(value_type));
1152 template <
class T,
int N,
class Allocator>
1155 for (
long i = 0; i < GetDataSize(); i++)
1165 template <
class T,
int N,
class Allocator>
1171 for (
long i = 0; i < GetDataSize(); i++)
1180 template <
class T,
int N,
class Allocator>
1183 #ifndef SELDON_WITHOUT_REINIT_RANDOM
1186 for (
long i = 0; i < GetDataSize(); i++)
1195 template <
class T,
int N,
class Allocator>
1201 for (i = 0; i < GetLength(0); i++)
1203 for (j = 0; j < GetLength(1); j++)
1205 for (k = 0; k < GetLength(2); k++)
1206 cout << (*
this)(i, j, k) <<
'\t';
1216 for (i = 0; i < GetLength(0); i++)
1218 for (j = 0; j < GetLength(1); j++)
1220 for (k = 0; k < GetLength(2); k++)
1222 for (l = 0; l < GetLength(3); l++)
1223 cout << (*
this)(i, j, k, l) <<
'\t';
1235 for (i = 0; i < GetLength(0); i++)
1237 for (j = 0; j < GetLength(1); j++)
1239 for (k = 0; k < GetLength(2); k++)
1241 for (l = 0; l < GetLength(3); l++)
1243 for (m = 0; m < GetLength(4); m++)
1244 cout << (*
this)(i, j, k, l, m) <<
'\t';
1257 int i, j, k, l, m, n;
1258 for (i = 0; i < GetLength(0); i++)
1260 for (j = 0; j < GetLength(1); j++)
1262 for (k = 0; k < GetLength(2); k++)
1264 for (l = 0; l < GetLength(3); l++)
1266 for (m = 0; m < GetLength(4); m++)
1268 for (n = 0; n < GetLength(5); n++)
1269 cout << (*
this)(i, j, k, l, m, n) <<
'\t';
1284 int i, j, k, l, m, n, o;
1285 for (i = 0; i < GetLength(0); i++)
1287 for (j = 0; j < GetLength(1); j++)
1289 for (k = 0; k < GetLength(2); k++)
1291 for (l = 0; l < GetLength(3); l++)
1293 for (m = 0; m < GetLength(4); m++)
1295 for (n = 0; n < GetLength(5); n++)
1297 for (o = 0; o < GetLength(6); o++)
1298 cout << (*
this)(i, j, k, l, m, n, o)
1316 int i, j, k, l, m, n, o, p;
1317 for (i = 0; i < GetLength(0); i++)
1319 for (j = 0; j < GetLength(1); j++)
1321 for (k = 0; k < GetLength(2); k++)
1323 for (l = 0; l < GetLength(3); l++)
1325 for (m = 0; m < GetLength(4); m++)
1327 for (n = 0; n < GetLength(5); n++)
1329 for (o = 0; o < GetLength(6); o++)
1331 for (p = 0; p < GetLength(7); p++)
1332 cout << (*
this)(i, j, k, l, m, n, o, p)
1352 int i, j, k, l, m, n, o, p, q;
1353 for (i = 0; i < GetLength(0); i++)
1355 for (j = 0; j < GetLength(1); j++)
1357 for (k = 0; k < GetLength(2); k++)
1359 for (l = 0; l < GetLength(3); l++)
1361 for (m = 0; m < GetLength(4); m++)
1363 for (n = 0; n < GetLength(5); n++)
1365 for (o = 0; o < GetLength(6); o++)
1367 for (p = 0; p < GetLength(7); p++)
1369 for (q = 0; q < GetLength(8); q++)
1370 cout << (*
this)(i, j, k, l, m, n,
1408 ofstream FileStream;
1409 FileStream.open(FileName.c_str(), ofstream::binary);
1411 #ifdef SELDON_CHECK_IO
1413 if (!FileStream.is_open())
1414 throw IOError(
"Array::Write(string FileName)",
1415 string(
"Unable to open file \"") + FileName +
"\".");
1418 Write(FileStream, with_size);
1432 ::Write(ofstream& FileStream,
bool with_size)
const
1435 #ifdef SELDON_CHECK_IO
1437 if (!FileStream.good())
1438 throw IOError(
"Array::Write(ofstream& FileStream)",
1439 "Stream is not ready.");
1444 for (
int i = 0; i < N; i++)
1445 FileStream.write(
reinterpret_cast<char*
>
1446 (
const_cast<int*
>(&length_[i])),
1450 FileStream.write(
reinterpret_cast<char*
>(data_),
1451 offset_[N - 1] *
sizeof(value_type));
1453 #ifdef SELDON_CHECK_IO
1455 if (!FileStream.good())
1456 throw IOError(
"Array::Write(ofstream& FileStream)",
1457 string(
"Output operation failed.")
1458 +
string(
" The output file may have been removed")
1459 +
" or there is no space left on device.");
1472 template <
class T,
int N,
class Allocator>
1475 ifstream FileStream;
1476 FileStream.open(FileName.c_str(), ifstream::binary);
1478 #ifdef SELDON_CHECK_IO
1480 if (!FileStream.is_open())
1481 throw IOError(
"Array::Read(string FileName)",
1482 string(
"Unable to open file \"") + FileName +
"\".");
1485 Read(FileStream, with_size);
1498 template <
class T,
int N,
class Allocator>
1503 #ifdef SELDON_CHECK_IO
1505 if (!FileStream.good())
1506 throw IOError(
"Matrix_Pointers::Read(ifstream& FileStream)",
1507 "Stream is not ready.");
1514 int new_l1, new_l2, new_l3;
1515 FileStream.read(
reinterpret_cast<char*
>(&new_l1),
sizeof(
int));
1516 FileStream.read(
reinterpret_cast<char*
>(&new_l2),
sizeof(
int));
1517 FileStream.read(
reinterpret_cast<char*
>(&new_l3),
sizeof(
int));
1518 Reallocate(new_l1, new_l2, new_l3);
1522 int new_l1, new_l2, new_l3, new_l4;
1523 FileStream.read(
reinterpret_cast<char*
>(&new_l1),
sizeof(
int));
1524 FileStream.read(
reinterpret_cast<char*
>(&new_l2),
sizeof(
int));
1525 FileStream.read(
reinterpret_cast<char*
>(&new_l3),
sizeof(
int));
1526 FileStream.read(
reinterpret_cast<char*
>(&new_l4),
sizeof(
int));
1527 Reallocate(new_l1, new_l2, new_l3, new_l4);
1531 int new_l1, new_l2, new_l3, new_l4, new_l5;
1532 FileStream.read(
reinterpret_cast<char*
>(&new_l1),
sizeof(
int));
1533 FileStream.read(
reinterpret_cast<char*
>(&new_l2),
sizeof(
int));
1534 FileStream.read(
reinterpret_cast<char*
>(&new_l3),
sizeof(
int));
1535 FileStream.read(
reinterpret_cast<char*
>(&new_l4),
sizeof(
int));
1536 FileStream.read(
reinterpret_cast<char*
>(&new_l5),
sizeof(
int));
1537 Reallocate(new_l1, new_l2, new_l3, new_l4, new_l5);
1541 int new_l1, new_l2, new_l3, new_l4, new_l5, new_l6;
1542 FileStream.read(
reinterpret_cast<char*
>(&new_l1),
sizeof(
int));
1543 FileStream.read(
reinterpret_cast<char*
>(&new_l2),
sizeof(
int));
1544 FileStream.read(
reinterpret_cast<char*
>(&new_l3),
sizeof(
int));
1545 FileStream.read(
reinterpret_cast<char*
>(&new_l4),
sizeof(
int));
1546 FileStream.read(
reinterpret_cast<char*
>(&new_l5),
sizeof(
int));
1547 FileStream.read(
reinterpret_cast<char*
>(&new_l6),
sizeof(
int));
1548 Reallocate(new_l1, new_l2, new_l3, new_l4, new_l5, new_l6);
1552 int new_l1, new_l2, new_l3, new_l4, new_l5, new_l6, new_l7;
1553 FileStream.read(
reinterpret_cast<char*
>(&new_l1),
sizeof(
int));
1554 FileStream.read(
reinterpret_cast<char*
>(&new_l2),
sizeof(
int));
1555 FileStream.read(
reinterpret_cast<char*
>(&new_l3),
sizeof(
int));
1556 FileStream.read(
reinterpret_cast<char*
>(&new_l4),
sizeof(
int));
1557 FileStream.read(
reinterpret_cast<char*
>(&new_l5),
sizeof(
int));
1558 FileStream.read(
reinterpret_cast<char*
>(&new_l6),
sizeof(
int));
1559 FileStream.read(
reinterpret_cast<char*
>(&new_l7),
sizeof(
int));
1560 Reallocate(new_l1, new_l2, new_l3, new_l4, new_l5, new_l6,
1565 int new_l1, new_l2, new_l3, new_l4, new_l5, new_l6, new_l7,
1567 FileStream.read(
reinterpret_cast<char*
>(&new_l1),
sizeof(
int));
1568 FileStream.read(
reinterpret_cast<char*
>(&new_l2),
sizeof(
int));
1569 FileStream.read(
reinterpret_cast<char*
>(&new_l3),
sizeof(
int));
1570 FileStream.read(
reinterpret_cast<char*
>(&new_l4),
sizeof(
int));
1571 FileStream.read(
reinterpret_cast<char*
>(&new_l5),
sizeof(
int));
1572 FileStream.read(
reinterpret_cast<char*
>(&new_l6),
sizeof(
int));
1573 FileStream.read(
reinterpret_cast<char*
>(&new_l7),
sizeof(
int));
1574 FileStream.read(
reinterpret_cast<char*
>(&new_l8),
sizeof(
int));
1575 Reallocate(new_l1, new_l2, new_l3, new_l4, new_l5, new_l6,
1580 int new_l1, new_l2, new_l3, new_l4, new_l5, new_l6, new_l7,
1582 FileStream.read(
reinterpret_cast<char*
>(&new_l1),
sizeof(
int));
1583 FileStream.read(
reinterpret_cast<char*
>(&new_l2),
sizeof(
int));
1584 FileStream.read(
reinterpret_cast<char*
>(&new_l3),
sizeof(
int));
1585 FileStream.read(
reinterpret_cast<char*
>(&new_l4),
sizeof(
int));
1586 FileStream.read(
reinterpret_cast<char*
>(&new_l5),
sizeof(
int));
1587 FileStream.read(
reinterpret_cast<char*
>(&new_l6),
sizeof(
int));
1588 FileStream.read(
reinterpret_cast<char*
>(&new_l7),
sizeof(
int));
1589 FileStream.read(
reinterpret_cast<char*
>(&new_l8),
sizeof(
int));
1590 FileStream.read(
reinterpret_cast<char*
>(&new_l9),
sizeof(
int));
1591 Reallocate(new_l1, new_l2, new_l3, new_l4, new_l5, new_l6,
1592 new_l7, new_l8, new_l9);
1596 FileStream.read(
reinterpret_cast<char*
>(data_),
1597 offset_[N - 1] *
sizeof(value_type));
1599 #ifdef SELDON_CHECK_IO
1601 if (!FileStream.good())
1602 throw IOError(
"Array::Read(ifstream& FileStream)",
1603 string(
"Output operation failed.")
1604 +
string(
" The intput file may have been removed")
1605 +
" or may not contain enough data.");
1616 template <
class T,
int N,
class Allocator>
1629 out << A(i, j, k) <<
'\t';
1647 out << A(i, j, k, l) <<
'\t';
1669 out << A(i, j, k, l, m) <<
'\t';
1682 int i, j, k, l, m, n;
1695 out << A(i, j, k, l, m, n) <<
'\t';
1710 int i, j, k, l, m, n, o;
1724 cout << A(i, j, k, l, m, n, o)
1742 int i, j, k, l, m, n, o, p;
1758 cout << A(i, j, k, l, m, n, o, p)
1778 int i, j, k, l, m, n, o, p, q;
1796 cout << A(i, j, k, l, m, n, o, p, q)
1822 #define SELDON_FILE_ARRAY_CXX