GNU Octave  4.0.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
chol.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-2015 John W. Eaton
4 Copyright (C) 2008-2009 Jaroslav Hajek
5 Copyright (C) 2008-2009 VZLU Prague
6 
7 This file is part of Octave.
8 
9 Octave is free software; you can redistribute it and/or modify it
10 under the terms of the GNU General Public License as published by the
11 Free Software Foundation; either version 3 of the License, or (at your
12 option) any later version.
13 
14 Octave is distributed in the hope that it will be useful, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with Octave; see the file COPYING. If not, see
21 <http://www.gnu.org/licenses/>.
22 
23 */
24 
25 
26 #ifdef HAVE_CONFIG_H
27 #include <config.h>
28 #endif
29 
30 #include "CmplxCHOL.h"
31 #include "dbleCHOL.h"
32 #include "fCmplxCHOL.h"
33 #include "floatCHOL.h"
34 #include "SparseCmplxCHOL.h"
35 #include "SparsedbleCHOL.h"
36 #include "oct-spparms.h"
37 #include "sparse-util.h"
38 
39 #include "ov-re-sparse.h"
40 #include "ov-cx-sparse.h"
41 #include "defun-dld.h"
42 #include "error.h"
43 #include "gripes.h"
44 #include "oct-obj.h"
45 #include "utils.h"
46 
47 template <class CHOLT>
48 static octave_value
49 get_chol_r (const CHOLT& fact)
50 {
51  return octave_value (fact.chol_matrix (),
53 }
54 
55 template <class CHOLT>
56 static octave_value
57 get_chol_l (const CHOLT& fact)
58 {
59  return octave_value (fact.chol_matrix ().transpose (),
61 }
62 
63 DEFUN_DLD (chol, args, nargout,
64  "-*- texinfo -*-\n\
65 @deftypefn {Loadable Function} {@var{R} =} chol (@var{A})\n\
66 @deftypefnx {Loadable Function} {[@var{R}, @var{p}] =} chol (@var{A})\n\
67 @deftypefnx {Loadable Function} {[@var{R}, @var{p}, @var{Q}] =} chol (@var{S})\n\
68 @deftypefnx {Loadable Function} {[@var{R}, @var{p}, @var{Q}] =} chol (@var{S}, \"vector\")\n\
69 @deftypefnx {Loadable Function} {[@var{L}, @dots{}] =} chol (@dots{}, \"lower\")\n\
70 @deftypefnx {Loadable Function} {[@var{L}, @dots{}] =} chol (@dots{}, \"upper\")\n\
71 @cindex Cholesky factorization\n\
72 Compute the Cholesky@tie{}factor, @var{R}, of the symmetric positive definite\n\
73 matrix @var{A}.\n\
74 \n\
75 The Cholesky@tie{}factor is defined by\n\
76 @tex\n\
77 $ R^T R = A $.\n\
78 @end tex\n\
79 @ifnottex\n\
80 \n\
81 @example\n\
82 @var{R}' * @var{R} = @var{A}.\n\
83 @end example\n\
84 \n\
85 @end ifnottex\n\
86 \n\
87 Called with one output argument @code{chol} fails if @var{A} or @var{S} is\n\
88 not positive definite. With two or more output arguments @var{p} flags\n\
89 whether the matrix was positive definite and @code{chol} does not fail. A\n\
90 zero value indicated that the matrix was positive definite and the @var{R}\n\
91 gives the factorization, and @var{p} will have a positive value otherwise.\n\
92 \n\
93 If called with 3 outputs then a sparsity preserving row/column permutation\n\
94 is applied to @var{A} prior to the factorization. That is @var{R} is the\n\
95 factorization of @code{@var{A}(@var{Q},@var{Q})} such that\n\
96 @tex\n\
97 $ R^T R = Q^T A Q$.\n\
98 @end tex\n\
99 @ifnottex\n\
100 \n\
101 @example\n\
102 @var{R}' * @var{R} = @var{Q}' * @var{A} * @var{Q}.\n\
103 @end example\n\
104 \n\
105 @end ifnottex\n\
106 \n\
107 The sparsity preserving permutation is generally returned as a matrix.\n\
108 However, given the flag @qcode{\"vector\"}, @var{Q} will be returned as a\n\
109 vector such that\n\
110 @tex\n\
111 $ R^T R = A (Q, Q)$.\n\
112 @end tex\n\
113 @ifnottex\n\
114 \n\
115 @example\n\
116 @var{R}' * @var{R} = @var{A}(@var{Q}, @var{Q}).\n\
117 @end example\n\
118 \n\
119 @end ifnottex\n\
120 \n\
121 Called with either a sparse or full matrix and using the @qcode{\"lower\"}\n\
122 flag, @code{chol} returns the lower triangular factorization such that\n\
123 @tex\n\
124 $ L L^T = A $.\n\
125 @end tex\n\
126 @ifnottex\n\
127 \n\
128 @example\n\
129 @var{L} * @var{L}' = @var{A}.\n\
130 @end example\n\
131 \n\
132 @end ifnottex\n\
133 \n\
134 For full matrices, if the @qcode{\"lower\"} flag is set only the lower\n\
135 triangular part of the matrix is used for the factorization, otherwise the\n\
136 upper triangular part is used.\n\
137 \n\
138 In general the lower triangular factorization is significantly faster for\n\
139 sparse matrices.\n\
140 @seealso{hess, lu, qr, qz, schur, svd, ichol, cholinv, chol2inv, cholupdate, cholinsert, choldelete, cholshift}\n\
141 @end deftypefn")
142 {
143  octave_value_list retval;
144  int nargin = args.length ();
145  bool LLt = false;
146  bool vecout = false;
147 
148  if (nargin < 1 || nargin > 3 || nargout > 3
149  || (! args(0).is_sparse_type () && nargout > 2))
150  {
151  print_usage ();
152  return retval;
153  }
154 
155  int n = 1;
156  while (n < nargin && ! error_state)
157  {
158  std::string tmp = args(n++).string_value ();
159 
160  if (! error_state)
161  {
162  if (tmp.compare ("vector") == 0)
163  vecout = true;
164  else if (tmp.compare ("lower") == 0)
165  // FIXME: currently the option "lower" is handled by transposing
166  // the matrix, factorizing it with the lapack function
167  // DPOTRF ('U', ...) and finally transposing the factor. It would
168  // be more efficient to use DPOTRF ('L', ...) in this case.
169  LLt = true;
170  else if (tmp.compare ("upper") == 0)
171  LLt = false;
172  else
173  error ("chol: unexpected second or third input");
174  }
175  else
176  error ("chol: expecting trailing string arguments");
177  }
178 
179  if (! error_state)
180  {
181  octave_value arg = args(0);
182 
183  octave_idx_type nr = arg.rows ();
184  octave_idx_type nc = arg.columns ();
185 
186  int arg_is_empty = empty_arg ("chol", nr, nc);
187 
188  if (arg_is_empty < 0)
189  return retval;
190  if (arg_is_empty > 0)
191  return octave_value (Matrix ());
192 
193  if (arg.is_sparse_type ())
194  {
195  octave_idx_type info;
196  bool natural = (nargout != 3);
197  bool force = nargout > 1;
198 
199  if (arg.is_real_type ())
200  {
202 
203  if (! error_state)
204  {
205  SparseCHOL fact (m, info, natural, force);
206 
207  if (nargout == 3)
208  {
209  if (vecout)
210  retval(2) = fact.perm ();
211  else
212  retval(2) = fact.Q ();
213  }
214 
215  if (nargout > 1 || info == 0)
216  {
217  retval(1) = info;
218  if (LLt)
219  retval(0) = fact.L ();
220  else
221  retval(0) = fact.R ();
222  }
223  else
224  error ("chol: input matrix must be positive definite");
225  }
226  }
227  else if (arg.is_complex_type ())
228  {
230 
231  if (! error_state)
232  {
233  SparseComplexCHOL fact (m, info, natural, force);
234 
235  if (nargout == 3)
236  {
237  if (vecout)
238  retval(2) = fact.perm ();
239  else
240  retval(2) = fact.Q ();
241  }
242 
243  if (nargout > 1 || info == 0)
244  {
245  retval(1) = info;
246  if (LLt)
247  retval(0) = fact.L ();
248  else
249  retval(0) = fact.R ();
250  }
251  else
252  error ("chol: input matrix must be positive definite");
253  }
254  }
255  else
256  gripe_wrong_type_arg ("chol", arg);
257  }
258  else if (arg.is_single_type ())
259  {
260  if (arg.is_real_type ())
261  {
262  FloatMatrix m = arg.float_matrix_value ();
263 
264  if (! error_state)
265  {
266  octave_idx_type info;
267 
268  FloatCHOL fact;
269  if (LLt)
270  fact = FloatCHOL (m.transpose (), info);
271  else
272  fact = FloatCHOL (m, info);
273 
274  if (nargout == 2 || info == 0)
275  {
276  retval(1) = info;
277  if (LLt)
278  retval(0) = get_chol_l (fact);
279  else
280  retval(0) = get_chol_r (fact);
281  }
282  else
283  error ("chol: input matrix must be positive definite");
284  }
285  }
286  else if (arg.is_complex_type ())
287  {
289 
290  if (! error_state)
291  {
292  octave_idx_type info;
293 
294  FloatComplexCHOL fact;
295  if (LLt)
296  fact = FloatComplexCHOL (m.transpose (), info);
297  else
298  fact = FloatComplexCHOL (m, info);
299 
300  if (nargout == 2 || info == 0)
301  {
302  retval(1) = info;
303  if (LLt)
304  retval(0) = get_chol_l (fact);
305  else
306  retval(0) = get_chol_r (fact);
307  }
308  else
309  error ("chol: input matrix must be positive definite");
310  }
311  }
312  else
313  gripe_wrong_type_arg ("chol", arg);
314  }
315  else
316  {
317  if (arg.is_real_type ())
318  {
319  Matrix m = arg.matrix_value ();
320 
321  if (! error_state)
322  {
323  octave_idx_type info;
324 
325  CHOL fact;
326  if (LLt)
327  fact = CHOL (m.transpose (), info);
328  else
329  fact = CHOL (m, info);
330 
331  if (nargout == 2 || info == 0)
332  {
333  retval(1) = info;
334  if (LLt)
335  retval(0) = get_chol_l (fact);
336  else
337  retval(0) = get_chol_r (fact);
338  }
339  else
340  error ("chol: input matrix must be positive definite");
341  }
342  }
343  else if (arg.is_complex_type ())
344  {
346 
347  if (! error_state)
348  {
349  octave_idx_type info;
350 
351  ComplexCHOL fact;
352  if (LLt)
353  fact = ComplexCHOL (m.transpose (), info);
354  else
355  fact = ComplexCHOL (m, info);
356 
357  if (nargout == 2 || info == 0)
358  {
359  retval(1) = info;
360  if (LLt)
361  retval(0) = get_chol_l (fact);
362  else
363  retval(0) = get_chol_r (fact);
364  }
365  else
366  error ("chol: input matrix must be positive definite");
367  }
368  }
369  else
370  gripe_wrong_type_arg ("chol", arg);
371  }
372  }
373 
374  return retval;
375 }
376 
377 /*
378 %!assert (chol ([2, 1; 1, 1]), [sqrt(2), 1/sqrt(2); 0, 1/sqrt(2)], sqrt (eps))
379 %!assert (chol (single ([2, 1; 1, 1])), single ([sqrt(2), 1/sqrt(2); 0, 1/sqrt(2)]), sqrt (eps ("single")))
380 %!testif HAVE_CHOLMOD
381 %! ## Bug #42587
382 %! A = sparse ([1 0 8;0 1 8;8 8 1]);
383 %! [Q, p] = chol (A);
384 %! assert (p != 0);
385 
386 %!error chol ()
387 %!error <matrix must be positive definite> chol ([1, 2; 3, 4])
388 %!error <requires square matrix> chol ([1, 2; 3, 4; 5, 6])
389 %!error <unexpected second or third input> chol (1, 2)
390 */
391 
392 DEFUN_DLD (cholinv, args, ,
393  "-*- texinfo -*-\n\
394 @deftypefn {Loadable Function} {} cholinv (@var{A})\n\
395 Compute the inverse of the symmetric positive definite matrix @var{A} using\n\
396 the Cholesky@tie{}factorization.\n\
397 @seealso{chol, chol2inv, inv}\n\
398 @end deftypefn")
399 {
400  octave_value retval;
401 
402  int nargin = args.length ();
403 
404  if (nargin == 1)
405  {
406  octave_value arg = args(0);
407 
408  octave_idx_type nr = arg.rows ();
409  octave_idx_type nc = arg.columns ();
410 
411  if (nr == 0 || nc == 0)
412  retval = Matrix ();
413  else
414  {
415  if (arg.is_sparse_type ())
416  {
417  octave_idx_type info;
418 
419  if (arg.is_real_type ())
420  {
422 
423  if (! error_state)
424  {
425  SparseCHOL chol (m, info);
426 
427  if (info == 0)
428  retval = chol.inverse ();
429  else
430  error ("cholinv: A must be positive definite");
431  }
432  }
433  else if (arg.is_complex_type ())
434  {
436 
437  if (! error_state)
438  {
439  SparseComplexCHOL chol (m, info);
440 
441  if (info == 0)
442  retval = chol.inverse ();
443  else
444  error ("cholinv: A must be positive definite");
445  }
446  }
447  else
448  gripe_wrong_type_arg ("cholinv", arg);
449  }
450  else if (arg.is_single_type ())
451  {
452  if (arg.is_real_type ())
453  {
454  FloatMatrix m = arg.float_matrix_value ();
455 
456  if (! error_state)
457  {
458  octave_idx_type info;
459  FloatCHOL chol (m, info);
460  if (info == 0)
461  retval = chol.inverse ();
462  else
463  error ("cholinv: A must be positive definite");
464  }
465  }
466  else if (arg.is_complex_type ())
467  {
469 
470  if (! error_state)
471  {
472  octave_idx_type info;
473  FloatComplexCHOL chol (m, info);
474  if (info == 0)
475  retval = chol.inverse ();
476  else
477  error ("cholinv: A must be positive definite");
478  }
479  }
480  else
481  gripe_wrong_type_arg ("chol", arg);
482  }
483  else
484  {
485  if (arg.is_real_type ())
486  {
487  Matrix m = arg.matrix_value ();
488 
489  if (! error_state)
490  {
491  octave_idx_type info;
492  CHOL chol (m, info);
493  if (info == 0)
494  retval = chol.inverse ();
495  else
496  error ("cholinv: A must be positive definite");
497  }
498  }
499  else if (arg.is_complex_type ())
500  {
502 
503  if (! error_state)
504  {
505  octave_idx_type info;
506  ComplexCHOL chol (m, info);
507  if (info == 0)
508  retval = chol.inverse ();
509  else
510  error ("cholinv: A must be positive definite");
511  }
512  }
513  else
514  gripe_wrong_type_arg ("chol", arg);
515  }
516  }
517  }
518  else
519  print_usage ();
520 
521  return retval;
522 }
523 
524 /*
525 %!shared A, Ainv
526 %! A = [2,0.2;0.2,1];
527 %! Ainv = inv (A);
528 %!test
529 %! Ainv1 = cholinv (A);
530 %! assert (norm (Ainv-Ainv1), 0, 1e-10);
531 %!testif HAVE_CHOLMOD
532 %! Ainv2 = inv (sparse (A));
533 %! assert (norm (Ainv-Ainv2), 0, 1e-10);
534 %!testif HAVE_CHOLMOD
535 %! Ainv3 = cholinv (sparse (A));
536 %! assert (norm (Ainv-Ainv3), 0, 1e-10);
537 */
538 
539 DEFUN_DLD (chol2inv, args, ,
540  "-*- texinfo -*-\n\
541 @deftypefn {Loadable Function} {} chol2inv (@var{U})\n\
542 Invert a symmetric, positive definite square matrix from its Cholesky\n\
543 decomposition, @var{U}.\n\
544 \n\
545 Note that @var{U} should be an upper-triangular matrix with positive\n\
546 diagonal elements. @code{chol2inv (@var{U})} provides\n\
547 @code{inv (@var{U}'*@var{U})} but it is much faster than using @code{inv}.\n\
548 @seealso{chol, cholinv, inv}\n\
549 @end deftypefn")
550 {
551  octave_value retval;
552 
553  int nargin = args.length ();
554 
555  if (nargin == 1)
556  {
557  octave_value arg = args(0);
558 
559  octave_idx_type nr = arg.rows ();
560  octave_idx_type nc = arg.columns ();
561 
562  if (nr == 0 || nc == 0)
563  retval = Matrix ();
564  else
565  {
566  if (arg.is_sparse_type ())
567  {
568  if (arg.is_real_type ())
569  {
571 
572  if (! error_state)
573  retval = chol2inv (r);
574  }
575  else if (arg.is_complex_type ())
576  {
578 
579  if (! error_state)
580  retval = chol2inv (r);
581  }
582  else
583  gripe_wrong_type_arg ("chol2inv", arg);
584  }
585  else if (arg.is_single_type ())
586  {
587  if (arg.is_real_type ())
588  {
589  FloatMatrix r = arg.float_matrix_value ();
590 
591  if (! error_state)
592  retval = chol2inv (r);
593  }
594  else if (arg.is_complex_type ())
595  {
597 
598  if (! error_state)
599  retval = chol2inv (r);
600  }
601  else
602  gripe_wrong_type_arg ("chol2inv", arg);
603 
604  }
605  else
606  {
607  if (arg.is_real_type ())
608  {
609  Matrix r = arg.matrix_value ();
610 
611  if (! error_state)
612  retval = chol2inv (r);
613  }
614  else if (arg.is_complex_type ())
615  {
617 
618  if (! error_state)
619  retval = chol2inv (r);
620  }
621  else
622  gripe_wrong_type_arg ("chol2inv", arg);
623  }
624  }
625  }
626  else
627  print_usage ();
628 
629  return retval;
630 }
631 
632 DEFUN_DLD (cholupdate, args, nargout,
633  "-*- texinfo -*-\n\
634 @deftypefn {Loadable Function} {[@var{R1}, @var{info}] =} cholupdate (@var{R}, @var{u}, @var{op})\n\
635 Update or downdate a Cholesky@tie{}factorization.\n\
636 \n\
637 Given an upper triangular matrix @var{R} and a column vector @var{u},\n\
638 attempt to determine another upper triangular matrix @var{R1} such that\n\
639 \n\
640 @itemize @bullet\n\
641 @item\n\
642 @var{R1}'*@var{R1} = @var{R}'*@var{R} + @var{u}*@var{u}'\n\
643 if @var{op} is @qcode{\"+\"}\n\
644 \n\
645 @item\n\
646 @var{R1}'*@var{R1} = @var{R}'*@var{R} - @var{u}*@var{u}'\n\
647 if @var{op} is @qcode{\"-\"}\n\
648 @end itemize\n\
649 \n\
650 If @var{op} is @qcode{\"-\"}, @var{info} is set to\n\
651 \n\
652 @itemize\n\
653 @item 0 if the downdate was successful,\n\
654 \n\
655 @item 1 if @var{R}'*@var{R} - @var{u}*@var{u}' is not positive definite,\n\
656 \n\
657 @item 2 if @var{R} is singular.\n\
658 @end itemize\n\
659 \n\
660 If @var{info} is not present, an error message is printed in cases 1 and 2.\n\
661 @seealso{chol, cholinsert, choldelete, cholshift}\n\
662 @end deftypefn")
663 {
664  octave_idx_type nargin = args.length ();
665 
666  octave_value_list retval;
667 
668  if (nargin > 3 || nargin < 2)
669  {
670  print_usage ();
671  return retval;
672  }
673 
674  octave_value argr = args(0);
675  octave_value argu = args(1);
676 
677  if (argr.is_numeric_type () && argu.is_numeric_type ()
678  && (nargin < 3 || args(2).is_string ()))
679  {
680  octave_idx_type n = argr.rows ();
681 
682  std::string op = (nargin < 3) ? "+" : args(2).string_value ();
683 
684  bool down = op == "-";
685 
686  if (down || op == "+")
687  if (argr.columns () == n && argu.rows () == n && argu.columns () == 1)
688  {
689  int err = 0;
690  if (argr.is_single_type () || argu.is_single_type ())
691  {
692  if (argr.is_real_type () && argu.is_real_type ())
693  {
694  // real case
695  FloatMatrix R = argr.float_matrix_value ();
697 
698  FloatCHOL fact;
699  fact.set (R);
700 
701  if (down)
702  err = fact.downdate (u);
703  else
704  fact.update (u);
705 
706  retval(0) = get_chol_r (fact);
707  }
708  else
709  {
710  // complex case
714 
715  FloatComplexCHOL fact;
716  fact.set (R);
717 
718  if (down)
719  err = fact.downdate (u);
720  else
721  fact.update (u);
722 
723  retval(0) = get_chol_r (fact);
724  }
725  }
726  else
727  {
728  if (argr.is_real_type () && argu.is_real_type ())
729  {
730  // real case
731  Matrix R = argr.matrix_value ();
732  ColumnVector u = argu.column_vector_value ();
733 
734  CHOL fact;
735  fact.set (R);
736 
737  if (down)
738  err = fact.downdate (u);
739  else
740  fact.update (u);
741 
742  retval(0) = get_chol_r (fact);
743  }
744  else
745  {
746  // complex case
749 
750  ComplexCHOL fact;
751  fact.set (R);
752 
753  if (down)
754  err = fact.downdate (u);
755  else
756  fact.update (u);
757 
758  retval(0) = get_chol_r (fact);
759  }
760  }
761 
762  if (nargout > 1)
763  retval(1) = err;
764  else if (err == 1)
765  error ("cholupdate: downdate violates positiveness");
766  else if (err == 2)
767  error ("cholupdate: singular matrix");
768  }
769  else
770  error ("cholupdate: dimension mismatch between R and U");
771  else
772  error ("cholupdate: OP must be \"+\" or \"-\"");
773  }
774  else
775  print_usage ();
776 
777  return retval;
778 }
779 
780 /*
781 %!shared A, u, Ac, uc
782 %! A = [ 0.436997 -0.131721 0.124120 -0.061673 ;
783 %! -0.131721 0.738529 0.019851 -0.140295 ;
784 %! 0.124120 0.019851 0.354879 -0.059472 ;
785 %! -0.061673 -0.140295 -0.059472 0.600939 ];
786 %!
787 %! u = [ 0.98950 ;
788 %! 0.39844 ;
789 %! 0.63484 ;
790 %! 0.13351 ];
791 %! Ac = [ 0.5585528 + 0.0000000i -0.1662088 - 0.0315341i 0.0107873 + 0.0236411i -0.0276775 - 0.0186073i ;
792 %! -0.1662088 + 0.0315341i 0.6760061 + 0.0000000i 0.0011452 - 0.0475528i 0.0145967 + 0.0247641i ;
793 %! 0.0107873 - 0.0236411i 0.0011452 + 0.0475528i 0.6263149 - 0.0000000i -0.1585837 - 0.0719763i ;
794 %! -0.0276775 + 0.0186073i 0.0145967 - 0.0247641i -0.1585837 + 0.0719763i 0.6034234 - 0.0000000i ];
795 %!
796 %! uc = [ 0.54267 + 0.91519i ;
797 %! 0.99647 + 0.43141i ;
798 %! 0.83760 + 0.68977i ;
799 %! 0.39160 + 0.90378i ];
800 
801 %!test
802 %! R = chol (A);
803 %! R1 = cholupdate (R, u);
804 %! assert (norm (triu (R1)-R1, Inf), 0);
805 %! assert (norm (R1'*R1 - R'*R - u*u', Inf) < 1e1*eps);
806 %!
807 %! R1 = cholupdate (R1, u, "-");
808 %! assert (norm (triu (R1)-R1, Inf), 0);
809 %! assert (norm (R1 - R, Inf) < 1e1*eps);
810 
811 %!test
812 %! R = chol (Ac);
813 %! R1 = cholupdate (R, uc);
814 %! assert (norm (triu (R1)-R1, Inf), 0);
815 %! assert (norm (R1'*R1 - R'*R - uc*uc', Inf) < 1e1*eps);
816 %!
817 %! R1 = cholupdate (R1, uc, "-");
818 %! assert (norm (triu (R1)-R1, Inf), 0);
819 %! assert (norm (R1 - R, Inf) < 1e1*eps);
820 
821 %!test
822 %! R = chol (single (A));
823 %! R1 = cholupdate (R, single (u));
824 %! assert (norm (triu (R1)-R1, Inf), single (0));
825 %! assert (norm (R1'*R1 - R'*R - single (u*u'), Inf) < 1e1*eps ("single"));
826 %!
827 %! R1 = cholupdate (R1, single (u), "-");
828 %! assert (norm (triu (R1)-R1, Inf), single (0));
829 %! assert (norm (R1 - R, Inf) < 2e1*eps ("single"));
830 
831 %!test
832 %! R = chol (single (Ac));
833 %! R1 = cholupdate (R, single (uc));
834 %! assert (norm (triu (R1)-R1, Inf), single (0));
835 %! assert (norm (R1'*R1 - R'*R - single (uc*uc'), Inf) < 1e1*eps ("single"));
836 %!
837 %! R1 = cholupdate (R1, single (uc), "-");
838 %! assert (norm (triu (R1)-R1, Inf), single (0));
839 %! assert (norm (R1 - R, Inf) < 2e1*eps ("single"));
840 */
841 
842 DEFUN_DLD (cholinsert, args, nargout,
843  "-*- texinfo -*-\n\
844 @deftypefn {Loadable Function} {@var{R1} =} cholinsert (@var{R}, @var{j}, @var{u})\n\
845 @deftypefnx {Loadable Function} {[@var{R1}, @var{info}] =} cholinsert (@var{R}, @var{j}, @var{u})\n\
846 Given a Cholesky@tie{}factorization of a real symmetric or complex Hermitian\n\
847 positive definite matrix @w{@var{A} = @var{R}'*@var{R}}, @var{R}@tie{}upper\n\
848 triangular, return the Cholesky@tie{}factorization of\n\
849 @var{A1}, where @w{A1(p,p) = A}, @w{A1(:,j) = A1(j,:)' = u} and\n\
850 @w{p = [1:j-1,j+1:n+1]}. @w{u(j)} should be positive.\n\
851 \n\
852 On return, @var{info} is set to\n\
853 \n\
854 @itemize\n\
855 @item 0 if the insertion was successful,\n\
856 \n\
857 @item 1 if @var{A1} is not positive definite,\n\
858 \n\
859 @item 2 if @var{R} is singular.\n\
860 @end itemize\n\
861 \n\
862 If @var{info} is not present, an error message is printed in cases 1 and 2.\n\
863 @seealso{chol, cholupdate, choldelete, cholshift}\n\
864 @end deftypefn")
865 {
866  octave_idx_type nargin = args.length ();
867 
868  octave_value_list retval;
869 
870  if (nargin != 3)
871  {
872  print_usage ();
873  return retval;
874  }
875 
876  octave_value argr = args(0);
877  octave_value argj = args(1);
878  octave_value argu = args(2);
879 
880  if (argr.is_numeric_type () && argu.is_numeric_type ()
881  && argj.is_real_scalar ())
882  {
883  octave_idx_type n = argr.rows ();
884  octave_idx_type j = argj.scalar_value ();
885 
886  if (argr.columns () == n && argu.rows () == n+1 && argu.columns () == 1)
887  {
888  if (j > 0 && j <= n+1)
889  {
890  int err = 0;
891  if (argr.is_single_type () || argu.is_single_type ())
892  {
893  if (argr.is_real_type () && argu.is_real_type ())
894  {
895  // real case
896  FloatMatrix R = argr.float_matrix_value ();
898 
899  FloatCHOL fact;
900  fact.set (R);
901  err = fact.insert_sym (u, j-1);
902 
903  retval(0) = get_chol_r (fact);
904  }
905  else
906  {
907  // complex case
911 
912  FloatComplexCHOL fact;
913  fact.set (R);
914  err = fact.insert_sym (u, j-1);
915 
916  retval(0) = get_chol_r (fact);
917  }
918  }
919  else
920  {
921  if (argr.is_real_type () && argu.is_real_type ())
922  {
923  // real case
924  Matrix R = argr.matrix_value ();
925  ColumnVector u = argu.column_vector_value ();
926 
927  CHOL fact;
928  fact.set (R);
929  err = fact.insert_sym (u, j-1);
930 
931  retval(0) = get_chol_r (fact);
932  }
933  else
934  {
935  // complex case
939 
940  ComplexCHOL fact;
941  fact.set (R);
942  err = fact.insert_sym (u, j-1);
943 
944  retval(0) = get_chol_r (fact);
945  }
946  }
947 
948  if (nargout > 1)
949  retval(1) = err;
950  else if (err == 1)
951  error ("cholinsert: insertion violates positiveness");
952  else if (err == 2)
953  error ("cholinsert: singular matrix");
954  else if (err == 3)
955  error ("cholinsert: diagonal element must be real");
956  }
957  else
958  error ("cholinsert: index J out of range");
959  }
960  else
961  error ("cholinsert: dimension mismatch between R and U");
962  }
963  else
964  print_usage ();
965 
966  return retval;
967 }
968 
969 /*
970 %!test
971 %! u2 = [ 0.35080 ;
972 %! 0.63930 ;
973 %! 3.31057 ;
974 %! -0.13825 ;
975 %! 0.45266 ];
976 %!
977 %! R = chol (A);
978 %!
979 %! j = 3; p = [1:j-1, j+1:5];
980 %! R1 = cholinsert (R, j, u2);
981 %! A1 = R1'*R1;
982 %!
983 %! assert (norm (triu (R1)-R1, Inf), 0);
984 %! assert (norm (A1(p,p) - A, Inf) < 1e1*eps);
985 
986 %!test
987 %! u2 = [ 0.35080 + 0.04298i;
988 %! 0.63930 + 0.23778i;
989 %! 3.31057 + 0.00000i;
990 %! -0.13825 + 0.19879i;
991 %! 0.45266 + 0.50020i];
992 %!
993 %! R = chol (Ac);
994 %!
995 %! j = 3; p = [1:j-1, j+1:5];
996 %! R1 = cholinsert (R, j, u2);
997 %! A1 = R1'*R1;
998 %!
999 %! assert (norm (triu (R1)-R1, Inf), 0);
1000 %! assert (norm (A1(p,p) - Ac, Inf) < 1e1*eps);
1001 
1002 %!test
1003 %! u2 = single ([ 0.35080 ;
1004 %! 0.63930 ;
1005 %! 3.31057 ;
1006 %! -0.13825 ;
1007 %! 0.45266 ]);
1008 %!
1009 %! R = chol (single (A));
1010 %!
1011 %! j = 3; p = [1:j-1, j+1:5];
1012 %! R1 = cholinsert (R, j, u2);
1013 %! A1 = R1'*R1;
1014 %!
1015 %! assert (norm (triu (R1)-R1, Inf), single (0));
1016 %! assert (norm (A1(p,p) - A, Inf) < 1e1*eps ("single"));
1017 
1018 %!test
1019 %! u2 = single ([ 0.35080 + 0.04298i;
1020 %! 0.63930 + 0.23778i;
1021 %! 3.31057 + 0.00000i;
1022 %! -0.13825 + 0.19879i;
1023 %! 0.45266 + 0.50020i]);
1024 %!
1025 %! R = chol (single (Ac));
1026 %!
1027 %! j = 3; p = [1:j-1, j+1:5];
1028 %! R1 = cholinsert (R, j, u2);
1029 %! A1 = R1'*R1;
1030 %!
1031 %! assert (norm (triu (R1)-R1, Inf), single (0));
1032 %! assert (norm (A1(p,p) - single (Ac), Inf) < 2e1*eps ("single"));
1033 
1034 %!test
1035 %! cu = chol (triu (A), "upper");
1036 %! cl = chol (tril (A), "lower");
1037 %! assert (cu, cl', eps);
1038 
1039 %!test
1040 %! cca = chol (Ac);
1041 %!
1042 %! ccal = chol (Ac, "lower");
1043 %! ccal2 = chol (tril (Ac), "lower");
1044 %!
1045 %! ccau = chol (Ac, "upper");
1046 %! ccau2 = chol (triu (Ac), "upper");
1047 %!
1048 %! assert (cca'*cca, Ac, eps);
1049 %! assert (ccau'*ccau, Ac, eps);
1050 %! assert (ccau2'*ccau2, Ac, eps);
1051 %!
1052 %! assert (cca, ccal', eps);
1053 %! assert (cca, ccau, eps);
1054 %! assert (cca, ccal2', eps);
1055 %! assert (cca, ccau2, eps);
1056 
1057 %!test
1058 %! cca = chol (single (Ac));
1059 %!
1060 %! ccal = chol (single (Ac), "lower");
1061 %! ccal2 = chol (tril (single (Ac)), "lower");
1062 %!
1063 %! ccau = chol (single (Ac), "upper");
1064 %! ccau2 = chol (triu (single (Ac)), "upper");
1065 %!
1066 %! assert (cca'*cca, single (Ac), eps ("single"));
1067 %! assert (ccau'*ccau, single (Ac), eps ("single"));
1068 %! assert (ccau2'*ccau2, single (Ac), eps ("single"));
1069 %!
1070 %! assert (cca, ccal', eps ("single"));
1071 %! assert (cca, ccau, eps ("single"));
1072 %! assert (cca, ccal2', eps ("single"));
1073 %! assert (cca, ccau2, eps ("single"));
1074 
1075 %!test
1076 %! a = [12, 2, 3, 4;
1077 %! 2, 14, 5, 3;
1078 %! 3, 5, 16, 6;
1079 %! 4, 3, 6, 16];
1080 %!
1081 %! b = [0, 1, 2, 3;
1082 %! -1, 0, 1, 2;
1083 %! -2, -1, 0, 1;
1084 %! -3, -2, -1, 0];
1085 %!
1086 %! ca = a + i*b;
1087 %!
1088 %! cca = chol (ca);
1089 %!
1090 %! ccal = chol (ca, "lower");
1091 %! ccal2 = chol (tril (ca), "lower");
1092 %!
1093 %! ccau = chol (ca, "upper");
1094 %! ccau2 = chol (triu (ca), "upper");
1095 %!
1096 %! assert (cca'*cca, ca, 16*eps);
1097 %! assert (ccau'*ccau, ca, 16*eps);
1098 %! assert (ccau2'*ccau2, ca, 16*eps);
1099 %!
1100 %! assert (cca, ccal', 16*eps);
1101 %! assert (cca, ccau, 16*eps);
1102 %! assert (cca, ccal2', 16*eps);
1103 %! assert (cca, ccau2, 16*eps);
1104 */
1105 
1106 DEFUN_DLD (choldelete, args, ,
1107  "-*- texinfo -*-\n\
1108 @deftypefn {Loadable Function} {@var{R1} =} choldelete (@var{R}, @var{j})\n\
1109 Given a Cholesky@tie{}factorization of a real symmetric or complex Hermitian\n\
1110 positive definite matrix @w{@var{A} = @var{R}'*@var{R}}, @var{R}@tie{}upper\n\
1111 triangular, return the Cholesky@tie{}factorization of @w{A(p,p)}, where\n\
1112 @w{p = [1:j-1,j+1:n+1]}.\n\
1113 @seealso{chol, cholupdate, cholinsert, cholshift}\n\
1114 @end deftypefn")
1115 {
1116  octave_idx_type nargin = args.length ();
1117 
1118  octave_value_list retval;
1119 
1120  if (nargin != 2)
1121  {
1122  print_usage ();
1123  return retval;
1124  }
1125 
1126  octave_value argr = args(0);
1127  octave_value argj = args(1);
1128 
1129  if (argr.is_numeric_type () && argj.is_real_scalar ())
1130  {
1131  octave_idx_type n = argr.rows ();
1132  octave_idx_type j = argj.scalar_value ();
1133 
1134  if (argr.columns () == n)
1135  {
1136  if (j > 0 && j <= n)
1137  {
1138  if (argr.is_single_type ())
1139  {
1140  if (argr.is_real_type ())
1141  {
1142  // real case
1143  FloatMatrix R = argr.float_matrix_value ();
1144 
1145  FloatCHOL fact;
1146  fact.set (R);
1147  fact.delete_sym (j-1);
1148 
1149  retval(0) = get_chol_r (fact);
1150  }
1151  else
1152  {
1153  // complex case
1155 
1156  FloatComplexCHOL fact;
1157  fact.set (R);
1158  fact.delete_sym (j-1);
1159 
1160  retval(0) = get_chol_r (fact);
1161  }
1162  }
1163  else
1164  {
1165  if (argr.is_real_type ())
1166  {
1167  // real case
1168  Matrix R = argr.matrix_value ();
1169 
1170  CHOL fact;
1171  fact.set (R);
1172  fact.delete_sym (j-1);
1173 
1174  retval(0) = get_chol_r (fact);
1175  }
1176  else
1177  {
1178  // complex case
1179  ComplexMatrix R = argr.complex_matrix_value ();
1180 
1181  ComplexCHOL fact;
1182  fact.set (R);
1183  fact.delete_sym (j-1);
1184 
1185  retval(0) = get_chol_r (fact);
1186  }
1187  }
1188  }
1189  else
1190  error ("choldelete: index J out of range");
1191  }
1192  else
1193  error ("choldelete: matrix R must be square");
1194  }
1195  else
1196  print_usage ();
1197 
1198  return retval;
1199 }
1200 
1201 /*
1202 %!test
1203 %! R = chol (A);
1204 %!
1205 %! j = 3; p = [1:j-1,j+1:4];
1206 %! R1 = choldelete (R, j);
1207 %!
1208 %! assert (norm (triu (R1)-R1, Inf), 0);
1209 %! assert (norm (R1'*R1 - A(p,p), Inf) < 1e1*eps);
1210 
1211 %!test
1212 %! R = chol (Ac);
1213 %!
1214 %! j = 3; p = [1:j-1,j+1:4];
1215 %! R1 = choldelete (R, j);
1216 %!
1217 %! assert (norm (triu (R1)-R1, Inf), 0);
1218 %! assert (norm (R1'*R1 - Ac(p,p), Inf) < 1e1*eps);
1219 
1220 %!test
1221 %! R = chol (single (A));
1222 %!
1223 %! j = 3; p = [1:j-1,j+1:4];
1224 %! R1 = choldelete (R, j);
1225 %!
1226 %! assert (norm (triu (R1)-R1, Inf), single (0));
1227 %! assert (norm (R1'*R1 - single (A(p,p)), Inf) < 1e1*eps ("single"));
1228 
1229 %!test
1230 %! R = chol (single (Ac));
1231 %!
1232 %! j = 3; p = [1:j-1,j+1:4];
1233 %! R1 = choldelete (R,j);
1234 %!
1235 %! assert (norm (triu (R1)-R1, Inf), single (0));
1236 %! assert (norm (R1'*R1 - single (Ac(p,p)), Inf) < 1e1*eps ("single"));
1237 */
1238 
1239 DEFUN_DLD (cholshift, args, ,
1240  "-*- texinfo -*-\n\
1241 @deftypefn {Loadable Function} {@var{R1} =} cholshift (@var{R}, @var{i}, @var{j})\n\
1242 Given a Cholesky@tie{}factorization of a real symmetric or complex Hermitian\n\
1243 positive definite matrix @w{@var{A} = @var{R}'*@var{R}}, @var{R}@tie{}upper\n\
1244 triangular, return the Cholesky@tie{}factorization of\n\
1245 @w{@var{A}(p,p)}, where @w{p} is the permutation @*\n\
1246 @code{p = [1:i-1, shift(i:j, 1), j+1:n]} if @w{@var{i} < @var{j}} @*\n\
1247  or @*\n\
1248 @code{p = [1:j-1, shift(j:i,-1), i+1:n]} if @w{@var{j} < @var{i}}. @*\n\
1249 \n\
1250 @seealso{chol, cholupdate, cholinsert, choldelete}\n\
1251 @end deftypefn")
1252 {
1253  octave_idx_type nargin = args.length ();
1254 
1255  octave_value_list retval;
1256 
1257  if (nargin != 3)
1258  {
1259  print_usage ();
1260  return retval;
1261  }
1262 
1263  octave_value argr = args(0);
1264  octave_value argi = args(1);
1265  octave_value argj = args(2);
1266 
1267  if (argr.is_numeric_type ()
1268  && argi.is_real_scalar () && argj.is_real_scalar ())
1269  {
1270  octave_idx_type n = argr.rows ();
1271  octave_idx_type i = argi.scalar_value ();
1272  octave_idx_type j = argj.scalar_value ();
1273 
1274  if (argr.columns () == n)
1275  {
1276  if (j > 0 && j <= n+1 && i > 0 && i <= n+1)
1277  {
1278 
1279  if (argr.is_single_type () && argi.is_single_type ()
1280  && argj.is_single_type ())
1281  {
1282  if (argr.is_real_type ())
1283  {
1284  // real case
1285  FloatMatrix R = argr.float_matrix_value ();
1286 
1287  FloatCHOL fact;
1288  fact.set (R);
1289  fact.shift_sym (i-1, j-1);
1290 
1291  retval(0) = get_chol_r (fact);
1292  }
1293  else
1294  {
1295  // complex case
1297 
1298  FloatComplexCHOL fact;
1299  fact.set (R);
1300  fact.shift_sym (i-1, j-1);
1301 
1302  retval(0) = get_chol_r (fact);
1303  }
1304  }
1305  else
1306  {
1307  if (argr.is_real_type ())
1308  {
1309  // real case
1310  Matrix R = argr.matrix_value ();
1311 
1312  CHOL fact;
1313  fact.set (R);
1314  fact.shift_sym (i-1, j-1);
1315 
1316  retval(0) = get_chol_r (fact);
1317  }
1318  else
1319  {
1320  // complex case
1321  ComplexMatrix R = argr.complex_matrix_value ();
1322 
1323  ComplexCHOL fact;
1324  fact.set (R);
1325  fact.shift_sym (i-1, j-1);
1326 
1327  retval(0) = get_chol_r (fact);
1328  }
1329  }
1330  }
1331  else
1332  error ("cholshift: index I or J is out of range");
1333  }
1334  else
1335  error ("cholshift: R must be a square matrix");
1336  }
1337  else
1338  print_usage ();
1339 
1340  return retval;
1341 }
1342 
1343 /*
1344 %!test
1345 %! R = chol (A);
1346 %!
1347 %! i = 1; j = 3; p = [1:i-1, shift(i:j,-1), j+1:4];
1348 %! R1 = cholshift (R, i, j);
1349 %!
1350 %! assert (norm (triu (R1)-R1, Inf), 0);
1351 %! assert (norm (R1'*R1 - A(p,p), Inf) < 1e1*eps);
1352 %!
1353 %! j = 1; i = 3; p = [1:j-1, shift(j:i,+1), i+1:4];
1354 %! R1 = cholshift (R, i, j);
1355 %!
1356 %! assert (norm (triu (R1) - R1, Inf), 0);
1357 %! assert (norm (R1'*R1 - A(p,p), Inf) < 1e1*eps);
1358 
1359 %!test
1360 %! R = chol (Ac);
1361 %!
1362 %! i = 1; j = 3; p = [1:i-1, shift(i:j,-1), j+1:4];
1363 %! R1 = cholshift (R, i, j);
1364 %!
1365 %! assert (norm (triu (R1)-R1, Inf), 0);
1366 %! assert (norm (R1'*R1 - Ac(p,p), Inf) < 1e1*eps);
1367 %!
1368 %! j = 1; i = 3; p = [1:j-1, shift(j:i,+1), i+1:4];
1369 %! R1 = cholshift (R, i, j);
1370 %!
1371 %! assert (norm (triu (R1)-R1, Inf), 0);
1372 %! assert (norm (R1'*R1 - Ac(p,p), Inf) < 1e1*eps);
1373 
1374 %!test
1375 %! R = chol (single (A));
1376 %!
1377 %! i = 1; j = 3; p = [1:i-1, shift(i:j,-1), j+1:4];
1378 %! R1 = cholshift (R, i, j);
1379 %!
1380 %! assert (norm (triu (R1)-R1, Inf), 0);
1381 %! assert (norm (R1'*R1 - single (A(p,p)), Inf) < 1e1*eps ("single"));
1382 %!
1383 %! j = 1; i = 3; p = [1:j-1, shift(j:i,+1), i+1:4];
1384 %! R1 = cholshift (R, i, j);
1385 %!
1386 %! assert (norm (triu (R1)-R1, Inf), 0);
1387 %! assert (norm (R1'*R1 - single (A(p,p)), Inf) < 1e1*eps ("single"));
1388 
1389 %!test
1390 %! R = chol (single (Ac));
1391 %!
1392 %! i = 1; j = 3; p = [1:i-1, shift(i:j,-1), j+1:4];
1393 %! R1 = cholshift (R, i, j);
1394 %!
1395 %! assert (norm (triu (R1)-R1, Inf), 0);
1396 %! assert (norm (R1'*R1 - single (Ac(p,p)), Inf) < 1e1*eps ("single"));
1397 %!
1398 %! j = 1; i = 3; p = [1:j-1, shift(j:i,+1), i+1:4];
1399 %! R1 = cholshift (R, i, j);
1400 %!
1401 %! assert (norm (triu (R1)-R1, Inf), 0);
1402 %! assert (norm (R1'*R1 - single (Ac(p,p)), Inf) < 1e1*eps ("single"));
1403 */
FloatComplexMatrix transpose(void) const
Definition: fCMatrix.h:156
ColumnVector column_vector_value(bool frc_str_conv=false, bool frc_vec_conv=false) const
Definition: ov.cc:1658
void shift_sym(octave_idx_type i, octave_idx_type j)
Definition: dbleCHOL.cc:288
ColumnVector perm(void) const
bool is_real_type(void) const
Definition: ov.h:651
void gripe_wrong_type_arg(const char *name, const char *s, bool is_error)
Definition: gripes.cc:135
SparseMatrix inverse(void) const
octave_idx_type insert_sym(const FloatComplexColumnVector &u, octave_idx_type j)
Definition: fCmplxCHOL.cc:239
octave_idx_type rows(void) const
Definition: ov.h:473
octave_idx_type downdate(const ColumnVector &u)
Definition: dbleCHOL.cc:222
FloatComplexMatrix float_complex_matrix_value(bool frc_str_conv=false) const
Definition: ov.h:795
FloatColumnVector float_column_vector_value(bool frc_str_conv=false, bool frc_vec_conv=false) const
Definition: ov.cc:1869
OCTINTERP_API void print_usage(void)
Definition: defun.cc:51
octave_idx_type downdate(const FloatComplexColumnVector &u)
Definition: fCmplxCHOL.cc:217
octave_idx_type length(void) const
Definition: oct-obj.h:89
ComplexMatrix inverse(void) const
Definition: CmplxCHOL.cc:182
FloatMatrix transpose(void) const
Definition: fMatrix.h:118
void update(const ColumnVector &u)
Definition: dbleCHOL.cc:204
bool is_numeric_type(void) const
Definition: ov.h:663
void update(const ComplexColumnVector &u)
Definition: CmplxCHOL.cc:199
void shift_sym(octave_idx_type i, octave_idx_type j)
Definition: floatCHOL.cc:288
void delete_sym(octave_idx_type j)
Definition: CmplxCHOL.cc:265
void error(const char *fmt,...)
Definition: error.cc:476
SparseMatrix R(void) const
static octave_value get_chol_r(const CHOLT &fact)
Definition: chol.cc:49
int empty_arg(const char *, octave_idx_type nr, octave_idx_type nc)
Definition: utils.cc:246
octave_idx_type downdate(const ComplexColumnVector &u)
Definition: CmplxCHOL.cc:217
double scalar_value(bool frc_str_conv=false) const
Definition: ov.h:765
SparseComplexMatrix inverse(void) const
FloatComplexMatrix inverse(void) const
Definition: fCmplxCHOL.cc:182
void delete_sym(octave_idx_type j)
Definition: dbleCHOL.cc:270
octave_idx_type insert_sym(const ColumnVector &u, octave_idx_type j)
Definition: dbleCHOL.cc:244
static octave_value get_chol_l(const CHOLT &fact)
Definition: chol.cc:57
SparseMatrix Q(void) const
octave_idx_type columns(void) const
Definition: ov.h:475
ComplexMatrix chol2inv(const ComplexMatrix &r)
Definition: CmplxCHOL.cc:443
void update(const FloatColumnVector &u)
Definition: floatCHOL.cc:204
bool is_sparse_type(void) const
Definition: ov.h:666
octave_idx_type downdate(const FloatColumnVector &u)
Definition: floatCHOL.cc:222
bool is_real_scalar(void) const
Definition: ov.h:535
void set(const ComplexMatrix &R)
Definition: CmplxCHOL.cc:188
SparseComplexMatrix R(void) const
octave_idx_type insert_sym(const FloatColumnVector &u, octave_idx_type j)
Definition: floatCHOL.cc:244
int error_state
Definition: error.cc:101
void shift_sym(octave_idx_type i, octave_idx_type j)
Definition: fCmplxCHOL.cc:284
bool is_complex_type(void) const
Definition: ov.h:654
Matrix inverse(void) const
Definition: dbleCHOL.cc:187
Matrix transpose(void) const
Definition: dMatrix.h:114
octave_idx_type insert_sym(const ComplexColumnVector &u, octave_idx_type j)
Definition: CmplxCHOL.cc:239
SparseMatrix L(void) const
octave_idx_type length(void) const
Definition: ov.cc:1525
Definition: dMatrix.h:35
ComplexMatrix transpose(void) const
Definition: CMatrix.h:151
SparseComplexMatrix sparse_complex_matrix_value(bool frc_str_conv=false) const
Definition: ov.h:824
Matrix matrix_value(bool frc_str_conv=false) const
Definition: ov.h:773
double arg(double x)
Definition: lo-mappers.h:37
SparseComplexMatrix L(void) const
ComplexMatrix complex_matrix_value(bool frc_str_conv=false) const
Definition: ov.h:791
Definition: dbleCHOL.h:32
FloatMatrix inverse(void) const
Definition: floatCHOL.cc:187
void delete_sym(octave_idx_type j)
Definition: floatCHOL.cc:270
FloatComplexColumnVector float_complex_column_vector_value(bool frc_str_conv=false, bool frc_vec_conv=false) const
Definition: ov.cc:1877
ColumnVector perm(void) const
FloatMatrix float_matrix_value(bool frc_str_conv=false) const
Definition: ov.h:776
void set(const FloatMatrix &R)
Definition: floatCHOL.cc:193
void set(const FloatComplexMatrix &R)
Definition: fCmplxCHOL.cc:188
ComplexColumnVector complex_column_vector_value(bool frc_str_conv=false, bool frc_vec_conv=false) const
Definition: ov.cc:1666
#define DEFUN_DLD(name, args_name, nargout_name, doc)
Definition: defun-dld.h:59
SparseMatrix sparse_matrix_value(bool frc_str_conv=false) const
Definition: ov.h:820
bool is_single_type(void) const
Definition: ov.h:611
void update(const FloatComplexColumnVector &u)
Definition: fCmplxCHOL.cc:199
void shift_sym(octave_idx_type i, octave_idx_type j)
Definition: CmplxCHOL.cc:283
void delete_sym(octave_idx_type j)
Definition: fCmplxCHOL.cc:266
void set(const Matrix &R)
Definition: dbleCHOL.cc:193
return octave_value(v1.char_array_value().concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string())? '\'': '"'))
SparseMatrix Q(void) const