26 #if defined (HAVE_CONFIG_H)
108 int32_t& nr, int32_t& nc,
118 is.read (
reinterpret_cast<char *
> (&mopt), 4);
122 if (! is.read (
reinterpret_cast<char *
> (&nr), 4))
125 if (! is.read (
reinterpret_cast<char *
> (&nc), 4))
128 if (! is.read (
reinterpret_cast<char *
> (&
imag), 4))
131 if (! is.read (
reinterpret_cast<char *
> (&
len), 4))
147 if (mopt > 9999 || mopt < 0)
159 if (mopt > 9999 || mopt < 0 || imag > 1 ||
imag < 0)
162 error (
"load: can't read binary file");
238 int32_t mopt, nr, nc,
imag,
len;
244 error (
"load: trouble reading binary file '%s'", filename.c_str ());
266 error (
"load: unrecognized binary format!");
268 if (
imag && type == 1)
269 error (
"load: encountered complex matrix with string flag set!");
280 if (! is.read (name,
len))
281 error (
"load: trouble reading binary file '%s'", filename.c_str ());
286 error (
"load: trouble reading binary file '%s'", filename.c_str ());
308 r.xelem (i) = dtmp[i] - 1;
309 nr_new = dtmp[nr - 1];
312 c.
xelem (i) = dtmp[i] - 1;
313 nc_new = dtmp[nr - 1];
337 r.xelem (i) = dtmp[i] - 1;
338 nr_new = dtmp[nr - 1];
341 c.
xelem (i) = dtmp[i] - 1;
342 nc_new = dtmp[nr - 1];
359 error (
"load: reading matrix data for '%s'", name);
369 error (
"load: reading imaginary matrix data for '%s'", name);
375 ctmp (i, j) =
Complex (re(i, j), im(i, j));
395 const std::string& name)
406 os.write (
reinterpret_cast<char *
> (&mopt), 4);
409 int32_t nr = tc.
rows ();
416 uint32_t nnz =
len + 1;
417 os.write (
reinterpret_cast<char *
> (&nnz), 4);
419 uint32_t iscmplx = (tc.
iscomplex () ? 4 : 3);
420 os.write (
reinterpret_cast<char *
> (&iscmplx), 4);
423 os.write (
reinterpret_cast<char *
> (&tmp), 4);
427 os.write (
reinterpret_cast<char *
> (&nr), 4);
428 os.write (
reinterpret_cast<char *
> (&nc), 4);
431 os.write (
reinterpret_cast<char *
> (&
imag), 4);
439 int32_t name_len = name.length () + 1;
441 os.write (
reinterpret_cast<char *
> (&name_len), 4);
456 const char *s = tstr.data ();
459 buf[j*nrow+i] =
static_cast<double> (*s++ & 0x00FF);
461 std::streamsize n_bytes =
static_cast<std::streamsize
> (nrow) *
462 static_cast<std::streamsize
> (ncol) *
464 os.write (
reinterpret_cast<char *
> (buf), n_bytes);
469 double base =
r.base ();
470 double inc =
r.increment ();
474 double x = base + i * inc;
475 os.write (
reinterpret_cast<char *
> (&
x), 8);
481 os.write (
reinterpret_cast<char *
> (&tmp), 8);
492 dtmp[i] =
m.ridx (i) + 1;
493 std::streamsize n_bytes = 8 *
static_cast<std::streamsize
> (
len);
494 os.write (
reinterpret_cast<const char *
> (dtmp), n_bytes);
496 os.write (
reinterpret_cast<const char *
> (&ds), 8);
502 os.write (
reinterpret_cast<const char *
> (dtmp), n_bytes);
504 os.write (
reinterpret_cast<const char *
> (&ds), 8);
508 os.write (
reinterpret_cast<const char *
> (dtmp), n_bytes);
510 os.write (
reinterpret_cast<const char *
> (&ds), 8);
514 os.write (
reinterpret_cast<const char *
> (dtmp), n_bytes);
515 os.write (
reinterpret_cast<const char *
> (&ds), 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);
536 os.write (
reinterpret_cast<const char *
> (
m.data ()), n_bytes);
538 os.write (
reinterpret_cast<const char *
> (&ds), 8);
544 std::streamsize n_bytes = 8 *
static_cast<std::streamsize
> (
len);
545 os.write (
reinterpret_cast<const char *
> (
m.data ()), n_bytes);
550 os.write (
reinterpret_cast<char *
> (&tmp), 16);
556 std::streamsize n_bytes = 8 *
static_cast<std::streamsize
> (
len);
557 os.write (
reinterpret_cast<const char *
> (
m.data ()), n_bytes);
559 os.write (
reinterpret_cast<const char *
> (
m.data ()), n_bytes);
void swap_bytes< 4 >(void *ptr)
N Dimensional Array with copy-on-write semantics.
OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type rows(void) const
OCTARRAY_API T * fortran_vec(void)
Size of the specified dimension.
OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type cols(void) const
OCTARRAY_OVERRIDABLE_FUNC_API T & xelem(octave_idx_type n)
Size of the specified dimension.
ComplexMatrix transpose(void) const
Matrix transpose(void) const
SparseComplexMatrix transpose(void) const
SparseMatrix transpose(void) const
OCTAVE_API std::string row_as_string(octave_idx_type, bool strip_ws=false) const
Vector representing the dimensions (size) of an Array.
octave::range< double > range_value(void) const
SparseMatrix sparse_matrix_value(bool frc_str_conv=false) const
bool is_complex_matrix(void) const
bool issparse(void) const
charMatrix char_matrix_value(bool frc_str_conv=false) const
octave_idx_type nnz(void) const
ComplexMatrix complex_matrix_value(bool frc_str_conv=false) const
Complex complex_value(bool frc_str_conv=false) const
octave_idx_type rows(void) const
bool is_string(void) const
octave_idx_type columns(void) const
bool is_range(void) const
bool is_real_matrix(void) const
octave_value convert_to_str(bool pad=false, bool force=false, char type='\'') const
bool is_real_scalar(void) const
Matrix matrix_value(bool frc_str_conv=false) const
bool iscomplex(void) const
double double_value(bool frc_str_conv=false) const
bool is_complex_scalar(void) const
SparseComplexMatrix sparse_complex_matrix_value(bool frc_str_conv=false) const
ColumnVector real(const ComplexColumnVector &a)
ColumnVector imag(const ComplexColumnVector &a)
void read_doubles(std::istream &is, double *data, save_type type, octave_idx_type len, bool swap, octave::mach_info::float_format fmt)
void error(const char *fmt,...)
void warn_wrong_type_arg(const char *name, const octave_value &tc)
F77_RET_T const F77_DBLE * x
octave::mach_info::float_format mopt_digit_to_float_format(int mach)
bool save_mat_binary_data(std::ostream &os, const octave_value &tc, const std::string &name)
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)
static void read_mat_binary_data(std::istream &is, double *data, int precision, int len, bool swap, octave::mach_info::float_format flt_fmt)
int float_format_to_mopt_digit(octave::mach_info::float_format flt_fmt)
bool words_big_endian(void)
float_format native_float_format(void)
@ flt_fmt_ieee_big_endian
@ flt_fmt_ieee_little_endian
class OCTAVE_API SparseMatrix
class OCTAVE_API SparseComplexMatrix
std::complex< double > Complex
#define OCTAVE_LOCAL_BUFFER(T, buf, size)