MOOCHO (Single Doxygen Collection) Version of the Day
DenseLinAlgPack_DMatrixAsTriSym.hpp
Go to the documentation of this file.
00001 // @HEADER
00002 // ***********************************************************************
00003 // 
00004 // Moocho: Multi-functional Object-Oriented arCHitecture for Optimization
00005 //                  Copyright (2003) 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 // 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 Roscoe A. Bartlett (rabartl@sandia.gov) 
00038 // 
00039 // ***********************************************************************
00040 // @HEADER
00041 
00042 #ifndef GEN_MATRIX_AS_TRI_SYM_H
00043 #define GEN_MATRIX_AS_TRI_SYM_H
00044 
00045 #include "DenseLinAlgPack_DMatrixClass.hpp"
00046 
00047 namespace DenseLinAlgPack {
00048 
00049 /* * @name  Packaging arguments for GenMatrixSlices treated as triangular
00050   *     and symmetric matrices in BLAS-like linear algebra operations.
00051   *
00052   */
00053 
00054 // @{
00055 
00056 // /////////////////////////////////////////////////////////////////////////////////////
00058 /* * Aggregate information for a triangular matrix (element-wise) stored in a DMatrix.
00059   *
00060   * This is the type to be used as lhs and rhs arguments in element-wise
00061   * linear algebra operations like assignment and binary arithmetic.
00062   */
00063 class DMatrixSliceTriEle {
00064 public:
00066   DMatrixSliceTriEle(const DMatrixSlice& gms, BLAS_Cpp::Uplo uplo)
00067     : gms_(const_cast<DMatrixSlice&>(gms)), uplo_(uplo)
00068   {
00069     #ifdef LINALGPACK_CHECK_RHS_SIZES
00070       assert_gms_square(gms);
00071     #endif
00072   }
00074   size_type rows() const {
00075     return gms_.rows();
00076   }
00078   size_type cols() const {
00079     return gms_.cols();
00080   }
00082   DMatrixSlice& gms() {
00083     return gms_;
00084   }
00086   const DMatrixSlice& gms() const {
00087     return gms_;
00088   }
00090   BLAS_Cpp::Uplo  uplo() const {
00091     return uplo_;
00092   }
00094   DMatrixSliceTriEle* operator&() {
00095     return this;
00096   }
00098   const DMatrixSliceTriEle* operator&() const {
00099     return this;
00100   }
00101 
00102 private:  
00103   DMatrixSlice  gms_;
00104   BLAS_Cpp::Uplo  uplo_;
00105   // Not defined and not to be called
00106   DMatrixSliceTriEle();
00107   DMatrixSliceTriEle& operator=(const DMatrixSliceTriEle&);
00108 };  // end class DMatrixSliceTriEle
00109 
00110 inline
00112 DMatrixSliceTriEle nonconst_tri_ele(DMatrixSlice gms, BLAS_Cpp::Uplo uplo)
00113 {
00114   return DMatrixSliceTriEle(gms, uplo);
00115 }
00116 
00117 inline
00119 const DMatrixSliceTriEle tri_ele(const DMatrixSlice& gms, BLAS_Cpp::Uplo uplo)
00120 {
00121   return DMatrixSliceTriEle(gms, uplo);
00122 }
00123 
00124 // ////////////////////////////////////////////////////////////////////////////////
00126 /* * Aggregate information for a triangular matrix (structure dependent) stored in a DMatrix.
00127   *
00128   * This is the type to be used as a rhs argument in linear algebra operations
00129   * that are structure specific like the BLAS operations.
00130   */
00131 class DMatrixSliceTri {
00132 public:
00134   DMatrixSliceTri(const DMatrixSlice& gms, BLAS_Cpp::Uplo uplo, BLAS_Cpp::Diag diag)
00135     : gms_(const_cast<DMatrixSlice&>(gms)), uplo_(uplo), diag_(diag)
00136   {
00137     #ifdef LINALGPACK_CHECK_RHS_SIZES
00138       assert_gms_square(gms);
00139     #endif
00140   }
00142   size_type rows() const {
00143     return gms_.rows();
00144   }
00146   size_type cols() const {
00147     return gms_.cols();
00148   }
00150   DMatrixSlice& gms() {
00151     return gms_;
00152   }
00154   const DMatrixSlice& gms() const {
00155     return gms_;
00156   }
00158   BLAS_Cpp::Uplo  uplo() const {
00159     return uplo_;
00160   }
00162   BLAS_Cpp::Diag  diag() const {
00163     return diag_;
00164   }
00166   DMatrixSliceTri* operator&() {
00167     return this;
00168   }
00170   const DMatrixSliceTri* operator&() const {
00171     return this;
00172   }
00173 
00174 private:  
00175   DMatrixSlice  gms_;
00176   BLAS_Cpp::Uplo  uplo_;
00177   BLAS_Cpp::Diag  diag_;
00178   // not defined and not to be called
00179   DMatrixSliceTri();
00180   DMatrixSliceTri& operator=(const DMatrixSliceTri&);
00181 };  // end class DMatrixSliceTri
00182 
00183 inline
00185 DMatrixSliceTri nonconst_tri(DMatrixSlice gms, BLAS_Cpp::Uplo uplo, BLAS_Cpp::Diag diag)
00186 {
00187   return DMatrixSliceTri(gms, uplo, diag);
00188 }
00189 
00190 inline
00192 const DMatrixSliceTri tri(const DMatrixSlice& gms, BLAS_Cpp::Uplo uplo, BLAS_Cpp::Diag diag)
00193 {
00194   return DMatrixSliceTri(gms, uplo, diag);
00195 }
00196 
00197 // /////////////////////////////////////////////////////////////////////////////////////////
00199 /* * Aggregate information for a symmetric matrix stored in a DMatrix.
00200   *
00201   * This is the type to be used as both lhs and rhs arguments in linear algebra operations.
00202   */
00203 class DMatrixSliceSym {
00204 public:
00206   DMatrixSliceSym(const DMatrixSlice& gms, BLAS_Cpp::Uplo uplo)
00207     : gms_(const_cast<DMatrixSlice&>(gms)), uplo_(uplo)
00208   {
00209     #ifdef LINALGPACK_CHECK_RHS_SIZES
00210       assert_gms_square(gms);
00211     #endif
00212   }
00214   size_type rows() const {
00215     return gms_.rows();
00216   }
00218   size_type cols() const {
00219     return gms_.cols();
00220   }
00222   DMatrixSlice& gms() {
00223     return gms_;
00224   }
00226   const DMatrixSlice& gms() const {
00227     return gms_;
00228   }
00230   BLAS_Cpp::Uplo  uplo() const {
00231     return uplo_;
00232   }
00234   DMatrixSliceSym* operator&() {
00235     return this;
00236   }
00237   const DMatrixSliceSym* operator&() const {
00238     return this;
00239   }
00240 
00241 private:  
00242   DMatrixSlice  gms_;
00243   BLAS_Cpp::Uplo  uplo_;
00244   // not defined and not to be called
00245   DMatrixSliceSym();
00246   DMatrixSliceSym& operator=(const DMatrixSliceTri&);
00247 };  // end class DMatrixSliceSym
00248 
00249 inline
00251 DMatrixSliceSym nonconst_sym(DMatrixSlice gms, BLAS_Cpp::Uplo uplo)
00252 {
00253   return DMatrixSliceSym(gms, uplo);
00254 }
00255 
00256 inline
00258 const DMatrixSliceSym sym(const DMatrixSlice& gms, BLAS_Cpp::Uplo uplo)
00259 {
00260   return DMatrixSliceSym(gms, uplo);
00261 }
00262 
00263 // @}
00264 
00265 } // end namespace DenseLinAlgPack
00266 
00267 #endif  // GEN_MATRIX_AS_TRI_SYM_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines