|
AbstractLinAlgPack: C++ Interfaces For Vectors, Matrices And Related Linear Algebra Objects 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 00030 #ifndef SPARSE_VECTOR_SLICE_OP_H 00031 #define SPARSE_VECTOR_SLICE_OP_H 00032 00033 #include "AbstractLinAlgPack_SparseVectorOp.hpp" 00034 #include "DenseLinAlgPack_AssertOp.hpp" 00035 #include "DenseLinAlgPack_DVectorOp.hpp" 00036 00037 namespace AbstractLinAlgPack { 00038 00061 00062 00063 00065 template<class T_Ele> 00066 inline 00067 value_type dot(const DVectorSlice& vs_rhs1, const SparseVectorSlice<T_Ele>& sv_rhs2) 00068 { 00069 return dot_V_SV(vs_rhs1, sv_rhs2); 00070 } 00071 00073 template<class T_Ele> 00074 inline 00075 value_type dot(const SparseVectorSlice<T_Ele>& sv_rhs1, const DVectorSlice& vs_rhs2) 00076 { 00077 return dot_SV_V(sv_rhs1, vs_rhs2); 00078 } 00079 00081 template<class T_Ele> 00082 inline 00083 value_type norm_1(const SparseVectorSlice<T_Ele>& sv_rhs) 00084 { 00085 return norm_1_SV(sv_rhs); 00086 } 00087 00089 template<class T_Ele> 00090 inline 00091 value_type norm_2(const SparseVectorSlice<T_Ele>& sv_rhs) 00092 { 00093 return norm_2_SV(sv_rhs); 00094 } 00095 00097 template<class T_Ele> 00098 inline 00099 value_type norm_inf(const SparseVectorSlice<T_Ele>& sv_rhs) 00100 { 00101 return norm_inf_SV(sv_rhs); 00102 } 00103 00105 template<class T_Ele> 00106 inline 00107 value_type max(const SparseVectorSlice<T_Ele>& sv_rhs) 00108 { 00109 return max_SV(sv_rhs); 00110 } 00111 00113 template<class T_Ele> 00114 inline 00115 value_type min(const SparseVectorSlice<T_Ele>& sv_rhs) 00116 { 00117 return min_SV(sv_rhs); 00118 } 00119 00121 template<class T_Ele> 00122 inline 00123 void Vp_StV(DVectorSlice* vs_lhs, value_type alpha, const SparseVectorSlice<T_Ele>& sv_rhs) 00124 { 00125 Vp_StSV(vs_lhs, alpha, sv_rhs); 00126 } 00127 00129 template<class T_Ele> 00130 inline 00131 void Vp_StMtV(DVectorSlice* vs_lhs, value_type alpha, const DMatrixSlice& gms_rhs1 00132 , BLAS_Cpp::Transp trans_rhs1, const SparseVectorSlice<T_Ele>& sv_rhs2) 00133 { 00134 Vp_StMtSV(vs_lhs, alpha, gms_rhs1, trans_rhs1, sv_rhs2); 00135 } 00136 00138 template<class T_Ele> 00139 inline 00140 void Vp_StMtV(DVectorSlice* vs_lhs, value_type alpha, const DMatrixSliceTri& tri_gms_rhs1 00141 , BLAS_Cpp::Transp trans_rhs1, const SparseVectorSlice<T_Ele>& sv_rhs2) 00142 { 00143 Vp_StMtSV(vs_lhs, alpha, tri_gms_rhs1, trans_rhs1, sv_rhs2); 00144 } 00145 00147 template<class T_Ele> 00148 inline 00149 void Vp_StMtV(DVectorSlice* vs_lhs, value_type alpha, const DMatrixSliceSym& sym_gms_rhs1 00150 , BLAS_Cpp::Transp trans_rhs1, const SparseVectorSlice<T_Ele>& sv_rhs2) 00151 { 00152 Vp_StMtSV(vs_lhs, alpha, sym_gms_rhs1, trans_rhs1, sv_rhs2); 00153 } 00154 00165 template<class M, class T_Ele> 00166 inline 00167 void Vp_StMtSVS(DVectorSlice* vs_lhs, value_type alpha, const M& M_rhs1 00168 , BLAS_Cpp::Transp trans_rhs1, const SparseVectorSlice<T_Ele>& sv_rhs2 00169 , value_type beta) 00170 { 00171 using DenseLinAlgPack::Vp_MtV_assert_sizes; 00172 using DenseLinAlgPack::Vt_S; 00173 Vp_MtV_assert_sizes(vs_lhs->dim(), M_rhs1.rows(), M_rhs1.cols(), trans_rhs1, sv_rhs2.dim()); 00174 if(beta == 0.0) 00175 *vs_lhs = 0.0; 00176 else if(beta != 1.0) 00177 Vt_S(vs_lhs,beta); 00178 Vp_StMtV(vs_lhs,alpha,M_rhs1,trans_rhs1,sv_rhs2); 00179 } 00180 00182 template<class T_Ele> 00183 inline 00184 void Vp_StMtV(DVectorSlice* vs_lhs, value_type alpha, const DMatrixSlice& gms_rhs1 00185 , BLAS_Cpp::Transp trans_rhs1, const SparseVectorSlice<T_Ele>& sv_rhs2 00186 , value_type beta) 00187 { Vp_StMtSVS(vs_lhs, alpha, gms_rhs1, trans_rhs1, sv_rhs2, beta); } 00188 00190 template<class T_Ele> 00191 inline 00192 void Vp_StMtV(DVectorSlice* vs_lhs, value_type alpha, const DMatrixSliceTri& tri_gms_rhs1 00193 , BLAS_Cpp::Transp trans_rhs1, const SparseVectorSlice<T_Ele>& sv_rhs2 00194 , value_type beta) 00195 { Vp_StMtSVS(vs_lhs, alpha, tri_gms_rhs1, trans_rhs1, sv_rhs2, beta); } 00196 00198 template<class T_Ele> 00199 inline 00200 void Vp_StMtV(DVectorSlice* vs_lhs, value_type alpha, const DMatrixSliceSym& sym_gms_rhs1 00201 , BLAS_Cpp::Transp trans_rhs1, const SparseVectorSlice<T_Ele>& sv_rhs2 00202 , value_type beta) 00203 { Vp_StMtSVS(vs_lhs, alpha, sym_gms_rhs1, trans_rhs1, sv_rhs2, beta); } 00204 00206 00207 } // end namespace AbstractLinAlgPack 00208 00209 #endif // SPARSE_VECTOR_SLICE_OP_H
1.7.4