|
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 // 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 00043 #ifndef SPARSE_VECTOR_SLICE_OP_H 00044 #define SPARSE_VECTOR_SLICE_OP_H 00045 00046 #include "AbstractLinAlgPack_SparseVectorOp.hpp" 00047 #include "DenseLinAlgPack_AssertOp.hpp" 00048 #include "DenseLinAlgPack_DVectorOp.hpp" 00049 00050 namespace AbstractLinAlgPack { 00051 00074 00075 00076 00078 template<class T_Ele> 00079 inline 00080 value_type dot(const DVectorSlice& vs_rhs1, const SparseVectorSlice<T_Ele>& sv_rhs2) 00081 { 00082 return dot_V_SV(vs_rhs1, sv_rhs2); 00083 } 00084 00086 template<class T_Ele> 00087 inline 00088 value_type dot(const SparseVectorSlice<T_Ele>& sv_rhs1, const DVectorSlice& vs_rhs2) 00089 { 00090 return dot_SV_V(sv_rhs1, vs_rhs2); 00091 } 00092 00094 template<class T_Ele> 00095 inline 00096 value_type norm_1(const SparseVectorSlice<T_Ele>& sv_rhs) 00097 { 00098 return norm_1_SV(sv_rhs); 00099 } 00100 00102 template<class T_Ele> 00103 inline 00104 value_type norm_2(const SparseVectorSlice<T_Ele>& sv_rhs) 00105 { 00106 return norm_2_SV(sv_rhs); 00107 } 00108 00110 template<class T_Ele> 00111 inline 00112 value_type norm_inf(const SparseVectorSlice<T_Ele>& sv_rhs) 00113 { 00114 return norm_inf_SV(sv_rhs); 00115 } 00116 00118 template<class T_Ele> 00119 inline 00120 value_type max(const SparseVectorSlice<T_Ele>& sv_rhs) 00121 { 00122 return max_SV(sv_rhs); 00123 } 00124 00126 template<class T_Ele> 00127 inline 00128 value_type min(const SparseVectorSlice<T_Ele>& sv_rhs) 00129 { 00130 return min_SV(sv_rhs); 00131 } 00132 00134 template<class T_Ele> 00135 inline 00136 void Vp_StV(DVectorSlice* vs_lhs, value_type alpha, const SparseVectorSlice<T_Ele>& sv_rhs) 00137 { 00138 Vp_StSV(vs_lhs, alpha, sv_rhs); 00139 } 00140 00142 template<class T_Ele> 00143 inline 00144 void Vp_StMtV(DVectorSlice* vs_lhs, value_type alpha, const DMatrixSlice& gms_rhs1 00145 , BLAS_Cpp::Transp trans_rhs1, const SparseVectorSlice<T_Ele>& sv_rhs2) 00146 { 00147 Vp_StMtSV(vs_lhs, alpha, gms_rhs1, trans_rhs1, sv_rhs2); 00148 } 00149 00151 template<class T_Ele> 00152 inline 00153 void Vp_StMtV(DVectorSlice* vs_lhs, value_type alpha, const DMatrixSliceTri& tri_gms_rhs1 00154 , BLAS_Cpp::Transp trans_rhs1, const SparseVectorSlice<T_Ele>& sv_rhs2) 00155 { 00156 Vp_StMtSV(vs_lhs, alpha, tri_gms_rhs1, trans_rhs1, sv_rhs2); 00157 } 00158 00160 template<class T_Ele> 00161 inline 00162 void Vp_StMtV(DVectorSlice* vs_lhs, value_type alpha, const DMatrixSliceSym& sym_gms_rhs1 00163 , BLAS_Cpp::Transp trans_rhs1, const SparseVectorSlice<T_Ele>& sv_rhs2) 00164 { 00165 Vp_StMtSV(vs_lhs, alpha, sym_gms_rhs1, trans_rhs1, sv_rhs2); 00166 } 00167 00178 template<class M, class T_Ele> 00179 inline 00180 void Vp_StMtSVS(DVectorSlice* vs_lhs, value_type alpha, const M& M_rhs1 00181 , BLAS_Cpp::Transp trans_rhs1, const SparseVectorSlice<T_Ele>& sv_rhs2 00182 , value_type beta) 00183 { 00184 using DenseLinAlgPack::Vp_MtV_assert_sizes; 00185 using DenseLinAlgPack::Vt_S; 00186 Vp_MtV_assert_sizes(vs_lhs->dim(), M_rhs1.rows(), M_rhs1.cols(), trans_rhs1, sv_rhs2.dim()); 00187 if(beta == 0.0) 00188 *vs_lhs = 0.0; 00189 else if(beta != 1.0) 00190 Vt_S(vs_lhs,beta); 00191 Vp_StMtV(vs_lhs,alpha,M_rhs1,trans_rhs1,sv_rhs2); 00192 } 00193 00195 template<class T_Ele> 00196 inline 00197 void Vp_StMtV(DVectorSlice* vs_lhs, value_type alpha, const DMatrixSlice& gms_rhs1 00198 , BLAS_Cpp::Transp trans_rhs1, const SparseVectorSlice<T_Ele>& sv_rhs2 00199 , value_type beta) 00200 { Vp_StMtSVS(vs_lhs, alpha, gms_rhs1, trans_rhs1, sv_rhs2, beta); } 00201 00203 template<class T_Ele> 00204 inline 00205 void Vp_StMtV(DVectorSlice* vs_lhs, value_type alpha, const DMatrixSliceTri& tri_gms_rhs1 00206 , BLAS_Cpp::Transp trans_rhs1, const SparseVectorSlice<T_Ele>& sv_rhs2 00207 , value_type beta) 00208 { Vp_StMtSVS(vs_lhs, alpha, tri_gms_rhs1, trans_rhs1, sv_rhs2, beta); } 00209 00211 template<class T_Ele> 00212 inline 00213 void Vp_StMtV(DVectorSlice* vs_lhs, value_type alpha, const DMatrixSliceSym& sym_gms_rhs1 00214 , BLAS_Cpp::Transp trans_rhs1, const SparseVectorSlice<T_Ele>& sv_rhs2 00215 , value_type beta) 00216 { Vp_StMtSVS(vs_lhs, alpha, sym_gms_rhs1, trans_rhs1, sv_rhs2, beta); } 00217 00219 00220 } // end namespace AbstractLinAlgPack 00221 00222 #endif // SPARSE_VECTOR_SLICE_OP_H
1.7.6.1