當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。