comparison src/DLD-FUNCTIONS/chol.cc @ 10154:40dfc0c99116

DLD-FUNCTIONS/*.cc: untabify
author John W. Eaton <jwe@octave.org>
date Wed, 20 Jan 2010 17:33:41 -0500
parents c0aeedd8fb86
children d0ce5e973937
comparison
equal deleted inserted replaced
10153:2c28f9d0360f 10154:40dfc0c99116
146 while (n < nargin && ! error_state) 146 while (n < nargin && ! error_state)
147 { 147 {
148 std::string tmp = args(n++).string_value (); 148 std::string tmp = args(n++).string_value ();
149 149
150 if (! error_state ) 150 if (! error_state )
151 { 151 {
152 if (tmp.compare ("vector") == 0) 152 if (tmp.compare ("vector") == 0)
153 vecout = true; 153 vecout = true;
154 else if (tmp.compare ("lower") == 0) 154 else if (tmp.compare ("lower") == 0)
155 LLt = true; 155 LLt = true;
156 else if (tmp.compare ("upper") == 0) 156 else if (tmp.compare ("upper") == 0)
157 LLt = false; 157 LLt = false;
158 else 158 else
159 error ("chol: unexpected second or third input"); 159 error ("chol: unexpected second or third input");
160 } 160 }
161 else 161 else
162 error ("chol: expecting trailing string arguments"); 162 error ("chol: expecting trailing string arguments");
163 } 163 }
164 164
165 if (! error_state) 165 if (! error_state)
166 { 166 {
167 octave_value arg = args(0); 167 octave_value arg = args(0);
171 bool natural = (nargout != 3); 171 bool natural = (nargout != 3);
172 172
173 int arg_is_empty = empty_arg ("chol", nr, nc); 173 int arg_is_empty = empty_arg ("chol", nr, nc);
174 174
175 if (arg_is_empty < 0) 175 if (arg_is_empty < 0)
176 return retval; 176 return retval;
177 if (arg_is_empty > 0) 177 if (arg_is_empty > 0)
178 return octave_value (Matrix ()); 178 return octave_value (Matrix ());
179 179
180 if (arg.is_sparse_type ()) 180 if (arg.is_sparse_type ())
181 { 181 {
182 if (arg.is_real_type ()) 182 if (arg.is_real_type ())
183 { 183 {
184 SparseMatrix m = arg.sparse_matrix_value (); 184 SparseMatrix m = arg.sparse_matrix_value ();
185 185
186 if (! error_state) 186 if (! error_state)
187 { 187 {
188 octave_idx_type info; 188 octave_idx_type info;
189 SparseCHOL fact (m, info, natural); 189 SparseCHOL fact (m, info, natural);
190 if (nargout == 3) 190 if (nargout == 3)
191 { 191 {
192 if (vecout) 192 if (vecout)
193 retval(2) = fact.perm (); 193 retval(2) = fact.perm ();
194 else 194 else
195 retval(2) = fact.Q(); 195 retval(2) = fact.Q();
196 } 196 }
197 197
198 if (nargout > 1 || info == 0) 198 if (nargout > 1 || info == 0)
199 { 199 {
200 retval(1) = fact.P(); 200 retval(1) = fact.P();
201 if (LLt) 201 if (LLt)
202 retval(0) = fact.L(); 202 retval(0) = fact.L();
203 else 203 else
204 retval(0) = fact.R(); 204 retval(0) = fact.R();
205 } 205 }
206 else 206 else
207 error ("chol: matrix not positive definite"); 207 error ("chol: matrix not positive definite");
208 } 208 }
209 } 209 }
210 else if (arg.is_complex_type ()) 210 else if (arg.is_complex_type ())
211 { 211 {
212 SparseComplexMatrix m = arg.sparse_complex_matrix_value (); 212 SparseComplexMatrix m = arg.sparse_complex_matrix_value ();
213 213
214 if (! error_state) 214 if (! error_state)
215 { 215 {
216 octave_idx_type info; 216 octave_idx_type info;
217 SparseComplexCHOL fact (m, info, natural); 217 SparseComplexCHOL fact (m, info, natural);
218 218
219 if (nargout == 3) 219 if (nargout == 3)
220 { 220 {
221 if (vecout) 221 if (vecout)
222 retval(2) = fact.perm (); 222 retval(2) = fact.perm ();
223 else 223 else
224 retval(2) = fact.Q(); 224 retval(2) = fact.Q();
225 } 225 }
226 226
227 if (nargout > 1 || info == 0) 227 if (nargout > 1 || info == 0)
228 { 228 {
229 retval(1) = fact.P(); 229 retval(1) = fact.P();
230 if (LLt) 230 if (LLt)
231 retval(0) = fact.L(); 231 retval(0) = fact.L();
232 else 232 else
233 retval(0) = fact.R(); 233 retval(0) = fact.R();
234 } 234 }
235 else 235 else
236 error ("chol: matrix not positive definite"); 236 error ("chol: matrix not positive definite");
237 } 237 }
238 } 238 }
239 else 239 else
240 gripe_wrong_type_arg ("chol", arg); 240 gripe_wrong_type_arg ("chol", arg);
241 } 241 }
242 else if (arg.is_single_type ()) 242 else if (arg.is_single_type ())
243 { 243 {
244 if (arg.is_real_type ()) 244 if (arg.is_real_type ())
245 { 245 {
246 FloatMatrix m = arg.float_matrix_value (); 246 FloatMatrix m = arg.float_matrix_value ();
247 247
248 if (! error_state) 248 if (! error_state)
249 { 249 {
250 octave_idx_type info; 250 octave_idx_type info;
251 FloatCHOL fact (m, info); 251 FloatCHOL fact (m, info);
252 if (nargout == 2 || info == 0) 252 if (nargout == 2 || info == 0)
253 { 253 {
254 retval(1) = info; 254 retval(1) = info;
255 if (LLt) 255 if (LLt)
256 retval(0) = get_chol_l (fact); 256 retval(0) = get_chol_l (fact);
257 else 257 else
258 retval(0) = get_chol_r (fact); 258 retval(0) = get_chol_r (fact);
259 } 259 }
260 else 260 else
261 error ("chol: matrix not positive definite"); 261 error ("chol: matrix not positive definite");
262 } 262 }
263 } 263 }
264 else if (arg.is_complex_type ()) 264 else if (arg.is_complex_type ())
265 { 265 {
266 FloatComplexMatrix m = arg.float_complex_matrix_value (); 266 FloatComplexMatrix m = arg.float_complex_matrix_value ();
267 267
268 if (! error_state) 268 if (! error_state)
269 { 269 {
270 octave_idx_type info; 270 octave_idx_type info;
271 FloatComplexCHOL fact (m, info); 271 FloatComplexCHOL fact (m, info);
272 if (nargout == 2 || info == 0) 272 if (nargout == 2 || info == 0)
273 { 273 {
274 retval(1) = info; 274 retval(1) = info;
275 if (LLt) 275 if (LLt)
276 retval(0) = get_chol_l (fact); 276 retval(0) = get_chol_l (fact);
277 else 277 else
278 retval(0) = get_chol_r (fact); 278 retval(0) = get_chol_r (fact);
279 } 279 }
280 else 280 else
281 error ("chol: matrix not positive definite"); 281 error ("chol: matrix not positive definite");
282 } 282 }
283 } 283 }
284 else 284 else
285 gripe_wrong_type_arg ("chol", arg); 285 gripe_wrong_type_arg ("chol", arg);
286 } 286 }
287 else 287 else
288 { 288 {
289 if (arg.is_real_type ()) 289 if (arg.is_real_type ())
290 { 290 {
291 Matrix m = arg.matrix_value (); 291 Matrix m = arg.matrix_value ();
292 292
293 if (! error_state) 293 if (! error_state)
294 { 294 {
295 octave_idx_type info; 295 octave_idx_type info;
296 CHOL fact (m, info); 296 CHOL fact (m, info);
297 if (nargout == 2 || info == 0) 297 if (nargout == 2 || info == 0)
298 { 298 {
299 retval(1) = info; 299 retval(1) = info;
300 if (LLt) 300 if (LLt)
301 retval(0) = get_chol_l (fact); 301 retval(0) = get_chol_l (fact);
302 else 302 else
303 retval(0) = get_chol_r (fact); 303 retval(0) = get_chol_r (fact);
304 } 304 }
305 else 305 else
306 error ("chol: matrix not positive definite"); 306 error ("chol: matrix not positive definite");
307 } 307 }
308 } 308 }
309 else if (arg.is_complex_type ()) 309 else if (arg.is_complex_type ())
310 { 310 {
311 ComplexMatrix m = arg.complex_matrix_value (); 311 ComplexMatrix m = arg.complex_matrix_value ();
312 312
313 if (! error_state) 313 if (! error_state)
314 { 314 {
315 octave_idx_type info; 315 octave_idx_type info;
316 ComplexCHOL fact (m, info); 316 ComplexCHOL fact (m, info);
317 if (nargout == 2 || info == 0) 317 if (nargout == 2 || info == 0)
318 { 318 {
319 retval(1) = info; 319 retval(1) = info;
320 if (LLt) 320 if (LLt)
321 retval(0) = get_chol_l (fact); 321 retval(0) = get_chol_l (fact);
322 else 322 else
323 retval(0) = get_chol_r (fact); 323 retval(0) = get_chol_r (fact);
324 } 324 }
325 else 325 else
326 error ("chol: matrix not positive definite"); 326 error ("chol: matrix not positive definite");
327 } 327 }
328 } 328 }
329 else 329 else
330 gripe_wrong_type_arg ("chol", arg); 330 gripe_wrong_type_arg ("chol", arg);
331 } 331 }
332 } 332 }
333 333
334 return retval; 334 return retval;
335 } 335 }
336 336
364 364
365 octave_idx_type nr = arg.rows (); 365 octave_idx_type nr = arg.rows ();
366 octave_idx_type nc = arg.columns (); 366 octave_idx_type nc = arg.columns ();
367 367
368 if (nr == 0 || nc == 0) 368 if (nr == 0 || nc == 0)
369 retval = Matrix (); 369 retval = Matrix ();
370 else 370 else
371 { 371 {
372 if (arg.is_sparse_type ()) 372 if (arg.is_sparse_type ())
373 { 373 {
374 if (arg.is_real_type ()) 374 if (arg.is_real_type ())
375 { 375 {
376 SparseMatrix m = arg.sparse_matrix_value (); 376 SparseMatrix m = arg.sparse_matrix_value ();
377 377
378 if (! error_state) 378 if (! error_state)
379 { 379 {
380 octave_idx_type info; 380 octave_idx_type info;
381 SparseCHOL chol (m, info); 381 SparseCHOL chol (m, info);
382 if (info == 0) 382 if (info == 0)
383 retval = chol.inverse (); 383 retval = chol.inverse ();
384 else 384 else
385 error ("cholinv: matrix not positive definite"); 385 error ("cholinv: matrix not positive definite");
386 } 386 }
387 } 387 }
388 else if (arg.is_complex_type ()) 388 else if (arg.is_complex_type ())
389 { 389 {
390 SparseComplexMatrix m = arg.sparse_complex_matrix_value (); 390 SparseComplexMatrix m = arg.sparse_complex_matrix_value ();
391 391
392 if (! error_state) 392 if (! error_state)
393 { 393 {
394 octave_idx_type info; 394 octave_idx_type info;
395 SparseComplexCHOL chol (m, info); 395 SparseComplexCHOL chol (m, info);
396 if (info == 0) 396 if (info == 0)
397 retval = chol.inverse (); 397 retval = chol.inverse ();
398 else 398 else
399 error ("cholinv: matrix not positive definite"); 399 error ("cholinv: matrix not positive definite");
400 } 400 }
401 } 401 }
402 else 402 else
403 gripe_wrong_type_arg ("cholinv", arg); 403 gripe_wrong_type_arg ("cholinv", arg);
404 } 404 }
405 else if (arg.is_single_type ()) 405 else if (arg.is_single_type ())
406 { 406 {
407 if (arg.is_real_type ()) 407 if (arg.is_real_type ())
408 { 408 {
409 FloatMatrix m = arg.float_matrix_value (); 409 FloatMatrix m = arg.float_matrix_value ();
410 410
411 if (! error_state) 411 if (! error_state)
412 { 412 {
413 octave_idx_type info; 413 octave_idx_type info;
414 FloatCHOL chol (m, info); 414 FloatCHOL chol (m, info);
415 if (info == 0) 415 if (info == 0)
416 retval = chol.inverse (); 416 retval = chol.inverse ();
417 else 417 else
418 error ("cholinv: matrix not positive definite"); 418 error ("cholinv: matrix not positive definite");
419 } 419 }
420 } 420 }
421 else if (arg.is_complex_type ()) 421 else if (arg.is_complex_type ())
422 { 422 {
423 FloatComplexMatrix m = arg.float_complex_matrix_value (); 423 FloatComplexMatrix m = arg.float_complex_matrix_value ();
424 424
425 if (! error_state) 425 if (! error_state)
426 { 426 {
427 octave_idx_type info; 427 octave_idx_type info;
428 FloatComplexCHOL chol (m, info); 428 FloatComplexCHOL chol (m, info);
429 if (info == 0) 429 if (info == 0)
430 retval = chol.inverse (); 430 retval = chol.inverse ();
431 else 431 else
432 error ("cholinv: matrix not positive definite"); 432 error ("cholinv: matrix not positive definite");
433 } 433 }
434 } 434 }
435 else 435 else
436 gripe_wrong_type_arg ("chol", arg); 436 gripe_wrong_type_arg ("chol", arg);
437 } 437 }
438 else 438 else
439 { 439 {
440 if (arg.is_real_type ()) 440 if (arg.is_real_type ())
441 { 441 {
442 Matrix m = arg.matrix_value (); 442 Matrix m = arg.matrix_value ();
443 443
444 if (! error_state) 444 if (! error_state)
445 { 445 {
446 octave_idx_type info; 446 octave_idx_type info;
447 CHOL chol (m, info); 447 CHOL chol (m, info);
448 if (info == 0) 448 if (info == 0)
449 retval = chol.inverse (); 449 retval = chol.inverse ();
450 else 450 else
451 error ("cholinv: matrix not positive definite"); 451 error ("cholinv: matrix not positive definite");
452 } 452 }
453 } 453 }
454 else if (arg.is_complex_type ()) 454 else if (arg.is_complex_type ())
455 { 455 {
456 ComplexMatrix m = arg.complex_matrix_value (); 456 ComplexMatrix m = arg.complex_matrix_value ();
457 457
458 if (! error_state) 458 if (! error_state)
459 { 459 {
460 octave_idx_type info; 460 octave_idx_type info;
461 ComplexCHOL chol (m, info); 461 ComplexCHOL chol (m, info);
462 if (info == 0) 462 if (info == 0)
463 retval = chol.inverse (); 463 retval = chol.inverse ();
464 else 464 else
465 error ("cholinv: matrix not positive definite"); 465 error ("cholinv: matrix not positive definite");
466 } 466 }
467 } 467 }
468 else 468 else
469 gripe_wrong_type_arg ("chol", arg); 469 gripe_wrong_type_arg ("chol", arg);
470 } 470 }
471 } 471 }
472 } 472 }
473 else 473 else
474 print_usage (); 474 print_usage ();
475 475
476 return retval; 476 return retval;
517 517
518 octave_idx_type nr = arg.rows (); 518 octave_idx_type nr = arg.rows ();
519 octave_idx_type nc = arg.columns (); 519 octave_idx_type nc = arg.columns ();
520 520
521 if (nr == 0 || nc == 0) 521 if (nr == 0 || nc == 0)
522 retval = Matrix (); 522 retval = Matrix ();
523 else 523 else
524 { 524 {
525 if (arg.is_sparse_type ()) 525 if (arg.is_sparse_type ())
526 { 526 {
527 if (arg.is_real_type ()) 527 if (arg.is_real_type ())
528 { 528 {
529 SparseMatrix r = arg.sparse_matrix_value (); 529 SparseMatrix r = arg.sparse_matrix_value ();
530 530
531 if (! error_state) 531 if (! error_state)
532 retval = chol2inv (r); 532 retval = chol2inv (r);
533 } 533 }
534 else if (arg.is_complex_type ()) 534 else if (arg.is_complex_type ())
535 { 535 {
536 SparseComplexMatrix r = arg.sparse_complex_matrix_value (); 536 SparseComplexMatrix r = arg.sparse_complex_matrix_value ();
537 537
538 if (! error_state) 538 if (! error_state)
539 retval = chol2inv (r); 539 retval = chol2inv (r);
540 } 540 }
541 else 541 else
542 gripe_wrong_type_arg ("chol2inv", arg); 542 gripe_wrong_type_arg ("chol2inv", arg);
543 } 543 }
544 else if (arg.is_single_type ()) 544 else if (arg.is_single_type ())
545 { 545 {
546 if (arg.is_real_type ()) 546 if (arg.is_real_type ())
547 { 547 {
548 FloatMatrix r = arg.float_matrix_value (); 548 FloatMatrix r = arg.float_matrix_value ();
549 549
550 if (! error_state) 550 if (! error_state)
551 retval = chol2inv (r); 551 retval = chol2inv (r);
552 } 552 }
553 else if (arg.is_complex_type ()) 553 else if (arg.is_complex_type ())
554 { 554 {
555 FloatComplexMatrix r = arg.float_complex_matrix_value (); 555 FloatComplexMatrix r = arg.float_complex_matrix_value ();
556 556
557 if (! error_state) 557 if (! error_state)
558 retval = chol2inv (r); 558 retval = chol2inv (r);
559 } 559 }
560 else 560 else
561 gripe_wrong_type_arg ("chol2inv", arg); 561 gripe_wrong_type_arg ("chol2inv", arg);
562 562
563 } 563 }
564 else 564 else
565 { 565 {
566 if (arg.is_real_type ()) 566 if (arg.is_real_type ())
567 { 567 {
568 Matrix r = arg.matrix_value (); 568 Matrix r = arg.matrix_value ();
569 569
570 if (! error_state) 570 if (! error_state)
571 retval = chol2inv (r); 571 retval = chol2inv (r);
572 } 572 }
573 else if (arg.is_complex_type ()) 573 else if (arg.is_complex_type ())
574 { 574 {
575 ComplexMatrix r = arg.complex_matrix_value (); 575 ComplexMatrix r = arg.complex_matrix_value ();
576 576
577 if (! error_state) 577 if (! error_state)
578 retval = chol2inv (r); 578 retval = chol2inv (r);
579 } 579 }
580 else 580 else
581 gripe_wrong_type_arg ("chol2inv", arg); 581 gripe_wrong_type_arg ("chol2inv", arg);
582 } 582 }
583 } 583 }
584 } 584 }
585 else 585 else
586 print_usage (); 586 print_usage ();
587 587
588 return retval; 588 return retval;
638 638
639 if (down || op == "+") 639 if (down || op == "+")
640 if (argr.columns () == n && argu.rows () == n && argu.columns () == 1) 640 if (argr.columns () == n && argu.rows () == n && argu.columns () == 1)
641 { 641 {
642 int err = 0; 642 int err = 0;
643 if (argr.is_single_type () || argu.is_single_type ()) 643 if (argr.is_single_type () || argu.is_single_type ())
644 { 644 {
645 if (argr.is_real_type () && argu.is_real_type ()) 645 if (argr.is_real_type () && argu.is_real_type ())
646 { 646 {
647 // real case 647 // real case
648 FloatMatrix R = argr.float_matrix_value (); 648 FloatMatrix R = argr.float_matrix_value ();
649 FloatColumnVector u = argu.float_column_vector_value (); 649 FloatColumnVector u = argu.float_column_vector_value ();
650 650
651 FloatCHOL fact; 651 FloatCHOL fact;
652 fact.set (R); 652 fact.set (R);
653 653
654 if (down) 654 if (down)
655 err = fact.downdate (u); 655 err = fact.downdate (u);
656 else 656 else
657 fact.update (u); 657 fact.update (u);
658 658
659 retval(0) = get_chol_r (fact); 659 retval(0) = get_chol_r (fact);
660 } 660 }
661 else 661 else
662 { 662 {
663 // complex case 663 // complex case
664 FloatComplexMatrix R = argr.float_complex_matrix_value (); 664 FloatComplexMatrix R = argr.float_complex_matrix_value ();
665 FloatComplexColumnVector u = argu.float_complex_column_vector_value (); 665 FloatComplexColumnVector u = argu.float_complex_column_vector_value ();
666 666
667 FloatComplexCHOL fact; 667 FloatComplexCHOL fact;
668 fact.set (R); 668 fact.set (R);
669 669
670 if (down) 670 if (down)
671 err = fact.downdate (u); 671 err = fact.downdate (u);
672 else 672 else
673 fact.update (u); 673 fact.update (u);
674 674
675 retval(0) = get_chol_r (fact); 675 retval(0) = get_chol_r (fact);
676 } 676 }
677 } 677 }
678 else 678 else
679 { 679 {
680 if (argr.is_real_type () && argu.is_real_type ()) 680 if (argr.is_real_type () && argu.is_real_type ())
681 { 681 {
682 // real case 682 // real case
683 Matrix R = argr.matrix_value (); 683 Matrix R = argr.matrix_value ();
684 ColumnVector u = argu.column_vector_value (); 684 ColumnVector u = argu.column_vector_value ();
685 685
686 CHOL fact; 686 CHOL fact;
687 fact.set (R); 687 fact.set (R);
688 688
689 if (down) 689 if (down)
690 err = fact.downdate (u); 690 err = fact.downdate (u);
691 else 691 else
692 fact.update (u); 692 fact.update (u);
693 693
694 retval(0) = get_chol_r (fact); 694 retval(0) = get_chol_r (fact);
695 } 695 }
696 else 696 else
697 { 697 {
698 // complex case 698 // complex case
699 ComplexMatrix R = argr.complex_matrix_value (); 699 ComplexMatrix R = argr.complex_matrix_value ();
700 ComplexColumnVector u = argu.complex_column_vector_value (); 700 ComplexColumnVector u = argu.complex_column_vector_value ();
701 701
702 ComplexCHOL fact; 702 ComplexCHOL fact;
703 fact.set (R); 703 fact.set (R);
704 704
705 if (down) 705 if (down)
706 err = fact.downdate (u); 706 err = fact.downdate (u);
707 else 707 else
708 fact.update (u); 708 fact.update (u);
709 709
710 retval(0) = get_chol_r (fact); 710 retval(0) = get_chol_r (fact);
711 } 711 }
712 } 712 }
713 713
714 if (nargout > 1) 714 if (nargout > 1)
715 retval(1) = err; 715 retval(1) = err;
716 else if (err == 1) 716 else if (err == 1)
717 error ("cholupdate: downdate violates positiveness"); 717 error ("cholupdate: downdate violates positiveness");
847 if (argr.columns () == n && argu.rows () == n+1 && argu.columns () == 1) 847 if (argr.columns () == n && argu.rows () == n+1 && argu.columns () == 1)
848 { 848 {
849 if (j > 0 && j <= n+1) 849 if (j > 0 && j <= n+1)
850 { 850 {
851 int err = 0; 851 int err = 0;
852 if (argr.is_single_type () || argu.is_single_type ()) 852 if (argr.is_single_type () || argu.is_single_type ())
853 { 853 {
854 if (argr.is_real_type () && argu.is_real_type ()) 854 if (argr.is_real_type () && argu.is_real_type ())
855 { 855 {
856 // real case 856 // real case
857 FloatMatrix R = argr.float_matrix_value (); 857 FloatMatrix R = argr.float_matrix_value ();
858 FloatColumnVector u = argu.float_column_vector_value (); 858 FloatColumnVector u = argu.float_column_vector_value ();
859 859
860 FloatCHOL fact; 860 FloatCHOL fact;
861 fact.set (R); 861 fact.set (R);
862 err = fact.insert_sym (u, j-1); 862 err = fact.insert_sym (u, j-1);
863 863
864 retval(0) = get_chol_r (fact); 864 retval(0) = get_chol_r (fact);
865 } 865 }
866 else 866 else
867 { 867 {
868 // complex case 868 // complex case
869 FloatComplexMatrix R = argr.float_complex_matrix_value (); 869 FloatComplexMatrix R = argr.float_complex_matrix_value ();
870 FloatComplexColumnVector u = argu.float_complex_column_vector_value (); 870 FloatComplexColumnVector u = argu.float_complex_column_vector_value ();
871 871
872 FloatComplexCHOL fact; 872 FloatComplexCHOL fact;
873 fact.set (R); 873 fact.set (R);
874 err = fact.insert_sym (u, j-1); 874 err = fact.insert_sym (u, j-1);
875 875
876 retval(0) = get_chol_r (fact); 876 retval(0) = get_chol_r (fact);
877 } 877 }
878 } 878 }
879 else 879 else
880 { 880 {
881 if (argr.is_real_type () && argu.is_real_type ()) 881 if (argr.is_real_type () && argu.is_real_type ())
882 { 882 {
883 // real case 883 // real case
884 Matrix R = argr.matrix_value (); 884 Matrix R = argr.matrix_value ();
885 ColumnVector u = argu.column_vector_value (); 885 ColumnVector u = argu.column_vector_value ();
886 886
887 CHOL fact; 887 CHOL fact;
888 fact.set (R); 888 fact.set (R);
889 err = fact.insert_sym (u, j-1); 889 err = fact.insert_sym (u, j-1);
890 890
891 retval(0) = get_chol_r (fact); 891 retval(0) = get_chol_r (fact);
892 } 892 }
893 else 893 else
894 { 894 {
895 // complex case 895 // complex case
896 ComplexMatrix R = argr.complex_matrix_value (); 896 ComplexMatrix R = argr.complex_matrix_value ();
897 ComplexColumnVector u = argu.complex_column_vector_value (); 897 ComplexColumnVector u = argu.complex_column_vector_value ();
898 898
899 ComplexCHOL fact; 899 ComplexCHOL fact;
900 fact.set (R); 900 fact.set (R);
901 err = fact.insert_sym (u, j-1); 901 err = fact.insert_sym (u, j-1);
902 902
903 retval(0) = get_chol_r (fact); 903 retval(0) = get_chol_r (fact);
904 } 904 }
905 } 905 }
906 906
907 if (nargout > 1) 907 if (nargout > 1)
908 retval(1) = err; 908 retval(1) = err;
909 else if (err == 1) 909 else if (err == 1)
910 error ("cholinsert: insertion violates positiveness"); 910 error ("cholinsert: insertion violates positiveness");
1018 1018
1019 if (argr.columns () == n) 1019 if (argr.columns () == n)
1020 { 1020 {
1021 if (j > 0 && j <= n) 1021 if (j > 0 && j <= n)
1022 { 1022 {
1023 if (argr.is_single_type ()) 1023 if (argr.is_single_type ())
1024 { 1024 {
1025 if (argr.is_real_type ()) 1025 if (argr.is_real_type ())
1026 { 1026 {
1027 // real case 1027 // real case
1028 FloatMatrix R = argr.float_matrix_value (); 1028 FloatMatrix R = argr.float_matrix_value ();
1029 1029
1030 FloatCHOL fact; 1030 FloatCHOL fact;
1031 fact.set (R); 1031 fact.set (R);
1032 fact.delete_sym (j-1); 1032 fact.delete_sym (j-1);
1033 1033
1034 retval(0) = get_chol_r (fact); 1034 retval(0) = get_chol_r (fact);
1035 } 1035 }
1036 else 1036 else
1037 { 1037 {
1038 // complex case 1038 // complex case
1039 FloatComplexMatrix R = argr.float_complex_matrix_value (); 1039 FloatComplexMatrix R = argr.float_complex_matrix_value ();
1040 1040
1041 FloatComplexCHOL fact; 1041 FloatComplexCHOL fact;
1042 fact.set (R); 1042 fact.set (R);
1043 fact.delete_sym (j-1); 1043 fact.delete_sym (j-1);
1044 1044
1045 retval(0) = get_chol_r (fact); 1045 retval(0) = get_chol_r (fact);
1046 } 1046 }
1047 } 1047 }
1048 else 1048 else
1049 { 1049 {
1050 if (argr.is_real_type ()) 1050 if (argr.is_real_type ())
1051 { 1051 {
1052 // real case 1052 // real case
1053 Matrix R = argr.matrix_value (); 1053 Matrix R = argr.matrix_value ();
1054 1054
1055 CHOL fact; 1055 CHOL fact;
1056 fact.set (R); 1056 fact.set (R);
1057 fact.delete_sym (j-1); 1057 fact.delete_sym (j-1);
1058 1058
1059 retval(0) = get_chol_r (fact); 1059 retval(0) = get_chol_r (fact);
1060 } 1060 }
1061 else 1061 else
1062 { 1062 {
1063 // complex case 1063 // complex case
1064 ComplexMatrix R = argr.complex_matrix_value (); 1064 ComplexMatrix R = argr.complex_matrix_value ();
1065 1065
1066 ComplexCHOL fact; 1066 ComplexCHOL fact;
1067 fact.set (R); 1067 fact.set (R);
1068 fact.delete_sym (j-1); 1068 fact.delete_sym (j-1);
1069 1069
1070 retval(0) = get_chol_r (fact); 1070 retval(0) = get_chol_r (fact);
1071 } 1071 }
1072 } 1072 }
1073 } 1073 }
1074 else 1074 else
1075 error ("choldelete: index out of range"); 1075 error ("choldelete: index out of range");
1076 } 1076 }
1077 else 1077 else
1158 if (argr.columns () == n) 1158 if (argr.columns () == n)
1159 { 1159 {
1160 if (j > 0 && j <= n+1 && i > 0 && i <= n+1) 1160 if (j > 0 && j <= n+1 && i > 0 && i <= n+1)
1161 { 1161 {
1162 1162
1163 if (argr.is_single_type () && argi.is_single_type () && 1163 if (argr.is_single_type () && argi.is_single_type () &&
1164 argj.is_single_type ()) 1164 argj.is_single_type ())
1165 { 1165 {
1166 if (argr.is_real_type ()) 1166 if (argr.is_real_type ())
1167 { 1167 {
1168 // real case 1168 // real case
1169 FloatMatrix R = argr.float_matrix_value (); 1169 FloatMatrix R = argr.float_matrix_value ();
1170 1170
1171 FloatCHOL fact; 1171 FloatCHOL fact;
1172 fact.set (R); 1172 fact.set (R);
1173 fact.shift_sym (i-1, j-1); 1173 fact.shift_sym (i-1, j-1);
1174 1174
1175 retval(0) = get_chol_r (fact); 1175 retval(0) = get_chol_r (fact);
1176 } 1176 }
1177 else 1177 else
1178 { 1178 {
1179 // complex case 1179 // complex case
1180 FloatComplexMatrix R = argr.float_complex_matrix_value (); 1180 FloatComplexMatrix R = argr.float_complex_matrix_value ();
1181 1181
1182 FloatComplexCHOL fact; 1182 FloatComplexCHOL fact;
1183 fact.set (R); 1183 fact.set (R);
1184 fact.shift_sym (i-1, j-1); 1184 fact.shift_sym (i-1, j-1);
1185 1185
1186 retval(0) = get_chol_r (fact); 1186 retval(0) = get_chol_r (fact);
1187 } 1187 }
1188 } 1188 }
1189 else 1189 else
1190 { 1190 {
1191 if (argr.is_real_type ()) 1191 if (argr.is_real_type ())
1192 { 1192 {
1193 // real case 1193 // real case
1194 Matrix R = argr.matrix_value (); 1194 Matrix R = argr.matrix_value ();
1195 1195
1196 CHOL fact; 1196 CHOL fact;
1197 fact.set (R); 1197 fact.set (R);
1198 fact.shift_sym (i-1, j-1); 1198 fact.shift_sym (i-1, j-1);
1199 1199
1200 retval(0) = get_chol_r (fact); 1200 retval(0) = get_chol_r (fact);
1201 } 1201 }
1202 else 1202 else
1203 { 1203 {
1204 // complex case 1204 // complex case
1205 ComplexMatrix R = argr.complex_matrix_value (); 1205 ComplexMatrix R = argr.complex_matrix_value ();
1206 1206
1207 ComplexCHOL fact; 1207 ComplexCHOL fact;
1208 fact.set (R); 1208 fact.set (R);
1209 fact.shift_sym (i-1, j-1); 1209 fact.shift_sym (i-1, j-1);
1210 1210
1211 retval(0) = get_chol_r (fact); 1211 retval(0) = get_chol_r (fact);
1212 } 1212 }
1213 } 1213 }
1214 } 1214 }
1215 else 1215 else
1216 error ("cholshift: index out of range"); 1216 error ("cholshift: index out of range");
1217 } 1217 }
1218 else 1218 else