本文整理汇总了Java中org.ojalgo.random.Uniform.doubleValue方法的典型用法代码示例。如果您正苦于以下问题:Java Uniform.doubleValue方法的具体用法?Java Uniform.doubleValue怎么用?Java Uniform.doubleValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.ojalgo.random.Uniform
的用法示例。
在下文中一共展示了Uniform.doubleValue方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDoubleKeys
import org.ojalgo.random.Uniform; //导入方法依赖的package包/类
public void testDoubleKeys() {
final int dim = 1000;
final Uniform tmpUniform = new Uniform(0, Double.MAX_VALUE);
final double[] keys = new double[dim];
final long[] indices = new long[dim];
for (int i = 0; i < dim; i++) {
keys[i] = tmpUniform.doubleValue();
indices[i] = Double.doubleToLongBits(keys[i]);
}
Arrays.sort(keys);
Arrays.sort(indices);
for (int i = 0; i < dim; i++) {
TestUtils.assertEquals(keys[i], Double.longBitsToDouble(indices[i]));
}
}
示例2: testEstimation
import org.ojalgo.random.Uniform; //导入方法依赖的package包/类
public void testEstimation() {
final int tmpMaxSamples = 9;
for (int tmpSamples = 1; tmpSamples <= tmpMaxSamples; tmpSamples++) {
final Uniform tmpRndm = new Uniform(-100, 200);
final double[] x = new double[tmpSamples];
final double[] y = new double[tmpSamples];
for (int i = 0; i < tmpSamples; i++) {
x[i] = tmpRndm.doubleValue();
y[i] = tmpRndm.doubleValue();
}
final int tmpDegree = tmpSamples - 1;
final PrimitivePolynomial tmpPoly = new PrimitivePolynomial(tmpDegree);
tmpPoly.estimate(Access1D.wrap(x), Access1D.wrap(y));
final NumberContext tmpEquals = new NumberContext(7, 14);
for (int i = 0; i < tmpSamples; i++) {
TestUtils.assertEquals(y[i], tmpPoly.invoke(x[i]), tmpEquals);
}
}
}
示例3: setup
import org.ojalgo.random.Uniform; //导入方法依赖的package包/类
@Override
@Setup
public void setup() {
FillMatchingLeft.THRESHOLD = dim / z;
final Uniform tmpSupplier = new Uniform();
left = PrimitiveDenseStore.FACTORY.makeFilled(dim, dim, tmpSupplier);
right = tmpSupplier.doubleValue();
target = PrimitiveDenseStore.FACTORY.makeZero(dim, dim);
}
示例4: setup
import org.ojalgo.random.Uniform; //导入方法依赖的package包/类
@Override
@Setup
public void setup() {
FillMatchingRight.THRESHOLD = dim / z;
final Uniform tmpSupplier = new Uniform();
left = tmpSupplier.doubleValue();
right = PrimitiveDenseStore.FACTORY.makeFilled(dim, dim, tmpSupplier);
target = PrimitiveDenseStore.FACTORY.makeZero(dim, dim);
}
示例5: testRandomGetSet
import org.ojalgo.random.Uniform; //导入方法依赖的package包/类
public void testRandomGetSet() {
final int tmpCount = 5000;
final BasicArray<Double> tmpArray = BufferArray.make(tmpCount);
TestUtils.assertEquals(tmpCount, tmpArray.count());
final Uniform tmpUniform = new Uniform();
for (int i = 0; i < 100; i++) {
final long tmpIndex = Uniform.randomInteger(tmpCount);
final double tmpExpected = tmpUniform.doubleValue();
tmpArray.set(tmpIndex, tmpExpected);
final double tmpActual = tmpArray.doubleValue(tmpIndex);
TestUtils.assertEquals(tmpExpected, tmpActual);
}
}
示例6: doTestGetSet
import org.ojalgo.random.Uniform; //导入方法依赖的package包/类
private void doTestGetSet(final BasicArray<Double> array) {
final long tmpCount = array.count();
TestUtils.assertEquals(tmpCount, array.count());
final Uniform tmpUniform = new Uniform();
for (int i = 0; i < 100; i++) {
final long tmpIndex = Uniform.randomInteger(tmpCount);
final double tmpExpected = tmpUniform.doubleValue();
array.set(tmpIndex, tmpExpected);
final double tmpActual = array.doubleValue(tmpIndex);
TestUtils.assertEquals(tmpExpected, tmpActual);
}
}
示例7: doTestRandomSetAndGetBack
import org.ojalgo.random.Uniform; //导入方法依赖的package包/类
static void doTestRandomSetAndGetBack(final BasicArray<Double> array, final long expectedCount) {
TestUtils.assertEquals(expectedCount, array.count());
final Uniform tmpUniform = new Uniform();
final Map<Long, Double> pairs = new HashMap<>();
for (int i = 0; i < 100; i++) {
final long tmpIndex = Uniform.randomInteger(expectedCount);
final double tmpValue = tmpUniform.doubleValue();
array.set(tmpIndex, tmpValue);
TestUtils.assertEquals(tmpValue, array.doubleValue(tmpIndex));
pairs.put(tmpIndex, tmpValue);
}
for (final Entry<Long, Double> pair : pairs.entrySet()) {
TestUtils.assertEquals(pair.getValue().doubleValue(), array.doubleValue(pair.getKey().longValue()));
}
}