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


Java IndexIterator.getDoubleNext方法代码示例

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


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

示例1: trapz

import ucar.ma2.IndexIterator; //导入方法依赖的package包/类
/**
 * Integrate vector array using the composite trapezoidal rule.
 *
 * @param y Vecotr array
 * @param dx Spacing between all y elements
 * @param ranges
 * @return Definite integral as approximated by trapezoidal rule
 * @throws ucar.ma2.InvalidRangeException
 */
public static double trapz(Array y, double dx, List<Range> ranges) throws InvalidRangeException {
    int n = 1;
    for (Range range : ranges) {
        n = n * range.length();
    }
    n -= 1;
    double a = 1;
    double b = n * dx + a;
    double r = 0;
    double v;
    IndexIterator ii = y.getRangeIterator(ranges);
    int i = 0;
    while (ii.hasNext()) {
        v = ii.getDoubleNext();
        r += v;
        if (i > 0 && i < n) {
            r += v;
        }
        i += 1;
    }
    r = r * ((b - a) / (2 * n));
    return r;
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:33,代码来源:ArrayMath.java

示例2: getMinimum

import ucar.ma2.IndexIterator; //导入方法依赖的package包/类
/**
 * Get minimum value
 *
 * @param a Array a
 * @return Minimum value
 */
public static double getMinimum(Array a) {
    IndexIterator iter = a.getIndexIterator();
    double min = 1.7976931348623157E+308D;
    while (iter.hasNext()) {
        double val = iter.getDoubleNext();
        if (!Double.isNaN(val)) {
            if (val < min) {
                min = val;
            }
        }
    }
    if (min == 1.7976931348623157E+308D) {
        return Double.NaN;
    } else {
        return min;
    }
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:24,代码来源:ArrayMath.java

示例3: getMaximum

import ucar.ma2.IndexIterator; //导入方法依赖的package包/类
/**
 * Get maximum value
 *
 * @param a Array a
 * @return Maximum value
 */
public static double getMaximum(Array a) {
    IndexIterator iter = a.getIndexIterator();
    double max = -1.797693134862316E+307D;
    while (iter.hasNext()) {
        double val = iter.getDoubleNext();
        if (!Double.isNaN(val)) {
            if (val > max) {
                max = val;
            }
        }
    }
    if (max == -1.797693134862316E+307D) {
        return Double.NaN;
    } else {
        return max;
    }
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:24,代码来源:ArrayMath.java

示例4: sum

import ucar.ma2.IndexIterator; //导入方法依赖的package包/类
/**
 * Compute sum value of an array
 *
 * @param a Array a
 * @param ranges Range list
 * @return Sum value
 * @throws ucar.ma2.InvalidRangeException
 */
public static double sum(Array a, List<Range> ranges) throws InvalidRangeException {
    double s = 0.0, v;
    int n = 0;
    IndexIterator ii = a.getRangeIterator(ranges);
    while (ii.hasNext()) {
        v = ii.getDoubleNext();
        if (!Double.isNaN(v)) {
            s += v;
            n += 1;
        }
    }
    if (n == 0) {            
        s = Double.NaN;
    }
    return s;
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:25,代码来源:ArrayMath.java

示例5: aveDouble

import ucar.ma2.IndexIterator; //导入方法依赖的package包/类
/**
 * Average array
 *
 * @param a Array a
 * @return Average value
 */
public static double aveDouble(Array a) {
    double sum = 0.0D;
    double v;
    int n = 0;
    IndexIterator iterA = a.getIndexIterator();
    while (iterA.hasNext()) {
        v = iterA.getDoubleNext();
        if (!Double.isNaN(v)) {
            sum += v;
            n += 1;
        }
    }
    if (n == 0) {
        return Double.NaN;
    } else {
        return sum / n;
    }
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:25,代码来源:ArrayMath.java

示例6: argMin

import ucar.ma2.IndexIterator; //导入方法依赖的package包/类
/**
 * Get the index of the minimum value into the flattened array.
 *
 * @param a Array a
 * @return Minimum value index
 * @throws ucar.ma2.InvalidRangeException
 */
public static int argMin(Array a) throws InvalidRangeException {
    double min = Double.MAX_VALUE, v;
    int idx = 0;
    IndexIterator iterator = a.getIndexIterator();
    int i = 0;
    while (iterator.hasNext()){
        v = iterator.getDoubleNext();
        if (!Double.isNaN(v)){
            if (min > v){
                min = v;
                idx = i;
            }
        }
        i += 1;
    }
    return idx;
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:25,代码来源:ArrayMath.java

示例7: argMax

import ucar.ma2.IndexIterator; //导入方法依赖的package包/类
/**
 * Get the index of the maximum value into the flattened array.
 *
 * @param a Array a
 * @return Maximum value index
 * @throws ucar.ma2.InvalidRangeException
 */
public static int argMax(Array a) throws InvalidRangeException {
    double max = Double.MIN_VALUE, v;
    int idx = 0;
    IndexIterator iterator = a.getIndexIterator();
    int i = 0;
    while (iterator.hasNext()){
        v = iterator.getDoubleNext();
        if (!Double.isNaN(v)){
            if (max < v){
                max = v;
                idx = i;
            }
        }
        i += 1;
    }
    return idx;
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:25,代码来源:ArrayMath.java

示例8: mean

import ucar.ma2.IndexIterator; //导入方法依赖的package包/类
/**
 * Compute mean value of an array
 *
 * @param a Array a
 * @param ranges Range list
 * @return Mean value
 * @throws ucar.ma2.InvalidRangeException
 */
public static double mean(Array a, List<Range> ranges) throws InvalidRangeException {
    double mean = 0.0, v;
    int n = 0;
    IndexIterator ii = a.getRangeIterator(ranges);
    while (ii.hasNext()) {
        v = ii.getDoubleNext();
        if (!Double.isNaN(v)) {
            mean += v;
            n += 1;
        }
    }
    if (n > 0) {
        mean = mean / n;
    } else {
        mean = Double.NaN;
    }
    return mean;
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:27,代码来源:ArrayMath.java

示例9: quantile

import ucar.ma2.IndexIterator; //导入方法依赖的package包/类
/**
 * Quantile function
 *
 * @param a The data array
 * @param aNum Quantile index
 * @return Quantile value
 */
public static double quantile(Array a, int aNum) {
    List<Double> dlist = new ArrayList<>();
    IndexIterator ii = a.getIndexIterator();
    double v;
    while (ii.hasNext()) {
        v = ii.getDoubleNext();
        if (!Double.isNaN(v))
            dlist.add(v);
    }
    return quantile(dlist, aNum);
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:19,代码来源:Statistics.java

示例10: GridData

import ucar.ma2.IndexIterator; //导入方法依赖的package包/类
/**
 * Constructor
 *
 * @param array Data array
 * @param xdata X data
 * @param ydata Y data
 * @param missingValue Missing value
 * @param projInfo Projection info
 */
public GridData(Array array, List<Number> xdata, List<Number> ydata, double missingValue, ProjectionInfo projInfo) {
    int yn = ydata.size();
    int xn = xdata.size();
    this.data = new double[yn][xn];
    IndexIterator iter = array.getIndexIterator();
    int idx = 0;
    while (iter.hasNext()) {
        double val = iter.getDoubleNext();
        if (java.lang.Double.isNaN(val)) {
            data[idx / xn][idx % xn] = missingValue;
        } else {
            data[idx / xn][idx % xn] = val;
        }
        idx += 1;
    }

    this.xArray = new double[xn];
    this.yArray = new double[yn];
    for (int i = 0; i < xn; i++) {
        this.xArray[i] = xdata.get(i).doubleValue();
    }
    for (int i = 0; i < yn; i++) {
        this.yArray[i] = ydata.get(i).doubleValue();
    }

    this.missingValue = missingValue;
    this.projInfo = projInfo;
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:38,代码来源:GridData.java

示例11: prodDouble

import ucar.ma2.IndexIterator; //导入方法依赖的package包/类
/**
 * Produce array
 *
 * @param a Array a
 * @return Produce value
 */
public static double prodDouble(Array a) {
    double prod = 1.0D;
    double v;
    IndexIterator iterA = a.getIndexIterator();
    while (iterA.hasNext()) {
        v = iterA.getDoubleNext();
        if (!Double.isNaN(v)) {
            prod *= v;
        }
    }
    return prod;
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:19,代码来源:ArrayMath.java

示例12: std

import ucar.ma2.IndexIterator; //导入方法依赖的package包/类
/**
 * Compute standard deviation value of an array
 *
 * @param a Array a
 * @param ranges Range list
 * @return Standard deviation value
 * @throws ucar.ma2.InvalidRangeException
 */
public static double std(Array a, List<Range> ranges) throws InvalidRangeException {
    double mean = 0.0, v;
    int n = 0;
    IndexIterator ii = a.getRangeIterator(ranges);
    while (ii.hasNext()) {
        v = ii.getDoubleNext();
        if (!Double.isNaN(v)) {
            mean += v;
            n += 1;
        }
    }
    if (n > 0) {
        mean = mean / n;
    } else {
        mean = Double.NaN;
    }
    
    if (Double.isNaN(mean))
        return Double.NaN;
    
    double sum = 0;
    ii = a.getRangeIterator(ranges);
    while (ii.hasNext()) {
        v = ii.getDoubleNext();
        if (!Double.isNaN(v)) {
            sum += Math.pow((v - mean), 2);
        }
    }
    sum = Math.sqrt(sum / n);
    
    return sum;
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:41,代码来源:ArrayMath.java

示例13: copyTo1DJavaArray

import ucar.ma2.IndexIterator; //导入方法依赖的package包/类
protected static void copyTo1DJavaArray(IndexIterator iter, Object javaArray) {
    double[] ja = (double[]) javaArray;
    for (int i = 0; i < ja.length; i++) {
        ja[i] = iter.getDoubleNext();
    }
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:7,代码来源:ArrayUtil.java


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