"Fossies" - the Fresh Open Source Software Archive

Member "armadillo-9.800.3/include/armadillo_bits/newarp_DoubleShiftQR_bones.hpp" (16 Jun 2016, 2508 Bytes) of package /linux/misc/armadillo-9.800.3.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "newarp_DoubleShiftQR_bones.hpp" see the Fossies "Dox" file reference documentation.

    1 // Copyright 2008-2016 Conrad Sanderson (http://conradsanderson.id.au)
    2 // Copyright 2008-2016 National ICT Australia (NICTA)
    3 // 
    4 // Licensed under the Apache License, Version 2.0 (the "License");
    5 // you may not use this file except in compliance with the License.
    6 // You may obtain a copy of the License at
    7 // http://www.apache.org/licenses/LICENSE-2.0
    8 // 
    9 // Unless required by applicable law or agreed to in writing, software
   10 // distributed under the License is distributed on an "AS IS" BASIS,
   11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   12 // See the License for the specific language governing permissions and
   13 // limitations under the License.
   14 // ------------------------------------------------------------------------
   15 
   16 
   17 namespace newarp
   18 {
   19 
   20 
   21 template<typename eT>
   22 class DoubleShiftQR
   23   {
   24   private:
   25 
   26   uword               n;        // Dimension of the matrix
   27   Mat<eT>             mat_H;    // A copy of the matrix to be factorised
   28   eT                  shift_s;  // Shift constant
   29   eT                  shift_t;  // Shift constant
   30   Mat<eT>             ref_u;    // Householder reflectors
   31   Col<unsigned short> ref_nr;   // How many rows does each reflector affects
   32                                 // 3 - A general reflector
   33                                 // 2 - A Givens rotation
   34                                 // 1 - An identity transformation
   35   const eT            prec;     // Approximately zero
   36   const eT            eps_rel;
   37   const eT            eps_abs;
   38   bool                computed; // Whether matrix has been factorised
   39 
   40   inline      void compute_reflector(const eT& x1, const eT& x2, const eT& x3, uword ind);
   41   arma_inline void compute_reflector(const eT* x, uword ind);
   42 
   43   // Update the block X = H(il:iu, il:iu)
   44   inline void update_block(uword il, uword iu);
   45 
   46   // P = I - 2 * u * u' = P'
   47   // PX = X - 2 * u * (u'X)
   48   inline void apply_PX(Mat<eT>& X, uword oi, uword oj, uword nrow, uword ncol, uword u_ind);
   49 
   50   // x is a pointer to a vector
   51   // Px = x - 2 * dot(x, u) * u
   52   inline void apply_PX(eT* x, uword u_ind);
   53 
   54   // XP = X - 2 * (X * u) * u'
   55   inline void apply_XP(Mat<eT>& X, uword oi, uword oj, uword nrow, uword ncol, uword u_ind);
   56 
   57 
   58   public:
   59 
   60   inline DoubleShiftQR(uword size);
   61 
   62   inline DoubleShiftQR(const Mat<eT>& mat_obj, eT s, eT t);
   63 
   64   inline void compute(const Mat<eT>& mat_obj, eT s, eT t);
   65 
   66   inline Mat<eT> matrix_QtHQ();
   67 
   68   inline void apply_QtY(Col<eT>& y);
   69 
   70   inline void apply_YQ(Mat<eT>& Y);
   71   };
   72 
   73 
   74 }  // namespace newarp