com.github.TKnudsen.ComplexDataObject.model.processors.ParameterSupportTools Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of complex-data-object Show documentation
Show all versions of complex-data-object Show documentation
A library that models real-world objects in Java, referred to as ComplexDataObjects. Other features: IO and preprocessing of ComplexDataObjects.
package com.github.TKnudsen.ComplexDataObject.model.processors;
import java.util.ArrayList;
import java.util.List;
import java.util.SortedSet;
import java.util.TreeSet;
import com.github.TKnudsen.ComplexDataObject.model.tools.MathFunctions;
public class ParameterSupportTools {
public static List getAlternativeIntegers(int baseline, int count) {
SortedSet set = new TreeSet<>();
int lower = count / 2;
double div = 1 / (lower + 1.0);
for (int i = 1; i < lower + 1; i++) {
int newValue = (int) (MathFunctions.round(baseline * (i * div), 0));
if (newValue != baseline)
set.add(newValue);
}
int upper = count - lower;
for (int i = 1; i < upper + 1; i++) {
double pow = Math.pow(2, i);
int newValue = (int) (baseline * pow);
if (newValue != baseline)
set.add(newValue);
}
return new ArrayList<>(set);
}
public static List getAlternativeLongs(long baseline, int count) {
SortedSet set = new TreeSet<>();
int lower = count / 2;
double div = 1 / (lower + 1.0);
for (int i = 1; i < lower + 1; i++) {
long newValue = (long) (MathFunctions.round(baseline * (i * div), 0));
if (newValue != baseline)
set.add(newValue);
}
int upper = count - lower;
for (int i = 1; i < upper + 1; i++) {
double pow = Math.pow(2, i);
long newValue = (long) (baseline * pow);
if (newValue != baseline)
set.add(newValue);
}
return new ArrayList<>(set);
}
}