comparison libinterp/corefcn/det.cc @ 20587:f90c8372b7ba

eliminate many more simple uses of error_state * Cell.cc, __ichol__.cc, __ilu__.cc, balance.cc, bsxfun.cc, colloc.cc, det.cc, dlmread.cc, dynamic-ld.cc, eig.cc, fft.cc, fft2.cc, fftn.cc, gcd.cc, getgrent.cc, getpwent.cc, givens.cc, hess.cc, input.cc, levenshtein.cc, load-path.cc, lookup.cc, ls-mat-ascii.cc, ls-mat4.cc, lsode.cc, lu.cc, max.cc, md5sum.cc, mex.cc, pager.cc, pinv.cc, pr-output.cc, qz.cc, schur.cc, sparse.cc, sqrtm.cc, str2double.cc, strfns.cc, sub2ind.cc, sysdep.cc, time.cc, toplev.cc, tril.cc, tsearch.cc, typecast.cc, __init_gnuplot__.cc, __magick_read__.cc, __osmesa_print__.cc, amd.cc, audiodevinfo.cc, dmperm.cc, fftw.cc, symrcm.cc, ov-base-diag.cc, ov-base-sparse.cc, ov-base.cc, ov-bool-sparse.cc, ov-builtin.cc, ov-complex.cc, ov-cx-diag.cc, ov-cx-mat.cc, ov-cx-sparse.cc, ov-fcn-handle.cc, ov-fcn-inline.cc, ov-float.cc, ov-flt-complex.cc, ov-flt-cx-diag.cc, ov-flt-cx-mat.cc, ov-flt-re-diag.cc, ov-flt-re-mat.cc, ov-lazy-idx.cc, ov-mex-fcn.cc, ov-perm.cc, ov-range.cc, ov-re-diag.cc, ov-re-mat.cc, ov-re-sparse.cc, ov-scalar.cc, ov-str-mat.cc, op-bm-b.cc, op-bm-bm.cc, op-sbm-b.cc, op-sbm-bm.cc, op-str-m.cc, op-str-s.cc, oct-parse.in.yy, pt-cbinop.cc, pt-colon.cc, pt-decl.cc, pt-exp.cc, pt-id.cc, pt-misc.cc, pt-select.cc, pt-unop.cc: Eliminate simple uses of error_state.
author John W. Eaton <jwe@octave.org>
date Mon, 05 Oct 2015 19:29:36 -0400
parents 4f45eaf83908
children
comparison
equal deleted inserted replaced
20586:b7ac1e94266e 20587:f90c8372b7ba
149 octave_idx_type info; 149 octave_idx_type info;
150 float rcond = 0.0; 150 float rcond = 0.0;
151 // Always compute rcond, so we can detect numerically 151 // Always compute rcond, so we can detect numerically
152 // singular matrices. 152 // singular matrices.
153 FloatMatrix m = arg.float_matrix_value (); 153 FloatMatrix m = arg.float_matrix_value ();
154 if (! error_state) 154
155 { 155 MAYBE_CAST (rep, octave_float_matrix);
156 MAYBE_CAST (rep, octave_float_matrix); 156 MatrixType mtype = rep ? rep -> matrix_type () : MatrixType ();
157 MatrixType mtype = rep ? rep -> matrix_type () : MatrixType (); 157 FloatDET det = m.determinant (mtype, info, rcond);
158 FloatDET det = m.determinant (mtype, info, rcond); 158 retval(1) = rcond;
159 retval(1) = rcond; 159 retval(0) = info == -1 ? 0.0f : det.value ();
160 retval(0) = info == -1 ? 0.0f : det.value (); 160 if (rep)
161 if (rep) rep->matrix_type (mtype); 161 rep->matrix_type (mtype);
162 }
163 } 162 }
164 else if (arg.is_complex_type ()) 163 else if (arg.is_complex_type ())
165 { 164 {
166 octave_idx_type info; 165 octave_idx_type info;
167 float rcond = 0.0; 166 float rcond = 0.0;
168 // Always compute rcond, so we can detect numerically 167 // Always compute rcond, so we can detect numerically
169 // singular matrices. 168 // singular matrices.
170 FloatComplexMatrix m = arg.float_complex_matrix_value (); 169 FloatComplexMatrix m = arg.float_complex_matrix_value ();
171 if (! error_state) 170
172 { 171 MAYBE_CAST (rep, octave_float_complex_matrix);
173 MAYBE_CAST (rep, octave_float_complex_matrix); 172 MatrixType mtype = rep ? rep -> matrix_type () : MatrixType ();
174 MatrixType mtype = rep ? rep -> matrix_type () : MatrixType (); 173 FloatComplexDET det = m.determinant (mtype, info, rcond);
175 FloatComplexDET det = m.determinant (mtype, info, rcond); 174 retval(1) = rcond;
176 retval(1) = rcond; 175 retval(0) = info == -1 ? FloatComplex (0.0) : det.value ();
177 retval(0) = info == -1 ? FloatComplex (0.0) : det.value (); 176 if (rep)
178 if (rep) rep->matrix_type (mtype); 177 rep->matrix_type (mtype);
179 }
180 } 178 }
181 } 179 }
182 else 180 else
183 { 181 {
184 if (arg.is_real_type ()) 182 if (arg.is_real_type ())
188 // Always compute rcond, so we can detect numerically 186 // Always compute rcond, so we can detect numerically
189 // singular matrices. 187 // singular matrices.
190 if (arg.is_sparse_type ()) 188 if (arg.is_sparse_type ())
191 { 189 {
192 SparseMatrix m = arg.sparse_matrix_value (); 190 SparseMatrix m = arg.sparse_matrix_value ();
193 if (! error_state) 191
194 { 192 DET det = m.determinant (info, rcond);
195 DET det = m.determinant (info, rcond); 193 retval(1) = rcond;
196 retval(1) = rcond; 194 retval(0) = info == -1 ? 0.0 : det.value ();
197 retval(0) = info == -1 ? 0.0 : det.value ();
198 }
199 } 195 }
200 else 196 else
201 { 197 {
202 Matrix m = arg.matrix_value (); 198 Matrix m = arg.matrix_value ();
203 if (! error_state) 199
204 { 200 MAYBE_CAST (rep, octave_matrix);
205 MAYBE_CAST (rep, octave_matrix); 201 MatrixType mtype = rep ? rep -> matrix_type ()
206 MatrixType mtype = rep ? rep -> matrix_type () 202 : MatrixType ();
207 : MatrixType (); 203 DET det = m.determinant (mtype, info, rcond);
208 DET det = m.determinant (mtype, info, rcond); 204 retval(1) = rcond;
209 retval(1) = rcond; 205 retval(0) = info == -1 ? 0.0 : det.value ();
210 retval(0) = info == -1 ? 0.0 : det.value (); 206 if (rep)
211 if (rep) rep->matrix_type (mtype); 207 rep->matrix_type (mtype);
212 }
213 } 208 }
214 } 209 }
215 else if (arg.is_complex_type ()) 210 else if (arg.is_complex_type ())
216 { 211 {
217 octave_idx_type info; 212 octave_idx_type info;
219 // Always compute rcond, so we can detect numerically 214 // Always compute rcond, so we can detect numerically
220 // singular matrices. 215 // singular matrices.
221 if (arg.is_sparse_type ()) 216 if (arg.is_sparse_type ())
222 { 217 {
223 SparseComplexMatrix m = arg.sparse_complex_matrix_value (); 218 SparseComplexMatrix m = arg.sparse_complex_matrix_value ();
224 if (! error_state) 219
225 { 220 ComplexDET det = m.determinant (info, rcond);
226 ComplexDET det = m.determinant (info, rcond); 221 retval(1) = rcond;
227 retval(1) = rcond; 222 retval(0) = info == -1 ? Complex (0.0) : det.value ();
228 retval(0) = info == -1 ? Complex (0.0) : det.value ();
229 }
230 } 223 }
231 else 224 else
232 { 225 {
233 ComplexMatrix m = arg.complex_matrix_value (); 226 ComplexMatrix m = arg.complex_matrix_value ();
234 if (! error_state) 227
235 { 228 MAYBE_CAST (rep, octave_complex_matrix);
236 MAYBE_CAST (rep, octave_complex_matrix); 229 MatrixType mtype = rep ? rep -> matrix_type ()
237 MatrixType mtype = rep ? rep -> matrix_type () 230 : MatrixType ();
238 : MatrixType (); 231 ComplexDET det = m.determinant (mtype, info, rcond);
239 ComplexDET det = m.determinant (mtype, info, rcond); 232 retval(1) = rcond;
240 retval(1) = rcond; 233 retval(0) = info == -1 ? Complex (0.0) : det.value ();
241 retval(0) = info == -1 ? Complex (0.0) : det.value (); 234 if (rep)
242 if (rep) rep->matrix_type (mtype); 235 rep->matrix_type (mtype);
243 }
244 } 236 }
245 } 237 }
246 else 238 else
247 gripe_wrong_type_arg ("det", arg); 239 gripe_wrong_type_arg ("det", arg);
248 } 240 }