23 #if defined (HAVE_CONFIG_H) 106 int32_t& nr, int32_t& nc,
107 int32_t&
imag, int32_t& len,
116 is.read (reinterpret_cast<char *> (&mopt), 4);
120 if (!
is.read (reinterpret_cast<char *> (&nr), 4))
123 if (!
is.read (reinterpret_cast<char *> (&nc), 4))
126 if (!
is.read (reinterpret_cast<char *> (&
imag), 4))
129 if (!
is.read (reinterpret_cast<char *> (&len), 4))
145 if (mopt > 9999 || mopt < 0)
157 if (mopt > 9999 || mopt < 0 || imag > 1 ||
imag < 0)
160 error (
"load: can't read binary file");
236 int32_t mopt, nr, nc,
imag, len;
242 error (
"load: trouble reading binary file '%s'",
filename.c_str ());
264 error (
"load: unrecognized binary format!");
267 error (
"load: encountered complex matrix with string flag set!");
278 if (!
is.read (
name, len))
279 error (
"load: trouble reading binary file '%s'",
filename.c_str ());
284 error (
"load: trouble reading binary file '%s'",
filename.c_str ());
307 nr_new = dtmp[nr - 1];
310 c.xelem (
i) = dtmp[
i] - 1;
311 nc_new = dtmp[nr - 1];
336 nr_new = dtmp[nr - 1];
339 c.xelem (
i) = dtmp[
i] - 1;
340 nc_new = dtmp[nr - 1];
357 error (
"load: reading matrix data for '%s'",
name);
367 error (
"load: reading imaginary matrix data for '%s'",
name);
404 os.
write (reinterpret_cast<char *> (&mopt), 4);
407 int32_t nr = tc.
rows ();
414 uint32_t
nnz = len + 1;
415 os.
write (reinterpret_cast<char *> (&
nnz), 4);
417 uint32_t iscmplx = (tc.
iscomplex () ? 4 : 3);
418 os.
write (reinterpret_cast<char *> (&iscmplx), 4);
421 os.
write (reinterpret_cast<char *> (&
tmp), 4);
425 os.
write (reinterpret_cast<char *> (&nr), 4);
426 os.
write (reinterpret_cast<char *> (&nc), 4);
437 int32_t name_len =
name.length () + 1;
439 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.
inc ();
474 double x = base +
i * inc;
475 os.
write (reinterpret_cast<char *> (&
x), 8);
481 os.
write (reinterpret_cast<char *> (&
tmp), 8);
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);
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);
octave_idx_type write(const octave_value &data, octave_idx_type block_size, oct_data_conv::data_type output_type, octave_idx_type skip, mach_info::float_format flt_fmt)
octave_idx_type rows(void) const
Range range_value(void) const
SparseComplexMatrix transpose(void) const
const T * data(void) const
bool is_real_matrix(void) const
octave_idx_type * cidx(void)
const T * fortran_vec(void) const
bool is_complex_scalar(void) const
void error(const char *fmt,...)
SparseMatrix transpose(void) const
octave::mach_info::float_format flt_fmt
Complex complex_value(bool frc_str_conv=false) const
nd example oindent opens the file binary numeric values will be read assuming they are stored in IEEE format with the least significant bit and then converted to the native representation Opening a file that is already open simply opens it again and returns a separate file id It is not an error to open a file several though writing to the same file through several different file ids may produce unexpected results The possible values of text mode reading and writing automatically converts linefeeds to the appropriate line end character for the you may append a you must also open the file in binary mode The parameter conversions are currently only supported for and permissions will be set to and then everything is written in a single operation This is very efficient and improves performance c
ComplexMatrix transpose(void) const
charMatrix char_matrix_value(bool frc_str_conv=false) const
octave_idx_type cols(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)
Matrix transpose(void) const
nd deftypefn *std::string name
void swap_bytes< 4 >(void *ptr)
int float_format_to_mopt_digit(octave::mach_info::float_format flt_fmt)
void read_doubles(std::istream &is, double *data, save_type type, octave_idx_type len, bool swap, octave::mach_info::float_format fmt)
octave_idx_type columns(void) const
float_format native_float_format(void)
octave_idx_type numel(void) const
octave_idx_type rows(void) const
bool issparse(void) const
bool is_complex_matrix(void) const
octave_idx_type * ridx(void)
bool words_big_endian(void)
octave_value convert_to_str(bool pad=false, bool force=false, char type='\'') const
SparseComplexMatrix sparse_complex_matrix_value(bool frc_str_conv=false) const
T & xelem(octave_idx_type n)
octave::mach_info::float_format mopt_digit_to_float_format(int mach)
octave::unwind_protect frame
std::string row_as_string(octave_idx_type, bool strip_ws=false) const
octave_idx_type nnz(void) const
bool save_mat_binary_data(std::ostream &os, const octave_value &tc, const std::string &name)
void warn_wrong_type_arg(const char *name, const octave_value &tc)
double double_value(bool frc_str_conv=false) const
static void read_mat_binary_data(std::istream &is, double *data, int precision, int len, bool swap, octave::mach_info::float_format flt_fmt)
SparseMatrix sparse_matrix_value(bool frc_str_conv=false) const
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
bool iscomplex(void) const
ColumnVector imag(const ComplexColumnVector &a)
bool is_string(void) const
OCTAVE_EXPORT octave_value_list error nd deftypefn *const octave_scalar_map err
ComplexMatrix complex_matrix_value(bool frc_str_conv=false) const
std::complex< double > Complex
bool is_range(void) const
ColumnVector real(const ComplexColumnVector &a)
write the output to stdout if nargout is
Vector representing the dimensions (size) of an Array.
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
bool is_real_scalar(void) const
Matrix matrix_value(bool frc_str_conv=false) const
F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T const F77_DBLE * x