113 int32_t& nr, int32_t& nc,
114 int32_t&
imag, int32_t& len,
123 is.read (reinterpret_cast<char *> (&mopt), 4);
127 if (! is.read (reinterpret_cast<char *> (&nr), 4))
128 goto data_read_error;
130 if (! is.read (reinterpret_cast<char *> (&nc), 4))
131 goto data_read_error;
133 if (! is.read (reinterpret_cast<char *> (&imag), 4))
134 goto data_read_error;
136 if (! is.read (reinterpret_cast<char *> (&len), 4))
137 goto data_read_error;
153 if (mopt > 9999 || mopt < 0)
165 if (mopt > 9999 || mopt < 0 || imag > 1 || imag < 0)
168 error (
"load: can't read binary file");
258 int32_t mopt, nr, nc,
imag, len;
264 goto data_read_error;
281 error (
"load: unrecognized binary format!");
285 if (imag && type == 1)
287 error (
"load: encountered complex matrix with string flag set!");
298 if (! is.read (name, len))
299 goto data_read_error;
304 goto data_read_error;
326 r.
xelem (i) = dtmp[i] - 1;
327 nr_new = dtmp[nr - 1];
330 c.
xelem (i) = dtmp[i] - 1;
331 nc_new = dtmp[nr - 1];
355 r.
xelem (i) = dtmp[i] - 1;
356 nr_new = dtmp[nr - 1];
359 c.
xelem (i) = dtmp[i] - 1;
360 nc_new = dtmp[nr - 1];
378 error (
"load: reading matrix data for '%s'", name);
379 goto data_read_error;
391 error (
"load: reading imaginary matrix data for '%s'", name);
392 goto data_read_error;
399 ctmp (i, j) =
Complex (re (i, j), im (i, j));
414 error (
"load: trouble reading binary file '%s'", filename.c_str ());
423 const std::string& name)
434 os.write (reinterpret_cast<char *> (&mopt), 4);
437 int32_t nr = tc.
rows ();
444 uint32_t nnz = len + 1;
445 os.write (reinterpret_cast<char *> (&nnz), 4);
448 os.write (reinterpret_cast<char *> (&iscmplx), 4);
451 os.write (reinterpret_cast<char *> (&tmp), 4);
455 os.write (reinterpret_cast<char *> (&nr), 4);
456 os.write (reinterpret_cast<char *> (&nc), 4);
459 os.write (reinterpret_cast<char *> (&imag), 4);
468 int32_t name_len = name.length () + 1;
470 os.write (reinterpret_cast<char *> (&name_len), 4);
487 const char *s = tstr.data ();
490 buf[j*nrow+i] = static_cast<double> (*s++ & 0x00FF);
492 os.write (reinterpret_cast<char *> (buf), nrow*ncol*
sizeof (
double));
497 double base = r.
base ();
498 double inc = r.
inc ();
502 double x = base + i * inc;
503 os.write (reinterpret_cast<char *> (&x), 8);
509 os.write (reinterpret_cast<char *> (&tmp), 8);
520 dtmp[i] = m.
ridx (i) + 1;
521 os.write (reinterpret_cast<const char *> (dtmp), 8 * len);
523 os.write (reinterpret_cast<const char *> (&ds), 8);
529 os.write (reinterpret_cast<const char *> (dtmp), 8 * len);
531 os.write (reinterpret_cast<const char *> (&ds), 8);
535 os.write (reinterpret_cast<const char *> (dtmp), 8 * len);
537 os.write (reinterpret_cast<const char *> (&ds), 8);
541 os.write (reinterpret_cast<const char *> (dtmp), 8 * len);
542 os.write (reinterpret_cast<const char *> (&ds), 8);
549 dtmp[i] = m.
ridx (i) + 1;
550 os.write (reinterpret_cast<const char *> (dtmp), 8 * len);
552 os.write (reinterpret_cast<const char *> (&ds), 8);
558 os.write (reinterpret_cast<const char *> (dtmp), 8 * len);
560 os.write (reinterpret_cast<const char *> (&ds), 8);
562 os.write (reinterpret_cast<const char *> (m.
data ()), 8 * len);
564 os.write (reinterpret_cast<const char *> (&ds), 8);
570 os.write (reinterpret_cast<const char *> (m.
data ()), 8 * len);
575 os.write (reinterpret_cast<char *> (&tmp), 16);
581 os.write (reinterpret_cast<const char *> (m.
data ()), 8 * len);
583 os.write (reinterpret_cast<const char *> (m.
data ()), 8 * len);