~ubuntu-branches/debian/sid/octave3.0/sid

« back to all changes in this revision

Viewing changes to src/ov-re-mat.h

  • Committer: Bazaar Package Importer
  • Author(s): Rafael Laboissiere
  • Date: 2007-12-23 16:04:15 UTC
  • Revision ID: james.westby@ubuntu.com-20071223160415-n4gk468dihy22e9v
Tags: upstream-3.0.0
ImportĀ upstreamĀ versionĀ 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 
 
3
Copyright (C) 1996, 1997, 1998, 2000, 2002, 2003, 2004, 2005, 2006,
 
4
              2007 John W. Eaton
 
5
 
 
6
This file is part of Octave.
 
7
 
 
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.
 
12
 
 
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
 
16
for more details.
 
17
 
 
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/>.
 
21
 
 
22
*/
 
23
 
 
24
#if !defined (octave_matrix_h)
 
25
#define octave_matrix_h 1
 
26
 
 
27
#include <cstdlib>
 
28
 
 
29
#include <iostream>
 
30
#include <string>
 
31
 
 
32
#include "mx-base.h"
 
33
#include "oct-alloc.h"
 
34
#include "so-array.h"
 
35
#include "str-vec.h"
 
36
 
 
37
#include "error.h"
 
38
#include "oct-stream.h"
 
39
#include "ov-base.h"
 
40
#include "ov-base-mat.h"
 
41
#include "ov-typeinfo.h"
 
42
 
 
43
#include "MatrixType.h"
 
44
 
 
45
class Octave_map;
 
46
class octave_value_list;
 
47
 
 
48
class tree_walker;
 
49
 
 
50
// Real matrix values.
 
51
 
 
52
class
 
53
OCTINTERP_API
 
54
octave_matrix : public octave_base_matrix<NDArray>
 
55
{
 
56
public:
 
57
 
 
58
  octave_matrix (void)
 
59
    : octave_base_matrix<NDArray> () { }
 
60
 
 
61
  octave_matrix (const Matrix& m)
 
62
    : octave_base_matrix<NDArray> (m) { }
 
63
 
 
64
  octave_matrix (const Matrix& m, const MatrixType& t)
 
65
    : octave_base_matrix<NDArray> (m, t) { }
 
66
 
 
67
  octave_matrix (const NDArray& nda)
 
68
    : octave_base_matrix<NDArray> (nda) { }
 
69
 
 
70
  octave_matrix (const ArrayN<double>& m)
 
71
    : octave_base_matrix<NDArray> (NDArray (m)) { }
 
72
 
 
73
  octave_matrix (const DiagMatrix& d)
 
74
    : octave_base_matrix<NDArray> (Matrix (d)) { }
 
75
 
 
76
  octave_matrix (const RowVector& v)
 
77
    : octave_base_matrix<NDArray> (Matrix (v)) { }
 
78
 
 
79
  octave_matrix (const ColumnVector& v)
 
80
    : octave_base_matrix<NDArray> (Matrix (v)) { }
 
81
 
 
82
  octave_matrix (const octave_matrix& m)
 
83
    : octave_base_matrix<NDArray> (m) { }
 
84
 
 
85
  ~octave_matrix (void) { }
 
86
 
 
87
  octave_base_value *clone (void) const { return new octave_matrix (*this); }
 
88
  octave_base_value *empty_clone (void) const { return new octave_matrix (); }
 
89
 
 
90
  octave_base_value *try_narrowing_conversion (void);
 
91
 
 
92
  idx_vector index_vector (void) const { return idx_vector (matrix); }
 
93
 
 
94
  bool is_real_matrix (void) const { return true; }
 
95
 
 
96
  bool is_real_type (void) const { return true; }
 
97
 
 
98
  bool is_double_type (void) const { return true; }
 
99
 
 
100
  bool valid_as_scalar_index (void) const;
 
101
 
 
102
  int8NDArray
 
103
  int8_array_value (void) const { return int8NDArray (matrix); }
 
104
 
 
105
  int16NDArray
 
106
  int16_array_value (void) const { return int16NDArray (matrix); }
 
107
 
 
108
  int32NDArray
 
109
  int32_array_value (void) const { return int32NDArray (matrix); }
 
110
 
 
111
  int64NDArray
 
112
  int64_array_value (void) const { return int64NDArray (matrix); }
 
113
 
 
114
  uint8NDArray
 
115
  uint8_array_value (void) const { return uint8NDArray (matrix); }
 
116
 
 
117
  uint16NDArray
 
118
  uint16_array_value (void) const { return uint16NDArray (matrix); }
 
119
 
 
120
  uint32NDArray
 
121
  uint32_array_value (void) const { return uint32NDArray (matrix); }
 
122
 
 
123
  uint64NDArray
 
124
  uint64_array_value (void) const { return uint64NDArray (matrix); }
 
125
 
 
126
  double double_value (bool = false) const;
 
127
 
 
128
  double scalar_value (bool frc_str_conv = false) const
 
129
    { return double_value (frc_str_conv); }
 
130
 
 
131
  Matrix matrix_value (bool = false) const;
 
132
 
 
133
  Complex complex_value (bool = false) const;
 
134
 
 
135
  ComplexMatrix complex_matrix_value (bool = false) const;
 
136
 
 
137
  ComplexNDArray complex_array_value (bool = false) const;
 
138
   
 
139
  boolNDArray bool_array_value (bool warn = false) const;
 
140
 
 
141
  charNDArray char_array_value (bool = false) const;
 
142
  
 
143
  NDArray array_value (bool = false) const { return matrix; }
 
144
 
 
145
  SparseMatrix sparse_matrix_value (bool = false) const;
 
146
 
 
147
  SparseComplexMatrix sparse_complex_matrix_value (bool = false) const;
 
148
 
 
149
  streamoff_array streamoff_array_value (void) const;
 
150
 
 
151
  void increment (void) { matrix += 1.0; }
 
152
 
 
153
  void decrement (void) { matrix -= 1.0; }
 
154
 
 
155
  octave_value convert_to_str_internal (bool pad, bool force, char type) const;
 
156
 
 
157
  void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const;
 
158
 
 
159
  bool save_ascii (std::ostream& os);
 
160
 
 
161
  bool load_ascii (std::istream& is);
 
162
 
 
163
  bool save_binary (std::ostream& os, bool& save_as_floats);
 
164
 
 
165
  bool load_binary (std::istream& is, bool swap, 
 
166
                    oct_mach_info::float_format fmt);
 
167
 
 
168
#if defined (HAVE_HDF5)
 
169
  bool save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats);
 
170
 
 
171
  bool load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug);
 
172
#endif
 
173
 
 
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); }
 
178
 
 
179
  mxArray *as_mxArray (void) const;
 
180
 
 
181
private:
 
182
 
 
183
  DECLARE_OCTAVE_ALLOCATOR
 
184
 
 
185
  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
 
186
};
 
187
 
 
188
#endif
 
189
 
 
190
/*
 
191
;;; Local Variables: ***
 
192
;;; mode: C++ ***
 
193
;;; End: ***
 
194
*/