Java Code Examples for org.apache.commons.math.util.MathUtils#copyOf()

The following examples show how to use org.apache.commons.math.util.MathUtils#copyOf() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Arja_0083_t.java    From coming with MIT License 6 votes vote down vote up
/**
 * 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;
}
 
Example 2
Source File: Math_56_MultidimensionalCounter_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * 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;
}
 
Example 3
Source File: JGenProg2017_0029_t.java    From coming with MIT License 6 votes vote down vote up
/**
 * 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;
}
 
Example 4
Source File: Math_56_MultidimensionalCounter_t.java    From coming with MIT License 6 votes vote down vote up
/**
 * 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;
}
 
Example 5
Source File: Arja_0083_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * 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;
}
 
Example 6
Source File: BOBYQAOptimizer.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @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;
}
 
Example 7
Source File: RegressionResults.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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));
    }
}
 
Example 8
Source File: Arja_0083_s.java    From coming with MIT License 2 votes vote down vote up
/**
 * Get the current multidimensional counter slots.
 *
 * @return the indices within the multidimensional counter.
 */
public int[] getCounts() {
    return MathUtils.copyOf(counter);
}
 
Example 9
Source File: MultidimensionalCounter.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Get the current multidimensional counter slots.
 *
 * @return the indices within the multidimensional counter.
 */
public int[] getCounts() {
    return MathUtils.copyOf(counter);
}
 
Example 10
Source File: MultidimensionalCounter.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * 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);
}
 
Example 11
Source File: Arja_0036_t.java    From coming with MIT License 2 votes vote down vote up
/**
 * 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);
}
 
Example 12
Source File: Arja_0036_s.java    From coming with MIT License 2 votes vote down vote up
/**
 * Get the current multidimensional counter slots.
 *
 * @return the indices within the multidimensional counter.
 */
public int[] getCounts() {
    return MathUtils.copyOf(counter);
}
 
Example 13
Source File: Math_56_MultidimensionalCounter_t.java    From coming with MIT License 2 votes vote down vote up
/**
 * 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);
}
 
Example 14
Source File: Arja_0036_s.java    From coming with MIT License 2 votes vote down vote up
/**
 * 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);
}
 
Example 15
Source File: Math_56_MultidimensionalCounter_t.java    From coming with MIT License 2 votes vote down vote up
/**
 * Get the current multidimensional counter slots.
 *
 * @return the indices within the multidimensional counter.
 */
public int[] getCounts() {
    return MathUtils.copyOf(counter);
}
 
Example 16
Source File: JGenProg2017_0029_s.java    From coming with MIT License 2 votes vote down vote up
/**
 * 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);
}
 
Example 17
Source File: Arja_0083_t.java    From coming with MIT License 2 votes vote down vote up
/**
 * 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);
}
 
Example 18
Source File: JGenProg2017_0029_t.java    From coming with MIT License 2 votes vote down vote up
/**
 * 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);
}
 
Example 19
Source File: MultidimensionalCounter.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Get the current multidimensional counter slots.
 *
 * @return the indices within the multidimensional counter.
 */
public int[] getCounts() {
    return MathUtils.copyOf(counter);
}
 
Example 20
Source File: Arja_0083_t.java    From coming with MIT License 2 votes vote down vote up
/**
 * Get the current multidimensional counter slots.
 *
 * @return the indices within the multidimensional counter.
 */
public int[] getCounts() {
    return MathUtils.copyOf(counter);
}