示例#1
0
void BLASInterface::Madd(const dMatrix& A,const dMatrix& B,dMatrix& X,bool Atranspose,bool Btranspose,double alpha,double beta)
{
  Assert(IsCompliant(A));
  Assert(IsCompliant(B));
  Assert(IsCompliant(X));
  Assert(X.m == (Atranspose?A.n:A.m));
  Assert(X.n == (Btranspose?B.m:B.n));

  integer m = (Atranspose?A.n:A.m);
  integer n = (Btranspose?B.m:B.n);
  integer k = (Atranspose?A.m:A.n);
  Assert(k == (Btranspose?B.n:B.m));
  integer lda = A.m;
  integer ldb = B.m;
  integer ldx = X.m;
  char transa = (Atranspose?'T':'N');
  char transb = (Btranspose?'T':'N');
  dgemm_(&transa,&transb,&m,&n,&k,
	 &alpha,
	 A.getStart(),&lda,
	 B.getStart(),&ldb,
	 &beta,
	 X.getStart(),&ldx);
}
示例#2
0
void Madd(const dMatrix& A,const dVector& x,dVector& y,double alpha,double beta,bool transpose)
{
  if(A.isRowMajor()) {
    Assert(A.jstride == 1);
    transpose = !transpose;
  }
  else {
    Assert(A.istride == 1);
    //Assert(IsCompliant(A));
  }
  //Assert(IsCompliant(A));
  Assert(x.n == A.n);
  Assert(y.n == A.m);
  integer m=A.m;
  integer n=A.n;
  integer lda=A.m;
  integer xinc=x.stride;
  integer yinc=y.stride;
  char trans = (transpose?'T':'N');
  dgemv_(&trans,&m,&n,&alpha,A.getStart(),&lda,x.getStart(),&xinc,&beta,y.getStart(),&yinc);
}