当前位置: 首页>>代码示例>>Java>>正文


Java FastMath.ceil方法代码示例

本文整理汇总了Java中net.jafama.FastMath.ceil方法的典型用法代码示例。如果您正苦于以下问题:Java FastMath.ceil方法的具体用法?Java FastMath.ceil怎么用?Java FastMath.ceil使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.jafama.FastMath的用法示例。


在下文中一共展示了FastMath.ceil方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: strPartition

import net.jafama.FastMath; //导入方法依赖的package包/类
/**
 * Recursively partition.
 * 
 * @param objs Object list
 * @param start Subinterval start
 * @param end Subinterval end
 * @param depth Iteration depth (must be less than dimensionality!)
 * @param dims Total number of dimensions
 * @param maxEntries Maximum page size
 * @param c Comparison helper
 * @param ret Output list
 * @param <T> data type
 */
protected <T extends SpatialComparable> void strPartition(List<T> objs, int start, int end, int depth, int dims, int maxEntries, SpatialSingleMeanComparator c, List<List<T>> ret) {
  final int p = (int) FastMath.ceil((end - start) / (double) maxEntries);
  final int s = (int) FastMath.ceil(FastMath.pow(p, 1.0 / (dims - depth)));

  final double len = end - start; // double intentional!
  for (int i = 0; i < s; i++) {
    // We don't completely sort, but only ensure the quantile is invariant.
    int s2 = start + (int) ((i * len) / s);
    int e2 = start + (int) (((i + 1) * len) / s);
    // LoggingUtil.warning("STR " + dim + " s2:" + s2 + " e2:" + e2);
    if (e2 < end) {
      c.setDimension(depth);
      QuickSelect.quickSelect(objs, c, s2, end, e2);
    }
    if (depth + 1 == dims) {
      ret.add(objs.subList(s2, e2));
    } else {
      // Descend
      strPartition(objs, s2, e2, depth + 1, dims, maxEntries, c, ret);
    }
  }
}
 
开发者ID:elki-project,项目名称:elki,代码行数:36,代码来源:SortTileRecursiveBulkSplit.java

示例2: computeMeans

import net.jafama.FastMath; //导入方法依赖的package包/类
/**
 * The specified sorted list of dense subspaces is divided into the selected
 * set I and the pruned set P. For each set the mean of the cover fractions is
 * computed.
 * 
 * @param denseSubspaces the dense subspaces in reverse order by their
 *        coverage
 * @return the mean of the cover fractions, the first value is the mean of the
 *         selected set I, the second value is the mean of the pruned set P.
 */
private int[][] computeMeans(List<CLIQUESubspace<V>> denseSubspaces) {
  int n = denseSubspaces.size() - 1;

  int[] mi = new int[n + 1], mp = new int[n + 1];
  double resultMI = 0, resultMP = 0;

  for(int i = 0; i < denseSubspaces.size(); i++) {
    resultMI += denseSubspaces.get(i).getCoverage();
    resultMP += denseSubspaces.get(n - i).getCoverage();
    mi[i] = (int) FastMath.ceil(resultMI / (i + 1));
    if(i != n) {
      mp[n - 1 - i] = (int) FastMath.ceil(resultMP / (i + 1));
    }
  }

  return new int[][] { mi, mp };
}
 
开发者ID:elki-project,项目名称:elki,代码行数:28,代码来源:CLIQUE.java

示例3: runForEachK

import net.jafama.FastMath; //导入方法依赖的package包/类
/**
 * Iterate over the k range.
 *
 * @param prefix Prefix string
 * @param startk Start k
 * @param stepk Step k
 * @param maxk Max k
 * @param runner Runner to run
 * @param out Output function
 */
