本文整理汇总了Java中org.ojalgo.random.Uniform.randomInteger方法的典型用法代码示例。如果您正苦于以下问题:Java Uniform.randomInteger方法的具体用法?Java Uniform.randomInteger怎么用?Java Uniform.randomInteger使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.ojalgo.random.Uniform
的用法示例。
在下文中一共展示了Uniform.randomInteger方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: grow
import org.ojalgo.random.Uniform; //导入方法依赖的package包/类
/**
* Randomly include 1 of the currently excluded
*/
public void grow() {
if (myExcludedLength > 0) {
final int tmpInclRef = Uniform.randomInteger(myExcludedLength);
int tmpExclCount = -1;
for (int i = 0; (i < mySelector.length) && (tmpExclCount < tmpInclRef); i++) {
if (!mySelector[i]) {
tmpExclCount++;
}
if (tmpExclCount == tmpInclRef) {
this.include(i);
}
}
}
}
示例2: shrink
import org.ojalgo.random.Uniform; //导入方法依赖的package包/类
/**
* Randomly exclude 1 of the currently included
*/
public void shrink() {
if (myIncludedLength > 0) {
final int tmpExclRef = Uniform.randomInteger(myIncludedLength);
int tmpInclCount = -1;
for (int i = 0; (i < mySelector.length) && (tmpInclCount < tmpExclRef); i++) {
if (mySelector[i]) {
tmpInclCount++;
}
if (tmpInclCount == tmpExclRef) {
this.exclude(i);
}
}
}
}
示例3: shuffle
import org.ojalgo.random.Uniform; //导入方法依赖的package包/类
/**
* Randomly exclude 1 of the currently included and include 1 of the excluded
*/
public void shuffle() {
if ((myIncludedLength > 0) && (myExcludedLength > 0)) {
final int tmpExclRef = Uniform.randomInteger(myIncludedLength);
int tmpInclCount = -1;
final int tmpInclRef = Uniform.randomInteger(myExcludedLength);
int tmpExclCount = -1;
for (int i = 0; (i < mySelector.length) && ((tmpInclCount < tmpExclRef) || (tmpExclCount < tmpInclRef)); i++) {
if (mySelector[i]) {
tmpInclCount++;
} else {
tmpExclCount++;
}
if (tmpInclCount == tmpExclRef) {
this.exclude(i);
} else if (tmpExclCount == tmpInclRef) {
this.include(i);
}
}
}
}
示例4: setUp
import org.ojalgo.random.Uniform; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
final int tmpRowDim = Uniform.randomInteger(1, 9);
final int tmpColDim = Uniform.randomInteger(1, 9);
final BasicMatrix tmpBase = NonPhysicalTest.makeRandomMatrix(tmpRowDim, tmpColDim);
final BasicMatrix tmpRow = NonPhysicalTest.makeRandomMatrix(1, tmpColDim);
final int tmpIndex = Uniform.randomInteger(tmpRowDim);
myBigStore = new SuperimposedStore<>(BigDenseStore.FACTORY.copy(tmpBase), tmpIndex, 0, BigDenseStore.FACTORY.copy(tmpRow));
myComplexStore = new SuperimposedStore<>(ComplexDenseStore.FACTORY.copy(tmpBase), tmpIndex, 0, ComplexDenseStore.FACTORY.copy(tmpRow));
myPrimitiveStore = new SuperimposedStore<>(PrimitiveDenseStore.FACTORY.copy(tmpBase), tmpIndex, 0, PrimitiveDenseStore.FACTORY.copy(tmpRow));
}
示例5: setUp
import org.ojalgo.random.Uniform; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
final int tmpRowDim = Uniform.randomInteger(1, 9);
final int tmpColDim = Uniform.randomInteger(1, 9);
final BasicMatrix tmpBase = NonPhysicalTest.makeRandomMatrix(tmpRowDim, tmpColDim);
final int tmpRowIndex = Uniform.randomInteger(tmpRowDim);
final int tmpColumnIndex = Uniform.randomInteger(tmpColDim);
final BigDecimal tmpElement = BigMath.PI;
final MatrixStore<BigDecimal> aBase = BigDenseStore.FACTORY.copy(tmpBase);
// myBigStore = new SuperimposedMatrixStore<BigDecimal>(BigDenseStore.FACTORY.copyMatrix(tmpBase), tmpRowIndex, tmpColumnIndex, tmpElement);
// myComplexStore = new SuperimposedMatrixStore<ComplexNumber>(ComplexDenseStore.FACTORY.copyMatrix(tmpBase), tmpRowIndex, tmpColumnIndex, ComplexNumber.makeReal(tmpElement.doubleValue()));
// myPrimitiveStore = new SuperimposedMatrixStore<Double>(PrimitiveDenseStore.FACTORY.copyMatrix(tmpBase), tmpRowIndex, tmpColumnIndex, tmpElement.doubleValue());
myBigStore = new SuperimposedStore<>(aBase, tmpRowIndex, tmpColumnIndex, new SingleStore<>(aBase.physical(), tmpElement));
final MatrixStore<ComplexNumber> aBase1 = ComplexDenseStore.FACTORY.copy(tmpBase);
myComplexStore = new SuperimposedStore<>(aBase1, tmpRowIndex, tmpColumnIndex,
new SingleStore<>(aBase1.physical(), ComplexNumber.valueOf(tmpElement.doubleValue())));
final MatrixStore<Double> aBase2 = PrimitiveDenseStore.FACTORY.copy(tmpBase);
myPrimitiveStore = new SuperimposedStore<>(aBase2, tmpRowIndex, tmpColumnIndex, new SingleStore<>(aBase2.physical(), tmpElement.doubleValue()));
}
示例6: setUp
import org.ojalgo.random.Uniform; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
final int tmpRowDim = Uniform.randomInteger(1, 9);
final int tmpColDim = Uniform.randomInteger(1, 9);
final BasicMatrix tmpBase = NonPhysicalTest.makeRandomMatrix(tmpRowDim, tmpColDim);
final int[] tmpCols = new int[Uniform.randomInteger(1, tmpColDim)];
for (int i = 0; i < tmpCols.length; i++) {
tmpCols[i] = Uniform.randomInteger(tmpColDim);
}
myBigStore = new ColumnsStore<>(BigDenseStore.FACTORY.copy(tmpBase), tmpCols);
myComplexStore = new ColumnsStore<>(ComplexDenseStore.FACTORY.copy(tmpBase), tmpCols);
myPrimitiveStore = new ColumnsStore<>(PrimitiveDenseStore.FACTORY.copy(tmpBase), tmpCols);
}
示例7: setUp
import org.ojalgo.random.Uniform; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
final int tmpRowDim = Uniform.randomInteger(1, 9);
final int tmpColDim = Uniform.randomInteger(1, 9);
final BasicMatrix tmpBase = NonPhysicalTest.makeRandomMatrix(tmpRowDim, tmpColDim);
final BasicMatrix tmpColumn = NonPhysicalTest.makeRandomMatrix(tmpRowDim, 1);
final int tmpIndex = Uniform.randomInteger(tmpColDim);
myBigStore = new SuperimposedStore<>(BigDenseStore.FACTORY.copy(tmpBase), 0, tmpIndex, BigDenseStore.FACTORY.copy(tmpColumn));
myComplexStore = new SuperimposedStore<>(ComplexDenseStore.FACTORY.copy(tmpBase), 0, tmpIndex, ComplexDenseStore.FACTORY.copy(tmpColumn));
myPrimitiveStore = new SuperimposedStore<>(PrimitiveDenseStore.FACTORY.copy(tmpBase), 0, tmpIndex, PrimitiveDenseStore.FACTORY.copy(tmpColumn));
}
示例8: setUp
import org.ojalgo.random.Uniform; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
final int tmpRowDim = Uniform.randomInteger(1, 9);
final int tmpColDim = Uniform.randomInteger(1, 9);
final BasicMatrix tmpBase = NonPhysicalTest.makeRandomMatrix(tmpRowDim, tmpColDim);
final int[] tmpRows = new int[Uniform.randomInteger(1, tmpRowDim)];
for (int i = 0; i < tmpRows.length; i++) {
tmpRows[i] = Uniform.randomInteger(tmpRowDim);
}
myBigStore = new RowsStore<>(BigDenseStore.FACTORY.copy(tmpBase), tmpRows);
myComplexStore = new RowsStore<>(ComplexDenseStore.FACTORY.copy(tmpBase), tmpRows);
myPrimitiveStore = new RowsStore<>(PrimitiveDenseStore.FACTORY.copy(tmpBase), tmpRows);
}
示例9: setUp
import org.ojalgo.random.Uniform; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
final int tmpRowDim = Uniform.randomInteger(1, 9);
final int tmpColDim = Uniform.randomInteger(1, 9);
final BasicMatrix tmpBase = NonPhysicalTest.makeRandomMatrix(tmpRowDim, tmpColDim);
final BasicMatrix tmpLower = NonPhysicalTest.makeRandomMatrix(tmpRowDim, tmpColDim);
myBigStore = new AboveBelowStore<>(BigDenseStore.FACTORY.copy(tmpBase), BigDenseStore.FACTORY.copy(tmpLower));
myComplexStore = new AboveBelowStore<>(ComplexDenseStore.FACTORY.copy(tmpBase), ComplexDenseStore.FACTORY.copy(tmpLower));
myPrimitiveStore = new AboveBelowStore<>(PrimitiveDenseStore.FACTORY.copy(tmpBase), PrimitiveDenseStore.FACTORY.copy(tmpLower));
}
示例10: setUp
import org.ojalgo.random.Uniform; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
final int tmpRowDim = Uniform.randomInteger(1, 9);
final int tmpColDim = Uniform.randomInteger(1, 9);
final BasicMatrix tmpBase = NonPhysicalTest.makeRandomMatrix(tmpRowDim, tmpColDim);
myBigStore = new ConjugatedStore<>(BigDenseStore.FACTORY.copy(tmpBase));
myComplexStore = new ConjugatedStore<>(ComplexDenseStore.FACTORY.copy(tmpBase));
myPrimitiveStore = new ConjugatedStore<>(PrimitiveDenseStore.FACTORY.copy(tmpBase));
}
示例11: setUp
import org.ojalgo.random.Uniform; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
final int tmpRowDim = Uniform.randomInteger(1, 9);
final int tmpColDim = Uniform.randomInteger(1, 9);
myBigStore = new ZeroStore<>(BigDenseStore.FACTORY, tmpRowDim, tmpColDim);
myComplexStore = new ZeroStore<>(ComplexDenseStore.FACTORY, tmpRowDim, tmpColDim);
myPrimitiveStore = new ZeroStore<>(PrimitiveDenseStore.FACTORY, tmpRowDim, tmpColDim);
}
示例12: testAccess2D
import org.ojalgo.random.Uniform; //导入方法依赖的package包/类
public void testAccess2D() {
final long tmpCountRows = 1 + Uniform.randomInteger(10);
final long tmpCountColumns = 1 + Uniform.randomInteger(10);
final long tmpCount = tmpCountRows * tmpCountColumns;
final long[] tmpStructure = new long[] { tmpCountRows, tmpCountColumns };
TestUtils.assertEquals(tmpCount, StructureAnyD.count(tmpStructure));
final long tmpExpIndex = Uniform.randomInteger(tmpCount);
final long tmpRow = Structure2D.row(tmpExpIndex, tmpStructure);
final long tmpColumn = Structure2D.column(tmpExpIndex, tmpStructure);
final long[] tmpReference = new long[] { tmpRow, tmpColumn };
TestUtils.assertEquals(tmpReference, StructureAnyD.reference(tmpExpIndex, tmpStructure));
TestUtils.assertEquals(tmpExpIndex, StructureAnyD.index(tmpStructure, tmpReference));
TestUtils.assertEquals(tmpExpIndex, Structure2D.index(tmpCountRows, tmpRow, tmpColumn));
final long tmpExpRow = Uniform.randomInteger(tmpCountRows);
final long tmpExpColumn = Uniform.randomInteger(tmpCountColumns);
final long tmpIndex1 = Structure2D.index(tmpCountRows, tmpExpRow, tmpExpColumn);
final long tmpIndex2 = Structure2D.index(tmpCountRows, tmpExpRow, tmpExpColumn);
TestUtils.assertEquals(tmpIndex1, tmpIndex2);
TestUtils.assertEquals(tmpExpRow, Structure2D.row(tmpIndex1, tmpStructure));
TestUtils.assertEquals(tmpExpColumn, Structure2D.column(tmpIndex1, tmpStructure));
}
示例13: _testP20111213square
import org.ojalgo.random.Uniform; //导入方法依赖的package包/类
/**
* A user reported problems solving complex valued (overdetermined) equation systemes.
*/
public void _testP20111213square() {
final int tmpDim = Uniform.randomInteger(2, 6);
final PhysicalStore<ComplexNumber> tmpSquare = MatrixUtils.makeRandomComplexStore(tmpDim, tmpDim);
final MatrixStore<ComplexNumber> tmpHermitian = tmpSquare.conjugate().multiply(tmpSquare);
final PhysicalStore<ComplexNumber> tmpExpected = ComplexDenseStore.FACTORY.makeEye(tmpDim, tmpDim);
MatrixStore<ComplexNumber> tmpActual;
@SuppressWarnings("unchecked")
final MatrixDecomposition<ComplexNumber>[] tmpCmplxDecomps = new MatrixDecomposition[] { Bidiagonal.COMPLEX.make(), Cholesky.COMPLEX.make(),
Eigenvalue.COMPLEX.make(MatrixDecomposition.TYPICAL,
true)/*
* , HessenbergDecomposition. makeComplex()
*/,
LU.COMPLEX.make(), QR.COMPLEX.make(),
SingularValue.COMPLEX.make() /*
* , TridiagonalDecomposition . makeComplex ( )
*/ };
for (final MatrixDecomposition<ComplexNumber> tmpDecomposition : tmpCmplxDecomps) {
tmpDecomposition.decompose(tmpHermitian);
if (MatrixDecompositionTests.DEBUG) {
BasicLogger.debug(tmpDecomposition.toString());
BasicLogger.debug("Original", tmpHermitian);
BasicLogger.debug("Recretaed", tmpDecomposition.reconstruct());
}
TestUtils.assertEquals("Recreation: " + tmpDecomposition.toString(), tmpHermitian, tmpDecomposition.reconstruct(), new NumberContext(8, 5));
if ((tmpDecomposition instanceof MatrixDecomposition.Solver<?>) && ((Solver) tmpDecomposition).isSolvable()) {
tmpActual = ((Solver) tmpDecomposition).getSolution(tmpHermitian);
if (MatrixDecompositionTests.DEBUG) {
BasicLogger.debug("Actual", tmpActual);
}
TestUtils.assertEquals("Solving: " + tmpDecomposition.toString(), tmpExpected, tmpActual, new NumberContext(7, 6));
}
}
}
示例14: testP20111213tall
import org.ojalgo.random.Uniform; //导入方法依赖的package包/类
/**
* A user reported problems solving complex valued (overdetermined) equation systemes.
*/
public void testP20111213tall() {
final int tmpDim = Uniform.randomInteger(2, 6);
final PhysicalStore<ComplexNumber> tmpTall = MatrixUtils.makeRandomComplexStore(tmpDim + tmpDim, tmpDim);
final PhysicalStore<ComplexNumber> tmpExpected = ComplexDenseStore.FACTORY.makeEye(tmpDim, tmpDim);
MatrixStore<ComplexNumber> tmpActual;
@SuppressWarnings("unchecked")
final MatrixDecomposition<ComplexNumber>[] tmpCmplxDecomps = new MatrixDecomposition[] {
Bidiagonal.COMPLEX.make()/*
* , LUDecomposition . makeComplex ( )
*/, QR.COMPLEX.make(), SingularValue.COMPLEX.make() };
for (final MatrixDecomposition<ComplexNumber> tmpDecomposition : tmpCmplxDecomps) {
tmpDecomposition.decompose(tmpTall);
if (MatrixDecompositionTests.DEBUG) {
BasicLogger.debug(tmpDecomposition.toString());
BasicLogger.debug("Original", tmpTall);
BasicLogger.debug("Recretaed", tmpDecomposition.reconstruct());
}
TestUtils.assertEquals(tmpDecomposition.toString(), tmpTall, tmpDecomposition.reconstruct(), new NumberContext(7, 5));
if ((tmpDecomposition instanceof MatrixDecomposition.Solver<?>) && ((Solver) tmpDecomposition).isSolvable()) {
tmpActual = ((Solver) tmpDecomposition).getSolution(tmpTall);
if (MatrixDecompositionTests.DEBUG) {
BasicLogger.debug("Actual", tmpActual);
}
TestUtils.assertEquals(tmpDecomposition.toString(), tmpExpected, tmpActual, new NumberContext(7, 6));
}
}
}
示例15: 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);
}
}