42 #include "DenseLinAlgPack_DMatrixOp.hpp"
43 #include "DenseLinAlgPack_BLAS_Cpp.hpp"
51 using DenseLinAlgPack::col;
52 using DenseLinAlgPack::value_type;
53 using DenseLinAlgPack::assert_gms_sizes;
57 using DenseLinAlgPack::assign;
62 using BLAS_Cpp::upper;
63 using BLAS_Cpp::lower;
73 inline void i_assign(DMatrixSlice* gms_lhs, value_type alpha) {
75 gms_lhs->col(i) = alpha;
79 inline void i_assign_basic(DMatrixSlice* gms_lhs,
const DMatrixSlice& gms_rhs
83 gms_lhs->col(i) = col(gms_rhs,trans_rhs,i);
87 inline void i_assign(DMatrixSlice* gms_lhs,
const DMatrixSlice& gms_rhs,
BLAS_Cpp::Transp trans_rhs)
89 switch(gms_lhs->overlap(gms_rhs)) {
90 case DenseLinAlgPack::NO_OVERLAP:
91 i_assign_basic(gms_lhs,gms_rhs,trans_rhs);
93 case DenseLinAlgPack::SAME_MEM:
96 DMatrix temp = gms_rhs;
97 i_assign_basic(gms_lhs,temp(),trans_rhs);
104 inline void i_assign_basic(DMatrixSliceTriEle* tri_lhs,
const DMatrixSliceTriEle& tri_rhs)
111 trans_rhs = (tri_rhs.uplo() == BLAS_Cpp::lower) ?
BLAS_Cpp::no_trans : BLAS_Cpp::trans;
113 for(
int i = 1; i <= n; ++i) {
114 col(tri_lhs->gms(),trans_lhs,i)(i,n) = col(tri_rhs.gms(),trans_rhs,i)(i,n);
121 void DenseLinAlgPack::assign(DMatrix* gm_lhs, value_type alpha)
123 if(!gm_lhs->rows()) gm_lhs->resize(1,1,alpha);
124 i_assign(&(*gm_lhs)(),alpha);
128 void DenseLinAlgPack::assign(DMatrix* gm_lhs,
const DMatrixSlice& gms_rhs,
BLAS_Cpp::Transp trans_rhs)
131 if(gm_lhs->overlap(gms_rhs) != NO_OVERLAP) {
133 DMatrix tmp(gms_rhs);
134 resize_gm_lhs(gm_lhs,gms_rhs.rows(),gms_rhs.cols(),trans_rhs);
135 i_assign(&(*gm_lhs)(), tmp(), trans_rhs);
139 resize_gm_lhs(gm_lhs,gms_rhs.rows(),gms_rhs.cols(),trans_rhs);
140 i_assign(&(*gm_lhs)(), gms_rhs, trans_rhs);
145 void DenseLinAlgPack::assign(DMatrixSlice* gms_lhs, value_type alpha)
148 !gms_lhs->rows(), std::length_error
149 ,
"Error, assign(gms_lhs,alpha): You can not assign Scalar to an unsized DMatrixSlice" );
150 i_assign(gms_lhs, alpha);
154 void DenseLinAlgPack::assign(DMatrixSlice* gms_lhs,
const DMatrixSlice& gms_rhs,
BLAS_Cpp::Transp trans_rhs)
156 assert_gms_lhs(*gms_lhs,gms_rhs.rows(),gms_rhs.cols(),trans_rhs);
157 i_assign(gms_lhs, gms_rhs, trans_rhs);
161 void DenseLinAlgPack::assign(DMatrixSliceTriEle* tri_lhs, value_type alpha)
164 !tri_lhs->gms().rows(), std::length_error
165 ,
"Error, assign(tri_lhs,alpha): You can not assign a scalar to an unsized triangular DMatrixSlice" );
166 assert_gms_square(tri_lhs->gms());
170 trans_lhs = (tri_lhs->uplo() == BLAS_Cpp::lower) ?
BLAS_Cpp::no_trans : BLAS_Cpp::trans;
171 for(
int i = 1; i <= n; ++i)
172 col( tri_lhs->gms(), trans_lhs , i )(i,n) = alpha;
176 void DenseLinAlgPack::assign(DMatrixSliceTriEle* tri_lhs,
const DMatrixSliceTriEle& tri_rhs)
178 assert_gms_lhs(tri_lhs->gms(),tri_rhs.gms().rows(),tri_rhs.gms().cols(),
BLAS_Cpp::no_trans);
180 switch(tri_lhs->gms().overlap(tri_rhs.gms())) {
182 if(tri_lhs->uplo() == tri_rhs.uplo())
return;
188 if(tri_lhs->uplo() != tri_rhs.uplo()) {
189 const DMatrixSlice *up = (tri_lhs->uplo() == upper)
190 ? &tri_lhs->gms() : &tri_rhs.gms();
191 const DMatrixSlice *lo = (tri_rhs.uplo() == BLAS_Cpp::lower)
192 ? &tri_lhs->gms() : &tri_rhs.gms();
193 if(lo->col_ptr(1) + lo->max_rows() - 1 == up->col_ptr(1)) {
195 i_assign_basic(tri_lhs, tri_rhs);
201 DMatrix temp(tri_rhs.gms());
202 i_assign_basic(tri_lhs, tri_ele(temp(),tri_rhs.uplo()));
207 i_assign_basic(tri_lhs, tri_rhs);
215 void DenseLinAlgPack::Mt_S(DMatrixSlice* gms_lhs, value_type alpha)
218 !gms_lhs->rows(), std::length_error
219 ,
"Error, Mt_S(gms_lhs,alpha): You can not scale an unsized DMatrixSlice" );
220 for(
int j = 1; j <= gms_lhs->cols(); ++j)
221 Vt_S(&gms_lhs->col(j), alpha);
224 void DenseLinAlgPack::M_diagVtM( DMatrixSlice* gms_lhs,
const DVectorSlice& vs_rhs
228 , gms_rhs.rows(), gms_rhs.cols(), trans_rhs);
230 prod( &gms_lhs->col(j), vs_rhs, col(gms_rhs,trans_rhs,j) );
233 void DenseLinAlgPack::Mt_S(DMatrixSliceTriEle* tri_lhs, value_type alpha) {
235 !tri_lhs->gms().rows(), std::length_error
236 ,
"Error, Mt_S(tri_lhs,alpha): You can not scale an unsized triangular DMatrixSlice" );
238 trans_lhs = (tri_lhs->uplo() == BLAS_Cpp::lower) ?
BLAS_Cpp::no_trans : BLAS_Cpp::trans;
242 Vt_S( &col( tri_lhs->gms(), trans_lhs , j )(j,n), alpha );
245 void DenseLinAlgPack::Mp_StM(DMatrixSliceTriEle* tri_lhs, value_type alpha,
const DMatrixSliceTriEle& tri_ele_rhs)
251 trans_lhs = (tri_lhs->uplo() == BLAS_Cpp::lower) ?
BLAS_Cpp::no_trans : BLAS_Cpp::trans,
252 trans_rhs = (tri_ele_rhs.uplo() == BLAS_Cpp::lower) ?
BLAS_Cpp::no_trans : BLAS_Cpp::trans;
256 Vp_StV( &col(tri_lhs->gms(),trans_lhs,j)(j,n), alpha, col(tri_ele_rhs.gms(),trans_rhs,j)(j,n) );
261 void DenseLinAlgPack::Mp_StM(DMatrixSlice* gms_lhs, value_type alpha,
const DMatrixSlice& gms_rhs
265 , gms_rhs.rows(), gms_rhs.cols(), trans_rhs);
267 Vp_StV( &gms_lhs->col(j), alpha, col(gms_rhs,trans_rhs,j) );
277 using DenseLinAlgPack::Mp_StM;
278 using DenseLinAlgPack::tri_ele;
279 const DenseLinAlgPack::size_type n = gms_lhs->
rows();
280 Mp_StM( const_cast<DenseLinAlgPack::DMatrixSliceTriEle*>(
281 &tri_ele((*gms_lhs)(2,n,1,n-1), BLAS_Cpp::lower ) )
282 , alpha, tri_ele_rhs );
283 Mp_StM( const_cast<DenseLinAlgPack::DMatrixSliceTriEle*>(
284 &tri_ele((*gms_lhs)(1,n-1,2,n), BLAS_Cpp::upper ) )
285 , alpha, tri_ele_rhs );
289 void DenseLinAlgPack::Mp_StM(DMatrixSlice* gms_lhs, value_type alpha,
const DMatrixSliceSym& sym_rhs
293 , sym_rhs.rows(), sym_rhs.cols(), trans_rhs);
294 Vp_StV( &gms_lhs->diag(), alpha, sym_rhs.gms().diag() );
296 switch(sym_rhs.uplo()) {
297 case BLAS_Cpp::lower:
298 i_Mp_StSM( gms_lhs, alpha, tri_ele(sym_rhs.gms()(2,n,1,n-1),BLAS_Cpp::lower) );
300 case BLAS_Cpp::upper:
301 i_Mp_StSM( gms_lhs, alpha, tri_ele(sym_rhs.gms()(1,n-1,2,n),BLAS_Cpp::upper) );
306 void DenseLinAlgPack::Mp_StM(DMatrixSlice* gms_lhs, value_type alpha,
const DMatrixSliceTri& tri_rhs
311 using BLAS_Cpp::lower;
312 using BLAS_Cpp::upper;
314 , tri_rhs.rows(), tri_rhs.cols(), trans_rhs );
316 if( tri_rhs.diag() == BLAS_Cpp::nonunit )
317 Vp_StV( &gms_lhs->diag(), alpha, tri_rhs.gms().diag() );
319 Vp_S( &gms_lhs->diag(), alpha );
324 const DMatrixSliceTriEle
325 tri = ( tri_rhs.uplo() == lower
326 ? tri_ele(tri_rhs.gms()(2,n,1,n-1),lower)
327 : tri_ele(tri_rhs.gms()(1,n-1,2,n),upper) );
329 as_uplo = ( ( tri_rhs.uplo() == lower && trans_rhs ==
no_trans )
330 || ( tri_rhs.uplo() == upper && trans_rhs ==
trans )
334 Mp_StM( const_cast<DenseLinAlgPack::DMatrixSliceTriEle*>(
335 &tri_ele((*gms_lhs)(2,n,1,n-1),lower) )
339 Mp_StM( const_cast<DenseLinAlgPack::DMatrixSliceTriEle*>(
340 &tri_ele((*gms_lhs)(1,n-1,2,n),upper) )
349 void DenseLinAlgPack::Vp_StMtV(DVectorSlice* vs_lhs, value_type alpha,
const DMatrixSlice& gms_rhs1
350 ,
BLAS_Cpp::Transp trans_rhs1,
const DVectorSlice& vs_rhs2, value_type beta)
352 Vp_MtV_assert_sizes(vs_lhs->dim(), gms_rhs1.rows() , gms_rhs1.cols(), trans_rhs1
354 BLAS_Cpp::gemv(trans_rhs1,gms_rhs1.rows(),gms_rhs1.cols(),alpha,gms_rhs1.col_ptr(1)
355 ,gms_rhs1.max_rows(), vs_rhs2.raw_ptr(),vs_rhs2.stride(),beta,vs_lhs->raw_ptr()
359 void DenseLinAlgPack::Vp_StMtV(DVectorSlice* vs_lhs, value_type alpha,
const DMatrixSliceSym& sym_rhs1
360 ,
BLAS_Cpp::Transp trans_rhs1,
const DVectorSlice& vs_rhs2, value_type beta)
362 assert_gms_square(sym_rhs1.gms());
363 Vp_MtV_assert_sizes(vs_lhs->dim(), sym_rhs1.gms().rows(), sym_rhs1.gms().cols(), trans_rhs1
365 BLAS_Cpp::symv(sym_rhs1.uplo(),sym_rhs1.gms().rows(),alpha,sym_rhs1.gms().col_ptr(1)
366 ,sym_rhs1.gms().max_rows(),vs_rhs2.raw_ptr(),vs_rhs2.stride(),beta
367 ,vs_lhs->raw_ptr(),vs_lhs->stride());
370 void DenseLinAlgPack::V_MtV(DVector* v_lhs,
const DMatrixSliceTri& tri_rhs1,
BLAS_Cpp::Transp trans_rhs1
371 ,
const DVectorSlice& vs_rhs2)
373 assert_gms_square(tri_rhs1.gms());
374 MtV_assert_sizes(tri_rhs1.gms().rows(), tri_rhs1.gms().cols(), trans_rhs1, vs_rhs2.dim());
375 v_lhs->resize(tri_rhs1.gms().rows());
377 BLAS_Cpp::trmv(tri_rhs1.uplo(),trans_rhs1,tri_rhs1.diag(),tri_rhs1.gms().rows()
378 ,tri_rhs1.gms().col_ptr(1),tri_rhs1.gms().max_rows(), v_lhs->raw_ptr(),1);
381 void DenseLinAlgPack::V_MtV(DVectorSlice* vs_lhs,
const DMatrixSliceTri& tri_rhs1,
BLAS_Cpp::Transp trans_rhs1
382 ,
const DVectorSlice& vs_rhs2)
384 assert_gms_square(tri_rhs1.gms());
385 MtV_assert_sizes(tri_rhs1.gms().rows(), tri_rhs1.gms().cols(), trans_rhs1, vs_rhs2.dim());
386 Vp_V_assert_sizes( vs_lhs->dim(), tri_rhs1.gms().rows() );
388 BLAS_Cpp::trmv(tri_rhs1.uplo(),trans_rhs1,tri_rhs1.diag(),tri_rhs1.gms().rows()
389 ,tri_rhs1.gms().col_ptr(1),tri_rhs1.gms().max_rows(), vs_lhs->raw_ptr(),vs_lhs->stride());
392 void DenseLinAlgPack::Vp_StMtV(DVectorSlice* vs_lhs, value_type alpha,
const DMatrixSliceTri& tri_rhs1
393 ,
BLAS_Cpp::Transp trans_rhs1,
const DVectorSlice& vs_rhs2, value_type beta)
395 Vp_MtV_assert_sizes(vs_lhs->dim(),tri_rhs1.gms().rows(),tri_rhs1.gms().cols()
396 ,trans_rhs1,vs_rhs2.dim() );
399 if( vs_lhs->overlap(vs_rhs2) == SAME_MEM && beta == 0.0 )
401 V_MtV(vs_lhs, tri_rhs1, trans_rhs1, vs_rhs2);
402 if(alpha != 1.0) Vt_S(vs_lhs,alpha);
406 if(beta != 1.0) Vt_S(vs_lhs,beta);
408 V_MtV(&tmp, tri_rhs1, trans_rhs1, vs_rhs2);
409 Vp_StV(vs_lhs,alpha,tmp());
413 void DenseLinAlgPack::V_InvMtV(DVector* v_lhs,
const DMatrixSliceTri& tri_rhs1,
BLAS_Cpp::Transp trans_rhs1
414 ,
const DVectorSlice& vs_rhs2)
416 assert_gms_square(tri_rhs1.gms());
417 MtV_assert_sizes(tri_rhs1.gms().rows(), tri_rhs1.gms().cols(), trans_rhs1, vs_rhs2.dim());
418 v_lhs->resize(tri_rhs1.gms().rows());
420 BLAS_Cpp::trsv(tri_rhs1.uplo(),trans_rhs1,tri_rhs1.diag(),tri_rhs1.gms().rows()
421 ,tri_rhs1.gms().col_ptr(1),tri_rhs1.gms().max_rows(), v_lhs->raw_ptr(),1);
424 void DenseLinAlgPack::V_InvMtV(DVectorSlice* vs_lhs,
const DMatrixSliceTri& tri_rhs1,
BLAS_Cpp::Transp trans_rhs1
425 ,
const DVectorSlice& vs_rhs2)
427 assert_gms_square(tri_rhs1.gms());
428 MtV_assert_sizes(tri_rhs1.gms().rows(), tri_rhs1.gms().cols(), trans_rhs1, vs_rhs2.dim());
429 Vp_V_assert_sizes( vs_lhs->dim(), tri_rhs1.gms().rows() );
431 BLAS_Cpp::trsv(tri_rhs1.uplo(),trans_rhs1,tri_rhs1.diag(),tri_rhs1.gms().rows()
432 ,tri_rhs1.gms().col_ptr(1),tri_rhs1.gms().max_rows(), vs_lhs->raw_ptr(),vs_lhs->stride());
436 void DenseLinAlgPack::ger(
437 value_type alpha,
const DVectorSlice& vs_rhs1,
const DVectorSlice& vs_rhs2
438 , DMatrixSlice* gms_lhs )
440 Vp_MtV_assert_sizes( vs_rhs2.dim(), gms_lhs->rows(), gms_lhs->cols()
443 gms_lhs->rows(), gms_lhs->cols(), alpha
444 ,vs_rhs1.raw_ptr(), vs_rhs1.stride()
445 ,vs_rhs2.raw_ptr(), vs_rhs2.stride()
446 ,gms_lhs->col_ptr(1), gms_lhs->max_rows() );
449 void DenseLinAlgPack::syr(value_type alpha,
const DVectorSlice& vs_rhs, DMatrixSliceSym* sym_lhs)
451 assert_gms_square(sym_lhs->gms());
452 MtV_assert_sizes( sym_lhs->gms().rows(), sym_lhs->gms().cols()
454 BLAS_Cpp::syr( sym_lhs->uplo(), vs_rhs.dim(), alpha, vs_rhs.raw_ptr()
455 , vs_rhs.stride(), sym_lhs->gms().col_ptr(1), sym_lhs->gms().max_rows() );
458 void DenseLinAlgPack::syr2(value_type alpha,
const DVectorSlice& vs_rhs1,
const DVectorSlice& vs_rhs2
459 , DMatrixSliceSym* sym_lhs)
461 assert_gms_square(sym_lhs->gms());
462 VopV_assert_sizes( vs_rhs1.dim(), vs_rhs2.dim() );
463 MtV_assert_sizes( sym_lhs->gms().rows(), sym_lhs->gms().cols()
465 BLAS_Cpp::syr2( sym_lhs->uplo(), vs_rhs1.dim(), alpha, vs_rhs1.raw_ptr()
466 , vs_rhs1.stride(), vs_rhs2.raw_ptr(), vs_rhs2.stride()
467 , sym_lhs->gms().col_ptr(1), sym_lhs->gms().max_rows() );
476 void DenseLinAlgPack::Mp_StMtM(DMatrixSlice* gms_lhs, value_type alpha,
const DMatrixSlice& gms_rhs1
481 , gms_rhs1.rows(), gms_rhs1.cols(), trans_rhs1
482 , gms_rhs2.rows(), gms_rhs2.cols(), trans_rhs2);
483 BLAS_Cpp::gemm(trans_rhs1,trans_rhs2,gms_lhs->rows(),gms_lhs->cols()
484 ,
cols(gms_rhs1.rows(),gms_rhs1.cols(),trans_rhs1)
485 ,alpha,gms_rhs1.col_ptr(1),gms_rhs1.max_rows()
486 ,gms_rhs2.col_ptr(1),gms_rhs2.max_rows()
487 ,beta,gms_lhs->col_ptr(1),gms_lhs->max_rows() );
498 void i_symm(
BLAS_Cpp::Side side, value_type alpha,
const DMatrixSliceSym& sym_rhs
499 ,
const DMatrixSlice& gms_rhs, value_type beta, DMatrixSlice* gms_lhs)
501 BLAS_Cpp::symm(side,sym_rhs.uplo(),gms_lhs->rows(),gms_lhs->cols()
502 ,alpha,sym_rhs.gms().col_ptr(1),sym_rhs.gms().max_rows()
503 ,gms_rhs.col_ptr(1),gms_rhs.max_rows()
504 ,beta,gms_lhs->col_ptr(1),gms_lhs->max_rows() );
509 void DenseLinAlgPack::Mp_StMtM(DMatrixSlice* gms_lhs, value_type alpha,
const DMatrixSliceSym& sym_rhs1
514 , sym_rhs1.gms().rows(), sym_rhs1.gms().cols(), trans_rhs1
515 , gms_rhs2.rows(), gms_rhs2.cols(), trans_rhs2);
517 i_symm(BLAS_Cpp::left,alpha,sym_rhs1,gms_rhs2,beta,gms_lhs);
522 assign(&tmp,gms_rhs2,trans_rhs2);
523 i_symm(BLAS_Cpp::left,alpha,sym_rhs1,tmp(),beta,gms_lhs);
527 void DenseLinAlgPack::Mp_StMtM(DMatrixSlice* gms_lhs, value_type alpha,
const DMatrixSlice& gms_rhs1
532 , gms_rhs1.rows(), gms_rhs1.cols(), trans_rhs1
533 , sym_rhs2.gms().rows(), sym_rhs2.gms().cols(), trans_rhs2 );
535 i_symm(BLAS_Cpp::right,alpha,sym_rhs2,gms_rhs1,beta,gms_lhs);
540 assign(&tmp,gms_rhs1,trans_rhs1);
541 i_symm(BLAS_Cpp::right,alpha,sym_rhs2,tmp(),beta,gms_lhs);
546 , value_type beta, DMatrixSliceSym* sym_lhs)
549 , gms_rhs.rows(), gms_rhs.cols(),
trans
550 , gms_rhs.rows(), gms_rhs.cols(),
trans_not(trans) );
551 BLAS_Cpp::syrk(sym_lhs->uplo(),
trans,sym_lhs->gms().rows()
552 ,
cols(gms_rhs.rows(), gms_rhs.cols(),
trans),alpha
553 ,gms_rhs.col_ptr(1),gms_rhs.max_rows(),beta
554 ,sym_lhs->gms().col_ptr(1),sym_lhs->gms().max_rows() );
557 void DenseLinAlgPack::syr2k(
BLAS_Cpp::Transp trans,value_type alpha,
const DMatrixSlice& gms_rhs1
558 ,
const DMatrixSlice& gms_rhs2, value_type beta, DMatrixSliceSym* sym_lhs)
561 , gms_rhs1.rows(), gms_rhs1.cols(),
trans
562 , gms_rhs2.rows(), gms_rhs2.cols(),
trans_not(trans) );
563 BLAS_Cpp::syr2k(sym_lhs->uplo(),
trans,sym_lhs->gms().rows()
564 ,
cols(gms_rhs1.rows(), gms_rhs1.cols(),
trans),alpha
565 ,gms_rhs1.col_ptr(1),gms_rhs1.max_rows()
566 ,gms_rhs2.col_ptr(1),gms_rhs2.max_rows(),beta
567 ,sym_lhs->gms().col_ptr(1),sym_lhs->gms().max_rows() );
582 , DMatrixSlice* gms_lhs)
584 BLAS_Cpp::trmm(side,tri_rhs.uplo(),
trans,tri_rhs.diag(),gms_lhs->rows(),gms_lhs->cols()
585 ,alpha,tri_rhs.gms().col_ptr(1),tri_rhs.gms().max_rows()
586 ,gms_lhs->col_ptr(1),gms_lhs->max_rows() );
593 void i_trmm_alt(
BLAS_Cpp::Side side, value_type alpha,
const DMatrixSliceTri& tri_rhs
597 assign(gms_lhs,gms_rhs,trans_gms_rhs);
598 i_trmm( side, trans_tri_rhs, alpha, tri_rhs, gms_lhs );
606 , DMatrixSlice* gms_lhs)
608 BLAS_Cpp::trsm(side,tri_rhs.uplo(),
trans,tri_rhs.diag(),gms_lhs->rows(),gms_lhs->cols()
609 ,alpha,tri_rhs.gms().col_ptr(1),tri_rhs.gms().max_rows()
610 ,gms_lhs->col_ptr(1),gms_lhs->max_rows() );
617 void i_trsm_alt(
BLAS_Cpp::Side side, value_type alpha,
const DMatrixSliceTri& tri_rhs
619 , DMatrixSlice* gms_lhs)
621 assign(gms_lhs,gms_rhs,trans_gms_rhs);
622 i_trsm( side, trans_tri_rhs, alpha, tri_rhs, gms_lhs );
627 void DenseLinAlgPack::M_StMtM(DMatrix* gm_lhs, value_type alpha,
const DMatrixSliceTri& tri_rhs1
631 MtM_assert_sizes( tri_rhs1.gms().rows(), tri_rhs1.gms().cols(), trans_rhs1
632 , gms_rhs2.rows(), gms_rhs2.cols(), trans_rhs2 );
633 gm_lhs->resize(
rows(tri_rhs1.gms().rows(), tri_rhs1.gms().cols(), trans_rhs1)
634 ,
cols(gms_rhs2.rows(), gms_rhs2.cols(), trans_rhs2) );
635 i_trmm_alt(BLAS_Cpp::left,alpha,tri_rhs1,trans_rhs1,gms_rhs2,trans_rhs2,&(*gm_lhs)());
638 void DenseLinAlgPack::M_StMtM(DMatrixSlice* gms_lhs, value_type alpha,
const DMatrixSliceTri& tri_rhs1
643 , tri_rhs1.gms().rows(), tri_rhs1.gms().cols(), trans_rhs1
644 , gms_rhs2.rows(), gms_rhs2.cols(), trans_rhs2 );
645 i_trmm_alt(BLAS_Cpp::left,alpha,tri_rhs1,trans_rhs1,gms_rhs2,trans_rhs2,gms_lhs);
648 void DenseLinAlgPack::M_StMtM(DMatrix* gm_lhs, value_type alpha,
const DMatrixSlice& gms_rhs1
652 MtM_assert_sizes( gms_rhs1.rows(), gms_rhs1.cols(), trans_rhs1
653 , tri_rhs2.gms().rows(), tri_rhs2.gms().cols(), trans_rhs2 );
654 gm_lhs->resize(
rows(gms_rhs1.rows(), gms_rhs1.cols(), trans_rhs1)
655 ,
cols(tri_rhs2.gms().rows(), tri_rhs2.gms().cols(), trans_rhs2) );
656 i_trmm_alt(BLAS_Cpp::right,alpha,tri_rhs2,trans_rhs2,gms_rhs1,trans_rhs1,&(*gm_lhs)());
659 void DenseLinAlgPack::M_StMtM(DMatrixSlice* gms_lhs, value_type alpha,
const DMatrixSlice& gms_rhs1
664 , gms_rhs1.rows(), gms_rhs1.cols(), trans_rhs1
665 , tri_rhs2.gms().rows(), tri_rhs2.gms().cols(), trans_rhs2 );
666 i_trmm_alt(BLAS_Cpp::right,alpha,tri_rhs2,trans_rhs2,gms_rhs1,trans_rhs1,gms_lhs);
669 void DenseLinAlgPack::Mp_StMtM(DMatrixSlice* gms_lhs, value_type alpha,
const DMatrixSliceTri& tri_rhs1
677 i_trmm(BLAS_Cpp::left,trans_rhs1,alpha,tri_rhs1,gms_lhs);
681 if(beta != 1.0) Mt_S(gms_lhs,beta);
683 M_StMtM(&tmp,alpha,tri_rhs1,trans_rhs1,gms_rhs2,trans_rhs2);
688 void DenseLinAlgPack::Mp_StMtM(DMatrixSlice* gms_lhs, value_type alpha,
const DMatrixSlice& gms_rhs1
696 i_trmm(BLAS_Cpp::right,trans_rhs2,alpha,tri_rhs2,gms_lhs);
700 if(beta != 1.0) Mt_S(gms_lhs,beta);
702 M_StMtM(&tmp,alpha,gms_rhs1,trans_rhs1,tri_rhs2,trans_rhs2);
707 void DenseLinAlgPack::M_StInvMtM(DMatrix* gm_lhs, value_type alpha,
const DMatrixSliceTri& tri_rhs1
711 MtM_assert_sizes( tri_rhs1.gms().rows(), tri_rhs1.gms().cols(), trans_rhs1
712 , gms_rhs2.rows(), gms_rhs2.cols(), trans_rhs2 );
713 gm_lhs->resize(
rows(tri_rhs1.gms().rows(), tri_rhs1.gms().cols(), trans_rhs1)
714 ,
cols(gms_rhs2.rows(), gms_rhs2.cols(), trans_rhs2) );
715 i_trsm_alt(BLAS_Cpp::left,alpha,tri_rhs1,trans_rhs1,gms_rhs2,trans_rhs2,&(*gm_lhs)());
718 void DenseLinAlgPack::M_StInvMtM(DMatrixSlice* gms_lhs, value_type alpha,
const DMatrixSliceTri& tri_rhs1
723 , tri_rhs1.gms().rows(), tri_rhs1.gms().cols(), trans_rhs1
724 , gms_rhs2.rows(), gms_rhs2.cols(), trans_rhs2 );
725 i_trsm_alt(BLAS_Cpp::left,alpha,tri_rhs1,trans_rhs1,gms_rhs2,trans_rhs2,gms_lhs);
728 void DenseLinAlgPack::M_StMtInvM(DMatrix* gm_lhs, value_type alpha,
const DMatrixSlice& gms_rhs1
732 MtM_assert_sizes( gms_rhs1.rows(), gms_rhs1.cols(), trans_rhs1
733 , tri_rhs2.gms().rows(), tri_rhs2.gms().cols(), trans_rhs2 );
734 gm_lhs->resize(
rows(gms_rhs1.rows(), gms_rhs1.cols(), trans_rhs1)
735 ,
cols(tri_rhs2.gms().rows(), tri_rhs2.gms().cols(), trans_rhs2) );
736 i_trsm_alt(BLAS_Cpp::right,alpha,tri_rhs2,trans_rhs2,gms_rhs1,trans_rhs1,&(*gm_lhs)());
739 void DenseLinAlgPack::M_StMtInvM(DMatrixSlice* gms_lhs, value_type alpha,
const DMatrixSlice& gms_rhs1
744 , gms_rhs1.rows(), gms_rhs1.cols(), trans_rhs1
745 , tri_rhs2.gms().rows(), tri_rhs2.gms().cols(), trans_rhs2 );
746 i_trsm_alt(BLAS_Cpp::right,alpha,tri_rhs2,trans_rhs2,gms_rhs1,trans_rhs1,gms_lhs);
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
size_type rows(size_type rows, size_type cols, BLAS_Cpp::Transp _trans)
Transp trans_not(Transp _trans)
size_type rows() const
Return the number of rows.
size_type cols(size_type rows, size_type cols, BLAS_Cpp::Transp _trans)