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 (2008) Sandia Corporation
00006 // 
00007 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00008 // the U.S. Government retains certain rights in this software.
00009 // 
00010 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00038 // 
00039 // ************************************************************************
00040 //@HEADER
00041 
00045 #ifndef __TSQR_Combine_hpp
00046 #define __TSQR_Combine_hpp
00047 
00048 #include <Teuchos_ScalarTraits.hpp>
00049 #include <Tsqr_ApplyType.hpp>
00050 #include <Tsqr_CombineNative.hpp>
00051 
00052 
00053 namespace TSQR {
00054 
00091   template< class Ordinal, 
00092       class Scalar, 
00093       class CombineImpl = CombineNative<Ordinal, Scalar, Teuchos::ScalarTraits<Scalar >::isComplex> >
00094   class Combine {
00095   public:
00098     typedef Scalar scalar_type;
00101     typedef Ordinal ordinal_type;
00104     typedef CombineImpl combine_impl_type;
00105 
00107     Combine () {}
00108 
00112     static bool QR_produces_R_factor_with_nonnegative_diagonal() {
00113       return combine_impl_type::QR_produces_R_factor_with_nonnegative_diagonal();
00114     }
00115 
00134     void
00135     factor_first (const Ordinal nrows,
00136       const Ordinal ncols,
00137       Scalar A[],
00138       const Ordinal lda,
00139       Scalar tau[],
00140       Scalar work[]) const
00141     {
00142       return impl_.factor_first (nrows, ncols, A, lda, tau, work);
00143     }
00144 
00149     void
00150     apply_first (const ApplyType& applyType,
00151      const Ordinal nrows,
00152      const Ordinal ncols_C,
00153      const Ordinal ncols_A,
00154      const Scalar A[],
00155      const Ordinal lda,
00156      const Scalar tau[],
00157      Scalar C[],
00158      const Ordinal ldc,
00159      Scalar work[]) const
00160     {
00161       return impl_.apply_first (applyType, nrows, ncols_C, ncols_A, 
00162         A, lda, tau, C, ldc, work);
00163     }
00164 
00193     void
00194     apply_inner (const ApplyType& apply_type,
00195      const Ordinal m,
00196      const Ordinal ncols_C,
00197      const Ordinal ncols_Q,
00198      const Scalar A[],
00199      const Ordinal lda,
00200      const Scalar tau[],
00201      Scalar C_top[],
00202      const Ordinal ldc_top,
00203      Scalar C_bot[],
00204      const Ordinal ldc_bot,
00205      Scalar work[]) const
00206     {
00207       impl_.apply_inner (apply_type, m, ncols_C, ncols_Q, 
00208        A, lda, tau, 
00209        C_top, ldc_top, C_bot, ldc_bot, work);
00210     }
00211 
00251     void
00252     factor_inner (const Ordinal m,
00253       const Ordinal n,
00254       Scalar R[],
00255       const Ordinal ldr,
00256       Scalar A[],
00257       const Ordinal lda,
00258       Scalar tau[],
00259       Scalar work[]) const
00260     {
00261       impl_.factor_inner (m, n, R, ldr, A, lda, tau, work);
00262     }
00263 
00277     void
00278     factor_pair (const Ordinal n,
00279      Scalar R_top[],
00280      const Ordinal ldr_top,
00281      Scalar R_bot[],
00282      const Ordinal ldr_bot,
00283      Scalar tau[],
00284      Scalar work[]) const
00285     {
00286       impl_.factor_pair (n, R_top, ldr_top, R_bot, ldr_bot, tau, work);      
00287     }
00288 
00299     void
00300     apply_pair (const ApplyType& apply_type,
00301     const Ordinal ncols_C, 
00302     const Ordinal ncols_Q, 
00303     const Scalar R_bot[], 
00304     const Ordinal ldr_bot,
00305     const Scalar tau[], 
00306     Scalar C_top[], 
00307     const Ordinal ldc_top, 
00308     Scalar C_bot[], 
00309     const Ordinal ldc_bot, 
00310     Scalar work[]) const
00311     {
00312       impl_.apply_pair (apply_type, ncols_C, ncols_Q, 
00313       R_bot, ldr_bot, tau, 
00314       C_top, ldc_top, C_bot, ldc_bot, work);
00315     }
00316 
00317   private:
00319     combine_impl_type impl_;
00320   };
00321 
00322 } // namespace TSQR
00323 
00324 #endif // __TSQR_Combine_hpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends