本文整理了Java中ucar.ma2.Index.factory()
方法的一些代码示例,展示了Index.factory()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Index.factory()
方法的具体详情如下:
包路径:ucar.ma2.Index
类名称:Index
方法名:factory
[英]Generate a subclass of Index optimized for this array's rank
[中]生成针对此数组的秩优化的索引子类
代码示例来源:origin: Unidata/thredds
protected Array(DataType dataType, int[] shape) {
this.dataType = dataType;
this.rank = shape.length;
this.indexCalc = Index.factory(shape);
}
代码示例来源:origin: edu.ucar/netcdf
protected Array(int[] shape) {
rank = shape.length;
indexCalc = Index.factory(shape);
this.sort = computesort();
}
代码示例来源:origin: edu.ucar/cdm
/**
* Generate new Array with given type and shape and zeroed storage.
*
* @param classType element Class type, eg double.class.
* @param shape shape of the array.
* @return new Array<type> or Array<type>.D<rank> if 0 <= rank <= 7.
*/
static public Array factory(Class classType, int[] shape) {
Index index = Index.factory(shape);
return factory(classType, index);
}
代码示例来源:origin: Unidata/thredds
/**
* Generate new Array with given dataType, shape, storage.
*
* @param dataType DataType, eg DataType.DOUBLE.
* @param shape shape of the array.
* @param storage primitive array of correct type
* @return new Array<type> or Array<type>.D<rank> if 0 <= rank <= 7.
* @throws ClassCastException wrong storage type
*/
static public Array factory(DataType dataType, int[] shape, Object storage) {
return factory(dataType, Index.factory(shape), storage);
}
代码示例来源:origin: edu.ucar/netcdf
/**
* Generate new Array with given type and shape and zeroed storage.
*
* @param classType element Class type, eg double.class.
* @param shape shape of the array.
* @return new Array<type> or Array<type>.D<rank> if 0 <= rank <= 7.
*/
static public Array factory(Class classType, int[] shape) {
Index index = Index.factory(shape);
return factory(classType, index);
}
代码示例来源:origin: edu.ucar/cdm
protected Array(int[] shape) {
rank = shape.length;
indexCalc = Index.factory(shape);
this.datatype = computesort();
}
代码示例来源:origin: Unidata/thredds
/**
* Generate new Array with given dataType and shape and zeroed storage.
*
* @param dataType instance of DataType.
* @param shape shape of the array.
* @return new Array<type> or Array<type>.D<rank> if 0 <= rank <= 7.
*/
static public Array factory(DataType dataType, int[] shape) {
return factory(dataType, Index.factory(shape), null);
}
代码示例来源:origin: edu.ucar/cdm
/**
* Generate new Array with given type, shape, storage.
* This should be package private, but is exposed for efficiency.
* Normally use factory( Class classType, int [] shape) instead.
* storage must be 1D array of type classType.
* storage.length must equal product of shapes
* storage data needs to be in canonical order
*
* @param classType element class type, eg double.class. Corresponding Object types like Double.class are
* mapped to double.class. Any reference types use ArrayObject.
* @param shape array shape
* @param storage 1D java array of type classType, except object types like Double.class are mapped to
* their corresponding primitive type, eg double.class.
* @return Array of given type, shape and storage
* @throws IllegalArgumentException storage.length != product of shapes
* @throws ClassCastException wrong storage type
*/
static public Array factory(Class classType, int[] shape, Object storage) {
Index indexCalc = Index.factory(shape);
return factory(classType, indexCalc, storage);
}
代码示例来源:origin: Unidata/thredds
/**
* Make a vlen array
* @param shape the outer shape, ie excluding the vlen dimension
* @param storage must be an Array type. must not be null
* @return ArrayObject
*/
static public Array makeVlenArray(int[] shape, @Nonnull Array[] storage) {
Index index = Index.factory(shape);
return ArrayObject.factory(storage[0].getDataType(), storage[0].getClass(), true, index, storage);
}
代码示例来源:origin: edu.ucar/netcdf
/**
* Generate new Array with given type, shape, storage.
* This should be package private, but is exposed for efficiency.
* Normally use factory( Class classType, int [] shape) instead.
* storage must be 1D array of type classType.
* storage.length must equal product of shapes
* storage data needs to be in canonical order
*
* @param classType element class type, eg double.class. Corresponding Object types like Double.class are
* mapped to double.class. Any reference types use ArrayObject.
* @param shape array shape
* @param storage 1D java array of type classType, except object types like Double.class are mapped to
* their corresponding primitive type, eg double.class.
* @return Array of given type, shape and storage
* @throws IllegalArgumentException storage.length != product of shapes
* @throws ClassCastException wrong storage type
*/
static public Array factory(Class classType, int[] shape, Object storage) {
Index indexCalc = Index.factory(shape);
return factory(classType, indexCalc, storage);
}
代码示例来源:origin: Unidata/thredds
/**
* Generate new Array with given type, shape, storage.
* This should be package private, but is exposed for efficiency.
* Normally use factory( Class classType, int [] shape) instead.
* storage must be 1D array of type classType.
* storage.length must equal product of shapes
* storage data needs to be in canonical order
*
* @param classType element class type, eg double.class. Corresponding Object types like Double.class are
* mapped to double.class. Any reference types use ArrayObject.
* @param shape array shape
* @param storage 1D java array of type classType, except object types like Double.class are mapped to
* their corresponding primitive type, eg double.class.
* @return Array of given type, shape and storage
* @throws IllegalArgumentException storage.length != product of shapes
* @throws ClassCastException wrong storage type
*/
static public Array makeObjectArray(DataType dtype, Class classType, int[] shape, Object storage) {
Index index = Index.factory(shape);
return ArrayObject.factory(dtype, classType, false, index, (Object[]) storage);
}
代码示例来源:origin: edu.ucar/netcdf
/**
* Generate new Array with given type and shape and zeroed storage.
*
* @param dataType instance of DataType.
* @param shape shape of the array.
* @return new Array<type> or Array<type>.D<rank> if 0 <= rank <= 7.
*/
static public Array factory(DataType dataType, int[] shape) {
Index index = Index.factory(shape);
return factory(dataType.getPrimitiveClassType(), index);
}
代码示例来源:origin: edu.ucar/cdm
public int[] getCurrentCounter() {
if (counter == null) // or counter == "" ?
counter = Index.factory(maa.getShape());
counter.setCurrentCounter( currElement);
return counter.current;
}
代码示例来源:origin: edu.ucar/cdm
/**
* Generate new Array with given type and shape and zeroed storage.
*
* @param dataType instance of DataType.
* @param shape shape of the array.
* @return new Array<type> or Array<type>.D<rank> if 0 <= rank <= 7.
*/
static public Array factory(DataType dataType, int[] shape) {
Index index = Index.factory(shape);
return factory(dataType.getPrimitiveClassType(), index);
}
代码示例来源:origin: Unidata/thredds
public int[] getCurrentCounter() {
if (counter == null) // or counter == "" ?
counter = Index.factory(maa.getShape());
counter.setCurrentCounter( currElement);
return counter.current;
}
代码示例来源:origin: Unidata/thredds
public String toString() {
if (counter == null || counter.toString().equals("")) // not sure about the second condition
counter = Index.factory(maa.getShape());
counter.setCurrentCounter( currElement);
return counter.toString();
}
代码示例来源:origin: edu.ucar/cdm
public String toString() {
if (counter == null || counter.toString().equals("")) // not sure about the second condition
counter = Index.factory(maa.getShape());
counter.setCurrentCounter( currElement);
return counter.toString();
}
代码示例来源:origin: Unidata/thredds
@Override
public Array copy() {
Array newA = factory(getDataType(), getElementType(), isVlen(), Index.factory(getShape()));
MAMath.copy(newA, this);
return newA;
}
代码示例来源:origin: Unidata/thredds
@Test
public void testDataValues() throws IOException {
Array valuesScan = varScan.read();
Array valuesExplicit = varExplicit.read();
List<int[]> idxs = new ArrayList<>();
idxs.add(new int[]{0, 0, 0, 0, 0});
idxs.add(new int[]{2, 20, 5, 38, 44});
idxs.add(new int[]{1, 10, 3, 19, 22});
Index idx = Index.factory(valuesScan.getShape());
for (int[] loc : idxs) {
idx.set(loc);
float a = valuesScan.getFloat(idx);
float b = valuesExplicit.getFloat(idx);
Assert.assertEquals(a, b, 0);
}
}
代码示例来源:origin: edu.ucar/netcdf
/**
* Use this when this is a one dimensional array of Structures, or you are doing the index calculation yourself for
* a multidimension array. This will read only the ith structure, and return the data as a StructureData object.
* @param index index into 1D array
* @return ith StructureData
* @throws java.io.IOException on read error
* @throws ucar.ma2.InvalidRangeException if index out of range
*/
public StructureData readStructure(int index) throws IOException, ucar.ma2.InvalidRangeException {
Section section = null; // works for scalars i think
if (getRank() == 1) {
section = new Section().appendRange(index,index);
} else if (getRank() > 1) {
Index ii = Index.factory(shape); // convert to nD index
ii.setCurrentCounter(index);
int[] origin = ii.getCurrentCounter();
section = new Section();
for (int i=0;i<origin.length;i++)
section.appendRange(origin[i], origin[i]);
}
Array dataArray = read(section);
ArrayStructure data = (ArrayStructure) dataArray;
return data.getStructureData(0);
}
内容来源于网络,如有侵权,请联系作者删除!