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


Java FastMath.min方法代码示例

本文整理汇总了Java中org.apache.commons.math3.util.FastMath.min方法的典型用法代码示例。如果您正苦于以下问题:Java FastMath.min方法的具体用法?Java FastMath.min怎么用?Java FastMath.min使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.math3.util.FastMath的用法示例。


在下文中一共展示了FastMath.min方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateP

import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
private double updateP (double duration, double[] p, double[] pDot, double[] pDotDot, double[] pDotDotDot){
	double max_dotdotdot = 0.0;
	for (int i = 0; i < (p.length-1); i++){
		if (FastMath.abs(pDotDotDot[i]) > max_dotdotdot)
			max_dotdotdot = FastMath.abs(pDotDotDot[i]);
	}
			
	double timeStep = FastMath.min(FastMath.pow((epsilon*6/max_dotdotdot), 1.0/3), FastMath.min(duration, max_step));

	double timeStepSquare = timeStep*timeStep*0.5;
	for (int i = 0; i < (p.length-1); i++){
		double new_val = p[i] + pDot[i]*timeStep + pDotDot[i]*timeStepSquare;
		double diff = FastMath.abs(new_val - p[i]);
		while (new_val > 1 || new_val < 0 || diff>0.2){
			timeStep *= 0.9;
			timeStepSquare = timeStep*timeStep*0.5;
			new_val = p[i] + pDot[i]*timeStep + pDotDot[i]*timeStepSquare;
			diff = FastMath.abs(new_val - p[i]);
		}			
	}
	doUpdating(timeStep, timeStepSquare, p, pDot, pDotDot);
	duration -= timeStep;
	return duration;
	
	
}
 
开发者ID:nicfel,项目名称:Mascot,代码行数:27,代码来源:Euler2ndOrder.java

示例2: getBackwardsMigration

import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
@Override    
  public double[][] getBackwardsMigration(int i){
int intervalNr;
  	if (i >= rateShiftsInput.get().getDimension())
  		intervalNr = rateShiftsInput.get().getDimension()-1;
  	else
  		intervalNr = i;

  	double[][] m = new double[dimensionInput.get()][dimensionInput.get()];
double[] mig = migrationGLMInput.get().getRates(intervalNr);
double[] Ne = NeGLMInput.get().getRates(intervalNr);

int c = 0;
for (int a = 0; a < dimensionInput.get(); a++){
	for (int b = 0; b < dimensionInput.get(); b++){
		if (a!=b){
			m[b][a] = FastMath.min( 
					Ne[a]*mig[c]/Ne[b],
					maxRateInput.get());
			c++;
		}
	}
}
return m;
  }
 
开发者ID:nicfel,项目名称:Mascot,代码行数:26,代码来源:GLM.java

示例3: BiDiagonalTransformer

import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/**
 * Build the transformation to bi-diagonal shape of a matrix.
 * @param matrix the matrix to transform.
 */
public BiDiagonalTransformer(RealMatrix matrix) {

    final int m = matrix.getRowDimension();
    final int n = matrix.getColumnDimension();
    final int p = FastMath.min(m, n);
    householderVectors = matrix.getData();
    main      = new double[p];
    secondary = new double[p - 1];
    cachedU   = null;
    cachedB   = null;
    cachedV   = null;

    // transform matrix
    if (m >= n) {
        transformToUpperBiDiagonal();
    } else {
        transformToLowerBiDiagonal();
    }

}
 
开发者ID:jiaminghan,项目名称:droidplanner-master,代码行数:25,代码来源:BiDiagonalTransformer.java

示例4: walkInRowOrder

import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public T walkInRowOrder(final FieldMatrixPreservingVisitor<T> visitor) {
    visitor.start(rows, columns, 0, rows - 1, 0, columns - 1);
    for (int iBlock = 0; iBlock < blockRows; ++iBlock) {
        final int pStart = iBlock * BLOCK_SIZE;
        final int pEnd   = FastMath.min(pStart + BLOCK_SIZE, rows);
        for (int p = pStart; p < pEnd; ++p) {
            for (int jBlock = 0; jBlock < blockColumns; ++jBlock) {
                final int jWidth = blockWidth(jBlock);
                final int qStart = jBlock * BLOCK_SIZE;
                final int qEnd   = FastMath.min(qStart + BLOCK_SIZE, columns);
                final T[] block = blocks[iBlock * blockColumns + jBlock];
                int k = (p - pStart) * jWidth;
                for (int q = qStart; q < qEnd; ++q) {
                    visitor.visit(p, q, block[k]);
                    ++k;
                }
            }
         }
    }
    return visitor.end();
}
 
开发者ID:jiaminghan,项目名称:droidplanner-master,代码行数:24,代码来源:BlockFieldMatrix.java

