Example #1
0
export void score_ispc(uniform double w[],
       	               uniform double b[],
		       uniform double x[],
		       uniform double res[],
		       uniform int nrow,
		       uniform int ncol) {

  for (int i = 0; i < nrow; i++) {
    double s = 0.0;
    foreach(j = 0 ... ncol) {
      s += w[i * ncol + j] * x[j];
    }
    res[i] = reduce_add(s) + b[i];
  }
}
Example #2
0
  HDRILight::HDRILight(const Parms& parms)
    : width(0), height(0), pixels(null)
  {
    local2world = parms.getTransform("local2world",one);
    world2local = rcp(local2world);
    L = parms.getColor("L",one);
    pixels = parms.getImage("image");
    if (pixels == null) pixels = new Image3f(5,5,one);
    width  = (unsigned) pixels->width;
    height = (unsigned) pixels->height;

    Array2D<float> importance(height,width);
    for (size_t y = 0; y < height; y++)
      for (size_t x = 0; x < width; x++)
        importance.set(y, x, sinf(float(pi)*(y+0.5f)*rcp(float(height))) * reduce_add(pixels->get(x,y)));

    distribution = new Distribution2D(importance,width,height);
  }