Package ca.eandb.util

Examples of ca.eandb.util.DoubleArray


      int callbackInterval = Math.min(1000,
          Math.max(1, pairsPerSeedTask / 100));
      int nextCallback = 0;

      DoubleArray weight = new DoubleArray();
      short[] lightPathLength = new short[pairsPerSeedTask];
      short[] eyePathLength = new short[pairsPerSeedTask];

      long randomSeed = initialRandomSeed;
      for (int i = 0; i < pairsPerSeedTask; i++) {
        if (--nextCallback <= 0) {
          if (!monitor.notifyProgress(i, pairsPerSeedTask)) {
            monitor.notifyCancelled();
            return null;
          }
          nextCallback = callbackInterval;
        }

        Path path = generatePath(randomSeed++);

        /* store information about the path so we don't have to
         * regenerate it during the resampling phase.
         */
        if (path.getLightPathLength() > Short.MAX_VALUE) {
          throw new UnexpectedException("Light subpath too long.");
        }
        if (path.getEyePathLength() > Short.MAX_VALUE) {
          throw new UnexpectedException("Eye subpath too long.");
        }
        lightPathLength[i] = (short) path.getLightPathLength();
        eyePathLength[i] = (short) path.getEyePathLength();

        join(path.getLightTail(), path.getEyeTail(), weight);
      }

      monitor.notifyStatusChanged("Resampling MLT seeds");

      double totalWeight = MathUtil.sum(weight);
      double scale = (double) numPathSeeds / totalWeight;
      double x = 0.5;
      int x0 = (int) Math.floor(x);
      int x1;
      List<PathSeed> seeds = new ArrayList<PathSeed>();

      for (int i = 0, n = 0; i < pairsPerSeedTask; i++) {
        int s0 = lightPathLength[i];
        int t0 = eyePathLength[i];
        for (int s = s0; s >= -1; s--) {
          for (int t = t0; t >= -1; t--, n++) {
            x += scale * weight.get(n);
            x1 = (int) Math.floor(x);
            for (int j = x0; j < x1; j++) {
              PathSeed seed = new PathSeed();
              seed.randomSeed = initialRandomSeed + (long) i;
              seed.lightPathLength = s;
View Full Code Here


  private int position = 0;

  public RepeatableRandom(Random inner) {
    this.inner = inner;
    values.add(new DoubleArray());
  }
View Full Code Here

  /* (non-Javadoc)
   * @see ca.eandb.jmist.framework.Random#next()
   */
  public double next() {
    DoubleArray seq = values.get(sequence);
    while (position >= seq.size()) {
      seq.add(inner.next());
    }
    return seq.get(position++);
  }
View Full Code Here

    values.get(sequence).resize(position);
  }

  public void mark() {
    if (++sequence >= values.size()) {
      values.add(new DoubleArray());
    }
    position = 0;
  }
View Full Code Here

  public void mutate() {
    mutate(1.0 / 16.0);
  }

  public void mutate(double width) {
    DoubleArray seq = values.get(sequence);
    for (int i = position, n = seq.size(); i < n; i++) {
      seq.set(i, mutate(seq.get(i), width));
    }
  }
View Full Code Here

      seq.set(i, mutate(seq.get(i), width));
    }
  }

  public void mutate(double width, int n) {
    DoubleArray seq = values.get(sequence);
    for (int i = position, j = 0; j < n && i < seq.size(); i++, j++) {
      seq.set(i, mutate(seq.get(i), width));
    }
  }
View Full Code Here

    }
  }

  public void clear() {
    values.clear();
    values.add(new DoubleArray());
    sequence = 0;
    position = 0;
  }
View Full Code Here

        values.add((int) reader.readUnsignedInt());
      }
      return new PlyIntegralListProperty(values, this);
    }
    case FLOAT: {
      DoubleArray values = new DoubleArray(count);
      for (int i = 0; i < count; i++) {
        values.add(reader.readFloat());
      }
      return new PlyFloatListProperty(values, this);
    }
    case DOUBLE: {
      DoubleArray values = new DoubleArray(count);
      for (int i = 0; i < count; i++) {
        values.add(reader.readDouble());
      }
      return new PlyFloatListProperty(values, this);
    }
    default:
      throw new UnexpectedException(String.format(
View Full Code Here

TOP

Related Classes of ca.eandb.util.DoubleArray

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.