comparison libinterp/dldfcn/chol.cc @ 15264:94cdf82d4a0c

don't overload meaning of info in Sparse Cholesky factorization functions * chol.cc (Fchol): New variable, force. Always pass natural and force to SparseCHOL and SparseComplexCHOL constructors. * SparsedbleCHOL.h, SparsedbleCHOL.cc (SparseCHOL::SparseCHOL): New arg, force. Pass it to sparse_base_chol constructor. * SparseCmplxCHOL.h, SparseCmplxCHOL.cc (SparseComplexCHOL::SparseComplexCHOL): Likewise. * sparse-base-chol.h (sparse_base_chol<>::sparse_base_chol_rep::init): * sparse-base-chol.h, sparse-base-chol.cc (sparse_base_chol<>::sparse_base_chol_rep::init): Replace nargout argument with force. Check force, not nargout > 1. * sparse-base-chol.h (sparse_base_chol::sparse_base_chol_rep::sparse_base_chol_rep): New arg, force. Pass it to init. (sparse_base_chol::sparse_base_chol): New arg force. Pass it to rep constructor.
author John W. Eaton <jwe@octave.org>
date Thu, 30 Aug 2012 16:57:24 -0400
parents 2fc554ffbc28
children 53eaa83e4181
comparison
equal deleted inserted replaced
15263:2136343014d5 15264:94cdf82d4a0c
178 { 178 {
179 octave_value arg = args(0); 179 octave_value arg = args(0);
180 180
181 octave_idx_type nr = arg.rows (); 181 octave_idx_type nr = arg.rows ();
182 octave_idx_type nc = arg.columns (); 182 octave_idx_type nc = arg.columns ();
183 bool natural = (nargout != 3);
184 183
185 int arg_is_empty = empty_arg ("chol", nr, nc); 184 int arg_is_empty = empty_arg ("chol", nr, nc);
186 185
187 if (arg_is_empty < 0) 186 if (arg_is_empty < 0)
188 return retval; 187 return retval;
189 if (arg_is_empty > 0) 188 if (arg_is_empty > 0)
190 return octave_value (Matrix ()); 189 return octave_value (Matrix ());
191 190
192 if (arg.is_sparse_type ()) 191 if (arg.is_sparse_type ())
193 { 192 {
193 octave_idx_type info;
194 bool natural = (nargout != 3);
195 bool force = nargout > 1;
196
194 if (arg.is_real_type ()) 197 if (arg.is_real_type ())
195 { 198 {
196 SparseMatrix m = arg.sparse_matrix_value (); 199 SparseMatrix m = arg.sparse_matrix_value ();
197 200
198 if (! error_state) 201 if (! error_state)
199 { 202 {
200 octave_idx_type info = nargout; 203 SparseCHOL fact (m, info, natural, force);
201 SparseCHOL fact (m, info, natural); 204
202 if (nargout == 3) 205 if (nargout == 3)
203 { 206 {
204 if (vecout) 207 if (vecout)
205 retval(2) = fact.perm (); 208 retval(2) = fact.perm ();
206 else 209 else
223 { 226 {
224 SparseComplexMatrix m = arg.sparse_complex_matrix_value (); 227 SparseComplexMatrix m = arg.sparse_complex_matrix_value ();
225 228
226 if (! error_state) 229 if (! error_state)
227 { 230 {
228 octave_idx_type info = nargout; 231 SparseComplexCHOL fact (m, info, natural, force);
229 SparseComplexCHOL fact (m, info, natural);
230 232
231 if (nargout == 3) 233 if (nargout == 3)
232 { 234 {
233 if (vecout) 235 if (vecout)
234 retval(2) = fact.perm (); 236 retval(2) = fact.perm ();
403 retval = Matrix (); 405 retval = Matrix ();
404 else 406 else
405 { 407 {
406 if (arg.is_sparse_type ()) 408 if (arg.is_sparse_type ())
407 { 409 {
410 octave_idx_type info;
411
408 if (arg.is_real_type ()) 412 if (arg.is_real_type ())
409 { 413 {
410 SparseMatrix m = arg.sparse_matrix_value (); 414 SparseMatrix m = arg.sparse_matrix_value ();
411 415
412 if (! error_state) 416 if (! error_state)
413 { 417 {
414 octave_idx_type info;
415 SparseCHOL chol (m, info); 418 SparseCHOL chol (m, info);
419
416 if (info == 0) 420 if (info == 0)
417 retval = chol.inverse (); 421 retval = chol.inverse ();
418 else 422 else
419 error ("cholinv: A must be positive definite"); 423 error ("cholinv: A must be positive definite");
420 } 424 }
423 { 427 {
424 SparseComplexMatrix m = arg.sparse_complex_matrix_value (); 428 SparseComplexMatrix m = arg.sparse_complex_matrix_value ();
425 429
426 if (! error_state) 430 if (! error_state)
427 { 431 {
428 octave_idx_type info;
429 SparseComplexCHOL chol (m, info); 432 SparseComplexCHOL chol (m, info);
433
430 if (info == 0) 434 if (info == 0)
431 retval = chol.inverse (); 435 retval = chol.inverse ();
432 else 436 else
433 error ("cholinv: A must be positive definite"); 437 error ("cholinv: A must be positive definite");
434 } 438 }