comparison libinterp/octave-value/ov-cx-diag.cc @ 30135:606652e9f446

maint: use "m_" prefix for member variables in class octave_base_diag. * ov-base-diag.cc, ov-base-diag.h, ov-cx-diag.cc, ov-flt-cx-diag.cc, ov-flt-re-diag.cc, ov-re-diag.cc: Use "m_" prefix for member variables in class octave_base_diag.
author Rik <rik@octave.org>
date Tue, 07 Sep 2021 16:07:34 -0700
parents 75dff8f2de2e
children 2dca5c25237d
comparison
equal deleted inserted replaced
30134:71d738ed015d 30135:606652e9f446
39 39
40 40
41 template class octave_base_diag<ComplexDiagMatrix, ComplexMatrix>; 41 template class octave_base_diag<ComplexDiagMatrix, ComplexMatrix>;
42 42
43 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_complex_diag_matrix, 43 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_complex_diag_matrix,
44 "complex diagonal matrix", "double"); 44 "complex diagonal m_matrix", "double");
45 45
46 static octave_base_value * 46 static octave_base_value *
47 default_numeric_conversion_function (const octave_base_value& a) 47 default_numeric_conversion_function (const octave_base_value& a)
48 { 48 {
49 const octave_complex_diag_matrix& v 49 const octave_complex_diag_matrix& v
81 octave_base_value * 81 octave_base_value *
82 octave_complex_diag_matrix::try_narrowing_conversion (void) 82 octave_complex_diag_matrix::try_narrowing_conversion (void)
83 { 83 {
84 octave_base_value *retval = nullptr; 84 octave_base_value *retval = nullptr;
85 85
86 if (matrix.nelem () == 1) 86 if (m_matrix.nelem () == 1)
87 { 87 {
88 retval = new octave_complex (matrix (0, 0)); 88 retval = new octave_complex (m_matrix (0, 0));
89 octave_base_value *rv2 = retval->try_narrowing_conversion (); 89 octave_base_value *rv2 = retval->try_narrowing_conversion ();
90 if (rv2) 90 if (rv2)
91 { 91 {
92 delete retval; 92 delete retval;
93 retval = rv2; 93 retval = rv2;
94 } 94 }
95 } 95 }
96 else if (matrix.all_elements_are_real ()) 96 else if (m_matrix.all_elements_are_real ())
97 { 97 {
98 return new octave_diag_matrix (::real (matrix)); 98 return new octave_diag_matrix (::real (m_matrix));
99 } 99 }
100 100
101 return retval; 101 return retval;
102 } 102 }
103 103
106 { 106 {
107 DiagMatrix retval; 107 DiagMatrix retval;
108 108
109 if (! force_conversion) 109 if (! force_conversion)
110 warn_implicit_conversion ("Octave:imag-to-real", 110 warn_implicit_conversion ("Octave:imag-to-real",
111 type_name (), "real matrix"); 111 type_name (), "real m_matrix");
112 112
113 retval = ::real (matrix); 113 retval = ::real (m_matrix);
114 114
115 return retval; 115 return retval;
116 } 116 }
117 117
118 FloatDiagMatrix 118 FloatDiagMatrix
120 { 120 {
121 DiagMatrix retval; 121 DiagMatrix retval;
122 122
123 if (! force_conversion) 123 if (! force_conversion)
124 warn_implicit_conversion ("Octave:imag-to-real", 124 warn_implicit_conversion ("Octave:imag-to-real",
125 type_name (), "real matrix"); 125 type_name (), "real m_matrix");
126 126
127 retval = ::real (matrix); 127 retval = ::real (m_matrix);
128 128
129 return retval; 129 return retval;
130 } 130 }
131 131
132 ComplexDiagMatrix 132 ComplexDiagMatrix
133 octave_complex_diag_matrix::complex_diag_matrix_value (bool) const 133 octave_complex_diag_matrix::complex_diag_matrix_value (bool) const
134 { 134 {
135 return matrix; 135 return m_matrix;
136 } 136 }
137 137
138 FloatComplexDiagMatrix 138 FloatComplexDiagMatrix
139 octave_complex_diag_matrix::float_complex_diag_matrix_value (bool) const 139 octave_complex_diag_matrix::float_complex_diag_matrix_value (bool) const
140 { 140 {
141 return FloatComplexDiagMatrix (matrix); 141 return FloatComplexDiagMatrix (m_matrix);
142 } 142 }
143 143
144 octave_value 144 octave_value
145 octave_complex_diag_matrix::as_double (void) const 145 octave_complex_diag_matrix::as_double (void) const
146 { 146 {
147 return matrix; 147 return m_matrix;
148 } 148 }
149 149
150 octave_value 150 octave_value
151 octave_complex_diag_matrix::as_single (void) const 151 octave_complex_diag_matrix::as_single (void) const
152 { 152 {
153 return FloatComplexDiagMatrix (matrix); 153 return FloatComplexDiagMatrix (m_matrix);
154 } 154 }
155 155
156 octave_value 156 octave_value
157 octave_complex_diag_matrix::map (unary_mapper_t umap) const 157 octave_complex_diag_matrix::map (unary_mapper_t umap) const
158 { 158 {
159 switch (umap) 159 switch (umap)
160 { 160 {
161 case umap_abs: 161 case umap_abs:
162 return matrix.abs (); 162 return m_matrix.abs ();
163 case umap_real: 163 case umap_real:
164 return ::real (matrix); 164 return ::real (m_matrix);
165 case umap_conj: 165 case umap_conj:
166 return ::conj (matrix); 166 return ::conj (m_matrix);
167 case umap_imag: 167 case umap_imag:
168 return ::imag (matrix); 168 return ::imag (m_matrix);
169 case umap_sqrt: 169 case umap_sqrt:
170 { 170 {
171 ComplexColumnVector tmp 171 ComplexColumnVector tmp
172 = matrix.extract_diag ().map<Complex> (std::sqrt); 172 = m_matrix.extract_diag ().map<Complex> (std::sqrt);
173 ComplexDiagMatrix retval (tmp); 173 ComplexDiagMatrix retval (tmp);
174 retval.resize (matrix.rows (), matrix.columns ()); 174 retval.resize (m_matrix.rows (), m_matrix.columns ());
175 return retval; 175 return retval;
176 } 176 }
177 default: 177 default:
178 return to_dense ().map (umap); 178 return to_dense ().map (umap);
179 } 179 }
181 181
182 bool 182 bool
183 octave_complex_diag_matrix::save_binary (std::ostream& os, bool save_as_floats) 183 octave_complex_diag_matrix::save_binary (std::ostream& os, bool save_as_floats)
184 { 184 {
185 185
186 int32_t r = matrix.rows (); 186 int32_t r = m_matrix.rows ();
187 int32_t c = matrix.cols (); 187 int32_t c = m_matrix.cols ();
188 os.write (reinterpret_cast<char *> (&r), 4); 188 os.write (reinterpret_cast<char *> (&r), 4);
189 os.write (reinterpret_cast<char *> (&c), 4); 189 os.write (reinterpret_cast<char *> (&c), 4);
190 190
191 ComplexMatrix m = ComplexMatrix (matrix.extract_diag ()); 191 ComplexMatrix m = ComplexMatrix (m_matrix.extract_diag ());
192 save_type st = LS_DOUBLE; 192 save_type st = LS_DOUBLE;
193 if (save_as_floats) 193 if (save_as_floats)
194 { 194 {
195 if (m.too_large_for_float ()) 195 if (m.too_large_for_float ())
196 { 196 {
198 warning ("save: saving as doubles instead"); 198 warning ("save: saving as doubles instead");
199 } 199 }
200 else 200 else
201 st = LS_FLOAT; 201 st = LS_FLOAT;
202 } 202 }
203 else if (matrix.length () > 4096) // FIXME: make this configurable. 203 else if (m_matrix.length () > 4096) // FIXME: make this configurable.
204 { 204 {
205 double max_val, min_val; 205 double max_val, min_val;
206 if (m.all_integers (max_val, min_val)) 206 if (m.all_integers (max_val, min_val))
207 st = octave::get_save_type (max_val, min_val); 207 st = octave::get_save_type (max_val, min_val);
208 } 208 }
237 static_cast<save_type> (tmp), 2 * len, swap, fmt); 237 static_cast<save_type> (tmp), 2 * len, swap, fmt);
238 238
239 if (! is) 239 if (! is)
240 return false; 240 return false;
241 241
242 matrix = m; 242 m_matrix = m;
243 243
244 return true; 244 return true;
245 } 245 }
246 246
247 bool 247 bool