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


Java Uniform类代码示例

本文整理汇总了Java中org.ojalgo.random.Uniform的典型用法代码示例。如果您正苦于以下问题:Java Uniform类的具体用法?Java Uniform怎么用?Java Uniform使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Uniform类属于org.ojalgo.random包,在下文中一共展示了Uniform类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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]));
        }

    }
 
开发者ID:optimatika,项目名称:ojAlgo-finance,代码行数:22,代码来源:CalendarDateSeriesTest.java

示例2: makeClearText

import org.ojalgo.random.Uniform; //导入依赖的package包/类
public static String makeClearText(final int length) {

        final char[] retVal = new char[length];

        final Uniform tmpRandom = new Uniform(0, 128);

        for (int c = 0; c < length; c++) {
            int tmpChar = ASCII.NBSP;
            do {
                tmpChar = tmpRandom.intValue();
            } while (!ASCII.isAlphanumeric(tmpChar));
            retVal[c] = (char) tmpChar;
        }

        return String.valueOf(retVal);
    }
 
开发者ID:optimatika,项目名称:ojAlgo,代码行数:17,代码来源:Password.java

示例3: 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);
            }
        }
    }
}
 
开发者ID:optimatika,项目名称:ojAlgo,代码行数:21,代码来源:IndexSelector.java

示例4: 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);
            }
        }
    }
}
 
开发者ID:optimatika,项目名称:ojAlgo,代码行数:21,代码来源:IndexSelector.java

示例5: 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);
            }
        }
    }
}
 
开发者ID:optimatika,项目名称:ojAlgo,代码行数:28,代码来源:IndexSelector.java

示例6: testAddIntIntNumber

import org.ojalgo.random.Uniform; //导入依赖的package包/类
/**
 * @see BasicMatrix.Builder#add(long, long, Number)
 */
public void testAddIntIntNumber() {

    final int tmpRow = Uniform.randomInteger((int) myBigAA.countRows());
    final int tmpCol = Uniform.randomInteger((int) myBigAA.countColumns());

    final Builder<RationalMatrix> tmpBigBuilder = myBigAA.copy();
    tmpBigBuilder.add(tmpRow, tmpCol, myNmbr);
    myExpMtrx = tmpBigBuilder.build();

    final Builder<ComplexMatrix> tmpComplexBuilder = myComplexAA.copy();
    tmpComplexBuilder.add(tmpRow, tmpCol, myNmbr);
    myActMtrx = tmpComplexBuilder.build();

    TestUtils.assertEquals(myExpMtrx, myActMtrx, EVALUATION);

    final Builder<PrimitiveMatrix> tmpPrimitiveBuilder = myPrimitiveAA.copy();
    tmpPrimitiveBuilder.add(tmpRow, tmpCol, myNmbr);
    myActMtrx = tmpPrimitiveBuilder.build();

    TestUtils.assertEquals(myExpMtrx, myActMtrx, EVALUATION);
}
 
开发者ID:optimatika,项目名称:ojAlgo,代码行数:25,代码来源:BasicMatrixTest.java

示例7: testSetIntIntNumber

import org.ojalgo.random.Uniform; //导入依赖的package包/类
/**
 * @see BasicMatrix.Builder#set(long, long, Number)
 */
public void testSetIntIntNumber() {

    final int tmpRow = Uniform.randomInteger((int) myBigAA.countRows());
    final int tmpCol = Uniform.randomInteger((int) myBigAA.countColumns());

    final Builder<RationalMatrix> tmpBigBuilder = myBigAA.copy();
    tmpBigBuilder.set(tmpRow, tmpCol, myNmbr);
    myExpMtrx = tmpBigBuilder.build();

    final Builder<ComplexMatrix> tmpComplexBuilder = myComplexAA.copy();
    tmpComplexBuilder.set(tmpRow, tmpCol, myNmbr);
    myActMtrx = tmpComplexBuilder.build();

    TestUtils.assertEquals(myExpMtrx, myActMtrx, EVALUATION);

    final Builder<PrimitiveMatrix> tmpPrimitiveBuilder = myPrimitiveAA.copy();
    tmpPrimitiveBuilder.set(tmpRow, tmpCol, myNmbr);
    myActMtrx = tmpPrimitiveBuilder.build();

    TestUtils.assertEquals(myExpMtrx, myActMtrx, EVALUATION);
}
 
开发者ID:optimatika,项目名称:ojAlgo,代码行数:25,代码来源:BasicMatrixTest.java

示例8: testSolveIdentity