private void runForEachK(String prefix, int startk, int stepk, int maxk, IntFunction<OutlierResult> runner, BiConsumer<String, OutlierResult> out) {
  if(isDisabled(prefix)) {
    LOG.verbose("Skipping (disabled): " + prefix);
    return; // Disabled
  }
  LOG.verbose("Running " + prefix);
  final int digits = (int) FastMath.ceil(FastMath.log10(maxk + 1));
  final String format = "%s-%0" + digits + "d";
  for(int k = startk; k <= maxk; k += stepk) {
    Duration time = LOG.newDuration(this.getClass().getCanonicalName() + "." + prefix + ".k" + k + ".runtime").begin();
    OutlierResult result = runner.apply(k);
    LOG.statistics(time.end());
    if(result != null) {
      out.accept(String.format(Locale.ROOT, format, prefix, k), result);
      result.getHierarchy().removeSubtree(result);
    }
  }
}
 
开发者ID:elki-project,项目名称:elki,代码行数:29,代码来源:ComputeKNNOutlierScores.java

示例4: partition

import net.jafama.FastMath; //导入方法依赖的package包/类
@Override
public <T extends SpatialComparable> List<List<T>> partition(List<T> spatialObjects, int minEntries, int maxEntries) {
  final int dims = spatialObjects.get(0).getDimensionality();
  final int p = (int) FastMath.ceil(spatialObjects.size() / (double) maxEntries);
  List<List<T>> ret = new ArrayList<>(p);
  strPartition(spatialObjects, 0, spatialObjects.size(), 0, dims, maxEntries, new SpatialSingleMeanComparator(0), ret);
  return ret;
}
 
开发者ID:elki-project,项目名称:elki,代码行数:9,代码来源:AdaptiveSortTileRecursiveBulkSplit.java

示例5: colorMultiply

import net.jafama.FastMath; //导入方法依赖的package包/类
private int colorMultiply(int col, double reldist, boolean ceil) {
  if(steps > 0) {
    if(!ceil) {
      reldist = FastMath.round(reldist * steps) / steps;
    }
    else {
      reldist = FastMath.ceil(reldist * steps) / steps;
    }
  }
  else if(steps < 0 && reldist > 0.) {
    double s = reldist * -steps;
    double off = Math.abs(s - FastMath.round(s));
    double factor = -steps * 1. / 1000; // height;
    if(off < factor) { // Blend with black:
      factor = (off / factor);
      int a = (col >> 24) & 0xFF;
      a = (int) (a * FastMath.sqrt(reldist)) & 0xFF;
      a = (int) ((1 - factor) * 0xFF + factor * a);
      int r = (int) (factor * ((col >> 16) & 0xFF));
      int g = (int) (factor * ((col >> 8) & 0xFF));
      int b = (int) (factor * (col & 0xFF));
      return a << 24 | r << 16 | g << 8 | b;
    }
  }
  int a = (col >> 24) & 0xFF, r = (col >> 16) & 0xFF, g = (col >> 8) & 0xFF,
      b = (col) & 0xFF;
  a = (int) (a * FastMath.sqrt(reldist)) & 0xFF;
  return a << 24 | r << 16 | g << 8 | b;
}
 
开发者ID:elki-project,项目名称:elki,代码行数:30,代码来源:VisualizeGeodesicDistances.java

示例6: strPartition

import net.jafama.FastMath; //导入方法依赖的package包/类
/**
 * Recursively partition.
 * 
 * @param objs Object list
 * @param start Subinterval start
 * @param end Subinterval end
 * @param depth Iteration depth (must be less than dimensionality!)
 * @param dims Total number of dimensions
 * @param maxEntries Maximum page size
 * @param c Comparison helper
 * @param ret Output list
 * @param <T> data type
 */