示例5: walkInRowOrder

import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public double walkInRowOrder(final RealMatrixChangingVisitor visitor) {
    visitor.start(rows, columns, 0, rows - 1, 0, columns - 1);
    for (int iBlock = 0; iBlock < blockRows; ++iBlock) {
        final int pStart = iBlock * BLOCK_SIZE;
        final int pEnd = FastMath.min(pStart + BLOCK_SIZE, rows);
        for (int p = pStart; p < pEnd; ++p) {
            for (int jBlock = 0; jBlock < blockColumns; ++jBlock) {
                final int jWidth = blockWidth(jBlock);
                final int qStart = jBlock * BLOCK_SIZE;
                final int qEnd = FastMath.min(qStart + BLOCK_SIZE, columns);
                final double[] block = blocks[iBlock * blockColumns + jBlock];
                int k = (p - pStart) * jWidth;
                for (int q = qStart; q < qEnd; ++q) {
                    block[k] = visitor.visit(p, q, block[k]);
                    ++k;
                }
            }
         }
    }
    return visitor.end();
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:24,代码来源:BlockRealMatrix.java

示例6: walkInOptimizedOrder

import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public double walkInOptimizedOrder(final RealMatrixChangingVisitor visitor) {
    visitor.start(rows, columns, 0, rows - 1, 0, columns - 1);
    int blockIndex = 0;
    for (int iBlock = 0; iBlock < blockRows; ++iBlock) {
        final int pStart = iBlock * BLOCK_SIZE;
        final int pEnd = FastMath.min(pStart + BLOCK_SIZE, rows);
        for (int jBlock = 0; jBlock < blockColumns; ++jBlock) {
            final int qStart = jBlock * BLOCK_SIZE;
            final int qEnd = FastMath.min(qStart + BLOCK_SIZE, columns);
            final double[] block = blocks[blockIndex];
            int k = 0;
            for (int p = pStart; p < pEnd; ++p) {
                for (int q = qStart; q < qEnd; ++q) {
                    block[k] = visitor.visit(p, q, block[k]);
                    ++k;
                }
            }
            ++blockIndex;
        }
    }
    return visitor.end();
}
 
开发者ID:jiaminghan,项目名称:droidplanner-master,代码行数:25,代码来源:BlockRealMatrix.java

示例7: walkInOptimizedOrder

import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public double walkInOptimizedOrder(final RealMatrixPreservingVisitor visitor) {
    visitor.start(rows, columns, 0, rows - 1, 0, columns - 1);
    int blockIndex = 0;
    for (int iBlock = 0; iBlock < blockRows; ++iBlock) {
        final int pStart = iBlock * BLOCK_SIZE;
        final int pEnd = FastMath.min(pStart + BLOCK_SIZE, rows);
        for (int jBlock = 0; jBlock < blockColumns; ++jBlock) {
            final int qStart = jBlock * BLOCK_SIZE;
            final int qEnd = FastMath.min(qStart + BLOCK_SIZE, columns);
            final double[] block = blocks[blockIndex];
            int k = 0;
            for (int p = pStart; p < pEnd; ++p) {
                for (int q = qStart; q < qEnd; ++q) {
                    visitor.visit(p, q, block[k]);
                    ++k;
                }
            }
            ++blockIndex;
        }
    }
    return visitor.end();
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:25,代码来源:BlockRealMatrix.java

示例8: getH

import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/**
 * Returns the Householder reflector vectors.
 * <p>H is a lower trapezoidal matrix whose columns represent
 * each successive Householder reflector vector. This matrix is used
 * to compute Q.</p>
 * @return a matrix containing the Householder reflector vectors
 */
public RealMatrix getH() {
    if (cachedH == null) {

        final int n = qrt.length;
        final int m = qrt[0].length;
        double[][] ha = new double[m][n];
        for (int i = 0; i < m; ++i) {
            for (int j = 0; j < FastMath.min(i + 1, n); ++j) {
                ha[i][j] = qrt[j][i] / -rDiag[j];
            }
        }
        cachedH = MatrixUtils.createRealMatrix(ha);
    }

    // return the cached matrix
    return cachedH;
}
 
开发者ID:jiaminghan,项目名称:droidplanner-master,代码行数:25,代码来源:QRDecomposition.java

示例9: updateP

import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
private double updateP (double duration, double[] p, double[] pDot, double[] pDotDot, double[] pDotDotDot) throws Exception{
	double max_dotdotdot = 0.0;
	for (int i = 0; i < p.length; i++){
		if (FastMath.abs(pDotDotDot[i]) > max_dotdotdot)
			max_dotdotdot = FastMath.abs(pDotDotDot[i]);
	}
	
	double timeStep = FastMath.min(FastMath.pow((epsilon*6/max_dotdotdot), 1.0/3), FastMath.min(duration, max_step));

	double timeStepSquare = timeStep*timeStep*0.5;
	for (int i = 0; i < p.length; i++){
		double new_val = p[i] + pDot[i]*timeStep + pDotDot[i]*timeStepSquare;
		double diff = FastMath.abs(new_val - p[i]);
		while (new_val > 1 || new_val < 0 || diff>0.2){
			timeStep *= 0.9;
			if (timeStep<1e-32){
				System.out.println("values are " + p[i] + " " + pDot[i]  + " " + pDotDot[i] + " " + pDotDotDot[i]);
				System.out.println("index is " + i + " of " + p.length + " " + lineages*states);
				System.out.println("minimum step size of 1e-32 reached");
				throw new Exception("error in the calculation of transition probabilities");
			}
			timeStepSquare = timeStep*timeStep*0.5;
			new_val = p[i] + pDot[i]*timeStep + pDotDot[i]*timeStepSquare;
			diff = FastMath.abs(new_val - p[i]);
		}			
	}
	doUpdating(timeStep, timeStepSquare, p, pDot, pDotDot);
	duration -= timeStep;
	return duration;		
}
 
开发者ID:nicfel,项目名称:Mascot,代码行数:31,代码来源:Euler2ndOrderTransitions.java

示例10: getCoalescentRate

import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
@Override
  public double[] getCoalescentRate(int i){
int intervalNr;
  	if (i >= rateShiftsInput.get().getDimension())
  		intervalNr = rateShiftsInput.get().getDimension()-1;
  	else
  		intervalNr = i;

  	double[] Ne = NeGLMInput.get().getRates(intervalNr);
double[] coal = new double[Ne.length];
for (int j = 0; j < Ne.length; j++){
	coal[j] = FastMath.min(1/Ne[j],maxRateInput.get());
}
return coal;
  }
 
开发者ID:nicfel,项目名称:Mascot,代码行数:16,代码来源:GLM.java

示例11: operate

import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public T[] operate(final T[] v) throws DimensionMismatchException {
    if (v.length != columns) {
        throw new DimensionMismatchException(v.length, columns);
    }
    final T[] out = MathArrays.buildArray(getField(), rows);
    final T zero = getField().getZero();

    // perform multiplication block-wise, to ensure good cache behavior
    for (int iBlock = 0; iBlock < blockRows; ++iBlock) {
        final int pStart = iBlock * BLOCK_SIZE;
        final int pEnd   = FastMath.min(pStart + BLOCK_SIZE, rows);
        for (int jBlock = 0; jBlock < blockColumns; ++jBlock) {
            final T[] block  = blocks[iBlock * blockColumns + jBlock];
            final int      qStart = jBlock * BLOCK_SIZE;
            final int      qEnd   = FastMath.min(qStart + BLOCK_SIZE, columns);
            int k = 0;
            for (int p = pStart; p < pEnd; ++p) {
                T sum = zero;
                int q = qStart;
                while (q < qEnd - 3) {
                    sum = sum.
                          add(block[k].multiply(v[q])).
                          add(block[k + 1].multiply(v[q + 1])).
                          add(block[k + 2].multiply(v[q + 2])).
                          add(block[k + 3].multiply(v[q + 3]));
                    k += 4;
                    q += 4;
                }
                while (q < qEnd) {
                    sum = sum.add(block[k++].multiply(v[q++]));
                }
                out[p] = out[p].add(sum);
            }
        }
    }

    return out;
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:41,代码来源:BlockFieldMatrix.java

示例12: getData

import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public T[][] getData() {

    final T[][] data = buildArray(getField(), getRowDimension(), getColumnDimension());
    final int lastColumns = columns - (blockColumns - 1) * BLOCK_SIZE;

    for (int iBlock = 0; iBlock < blockRows; ++iBlock) {
        final int pStart = iBlock * BLOCK_SIZE;
        final int pEnd   = FastMath.min(pStart + BLOCK_SIZE, rows);
        int regularPos   = 0;
        int lastPos      = 0;
        for (int p = pStart; p < pEnd; ++p) {
            final T[] dataP = data[p];
            int blockIndex = iBlock * blockColumns;
            int dataPos    = 0;
            for (int jBlock = 0; jBlock < blockColumns - 1; ++jBlock) {
                System.arraycopy(blocks[blockIndex++], regularPos, dataP, dataPos, BLOCK_SIZE);
                dataPos += BLOCK_SIZE;
            }
            System.arraycopy(blocks[blockIndex], lastPos, dataP, dataPos, lastColumns);
            regularPos += BLOCK_SIZE;
            lastPos    += lastColumns;
        }
    }

    return data;
}
 
开发者ID:jiaminghan,项目名称:droidplanner-master,代码行数:29,代码来源:BlockFieldMatrix.java

示例13: transpose

import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public BlockRealMatrix transpose() {
    final int nRows = getRowDimension();
    final int nCols = getColumnDimension();
    final BlockRealMatrix out = new BlockRealMatrix(nCols, nRows);

    // perform transpose block-wise, to ensure good cache behavior
    int blockIndex = 0;
    for (int iBlock = 0; iBlock < blockColumns; ++iBlock) {
        for (int jBlock = 0; jBlock < blockRows; ++jBlock) {
            // transpose current block
            final double[] outBlock = out.blocks[blockIndex];
            final double[] tBlock = blocks[jBlock * blockColumns + iBlock];
            final int pStart = iBlock * BLOCK_SIZE;
            final int pEnd = FastMath.min(pStart + BLOCK_SIZE, columns);
            final int qStart = jBlock * BLOCK_SIZE;
            final int qEnd = FastMath.min(qStart + BLOCK_SIZE, rows);
            int k = 0;
            for (int p = pStart; p < pEnd; ++p) {
                final int lInc = pEnd - pStart;
                int l = p - pStart;
                for (int q = qStart; q < qEnd; ++q) {
                    outBlock[k] = tBlock[l];
                    ++k;
                    l+= lInc;
                }
            }
            // go to next block
            ++blockIndex;
        }
    }

    return out;
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:36,代码来源:BlockRealMatrix.java

示例14: walkInRowOrder

import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public double walkInRowOrder(final RealMatrixPreservingVisitor visitor,
                             final int startRow, final int endRow,
                             final int startColumn, final int endColumn) {
    MatrixUtils.checkSubMatrixIndex(this, startRow, endRow, startColumn, endColumn);
    visitor.start(rows, columns, startRow, endRow, startColumn, endColumn);
    for (int iBlock = startRow / BLOCK_SIZE; iBlock < 1 + endRow / BLOCK_SIZE; ++iBlock) {
        final int p0 = iBlock * BLOCK_SIZE;
        final int pStart = FastMath.max(startRow, p0);
        final int pEnd = FastMath.min((iBlock + 1) * BLOCK_SIZE, 1 + endRow);
        for (int p = pStart; p < pEnd; ++p) {
            for (int jBlock = startColumn / BLOCK_SIZE; jBlock < 1 + endColumn / BLOCK_SIZE; ++jBlock) {
                final int jWidth = blockWidth(jBlock);
                final int q0 = jBlock * BLOCK_SIZE;
                final int qStart = FastMath.max(startColumn, q0);
                final int qEnd = FastMath.min((jBlock + 1) * BLOCK_SIZE, 1 + endColumn);
                final double[] block = blocks[iBlock * blockColumns + jBlock];
                int k = (p - p0) * jWidth + qStart - q0;
                for (int q = qStart; q < qEnd; ++q) {
                    visitor.visit(p, q, block[k]);
                    ++k;
                }
            }
         }
    }
    return visitor.end();
}
 
开发者ID:jiaminghan,项目名称:droidplanner-master,代码行数:29,代码来源:BlockRealMatrix.java

示例15: walkInOptimizedOrder

import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public T walkInOptimizedOrder(final FieldMatrixPreservingVisitor<T> visitor,
                                   final int startRow, final int endRow,
                                   final int startColumn, final int endColumn) {
    checkSubMatrixIndex(startRow, endRow, startColumn, endColumn);
    visitor.start(rows, columns, startRow, endRow, startColumn, endColumn);
    for (int iBlock = startRow / BLOCK_SIZE; iBlock < 1 + endRow / BLOCK_SIZE; ++iBlock) {
        final int p0     = iBlock * BLOCK_SIZE;
        final int pStart = FastMath.max(startRow, p0);
        final int pEnd   = FastMath.min((iBlock + 1) * BLOCK_SIZE, 1 + endRow);
        for (int jBlock = startColumn / BLOCK_SIZE; jBlock < 1 + endColumn / BLOCK_SIZE; ++jBlock) {
            final int jWidth = blockWidth(jBlock);
            final int q0     = jBlock * BLOCK_SIZE;
            final int qStart = FastMath.max(startColumn, q0);
            final int qEnd   = FastMath.min((jBlock + 1) * BLOCK_SIZE, 1 + endColumn);
            final T[] block = blocks[iBlock * blockColumns + jBlock];
            for (int p = pStart; p < pEnd; ++p) {
                int k = (p - p0) * jWidth + qStart - q0;
                for (int q = qStart; q < qEnd; ++q) {
                    visitor.visit(p, q, block[k]);
                    ++k;
                }
            }
        }
    }
    return visitor.end();
}
 
开发者ID:jiaminghan,项目名称:droidplanner-master,代码行数:29,代码来源:BlockFieldMatrix.java


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