annotate src/ov-cx-mat.h @ 5785:6b9cec830d72

[project @ 2006-05-03 19:32:46 by dbateman]
author dbateman
date Wed, 03 May 2006 19:32:48 +0000
parents ce79d238f142
children b9c45e0cf685
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
1 /*
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
2
2847
8b262e771614 [project @ 1997-03-27 16:18:26 by jwe]
jwe
parents: 2477
diff changeset
3 Copyright (C) 1996, 1997 John W. Eaton
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
4
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
6
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
9 Free Software Foundation; either version 2, or (at your option) any
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
10 later version.
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
11
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
15 for more details.
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
16
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
18 along with Octave; see the file COPYING. If not, write to the Free
5307
4c8a2e4e0717 [project @ 2005-04-26 19:24:27 by jwe]
jwe
parents: 5164
diff changeset
19 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
4c8a2e4e0717 [project @ 2005-04-26 19:24:27 by jwe]
jwe
parents: 5164
diff changeset
20 02110-1301, USA.
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
21
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
22 */
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
23
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
24 #if !defined (octave_complex_matrix_h)
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
25 #define octave_complex_matrix_h 1
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
26
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
27 #include <cstdlib>
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
28
3503
d14c483b3c12 [project @ 2000-02-01 04:06:07 by jwe]
jwe
parents: 3418
diff changeset
29 #include <iostream>
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
30 #include <string>
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
31
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
32 #include "mx-base.h"
2477
3d905d3820a4 [project @ 1996-11-07 16:46:11 by jwe]
jwe
parents: 2466
diff changeset
33 #include "oct-alloc.h"
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
34 #include "str-vec.h"
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
35
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
36 #include "error.h"
4944
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4911
diff changeset
37 #include "oct-stream.h"
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
38 #include "ov-base.h"
3219
30770ba4457a [project @ 1998-11-13 03:44:31 by jwe]
jwe
parents: 3203
diff changeset
39 #include "ov-base-mat.h"
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
40 #include "ov-typeinfo.h"
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
41
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5759
diff changeset
42 #include "MatrixType.h"
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5759
diff changeset
43
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
44 class Octave_map;
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
45 class octave_value_list;
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
46
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
47 class tree_walker;
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
48
2477
3d905d3820a4 [project @ 1996-11-07 16:46:11 by jwe]
jwe
parents: 2466
diff changeset
49 // Complex matrix values.
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
50
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
51 class
4513
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4418
diff changeset
52 octave_complex_matrix : public octave_base_matrix<ComplexNDArray>
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
53 {
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
54 public:
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
55
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
56 octave_complex_matrix (void)
4513
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4418
diff changeset
57 : octave_base_matrix<ComplexNDArray> () { }
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4418
diff changeset
58
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4418
diff changeset
59 octave_complex_matrix (const ComplexNDArray& m)
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4418
diff changeset
60 : octave_base_matrix<ComplexNDArray> (m) { }
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
61
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
62 octave_complex_matrix (const ComplexMatrix& m)
4513
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4418
diff changeset
63 : octave_base_matrix<ComplexNDArray> (m) { }
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
64
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5759
diff changeset
65 octave_complex_matrix (const ComplexMatrix& m, const MatrixType& t)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5759
diff changeset
66 : octave_base_matrix<ComplexNDArray> (m, t) { }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5759
diff changeset
67
4911
14027e0bafa4 [project @ 2004-07-22 19:58:06 by jwe]
jwe
parents: 4899
diff changeset
68 octave_complex_matrix (const ArrayN<Complex>& m)
14027e0bafa4 [project @ 2004-07-22 19:58:06 by jwe]
jwe
parents: 4899
diff changeset
69 : octave_base_matrix<ComplexNDArray> (ComplexNDArray (m)) { }
14027e0bafa4 [project @ 2004-07-22 19:58:06 by jwe]
jwe
parents: 4899
diff changeset
70
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
71 octave_complex_matrix (const ComplexDiagMatrix& d)
4513
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4418
diff changeset
72 : octave_base_matrix<ComplexNDArray> (ComplexMatrix (d)) { }
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
73
3418
ca92c9d3f882 [project @ 2000-01-12 03:07:47 by jwe]
jwe
parents: 3221
diff changeset
74 octave_complex_matrix (const ComplexRowVector& v)
4513
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4418
diff changeset
75 : octave_base_matrix<ComplexNDArray> (ComplexMatrix (v)) { }
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
76
3418
ca92c9d3f882 [project @ 2000-01-12 03:07:47 by jwe]
jwe
parents: 3221
diff changeset
77 octave_complex_matrix (const ComplexColumnVector& v)
4513
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4418
diff changeset
78 : octave_base_matrix<ComplexNDArray> (ComplexMatrix (v)) { }
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
79
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
80 octave_complex_matrix (const octave_complex_matrix& cm)
4513
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4418
diff changeset
81 : octave_base_matrix<ComplexNDArray> (cm) { }
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
82
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
83 ~octave_complex_matrix (void) { }
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
84
5759
ce79d238f142 [project @ 2006-04-13 13:04:32 by jwe]
jwe
parents: 5307
diff changeset
85 octave_base_value *clone (void) const { return new octave_complex_matrix (*this); }
ce79d238f142 [project @ 2006-04-13 13:04:32 by jwe]
jwe
parents: 5307
diff changeset
86 octave_base_value *empty_clone (void) const { return new octave_complex_matrix (); }
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
87
5759
ce79d238f142 [project @ 2006-04-13 13:04:32 by jwe]
jwe
parents: 5307
diff changeset
88 octave_base_value *try_narrowing_conversion (void);
2410
367485171742 [project @ 1996-10-15 16:50:27 by jwe]
jwe
parents: 2376
diff changeset
89
4686
c7ae43dfdea4 [project @ 2004-01-06 19:29:23 by jwe]
jwe
parents: 4643
diff changeset
90 void assign (const octave_value_list& idx, const ComplexNDArray& rhs);
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
91
4686
c7ae43dfdea4 [project @ 2004-01-06 19:29:23 by jwe]
jwe
parents: 4643
diff changeset
92 void assign (const octave_value_list& idx, const NDArray& rhs);
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
93
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
94 bool is_complex_matrix (void) const { return true; }
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
95
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
96 bool is_complex_type (void) const { return true; }
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
97
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
98 bool valid_as_scalar_index (void) const;
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
99
3145
0d640dc625c7 [project @ 1998-02-05 08:44:59 by jwe]
jwe
parents: 3107
diff changeset
100 double double_value (bool = false) const;
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
101
3145
0d640dc625c7 [project @ 1998-02-05 08:44:59 by jwe]
jwe
parents: 3107
diff changeset
102 double scalar_value (bool frc_str_conv = false) const
0d640dc625c7 [project @ 1998-02-05 08:44:59 by jwe]
jwe
parents: 3107
diff changeset
103 { return double_value (frc_str_conv); }
2916
4e7bea116f24 [project @ 1997-04-30 20:56:31 by jwe]
jwe
parents: 2901
diff changeset
104
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
105 Matrix matrix_value (bool = false) const;
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
106
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
107 Complex complex_value (bool = false) const;
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
108
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
109 ComplexMatrix complex_matrix_value (bool = false) const;
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
110
4550
69a9b22a72a2 [project @ 2003-10-27 15:41:55 by jwe]
jwe
parents: 4543
diff changeset
111 ComplexNDArray complex_array_value (bool = false) const { return matrix; }
4543
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 4513
diff changeset
112
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents: 5105
diff changeset
113 SparseMatrix sparse_matrix_value (bool = false) const;
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents: 5105
diff changeset
114
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents: 5105
diff changeset
115 SparseComplexMatrix sparse_complex_matrix_value (bool = false) const;
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents: 5105
diff changeset
116
3107
a8dcfbf87ea3 [project @ 1997-11-19 22:34:59 by jwe]
jwe
parents: 2974
diff changeset
117 void increment (void) { matrix += Complex (1.0); }
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
118
3107
a8dcfbf87ea3 [project @ 1997-11-19 22:34:59 by jwe]
jwe
parents: 2974
diff changeset
119 void decrement (void) { matrix -= Complex (1.0); }
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
120
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4686
diff changeset
121 bool save_ascii (std::ostream& os, bool& infnan_warned,
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4686
diff changeset
122 bool strip_nan_and_inf);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4686
diff changeset
123
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4686
diff changeset
124 bool load_ascii (std::istream& is);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4686
diff changeset
125
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4686
diff changeset
126 bool save_binary (std::ostream& os, bool& save_as_floats);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4686
diff changeset
127
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4686
diff changeset
128 bool load_binary (std::istream& is, bool swap,
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4686
diff changeset
129 oct_mach_info::float_format fmt);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4686
diff changeset
130
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4686
diff changeset
131 #if defined (HAVE_HDF5)
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4686
diff changeset
132 bool save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4686
diff changeset
133
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4686
diff changeset
134 bool load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4686
diff changeset
135 #endif
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4686
diff changeset
136
4944
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4911
diff changeset
137 int write (octave_stream& os, int block_size,
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4911
diff changeset
138 oct_data_conv::data_type output_type, int skip,
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4911
diff changeset
139 oct_mach_info::float_format flt_fmt) const
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4911
diff changeset
140 {
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4911
diff changeset
141 // Yes, for compatibility, we drop the imaginary part here.
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4911
diff changeset
142 return os.write (matrix_value (true), block_size, output_type,
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4911
diff changeset
143 skip, flt_fmt);
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4911
diff changeset
144 }
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4911
diff changeset
145
4643
ef3a14fb6847 [project @ 2003-11-22 12:25:44 by jwe]
jwe
parents: 4550
diff changeset
146 void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const;
ef3a14fb6847 [project @ 2003-11-22 12:25:44 by jwe]
jwe
parents: 4550
diff changeset
147
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
148 private:
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
149
3219
30770ba4457a [project @ 1998-11-13 03:44:31 by jwe]
jwe
parents: 3203
diff changeset
150 DECLARE_OCTAVE_ALLOCATOR
2477
3d905d3820a4 [project @ 1996-11-07 16:46:11 by jwe]
jwe
parents: 2466
diff changeset
151
3219
30770ba4457a [project @ 1998-11-13 03:44:31 by jwe]
jwe
parents: 3203
diff changeset
152 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
153 };
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
154
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
155 #endif
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
156
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
157 /*
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
158 ;;; Local Variables: ***
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
159 ;;; mode: C++ ***
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
160 ;;; End: ***
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
161 */