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
matrix_type.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2005-2015 David Bateman
4 
5 This file is part of Octave.
6 
7 Octave is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #ifdef HAVE_CONFIG_H
24 #include <config.h>
25 #endif
26 
27 #include <algorithm>
28 
29 #include "ov.h"
30 #include "defun.h"
31 #include "error.h"
32 #include "ov-re-mat.h"
33 #include "ov-cx-mat.h"
34 #include "ov-re-sparse.h"
35 #include "ov-cx-sparse.h"
36 #include "MatrixType.h"
37 #include "oct-locbuf.h"
38 
39 DEFUN (matrix_type, args, ,
40  "-*- texinfo -*-\n\
41 @deftypefn {Built-in Function} {@var{type} =} matrix_type (@var{A})\n\
42 @deftypefnx {Built-in Function} {@var{type} =} matrix_type (@var{A}, \"nocompute\")\n\
43 @deftypefnx {Built-in Function} {@var{A} =} matrix_type (@var{A}, @var{type})\n\
44 @deftypefnx {Built-in Function} {@var{A} =} matrix_type (@var{A}, \"upper\", @var{perm})\n\
45 @deftypefnx {Built-in Function} {@var{A} =} matrix_type (@var{A}, \"lower\", @var{perm})\n\
46 @deftypefnx {Built-in Function} {@var{A} =} matrix_type (@var{A}, \"banded\", @var{nl}, @var{nu})\n\
47 Identify the matrix type or mark a matrix as a particular type.\n\
48 \n\
49 This allows more rapid solutions of linear equations involving @var{A} to be\n\
50 performed.\n\
51 \n\
52 Called with a single argument, @code{matrix_type} returns the type of the\n\
53 matrix and caches it for future use.\n\
54 \n\
55 Called with more than one argument, @code{matrix_type} allows the type of\n\
56 the matrix to be defined.\n\
57 \n\
58 If the option @qcode{\"nocompute\"} is given, the function will not attempt\n\
59 to guess the type if it is still unknown. This is useful for debugging\n\
60 purposes.\n\
61 \n\
62 The possible matrix types depend on whether the matrix is full or sparse, and\n\
63 can be one of the following\n\
64 \n\
65 @table @asis\n\
66 @item @qcode{\"unknown\"}\n\
67 Remove any previously cached matrix type, and mark type as unknown.\n\
68 \n\
69 @item @qcode{\"full\"}\n\
70 Mark the matrix as full.\n\
71 \n\
72 @item @qcode{\"positive definite\"}\n\
73 Probable full positive definite matrix.\n\
74 \n\
75 @item @qcode{\"diagonal\"}\n\
76 Diagonal matrix. (Sparse matrices only)\n\
77 \n\
78 @item @qcode{\"permuted diagonal\"}\n\
79 Permuted Diagonal matrix. The permutation does not need to be specifically\n\
80 indicated, as the structure of the matrix explicitly gives this. (Sparse\n\
81 matrices only)\n\
82 \n\
83 @item @qcode{\"upper\"}\n\
84 Upper triangular. If the optional third argument @var{perm} is given, the\n\
85 matrix is assumed to be a permuted upper triangular with the permutations\n\
86 defined by the vector @var{perm}.\n\
87 \n\
88 @item @qcode{\"lower\"}\n\
89 Lower triangular. If the optional third argument @var{perm} is given, the\n\
90 matrix is assumed to be a permuted lower triangular with the permutations\n\
91 defined by the vector @var{perm}.\n\
92 \n\
93 @item @qcode{\"banded\"}\n\
94 @itemx @qcode{\"banded positive definite\"}\n\
95 Banded matrix with the band size of @var{nl} below the diagonal and @var{nu}\n\
96 above it. If @var{nl} and @var{nu} are 1, then the matrix is tridiagonal and\n\
97 treated with specialized code. In addition the matrix can be marked as\n\
98 probably a positive definite. (Sparse matrices only)\n\
99 \n\
100 @item @qcode{\"singular\"}\n\
101 The matrix is assumed to be singular and will be treated with a minimum norm\n\
102 solution.\n\
103 \n\
104 @end table\n\
105 \n\
106 Note that the matrix type will be discovered automatically on the first\n\
107 attempt to solve a linear equation involving @var{A}. Therefore\n\
108 @code{matrix_type} is only useful to give Octave hints of the matrix type.\n\
109 Incorrectly defining the matrix type will result in incorrect results from\n\
110 solutions of linear equations; it is entirely @strong{the responsibility of\n\
111 the user} to correctly identify the matrix type.\n\
112 \n\
113 Also, the test for positive definiteness is a low-cost test for a Hermitian\n\
114 matrix with a real positive diagonal. This does not guarantee that the\n\
115 matrix is positive definite, but only that it is a probable candidate. When\n\
116 such a matrix is factorized, a Cholesky@tie{}factorization is first\n\
117 attempted, and if that fails the matrix is then treated with an\n\
118 LU@tie{}factorization. Once the matrix has been factorized,\n\
119 @code{matrix_type} will return the correct classification of the matrix.\n\
120 @end deftypefn")
121 {
122  int nargin = args.length ();
123  octave_value retval;
124 
125  if (nargin == 0)
126  print_usage ();
127  else if (nargin > 4)
128  error ("matrix_type: incorrect number of arguments");
129  else
130  {
131  bool autocomp = true;
132  if (nargin == 2 && args(1).is_string ()
133  && args(1).string_value () == "nocompute")
134  {
135  nargin = 1;
136  autocomp = false;
137  }
138 
139  if (args(0).is_scalar_type ())
140  {
141  if (nargin == 1)
142  retval = octave_value ("Diagonal");
143  else
144  retval = args(0);
145  }
146  else if (args(0).is_sparse_type ())
147  {
148  if (nargin == 1)
149  {
150  MatrixType mattyp;
151 
152  if (args(0).is_complex_type ())
153  {
154  mattyp = args(0).matrix_type ();
155 
156  if (mattyp.is_unknown () && autocomp)
157  {
159  args(0).sparse_complex_matrix_value ();
160  if (!error_state)
161  {
162  mattyp = MatrixType (m);
163  args(0).matrix_type (mattyp);
164  }
165  }
166  }
167  else
168  {
169  mattyp = args(0).matrix_type ();
170 
171  if (mattyp.is_unknown () && autocomp)
172  {
173  SparseMatrix m = args(0).sparse_matrix_value ();
174  if (!error_state)
175  {
176  mattyp = MatrixType (m);
177  args(0).matrix_type (mattyp);
178  }
179  }
180  }
181 
182  int typ = mattyp.type ();
183 
184  if (typ == MatrixType::Diagonal)
185  retval = octave_value ("Diagonal");
186  else if (typ == MatrixType::Permuted_Diagonal)
187  retval = octave_value ("Permuted Diagonal");
188  else if (typ == MatrixType::Upper)
189  retval = octave_value ("Upper");
190  else if (typ == MatrixType::Permuted_Upper)
191  retval = octave_value ("Permuted Upper");
192  else if (typ == MatrixType::Lower)
193  retval = octave_value ("Lower");
194  else if (typ == MatrixType::Permuted_Lower)
195  retval = octave_value ("Permuted Lower");
196  else if (typ == MatrixType::Banded)
197  retval = octave_value ("Banded");
198  else if (typ == MatrixType::Banded_Hermitian)
199  retval = octave_value ("Banded Positive Definite");
200  else if (typ == MatrixType::Tridiagonal)
201  retval = octave_value ("Tridiagonal");
202  else if (typ == MatrixType::Tridiagonal_Hermitian)
203  retval = octave_value ("Tridiagonal Positive Definite");
204  else if (typ == MatrixType::Hermitian)
205  retval = octave_value ("Positive Definite");
206  else if (typ == MatrixType::Rectangular)
207  {
208  if (args(0).rows () == args(0).columns ())
209  retval = octave_value ("Singular");
210  else
211  retval = octave_value ("Rectangular");
212  }
213  else if (typ == MatrixType::Full)
214  retval = octave_value ("Full");
215  else
216  retval = octave_value ("Unknown");
217  }
218  else
219  {
220  // Ok, we're changing the matrix type
221  if (! args(1).is_string ())
222  error ("matrix_type: TYPE must be a string");
223  else
224  {
225  std::string str_typ = args(1).string_value ();
226 
227  // FIXME: why do I have to explicitly call the constructor?
228  MatrixType mattyp = MatrixType ();
229 
230  octave_idx_type nl = 0;
231  octave_idx_type nu = 0;
232 
233  // Use STL function to convert to lower case
234  std::transform (str_typ.begin (), str_typ.end (),
235  str_typ.begin (), tolower);
236 
237  if (str_typ == "diagonal")
238  mattyp.mark_as_diagonal ();
239  if (str_typ == "permuted diagonal")
240  mattyp.mark_as_permuted_diagonal ();
241  else if (str_typ == "upper")
242  mattyp.mark_as_upper_triangular ();
243  else if (str_typ == "lower")
244  mattyp.mark_as_lower_triangular ();
245  else if (str_typ == "banded"
246  || str_typ == "banded positive definite")
247  {
248  if (nargin != 4)
249  error ("matrix_type: banded matrix type requires 4 arguments");
250  else
251  {
252  nl = args(2).nint_value ();
253  nu = args(3).nint_value ();
254 
255  if (error_state)
256  error ("matrix_type: band size NL, NU must be integers");
257  else
258  {
259  if (nl == 1 && nu == 1)
260  mattyp.mark_as_tridiagonal ();
261  else
262  mattyp.mark_as_banded (nu, nl);
263 
264  if (str_typ == "banded positive definite")
265  mattyp.mark_as_symmetric ();
266  }
267  }
268  }
269  else if (str_typ == "positive definite")
270  {
271  mattyp.mark_as_full ();
272  mattyp.mark_as_symmetric ();
273  }
274  else if (str_typ == "singular")
275  mattyp.mark_as_rectangular ();
276  else if (str_typ == "full")
277  mattyp.mark_as_full ();
278  else if (str_typ == "unknown")
279  mattyp.invalidate_type ();
280  else
281  error ("matrix_type: Unknown matrix type %s", str_typ.c_str ());
282 
283  if (! error_state)
284  {
285  if (nargin == 3
286  && (str_typ == "upper" || str_typ == "lower"))
287  {
288  const ColumnVector perm =
289  ColumnVector (args(2).vector_value ());
290 
291  if (error_state)
292  error ("matrix_type: Invalid permutation vector PERM");
293  else
294  {
295  octave_idx_type len = perm.length ();
296  dim_vector dv = args(0).dims ();
297 
298  if (len != dv(0))
299  error ("matrix_type: Invalid permutation vector PERM");
300  else
301  {
303 
304  for (octave_idx_type i = 0; i < len; i++)
305  p[i] = static_cast<octave_idx_type>
306  (perm (i))
307  - 1;
308 
309  if (str_typ == "upper")
310  mattyp.mark_as_permuted (len, p);
311  else
312  mattyp.mark_as_permuted (len, p);
313  }
314  }
315  }
316  else if (nargin != 2
317  && str_typ != "banded positive definite"
318  && str_typ != "banded")
319  error ("matrix_type: Invalid number of arguments");
320 
321  if (! error_state)
322  {
323  // Set the matrix type
324  if (args(0).is_complex_type ())
325  retval =
326  octave_value (args(0).sparse_complex_matrix_value (),
327  mattyp);
328  else
329  retval
330  = octave_value (args(0).sparse_matrix_value (),
331  mattyp);
332  }
333  }
334  }
335  }
336  }
337  else
338  {
339  if (nargin == 1)
340  {
341  MatrixType mattyp;
342 
343  if (args(0).is_complex_type ())
344  {
345  mattyp = args(0).matrix_type ();
346 
347  if (mattyp.is_unknown () && autocomp)
348  {
349  if (args(0).is_single_type ())
350  {
352  m = args(0).float_complex_matrix_value ();
353  if (!error_state)
354  {
355  mattyp = MatrixType (m);
356  args(0).matrix_type (mattyp);
357  }
358  }
359  else
360  {
361  ComplexMatrix m = args(0).complex_matrix_value ();
362  if (!error_state)
363  {
364  mattyp = MatrixType (m);
365  args(0).matrix_type (mattyp);
366  }
367  }
368  }
369  }
370  else
371  {
372  mattyp = args(0).matrix_type ();
373 
374  if (mattyp.is_unknown () && autocomp)
375  {
376  if (args(0).is_single_type ())
377  {
378  FloatMatrix m = args(0).float_matrix_value ();
379  if (!error_state)
380  {
381  mattyp = MatrixType (m);
382  args(0).matrix_type (mattyp);
383  }
384  }
385  else
386  {
387  Matrix m = args(0).matrix_value ();
388  if (!error_state)
389  {
390  mattyp = MatrixType (m);
391  args(0).matrix_type (mattyp);
392  }
393  }
394  }
395  }
396 
397  int typ = mattyp.type ();
398 
399  if (typ == MatrixType::Upper)
400  retval = octave_value ("Upper");
401  else if (typ == MatrixType::Permuted_Upper)
402  retval = octave_value ("Permuted Upper");
403  else if (typ == MatrixType::Lower)
404  retval = octave_value ("Lower");
405  else if (typ == MatrixType::Permuted_Lower)
406  retval = octave_value ("Permuted Lower");
407  else if (typ == MatrixType::Hermitian)
408  retval = octave_value ("Positive Definite");
409  else if (typ == MatrixType::Rectangular)
410  {
411  if (args(0).rows () == args(0).columns ())
412  retval = octave_value ("Singular");
413  else
414  retval = octave_value ("Rectangular");
415  }
416  else if (typ == MatrixType::Full)
417  retval = octave_value ("Full");
418  else
419  retval = octave_value ("Unknown");
420  }
421  else
422  {
423  // Ok, we're changing the matrix type
424  if (! args(1).is_string ())
425  error ("matrix_type: TYPE must be a string");
426  else
427  {
428  std::string str_typ = args(1).string_value ();
429 
430  // FIXME: why do I have to explicitly call the constructor?
431  MatrixType mattyp = MatrixType (MatrixType::Unknown, true);
432 
433  // Use STL function to convert to lower case
434  std::transform (str_typ.begin (), str_typ.end (),
435  str_typ.begin (), tolower);
436 
437  if (str_typ == "upper")
438  mattyp.mark_as_upper_triangular ();
439  else if (str_typ == "lower")
440  mattyp.mark_as_lower_triangular ();
441  else if (str_typ == "positive definite")
442  {
443  mattyp.mark_as_full ();
444  mattyp.mark_as_symmetric ();
445  }
446  else if (str_typ == "singular")
447  mattyp.mark_as_rectangular ();
448  else if (str_typ == "full")
449  mattyp.mark_as_full ();
450  else if (str_typ == "unknown")
451  mattyp.invalidate_type ();
452  else
453  error ("matrix_type: Unknown matrix type %s",
454  str_typ.c_str ());
455 
456  if (! error_state)
457  {
458  if (nargin == 3 && (str_typ == "upper"
459  || str_typ == "lower"))
460  {
461  const ColumnVector perm =
462  ColumnVector (args(2).vector_value ());
463 
464  if (error_state)
465  error ("matrix_type: Invalid permutation vector PERM");
466  else
467  {
468  octave_idx_type len = perm.length ();
469  dim_vector dv = args(0).dims ();
470 
471  if (len != dv(0))
472  error ("matrix_type: Invalid permutation vector PERM");
473  else
474  {
476 
477  for (octave_idx_type i = 0; i < len; i++)
478  p[i] = static_cast<octave_idx_type>
479  (perm (i))
480  - 1;
481 
482  if (str_typ == "upper")
483  mattyp.mark_as_permuted (len, p);
484  else
485  mattyp.mark_as_permuted (len, p);
486  }
487  }
488  }
489  else if (nargin != 2)
490  error ("matrix_type: Invalid number of arguments");
491 
492  if (! error_state)
493  {
494  // Set the matrix type
495  if (args(0).is_single_type ())
496  {
497  if (args(0).is_complex_type ())
498  retval = octave_value
499  (args(0).float_complex_matrix_value (),
500  mattyp);
501  else
502  retval = octave_value
503  (args(0).float_matrix_value (),
504  mattyp);
505  }
506  else
507  {
508  if (args(0).is_complex_type ())
509  retval = octave_value
510  (args(0).complex_matrix_value (),
511  mattyp);
512  else
513  retval = octave_value
514  (args(0).matrix_value (),
515  mattyp);
516  }
517  }
518  }
519  }
520  }
521  }
522  }
523 
524  return retval;
525 }
526 
527 /*
528 ## FIXME:
529 ## Disable tests for lower under-determined and upper over-determined
530 ## matrices as this detection is disabled in MatrixType due to issues
531 ## of non minimum norm solution being found.
532 
533 %!assert (matrix_type (speye (10,10)), "Diagonal")
534 %!assert (matrix_type (speye (10,10)([2:10,1],:)), "Permuted Diagonal")
535 %!assert (matrix_type ([[speye(10,10);sparse(1,10)],[1;sparse(9,1);1]]), "Upper")
536 %!assert (matrix_type ([[speye(10,10);sparse(1,10)],[1;sparse(9,1);1]](:,[2,1,3:11])), "Permuted Upper")
537 %!assert (matrix_type ([speye(10,10),sparse(10,1);1,sparse(1,9),1]), "Lower")
538 %!assert (matrix_type ([speye(10,10),sparse(10,1);1,sparse(1,9),1]([2,1,3:11],:)), "Permuted Lower")
539 
540 %!test
541 %! bnd = spparms ("bandden");
542 %! spparms ("bandden", 0.5);
543 %! a = spdiags (rand (10,3)-0.5,[-1,0,1],10,10);
544 %! assert (matrix_type (a), "Tridiagonal");
545 %! assert (matrix_type (a'+a+2*speye (10)), "Tridiagonal Positive Definite");
546 %! spparms ("bandden", bnd);
547 %!test
548 %! bnd=spparms ("bandden");
549 %! spparms ("bandden", 0.5);
550 %! a = spdiags (randn (10,4),[-2:1],10,10);
551 %! assert (matrix_type (a), "Banded");
552 %! assert (matrix_type (a'*a), "Banded Positive Definite");
553 %! spparms ("bandden", bnd);
554 %!test
555 %! a = [speye(10,10),[sparse(9,1);1];-1,sparse(1,9),1];
556 %! assert (matrix_type (a), "Full");
557 %! assert (matrix_type (a'*a), "Positive Definite");
558 
559 %!assert (matrix_type (speye (10,11)), "Diagonal")
560 %!assert (matrix_type (speye (10,11)([2:10,1],:)), "Permuted Diagonal")
561 %!assert (matrix_type (speye (11,10)), "Diagonal")
562 %!assert (matrix_type (speye (11,10)([2:11,1],:)), "Permuted Diagonal")
563 %#!assert (matrix_type ([[speye(10,10);sparse(1,10)],[[1,1];sparse(9,2);[1,1]]]), "Upper")
564 %#!assert (matrix_type ([[speye(10,10);sparse(1,10)],[[1,1];sparse(9,2);[1,1]]](:,[2,1,3:12])), "Permuted Upper")
565 %!assert (matrix_type ([speye(11,9),[1;sparse(8,1);1;0]]), "Upper")
566 %!assert (matrix_type ([speye(11,9),[1;sparse(8,1);1;0]](:,[2,1,3:10])), "Permuted Upper")
567 %#!assert (matrix_type ([speye(10,10),sparse(10,1);[1;1],sparse(2,9),[1;1]]), "Lower")
568 %#!assert (matrix_type ([speye(10,10),sparse(10,1);[1;1],sparse(2,9),[1;1]]([2,1,3:12],:)), "Permuted Lower")
569 %!assert (matrix_type ([speye(9,11);[1,sparse(1,8),1,0]]), "Lower")
570 %!assert (matrix_type ([speye(9,11);[1,sparse(1,8),1,0]]([2,1,3:10],:)), "Permuted Lower")
571 %!assert (matrix_type (spdiags (randn (10,4),[-2:1],10,9)), "Rectangular")
572 
573 %!assert (matrix_type (1i*speye (10,10)), "Diagonal")
574 %!assert (matrix_type (1i*speye (10,10)([2:10,1],:)), "Permuted Diagonal")
575 %!assert (matrix_type ([[speye(10,10);sparse(1,10)],[1i;sparse(9,1);1]]), "Upper")
576 %!assert (matrix_type ([[speye(10,10);sparse(1,10)],[1i;sparse(9,1);1]](:,[2,1,3:11])), "Permuted Upper")
577 %!assert (matrix_type ([speye(10,10),sparse(10,1);1i,sparse(1,9),1]), "Lower")
578 %!assert (matrix_type ([speye(10,10),sparse(10,1);1i,sparse(1,9),1]([2,1,3:11],:)), "Permuted Lower")
579 
580 %!test
581 %! bnd = spparms ("bandden");
582 %! spparms ("bandden", 0.5);
583 %! assert (matrix_type (spdiags (1i*randn (10,3),[-1,0,1],10,10)), "Tridiagonal");
584 %! a = 1i*(rand (9,1)-0.5);
585 %! a = [[a;0],ones(10,1),[0;-a]];
586 %! assert (matrix_type (spdiags (a,[-1,0,1],10,10)), "Tridiagonal Positive Definite");
587 %! spparms ("bandden", bnd);
588 %!test
589 %! bnd = spparms ("bandden");
590 %! spparms ("bandden", 0.5);
591 %! assert (matrix_type (spdiags (1i*randn (10,4),[-2:1],10,10)), "Banded");
592 %! a = 1i*(rand (9,2)-0.5);
593 %! a = [[a;[0,0]],ones(10,1),[[0;-a(:,2)],[0;0;-a(1:8,1)]]];
594 %! assert (matrix_type (spdiags (a,[-2:2],10,10)), "Banded Positive Definite");
595 %! spparms ("bandden", bnd);
596 %!test
597 %! a = [speye(10,10),[sparse(9,1);1i];-1,sparse(1,9),1];
598 %! assert (matrix_type (a), "Full");
599 %! assert (matrix_type (a'*a), "Positive Definite");
600 
601 %!assert (matrix_type (1i*speye (10,11)), "Diagonal")
602 %!assert (matrix_type (1i*speye (10,11)([2:10,1],:)), "Permuted Diagonal")
603 %!assert (matrix_type (1i*speye (11,10)), "Diagonal")
604 %!assert (matrix_type (1i*speye (11,10)([2:11,1],:)), "Permuted Diagonal")
605 %#!assert (matrix_type ([[speye(10,10);sparse(1,10)],[[1i,1i];sparse(9,2);[1i,1i]]]), "Upper")
606 %#!assert (matrix_type ([[speye(10,10);sparse(1,10)],[[1i,1i];sparse(9,2);[1i,1i]]](:,[2,1,3:12])), "Permuted Upper")
607 %!assert (matrix_type ([speye(11,9),[1i;sparse(8,1);1i;0]]), "Upper")
608 %!assert (matrix_type ([speye(11,9),[1i;sparse(8,1);1i;0]](:,[2,1,3:10])), "Permuted Upper")
609 %#!assert (matrix_type ([speye(10,10),sparse(10,1);[1i;1i],sparse(2,9),[1i;1i]]), "Lower")
610 %#!assert (matrix_type ([speye(10,10),sparse(10,1);[1i;1i],sparse(2,9),[1i;1i]]([2,1,3:12],:)), "Permuted Lower")
611 %!assert (matrix_type ([speye(9,11);[1i,sparse(1,8),1i,0]]), "Lower")
612 %!assert (matrix_type ([speye(9,11);[1i,sparse(1,8),1i,0]]([2,1,3:10],:)), "Permuted Lower")
613 %!assert (matrix_type (1i*spdiags(randn(10,4),[-2:1],10,9)), "Rectangular")
614 
615 %!test
616 %! a = matrix_type (spdiags (randn (10,3),[-1,0,1],10,10), "Singular");
617 %! assert (matrix_type (a), "Singular");
618 
619 %!assert (matrix_type (triu (ones(10,10))), "Upper")
620 %!assert (matrix_type (triu (ones(10,10),-1)), "Full")
621 %!assert (matrix_type (tril (ones(10,10))), "Lower")
622 %!assert (matrix_type (tril (ones(10,10),1)), "Full")
623 %!assert (matrix_type (10*eye (10,10) + ones (10,10)), "Positive Definite")
624 %!assert (matrix_type (ones (11,10)), "Rectangular")
625 %!test
626 %! a = matrix_type (ones (10,10), "Singular");
627 %! assert (matrix_type (a), "Singular");
628 
629 %!assert (matrix_type (triu (1i*ones (10,10))), "Upper")
630 %!assert (matrix_type (triu (1i*ones (10,10),-1)), "Full")
631 %!assert (matrix_type (tril (1i*ones (10,10))), "Lower")
632 %!assert (matrix_type (tril (1i*ones (10,10),1)), "Full")
633 %!assert (matrix_type (10*eye (10,10) + 1i*triu (ones (10,10),1) -1i*tril (ones (10,10),-1)), "Positive Definite")
634 %!assert (matrix_type (ones (11,10)), "Rectangular")
635 %!test
636 %! a = matrix_type (ones (10,10), "Singular");
637 %! assert (matrix_type (a), "Singular");
638 */
void mark_as_lower_triangular(void)
Definition: MatrixType.h:146
void mark_as_diagonal(void)
Definition: MatrixType.h:140
bool is_unknown(void) const
Definition: MatrixType.h:132
OCTINTERP_API void print_usage(void)
Definition: defun.cc:51
void mark_as_symmetric(void)
Definition: MatrixType.cc:1208
#define DEFUN(name, args_name, nargout_name, doc)
Definition: defun.h:44
void mark_as_permuted_diagonal(void)
Definition: MatrixType.h:142
void error(const char *fmt,...)
Definition: error.cc:476
void mark_as_full(void)
Definition: MatrixType.h:153
int type(bool quiet=true)
Definition: MatrixType.cc:963
void mark_as_permuted(const octave_idx_type np, const octave_idx_type *p)
Definition: MatrixType.cc:1237
int error_state
Definition: error.cc:101
void mark_as_upper_triangular(void)
Definition: MatrixType.h:144
Definition: dMatrix.h:35
void mark_as_rectangular(void)
Definition: MatrixType.h:155
void invalidate_type(void)
Definition: MatrixType.h:138
octave_idx_type length(void) const
Number of elements in the array.
Definition: Array.h:267
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
Definition: oct-locbuf.h:197
ColumnVector transform(const Matrix &m, double x, double y, double z)
Definition: graphics.cc:5259
void mark_as_tridiagonal(void)
Definition: MatrixType.h:148
void mark_as_banded(const octave_idx_type ku, const octave_idx_type kl)
Definition: MatrixType.h:150
return octave_value(v1.char_array_value().concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string())? '\'': '"'))