|
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 LIN_ALG_OP_PACK_DECL_H 00030 #define LIN_ALG_OP_PACK_DECL_H 00031 00032 #include "DenseLinAlgPack_DVectorOp.hpp" 00033 #include "DenseLinAlgPack_DMatrixOp.hpp" 00034 00035 namespace LinAlgOpPack { 00036 00037 typedef DenseLinAlgPack::value_type value_type; 00038 00039 using DenseLinAlgPack::DVector; 00040 using DenseLinAlgPack::DVectorSlice; 00041 using DenseLinAlgPack::DMatrix; 00042 using DenseLinAlgPack::DMatrixSlice; 00043 00044 using DenseLinAlgPack::Vt_S; 00045 using DenseLinAlgPack::Vp_StV; 00046 using DenseLinAlgPack::Vp_StMtV; 00047 using DenseLinAlgPack::V_InvMtV; 00048 using DenseLinAlgPack::Mp_StM; 00049 using DenseLinAlgPack::Mp_StMtM; 00050 using DenseLinAlgPack::M_StInvMtM; 00051 00052 // ////////////////////////////////////////////////////////////////////////////// 00053 // ////////////////////////////////////////////////////////////////////////////// 00054 /* * @name Default Linear Algebra implementation operations. 00055 * 00056 * These are template functions that can be used to perform simpler 00057 * linear algebra operations given more elaborate ones. The idea is that 00058 * for each combination of vector and matrix types, the BLAS like operations 00059 * must be provided and then these template functions provide related 00060 * linear algebra operations. The user can override these default implementations 00061 * by defining the exact functions himself. 00062 * 00063 * Warning\\ 00064 * In general it is not allowed for the lhs argument to be used in the rhs expression. 00065 * Concidering aliasing would have make the operations much more complicated. 00066 * So unless you are sure that it is okay, do not use a vector or matrix object 00067 * in both the lhs and rhs expressions. 00068 * 00069 * The nameing covension for these functions is the same as for the linear algebra 00070 * functions for #DVectorSlice# and #DMatrixSlice#. 00071 */ 00072 // @{ 00073 00074 // ////////////////////////////////////////////////////////////////////////////// 00075 // /////////////////////////////////////////////////////////////////////////////// 00076 /* * @name Level 1 BLAS for Vectors 00077 * 00078 * For these functions to work for the type V the following function must 00079 * be defined: 00080 * 00081 * // vs_lhs += alpha * V_rhs \\ 00082 * void Vp_StV(DVectorSlice* vs_lhs, value_type alpha, const V& V_rhs); 00083 * 00084 * The rest of these level 1 BLAS functions implement the variations. 00085 */ 00086 // @{ 00087 00088 // ////////////////////////////////////////////////////////////////////////////// 00089 /* * @name += operations 00090 */ 00091 // @{ 00092 00094 /* * vs_lhs += V_rhs. 00095 * 00096 * Calls: #Vp_StV(vs_lhs,1.0,V_rhs);# 00097 */ 00098 template <class V> 00099 void Vp_V(DVectorSlice* vs_lhs, const V& V_rhs); 00100 00101 // end += operations 00102 // @} 00103 00104 // ////////////////////////////////////////////////////////////////////////////// 00105 /* * @name = operations with DVector as lhs 00106 */ 00107 // @{ 00108 00110 /* * v_lhs = V_rhs. 00111 * 00112 * Calls: #Vp_V(&(*v_lhs)(),V_rhs);# 00113 */ 00114 template <class V> 00115 void assign(DVector* v_lhs, const V& V_rhs); 00116 00118 /* * v_lhs = alpha * V_rhs. 00119 * 00120 * Calls: #Vp_StV(&(*v_lhs)(),alpha,V_rhs);# 00121 */ 00122 template <class V> 00123 void V_StV(DVector* v_lhs, value_type alpha, const V& V_rhs); 00124 00126 /* * v_lhs = - V_rhs. 00127 * 00128 * Calls: #V_StV(&(*v_lhs)(),-1.0,V_rhs);# 00129 */ 00130 template <class V> 00131 void V_mV(DVector* v_lhs, const V& V_rhs); 00132 00134 /* * v_lhs = V1_rhs1 + V2_rhs2. 00135 * 00136 * Calls: #Vp_V(&(*v_lhs)(),V1_rhs1); Vp_V(&(*v_lhs)(),V1_rhs2);# 00137 */ 00138 template <class V1, class V2> 00139 void V_VpV(DVector* v_lhs, const V1& V1_rhs1, const V2& V2_rhs2); 00140 00142 /* * v_lhs = V_rhs1 - V_rhs2. 00143 * 00144 * Calls: #Vp_V(&(*v_lhs)(),V1_rhs1); Vp_StV(&(*v_lhs)(),-1.0,V2_rhs2);# 00145 */ 00146 template <class V1, class V2> 00147 void V_VmV(DVector* v_lhs, const V1& V1_rhs1, const V2& V2_rhs2); 00149 /* * v_lhs = alpha * V_rhs1 + vs_rhs2. 00150 * 00151 * Calls: #Vp_StV(&(*v_lhs)(),alpha,V_rhs1);# 00152 */ 00153 template <class V> 00154 void V_StVpV(DVector* v_lhs, value_type alpha, const V& V_rhs1 00155 , const DVectorSlice& vs_rhs2); 00156 00157 // end = operations with DVector as lhs 00158 // @} 00159 00160 // ////////////////////////////////////////////////////////////////////////////// 00161 /* * @name = operations with DVectorSlice as lhs 00162 */ 00163 // @{ 00164 00166 /* * vs_lhs = V_rhs. 00167 * 00168 * Calls: #Vp_V(vs_lhs,V_rhs);# 00169 */ 00170 template <class V> 00171 void assign(DVectorSlice* vs_lhs, const V& V_rhs); 00172 00174 /* * vs_lhs = alpha * V_rhs. 00175 * 00176 * Calls: #Vp_StV(vs_lhs,alpha,V_rhs);# 00177 */ 00178 template <class V> 00179 void V_StV(DVectorSlice* vs_lhs, value_type alpha, const V& V_rhs); 00180 00182 /* * vs_lhs = - V_rhs. 00183 * 00184 * Calls: #V_StV(vs_lhs,-1.0,V_rhs);# 00185 */ 00186 template <class V> 00187 void V_mV(DVectorSlice* vs_lhs, const V& V_rhs); 00188 00190 /* * vs_lhs = V1_rhs1 + V2_rhs2. 00191 * 00192 * Calls: #Vp_V(vs_lhs,V1_rhs1); Vp_V(vs_lhs,V1_rhs2);# 00193 */ 00194 template <class V1, class V2> 00195 void V_VpV(DVectorSlice* vs_lhs, const V1& V1_rhs1, const V2& V2_rhs2); 00196 00198 /* * vs_lhs = V_rhs1 - V_rhs2. 00199 * 00200 * Calls: #Vp_V(vs_lhs,V1_rhs1); Vp_StV(vs_lhs,-1.0,V2_rhs2);# 00201 */ 00202 template <class V1, class V2> 00203 void V_VmV(DVectorSlice* vs_lhs, const V1& V1_rhs1, const V2& V2_rhs2); 00204 00206 /* * vs_lhs = alpha * V_rhs1 + vs_rhs2. 00207 * 00208 * Calls: #Vp_StV(vs_lhs,alpha,V_rhs1);# 00209 */ 00210 template <class V> 00211 void V_StVpV(DVectorSlice* vs_lhs, value_type alpha, const V& V_rhs1 00212 , const DVectorSlice& vs_rhs2); 00213 00214 // end = operations with DVectorSlice as lhs 00215 // @} 00216 00217 // end Level 1 BLAS for Vectors 00218 // @} 00219 00220 // ////////////////////////////////////////////////////////////////////////////// 00221 // /////////////////////////////////////////////////////////////////////////////// 00222 /* * @name Level 1 BLAS for Matrices 00223 * 00224 * For these functions to work for the type M the following function must 00225 * be defined: 00226 * 00227 * // gms_lhs += alpha * op(M_rhs) \\ 00228 * void Mp_StM(DMatrixSlice* vs_lhs, value_type alpha, const V& V_rhs, BLAS_Cpp::Transp); 00229 * 00230 * The rest of these level 1 BLAS functions implement the variations. 00231 */ 00232 // @{ 00233 00234 // ////////////////////////////////////////////////////////////////////////////// 00235 /* * @name += operations 00236 */ 00237 // @{ 00238 00240 /* * gms_lhs += op(M_rhs). 00241 * 00242 * Calls: #Mp_StM(gms_lhs,1.0,M_rhs,trans_rhs);# 00243 */ 00244 template <class M> 00245 void Mp_M(DMatrixSlice* gms_lhs, const M& M_rhs, BLAS_Cpp::Transp trans_rhs); 00246 00247 // end += operations 00248 // @} 00249 00250 // ////////////////////////////////////////////////////////////////////////////// 00251 /* * @name = operations with DMatrix as lhs 00252 */ 00253 // @{ 00254 00256 /* * gm_lhs = op(M_rhs). 00257 * 00258 * Calls: #Mp_M(&(*gm_lhs)(),M_rhs,trans_rhs);# 00259 */ 00260 template <class M> 00261 void assign(DMatrix* gm_lhs, const M& M_rhs, BLAS_Cpp::Transp trans_rhs); 00262 00264 /* * gm_lhs = alpha * M_rhs. 00265 * 00266 * Calls: #Mp_StM(&(*gm_lhs)(),alpha,M_rhs,trans_rhs);# 00267 */ 00268 template <class M> 00269 void M_StM(DMatrix* v_lhs, value_type alpha, const M& M_rhs 00270 , BLAS_Cpp::Transp trans_rhs); 00271 00273 /* * gm_lhs = - op(M_rhs). 00274 * 00275 * Calls: #M_StM(&(*gm_lhs)(),-1.0,M_rhs,trans_rhs);# 00276 */ 00277 template <class M> 00278 void M_mM(DMatrix* gm_lhs, const M& M_rhs, BLAS_Cpp::Transp trans_rhs) ; 00279 00281 /* * gm_lhs = op(M1_rhs1) + op(M2_rhs2). 00282 * 00283 * Calls: #Mp_M(&(*gm_lhs)(),M1_rhs1,trans_rhs1); Mp_M(&(*gm_lhs)(),M1_rhs2,trans_rhs2);# 00284 */ 00285 template <class M1, class M2> 00286 void M_MpM(DMatrix* gm_lhs, const M1& M1_rhs1, BLAS_Cpp::Transp trans_rhs1 00287 , const M2& M2_rhs2, BLAS_Cpp::Transp trans_rhs2); 00288 00290 /* * gm_lhs = op(M_rhs1) - op(M_rhs2). 00291 * 00292 * Calls: #Mp_M(&(*gm_lhs)(),M1_rhs1,trans_rhs1); Mp_StM(&(*gm_lhs)(),-1.0,M2_rhs2,trans_rhs2);# 00293 */ 00294 template <class M1, class M2> 00295 void M_MmM(DMatrix* gm_lhs, const M1& M1_rhs1, BLAS_Cpp::Transp trans_rhs1 00296 , const M2& M2_rhs2, BLAS_Cpp::Transp trans_rhs2); 00297 00299 /* * gm_lhs = alpha * op(M_rhs1) + op(gms_rhs2). 00300 * 00301 * Calls: #Mp_StM(&(*gm_lhs)(),alpha,M_rhs1,trans_rhs1);# 00302 */ 00303 template <class M> 00304 void M_StMpM(DMatrix* gm_lhs, value_type alpha, const M& M_rhs1, BLAS_Cpp::Transp trans_rhs1 00305 , const DMatrixSlice& gms_rhs2, BLAS_Cpp::Transp trans_rhs2); 00306 00307 // end = operations with DMatrix as lhs 00308 // @} 00309 00310 // ////////////////////////////////////////////////////////////////////////////// 00311 /* * @name = operations with DMatrixSlice as lhs 00312 */ 00313 // @{ 00314 00316 /* * gms_lhs = op(M_rhs). 00317 * 00318 * Calls: #Mp_M(gms_lhs,M_rhs,trans_rhs);# 00319 */ 00320 template <class M> 00321 void assign(DMatrixSlice* gms_lhs, const M& M_rhs, BLAS_Cpp::Transp trans_rhs); 00322 00324 /* * gm_lhs = alpha * M_rhs. 00325 * 00326 * Calls: #Mp_StM(&(*gm_lhs)(),alpha,M_rhs,trans_rhs);# 00327 */ 00328 template <class M> 00329 void M_StM(DMatrixSlice* gms_lhs, value_type alpha, const M& M_rhs 00330 , BLAS_Cpp::Transp trans_rhs); 00331 00333 /* * gm_lhs = - op(M_rhs). 00334 * 00335 * Calls: #M_StM(&(*gm_lhs)(),-1.0,M_rhs,trans_rhs);# 00336 */ 00337 template <class M> 00338 void M_mM(DMatrixSlice* gms_lhs, const M& M_rhs, BLAS_Cpp::Transp trans_rhs) ; 00339 00341 /* * gms_lhs = op(M1_rhs1) + op(M2_rhs2). 00342 * 00343 * Calls: #Mp_M(gms_lhs,M1_rhs1,trans_rhs1); Mp_M(gms_lhs,M1_rhs2,trans_rhs2);# 00344 */ 00345 template <class M1, class M2> 00346 void M_MpM(DMatrixSlice* gms_lhs, const M1& M1_rhs1, BLAS_Cpp::Transp trans_rhs1 00347 , const M2& M2_rhs2, BLAS_Cpp::Transp trans_rhs2); 00348 00350 /* * gms_lhs = op(M_rhs1) - op(M_rhs2). 00351 * 00352 * Calls: #Mp_M(gms_lhs,M1_rhs1,trans_rhs1); Mp_StM(gms_lhs,-1.0,M2_rhs2,trans_rhs2);# 00353 */ 00354 template <class M1, class M2> 00355 void M_MmM(DMatrixSlice* gms_lhs, const M1& M1_rhs1, BLAS_Cpp::Transp trans_rhs1 00356 , const M2& M2_rhs2, BLAS_Cpp::Transp trans_rhs2); 00357 00359 /* * gms_lhs = alpha * op(M_rhs1) + op(gms_rhs2). 00360 * 00361 * Calls: #Mp_StM(gms_lhs,alpha,M_rhs1,trans_rhs1);# 00362 */ 00363 template <class M> 00364 void M_StMpM(DMatrixSlice* gms_lhs, value_type alpha, const M& M_rhs1, BLAS_Cpp::Transp trans_rhs1 00365 , const DMatrixSlice& gms_rhs2, BLAS_Cpp::Transp trans_rhs2); 00366 00367 // end = operations with DMatrixSlice as lhs 00368 // @} 00369 00370 // end Level 1 BLAS for Matrices 00371 // @} 00372 00373 // ////////////////////////////////////////////////////////////////////////////// 00374 // /////////////////////////////////////////////////////////////////////// 00375 /* * @name Level 2 BLAS 00376 * 00377 * These operations implement variations on the Level-2 BLAS operation:\\ 00378 * 00379 * vs_lhs = alpha * op(M_rhs1) * V_rhs2 + beta * vs_lhs 00380 */ 00381 // @{ 00382 00383 // ////////////////////////////////////////////////////////////////////////////// 00384 /* * @name += operations 00385 */ 00386 // @{ 00387 00389 /* * vs_lhs += op(M_rhs1) * V_rhs2. 00390 * 00391 * Calls: #Vp_StMtV(vs_lhs,1.0,M_rhs1,trans_rhs1,V_rhs2);# 00392 */ 00393 template <class M, class V> 00394 void Vp_MtV(DVectorSlice* vs_lhs, const M& M_rhs1, BLAS_Cpp::Transp trans_rhs1 00395 , const V& V_rhs2); 00396 00398 /* * vs_lhs = op(M_rhs1) * V_rhs2 + beta * vs_lhs. 00399 * 00400 * Calls: #Vp_StMtV(vs_lhs,1.0,M_rhs1,trans_rhs1,V_rhs2,beta);# 00401 */ 00402 template <class M, class V> 00403 void Vp_MtV(DVectorSlice* vs_lhs, const M& M_rhs1, BLAS_Cpp::Transp trans_rhs1 00404 , const V& V_rhs2, value_type beta); 00405 00406 // end += operations 00407 // @} 00408 00409 // ////////////////////////////////////////////////////////////////////////////// 00410 /* * @name = operations with DVector as lhs 00411 */ 00412 // @{ 00413 00415 /* * v_lhs = alpha * op(M_rhs1) * V_rhs2. 00416 * 00417 * Calls: #Vp_StMtV(&(*v_lhs)(),alpha,M_rhs1,trans_rhs1,V_rhs2);# 00418 */ 00419 template <class M, class V> 00420 void V_StMtV(DVector* v_lhs, value_type alpha, const M& M_rhs1 00421 , BLAS_Cpp::Transp trans_rhs1, const V& V_rhs2); 00422 00424 /* * v_lhs = op(M_rhs1) * V_rhs2. 00425 * 00426 * Calls: #Vp_MtV(&(*v_lhs)(),M_rhs1,trans_rhs1,V_rhs2);# 00427 */ 00428 template <class M, class V> 00429 void V_MtV(DVector* v_lhs, const M& M_rhs1, BLAS_Cpp::Transp trans_rhs1 00430 , const V& V_rhs2); 00431 00432 // end = operations with DVector as lhs 00433 // @} 00434 00435 // ////////////////////////////////////////////////////////////////////////////// 00436 /* * @name = operations with DVectorSlice as lhs 00437 */ 00438 // @{ 00439 00441 /* * vs_lhs = alpha * op(M_rhs1) * V_rhs2. 00442 * 00443 * Calls: #Vp_StMtV(vs_lhs,alpha,M_rhs1,trans_rhs1,V_rhs2);# 00444 */ 00445 template <class M, class V> 00446 void V_StMtV(DVectorSlice* vs_lhs, value_type alpha, const M& M_rhs1 00447 , BLAS_Cpp::Transp trans_rhs1, const V& V_rhs2); 00448 00450 /* * vs_lhs = op(M_rhs1) * V_rhs2. 00451 * 00452 * Calls: #Vp_MtV(vs_lhs,M_rhs1,trans_rhs1,V_rhs2);# 00453 */ 00454 template <class M, class V> 00455 void V_MtV(DVectorSlice* vs_lhs, const M& M_rhs1, BLAS_Cpp::Transp trans_rhs1 00456 , const V& V_rhs2); 00457 00458 // end = operations with DVectorSlice as lhs 00459 // @} 00460 00461 // end Level 2 BLAS 00462 // @} 00463 00464 // ////////////////////////////////////////////////////////////////////////////// 00465 // ////////////////////////////////////////////////////////////////////////////// 00466 /* * @name Level 3 BLAS 00467 * 00468 * These operations are based on the Level-3 BLAS operation: 00469 * 00470 * gms_lhs = alpha * op(M1_rhs1) * op(M2_rhs2) + beta * gms_lhs 00471 */ 00472 // @{ 00473 00474 // ////////////////////////////////////////////////////////////////////////////// 00475 /* * @name += operations 00476 */ 00477 // @{ 00478 00480 /* * gms_lhs += op(M1_rhs1) * op(M2_rhs2). 00481 * 00482 * Calls: #Mp_StMtM(gms_lhs,1.0,M1_rhs1,trans_rhs1,M2_rhs2,trans_rhs2);# 00483 */ 00484 template <class M1, class M2> 00485 void Mp_MtM(DMatrixSlice* gms_lhs, const M1& M1_rhs1, BLAS_Cpp::Transp trans_rhs1 00486 , const M2& M2_rhs2, BLAS_Cpp::Transp trans_rhs2); 00487 00489 /* * gms_lhs = op(M1_rhs1) * op(M2_rhs2) + beta * gms_rhs. 00490 * 00491 * Calls: #Mp_StMtM(gms_lhs,1.0,M1_rhs1,trans_rhs1,M2_rhs2,trans_rhs2,beta);# 00492 */ 00493 template <class M1, class M2> 00494 void Mp_MtM(DMatrixSlice* gms_lhs, const M1& M1_rhs1, BLAS_Cpp::Transp trans_rhs1 00495 , const M2& M2_rhs2, BLAS_Cpp::Transp trans_rhs2, value_type beta); 00496 00497 // end += operations 00498 // @} 00499 00500 // ////////////////////////////////////////////////////////////////////////////// 00501 /* * @name = operations with DMatrix as lhs 00502 */ 00503 // @{ 00504 00506 /* * gm_lhs = alpha * op(M1_rhs1) * op(M2_rhs2). 00507 * 00508 * Calls: #Mp_StMtM(&(*gm_lhs)(),alpha,M1_rhs1,trans_rhs1,M2_rhs2,trans_rhs2);# 00509 */ 00510 template <class M1, class M2> 00511 void M_StMtM(DMatrix* gm_lhs, value_type alpha, const M1& M1_rhs1 00512 , BLAS_Cpp::Transp trans_rhs1, const M2& M2_rhs2, BLAS_Cpp::Transp trans_rhs2); 00513 00515 /* * gm_lhs = op(M1_rhs1) * op(M2_rhs2). 00516 * 00517 * Calls: #Mp_MtM(&(*gm_lhs)(),M1_rhs1,trans_rhs1,M2_rhs2,trans_rhs2);# 00518 */ 00519 template <class M1, class M2> 00520 void M_MtM(DMatrix* gm_lhs, const M1& M1_rhs1 00521 , BLAS_Cpp::Transp trans_rhs1, const M2& M2_rhs2, BLAS_Cpp::Transp trans_rhs2); 00522 00523 // end = operations with DMatrix as lhs 00524 // @} 00525 00526 // ////////////////////////////////////////////////////////////////////////////// 00527 /* * @name = operations with DMatrixSlice as lhs 00528 */ 00529 // @{ 00530 00532 /* * gms_lhs = alpha * op(M1_rhs1) * op(M2_rhs2). 00533 * 00534 * Calls: #Mp_StMtM(gms_lhs,alpha,M1_rhs1,trans_rhs1,M2_rhs2,trans_rhs2);# 00535 */ 00536 template <class M1, class M2> 00537 void M_StMtM(DMatrixSlice* gms_lhs, value_type alpha, const M1& M1_rhs1 00538 , BLAS_Cpp::Transp trans_rhs1, const M2& M2_rhs2, BLAS_Cpp::Transp trans_rhs2); 00539 00541 /* * gms_lhs = op(M1_rhs1) * op(M2_rhs2). 00542 * 00543 * Calls: #Mp_MtM(gms_lhs,M1_rhs1,trans_rhs1,M2_rhs2,trans_rhs2);# 00544 */ 00545 template <class M1, class M2> 00546 void M_MtM(DMatrixSlice* gms_lhs, const M1& M1_rhs1 00547 , BLAS_Cpp::Transp trans_rhs1, const M2& M2_rhs2, BLAS_Cpp::Transp trans_rhs2); 00548 // end = operations with DMatrixSlice as lhs 00549 // @} 00550 00551 // end Level 3 BLAS 00552 // @} 00553 00554 // end Default Linear Algebra Implementations 00555 // @} 00556 00557 // /////////////////////////////////////////////////////////////////////////// 00558 // /////////////////////////////////////////////////////////////////////////// 00559 // Inline definitions 00560 00561 // /////////////////////////////////////////////////////////////////////////////// 00562 // Level 1 BLAS for Vectors 00563 00564 // vs_lhs += V_rhs. 00565 template <class V> 00566 inline 00567 void Vp_V(DVectorSlice* vs_lhs, const V& V_rhs) { 00568 Vp_StV(vs_lhs,1.0,V_rhs); 00569 } 00570 00571 // v_lhs = - V_rhs. 00572 template <class V> 00573 inline 00574 void V_mV(DVector* v_lhs, const V& V_rhs) { 00575 V_StV(v_lhs,-1.0,V_rhs); 00576 } 00577 00578 // vs_lhs = - V_rhs. 00579 template <class V> 00580 inline 00581 void V_mV(DVectorSlice* vs_lhs, const V& V_rhs) { 00582 V_StV(vs_lhs,-1.0,V_rhs); 00583 } 00584 00585 // /////////////////////////////////////////////////////////////////////////////// 00586 // Level 1 BLAS for Matrices 00587 00588 // gms_lhs += op(M_rhs). 00589 template <class M> 00590 inline 00591 void Mp_M(DMatrixSlice* gms_lhs, const M& M_rhs, BLAS_Cpp::Transp trans_rhs) { 00592 Mp_StM(gms_lhs,1.0,M_rhs,trans_rhs); 00593 } 00594 00595 // gm_lhs = - op(M_rhs). 00596 template <class M> 00597 inline 00598 void M_mM(DMatrix* gm_lhs, const M& M_rhs, BLAS_Cpp::Transp trans_rhs) { 00599 M_StM(gm_lhs,-1.0,M_rhs,trans_rhs); 00600 } 00601 00602 // gms_lhs = - op(M_rhs). 00603 template <class M> 00604 inline 00605 void M_mM(DMatrixSlice* gms_lhs, const M& M_rhs, BLAS_Cpp::Transp trans_rhs) { 00606 M_StM(gms_lhs,-1.0,M_rhs,trans_rhs); 00607 } 00608 00609 // /////////////////////////////////////////////////////////////////////// 00610 // Level 2 BLAS 00611 00612 // vs_lhs += op(M_rhs1) * V_rhs2. 00613 template <class M, class V> 00614 inline 00615 void Vp_MtV(DVectorSlice* vs_lhs, const M& M_rhs1, BLAS_Cpp::Transp trans_rhs1 00616 , const V& V_rhs2) 00617 { 00618 Vp_StMtV(vs_lhs,1.0,M_rhs1,trans_rhs1,V_rhs2); 00619 } 00620 00621 // vs_lhs = op(M_rhs1) * V_rhs2 + beta * vs_lhs. 00622 template <class M, class V> 00623 inline 00624 void Vp_MtV(DVectorSlice* vs_lhs, const M& M_rhs1, BLAS_Cpp::Transp trans_rhs1 00625 , const V& V_rhs2, value_type beta) 00626 { 00627 Vp_StMtV(vs_lhs,1.0,M_rhs1,trans_rhs1,V_rhs2,beta); 00628 } 00629 00630 // ////////////////////////////////////////////////////////////////////////////// 00631 // Level 3 BLAS 00632 00633 // gms_lhs += op(M1_rhs1) * op(M2_rhs2). 00634 template <class M1, class M2> 00635 inline 00636 void Mp_MtM(DMatrixSlice* gms_lhs, const M1& M1_rhs1, BLAS_Cpp::Transp trans_rhs1 00637 , const M2& M2_rhs2, BLAS_Cpp::Transp trans_rhs2) 00638 { 00639 Mp_StMtM(gms_lhs,1.0,M1_rhs1,trans_rhs1,M2_rhs2,trans_rhs2); 00640 } 00641 00642 // gms_lhs = op(M1_rhs1) * op(M2_rhs2) + beta * gms_rhs. 00643 template <class M1, class M2> 00644 inline 00645 void Mp_MtM(DMatrixSlice* gms_lhs, const M1& M1_rhs1, BLAS_Cpp::Transp trans_rhs1 00646 , const M2& M2_rhs2, BLAS_Cpp::Transp trans_rhs2, value_type beta) 00647 { 00648 Mp_StMtM(gms_lhs,1.0,M1_rhs1,trans_rhs1,M2_rhs2,trans_rhs2,beta); 00649 } 00650 00651 00652 } // end namespace LinAlgOpPack 00653 00654 00655 #endif // LIN_ALG_OP_PACK_DECL_H
1.7.4