import org.ojalgo.random.Uniform; //导入依赖的package包/类
public void testSolveIdentity() {

        final Access2D<?> tmpIdentity = MatrixStore.PRIMITIVE.makeIdentity(9).get();
        final Access2D<?> tmpRandom = PrimitiveDenseStore.FACTORY.makeFilled(9, 1, new Uniform());

        final List<MatrixDecomposition<Double>> tmpAllDecomps = MatrixDecompositionTests.getAllPrimitive();
        for (final MatrixDecomposition<Double> tmpDecomp : tmpAllDecomps) {
            if (tmpDecomp instanceof SolverTask) {
                final SolverTask<Double> tmpSolverTask = (SolverTask<Double>) tmpDecomp;
                try {
                    TestUtils.assertEquals(tmpDecomp.getClass().toString(), tmpRandom, tmpSolverTask.solve(tmpIdentity, tmpRandom));
                } catch (final RecoverableCondition xcptn) {
                    TestUtils.fail(tmpDecomp.getClass().toString() + " " + xcptn.getMessage());
                }
            }
        }
    }
 
开发者ID:optimatika,项目名称:ojAlgo,代码行数:18,代码来源:DesignCase.java

示例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 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));
}
 
开发者ID:optimatika,项目名称:ojAlgo,代码行数:17,代码来源:SuperimposedMatrixColumnCase.java

示例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);

    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);
}
 
开发者ID:optimatika,项目名称:ojAlgo,代码行数:20,代码来源:SelectedRowsCase.java

示例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);

    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);
}
 
开发者ID:optimatika,项目名称:ojAlgo,代码行数:20,代码来源:SelectedColumnsCase.java

示例12: 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));
}
 
开发者ID:optimatika,项目名称:ojAlgo,代码行数:17,代码来源:SuperimposedMatrixRowCase.java

示例13: 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()));
}
 
开发者ID:optimatika,项目名称:ojAlgo,代码行数:26,代码来源:SuperimposedMatrixElementCase.java

示例14: testStratCombPortfolioMixerRandom

import org.ojalgo.random.Uniform; //导入依赖的package包/类
public void testStratCombPortfolioMixerRandom() {

        final FinancePortfolio tmpTarget = new SimplePortfolio(QUARTER, QUARTER, QUARTER, QUARTER).normalise();

        final Uniform tmpGen = new Uniform();

        final FinancePortfolio tmpStrat1 = new SimplePortfolio(tmpGen.doubleValue(), tmpGen.doubleValue(), tmpGen.doubleValue(), tmpGen.doubleValue())
                .normalise();
        final FinancePortfolio tmpStrat2 = new SimplePortfolio(tmpGen.doubleValue(), tmpGen.doubleValue(), tmpGen.doubleValue(), tmpGen.doubleValue())
                .normalise();
        final FinancePortfolio tmpStrat3 = new SimplePortfolio(tmpGen.doubleValue(), tmpGen.doubleValue(), tmpGen.doubleValue(), tmpGen.doubleValue())
                .normalise();

        final PortfolioMixer tmpMixer = new PortfolioMixer(tmpTarget, tmpStrat1, tmpStrat2, tmpStrat3);

        final int tmpExpectedNumberOfStrategies = 2;
        final List<BigDecimal> tmpStrategyWeights = tmpMixer.mix(tmpExpectedNumberOfStrategies);

        int tmpUseCount = 0;
        double tmpTotalWeight = 0D;

        for (final BigDecimal tmpWeight : tmpStrategyWeights) {
            if (tmpWeight.signum() != 0) {
                tmpUseCount++;
                tmpTotalWeight += tmpWeight.doubleValue();
            }
        }

        TestUtils.assertEquals(tmpExpectedNumberOfStrategies, tmpUseCount);
        TestUtils.assertEquals(PrimitiveMath.ONE, tmpTotalWeight, 1E-14 / PrimitiveMath.THREE / PrimitiveMath.HUNDRED);
    }
 
开发者ID:optimatika,项目名称:ojAlgo-finance,代码行数:32,代码来源:StrategyMixer.java

示例15: makeRandomComplexStore

import org.ojalgo.random.Uniform; //导入依赖的package包/类
public static PhysicalStore<ComplexNumber> makeRandomComplexStore(final int aRowDim, final int aColDim) {

        final PhysicalStore<ComplexNumber> retVal = GenericDenseStore.COMPLEX.makeZero(aRowDim, aColDim);

        final Uniform tmpArgGen = new Uniform(PrimitiveMath.ZERO, PrimitiveMath.TWO_PI);

        for (int j = 0; j < aColDim; j++) {
            for (int i = 0; i < aRowDim; i++) {
                retVal.set(i, j, ComplexNumber.makePolar(PrimitiveMath.E, tmpArgGen.doubleValue()).add(PrimitiveMath.PI));
            }
        }

        return retVal;
    }
 
开发者ID:optimatika,项目名称:ojAlgo,代码行数:15,代码来源:MatrixUtils.java


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