本文整理汇总了Java中org.apache.commons.math.util.MathUtils.copyOf方法的典型用法代码示例。如果您正苦于以下问题:Java MathUtils.copyOf方法的具体用法?Java MathUtils.copyOf怎么用?Java MathUtils.copyOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.math.util.MathUtils
的用法示例。
在下文中一共展示了MathUtils.copyOf方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: StepFunction
import org.apache.commons.math.util.MathUtils; //导入方法依赖的package包/类
/**
* Builds a step function from a list of abscissae and the corresponding
* ordinates.
*
* @param x Abscissae.
* @param y Ordinates.
* @throws org.apache.commons.math.exception.NonMonotonousSequenceException
* if the {@code x} array is not sorted in strictly increasing order.
* @throws NullArgumentException if {@code x} or {@code y} are {@code null}.
* @throws NoDataException if {@code x} or {@code y} are zero-length.
*/
public StepFunction(double[] x,
double[] y) {
if (x == null ||
y == null) {
throw new NullArgumentException();
}
if (x.length == 0 ||
y.length == 0) {
throw new NoDataException();
}
if (y.length != x.length) {
throw new DimensionMismatchException(y.length, x.length);
}
MathUtils.checkOrder(x);
abscissa = MathUtils.copyOf(x);
ordinate = MathUtils.copyOf(y);
}
示例2: MultidimensionalCounter
import org.apache.commons.math.util.MathUtils; //导入方法依赖的package包/类
/**
* Create a counter.
*
* @param size Counter sizes (number of slots in each dimension).
* @throws NotStrictlyPositiveException if one of the sizes is
* negative or zero.
*/
public MultidimensionalCounter(int ... size) {
dimension = size.length;
this.size = MathUtils.copyOf(size);
uniCounterOffset = new int[dimension];
last = dimension - 1;
int tS = size[last];
for (int i = 0; i < last; i++) {
int count = 1;
for (int j = i + 1; j < dimension; j++) {
count *= size[j];
}
uniCounterOffset[i] = count;
tS *= size[i];
}
uniCounterOffset[last] = 0;
if (tS <= 0) {
throw new NotStrictlyPositiveException(tS);
}
totalSize = tS;
}
示例3: BOBYQAOptimizer
import org.apache.commons.math.util.MathUtils; //导入方法依赖的package包/类
/**
* @param numberOfInterpolationPoints Number of interpolation conditions.
* For a problem of dimension {@code n}, its value must be in the interval
* {@code [n+2, (n+1)(n+2)/2]}.
* Choices that exceed {@code 2n+1} are not recommended.
* @param lowerBound Lower bounds (constraints) of the objective variables.
* @param upperBound Upperer bounds (constraints) of the objective variables.
* @param initialTrustRegionRadius Initial trust region radius.
* @param stoppingTrustRegionRadius Stopping trust region radius.
*/
public BOBYQAOptimizer(int numberOfInterpolationPoints,
double[] lowerBound,
double[] upperBound,
double initialTrustRegionRadius,
double stoppingTrustRegionRadius) {
this.lowerBound = lowerBound == null ? null : MathUtils.copyOf(lowerBound);
this.upperBound = upperBound == null ? null : MathUtils.copyOf(upperBound);
this.numberOfInterpolationPoints = numberOfInterpolationPoints;
this.initialTrustRegionRadius = initialTrustRegionRadius;
this.stoppingTrustRegionRadius = stoppingTrustRegionRadius;
}
示例4: RegressionResults
import org.apache.commons.math.util.MathUtils; //导入方法依赖的package包/类
/**
* Constructor for Regression Results.
*
* @param parameters a double array with the regression slope estimates
* @param varcov the variance covariance matrix, stored either in a square matrix
* or as a compressed
* @param isSymmetricCompressed a flag which denotes that the variance covariance
* matrix is in symmetric compressed format
* @param nobs the number of observations of the regression estimation
* @param rank the number of independent variables in the regression
* @param sumy the sum of the independent variable
* @param sumysq the sum of the squared independent variable
* @param sse sum of squared errors
* @param containsConstant true model has constant, false model does not have constant
* @param copyData if true a deep copy of all input data is made, if false only references
* are copied and the RegressionResults become mutable
*/
public RegressionResults(
final double[] parameters, final double[][] varcov,
final boolean isSymmetricCompressed,
final long nobs, final int rank,
final double sumy, final double sumysq, final double sse,
final boolean containsConstant,
final boolean copyData) {
if (copyData) {
this.parameters = MathUtils.copyOf(parameters);
this.varCovData = new double[varcov.length][];
for (int i = 0; i < varcov.length; i++) {
this.varCovData[i] = MathUtils.copyOf(varcov[i]);
}
} else {
this.parameters = parameters;
this.varCovData = varcov;
}
this.isSymmetricVCD = isSymmetricCompressed;
this.nobs = nobs;
this.rank = rank;
this.containsConstant = containsConstant;
this.globalFitInfo = new double[5];
Arrays.fill(this.globalFitInfo, Double.NaN);
if (rank > 2) {
this.globalFitInfo[SST_IDX] = containsConstant ?
(sumysq - sumy * sumy / ((double) nobs)) : sumysq;
}
this.globalFitInfo[SSE_IDX] = sse;
this.globalFitInfo[MSE_IDX] = this.globalFitInfo[SSE_IDX] /
((double) (nobs - rank));
this.globalFitInfo[RSQ_IDX] = 1.0 -
this.globalFitInfo[SSE_IDX] /
this.globalFitInfo[SST_IDX];
if (!containsConstant) {
this.globalFitInfo[ADJRSQ_IDX] = 1.0-
(1.0 - this.globalFitInfo[RSQ_IDX]) *
( (double) nobs / ( (double) (nobs - rank)));
} else {
this.globalFitInfo[ADJRSQ_IDX] = 1.0 - (sse * (nobs - 1.0)) /
(globalFitInfo[SST_IDX] * (nobs - rank));
}
}
示例5: getParameterEstimates
import org.apache.commons.math.util.MathUtils; //导入方法依赖的package包/类
/**
* <p>Returns a copy of the regression parameters estimates.</p>
*
* <p>The parameter estimates are returned in the natural order of the data.</p>
*
* <p>A redundant regressor will have its redundancy flag set, as will
* a parameter estimate equal to {@code Double.NaN}.</p>
*
* @return array of parameter estimates, null if no estimation occurred
*/
public double[] getParameterEstimates() {
if (this.parameters == null) {
return null;
}
return MathUtils.copyOf(parameters);
}
示例6: getCounts
import org.apache.commons.math.util.MathUtils; //导入方法依赖的package包/类
/**
* Get the current multidimensional counter slots.
*
* @return the indices within the multidimensional counter.
*/
public int[] getCounts() {
return MathUtils.copyOf(counter);
}
示例7: getSizes
import org.apache.commons.math.util.MathUtils; //导入方法依赖的package包/类
/**
* Get the number of multidimensional counter slots in each dimension.
*
* @return the sizes of the multidimensional counter in each dimension.
*/
public int[] getSizes() {
return MathUtils.copyOf(size);
}
示例8: getOrderOfRegressors
import org.apache.commons.math.util.MathUtils; //导入方法依赖的package包/类
/**
* Gets the order of the regressors, useful if some type of reordering
* has been called. Calling regress with int[]{} args will trigger
* a reordering.
*
* @return int[] with the current order of the regressors
*/
public int[] getOrderOfRegressors(){
return MathUtils.copyOf(vorder);
}