MOOCHO (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AbstractLinAlgPack_COOMPartitionOp.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 #ifndef COOM_PARTITION_OP_H
43 #define COOM_PARTITION_OP_H
44 
46 
47 namespace AbstractLinAlgPack {
48 
49 // ///////////////////////////////////////////////////////////////////////////
57 
58 // ////////////////////////////////////////////////////////////////////
62 
64 template <class T_Indice, class T_Value>
65 inline void Mp_StM( DMatrixSlice* gms_lhs, value_type alpha
67  , BLAS_Cpp::Transp trans_rhs )
68 {
69  Mp_StCOOM(gms_lhs, alpha, coom_rhs, trans_rhs);
70 }
71 
73 
74 // ///////////////////////////////////////////////////////////////////////
82 
84 template <class T_Indice, class T_Value>
85 inline void Vp_StMtV( DVectorSlice* vs_lhs, value_type alpha
87  , BLAS_Cpp::Transp trans_rhs1, const DVectorSlice& vs_rhs2 )
88 {
89  Vp_StCOOMtV(vs_lhs, alpha, coom_rhs1, trans_rhs1, vs_rhs2);
90 }
91 
93 template <class T_Indice, class T_Value>
94 inline void Vp_StMtV( DVectorSlice* vs_lhs, value_type alpha
96  , BLAS_Cpp::Transp trans_rhs1, const DVectorSlice& vs_rhs2, value_type beta )
97 {
98  if( beta == 0.0 ) {
99  *vs_lhs = 0.0; // We must specifically assign this in case uninitialized memory
100  // was used and you might get NaN by accident (this happened to me!).
101  }
102  else {
103  DenseLinAlgPack::Vt_S(vs_lhs,beta);
104  }
105  Vp_StCOOMtV(vs_lhs, alpha, coom_rhs1, trans_rhs1, vs_rhs2);
106 }
107 
109 
110 // /////////////////////////////////////////////////////////////////////////////////
114 
116 template <class T_Indice, class T_Value>
117 inline void Mp_StMtM( DMatrixSlice* gms_lhs, value_type alpha
119  , BLAS_Cpp::Transp trans_rhs1, const DMatrixSlice& gms_rhs2, BLAS_Cpp::Transp trans_rhs2 )
120 {
121  Mp_StCOOMtM(gms_lhs, alpha, coom_rhs1, trans_rhs1, gms_rhs2, trans_rhs2);
122 }
123 
125 template <class T_Indice, class T_Value>
126 inline void Mp_StMtM( DMatrixSlice* gms_lhs, value_type alpha, const DMatrixSlice& gms_rhs1
127  , BLAS_Cpp::Transp trans_rhs1
129  , BLAS_Cpp::Transp trans_rhs2 )
130 {
131  Mp_StMtCOOM(gms_lhs, alpha, gms_rhs1, trans_rhs1, coom_rhs2, trans_rhs2);
132 }
133 
138 template <class T_Indice, class T_Value, class M2>
139 inline
140 void Mp_StMtM(DMatrixSlice* gms_lhs, value_type alpha
142  , BLAS_Cpp::Transp trans_rhs1, const M2& M2_rhs2, BLAS_Cpp::Transp trans_rhs2
143  , value_type beta)
144 {
145  Mp_MtM_assert_sizes( gms_lhs->rows(), gms_lhs->cols(), BLAS_Cpp::no_trans
146  , coom_rhs1.rows(), coom_rhs1.cols(), trans_rhs1
147  , M2_rhs2.rows(), M2_rhs2.cols(), trans_rhs2 );
148  if( beta == 0.0 ) {
149  *gms_lhs = 0.0; // We must specifically assign this in case uninitialized memory
150  // was used and you might get NaN by accident (this happened to me!).
151  }
152  else {
153  DenseLinAlgPack::Mt_S(gms_lhs,beta);
154  }
155  Mp_StMtM(gms_lhs,alpha,coom_rhs1,trans_rhs1,M2_rhs2,trans_rhs2);
156 }
157 
162 template <class M1, class T_Indice, class T_Value>
163 inline
164 void Mp_StMtM(DMatrixSlice* gms_lhs, value_type alpha, const M1& M1_rhs1
165  , BLAS_Cpp::Transp trans_rhs1
167  , BLAS_Cpp::Transp trans_rhs2, value_type beta)
168 {
169  Mp_MtM_assert_sizes( gms_lhs->rows(), gms_lhs->cols(), BLAS_Cpp::no_trans
170  , M1_rhs1.rows(), M1_rhs1.cols(), trans_rhs1
171  , coom_rhs2.rows(), coom_rhs2.cols(), trans_rhs2 );
172  if( beta == 0.0 ) {
173  *gms_lhs = 0.0; // We must specifically assign this in case uninitialized memory
174  // was used and you might get NaN by accident (this happened to me!).
175  }
176  else {
177  DenseLinAlgPack::Mt_S(gms_lhs,beta);
178  }
179  Mp_StMtM(gms_lhs,alpha,M1_rhs1,trans_rhs1,coom_rhs2,trans_rhs2);
180 }
181 
183 
185 
186 // ///////////////////////////////////////////////////////////////////////////
194 
195 // ////////////////////////////////////////////////////////////////////
199 
201 template <class T_Indice, class T_Value>
202 inline void Mp_StM( DMatrixSlice* gms_lhs, value_type alpha
204  , BLAS_Cpp::Transp trans_rhs )
205 {
206  Mp_StCOOM(gms_lhs, alpha, coom_rhs, trans_rhs);
207 }
208 
210 
211 // ///////////////////////////////////////////////////////////////////////
219 
221 template <class T_Indice, class T_Value>
222 inline void Vp_StMtV( DVectorSlice* vs_lhs, value_type alpha
224  , BLAS_Cpp::Transp trans_rhs1, const DVectorSlice& vs_rhs2 )
225 {
226  Vp_StCOOMtV(vs_lhs, alpha, coom_rhs1, trans_rhs1, vs_rhs2);
227 }
228 
230 template <class T_Indice, class T_Value>
231 inline void Vp_StMtV( DVectorSlice* vs_lhs, value_type alpha
233  , BLAS_Cpp::Transp trans_rhs1, const DVectorSlice& vs_rhs2, value_type beta )
234 {
235  if( beta == 0.0 ) {
236  *vs_lhs = 0.0; // We must specifically assign this in case uninitialized memory
237  // was used and you might get NaN by accident (this happened to me!).
238  }
239  else {
240  DenseLinAlgPack::Vt_S(vs_lhs,beta);
241  }
242  Vp_StCOOMtV(vs_lhs, alpha, coom_rhs1, trans_rhs1, vs_rhs2);
243 }
244 
246 
247 // /////////////////////////////////////////////////////////////////////////////////
251 
253 template <class T_Indice, class T_Value>
254 inline void Mp_StMtM( DMatrixSlice* gms_lhs, value_type alpha
256  , BLAS_Cpp::Transp trans_rhs1, const DMatrixSlice& gms_rhs2, BLAS_Cpp::Transp trans_rhs2 )
257 {
258  Mp_StCOOMtM(gms_lhs, alpha, coom_rhs1, trans_rhs1, gms_rhs2, trans_rhs2);
259 }
260 
262 template <class T_Indice, class T_Value>
263 inline void Mp_StMtM( DMatrixSlice* gms_lhs, value_type alpha, const DMatrixSlice& gms_rhs1
264  , BLAS_Cpp::Transp trans_rhs1
266  , BLAS_Cpp::Transp trans_rhs2 )
267 {
268  Mp_StMtCOOM(gms_lhs, alpha, gms_rhs1, trans_rhs1, coom_rhs2, trans_rhs2);
269 }
270 
275 template <class T_Indice, class T_Value, class M2>
276 inline
277 void Mp_StMtM(DMatrixSlice* gms_lhs, value_type alpha
279  , BLAS_Cpp::Transp trans_rhs1, const M2& M2_rhs2, BLAS_Cpp::Transp trans_rhs2
280  , value_type beta)
281 {
282  Mp_MtM_assert_sizes( gms_lhs->rows(), gms_lhs->cols(), BLAS_Cpp::no_trans
283  , coom_rhs1.rows(), coom_rhs1.cols(), trans_rhs1
284  , M2_rhs2.rows(), M2_rhs2.cols(), trans_rhs2 );
285  if( beta == 0.0 ) {
286  *gms_lhs = 0.0; // We must specifically assign this in case uninitialized memory
287  // was used and you might get NaN by accident (this happened to me!).
288  }
289  else {
290  DenseLinAlgPack::Mt_S(gms_lhs,beta);
291  }
292  Mp_StMtM(gms_lhs,alpha,coom_rhs1,trans_rhs1,M2_rhs2,trans_rhs2);
293 }
294 
299 template <class M1, class T_Indice, class T_Value>
300 inline
301 void Mp_StMtM(DMatrixSlice* gms_lhs, value_type alpha, const M1& M1_rhs1
302  , BLAS_Cpp::Transp trans_rhs1
304  , BLAS_Cpp::Transp trans_rhs2, value_type beta)
305 {
306  Mp_MtM_assert_sizes( gms_lhs->rows(), gms_lhs->cols(), BLAS_Cpp::no_trans
307  , M1_rhs1.rows(), M1_rhs1.cols(), trans_rhs1
308  , coom_rhs2.rows(), coom_rhs2.cols(), trans_rhs2 );
309  if( beta == 0.0 ) {
310  *gms_lhs = 0.0; // We must specifically assign this in case uninitialized memory
311  // was used and you might get NaN by accident (this happened to me!).
312  }
313  else {
314  DenseLinAlgPack::Mt_S(gms_lhs,beta);
315  }
316  Mp_StMtM(gms_lhs,alpha,M1_rhs1,trans_rhs1,coom_rhs2,trans_rhs2);
317 }
318 
320 
322 
323 } // end namespace AbstractLinAlgPack
324 
325 #endif // COOM_PARTITION_OP_H
void Mp_StMtM(MatrixOp *mwo_lhs, value_type alpha, const MatrixOp &mwo_rhs1, BLAS_Cpp::Transp trans_rhs1, const MatrixOp &mwo_rhs2, BLAS_Cpp::Transp trans_rhs2, value_type beta=1.0)
mwo_lhs = alpha * op(mwo_rhs1) * op(mwo_rhs2) + beta * mwo_lhs (right) (xGEMM).
size_type cols() const
Return the number of columns.
void Mp_StMtCOOM(DMatrixSlice *gms_lhs, value_type alpha, const DMatrixSlice &gms_rhs1, BLAS_Cpp::Transp trans_rhs1, const T_COOM &coom_rhs2, BLAS_Cpp::Transp trans_rhs2)
gms_lhs += alpha * op(gms_rhs1) * op(coom_rhs2) (left) (BLAS xGEMM)
void Mp_MtM_assert_sizes(size_type m_lhs_rows, size_type m_lhs_cols, BLAS_Cpp::Transp trans_lhs, size_type m_rhs1_rows, size_type m_rhs1_cols, BLAS_Cpp::Transp trans_rhs1, size_type m_rhs2_rows, size_type m_rhs2_cols, BLAS_Cpp::Transp trans_rhs2)
op(m_lhs) += op(m_rhs1) * op(m_rhs2)
Not transposed.
void Mp_StCOOMtM(DMatrixSlice *gms_lhs, value_type alpha, const T_COOM &coom_rhs1, BLAS_Cpp::Transp trans_rhs1, const DMatrixSlice &gms_rhs2, BLAS_Cpp::Transp trans_rhs2)
gms_lhs += alpha * op(coom_rhs1) * op(gms_rhs2) (right) (BLAS xGEMM)
void Mt_S(DMatrixSlice *gms_lhs, value_type alpha)
gms_lhs *= alpha (BLAS xSCAL)
void Mp_StM(MatrixOp *mwo_lhs, value_type alpha, const MatrixOp &M_rhs, BLAS_Cpp::Transp trans_rhs)
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)
void Mp_StCOOM(DMatrixSlice *gms_lhs, value_type alpha, const T_COOM &coom_rhs, BLAS_Cpp::Transp trans_rhs)
gms_lhs += alpha * op(coom_rhs) (time = O(coom_rhs.nz(), space = O(1))
void Vp_StCOOMtV(DVectorSlice *vs_lhs, value_type alpha, const T_COOM &coom_rhs1, BLAS_Cpp::Transp trans_rhs1, const DVectorSlice &vs_rhs2)
vs_lhs += alpha * op(coom_rhs1) * vs_rhs2 (BLAS xGEMV) (time = O(coom_rhs.nz(), space = O(1)) ...
size_type rows() const
Return the number of rows.
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)
Class for a partition or a set of continous partitions in a partitioned COO matrix.
Transp
TRANS.