本文整理汇总了Java中com.jmatio.types.MLStructure.getField方法的典型用法代码示例。如果您正苦于以下问题:Java MLStructure.getField方法的具体用法?Java MLStructure.getField怎么用?Java MLStructure.getField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jmatio.types.MLStructure
的用法示例。
在下文中一共展示了MLStructure.getField方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadMoG
import com.jmatio.types.MLStructure; //导入方法依赖的package包/类
private static MixtureOfGaussians loadMoG() throws IOException {
final File f = new File(GMM_MATLAB_FILE);
final MatFileReader reader = new MatFileReader(f);
final MLStructure codebook = (MLStructure) reader.getContent().get("codebook");
final MLSingle mean = (MLSingle) codebook.getField("mean");
final MLSingle variance = (MLSingle) codebook.getField("variance");
final MLSingle coef = (MLSingle) codebook.getField("coef");
final int n_gaussians = mean.getN();
final int n_dims = mean.getM();
final MultivariateGaussian[] ret = new MultivariateGaussian[n_gaussians];
final double[] weights = new double[n_gaussians];
for (int i = 0; i < n_gaussians; i++) {
weights[i] = coef.get(i, 0);
final DiagonalMultivariateGaussian d = new DiagonalMultivariateGaussian(n_dims);
for (int j = 0; j < n_dims; j++) {
d.mean.set(0, j, mean.get(j, i));
d.variance[j] = variance.get(j, i);
}
ret[i] = d;
}
return new MixtureOfGaussians(ret, weights);
}
示例2: loadMoG
import com.jmatio.types.MLStructure; //导入方法依赖的package包/类
public static MixtureOfGaussians loadMoG(File f) throws IOException {
final MatFileReader reader = new MatFileReader(f);
final MLStructure codebook = (MLStructure) reader.getContent().get("codebook");
final MLSingle mean = (MLSingle) codebook.getField("mean");
final MLSingle variance = (MLSingle) codebook.getField("variance");
final MLSingle coef = (MLSingle) codebook.getField("coef");
final int n_gaussians = mean.getN();
final int n_dims = mean.getM();
final MultivariateGaussian[] ret = new MultivariateGaussian[n_gaussians];
final double[] weights = new double[n_gaussians];
for (int i = 0; i < n_gaussians; i++) {
weights[i] = coef.get(i, 0);
final DiagonalMultivariateGaussian d = new DiagonalMultivariateGaussian(n_dims);
for (int j = 0; j < n_dims; j++) {
d.mean.set(0, j, mean.get(j, i));
d.variance[j] = variance.get(j, i);
}
ret[i] = d;
}
return new MixtureOfGaussians(ret, weights);
}
示例3: getMeasurements
import com.jmatio.types.MLStructure; //导入方法依赖的package包/类
private LinkedList<IndependentMeasurement> getMeasurements(MatFileReader matFileReader, String sourcePath) {
LinkedList<IndependentMeasurement> measurements = new LinkedList<IndependentMeasurement>();
try {
MLStructure root = (MLStructure) matFileReader.getMLArray(rootKey);
MLCell accX = (MLCell) root.getField(accXKey);
MLCell accY = (MLCell) root.getField(accYKey);
MLCell accZ = (MLCell) root.getField(accZKey);
MLCell label = (MLCell) root.getField(labelKey);
fillSampleProperyLists(root);
int nOfSamples = (int) Math.round(((MLDouble) root.getField(nOfSamplesKey)).get(0));
for (int i = 0; i < nOfSamples; i++) {
double[] accXValues = getSampleRow(accX, i);
double[] accYValues = getSampleRow(accY, i);
double[] accZValues = getSampleRow(accZ, i);
double[] labelValues = getSampleRow(label, i);
List<IndependentMeasurement> newMeasurements = getMeasurementsFromSample(accXValues, accYValues, accZValues,
labelValues, i);
measurements.addAll(newMeasurements);
}
} catch (NullPointerException e) {
throwInvalidFormatException(sourcePath, e);
}
return measurements;
}
示例4: getDoubleList
import com.jmatio.types.MLStructure; //导入方法依赖的package包/类
protected List<Double> getDoubleList(MLStructure root, String key) {
MLDouble mlDouble = (MLDouble) root.getField(key);
double[] primitiveArray = new DoubleMatrix(mlDouble.getArray()).toArray();
Double[] objectArray = ArrayUtils.toObject(primitiveArray);
return Arrays.asList(objectArray);
}