protected <T extends SpatialComparable> void strPartition(List<T> objs, int start, int end, int depth, int dims, int maxEntries, SpatialSingleMeanComparator c, List<List<T>> ret) {
  final int p = (int) FastMath.ceil((end - start) / (double) maxEntries);

  // Compute min and max:
  double[] mm = new double[dims * 2];
  for (int d = 0; d < mm.length; d += 2) {
    mm[d] = Double.POSITIVE_INFINITY; // min <- +inf
    mm[d + 1] = Double.NEGATIVE_INFINITY; // max <- -inf
  }
  for (int i = start; i < end; i++) {
    T o = objs.get(i);
    for (int d1 = 0, d2 = 0; d2 < mm.length; d1++, d2 += 2) {
      mm[d2] = Math.min(mm[d2], o.getMin(d1));
      mm[d2 + 1] = Math.max(mm[d2 + 1], o.getMax(d1));
    }
  }
  // Find maximum and compute extends
  double maxex = 0.0;
  int sdim = depth;
  double[] exts = new double[dims];
  for (int d = 0; d < mm.length; d += 2) {
    final double extend = mm[d + 1] - mm[d];
    if (extend > maxex) {
      maxex = extend;
      sdim = d >>> 1;
    }
    exts[d >>> 1] = extend;
  }
  // Compute sum of the k largest extends:
  Arrays.sort(exts);
  double extsum = 0.;
  for (int d = depth; d < exts.length; d++) {
    extsum += exts[d];
  }
  // Chose the number of partitions:
  final int s;
  if (maxex > 0. && depth + 1 < dims) {
    s = (int) FastMath.ceil(FastMath.pow(p, 1.0 / (dims - depth)) * (dims - depth) * maxex / extsum);
  } else {
    s = (int) FastMath.ceil(FastMath.pow(p, 1.0 / (dims - depth)));
  }

  final double len = end - start; // double intentional!
  for (int i = 0; i < s; i++) {
    // We don't completely sort, but only ensure the quantile is invariant.
    int s2 = start + (int) ((i * len) / s);
    int e2 = start + (int) (((i + 1) * len) / s);
    // LoggingUtil.warning("STR " + dim + " s2:" + s2 + " e2:" + e2);
    if (e2 < end) {
      c.setDimension(sdim);
      QuickSelect.quickSelect(objs, c, s2, end, e2);
    }
    if (depth + 1 == dims) {
      ret.add(objs.subList(s2, e2));
    } else {
      // Descend
      strPartition(objs, s2, e2, depth + 1, dims, maxEntries, c, ret);
    }
  }
}
 
开发者ID:elki-project,项目名称:elki,代码行数:74,代码来源:AdaptiveSortTileRecursiveBulkSplit.java

示例7: strPartition

import net.jafama.FastMath; //导入方法依赖的package包/类
/**
 * Recursively partition.
 * 
 * @param objs Object list
 * @param start Subinterval start
 * @param end Subinterval end
 * @param depth Iteration depth (must be less than dimensionality!)
 * @param dims Total number of dimensions
 * @param maxEntries Maximum page size
 * @param c Comparison helper
 * @param ret Output list
 * @param <T> data type
 */
protected <T extends SpatialComparable> void strPartition(List<T> objs, int start, int end, int depth, int dims, int maxEntries, SpatialSingleMeanComparator c, List<List<T>> ret) {
  final int p = (int) FastMath.ceil((end - start) / (double) maxEntries);

  // Compute min and max:
  double[] mm = new double[dims * 2];
  for (int d = 0; d < mm.length; d += 2) {
    mm[d] = Double.POSITIVE_INFINITY; // min <- +inf
    mm[d + 1] = Double.NEGATIVE_INFINITY; // max <- -inf
  }
  for (int i = start; i < end; i++) {
    T o = objs.get(i);
    for (int d1 = 0, d2 = 0; d2 < mm.length; d1++, d2 += 2) {
      mm[d2] = Math.min(mm[d2], o.getMin(d1));
      mm[d2 + 1] = Math.max(mm[d2 + 1], o.getMax(d1));
    }
  }
  // Find maximum and compute extends
  double maxex = 0.0;
  int sdim = -1;
  for (int d = 0; d < mm.length; d += 2) {
    final double extend = mm[d + 1] - mm[d];
    if (extend > maxex) {
      maxex = extend;
      sdim = d >> 1;
    }
  }
  // Chose the number of partitions:
  final int s = (int) FastMath.ceil(FastMath.pow(p, 1.0 / (dims - depth)));

  final double len = end - start; // double intentional!
  for (int i = 0; i < s; i++) {
    // We don't completely sort, but only ensure the quantile is invariant.
    int s2 = start + (int) ((i * len) / s);
    int e2 = start + (int) (((i + 1) * len) / s);
    // LoggingUtil.warning("STR " + dim + " s2:" + s2 + " e2:" + e2);
    if (e2 < end) {
      c.setDimension(sdim);
      QuickSelect.quickSelect(objs, c, s2, end, e2);
    }
    if (depth + 1 == dims) {
      ret.add(objs.subList(s2, e2));
    } else {
      // Descend
      strPartition(objs, s2, e2, depth + 1, dims, maxEntries, c, ret);
    }
  }
}
 
