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);
467 int32_t name_len = name.length () + 1;
469 os.write (reinterpret_cast<char *> (&name_len), 4);
486 const char *s = tstr.data ();
489 buf[j*nrow+i] = static_cast<double> (*s++ & 0x00FF);
491 std::streamsize n_bytes =
static_cast<std::streamsize
> (nrow) *
492 static_cast<std::streamsize> (ncol) *
494 os.write (reinterpret_cast<char *> (buf), n_bytes);
499 double base = r.
base ();
500 double inc = r.
inc ();
504 double x = base + i * inc;
505 os.write (reinterpret_cast<char *> (&x), 8);
511 os.write (reinterpret_cast<char *> (&tmp), 8);
522 dtmp[i] = m.
ridx (i) + 1;
523 std::streamsize n_bytes = 8 *
static_cast<std::streamsize
> (len);
524 os.write (reinterpret_cast<const char *> (dtmp), n_bytes);
526 os.write (reinterpret_cast<const char *> (&ds), 8);
532 os.write (reinterpret_cast<const char *> (dtmp), n_bytes);
534 os.write (reinterpret_cast<const char *> (&ds), 8);
538 os.write (reinterpret_cast<const char *> (dtmp), n_bytes);
540 os.write (reinterpret_cast<const char *> (&ds), 8);
544 os.write (reinterpret_cast<const char *> (dtmp), n_bytes);
545 os.write (reinterpret_cast<const char *> (&ds), 8);
552 dtmp[i] = m.
ridx (i) + 1;
553 std::streamsize n_bytes = 8 *
static_cast<std::streamsize
> (len);
554 os.write (reinterpret_cast<const char *> (dtmp), n_bytes);
556 os.write (reinterpret_cast<const char *> (&ds), 8);
562 os.write (reinterpret_cast<const char *> (dtmp), n_bytes);
564 os.write (reinterpret_cast<const char *> (&ds), 8);
566 os.write (reinterpret_cast<const char *> (m.
data ()), n_bytes);
568 os.write (reinterpret_cast<const char *> (&ds), 8);
574 std::streamsize n_bytes = 8 *
static_cast<std::streamsize
> (len);
575 os.write (reinterpret_cast<const char *> (m.
data ()), n_bytes);
580 os.write (reinterpret_cast<char *> (&tmp), 16);
586 std::streamsize n_bytes = 8 *
static_cast<std::streamsize
> (len);
587 os.write (reinterpret_cast<const char *> (m.
data ()), n_bytes);
589 os.write (reinterpret_cast<const char *> (m.
data ()), n_bytes);
octave_idx_type nnz(void) const
bool is_range(void) const
void gripe_wrong_type_arg(const char *name, const char *s, bool is_error)
octave_idx_type rows(void) const
void resize(octave_idx_type nr, octave_idx_type nc, double rfv=0)
SparseMatrix transpose(void) const
octave_idx_type nelem(void) const
bool is_complex_scalar(void) const
void error(const char *fmt,...)
octave_idx_type * cidx(void)
static void read_mat_binary_data(std::istream &is, double *data, int precision, int len, bool swap, oct_mach_info::float_format flt_fmt)
std::string row_as_string(octave_idx_type, bool strip_ws=false) const
octave_idx_type rows(void) const
SparseComplexMatrix transpose(void) const
int read_mat_file_header(std::istream &is, bool &swap, int32_t &mopt, int32_t &nr, int32_t &nc, int32_t &imag, int32_t &len, int quiet)
octave_idx_type columns(void) const
void swap_bytes< 4 >(void *ptr)
octave_value convert_to_str(bool pad=false, bool force=false, char type= '\'') const
bool is_complex_matrix(void) const
bool is_sparse_type(void) const
bool is_real_scalar(void) const
Range range_value(void) const
bool is_string(void) const
const T * data(void) const
bool is_complex_type(void) const
int float_format_to_mopt_digit(oct_mach_info::float_format flt_fmt)
Matrix transpose(void) const
static bool words_big_endian(void)
ComplexMatrix transpose(void) const
oct_mach_info::float_format mopt_digit_to_float_format(int mach)
SparseComplexMatrix sparse_complex_matrix_value(bool frc_str_conv=false) const
void read_doubles(std::istream &is, double *data, save_type type, octave_idx_type len, bool swap, oct_mach_info::float_format fmt)
Matrix matrix_value(bool frc_str_conv=false) const
charMatrix char_matrix_value(bool frc_str_conv=false) const
T & xelem(octave_idx_type n)
Handles the reference counting for all the derived classes.
octave_idx_type * ridx(void)
static float_format native_float_format(void)
ComplexMatrix complex_matrix_value(bool frc_str_conv=false) const
bool save_mat_binary_data(std::ostream &os, const octave_value &tc, const std::string &name)
Complex complex_value(bool frc_str_conv=false) const
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
ColumnVector imag(const ComplexColumnVector &a)
SparseMatrix sparse_matrix_value(bool frc_str_conv=false) const
std::complex< double > Complex
const T * fortran_vec(void) const
ColumnVector real(const ComplexColumnVector &a)
double double_value(bool frc_str_conv=false) const
octave_idx_type cols(void) const
F77_RET_T const double * x
bool is_real_matrix(void) const