MOOCHO (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AbstractLinAlgPack_SparseVectorSliceOp.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Moocho: Multi-functional Object-Oriented arCHitecture for Optimization
5 // Copyright (2003) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov)
38 //
39 // ***********************************************************************
40 // @HEADER
41 //
42 
43 #ifndef SPARSE_VECTOR_SLICE_OP_H
44 #define SPARSE_VECTOR_SLICE_OP_H
45 
49 
50 namespace AbstractLinAlgPack {
51 
74 
75 
76 
78 template<class T_Ele>
79 inline
80 value_type dot(const DVectorSlice& vs_rhs1, const SparseVectorSlice<T_Ele>& sv_rhs2)
81 {
82  return dot_V_SV(vs_rhs1, sv_rhs2);
83 }
84 
86 template<class T_Ele>
87 inline
88 value_type dot(const SparseVectorSlice<T_Ele>& sv_rhs1, const DVectorSlice& vs_rhs2)
89 {
90  return dot_SV_V(sv_rhs1, vs_rhs2);
91 }
92 
94 template<class T_Ele>
95 inline
97 {
98  return norm_1_SV(sv_rhs);
99 }
100 
102 template<class T_Ele>
103 inline
105 {
106  return norm_2_SV(sv_rhs);
107 }
108 
110 template<class T_Ele>
111 inline
113 {
114  return norm_inf_SV(sv_rhs);
115 }
116 
118 template<class T_Ele>
119 inline
121 {
122  return max_SV(sv_rhs);
123 }
124 
126 template<class T_Ele>
127 inline
129 {
130  return min_SV(sv_rhs);
131 }
132 
134 template<class T_Ele>
135 inline
136 void Vp_StV(DVectorSlice* vs_lhs, value_type alpha, const SparseVectorSlice<T_Ele>& sv_rhs)
137 {
138  Vp_StSV(vs_lhs, alpha, sv_rhs);
139 }
140 
142 template<class T_Ele>
143 inline
144 void Vp_StMtV(DVectorSlice* vs_lhs, value_type alpha, const DMatrixSlice& gms_rhs1
145  , BLAS_Cpp::Transp trans_rhs1, const SparseVectorSlice<T_Ele>& sv_rhs2)
146 {
147  Vp_StMtSV(vs_lhs, alpha, gms_rhs1, trans_rhs1, sv_rhs2);
148 }
149 
151 template<class T_Ele>
152 inline
153 void Vp_StMtV(DVectorSlice* vs_lhs, value_type alpha, const DMatrixSliceTri& tri_gms_rhs1
154  , BLAS_Cpp::Transp trans_rhs1, const SparseVectorSlice<T_Ele>& sv_rhs2)
155 {
156  Vp_StMtSV(vs_lhs, alpha, tri_gms_rhs1, trans_rhs1, sv_rhs2);
157 }
158 
160 template<class T_Ele>
161 inline
162 void Vp_StMtV(DVectorSlice* vs_lhs, value_type alpha, const DMatrixSliceSym& sym_gms_rhs1
163  , BLAS_Cpp::Transp trans_rhs1, const SparseVectorSlice<T_Ele>& sv_rhs2)
164 {
165  Vp_StMtSV(vs_lhs, alpha, sym_gms_rhs1, trans_rhs1, sv_rhs2);
166 }
167 
178 template<class M, class T_Ele>
179 inline
180 void Vp_StMtSVS(DVectorSlice* vs_lhs, value_type alpha, const M& M_rhs1
181  , BLAS_Cpp::Transp trans_rhs1, const SparseVectorSlice<T_Ele>& sv_rhs2
182  , value_type beta)
183 {
185  using DenseLinAlgPack::Vt_S;
186  Vp_MtV_assert_sizes(vs_lhs->dim(), M_rhs1.rows(), M_rhs1.cols(), trans_rhs1, sv_rhs2.dim());
187  if(beta == 0.0)
188  *vs_lhs = 0.0;
189  else if(beta != 1.0)
190  Vt_S(vs_lhs,beta);
191  Vp_StMtV(vs_lhs,alpha,M_rhs1,trans_rhs1,sv_rhs2);
192 }
193 
195 template<class T_Ele>
196 inline
197 void Vp_StMtV(DVectorSlice* vs_lhs, value_type alpha, const DMatrixSlice& gms_rhs1
198  , BLAS_Cpp::Transp trans_rhs1, const SparseVectorSlice<T_Ele>& sv_rhs2
199  , value_type beta)
200 { Vp_StMtSVS(vs_lhs, alpha, gms_rhs1, trans_rhs1, sv_rhs2, beta); }
201 
203 template<class T_Ele>
204 inline
205 void Vp_StMtV(DVectorSlice* vs_lhs, value_type alpha, const DMatrixSliceTri& tri_gms_rhs1
206  , BLAS_Cpp::Transp trans_rhs1, const SparseVectorSlice<T_Ele>& sv_rhs2
207  , value_type beta)
208 { Vp_StMtSVS(vs_lhs, alpha, tri_gms_rhs1, trans_rhs1, sv_rhs2, beta); }
209 
211 template<class T_Ele>
212 inline
213 void Vp_StMtV(DVectorSlice* vs_lhs, value_type alpha, const DMatrixSliceSym& sym_gms_rhs1
214  , BLAS_Cpp::Transp trans_rhs1, const SparseVectorSlice<T_Ele>& sv_rhs2
215  , value_type beta)
216 { Vp_StMtSVS(vs_lhs, alpha, sym_gms_rhs1, trans_rhs1, sv_rhs2, beta); }
217 
219 
220 } // end namespace AbstractLinAlgPack
221 
222 #endif // SPARSE_VECTOR_SLICE_OP_H
void Vp_StSV(DVectorSlice *vs_lhs, value_type alpha, const T_SpVec &sv_rhs)
vs_lhs += alpha * sv_rhs (BLAS xAXPY)
size_type dim() const
Returns the number of elements of the VectorSliceTmpl.
size_type dim() const
Return the number of elements in the full vector.
void Vt_S(VectorMutable *v_lhs, const value_type &alpha)
v_lhs *= alpha
void Vp_StV(VectorMutable *v_lhs, const value_type &alpha, const Vector &v_rhs)
v_lhs = alpha * v_rhs + v_lhs
value_type min_SV(const T_SpVec &sv_rhs)
result = min(sv_rhs)
void Vp_StMtSV(DVectorSlice *vs_lhs, value_type alpha, const DMatrixSlice &gms_rhs1, BLAS_Cpp::Transp trans_rhs1, const T_SpVec &sv_rhs2)
vs_lhs += alpha * op(gms_rhs1) * sv_rhs2 (BLAS xGEMV)
value_type norm_1_SV(const T_SpVec &sv_rhs)
result = ||sv_rhs||1 (BLAS xASUM)
value_type norm_inf_SV(const T_SpVec &sv_rhs)
result = ||sv_rhs||inf (BLAS IxAMAX)
value_type norm_2_SV(const T_SpVec &sv_rhs)
result = ||sv_rhs||2 (BLAS xNRM2)
const LAPACK_C_Decl::f_int & M
void Vp_StMtV(VectorMutable *v_lhs, value_type alpha, const MatrixOp &M_rhs1, BLAS_Cpp::Transp trans_rhs1, const Vector &v_rhs2, value_type beta=1.0)
v_lhs = alpha * op(M_rhs1) * v_rhs2 + beta * v_lhs (BLAS xGEMV)
value_type norm_inf(const SparseVectorSlice< T_Ele > &sv_rhs)
result = ||sv_rhs||inf (BLAS IxAMAX)
value_type dot(const Vector &v_rhs1, const Vector &v_rhs2)
result = v_rhs1' * v_rhs2
void Vt_S(DVectorSlice *vs_lhs, value_type alpha)
vs_lhs *= alpha (BLAS xSCAL) (*** Note that alpha == 0.0 is handeled as vs_lhs = 0.0)
value_type max_SV(const T_SpVec &sv_rhs)
result = max(sv_rhs)
value_type norm_2(const SparseVectorSlice< T_Ele > &sv_rhs)
result = ||sv_rhs||2 (BLAS xNRM2)
void Vp_MtV_assert_sizes(size_type v_lhs_size, size_type m_rhs1_rows, size_type m_rhs1_cols, BLAS_Cpp::Transp trans_rhs1, size_type v_rhs2_size)
v_lhs += op(m_rhs1) * v_rhs2
value_type min(const SparseVectorSlice< T_Ele > &sv_rhs)
result = min(sv_rhs)
value_type max(const SparseVectorSlice< T_Ele > &sv_rhs)
result = max(sv_rhs)
value_type norm_1(const SparseVectorSlice< T_Ele > &sv_rhs)
result = ||sv_rhs||1 (BLAS xASUM)
value_type dot_SV_V(const T_SpVec &sv_rhs1, const DVectorSlice &vs_rhs2)
result = dot(sv_rhs1,vs_rhs2) (BLAS xDOT)
value_type dot_V_SV(const DVectorSlice &vs_rhs1, const T_SpVec &sv_rhs2)
result = dot(vs_rhs1,sv_rhs2) (BLAS xDOT)
Transp
TRANS.
void Vp_StMtSVS(DVectorSlice *vs_lhs, value_type alpha, const M &M_rhs1, BLAS_Cpp::Transp trans_rhs1, const SparseVectorSlice< T_Ele > &sv_rhs2, value_type beta)
vs_lhs = alpha * op(M_rhs1) * sv_rhs2 + beta * vs_lhs