开发者ID:elki-project,项目名称:elki,代码行数:61,代码来源:MaxExtensionSortTileRecursiveBulkSplit.java

示例8: initHeap

import net.jafama.FastMath; //导入方法依赖的package包/类
/**
 * Initializes the heap with the root intervals.
 *
 * @param heap the heap to be initialized
 * @param relation the database storing the parameterization functions
 * @param dim the dimensionality of the database
 * @param ids the ids of the database
 */
private void initHeap(ObjectHeap<IntegerPriorityObject<CASHInterval>> heap, Relation<ParameterizationFunction> relation, int dim, DBIDs ids) {
  CASHIntervalSplit split = new CASHIntervalSplit(relation, minPts);

  // determine minimum and maximum function value of all functions
  double[] minMax = determineMinMaxDistance(relation, dim);

  double d_min = minMax[0], d_max = minMax[1];
  double dIntervalLength = d_max - d_min;
  int numDIntervals = (int) FastMath.ceil(dIntervalLength / jitter);
  double dIntervalSize = dIntervalLength / numDIntervals;
  double[] d_mins = new double[numDIntervals],
      d_maxs = new double[numDIntervals];

  if(LOG.isVerbose()) {
    LOG.verbose(new StringBuilder().append("d_min ").append(d_min)//
        .append("\nd_max ").append(d_max)//
        .append("\nnumDIntervals ").append(numDIntervals)//
        .append("\ndIntervalSize ").append(dIntervalSize).toString());
  }

  // alpha intervals
  double[] alphaMin = new double[dim - 1], alphaMax = new double[dim - 1];
  Arrays.fill(alphaMax, Math.PI);

  for(int i = 0; i < numDIntervals; i++) {
    d_mins[i] = (i == 0) ? d_min : d_maxs[i - 1];
    d_maxs[i] = (i < numDIntervals - 1) ? d_mins[i] + dIntervalSize : d_max - d_mins[i];

    HyperBoundingBox alphaInterval = new HyperBoundingBox(alphaMin, alphaMax);
    ModifiableDBIDs intervalIDs = split.determineIDs(ids, alphaInterval, d_mins[i], d_maxs[i]);
    if(intervalIDs != null && intervalIDs.size() >= minPts) {
      CASHInterval rootInterval = new CASHInterval(alphaMin, alphaMax, split, intervalIDs, -1, 0, d_mins[i], d_maxs[i]);
      heap.add(new IntegerPriorityObject<>(rootInterval.priority(), rootInterval));
    }
  }

  if(LOG.isDebuggingFiner()) {
    LOG.debugFiner(new StringBuilder().append("heap.size: ").append(heap.size()).toString());
  }
}
 
开发者ID:elki-project,项目名称:elki,代码行数:49,代码来源:CASH.java

示例9: NearestNeighborAffinityMatrixBuilder

import net.jafama.FastMath; //导入方法依赖的package包/类
/**
 * Constructor.
 *
 * @param distanceFunction Distance function
 * @param perplexity Desired perplexity (will use 3*perplexity neighbors)
 */
public NearestNeighborAffinityMatrixBuilder(DistanceFunction<? super O> distanceFunction, double perplexity) {
  super(distanceFunction, perplexity);
  this.numberOfNeighbours = (int) FastMath.ceil(3 * perplexity);
}
 
开发者ID:elki-project,项目名称:elki,代码行数:11,代码来源:NearestNeighborAffinityMatrixBuilder.java


注:本文中的net.jafama.FastMath.ceil方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。