Anasazi Version of the Day
Tsqr_NodeTsqr.hpp
00001 // @HEADER
00002 // ***********************************************************************
00003 //
00004 //                 Anasazi: Block Eigensolvers Package
00005 //                 Copyright (2010) Sandia Corporation
00006 //
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 //
00010 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
00025 //
00026 // ***********************************************************************
00027 // @HEADER
00028 
00029 #ifndef __TSQR_Tsqr_NodeTsqr_hpp
00030 #define __TSQR_Tsqr_NodeTsqr_hpp
00031 
00032 #include <Tsqr_ApplyType.hpp>
00033 #include <Tsqr_Lapack.hpp>
00034 #include <Tsqr_MatView.hpp>
00035 #include <Tsqr_ScalarTraits.hpp>
00036 #include <cstring> // size_t
00037 
00040 
00041 namespace TSQR {
00042 
00043   template< class LocalOrdinal, class Scalar >
00044   class NodeTsqrFactorOutput {
00045   public:
00046     NodeTsqrFactorOutput () {}
00047     virtual ~NodeTsqrFactorOutput() = 0;
00048   };
00049 
00050   template< class LocalOrdinal, class Scalar >
00051   class NodeTsqr {
00052   public:
00053     typedef Scalar scalar_type;
00054     typedef typename ScalarTraits< Scalar >::magnitude_type magnitude_type;
00055     typedef LocalOrdinal ordinal_type;
00056     typedef NodeTsqrFactorOutput factor_output_type;
00057 
00058     NodeTsqr(const size_t cacheBlockSize = 0) {}
00059     virtual ~NodeTsqr() {}
00060 
00063     bool QR_produces_R_factor_with_nonnegative_diagonal () const {
00064       return LAPACK< LocalOrdinal, Scalar >::QR_produces_R_factor_with_nonnegative_diagonal;
00065     }
00066 
00067     virtual size_t
00068     cache_block_size() const = 0;
00069 
00070     virtual void
00071     cache_block (const LocalOrdinal nrows,
00072      const LocalOrdinal ncols, 
00073      Scalar A_out[],
00074      const Scalar A_in[],
00075      const LocalOrdinal lda_in) const = 0;
00076 
00077     virtual void
00078     un_cache_block (const LocalOrdinal nrows,
00079         const LocalOrdinal ncols,
00080         Scalar A_out[],
00081         const LocalOrdinal lda_out,       
00082         const Scalar A_in[]) const = 0;
00083 
00084     virtual factor_output_type
00085     factor (const LocalOrdinal nrows,
00086       const LocalOrdinal ncols, 
00087       Scalar A[],
00088       const LocalOrdinal lda,
00089       Scalar R[],
00090       const LocalOrdinal ldr,
00091       const bool contiguous_cache_blocks) = 0;
00092 
00093     virtual void
00094     apply (const ApplyType& apply_type,
00095      const LocalOrdinal nrows,
00096      const LocalOrdinal ncols_Q,
00097      const Scalar* const Q,
00098      const LocalOrdinal ldq,
00099      const FactorOutput& factor_output,
00100      const LocalOrdinal ncols_C,
00101      Scalar* const C,
00102      const LocalOrdinal ldc,
00103      const bool contiguous_cache_blocks) = 0;
00104 
00105     virtual void
00106     explicit_Q (const LocalOrdinal nrows,
00107     const LocalOrdinal ncols_Q,
00108     const Scalar Q[],
00109     const LocalOrdinal ldq,
00110     const factor_output_type& factor_output,
00111     const LocalOrdinal ncols_C,
00112     Scalar C[],
00113     const LocalOrdinal ldc,
00114     const bool contiguous_cache_blocks) = 0;
00115 
00120     virtual void
00121     Q_times_B (const LocalOrdinal nrows,
00122          const LocalOrdinal ncols,
00123          Scalar Q[],
00124          const LocalOrdinal ldq,
00125          const Scalar B[],
00126          const LocalOrdinal ldb,
00127          const bool contiguous_cache_blocks) const = 0;
00128 
00136     virtual LocalOrdinal
00137     reveal_R_rank (const LocalOrdinal ncols,
00138        Scalar R[],
00139        const LocalOrdinal ldr,
00140        Scalar U[],
00141        const LocalOrdinal ldu,
00142        const magnitude_type tol) const = 0;
00143 
00155     virtual LocalOrdinal
00156     reveal_rank (const LocalOrdinal nrows,
00157      const LocalOrdinal ncols,
00158      Scalar Q[],
00159      const LocalOrdinal ldq,
00160      Scalar R[],
00161      const LocalOrdinal ldr,
00162      const magnitude_type tol,
00163      const bool contiguous_cache_blocks) = 0;
00164 
00177     virtual void
00178     fill_with_zeros (const LocalOrdinal nrows,
00179          const LocalOrdinal ncols,
00180          Scalar A[],
00181          const LocalOrdinal lda, 
00182          const bool contiguous_cache_blocks = false) = 0;
00183 
00200     template< class MatrixViewType >
00201     virtual MatrixViewType
00202     top_block (const MatrixViewType& C, 
00203          const bool contiguous_cache_blocks = false) const = 0;
00204   };
00205 } // namespace TSQR
00206 
00207 
00208 #endif __TSQR_Tsqr_NodeTsqr_hpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends