3
Copyright (C) 1996, 1997, 1998, 2000, 2002, 2003, 2004, 2005, 2006,
6
This file is part of Octave.
8
Octave is free software; you can redistribute it and/or modify it
9
under the terms of the GNU General Public License as published by the
10
Free Software Foundation; either version 3 of the License, or (at your
11
option) any later version.
13
Octave is distributed in the hope that it will be useful, but WITHOUT
14
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18
You should have received a copy of the GNU General Public License
19
along with Octave; see the file COPYING. If not, see
20
<http://www.gnu.org/licenses/>.
24
#if !defined (octave_matrix_h)
25
#define octave_matrix_h 1
33
#include "oct-alloc.h"
38
#include "oct-stream.h"
40
#include "ov-base-mat.h"
41
#include "ov-typeinfo.h"
43
#include "MatrixType.h"
46
class octave_value_list;
50
// Real matrix values.
54
octave_matrix : public octave_base_matrix<NDArray>
59
: octave_base_matrix<NDArray> () { }
61
octave_matrix (const Matrix& m)
62
: octave_base_matrix<NDArray> (m) { }
64
octave_matrix (const Matrix& m, const MatrixType& t)
65
: octave_base_matrix<NDArray> (m, t) { }
67
octave_matrix (const NDArray& nda)
68
: octave_base_matrix<NDArray> (nda) { }
70
octave_matrix (const ArrayN<double>& m)
71
: octave_base_matrix<NDArray> (NDArray (m)) { }
73
octave_matrix (const DiagMatrix& d)
74
: octave_base_matrix<NDArray> (Matrix (d)) { }
76
octave_matrix (const RowVector& v)
77
: octave_base_matrix<NDArray> (Matrix (v)) { }
79
octave_matrix (const ColumnVector& v)
80
: octave_base_matrix<NDArray> (Matrix (v)) { }
82
octave_matrix (const octave_matrix& m)
83
: octave_base_matrix<NDArray> (m) { }
85
~octave_matrix (void) { }
87
octave_base_value *clone (void) const { return new octave_matrix (*this); }
88
octave_base_value *empty_clone (void) const { return new octave_matrix (); }
90
octave_base_value *try_narrowing_conversion (void);
92
idx_vector index_vector (void) const { return idx_vector (matrix); }
94
bool is_real_matrix (void) const { return true; }
96
bool is_real_type (void) const { return true; }
98
bool is_double_type (void) const { return true; }
100
bool valid_as_scalar_index (void) const;
103
int8_array_value (void) const { return int8NDArray (matrix); }
106
int16_array_value (void) const { return int16NDArray (matrix); }
109
int32_array_value (void) const { return int32NDArray (matrix); }
112
int64_array_value (void) const { return int64NDArray (matrix); }
115
uint8_array_value (void) const { return uint8NDArray (matrix); }
118
uint16_array_value (void) const { return uint16NDArray (matrix); }
121
uint32_array_value (void) const { return uint32NDArray (matrix); }
124
uint64_array_value (void) const { return uint64NDArray (matrix); }
126
double double_value (bool = false) const;
128
double scalar_value (bool frc_str_conv = false) const
129
{ return double_value (frc_str_conv); }
131
Matrix matrix_value (bool = false) const;
133
Complex complex_value (bool = false) const;
135
ComplexMatrix complex_matrix_value (bool = false) const;
137
ComplexNDArray complex_array_value (bool = false) const;
139
boolNDArray bool_array_value (bool warn = false) const;
141
charNDArray char_array_value (bool = false) const;
143
NDArray array_value (bool = false) const { return matrix; }
145
SparseMatrix sparse_matrix_value (bool = false) const;
147
SparseComplexMatrix sparse_complex_matrix_value (bool = false) const;
149
streamoff_array streamoff_array_value (void) const;
151
void increment (void) { matrix += 1.0; }
153
void decrement (void) { matrix -= 1.0; }
155
octave_value convert_to_str_internal (bool pad, bool force, char type) const;
157
void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const;
159
bool save_ascii (std::ostream& os);
161
bool load_ascii (std::istream& is);
163
bool save_binary (std::ostream& os, bool& save_as_floats);
165
bool load_binary (std::istream& is, bool swap,
166
oct_mach_info::float_format fmt);
168
#if defined (HAVE_HDF5)
169
bool save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats);
171
bool load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug);
174
int write (octave_stream& os, int block_size,
175
oct_data_conv::data_type output_type, int skip,
176
oct_mach_info::float_format flt_fmt) const
177
{ return os.write (matrix, block_size, output_type, skip, flt_fmt); }
179
mxArray *as_mxArray (void) const;
183
DECLARE_OCTAVE_ALLOCATOR
185
DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
191
;;; Local Variables: ***