Kokkos Node API and Local Linear Algebra Kernels Version of the Day
Tsqr_Combine.hpp
Go to the documentation of this file.
00001 //@HEADER
00002 // ************************************************************************
00003 // 
00004 //          Kokkos: Node API and Parallel Node Kernels
00005 //              Copyright (2009) 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 
00032 #ifndef __TSQR_Combine_hpp
00033 #define __TSQR_Combine_hpp
00034 
00035 #include <Teuchos_ScalarTraits.hpp>
00036 #include <Tsqr_ApplyType.hpp>
00037 #include <Tsqr_CombineNative.hpp>
00038 
00039 
00040 namespace TSQR {
00041 
00078   template< class Ordinal, 
00079       class Scalar, 
00080       class CombineImpl = CombineNative<Ordinal, Scalar, Teuchos::ScalarTraits<Scalar >::isComplex> >
00081   class Combine {
00082   public:
00085     typedef Scalar scalar_type;
00088     typedef Ordinal ordinal_type;
00091     typedef CombineImpl combine_impl_type;
00092 
00094     Combine () {}
00095 
00099     static bool QR_produces_R_factor_with_nonnegative_diagonal() {
00100       return combine_impl_type::QR_produces_R_factor_with_nonnegative_diagonal();
00101     }
00102 
00121     void
00122     factor_first (const Ordinal nrows,
00123       const Ordinal ncols,
00124       Scalar A[],
00125       const Ordinal lda,
00126       Scalar tau[],
00127       Scalar work[]) const
00128     {
00129       return impl_.factor_first (nrows, ncols, A, lda, tau, work);
00130     }
00131 
00136     void
00137     apply_first (const ApplyType& applyType,
00138      const Ordinal nrows,
00139      const Ordinal ncols_C,
00140      const Ordinal ncols_A,
00141      const Scalar A[],
00142      const Ordinal lda,
00143      const Scalar tau[],
00144      Scalar C[],
00145      const Ordinal ldc,
00146      Scalar work[]) const
00147     {
00148       return impl_.apply_first (applyType, nrows, ncols_C, ncols_A, 
00149         A, lda, tau, C, ldc, work);
00150     }
00151 
00180     void
00181     apply_inner (const ApplyType& apply_type,
00182      const Ordinal m,
00183      const Ordinal ncols_C,
00184      const Ordinal ncols_Q,
00185      const Scalar A[],
00186      const Ordinal lda,
00187      const Scalar tau[],
00188      Scalar C_top[],
00189      const Ordinal ldc_top,
00190      Scalar C_bot[],
00191      const Ordinal ldc_bot,
00192      Scalar work[]) const
00193     {
00194       impl_.apply_inner (apply_type, m, ncols_C, ncols_Q, 
00195        A, lda, tau, 
00196        C_top, ldc_top, C_bot, ldc_bot, work);
00197     }
00198 
00238     void
00239     factor_inner (const Ordinal m,
00240       const Ordinal n,
00241       Scalar R[],
00242       const Ordinal ldr,
00243       Scalar A[],
00244       const Ordinal lda,
00245       Scalar tau[],
00246       Scalar work[]) const
00247     {
00248       impl_.factor_inner (m, n, R, ldr, A, lda, tau, work);
00249     }
00250 
00264     void
00265     factor_pair (const Ordinal n,
00266      Scalar R_top[],
00267      const Ordinal ldr_top,
00268      Scalar R_bot[],
00269      const Ordinal ldr_bot,
00270      Scalar tau[],
00271      Scalar work[]) const
00272     {
00273       impl_.factor_pair (n, R_top, ldr_top, R_bot, ldr_bot, tau, work);      
00274     }
00275 
00286     void
00287     apply_pair (const ApplyType& apply_type,
00288     const Ordinal ncols_C, 
00289     const Ordinal ncols_Q, 
00290     const Scalar R_bot[], 
00291     const Ordinal ldr_bot,
00292     const Scalar tau[], 
00293     Scalar C_top[], 
00294     const Ordinal ldc_top, 
00295     Scalar C_bot[], 
00296     const Ordinal ldc_bot, 
00297     Scalar work[]) const
00298     {
00299       impl_.apply_pair (apply_type, ncols_C, ncols_Q, 
00300       R_bot, ldr_bot, tau, 
00301       C_top, ldc_top, C_bot, ldc_bot, work);
00302     }
00303 
00304   private:
00306     combine_impl_type impl_;
00307   };
00308 
00309 } // namespace TSQR
00310 
00311 #endif // __TSQR_Combine_hpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends