void BLASInterface::Madd(dVector& v,const dVector& x,double a)
{
  integer n=x.n;
  integer vinc = v.stride;
  integer xinc = x.stride;
  daxpy_(&n,&a,x.getStart(),&xinc,v.getStart(),&vinc);
}
double BLASInterface::Dot(const dVector& x,const dVector& y)
{
  Assert(x.n == y.n);
  integer n=x.n;
  integer xinc = x.stride;
  integer yinc = y.stride;
  return ddot_(&n,x.getStart(),&xinc,y.getStart(),&yinc);
}
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);
}
void BLASInterface::InplaceMul(dVector& x,double a)
{
  integer n=x.n;
  integer xinc = x.stride;
  dscal_(&n,&a,x.getStart(),&xinc);
}
int BLASInterface::MaxAbsIndex(const dVector& x)
{
  integer n=x.n;
  integer xinc = x.stride;
  return idamax_(&n,x.getStart(),&xinc)-1;
}
double BLASInterface::Norm_L1(const dVector& x)
{
  integer n=x.n;
  integer xinc = x.stride;
  return dasum_(&n,x.getStart(),&xinc);
}