|
DenseLinAlgPack: Concreate C++ Classes for Dense Blas-Compatible Linear Algebra Version of the Day
|
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 // 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 Roscoe A. Bartlett (rabartl@sandia.gov) 00025 // 00026 // *********************************************************************** 00027 // @HEADER 00028 00029 #ifndef GEN_MATRIX_AS_TRI_SYM_H 00030 #define GEN_MATRIX_AS_TRI_SYM_H 00031 00032 #include "DenseLinAlgPack_DMatrixClass.hpp" 00033 00034 namespace DenseLinAlgPack { 00035 00036 /* * @name Packaging arguments for GenMatrixSlices treated as triangular 00037 * and symmetric matrices in BLAS-like linear algebra operations. 00038 * 00039 */ 00040 00041 // @{ 00042 00043 // ///////////////////////////////////////////////////////////////////////////////////// 00045 /* * Aggregate information for a triangular matrix (element-wise) stored in a DMatrix. 00046 * 00047 * This is the type to be used as lhs and rhs arguments in element-wise 00048 * linear algebra operations like assignment and binary arithmetic. 00049 */ 00050 class DMatrixSliceTriEle { 00051 public: 00053 DMatrixSliceTriEle(const DMatrixSlice& gms, BLAS_Cpp::Uplo uplo) 00054 : gms_(const_cast<DMatrixSlice&>(gms)), uplo_(uplo) 00055 { 00056 #ifdef LINALGPACK_CHECK_RHS_SIZES 00057 assert_gms_square(gms); 00058 #endif 00059 } 00061 size_type rows() const { 00062 return gms_.rows(); 00063 } 00065 size_type cols() const { 00066 return gms_.cols(); 00067 } 00069 DMatrixSlice& gms() { 00070 return gms_; 00071 } 00073 const DMatrixSlice& gms() const { 00074 return gms_; 00075 } 00077 BLAS_Cpp::Uplo uplo() const { 00078 return uplo_; 00079 } 00081 DMatrixSliceTriEle* operator&() { 00082 return this; 00083 } 00085 const DMatrixSliceTriEle* operator&() const { 00086 return this; 00087 } 00088 00089 private: 00090 DMatrixSlice gms_; 00091 BLAS_Cpp::Uplo uplo_; 00092 // Not defined and not to be called 00093 DMatrixSliceTriEle(); 00094 DMatrixSliceTriEle& operator=(const DMatrixSliceTriEle&); 00095 }; // end class DMatrixSliceTriEle 00096 00097 inline 00099 DMatrixSliceTriEle nonconst_tri_ele(DMatrixSlice gms, BLAS_Cpp::Uplo uplo) 00100 { 00101 return DMatrixSliceTriEle(gms, uplo); 00102 } 00103 00104 inline 00106 const DMatrixSliceTriEle tri_ele(const DMatrixSlice& gms, BLAS_Cpp::Uplo uplo) 00107 { 00108 return DMatrixSliceTriEle(gms, uplo); 00109 } 00110 00111 // //////////////////////////////////////////////////////////////////////////////// 00113 /* * Aggregate information for a triangular matrix (structure dependent) stored in a DMatrix. 00114 * 00115 * This is the type to be used as a rhs argument in linear algebra operations 00116 * that are structure specific like the BLAS operations. 00117 */ 00118 class DMatrixSliceTri { 00119 public: 00121 DMatrixSliceTri(const DMatrixSlice& gms, BLAS_Cpp::Uplo uplo, BLAS_Cpp::Diag diag) 00122 : gms_(const_cast<DMatrixSlice&>(gms)), uplo_(uplo), diag_(diag) 00123 { 00124 #ifdef LINALGPACK_CHECK_RHS_SIZES 00125 assert_gms_square(gms); 00126 #endif 00127 } 00129 size_type rows() const { 00130 return gms_.rows(); 00131 } 00133 size_type cols() const { 00134 return gms_.cols(); 00135 } 00137 DMatrixSlice& gms() { 00138 return gms_; 00139 } 00141 const DMatrixSlice& gms() const { 00142 return gms_; 00143 } 00145 BLAS_Cpp::Uplo uplo() const { 00146 return uplo_; 00147 } 00149 BLAS_Cpp::Diag diag() const { 00150 return diag_; 00151 } 00153 DMatrixSliceTri* operator&() { 00154 return this; 00155 } 00157 const DMatrixSliceTri* operator&() const { 00158 return this; 00159 } 00160 00161 private: 00162 DMatrixSlice gms_; 00163 BLAS_Cpp::Uplo uplo_; 00164 BLAS_Cpp::Diag diag_; 00165 // not defined and not to be called 00166 DMatrixSliceTri(); 00167 DMatrixSliceTri& operator=(const DMatrixSliceTri&); 00168 }; // end class DMatrixSliceTri 00169 00170 inline 00172 DMatrixSliceTri nonconst_tri(DMatrixSlice gms, BLAS_Cpp::Uplo uplo, BLAS_Cpp::Diag diag) 00173 { 00174 return DMatrixSliceTri(gms, uplo, diag); 00175 } 00176 00177 inline 00179 const DMatrixSliceTri tri(const DMatrixSlice& gms, BLAS_Cpp::Uplo uplo, BLAS_Cpp::Diag diag) 00180 { 00181 return DMatrixSliceTri(gms, uplo, diag); 00182 } 00183 00184 // ///////////////////////////////////////////////////////////////////////////////////////// 00186 /* * Aggregate information for a symmetric matrix stored in a DMatrix. 00187 * 00188 * This is the type to be used as both lhs and rhs arguments in linear algebra operations. 00189 */ 00190 class DMatrixSliceSym { 00191 public: 00193 DMatrixSliceSym(const DMatrixSlice& gms, BLAS_Cpp::Uplo uplo) 00194 : gms_(const_cast<DMatrixSlice&>(gms)), uplo_(uplo) 00195 { 00196 #ifdef LINALGPACK_CHECK_RHS_SIZES 00197 assert_gms_square(gms); 00198 #endif 00199 } 00201 size_type rows() const { 00202 return gms_.rows(); 00203 } 00205 size_type cols() const { 00206 return gms_.cols(); 00207 } 00209 DMatrixSlice& gms() { 00210 return gms_; 00211 } 00213 const DMatrixSlice& gms() const { 00214 return gms_; 00215 } 00217 BLAS_Cpp::Uplo uplo() const { 00218 return uplo_; 00219 } 00221 DMatrixSliceSym* operator&() { 00222 return this; 00223 } 00224 const DMatrixSliceSym* operator&() const { 00225 return this; 00226 } 00227 00228 private: 00229 DMatrixSlice gms_; 00230 BLAS_Cpp::Uplo uplo_; 00231 // not defined and not to be called 00232 DMatrixSliceSym(); 00233 DMatrixSliceSym& operator=(const DMatrixSliceTri&); 00234 }; // end class DMatrixSliceSym 00235 00236 inline 00238 DMatrixSliceSym nonconst_sym(DMatrixSlice gms, BLAS_Cpp::Uplo uplo) 00239 { 00240 return DMatrixSliceSym(gms, uplo); 00241 } 00242 00243 inline 00245 const DMatrixSliceSym sym(const DMatrixSlice& gms, BLAS_Cpp::Uplo uplo) 00246 { 00247 return DMatrixSliceSym(gms, uplo); 00248 } 00249 00250 // @} 00251 00252 } // end namespace DenseLinAlgPack 00253 00254 #endif // GEN_MATRIX_AS_TRI_SYM_H
1.7.4