|
Anasazi Version of the Day
|
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_CombineFortran_hpp 00030 #define __TSQR_CombineFortran_hpp 00031 00032 #include <Tsqr_ApplyType.hpp> 00033 #include <Tsqr_MatView.hpp> 00034 #include <Tsqr_ScalarTraits.hpp> 00035 #include <Tsqr_CombineDefault.hpp> 00036 00039 00040 namespace TSQR { 00041 00051 template< class Scalar, bool is_complex = ScalarTraits< Scalar >::is_complex > 00052 class CombineFortran { 00053 private: 00054 typedef CombineDefault< int, Scalar > combine_default_type; 00055 00056 public: 00057 typedef Scalar scalar_type; 00058 typedef typename ScalarTraits< Scalar >::magnitude_type magnitude_type; 00059 typedef int ordinal_type; 00060 00061 CombineFortran () {} 00062 00066 static bool QR_produces_R_factor_with_nonnegative_diagonal(); 00067 00068 void 00069 factor_first (const ordinal_type nrows, 00070 const ordinal_type ncols, 00071 Scalar A[], 00072 const ordinal_type lda, 00073 Scalar tau[], 00074 Scalar work[]) const; 00075 00076 void 00077 apply_first (const ApplyType& applyType, 00078 const ordinal_type nrows, 00079 const ordinal_type ncols_C, 00080 const ordinal_type ncols_A, 00081 const Scalar A[], 00082 const ordinal_type lda, 00083 const Scalar tau[], 00084 Scalar C[], 00085 const ordinal_type ldc, 00086 Scalar work[]) const; 00087 00088 void 00089 apply_inner (const ApplyType& apply_type, 00090 const ordinal_type m, 00091 const ordinal_type ncols_C, 00092 const ordinal_type ncols_Q, 00093 const Scalar A[], 00094 const ordinal_type lda, 00095 const Scalar tau[], 00096 Scalar C_top[], 00097 const ordinal_type ldc_top, 00098 Scalar C_bot[], 00099 const ordinal_type ldc_bot, 00100 Scalar work[]) const; 00101 00102 void 00103 factor_inner (const ordinal_type m, 00104 const ordinal_type n, 00105 Scalar R[], 00106 const ordinal_type ldr, 00107 Scalar A[], 00108 const ordinal_type lda, 00109 Scalar tau[], 00110 Scalar work[]) const; 00111 00112 void 00113 factor_pair (const ordinal_type n, 00114 Scalar R_top[], 00115 const ordinal_type ldr_top, 00116 Scalar R_bot[], 00117 const ordinal_type ldr_bot, 00118 Scalar tau[], 00119 Scalar work[]) const; 00120 00121 void 00122 apply_pair (const ApplyType& apply_type, 00123 const ordinal_type ncols_C, 00124 const ordinal_type ncols_Q, 00125 const Scalar R_bot[], 00126 const ordinal_type ldr_bot, 00127 const Scalar tau[], 00128 Scalar C_top[], 00129 const ordinal_type ldc_top, 00130 Scalar C_bot[], 00131 const ordinal_type ldc_bot, 00132 Scalar work[]) const; 00133 00134 private: 00135 mutable combine_default_type default_; 00136 }; 00137 00140 template< class Scalar > 00141 class CombineFortran< Scalar, false > { 00142 private: 00143 typedef CombineDefault< int, Scalar > combine_default_type; 00144 00145 public: 00146 typedef Scalar scalar_type; 00147 typedef typename ScalarTraits< Scalar >::magnitude_type magnitude_type; 00148 typedef int ordinal_type; 00149 00150 CombineFortran () {} 00151 00152 static bool QR_produces_R_factor_with_nonnegative_diagonal() { 00153 typedef LAPACK< int, Scalar > lapack_type; 00154 00155 return lapack_type::QR_produces_R_factor_with_nonnegative_diagonal() && 00156 combine_default_type::QR_produces_R_factor_with_nonnegative_diagonal(); 00157 } 00158 00159 void 00160 factor_first (const ordinal_type nrows, 00161 const ordinal_type ncols, 00162 Scalar A[], 00163 const ordinal_type lda, 00164 Scalar tau[], 00165 Scalar work[]) const 00166 { 00167 return default_.factor_first (nrows, ncols, A, lda, tau, work); 00168 } 00169 00170 void 00171 apply_first (const ApplyType& applyType, 00172 const ordinal_type nrows, 00173 const ordinal_type ncols_C, 00174 const ordinal_type ncols_A, 00175 const Scalar A[], 00176 const ordinal_type lda, 00177 const Scalar tau[], 00178 Scalar C[], 00179 const ordinal_type ldc, 00180 Scalar work[]) const 00181 { 00182 return default_.apply_first (applyType, nrows, ncols_C, ncols_A, 00183 A, lda, tau, 00184 C, ldc, work); 00185 } 00186 00187 void 00188 apply_inner (const ApplyType& apply_type, 00189 const ordinal_type m, 00190 const ordinal_type ncols_C, 00191 const ordinal_type ncols_Q, 00192 const Scalar A[], 00193 const ordinal_type lda, 00194 const Scalar tau[], 00195 Scalar C_top[], 00196 const ordinal_type ldc_top, 00197 Scalar C_bot[], 00198 const ordinal_type ldc_bot, 00199 Scalar work[]) const; 00200 00201 void 00202 factor_inner (const ordinal_type m, 00203 const ordinal_type n, 00204 Scalar R[], 00205 const ordinal_type ldr, 00206 Scalar A[], 00207 const ordinal_type lda, 00208 Scalar tau[], 00209 Scalar work[]) const; 00210 00211 void 00212 factor_pair (const ordinal_type n, 00213 Scalar R_top[], 00214 const ordinal_type ldr_top, 00215 Scalar R_bot[], 00216 const ordinal_type ldr_bot, 00217 Scalar tau[], 00218 Scalar work[]) const; 00219 00220 void 00221 apply_pair (const ApplyType& apply_type, 00222 const ordinal_type ncols_C, 00223 const ordinal_type ncols_Q, 00224 const Scalar R_bot[], 00225 const ordinal_type ldr_bot, 00226 const Scalar tau[], 00227 Scalar C_top[], 00228 const ordinal_type ldc_top, 00229 Scalar C_bot[], 00230 const ordinal_type ldc_bot, 00231 Scalar work[]) const; 00232 00233 private: 00234 mutable combine_default_type default_; 00235 }; 00236 00237 00242 template< class Scalar > 00243 class CombineFortran< Scalar, true > { 00244 private: 00245 typedef CombineDefault< int, Scalar > combine_default_type; 00246 00247 public: 00248 typedef Scalar scalar_type; 00249 typedef typename ScalarTraits< Scalar >::magnitude_type magnitude_type; 00250 typedef int ordinal_type; 00251 00252 CombineFortran () {} 00253 00254 static bool QR_produces_R_factor_with_nonnegative_diagonal() { 00255 return combine_default_type::QR_produces_R_factor_with_nonnegative_diagonal(); 00256 } 00257 00258 void 00259 factor_first (const ordinal_type nrows, 00260 const ordinal_type ncols, 00261 Scalar A[], 00262 const ordinal_type lda, 00263 Scalar tau[], 00264 Scalar work[]) const 00265 { 00266 return default_.factor_first (nrows, ncols, A, lda, tau, work); 00267 } 00268 00269 void 00270 apply_first (const ApplyType& applyType, 00271 const ordinal_type nrows, 00272 const ordinal_type ncols_C, 00273 const ordinal_type ncols_A, 00274 const Scalar A[], 00275 const ordinal_type lda, 00276 const Scalar tau[], 00277 Scalar C[], 00278 const ordinal_type ldc, 00279 Scalar work[]) const 00280 { 00281 return default_.apply_first (applyType, nrows, ncols_C, ncols_A, 00282 A, lda, tau, 00283 C, ldc, work); 00284 } 00285 00286 void 00287 apply_inner (const ApplyType& apply_type, 00288 const ordinal_type m, 00289 const ordinal_type ncols_C, 00290 const ordinal_type ncols_Q, 00291 const Scalar A[], 00292 const ordinal_type lda, 00293 const Scalar tau[], 00294 Scalar C_top[], 00295 const ordinal_type ldc_top, 00296 Scalar C_bot[], 00297 const ordinal_type ldc_bot, 00298 Scalar work[]) const 00299 { 00300 default_.apply_inner (apply_type, m, ncols_C, ncols_Q, 00301 A, lda, tau, 00302 C_top, ldc_top, C_bot, ldc_bot, work); 00303 } 00304 00305 void 00306 factor_inner (const ordinal_type m, 00307 const ordinal_type n, 00308 Scalar R[], 00309 const ordinal_type ldr, 00310 Scalar A[], 00311 const ordinal_type lda, 00312 Scalar tau[], 00313 Scalar work[]) const 00314 { 00315 default_.factor_inner (m, n, R, ldr, A, lda, tau, work); 00316 } 00317 00318 void 00319 factor_pair (const ordinal_type n, 00320 Scalar R_top[], 00321 const ordinal_type ldr_top, 00322 Scalar R_bot[], 00323 const ordinal_type ldr_bot, 00324 Scalar tau[], 00325 Scalar work[]) const 00326 { 00327 default_.factor_pair (n, R_top, ldr_top, R_bot, ldr_bot, tau, work); 00328 } 00329 00330 void 00331 apply_pair (const ApplyType& apply_type, 00332 const ordinal_type ncols_C, 00333 const ordinal_type ncols_Q, 00334 const Scalar R_bot[], 00335 const ordinal_type ldr_bot, 00336 const Scalar tau[], 00337 Scalar C_top[], 00338 const ordinal_type ldc_top, 00339 Scalar C_bot[], 00340 const ordinal_type ldc_bot, 00341 Scalar work[]) const 00342 { 00343 default_.apply_pair (apply_type, ncols_C, ncols_Q, 00344 R_bot, ldr_bot, tau, 00345 C_top, ldc_top, C_bot, ldc_bot, work); 00346 } 00347 00348 private: 00354 mutable CombineDefault< ordinal_type, scalar_type > default_; 00355 }; 00356 00357 00358 } // namespace TSQR 00359 00360 #endif // __TSQR_CombineFortran_hpp
1.7.4