base-qr.cc

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (C) 2009-2012 Jaroslav Hajek
00004 
00005 This file is part of Octave.
00006 
00007 Octave is free software; you can redistribute it and/or modify it
00008 under the terms of the GNU General Public License as published by the
00009 Free Software Foundation; either version 3 of the License, or (at your
00010 option) any later version.
00011 
00012 Octave is distributed in the hope that it will be useful, but WITHOUT
00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00015 for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Octave; see the file COPYING.  If not, see
00019 <http://www.gnu.org/licenses/>.
00020 
00021 */
00022 
00023 #ifdef HAVE_CONFIG_H
00024 #include <config.h>
00025 #endif
00026 
00027 #include "base-qr.h"
00028 
00029 template <class qr_type>
00030 base_qr<qr_type>::base_qr (const qr_type& q_arg, const qr_type& r_arg)
00031   : q (q_arg), r (r_arg)
00032 {
00033   octave_idx_type q_nr = q.rows (), q_nc = q.columns ();
00034   octave_idx_type r_nr = r.rows (), r_nc = r.columns ();
00035 
00036   if (! (q_nc == r_nr && (q_nr == q_nc || (q_nr > q_nc && r_nr == r_nc))))
00037     {
00038       q = qr_type ();
00039       r = qr_type ();
00040 
00041       (*current_liboctave_error_handler) ("QR dimensions mismatch");
00042     }
00043 }
00044 
00045 template <class qr_type>
00046 qr_type_t
00047 base_qr<qr_type>::get_type (void) const
00048 {
00049   qr_type_t retval;
00050 
00051   if (!q.is_empty () && q.is_square ())
00052     retval = qr_type_std;
00053   else if (q.rows () > q.columns () && r.is_square ())
00054     retval = qr_type_economy;
00055   else
00056     retval = qr_type_raw;
00057 
00058   return retval;
00059 }
00060 
00061 template <class qr_type>
00062 bool
00063 base_qr<qr_type>::regular (void) const
00064 {
00065   bool retval = true;
00066 
00067   octave_idx_type k = std::min (r.rows (), r.columns ());
00068 
00069   for (octave_idx_type i = 0; i < k; i++)
00070     {
00071       if (r(i, i) == qr_elt_type ())
00072         {
00073           retval = false;
00074           break;
00075         }
00076     }
00077 
00078   return retval;
00079 }
00080 
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines