42 #ifndef LIN_ALG_OP_PACK_DEF_H
43 #define LIN_ALG_OP_PACK_DEF_H
45 #include "DenseLinAlgPack_LinAlgOpPackDecl.hpp"
46 #include "DenseLinAlgPack_AssertOp.hpp"
47 #include "DenseLinAlgPack_DMatrixClass.hpp"
49 namespace LinAlgOpPack {
55 using DenseLinAlgPack::assert_gms_lhs;
56 using DenseLinAlgPack::Vp_V_assert_sizes;
57 using DenseLinAlgPack::VopV_assert_sizes;
58 using DenseLinAlgPack::Mp_M_assert_sizes;
59 using DenseLinAlgPack::MopM_assert_sizes;
60 using DenseLinAlgPack::Vp_MtV_assert_sizes;
61 using DenseLinAlgPack::MtV_assert_sizes;
62 using DenseLinAlgPack::MtM_assert_sizes;
69 using DenseLinAlgPack::assign;
70 using DenseLinAlgPack::Vt_S;
71 using DenseLinAlgPack::Vp_StV;
72 using DenseLinAlgPack::Vp_StMtV;
73 using DenseLinAlgPack::Mt_S;
74 using DenseLinAlgPack::Mp_StM;
75 using DenseLinAlgPack::Mp_StMtM;
89 void assign(DVector* v_lhs,
const V& V_rhs) {
90 v_lhs->resize(V_rhs.dim());
92 Vp_V(&(*v_lhs)(),V_rhs);
97 void V_StV(DVector* v_lhs, value_type alpha,
const V& V_rhs) {
98 v_lhs->resize(V_rhs.dim());
100 Vp_StV(&(*v_lhs)(),alpha,V_rhs);
104 template <
class V1,
class V2>
105 void V_VpV(DVector* v_lhs,
const V1& V1_rhs1,
const V2& V2_rhs2) {
106 VopV_assert_sizes(V1_rhs1.dim(),V2_rhs2.dim());
107 v_lhs->resize(V1_rhs1.dim());
109 DVectorSlice vs_lhs(*v_lhs);
110 Vp_V(&vs_lhs,V1_rhs1);
111 Vp_V(&vs_lhs,V2_rhs2);
116 template <
class V1,
class V2>
117 void V_VmV(DVector* v_lhs,
const V1& V1_rhs1,
const V2& V2_rhs2) {
118 VopV_assert_sizes(V1_rhs1.dim(),V2_rhs2.dim());
119 v_lhs->resize(V1_rhs1.dim());
121 DVectorSlice vs_lhs(*v_lhs);
122 Vp_V(&vs_lhs,V1_rhs1);
123 Vp_StV(&vs_lhs,-1.0,V2_rhs2);
129 void V_StVpV(DVector* v_lhs, value_type alpha,
const V& V_rhs1
130 ,
const DVectorSlice& vs_rhs2)
132 VopV_assert_sizes(V_rhs1.dim(),vs_rhs2.dim());
134 Vp_StV(&(*v_lhs)(),alpha,V_rhs1);
142 void assign(DVectorSlice* vs_lhs,
const V& V_rhs) {
143 Vp_V_assert_sizes( vs_lhs->dim(), V_rhs.dim() );
150 void V_StV(DVectorSlice* vs_lhs, value_type alpha,
const V& V_rhs) {
151 Vp_V_assert_sizes( vs_lhs->dim(), V_rhs.dim() );
153 Vp_StV(vs_lhs,alpha,V_rhs);
157 template <
class V1,
class V2>
158 void V_VpV(DVectorSlice* vs_lhs,
const V1& V1_rhs1,
const V2& V2_rhs2) {
159 VopV_assert_sizes(V1_rhs1.dim(),V2_rhs2.dim());
160 Vp_V_assert_sizes( vs_lhs->dim(), V1_rhs1.dim() );
162 Vp_V(vs_lhs,V1_rhs1);
163 Vp_V(vs_lhs,V2_rhs2);
167 template <
class V1,
class V2>
168 void V_VmV(DVectorSlice* vs_lhs,
const V1& V1_rhs1,
const V2& V2_rhs2) {
169 VopV_assert_sizes(V1_rhs1.dim(),V2_rhs2.dim());
170 Vp_V_assert_sizes( vs_lhs->dim(), V1_rhs1.dim() );
172 Vp_V(vs_lhs,V1_rhs1);
173 Vp_StV(vs_lhs,-1.0,V2_rhs2);
178 void V_StVpV(DVectorSlice* vs_lhs, value_type alpha,
const V& V_rhs1
179 ,
const DVectorSlice& vs_rhs2)
181 VopV_assert_sizes(V_rhs1.dim(),vs_rhs2.dim());
183 Vp_StV(vs_lhs,alpha,V_rhs1);
200 gm_lhs->resize(
rows(M_rhs.rows(),M_rhs.cols(),trans_rhs)
201 ,
cols(M_rhs.rows(),M_rhs.cols(),trans_rhs) );
203 Mp_StM(&(*gm_lhs)(),1.0,M_rhs,trans_rhs);
208 void M_StM(DMatrix* gm_lhs, value_type alpha,
const M& M_rhs,
BLAS_Cpp::Transp trans_rhs) {
209 gm_lhs->resize(
rows(M_rhs.rows(),M_rhs.cols(),trans_rhs)
210 ,
cols(M_rhs.rows(),M_rhs.cols(),trans_rhs) );
212 Mp_StM(&(*gm_lhs)(),alpha,M_rhs,trans_rhs);
216 template <
class M1,
class M2>
220 MopM_assert_sizes( M1_rhs1.rows(),M1_rhs1.cols(),trans_rhs1
221 ,M2_rhs2.rows(),M2_rhs2.cols(),trans_rhs2 );
222 gm_lhs->resize(
rows(M1_rhs1.rows(),M1_rhs1.cols(),trans_rhs1)
223 ,
cols(M1_rhs1.rows(),M1_rhs1.cols(),trans_rhs2) );
225 DMatrixSlice gms_lhs(*gm_lhs);
226 Mp_M(&gms_lhs,M1_rhs1,trans_rhs1);
227 Mp_M(&gms_lhs,M2_rhs2,trans_rhs2);
231 template <
class M1,
class M2>
235 MopM_assert_sizes( M1_rhs1.rows(),M1_rhs1.cols(),trans_rhs1
236 ,M2_rhs2.rows(),M2_rhs2.cols(),trans_rhs2 );
237 gm_lhs->resize(
rows(M1_rhs1.rows(),M1_rhs1.cols(),trans_rhs1)
238 ,
cols(M1_rhs1.rows(),M1_rhs1.cols(),trans_rhs1) );
240 DMatrixSlice gms_lhs(*gm_lhs);
241 Mp_M(&gms_lhs,M1_rhs1,trans_rhs1);
242 Mp_StM(&gms_lhs,-1.0,M2_rhs2,trans_rhs2);
247 void M_StMpM(DMatrix* gm_lhs, value_type alpha,
const M& M_rhs1,
BLAS_Cpp::Transp trans_rhs1
250 MopM_assert_sizes( M_rhs1.rows(),M_rhs1.cols(),trans_rhs1
251 ,gms_rhs2.rows(),gms_rhs2.cols(),trans_rhs2);
252 assign(gm_lhs,gms_rhs2,trans_rhs2);
253 Mp_StM(&(*gm_lhs)(),alpha,M_rhs1,trans_rhs1);
261 void assign(DMatrixSlice* gms_lhs,
const M& M_rhs,
BLAS_Cpp::Transp trans_rhs) {
263 , M_rhs.rows(), M_rhs.cols(), trans_rhs );
265 Mp_StM(gms_lhs,1.0,M_rhs,trans_rhs);
270 void M_StM(DMatrixSlice* gms_lhs, value_type alpha,
const M& M_rhs,
BLAS_Cpp::Transp trans_rhs) {
272 , M_rhs.rows(), M_rhs.cols(), trans_rhs );
274 Mp_StM(gms_lhs,alpha,M_rhs,trans_rhs);
278 template <
class M1,
class M2>
279 void M_MpM(DMatrixSlice* gms_lhs,
const M1& M1_rhs1,
BLAS_Cpp::Transp trans_rhs1
282 MopM_assert_sizes( M1_rhs1.rows(),M1_rhs1.cols(),trans_rhs1
283 ,M2_rhs2.rows(),M2_rhs2.cols(),trans_rhs2 );
284 assert_gms_lhs(*gms_lhs,
rows(M1_rhs1.rows(),M1_rhs1.cols(),trans_rhs1)
285 ,
cols(M1_rhs1.rows(),M1_rhs1.cols(),trans_rhs1) );
287 Mp_M(gms_lhs,M1_rhs1,trans_rhs1);
288 Mp_M(gms_lhs,M2_rhs2,trans_rhs2);
292 template <
class M1,
class M2>
293 void M_MmM(DMatrixSlice* gms_lhs,
const M1& M1_rhs1,
BLAS_Cpp::Transp trans_rhs1
296 MopM_assert_sizes( M1_rhs1.rows(),M1_rhs1.cols(),trans_rhs1
297 ,M2_rhs2.rows(),M2_rhs2.cols(),trans_rhs2 );
298 assert_gms_lhs(*gms_lhs,
rows(M1_rhs1.rows(),M1_rhs1.cols(),trans_rhs1)
299 ,
cols(M1_rhs1.rows(),M1_rhs1.cols(),trans_rhs1) );
301 Mp_M(gms_lhs,M1_rhs1,trans_rhs1);
302 Mp_StM(gms_lhs,-1.0,M2_rhs2,trans_rhs2);
307 void M_StMpM(DMatrixSlice* gms_lhs, value_type alpha,
const M& M_rhs1,
BLAS_Cpp::Transp trans_rhs1
310 MopM_assert_sizes( M_rhs1.rows(),M_rhs1.cols(),trans_rhs1
311 ,gms_rhs2.rows(),gms_rhs2.cols(),trans_rhs2);
312 assign(gms_lhs,gms_rhs2,trans_rhs2);
313 Mp_StM(gms_lhs,alpha,M_rhs1,trans_rhs1);
327 template <
class M,
class V>
328 void V_StMtV(DVector* v_lhs, value_type alpha,
const M& M_rhs1
331 MtV_assert_sizes(M_rhs1.rows(),M_rhs1.cols(),trans_rhs1,V_rhs2.dim());
332 v_lhs->resize(
rows(M_rhs1.rows(),M_rhs1.cols(),trans_rhs1));
333 Vp_StMtV(&(*v_lhs)(),alpha,M_rhs1,trans_rhs1,V_rhs2,0.0);
337 template <
class M,
class V>
341 MtV_assert_sizes(M_rhs1.rows(),M_rhs1.cols(),trans_rhs1,V_rhs2.dim());
342 v_lhs->resize(
rows(M_rhs1.rows(),M_rhs1.cols(),trans_rhs1));
343 Vp_StMtV(&(*v_lhs)(),1.0,M_rhs1,trans_rhs1,V_rhs2,0.0);
350 template <
class M,
class V>
351 void V_StMtV(DVectorSlice* vs_lhs, value_type alpha,
const M& M_rhs1
354 MtV_assert_sizes(M_rhs1.rows(),M_rhs1.cols(),trans_rhs1,V_rhs2.dim());
355 Vp_V_assert_sizes( vs_lhs->dim(),
rows(M_rhs1.rows(),M_rhs1.cols(),trans_rhs1) );
356 Vp_StMtV(vs_lhs,alpha,M_rhs1,trans_rhs1,V_rhs2,0.0);
360 template <
class M,
class V>
361 void V_MtV(DVectorSlice* vs_lhs,
const M& M_rhs1,
BLAS_Cpp::Transp trans_rhs1
364 MtV_assert_sizes(M_rhs1.rows(),M_rhs1.cols(),trans_rhs1,V_rhs2.dim());
365 Vp_V_assert_sizes( vs_lhs->dim(),
rows(M_rhs1.rows(),M_rhs1.cols(),trans_rhs1) );
366 Vp_StMtV(vs_lhs,1.0,M_rhs1,trans_rhs1,V_rhs2,0.0);
380 template <
class M1,
class M2>
381 void M_StMtM(DMatrix* gm_lhs, value_type alpha,
const M1& M1_rhs1
384 MtM_assert_sizes( M1_rhs1.rows(), M1_rhs1.cols(), trans_rhs1
385 , M2_rhs2.rows(), M2_rhs2.cols(), trans_rhs2 );
386 gm_lhs->resize(
rows(M1_rhs1.rows(), M1_rhs1.cols(), trans_rhs1)
387 ,
cols(M2_rhs2.rows(), M2_rhs2.cols(), trans_rhs2) );
388 Mp_StMtM(&(*gm_lhs)(),alpha,M1_rhs1,trans_rhs1,M2_rhs2,trans_rhs2,0.0);
392 template <
class M1,
class M2>
393 void M_MtM(DMatrix* gm_lhs,
const M1& M1_rhs1
396 MtM_assert_sizes( M1_rhs1.rows(), M1_rhs1.cols(), trans_rhs1
397 , M2_rhs2.rows(), M2_rhs2.cols(), trans_rhs2 );
398 gm_lhs->resize(
rows(M1_rhs1.rows(), M1_rhs1.cols(), trans_rhs1)
399 ,
cols(M2_rhs2.rows(), M2_rhs2.cols(), trans_rhs2) );
400 Mp_StMtM(&(*gm_lhs)(),1.0,M1_rhs1,trans_rhs1,M2_rhs2,trans_rhs2,0.0);
407 template <
class M1,
class M2>
408 void M_StMtM(DMatrixSlice* gms_lhs, value_type alpha,
const M1& M1_rhs1
411 MtM_assert_sizes( M1_rhs1.rows(), M1_rhs1.cols(), trans_rhs1
412 , M2_rhs2.rows(), M2_rhs2.cols(), trans_rhs2 );
413 assert_gms_lhs( *gms_lhs
414 ,
rows(M1_rhs1.rows(), M1_rhs1.cols(), trans_rhs1)
415 ,
cols(M2_rhs2.rows(), M2_rhs2.cols(), trans_rhs2) );
416 Mp_StMtM(gms_lhs,alpha,M1_rhs1,trans_rhs1,M2_rhs2,trans_rhs2,0.0);
420 template <
class M1,
class M2>
421 void M_MtM(DMatrixSlice* gms_lhs,
const M1& M1_rhs1
424 MtM_assert_sizes( M1_rhs1.rows(), M1_rhs1.cols(), trans_rhs1
425 , M2_rhs2.rows(), M2_rhs2.cols(), trans_rhs2 );
426 assert_gms_lhs( gms_lhs
427 ,
rows(M1_rhs1.rows(), M1_rhs1.cols(), trans_rhs1)
428 ,
cols(M2_rhs2.rows(), M2_rhs2.cols(), trans_rhs2) );
429 Mp_StMtM(gms_lhs,1.0,M1_rhs1,trans_rhs1,M2_rhs2,trans_rhs2,0,0);
435 #endif // LIN_ALG_OP_PACK_DEF_H
size_type rows(size_type rows, size_type cols, BLAS_Cpp::Transp _trans)
size_type cols(size_type rows, size_type cols, BLAS_Cpp::Transp _trans)