List of usage examples for java.util.stream IntStream range
public static IntStream range(int startInclusive, int endExclusive)
From source file:com.dgtlrepublic.anitomyj.StringHelper.java
/** Returns whether or not the {@code string} is mostly a latin string. */ public static boolean isMostlyLatinString(String string) { double length = StringUtils.isNotEmpty(string) ? 1.0 : string.length(); return IntStream.range(0, StringUtils.isEmpty(string) ? 0 : string.length()) .filter(value -> isLatinChar(string.charAt(value))).count() / length >= 0.5; }
From source file:org.anhonesteffort.dsp.filter.ComplexNumberMovingGainControl.java
public ComplexNumberMovingGainControl(int historyLength) { history = new CircularFifoQueue<>(historyLength); IntStream.range(0, historyLength).forEach(i -> history.offer(MINIMUM_ENVELOPE)); }
From source file:io.github.carlomicieli.footballdb.starter.pages.TableBuilder.java
private static List<String> merge(List<String> first, List<String> second) { if (first == null || first.size() == 0) return second; return IntStream.range(0, first.size()).mapToObj(id -> first.get(id) + "." + second.get(id)) .collect(Collectors.toList()); }
From source file:org.anhonesteffort.dsp.util.CircularFloatAveragingQueue.java
public float[] remove() { float[] averages = new float[arrayLength]; IntStream.range(0, arrayLength) .forEach(arrayIndex -> averages[arrayIndex] = (float) IntStream.range(0, queue.size()) .mapToDouble(queueIndex -> (double) queue.get(queueIndex)[arrayIndex]).average() .getAsDouble());/*from w w w. j a va2 s .com*/ queue.remove(); return averages; }
From source file:kishida.cnn.layers.MaxPoolingLayer.java
/** (max) */ @Override// w ww. j a v a 2 s. c om public float[] forward(float[] data) { IntStream.range(0, inputChannels).parallel().forEach(ch -> { for (int x = 0; x < outputWidth; ++x) { for (int y = 0; y < outputHeight; ++y) { float max = Float.NEGATIVE_INFINITY; for (int i = 0; i < size; ++i) { int xx = x * stride + i - size / 2; if (xx < 0 || xx >= inputWidth) { continue; } for (int j = 0; j < size; ++j) { int yy = y * stride + j - size / 2; if (yy < 0 || yy >= inputHeight) { continue; } float d = data[ch * inputWidth * inputHeight + xx * inputHeight + yy]; if (max < d) { max = d; } } } result[ch * outputWidth * outputHeight + x * outputHeight + y] = max; } } }); return result; }
From source file:com.create.validation.ValidationErrorsProvider.java
public List<ValidationError<?>> getValidationErrors() { return IntStream.range(0, targets.size()).boxed().map(this::getValidationError).filter(Objects::nonNull) .collect(Collectors.toList()); }
From source file:org.neo4j.nlp.examples.sentiment.main.java
private static Stack<Integer> getRandomizedIndex(int lowerBound, int upperBound) { List<Integer> randomIndex = new ArrayList<>(); Collections.addAll(randomIndex, ArrayUtils.toObject(IntStream.range(lowerBound, upperBound).toArray())); //randomIndex.sort((a, b) -> new Random().nextInt(2) == 0 ? -1 : 1 ); Stack<Integer> integerStack = new Stack<>(); integerStack.addAll(randomIndex);/*from w w w.j a v a 2 s . c om*/ return integerStack; }
From source file:com.create.validation.ListValidator.java
@Override public void validate(Object target, Errors errors) { final List<?> targets = (List) target; IntStream.range(0, targets.size()).forEach(index -> validate(targets, index, errors)); }
From source file:kishida.cnn.layers.MultiNormalizeLayer.java
@Override public float[] forward(float[] in) { IntStream.range(0, inputWidth).parallel().forEach(x -> { for (int y = 0; y < inputHeight; ++y) { float total = 0; int count = 0; for (int i = 0; i < size; ++i) { int xx = x + i - size / 2; if (xx < 0 || xx >= inputWidth) { continue; }/*from www . j av a2s. c o m*/ for (int j = 0; j < size; ++j) { int yy = y + j - size / 2; if (yy < 0 || yy >= inputHeight) { continue; } for (int ch = 0; ch < inputChannels; ++ch) { total += in[ch * inputHeight * inputWidth + xx * inputHeight + yy]; ++count; } } } float average = total / count; float variance = 0; for (int i = 0; i < size; ++i) { int xx = x + i - size / 2; if (xx < 0 || xx >= inputWidth) { continue; } for (int j = 0; j < size; ++j) { int yy = y + j - size / 2; if (yy < 0 || yy >= inputHeight) { continue; } for (int ch = 0; ch < inputChannels; ++ch) { float data = in[ch * inputHeight * inputWidth + xx * inputHeight + yy]; variance += (data - average) * (data - average); } } } float std = Math.max(threshold, (float) Math.sqrt(variance / count)); averages[x * inputHeight + y] = average; rates[x * inputHeight + y] = std; for (int ch = 0; ch < inputChannels; ++ch) { int pos = ch * inputHeight * inputWidth + x * inputHeight + y; result[pos] = (in[pos] - average) / std; } } }); return result; }
From source file:org.anhonesteffort.p25.util.CircularFloatAveragingQueue.java
public float[] remove() { float[] averages = new float[arrayLength]; IntStream.range(0, arrayLength) .forEach(arrayIndex -> averages[arrayIndex] = (float) IntStream.range(0, queueSize) .mapToDouble(queueIndex -> (double) queue.get(queueIndex)[arrayIndex]).average() .getAsDouble());/* www .j a va 2 s. c o m*/ queue.remove(); queueSize--; return averages; }