예제 #1
0
void N_VScale(real c, N_Vector x, N_Vector z)
{
  integer N;
  real *xd, *zd;

  if (z == x) {       /* BLAS usage: scale x <- cx */
    VScaleBy(c, x);
    return;
  }

  if (c == ONE) {
    VCopy(x, z);
  } else if (c == -ONE) {
    VNeg(x, z);
  } else {
    N = x->length;
    xd = x->data;
    zd = z->data;
#ifndef _OPENMP
    for (integer i=0; i < N; i++) *zd++ = c * (*xd++);
#else
    #pragma omp parallel for
    for (integer i=0; i < N; i++)
      zd[i] = c * xd[i];
#endif
  }
}
예제 #2
0
void N_VScale(float c, N_Vector x, N_Vector z)
{
  int i, N;
  float *xd, *zd;

  if (z == x) {       /* BLAS usage: scale x <- cx */
    VScaleBy(c, x);
    return;
  }

  if (c == ONE) {
    VCopy(x, z);
  } else if (c == -ONE) {
    VNeg(x, z);
  } else {
    N = x->length;
    xd = x->data;
    zd = z->data;
    for (i=0; i < N; ++i ) *zd++ = c * (*xd++);
  }
}