53 s.open_readonly(name, bfstream_base::l_endian);
56 it_error(
"it_ifile::open(): Corrupt file (not an it_file)");
80 if (h.
type !=
"" && h.
name == name) {
97 for (
int i = 0; i <= n; i++) {
106 s.seekg((i == n) ? p : p +
static_cast<std::streamoff
>(h.
block_bytes));
112 std::string &desc, uint64_t &bytes)
129 s.read(
reinterpret_cast<char *
>(&h),
sizeof(h));
159 x = (tmp == 0) ?
false :
true;
196 float x_real, x_imag;
199 x = std::complex<float>(x_real, x_imag);
204 double x_real, x_imag;
207 x = std::complex<double>(x_real, x_imag);
215 v.set_size(
static_cast<int>(
size),
false);
216 for (
int i = 0; i < v.size(); ++i) {
227 v.set_size(
static_cast<int>(
size),
false);
228 for (
int i = 0; i < v.size(); ++i) {
239 v.set_size(
static_cast<int>(
size),
false);
240 for (
int i = 0; i < v.size(); ++i) {
251 v.set_size(
static_cast<int>(
size),
false);
252 for (
int i = 0; i < v.size(); ++i) {
254 v(i) =
static_cast<double>(val);
262 v.set_size(
static_cast<int>(
size),
false);
263 for (
int i = 0; i < v.size(); ++i)
270 float val_real, val_imag;
272 v.set_size(
static_cast<int>(
size),
false);
273 for (
int i = 0; i < v.size(); ++i) {
276 v(i) = std::complex<double>(val_real, val_imag);
283 double val_real, val_imag;
285 v.set_size(
static_cast<int>(
size),
false);
286 for (
int i = 0; i < v.size(); ++i) {
289 v(i) = std::complex<double>(val_real, val_imag);
297 std::string::size_type size2 =
static_cast<std::string::size_type
>(
size);
299 for (std::string::size_type i = 0; i < size2; ++i)
308 m.set_size(
static_cast<int>(i),
static_cast<int>(j),
false);
309 for (
int j = 0; j < m.cols(); ++j) {
310 for (
int i = 0; i < m.rows(); ++i) {
322 m.set_size(
static_cast<int>(i),
static_cast<int>(j),
false);
323 for (
int j = 0; j < m.cols(); ++j)
324 for (
int i = 0; i < m.rows(); ++i) {
335 m.set_size(
static_cast<int>(i),
static_cast<int>(j),
false);
336 for (
int j = 0; j < m.cols(); ++j)
337 for (
int i = 0; i < m.rows(); ++i) {
348 m.set_size(
static_cast<int>(i),
static_cast<int>(j),
false);
349 for (
int j = 0; j < m.cols(); ++j)
350 for (
int i = 0; i < m.rows(); ++i) {
352 m(i, j) =
static_cast<double>(val);
360 m.set_size(
static_cast<int>(i),
static_cast<int>(j),
false);
361 for (
int j = 0; j < m.cols(); ++j)
362 for (
int i = 0; i < m.rows(); ++i)
369 float val_real, val_imag;
371 m.set_size(
static_cast<int>(i),
static_cast<int>(j),
false);
372 for (
int j = 0; j < m.cols(); ++j)
373 for (
int i = 0; i < m.rows(); ++i) {
376 m(i, j) = std::complex<double>(val_real, val_imag);
383 double val_real, val_imag;
385 m.set_size(
static_cast<int>(i),
static_cast<int>(j),
false);
386 for (
int j = 0; j < m.cols(); ++j)
387 for (
int i = 0; i < m.rows(); ++i) {
390 m(i, j) = std::complex<double>(val_real, val_imag);
400 for (
int i = 0; i < v.
size(); ++i) {
412 for (
int i = 0; i < v.
size(); ++i) {
424 for (
int i = 0; i < v.
size(); ++i) {
435 for (
int i = 0; i < v.
size(); ++i)
445 for (
int i = 0; i < v.
size(); ++i) {
447 v(i) =
static_cast<double>(val);
456 for (
int i = 0; i < v.
size(); ++i)
463 float val_real, val_imag;
465 v.set_size(
static_cast<int>(
size),
false);
466 for (
int i = 0; i < v.size(); ++i) {
469 v(i) = std::complex<float>(val_real, val_imag);
476 float val_real, val_imag;
478 v.set_size(
static_cast<int>(
size),
false);
479 for (
int i = 0; i < v.size(); ++i) {
482 v(i) = std::complex<double>(val_real, val_imag);
489 double val_real, val_imag;
491 v.set_size(
static_cast<int>(
size),
false);
492 for (
int i = 0; i < v.size(); ++i) {
495 v(i) = std::complex<double>(val_real, val_imag);
507 low_prec(false), _strings(new Strings_Holder)
517 s.open(name, trunc, bfstream_base::l_endian);
518 it_assert(
s.is_open(),
"it_file::open(): Could not open file for writing");
524 it_error(
"it_file::open(): Corrupt file (not an it_file)");
549 "write without a name");
556 const std::string &name, uint64_t
size,
557 const std::string &desc)
562 h1.
hdr_bytes = 3 *
sizeof(uint64_t) + type.size() + 1 + name.size() + 1
579 std::streampos p =
s.tellp();
586 s.seekp(0, std::ios::end);
590 std::streamoff skip =
static_cast<std::streamoff
>(h2.
block_bytes);
605 s.seekp(p +
static_cast<std::streamoff
>(h2.
block_bytes));
637 h.
hdr_bytes = 3 *
sizeof(uint64_t) + 1 + 1 + 1;
641 s.seekp(p +
static_cast<std::streamoff
>(h.
block_bytes));
651 it_assert(
s.is_open(),
"it_file::pack(): File has to be open");
654 s.seekg(0, std::ios::end);
655 std::streampos p =
s.tellg();
656 s.seekg(0, std::ios::beg);
660 char* buffer =
new char[int(p)];
661 char* b_ptr = buffer;
683 s.seekg(p +
static_cast<std::streamoff
>(h.
block_bytes));
688 s.open(fname(),
true, bfstream_base::l_endian);
690 for (uint64_t i = 0; i <
size; ++i)
712 s.seekg(p +
static_cast<std::streamoff
>(h.
block_bytes));
771 for (
int i = 0; i < v.size(); ++i)
778 for (
int i = 0; i < v.size(); ++i)
779 s <<
static_cast<int16_t
>(v(i));
785 for (
int i = 0; i < v.size(); ++i)
786 s <<
static_cast<int32_t
>(v(i));
793 for (
int i = 0; i < v.size(); ++i)
794 s <<
static_cast<float>(v(i));
797 for (
int i = 0; i < v.size(); ++i)
806 for (
int i = 0; i < v.size(); ++i) {
812 for (
int i = 0; i < v.size(); ++i) {
822 for (std::string::size_type i = 0; i < str.size(); ++i)
829 <<
static_cast<uint64_t
>(m.cols());
830 for (
int j = 0; j < m.cols(); ++j)
831 for (
int i = 0; i < m.rows(); ++i)
832 s << m(i, j).value();
838 <<
static_cast<uint64_t
>(m.cols());
839 for (
int j = 0; j < m.cols(); ++j)
840 for (
int i = 0; i < m.rows(); ++i)
841 s <<
static_cast<int16_t
>(m(i, j));
847 <<
static_cast<uint64_t
>(m.cols());
848 for (
int j = 0; j < m.cols(); ++j)
849 for (
int i = 0; i < m.rows(); ++i)
850 s <<
static_cast<int32_t
>(m(i, j));
856 <<
static_cast<uint64_t
>(m.cols());
858 for (
int j = 0; j < m.cols(); ++j)
859 for (
int i = 0; i < m.rows(); ++i)
860 s <<
static_cast<float>(m(i, j));
863 for (
int j = 0; j < m.cols(); ++j)
864 for (
int i = 0; i < m.rows(); ++i)
872 <<
static_cast<uint64_t
>(m.cols());
874 for (
int j = 0; j < m.cols(); ++j)
875 for (
int i = 0; i < m.rows(); ++i) {
881 for (
int j = 0; j < m.cols(); ++j)
882 for (
int i = 0; i < m.rows(); ++i) {
892 for (
int i = 0; i < v.
size(); ++i)
899 for (
int i = 0; i < v.
size(); ++i)
900 s <<
static_cast<int16_t
>(v(i));
906 for (
int i = 0; i < v.
size(); ++i)
907 s <<
static_cast<int32_t
>(v(i));
913 for (
int i = 0; i < v.
size(); ++i)
921 for (
int i = 0; i < v.
size(); ++i)
922 s <<
static_cast<float>(v(i));
925 for (
int i = 0; i < v.
size(); ++i)
926 s <<
static_cast<double>(v(i));
933 for (
int i = 0; i < v.size(); ++i) {
943 for (
int i = 0; i < v.size(); ++i) {
949 for (
int i = 0; i < v.size(); ++i) {
961 it_assert(h.
type ==
"int8",
"it_ifile::operator>>(): Wrong type");
970 it_assert(h.
type ==
"bool",
"it_ifile::operator>>(): Wrong type");
979 it_assert(h.
type ==
"bin",
"it_ifile::operator>>(): Wrong type");
988 it_assert(h.
type ==
"int16",
"it_ifile::operator>>(): Wrong type");
997 if (h.
type ==
"int32")
999 else if (h.
type ==
"int16") {
1002 x =
static_cast<int>(x16);
1005 it_error(
"it_ifile::operator>>(): Wrong type");
1014 it_assert(h.
type ==
"float32",
"it_ifile::operator>>(): Wrong type");
1023 if (h.
type ==
"float64")
1025 else if (h.
type ==
"float32") {
1028 x =
static_cast<double>(f32);
1031 it_error(
"it_ifile::operator>>(): Wrong type");
1041 "it_ifile::operator>>(): Wrong type");
1050 if (h.
type ==
"cfloat64")
1052 else if (h.
type ==
"cfloat32") {
1053 std::complex<float> f32_c;
1055 x =
static_cast<std::complex<double>
>(f32_c);
1058 it_error(
"it_ifile::operator>>(): Wrong type");
1067 it_assert(h.
type ==
"bvec",
"it_ifile::operator>>(): Wrong type");
1076 it_assert(h.
type ==
"svec",
"it_ifile::operator>>(): Wrong type");
1085 it_assert(h.
type ==
"ivec",
"it_ifile::operator>>(): Wrong type");
1095 if (h.
type ==
"fvec")
1097 else if (h.
type ==
"dvec")
1100 it_error(
"it_ifile::operator>>(): Wrong type");
1110 if (h.
type ==
"fcvec")
1112 else if (h.
type ==
"dcvec")
1115 it_error(
"it_ifile::operator>>(): Wrong type");
1124 it_assert(h.
type ==
"string",
"it_ifile::operator>>(): Wrong type");
1133 it_assert(h.
type ==
"bmat",
"it_ifile::operator>>(): Wrong type");
1142 it_assert(h.
type ==
"smat",
"it_ifile::operator>>(): Wrong type");
1151 it_assert(h.
type ==
"imat",
"it_ifile::operator>>(): Wrong type");
1161 if (h.
type ==
"fmat")
1163 else if (h.
type ==
"dmat")
1166 it_error(
"it_ifile::operator>>(): Wrong type");
1175 if (h.
type ==
"fcmat")
1177 else if (h.
type ==
"dcmat")
1180 it_error(
"it_ifile::operator>>(): Wrong type");
1189 it_assert(h.
type ==
"bArray",
"it_ifile::operator>>(): Wrong type");
1198 it_assert(h.
type ==
"sArray",
"it_ifile::operator>>(): Wrong type");
1207 it_assert(h.
type ==
"iArray",
"it_ifile::operator>>(): Wrong type");
1216 it_assert(h.
type ==
"fArray",
"it_ifile::operator>>(): Wrong type");
1225 if (h.
type ==
"fArray")
1227 else if (h.
type ==
"dArray")
1230 it_error(
"it_ifile::operator>>(): Wrong type");
1239 it_assert(h.
type ==
"fcArray",
"it_ifile::operator>>(): Wrong type");
1248 if (h.
type ==
"fcArray")
1250 else if (h.
type ==
"dcArray")
1253 it_error(
"it_ifile::operator>>(): Wrong type");
1262 it_assert(h.
type ==
"bvecArray",
"it_ifile::operator>>(): Wrong type");
1265 int size =
static_cast<int>(n);
1267 for (
int i = 0; i <
size; ++i)
1277 it_assert(h.
type ==
"svecArray",
"it_ifile::operator>>(): Wrong type");
1280 int size =
static_cast<int>(n);
1282 for (
int i = 0; i <
size; ++i)
1292 it_assert(h.
type ==
"ivecArray",
"it_ifile::operator>>(): Wrong type");
1295 int size =
static_cast<int>(n);
1297 for (
int i = 0; i <
size; ++i)
1307 it_assert(h.
type ==
"vecArray",
"it_ifile::operator>>(): Wrong type");
1310 int size =
static_cast<int>(n);
1312 for (
int i = 0; i <
size; ++i)
1322 it_assert(h.
type ==
"cvecArray",
"it_ifile::operator>>(): Wrong type");
1325 int size =
static_cast<int>(n);
1327 for (
int i = 0; i <
size; ++i)
1337 it_assert(h.
type ==
"stringArray",
"it_ifile::operator>>(): Wrong type");
1340 int size =
static_cast<int>(n);
1342 for (
int i = 0; i <
size; ++i)
1352 it_assert(h.
type ==
"bmatArray",
"it_ifile::operator>>(): Wrong type");
1355 int size =
static_cast<int>(n);
1357 for (
int i = 0; i <
size; ++i)
1367 it_assert(h.
type ==
"smatArray",
"it_ifile::operator>>(): Wrong type");
1370 int size =
static_cast<int>(n);
1372 for (
int i = 0; i <
size; ++i)
1382 it_assert(h.
type ==
"imatArray",
"it_ifile::operator>>(): Wrong type");
1385 int size =
static_cast<int>(n);
1387 for (
int i = 0; i <
size; ++i)
1397 it_assert(h.
type ==
"matArray",
"it_ifile::operator>>(): Wrong type");
1400 int size =
static_cast<int>(n);
1402 for (
int i = 0; i <
size; ++i)
1412 it_assert(h.
type ==
"cmatArray",
"it_ifile::operator>>(): Wrong type");
1415 int size =
static_cast<int>(n);
1417 for (
int i = 0; i <
size; ++i)
1512 + v.size() *
sizeof(
float));
1515 + v.size() *
sizeof(
double));
1524 + v.size() * 2 *
sizeof(
float));
1527 + v.size() * 2 *
sizeof(
double));
1542 + m.rows() * m.cols() *
sizeof(
char));
1550 + m.rows() * m.cols() *
sizeof(int16_t));
1558 + m.rows() * m.cols() *
sizeof(int32_t));
1567 + m.rows() * m.cols() *
sizeof(
float));
1570 + m.rows() * m.cols() *
sizeof(
double));
1579 + m.rows() * m.cols() * 2 *
sizeof(
float));
1582 + m.rows() * m.cols() * 2 *
sizeof(
double));
1597 + v.
size() *
sizeof(int16_t));
1605 + v.
size() *
sizeof(int32_t));
1621 + v.
size() *
sizeof(
float));
1624 + v.
size() *
sizeof(
double));
1632 + v.size() * 2 *
sizeof(
float));
1641 + v.size() * 2 *
sizeof(
float));
1644 + v.size() * 2 *
sizeof(
double));
1653 for (
int i = 0; i < v.
size(); ++i)
1654 sum_l += v(i).
size();
1658 + sum_l *
sizeof(
char));
1663 for (
int i = 0; i < v.
size(); ++i)
1673 for (
int i = 0; i < v.
size(); ++i)
1674 sum_l += v(i).
size();
1678 + sum_l *
sizeof(int16_t));
1683 for (
int i = 0; i < v.
size(); ++i)
1693 for (
int i = 0; i < v.
size(); ++i)
1694 sum_l += v(i).
size();
1698 + sum_l *
sizeof(int32_t));
1703 for (
int i = 0; i < v.
size(); ++i)
1713 for (
int i = 0; i < v.
size(); ++i)
1714 sum_l += v(i).
size();
1718 + sum_l *
sizeof(
double));
1723 for (
int i = 0; i < v.
size(); ++i)
1733 for (
int i = 0; i < v.
size(); ++i)
1734 sum_l += v(i).
size();
1738 + sum_l * 2 *
sizeof(
double));
1743 for (
int i = 0; i < v.
size(); ++i)
1753 for (
int i = 0; i < v.
size(); ++i)
1754 sum_l +=
int(v(i).
size());
1758 + sum_l *
sizeof(
char));
1763 for (
int i = 0; i < v.
size(); ++i)
1773 for (
int i = 0; i < v.
size(); ++i)
1774 sum_l += v(i)._datasize();
1778 + sum_l *
sizeof(
char));
1783 for (
int i = 0; i < v.
size(); ++i)
1793 for (
int i = 0; i < v.
size(); ++i)
1794 sum_l += v(i)._datasize();
1798 + sum_l *
sizeof(int16_t));
1803 for (
int i = 0; i < v.
size(); ++i)
1813 for (
int i = 0; i < v.
size(); ++i)
1814 sum_l += v(i)._datasize();
1818 + sum_l *
sizeof(int32_t));
1823 for (
int i = 0; i < v.
size(); ++i)
1833 for (
int i = 0; i < v.
size(); ++i)
1834 sum_l += v(i)._datasize();
1838 + sum_l *
sizeof(
double));
1843 for (
int i = 0; i < v.
size(); ++i)
1853 for (
int i = 0; i < v.
size(); ++i)
1854 sum_l += v(i)._datasize();
1858 + sum_l * 2 *
sizeof(
double));
1863 for (
int i = 0; i < v.
size(); ++i)
1892 s.open_readonly(name);
1896 it_error(
"Corrupt file (Not an it-file)");
1921 if (h.
type !=
"" && h.
name == name) {
1925 s.seekg(p +
static_cast<std::streamoff
>(h.
block_bytes));
1938 for (
int i = 0; i <= n; i++) {
1947 s.seekg(i == n ? p : p +
static_cast<std::streamoff
>(h.
block_bytes));
1969 memset(&h, 0,
sizeof(h));
1970 s.read(
reinterpret_cast<char *
>(&h),
sizeof(h));
1977 std::streampos p =
s.tellg();
1992 s.seekg(p +
static_cast<std::streamoff
>(h.
hdr_bytes));
2029 float x_real, x_imag;
2032 x = std::complex<float>(x_real, x_imag);
2037 double x_real, x_imag;
2040 x = std::complex<double>(x_real, x_imag);
2049 v.set_size(i,
false);
2050 for (i = 0; i < v.size(); i++) {
2052 v(i) =
static_cast<double>(val);
2062 v.set_size(i,
false);
2063 for (i = 0; i < v.size(); i++) {
2065 v(i) =
static_cast<double>(val);
2074 v.set_size(i,
false);
2075 for (i = 0; i < v.size(); i++) {
2086 v.set_size(i,
false);
2087 for (i = 0; i < v.size(); i++)
2094 float val_real, val_imag;
2097 v.set_size(i,
false);
2098 for (i = 0; i < v.size(); i++) {
2101 v(i) = std::complex<double>(val_real, val_imag);
2108 double val_real, val_imag;
2111 v.set_size(i,
false);
2112 for (i = 0; i < v.size(); i++) {
2115 v(i) = std::complex<double>(val_real, val_imag);
2127 for (j = 0; j < i; j++) {
2139 m.set_size(i, j,
false);
2140 for (j = 0; j < m.cols(); j++)
2141 for (i = 0; i < m.rows(); i++) {
2143 m(i, j) =
static_cast<double>(val);
2153 m.set_size(i, j,
false);
2154 for (j = 0; j < m.cols(); j++)
2155 for (i = 0; i < m.rows(); i++) {
2157 m(i, j) =
static_cast<double>(val);
2166 m.set_size(i, j,
false);
2167 for (j = 0; j < m.cols(); j++)
2168 for (i = 0; i < m.rows(); i++) {
2179 m.set_size(i, j,
false);
2180 for (j = 0; j < m.cols(); j++)
2181 for (i = 0; i < m.rows(); i++)
2188 float val_real, val_imag;
2191 m.set_size(i, j,
false);
2192 for (j = 0; j < m.cols(); j++)
2193 for (i = 0; i < m.rows(); i++) {
2196 m(i, j) = std::complex<double>(val_real, val_imag);
2203 double val_real, val_imag;
2206 m.set_size(i, j,
false);
2207 for (j = 0; j < m.cols(); j++)
2208 for (i = 0; i < m.rows(); i++) {
2211 m(i, j) = std::complex<double>(val_real, val_imag);
2223 for (i = 0; i < v.
size(); i++) {
2236 for (i = 0; i < v.
size(); i++) {
2238 v(i) =
static_cast<double>(val);
2249 for (i = 0; i < v.
size(); i++) {
2251 v(i) =
static_cast<double>(val);
2261 for (i = 0; i < v.
size(); i++) {
2273 for (i = 0; i < v.
size(); i++)
2280 float val_real, val_imag;
2283 v.set_size(i,
false);
2284 for (i = 0; i < v.size(); i++) {
2287 v(i) = std::complex<float>(val_real, val_imag);
2294 float val_real, val_imag;
2297 v.set_size(i,
false);
2298 for (i = 0; i < v.size(); i++) {
2301 v(i) = std::complex<double>(val_real, val_imag);
2308 double val_real, val_imag;
2311 v.set_size(i,
false);
2312 for (i = 0; i < v.size(); i++) {
2315 v(i) = std::complex<double>(val_real, val_imag);
2325_string(new String_Holder())
2336 s.open(name, trunc);
2337 it_error_if(!
s.is_open(),
"Could not open file for writing");
2343 it_error(
"Corrupt file (Not an it-file)");
2371 const std::string &name, uint32_t
size)
2376 bool removed =
false;
2379 h1.
endianity =
static_cast<char>(
s.get_native_endianity());
2380 h1.
hdr_bytes = 1 + 3 * 4 + int(type.size()) + 1 + int(name.size()) + 1;
2400 if (h2.
type !=
"" && h2.
name == name) {
2409 if (availpos == 0) {
2424 s.seekg(p +
static_cast<std::streamoff
>(skip));
2429 s.seekp(0, std::ios::end);
2459 s.seekp(p +
static_cast<std::streamoff
>(h.
block_bytes));
2521 for (
int i = 0; i < v.size(); i++)
2522 s <<
static_cast<float>(v(i));
2526 for (
int i = 0; i < v.size(); i++)
2527 s <<
static_cast<double>(v(i));
2534 for (
int i = 0; i < v.size(); i++)
2535 s <<
static_cast<int32_t
>(v(i));
2541 for (
int i = 0; i < v.size(); i++)
2549 for (
int i = 0; i < v.size(); i++) {
2556 for (
int i = 0; i < v.size(); i++) {
2565 int size = int(str.size());
2568 for (
int i = 0; i <
size; i++)
2578 for (j = 0; j < m.cols(); j++)
2579 for (i = 0; i < m.rows(); i++)
2580 s <<
static_cast<float>(m(i, j));
2584 for (j = 0; j < m.cols(); j++)
2585 for (i = 0; i < m.rows(); i++)
2586 s <<
static_cast<double>(m(i, j));
2595 for (j = 0; j < m.cols(); j++)
2596 for (i = 0; i < m.rows(); i++)
2597 s <<
static_cast<int32_t
>(m(i, j));
2605 for (j = 0; j < m.cols(); j++)
2606 for (i = 0; i < m.rows(); i++)
2607 s << m(i, j).value();
2616 for (j = 0; j < m.cols(); j++)
2617 for (i = 0; i < m.rows(); i++) {
2625 for (j = 0; j < m.cols(); j++)
2626 for (i = 0; i < m.rows(); i++) {
2636 for (
int i = 0; i < v.
size(); i++)
2644 for (
int i = 0; i < v.
size(); i++)
2645 s <<
static_cast<float>(v(i));
2649 for (
int i = 0; i < v.
size(); i++)
2650 s <<
static_cast<double>(v(i));
2657 for (
int i = 0; i < v.
size(); i++)
2658 s <<
static_cast<int32_t
>(v(i));
2664 for (
int i = 0; i < v.
size(); i++)
2671 for (
int i = 0; i < v.size(); i++) {
2681 for (
int i = 0; i < v.size(); i++) {
2688 for (
int i = 0; i < v.size(); i++) {
2700 if (h.
type ==
"int8")
2713 if (h.
type ==
"bin")
2726 if (h.
type ==
"int16")
2739 if (h.
type ==
"int32")
2741 else if (h.
type ==
"int16") {
2757 if (h.
type ==
"float64")
2759 else if (h.
type ==
"float32") {
2775 if (h.
type ==
"float32")
2789 if (h.
type ==
"float32_complex") {
2790 std::complex<float> f32_c;
2805 if (h.
type ==
"float64_complex")
2807 else if (h.
type ==
"float32_complex") {
2808 std::complex<float> f32_c;
2823 if (h.
type ==
"fvec")
2825 else if (h.
type ==
"dvec")
2838 if (h.
type ==
"ivec")
2851 if (h.
type ==
"bvec")
2864 if (h.
type ==
"fcvec")
2866 else if (h.
type ==
"dcvec")
2879 if (h.
type ==
"string")
2892 if (h.
type ==
"fmat")
2894 else if (h.
type ==
"dmat")
2907 if (h.
type ==
"imat")
2920 if (h.
type ==
"bmat")
2933 if (h.
type ==
"fcmat")
2935 else if (h.
type ==
"dcmat")
2948 if (h.
type ==
"fArray")
2961 if (h.
type ==
"fArray")
2963 else if (h.
type ==
"dArray")
2976 if (h.
type ==
"iArray")
2989 if (h.
type ==
"bArray")
3002 if (h.
type ==
"fcArray")
3015 if (h.
type ==
"fcArray")
3017 else if (h.
type ==
"dcArray")
3030 if (h.
type ==
"vecArray") {
3034 for (
int i = 0; i < n; i++)
3048 if (h.
type ==
"ivecArray") {
3052 for (
int i = 0; i < n; i++)
3066 if (h.
type ==
"bvecArray") {
3070 for (
int i = 0; i < n; i++)
3084 if (h.
type ==
"cvecArray") {
3088 for (
int i = 0; i < n; i++)
3102 if (h.
type ==
"stringArray") {
3106 for (
int i = 0; i < n; i++)
3120 if (h.
type ==
"matArray") {
3124 for (
int i = 0; i < n; i++)
3138 if (h.
type ==
"imatArray") {
3142 for (
int i = 0; i < n; i++)
3156 if (h.
type ==
"bmatArray") {
3160 for (
int i = 0; i < n; i++)
3174 if (h.
type ==
"cmatArray") {
3178 for (
int i = 0; i < n; i++)
3327 f.
write_data_header(
"fcmat", 2*
sizeof(
int) + 2*m.rows()*m.cols()*
sizeof(
float));
3329 f.
write_data_header(
"dcmat", 2*
sizeof(
int) + 2*m.rows()*m.cols()*
sizeof(
double));
3394 for (i = 0; i < v.
size(); i++) {
3395 sum_l += v(i).
size();
3404 for (i = 0; i < v.
size(); i++)
3415 for (i = 0; i < v.
size(); i++) {
3416 sum_l += v(i).
size();
3425 for (i = 0; i < v.
size(); i++)
3436 for (i = 0; i < v.
size(); i++) {
3437 sum_l += v(i).
size();
3446 for (i = 0; i < v.
size(); i++)
3457 for (i = 0; i < v.
size(); i++) {
3458 sum_l += v(i).
size();
3462 f.
write_data_header(
"cvecArray",
sizeof(
int)*(1 + v.
size()) + sum_l *
sizeof(std::complex<double>));
3467 for (i = 0; i < v.
size(); i++)
3478 for (i = 0; i < v.
size(); i++) {
3479 sum_l += int(v(i).
size());
3488 for (i = 0; i < v.
size(); i++)
3499 for (i = 0; i < v.
size(); i++) {
3500 sum_l += v(i)._datasize();
3509 for (i = 0; i < v.
size(); i++)
3520 for (i = 0; i < v.
size(); i++) {
3521 sum_l += v(i)._datasize();
3530 for (i = 0; i < v.
size(); i++)
3541 for (i = 0; i < v.
size(); i++) {
3542 sum_l += v(i)._datasize();
3551 for (i = 0; i < v.
size(); i++)
3562 for (i = 0; i < v.
size(); i++) {
3563 sum_l += v(i)._datasize();
3567 f.
write_data_header(
"cmatArray",
sizeof(
int)*(1 + 2*v.
size()) + sum_l *
sizeof(std::complex<double>));
3572 for (i = 0; i < v.
size(); i++)
int size() const
Returns the number of data elements in the array object.
void set_size(int n, bool copy=false)
Resizing an Array<T>.
endian
Definition of the endian data type.
Binary arithmetic (boolean) class.
char value() const
Output the binary value of the object.
static char file_version
ACTION: Add documentation.
static char file_magic[4]
ACTION: Add documentation.
static char file_magic[4]
IT++ file marker: "IT++".
static char file_version
IT++ file version.
The old (version 2) IT++ file format reading and writing class.
void write_data_header(const std::string &type, uint32_t size)
Write the data header for a variable, specifying the type and size of the data to follow.
bool low_prec
ACTION: Add documenation for this protected member.
void flush()
Flush the data to disk.
void close()
Close the file.
bool get_low_precision()
Get the precision.
bool exists(const std::string &name)
Returns true if the variable name exists in the file.
it_file_old()
Constructor.
std::string & next_name()
ACTION: Add documenation for this protected member.
void write_file_header()
Write the header for the it_file_old.
void low_level_write(char x)
Write a char value at the current file pointer position.
void remove()
ACTION: Add documenation for this protected member.
void open(const std::string &name, bool trunc=false)
Open a file for reading and writing.
void write_data_header_here(const data_header &h)
ACTION: Add documenation for this protected member.
void pack()
Remove slack space from the file.
The IT++ file format reading and writing class.
void write_data_header(const std::string &type, uint64_t size)
Write the data header for a variable, specifying the type and size of the data to follow.
void flush()
Flush the data to disk.
bool get_low_precision() const
Get the precision.
std::string & next_name()
Name to be used for saving the next variable.
void open(const std::string &filename, bool trunc=false)
Open a file for reading and writing.
void write_data_header_here(const data_header &h)
Write data header h at the current file position.
void close()
Close the file.
std::string & next_desc()
Description to be used for saving the next variable.
void write_file_header()
Write the header for the it_file.
void remove()
Remove the current variable, denoted by next_name.
bool exists(const std::string &name)
Returns true if the variable name exists in the file.
bool low_prec
Low precision flag. If true, use float type, otherwise double.
it_file()
Default constructor.
void pack()
Remove slack space from the file.
void low_level_write(char x)
Write a char value at the current file pointer position.
The old (version 2) IT++ file format reading class.
void open(const std::string &name)
Open a file. The file must exist.
void low_level_read_lo(vec &v)
Read a vector of float values at the current file pointer position.
bool seek(const std::string &name)
Find the variable name.
void low_level_read_hi(vec &v)
Read a vector of double values at the current file pointer position.
it_ifile_old()
Constructor.
void info(std::string &name, std::string &type, int &bytes)
Get information about the current variable.
void low_level_read(char &x)
Read a char value at the current file pointer position.
void read_data_header(data_header &h)
Read the data header and return the result in the variable h.
virtual void close()
Close a file.
bool read_check_file_header()
Reads and checks the file data header. Returns true if the header is valid and false otherwise.
bfstream s
Protected binary file stream.
The IT++ file format reading class.
bool seek(const std::string &name)
Find the variable name.
void open(const std::string &filename)
Open an existing file in read-only mode.
virtual void close()
Close the file.
void low_level_read(char &x)
Read a char value at the current file pointer position.
void low_level_read_lo(vec &v)
Read a vector of float values at the current file pointer position.
bool read_check_file_header()
Read and check the file header. Return true if the header is valid and false otherwise.
void read_data_header(it_file_base::data_header &h)
Read data header and return the result in the variable h.
bfstream s
Protected binary file stream.
void info(std::string &name, std::string &type, std::string &desc, uint64_t &bytes)
Get information about the current variable.
void low_level_read_hi(vec &v)
Read a vector of double values at the current file pointer position.
it_ifile()
Default constructor.
#define it_error_if(t, s)
Abort if t is true.
#define it_error(s)
Abort unconditionally.
#define it_warning(s)
Display a warning message.
#define it_assert(t, s)
Abort if t is not true.
bool exist(const std::string &name)
Checks if a file named name already exists on the disk.
int size(const Vec< T > &v)
Length of vector.
vec imag(const cvec &data)
Imaginary part of complex values.
vec real(const cvec &data)
Real part of complex values.
Definition of classes for the IT++ file format.
Mat< bin > bmat
bin matrix
std::ostream & operator<<(std::ostream &output, const bin &inbin)
Output stream of bin.
std::istream & operator>>(std::istream &input, bin &outbin)
Input stream of bin.