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
base-qr.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2009-2015 Jaroslav Hajek
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 "base-qr.h"
28 
29 template <class qr_type>
30 base_qr<qr_type>::base_qr (const qr_type& q_arg, const qr_type& r_arg)
31  : q (q_arg), r (r_arg)
32 {
33  octave_idx_type q_nr = q.rows ();
34  octave_idx_type q_nc = q.columns ();
35  octave_idx_type r_nr = r.rows ();
36  octave_idx_type r_nc = r.columns ();
37 
38  if (! (q_nc == r_nr && (q_nr == q_nc || (q_nr > q_nc && r_nr == r_nc))))
39  {
40  q = qr_type ();
41  r = qr_type ();
42 
43  (*current_liboctave_error_handler) ("QR dimensions mismatch");
44  }
45 }
46 
47 template <class qr_type>
50 {
51  qr_type_t retval;
52 
53  if (!q.is_empty () && q.is_square ())
54  retval = qr_type_std;
55  else if (q.rows () > q.columns () && r.is_square ())
56  retval = qr_type_economy;
57  else
58  retval = qr_type_raw;
59 
60  return retval;
61 }
62 
63 template <class qr_type>
64 bool
66 {
67  bool retval = true;
68 
69  octave_idx_type k = std::min (r.rows (), r.columns ());
70 
71  for (octave_idx_type i = 0; i < k; i++)
72  {
73  if (r(i, i) == qr_elt_type ())
74  {
75  retval = false;
76  break;
77  }
78  }
79 
80  return retval;
81 }
82 
base_qr(void)
Definition: base-qr.h:45
qr_type::element_type qr_elt_type
Definition: base-qr.h:43
qr_type_t get_type(void) const
Definition: base-qr.cc:49
bool regular(void) const
Definition: base-qr.cc:65
qr_type r
Definition: base-qr.h:74
qr_type q
Definition: base-qr.h:73
qr_type_t
Definition: base-qr.h:30
charNDArray min(char d, const charNDArray &m)
Definition: chNDArray.cc:210