Mercurial > octave-dspies
comparison libinterp/corefcn/lu.cc @ 18678:6113e0c6920b
maint: Clean up extra spaces before/after parentheses.
author | Rik <rik@octave.org> |
---|---|
date | Fri, 25 Apr 2014 13:25:25 -0700 |
parents | 4e0d72145c5a |
children | aa9ca67f09fb |
comparison
equal
deleted
inserted
replaced
18677:f684f7075aee | 18678:6113e0c6920b |
---|---|
160 { | 160 { |
161 if (args(n).is_string ()) | 161 if (args(n).is_string ()) |
162 { | 162 { |
163 std::string tmp = args(n++).string_value (); | 163 std::string tmp = args(n++).string_value (); |
164 | 164 |
165 if (! error_state ) | 165 if (! error_state) |
166 { | 166 { |
167 if (tmp.compare ("vector") == 0) | 167 if (tmp.compare ("vector") == 0) |
168 vecout = true; | 168 vecout = true; |
169 else | 169 else |
170 error ("lu: unrecognized string argument"); | 170 error ("lu: unrecognized string argument"); |
172 } | 172 } |
173 else | 173 else |
174 { | 174 { |
175 Matrix tmp = args(n++).matrix_value (); | 175 Matrix tmp = args(n++).matrix_value (); |
176 | 176 |
177 if (! error_state ) | 177 if (! error_state) |
178 { | 178 { |
179 if (!issparse) | 179 if (!issparse) |
180 error ("lu: can not define pivoting threshold THRES for full matrices"); | 180 error ("lu: can not define pivoting threshold THRES for full matrices"); |
181 else if (tmp.nelem () == 1) | 181 else if (tmp.nelem () == 1) |
182 { | 182 { |
209 if (arg.is_real_type ()) | 209 if (arg.is_real_type ()) |
210 { | 210 { |
211 | 211 |
212 SparseMatrix m = arg.sparse_matrix_value (); | 212 SparseMatrix m = arg.sparse_matrix_value (); |
213 | 213 |
214 if ( nargout < 4 ) | 214 if (nargout < 4) |
215 { | 215 { |
216 | 216 |
217 ColumnVector Qinit; | 217 ColumnVector Qinit; |
218 Qinit.resize (nc); | 218 Qinit.resize (nc); |
219 for (octave_idx_type i = 0; i < nc; i++) | 219 for (octave_idx_type i = 0; i < nc; i++) |
220 Qinit (i) = i; | 220 Qinit (i) = i; |
221 SparseLU fact (m, Qinit, thres, false, true); | 221 SparseLU fact (m, Qinit, thres, false, true); |
222 | 222 |
223 if ( nargout < 2 ) | 223 if (nargout < 2) |
224 retval(0) = fact.Y (); | 224 retval(0) = fact.Y (); |
225 else | 225 else |
226 { | 226 { |
227 | 227 |
228 retval(1) | 228 retval(1) |
231 MatrixType (MatrixType::Permuted_Upper, | 231 MatrixType (MatrixType::Permuted_Upper, |
232 nc, fact.col_perm ())); | 232 nc, fact.col_perm ())); |
233 | 233 |
234 PermMatrix P = fact.Pr_mat (); | 234 PermMatrix P = fact.Pr_mat (); |
235 SparseMatrix L = fact.L (); | 235 SparseMatrix L = fact.L (); |
236 if ( nargout < 3 ) | 236 if (nargout < 3) |
237 retval(0) | 237 retval(0) |
238 = octave_value ( P.transpose () * L, | 238 = octave_value (P.transpose () * L, |
239 MatrixType (MatrixType::Permuted_Lower, | 239 MatrixType (MatrixType::Permuted_Lower, |
240 nr, fact.row_perm ())); | 240 nr, fact.row_perm ())); |
241 else | 241 else |
242 { | 242 { |
243 retval(0) = L; | 243 retval(0) = L; |
244 if ( vecout ) | 244 if (vecout) |
245 retval(2) = fact.Pr_vec(); | 245 retval(2) = fact.Pr_vec(); |
246 else | 246 else |
247 retval(2) = P; | 247 retval(2) = P; |
248 } | 248 } |
249 | 249 |
277 } | 277 } |
278 else if (arg.is_complex_type ()) | 278 else if (arg.is_complex_type ()) |
279 { | 279 { |
280 SparseComplexMatrix m = arg.sparse_complex_matrix_value (); | 280 SparseComplexMatrix m = arg.sparse_complex_matrix_value (); |
281 | 281 |
282 if ( nargout < 4 ) | 282 if (nargout < 4) |
283 { | 283 { |
284 | 284 |
285 ColumnVector Qinit; | 285 ColumnVector Qinit; |
286 Qinit.resize (nc); | 286 Qinit.resize (nc); |
287 for (octave_idx_type i = 0; i < nc; i++) | 287 for (octave_idx_type i = 0; i < nc; i++) |
288 Qinit (i) = i; | 288 Qinit (i) = i; |
289 SparseComplexLU fact (m, Qinit, thres, false, true); | 289 SparseComplexLU fact (m, Qinit, thres, false, true); |
290 | 290 |
291 if ( nargout < 2 ) | 291 if (nargout < 2) |
292 | 292 |
293 retval(0) = fact.Y (); | 293 retval(0) = fact.Y (); |
294 | 294 |
295 else | 295 else |
296 { | 296 { |
301 MatrixType (MatrixType::Permuted_Upper, | 301 MatrixType (MatrixType::Permuted_Upper, |
302 nc, fact.col_perm ())); | 302 nc, fact.col_perm ())); |
303 | 303 |
304 PermMatrix P = fact.Pr_mat (); | 304 PermMatrix P = fact.Pr_mat (); |
305 SparseComplexMatrix L = fact.L (); | 305 SparseComplexMatrix L = fact.L (); |
306 if ( nargout < 3 ) | 306 if (nargout < 3) |
307 retval(0) | 307 retval(0) |
308 = octave_value ( P.transpose () * L, | 308 = octave_value (P.transpose () * L, |
309 MatrixType (MatrixType::Permuted_Lower, | 309 MatrixType (MatrixType::Permuted_Lower, |
310 nr, fact.row_perm ())); | 310 nr, fact.row_perm ())); |
311 else | 311 else |
312 { | 312 { |
313 retval(0) = L; | 313 retval(0) = L; |
314 if ( vecout ) | 314 if (vecout) |
315 retval(2) = fact.Pr_vec(); | 315 retval(2) = fact.Pr_vec(); |
316 else | 316 else |
317 retval(2) = P; | 317 retval(2) = P; |
318 } | 318 } |
319 | 319 |