42 #ifndef LIN_ALG_OP_PACK_DEF_H
43 #define LIN_ALG_OP_PACK_DEF_H
49 namespace LinAlgOpPack {
90 v_lhs->resize(V_rhs.dim());
92 Vp_V(&(*v_lhs)(),V_rhs);
98 v_lhs->resize(V_rhs.dim());
100 Vp_StV(&(*v_lhs)(),alpha,V_rhs);
104 template <
class V1,
class V2>
107 v_lhs->resize(V1_rhs1.dim());
110 Vp_V(&vs_lhs,V1_rhs1);
111 Vp_V(&vs_lhs,V2_rhs2);
116 template <
class V1,
class V2>
119 v_lhs->resize(V1_rhs1.dim());
122 Vp_V(&vs_lhs,V1_rhs1);
123 Vp_StV(&vs_lhs,-1.0,V2_rhs2);
134 Vp_StV(&(*v_lhs)(),alpha,V_rhs1);
153 Vp_StV(vs_lhs,alpha,V_rhs);
157 template <
class V1,
class V2>
162 Vp_V(vs_lhs,V1_rhs1);
163 Vp_V(vs_lhs,V2_rhs2);
167 template <
class V1,
class V2>
172 Vp_V(vs_lhs,V1_rhs1);
173 Vp_StV(vs_lhs,-1.0,V2_rhs2);
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);
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>
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) );
226 Mp_M(&gms_lhs,M1_rhs1,trans_rhs1);
227 Mp_M(&gms_lhs,M2_rhs2,trans_rhs2);
231 template <
class M1,
class M2>
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) );
241 Mp_M(&gms_lhs,M1_rhs1,trans_rhs1);
242 Mp_StM(&gms_lhs,-1.0,M2_rhs2,trans_rhs2);
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);
263 , M_rhs.rows(), M_rhs.cols(), trans_rhs );
265 Mp_StM(gms_lhs,1.0,M_rhs,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>
283 ,M2_rhs2.rows(),M2_rhs2.cols(),trans_rhs2 );
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>
297 ,M2_rhs2.rows(),M2_rhs2.cols(),trans_rhs2 );
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);
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>
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>
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>
356 Vp_StMtV(vs_lhs,alpha,M_rhs1,trans_rhs1,V_rhs2,0.0);
360 template <
class M,
class V>
366 Vp_StMtV(vs_lhs,1.0,M_rhs1,trans_rhs1,V_rhs2,0.0);
380 template <
class M1,
class M2>
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>
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>
412 , M2_rhs2.rows(), M2_rhs2.cols(), trans_rhs2 );
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>
425 , M2_rhs2.rows(), M2_rhs2.cols(), trans_rhs2 );
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
void M_StMtM(MatrixOp *M_lhs, value_type alpha, const MatrixOp &M_rhs1, BLAS_Cpp::Transp trans_rhs1, const MatrixOp &M_rhs2, BLAS_Cpp::Transp trans_rhs2)
M_lhs = alpha * op(M_rhs1) * op(M_rhs2).
void V_StVpV(VectorMutable *v_lhs, value_type alpha, const V &V_rhs1, const Vector &vs_rhs2)
v_lhs = alpha * V_rhs1 + vs_rhs2.
void Vp_StMtV(DVectorSlice *vs_lhs, value_type alpha, const MatrixOp &mwo_rhs1, BLAS_Cpp::Transp trans_rhs1, const DVectorSlice &vs_rhs2, value_type beta=1.0)
vs_lhs = alpha * op(mwo_rhs1) * vs_rhs2 + beta * vs_lhs.
void Vp_StV(DVectorSlice *vs_lhs, value_type alpha, const DVectorSlice &vs_rhs)
vs_lhs += alpha * vs_rhs (BLAS xAXPY)
void assign(DMatrix *gm_lhs, value_type alpha)
gm_lhs = alpha (elementwise)
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).
void MtM_assert_sizes(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)
size_type cols() const
Return the number of columns.
void Vp_StV(VectorMutable *v_lhs, const value_type &alpha, const Vector &v_rhs)
v_lhs = alpha * v_rhs + v_lhs
size_type rows(size_type rows, size_type cols, BLAS_Cpp::Transp _trans)
Return rows of a possible transposed matrix.
void assign(VectorMutable *v_lhs, const V &V_rhs)
v_lhs = V_rhs.
void V_StV(VectorMutable *v_lhs, value_type alpha, const V &V_rhs)
v_lhs = alpha * V_rhs.
void Mp_StM(DMatrixSlice *vs_lhs, value_type alpha, const MatrixOp &mwo_rhs1, BLAS_Cpp::Transp trans_rhs1)
m_lhs += alpha * op(mwo_rhs1).
void M_MtM(MatrixOp *M_lhs, const MatrixOp &M_rhs1, BLAS_Cpp::Transp trans_rhs1, const MatrixOp &M_rhs2, BLAS_Cpp::Transp trans_rhs2)
M_lhs = op(M_rhs1) * op(M_rhs2).
void Mp_M_assert_sizes(size_type m_lhs_rows, size_type m_lhs_cols, BLAS_Cpp::Transp trans_lhs, size_type m_rhs_rows, size_type m_rhs_cols, BLAS_Cpp::Transp trans_rhs)
op(m_lhs) += op op(m_rhs)
void V_StMtV(VectorMutable *v_lhs, value_type alpha, const MatrixOp &M_rhs1, BLAS_Cpp::Transp trans_rhs1, const V &V_rhs2)
v_lhs = alpha * op(M_rhs1) * V_rhs2.
void MopM_assert_sizes(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)
v_rhs1 op v_rhs2
void Vp_V_assert_sizes(size_type v_lhs_size, size_type v_rhs_size)
v_lhs += op v_rhs
void M_MmM(MatrixOp *M_lhs, const MatrixOp &M_rhs1, BLAS_Cpp::Transp trans_rhs1, const MatrixOp &M_rhs2, BLAS_Cpp::Transp trans_rhs2)
M_lhs = op(M_rhs1) - op(M_rhs2).
void assert_gms_lhs(const DMatrixSlice &gms_lhs, size_type rows, size_type cols, BLAS_Cpp::Transp trans_rhs=BLAS_Cpp::no_trans)
void M_MpM(MatrixOp *M_lhs, const MatrixOp &M_rhs1, BLAS_Cpp::Transp trans_rhs1, const MatrixOp &M_rhs2, BLAS_Cpp::Transp trans_rhs2)
void M_StM(MatrixOp *M_lhs, value_type alpha, const MatrixOp &M_rhs, BLAS_Cpp::Transp trans_rhs)
gm_lhs = alpha * M_rhs.
void V_VpV(VectorMutable *v_lhs, const V1 &V1_rhs1, const V2 &V2_rhs2)
void Mt_S(DMatrixSlice *gms_lhs, value_type alpha)
gms_lhs *= alpha (BLAS xSCAL)
const LAPACK_C_Decl::f_int & M
void Mp_StMtM(DMatrixSlice *gms_lhs, value_type alpha, const DMatrixSlice &gms_rhs1, BLAS_Cpp::Transp trans_rhs1, const DMatrixSlice &gms_rhs2, BLAS_Cpp::Transp trans_rhs2, value_type beta=1.0)
void resize(size_type rows, size_type cols, value_type val=value_type())
Resize matrix to a (rows x cols) matrix and initializes any added elements by val.
void Mp_M(MatrixOp *M_lhs, const MatrixOp &M_rhs, BLAS_Cpp::Transp trans_rhs)
M_lhs += op(M_rhs).
void VopV_assert_sizes(size_type v_rhs1_size, size_type v_rhs2_size)
v_rhs1 op v_rhs2
DenseLinAlgPack::VectorSliceTmpl< value_type > DVectorSlice
size_type rows() const
Return the number of rows.
DenseLinAlgPack::VectorTmpl< value_type > DVector
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)
void V_MtV(VectorMutable *v_lhs, const MatrixOp &M_rhs1, BLAS_Cpp::Transp trans_rhs1, const V &V_rhs2)
v_lhs = op(M_rhs1) * V_rhs2.
AbstractLinAlgPack::value_type value_type
void Mp_StM(DMatrixSliceTriEle *tri_lhs, value_type alpha, const DMatrixSliceTriEle &tri_rhs)
tri_lhs += alpha * tri_rhs (BLAS xAXPY)
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
void Vp_StMtV(DVectorSlice *vs_lhs, value_type alpha, const DMatrixSlice &gms_rhs1, BLAS_Cpp::Transp trans_rhs1, const DVectorSlice &vs_rhs2, value_type beta=1.0)
vs_lhs = alpha * op(gms_rhs1) * vs_rhs2 + beta * vs_lhs (BLAS xGEMV)
void M_StMpM(MatrixOp *M_lhs, value_type alpha, const MatrixOp &M_rhs1, BLAS_Cpp::Transp trans_rhs1, const MatrixOp &gms_rhs2, BLAS_Cpp::Transp trans_rhs2)
M_lhs = alpha * op(M_rhs1) + op(gms_rhs2).
void MtV_assert_sizes(size_type m_rhs1_rows, size_type m_rhs1_cols, BLAS_Cpp::Transp trans_rhs1, size_type v_rhs2_size)
op(m_rhs1) * v_rhs2
size_type cols(size_type rows, size_type cols, BLAS_Cpp::Transp _trans)
Return columns of a possible transposed matrix.
void V_VmV(VectorMutable *v_lhs, const V1 &V1_rhs1, const V2 &V2_rhs2)
v_lhs = V_rhs1 - V_rhs2.
void Vp_V(VectorMutable *v_lhs, const V &V_rhs)
v_lhs += V_rhs.