File |
Line |
org/apache/commons/math/analysis/MullerSolver.java |
46
|
org/apache/commons/math/analysis/RiddersSolver.java |
45
|
public RiddersSolver(UnivariateRealFunction f) {
super(f, 100, 1E-6);
}
/**
* Find a root in the given interval with initial value.
* <p>
* Requires bracketing condition.</p>
*
* @param min the lower bound for the interval
* @param max the upper bound for the interval
* @param initial the start value to use
* @return the point at which the function value is zero
* @throws MaxIterationsExceededException if the maximum iteration count is exceeded
* @throws FunctionEvaluationException if an error occurs evaluating the
* function
* @throws IllegalArgumentException if any parameters are invalid
*/
public double solve(double min, double max, double initial) throws
MaxIterationsExceededException, FunctionEvaluationException {
// check for zeros before verifying bracketing
if (f.value(min) == 0.0) { return min; }
if (f.value(max) == 0.0) { return max; }
if (f.value(initial) == 0.0) { return initial; }
verifyBracketing(min, max, f);
verifySequence(min, initial, max);
if (isBracketing(min, initial, f)) {
return solve(min, initial);
} else {
return solve(initial, max);
}
}
/**
* Find a root in the given interval.
* <p>
* Requires bracketing condition.</p>
*
* @param min the lower bound for the interval
* @param max the upper bound for the interval
* @return the point at which the function value is zero
* @throws MaxIterationsExceededException if the maximum iteration count is exceeded
* @throws FunctionEvaluationException if an error occurs evaluating the
* function
* @throws IllegalArgumentException if any parameters are invalid
*/
public double solve(double min, double max) throws MaxIterationsExceededException,
FunctionEvaluationException {
// [x1, x2] is the bracketing interval in each iteration
// x3 is the midpoint of [x1, x2]
// x is the new root approximation and an endpoint of the new interval
double x1, x2, x3, x, oldx, y1, y2, y3, y, delta, correction, tolerance;
|
File |
Line |
org/apache/commons/math/linear/BigMatrixImpl.java |
1104
|
org/apache/commons/math/linear/RealMatrixImpl.java |
855
|
res.append("RealMatrixImpl{");
if (data != null) {
for (int i = 0; i < data.length; i++) {
if (i > 0)
res.append(",");
res.append("{");
for (int j = 0; j < data[0].length; j++) {
if (j > 0)
res.append(",");
res.append(data[i][j]);
}
res.append("}");
}
}
res.append("}");
return res.toString();
}
/**
* Returns true iff <code>object</code> is a
* <code>RealMatrixImpl</code> instance with the same dimensions as this
* and all corresponding matrix entries are equal. Corresponding entries
* are compared using {@link java.lang.Double#doubleToLongBits(double)}
*
* @param object the object to test equality against.
* @return true if object equals this
*/
public boolean equals(Object object) {
if (object == this ) {
return true;
}
if (object instanceof RealMatrixImpl == false) {
|
File |
Line |
org/apache/commons/math/ode/AdaptiveStepsizeIntegrator.java |
173
|
org/apache/commons/math/ode/RungeKuttaIntegrator.java |
115
|
private void sanityChecks(FirstOrderDifferentialEquations equations,
double t0, double[] y0, double t, double[] y)
throws IntegratorException {
if (equations.getDimension() != y0.length) {
throw new IntegratorException("dimensions mismatch: ODE problem has dimension {0}," +
" initial state vector has dimension {1}",
new Object[] {
new Integer(equations.getDimension()),
new Integer(y0.length)
});
}
if (equations.getDimension() != y.length) {
throw new IntegratorException("dimensions mismatch: ODE problem has dimension {0}," +
" final state vector has dimension {1}",
new Object[] {
new Integer(equations.getDimension()),
new Integer(y.length)
});
}
if (Math.abs(t - t0) <= 1.0e-12 * Math.max(Math.abs(t0), Math.abs(t))) {
|
File |
Line |
org/apache/commons/math/stat/descriptive/MultivariateSummaryStatistics.java |
378
|
org/apache/commons/math/stat/descriptive/SummaryStatistics.java |
377
|
MathUtils.equals(stat.getVariance(),this.getVariance()));
}
/**
* Returns hash code based on values of statistics
*
* @return hash code
*/
public int hashCode() {
int result = 31 + MathUtils.hash(getGeometricMean());
result = result * 31 + MathUtils.hash(getGeometricMean());
result = result * 31 + MathUtils.hash(getMax());
result = result * 31 + MathUtils.hash(getMean());
result = result * 31 + MathUtils.hash(getMin());
result = result * 31 + MathUtils.hash(getN());
result = result * 31 + MathUtils.hash(getSum());
result = result * 31 + MathUtils.hash(getSumsq());
|
File |
Line |
org/apache/commons/math/linear/BigMatrixImpl.java |
217
|
org/apache/commons/math/linear/BigMatrixImpl.java |
240
|
public BigMatrix subtract(BigMatrix m) throws IllegalArgumentException {
if (this.getColumnDimension() != m.getColumnDimension() ||
this.getRowDimension() != m.getRowDimension()) {
throw new IllegalArgumentException("matrix dimension mismatch");
}
int rowCount = this.getRowDimension();
int columnCount = this.getColumnDimension();
BigDecimal[][] outData = new BigDecimal[rowCount][columnCount];
for (int row = 0; row < rowCount; row++) {
for (int col = 0; col < columnCount; col++) {
outData[row][col] = data[row][col].subtract(m.getEntry(row, col));
|
File |
Line |
org/apache/commons/math/linear/RealMatrixImpl.java |
146
|
org/apache/commons/math/linear/RealMatrixImpl.java |
169
|
public RealMatrix subtract(RealMatrix m) throws IllegalArgumentException {
if (this.getColumnDimension() != m.getColumnDimension() ||
this.getRowDimension() != m.getRowDimension()) {
throw new IllegalArgumentException("matrix dimension mismatch");
}
int rowCount = this.getRowDimension();
int columnCount = this.getColumnDimension();
double[][] outData = new double[rowCount][columnCount];
for (int row = 0; row < rowCount; row++) {
for (int col = 0; col < columnCount; col++) {
outData[row][col] = data[row][col] - m.getEntry(row, col);
|
File |
Line |
org/apache/commons/math/stat/descriptive/MultivariateSummaryStatistics.java |
368
|
org/apache/commons/math/stat/descriptive/SummaryStatistics.java |
368
|
SummaryStatistics stat = (SummaryStatistics) object;
return (MathUtils.equals(stat.getGeometricMean(),
this.getGeometricMean()) &&
MathUtils.equals(stat.getMax(), this.getMax()) &&
MathUtils.equals(stat.getMean(),this.getMean()) &&
MathUtils.equals(stat.getMin(),this.getMin()) &&
MathUtils.equals(stat.getN(), this.getN()) &&
MathUtils.equals(stat.getSum(), this.getSum()) &&
MathUtils.equals(stat.getSumsq(),this.getSumsq()) &&
|
File |
Line |
org/apache/commons/math/linear/BigMatrixImpl.java |
1146
|
org/apache/commons/math/linear/RealMatrixImpl.java |
898
|
Double.doubleToLongBits(m.getEntry(row, col))) {
return false;
}
}
}
return true;
}
/**
* Computes a hashcode for the matrix.
*
* @return hashcode for matrix
*/
public int hashCode() {
int ret = 7;
int nRows = getRowDimension();
int nCols = getColumnDimension();
ret = ret * 31 + nRows;
ret = ret * 31 + nCols;
for (int row = 0; row < nRows; row++) {
for (int col = 0; col < nCols; col++) {
ret = ret * 31 + (11 * (row+1) + 17 * (col+1)) *
|
File |
Line |
org/apache/commons/math/fraction/FractionFormat.java |
268
|
org/apache/commons/math/fraction/ProperFractionFormat.java |
166
|
if (num.intValue() < 0) {
// minus signs should be leading, invalid expression
pos.setIndex(initialIndex);
return null;
}
// parse '/'
int startIndex = pos.getIndex();
char c = parseNextCharacter(source, pos);
switch (c) {
case 0 :
// no '/'
// return num as a fraction
return new Fraction(num.intValue(), 1);
case '/' :
// found '/', continue parsing denominator
break;
default :
// invalid '/'
// set index back to initial, error index should be the last
// character examined.
pos.setIndex(initialIndex);
pos.setErrorIndex(startIndex);
return null;
}
// parse whitespace
parseAndIgnoreWhitespace(source, pos);
// parse denominator
Number den = getDenominatorFormat().parse(source, pos);
if (den == null) {
// invalid integer number
// set index back to initial, error index should already be set
// character examined.
pos.setIndex(initialIndex);
return null;
}
|
File |
Line |
org/apache/commons/math/linear/BigMatrixImpl.java |
972
|
org/apache/commons/math/linear/RealMatrixImpl.java |
725
|
double[][] bp = new double[nRowB][nColB];
for (int row = 0; row < nRowB; row++) {
for (int col = 0; col < nColB; col++) {
bp[row][col] = b.getEntry(permutation[row], col);
}
}
// Solve LY = b
for (int col = 0; col < nCol; col++) {
for (int i = col + 1; i < nCol; i++) {
for (int j = 0; j < nColB; j++) {
bp[i][j] -= bp[col][j] * lu[i][col];
|