• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java MLStructure类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.jmatio.types.MLStructure的典型用法代码示例。如果您正苦于以下问题:Java MLStructure类的具体用法?Java MLStructure怎么用?Java MLStructure使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MLStructure类属于com.jmatio.types包,在下文中一共展示了MLStructure类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: writeSamplingNetworkData

import com.jmatio.types.MLStructure; //导入依赖的package包/类
public void writeSamplingNetworkData(SamplingNetworkData mcNetworkSamplingData) throws IOException {
    Objects.requireNonNull(mcNetworkSamplingData, "sampling network data is null");

    LOGGER.debug("Preparing buses mat data");
    MLStructure buses  = busesDataAsMLStructure(mcNetworkSamplingData.getBusesData());
    LOGGER.debug("Preparing generators mat data");
    MLStructure generators  = generatorsDataAsMLStructure(mcNetworkSamplingData.getGeneratorsData());
    LOGGER.debug("Preparing loads mat data");
    MLStructure loads  = loadsDataAsMLStructure(mcNetworkSamplingData.getLoadsData());
    LOGGER.debug("Saving mat data into " + matFile.toString());
    List<MLArray> mlarray = new ArrayList<>();
    mlarray.add((MLArray) buses);
    mlarray.add((MLArray) generators);
    mlarray.add((MLArray) loads);
    MatFileWriter writer = new MatFileWriter();
    writer.write(matFile.toFile(), mlarray);
}
 
开发者ID:itesla,项目名称:ipst,代码行数:18,代码来源:MCSMatFileWriter.java


示例2: createMLStruct

import com.jmatio.types.MLStructure; //导入依赖的package包/类
/** Create ML Structure with data for a channel
 *  @param index Index of channel in model
 *  @param name Channel name
 *  @param times Time stamps
 *  @param values Values
 *  @param severities Severities
 *  @return {@link MLStructure}
 */
private MLStructure createMLStruct(final int index, final String name,
        final List<Instant> times,
        final List<Double> values,
        final List<AlarmSeverity> severities)
{
    final MLStructure struct = new MLStructure("channel" + index, new int[] { 1, 1 });
    final int N = values.size();
    final int[] dims = new int[] { N, 1 };
    final MLCell time = new MLCell(null, dims);
    final MLDouble value = new MLDouble(null, dims);
    final MLCell severity = new MLCell(null, dims);
    for (int i=0; i<N; ++i)
    {
        setCellText(time, i, TimestampHelper.format(times.get(i)));
        value.set(values.get(i), i);
        setCellText(severity, i, severities.get(i).toString());
    }
    struct.setField("name", new MLChar(null, name));
    struct.setField("time", time);
    struct.setField("value", value);
    struct.setField("severity", severity);
    return struct;
}
 
开发者ID:kasemir,项目名称:org.csstudio.display.builder,代码行数:32,代码来源:MatlabFileExportJob.java


示例3: 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);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:27,代码来源:FVFWCheckGMM.java


示例4: 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);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:26,代码来源:FVFWCheckPCAGMM.java


示例5: fillDataFields

import com.jmatio.types.MLStructure; //导入依赖的package包/类
private void fillDataFields(MatFileReader reader) {
    root = (MLStructure) reader.getMLArray(rootKey);
    accX = getDoubleList(root, accXKey);
    accY = getDoubleList(root, accYKey);
    accZ = getDoubleList(root, accZKey);
    gpsSpeeds = getDoubleList(root, gpsSpeedKey);
    longitudes = getDoubleList(root, longitudeKey);
    latitudes = getDoubleList(root, latitudeKey);
    altitudes = getDoubleList(root, altitudeKey);
    indices = getIntList(root, indexKey);
    deviceIds = getIntList(root, deviceIdKey);
    years = getIntList(root, yearsKey);
    months = getIntList(root, monthsKey);
    days = getIntList(root, daysKey);
    hours = getIntList(root, hoursKey);
    minutes = getIntList(root, minutesKey);
    seconds = getIntList(root, secondsKey);
    gpsSpeeds = getDoubleList(root, gpsSpeedKey);
}
 
开发者ID:NLeSC,项目名称:eEcology-Classification,代码行数:20,代码来源:UnannotatedMeasurementsMatLoader.java


示例6: testMLStructureFieldNames

import com.jmatio.types.MLStructure; //导入依赖的package包/类
@Test
public void testMLStructureFieldNames() throws IOException
{
    //test column-packed vector
    double[] src = new double[] { 1.3, 2.0, 3.0, 4.0, 5.0, 6.0 };
    
    //create 3x2 double matrix
    //[ 1.0 4.0 ;
    //  2.0 5.0 ;
    //  3.0 6.0 ]
    MLDouble mlDouble = new MLDouble( null, src, 3 );
    MLChar mlChar = new MLChar( null, "I am dummy" );
    
    
    MLStructure mlStruct = new MLStructure("str", new int[] {1,1} );
    mlStruct.setField("f1", mlDouble);
    mlStruct.setField("f2", mlChar);
    
    Collection<String> fieldNames = mlStruct.getFieldNames();
    
    assertEquals( 2, fieldNames.size() );
    assertTrue( fieldNames.contains("f1") );
    assertTrue( fieldNames.contains("f2") );
}
 
开发者ID:gradusnikov,项目名称:jmatio,代码行数:25,代码来源:MatIOTest.java


示例7: putBusDataIntoMLStructure

import com.jmatio.types.MLStructure; //导入依赖的package包/类
private void putBusDataIntoMLStructure(BusData busData, MLStructure buses, int i) {
    LOGGER.debug("Preparing mat data for bus " + busData.getBusId());
    // nome
    MLChar nome = new MLChar("", busData.getBusName());
    buses.setField("nome", nome, 0, i);
    // codice
    MLChar codice = new MLChar("", busData.getBusId());
    buses.setField("codice", codice, 0, i);
    // ID
    MLInt64 id = new MLInt64("", new long[]{busData.getBusIndex()}, 1);
    buses.setField("ID", id, 0, i);
    // type
    MLInt64 type = new MLInt64("", new long[]{busData.getBusType()}, 1);
    buses.setField("type", type, 0, i);
    // Vnom
    MLDouble vNom = new MLDouble("", new double[]{busData.getNominalVoltage()}, 1);
    buses.setField("Vnom", vNom, 0, i);
    // V
    MLDouble v = new MLDouble("", new double[]{busData.getVoltage()}, 1);
    buses.setField("V", v, 0, i);
    // angle
    MLDouble angle = new MLDouble("", new double[]{busData.getAngle()}, 1);
    buses.setField("angle", angle, 0, i);
    // Vmin
    MLDouble vMin = new MLDouble("", new double[]{busData.getMinVoltage()}, 1);
    buses.setField("Vmin", vMin, 0, i);
    // Vmax
    MLDouble vMax = new MLDouble("", new double[]{busData.getMaxVoltage()}, 1);
    buses.setField("Vmax", vMax, 0, i);
    // P
    MLDouble p = new MLDouble("", new double[]{busData.getActivePower()}, 1);
    buses.setField("P", p, 0, i);
    // Q
    MLDouble q = new MLDouble("", new double[]{busData.getReactivePower() }, 1);
    buses.setField("Q", q, 0, i);
}
 
开发者ID:itesla,项目名称:ipst,代码行数:37,代码来源:MCSMatFileWriter.java


示例8: putGeneratorDataIntoMLStructure

import com.jmatio.types.MLStructure; //导入依赖的package包/类
private void putGeneratorDataIntoMLStructure(LoadData loadData, MLStructure loads, int i) {
    LOGGER.debug("Preparing mat data for load " + loadData.getLoadId());
    // estremo_ID
    MLInt64 estremoId = new MLInt64("", new long[]{loadData.getBusIndex()}, 1);
    loads.setField("estremo_ID", estremoId, 0, i);
    // estremo
    MLChar estremo = new MLChar("", loadData.getBusId());
    loads.setField("estremo", estremo, 0, i);
    // codice
    MLChar codice = new MLChar("", loadData.getLoadId());
    loads.setField("codice", codice, 0, i);
    // conn
    int connected = 0;
    if (loadData.isConnected()) {
        connected = 1;
    }
    MLInt64 disp = new MLInt64("", new long[]{connected}, 1);
    loads.setField("conn", disp, 0, i);
    // P
    MLDouble p = new MLDouble("", new double[]{loadData.getActvePower()}, 1);
    loads.setField("P", p, 0, i);
    // Q
    MLDouble q = new MLDouble("", new double[]{loadData.getReactvePower()}, 1);
    loads.setField("Q", q, 0, i);
    // V
    MLDouble v = new MLDouble("", new double[]{loadData.getVoltage()}, 1);
    loads.setField("V", v, 0, i);
}
 
开发者ID:itesla,项目名称:ipst,代码行数:29,代码来源:MCSMatFileWriter.java


示例9: putStochasticVariablesIntoMLStructure

import com.jmatio.types.MLStructure; //导入依赖的package包/类
private void putStochasticVariablesIntoMLStructure(StochasticVariable stochasticVariable, MLStructure stochVars, int i) {
    LOGGER.debug("Preparing mat data for stochastic variable " + stochasticVariable.getId());
    // id
    MLChar id = new MLChar("", stochasticVariable.getId());
    stochVars.setField("id", id, 0, i);
    // type
    MLChar type = new MLChar("", stochasticVariable.getType());
    stochVars.setField("type", type, 0, i);
}
 
开发者ID:itesla,项目名称:ipst,代码行数:10,代码来源:FEAMatFileWriter.java


示例10: writeMatlabFile2

import com.jmatio.types.MLStructure; //导入依赖的package包/类
public void writeMatlabFile2() throws Exception
{
    // Example values
    final VType[] values = new VType[10];
    for (int i=0; i<10; ++i)
        values[i] = new ArchiveVNumber(VTypeHelper.getTimestamp(null), AlarmSeverity.NONE, "OK",
                ValueFactory.displayNone(),
                Math.exp(-((5.0-i)*(5.0-i))) );

    // Turn values into Matlab data
    final int[] dims = new int[] { values.length, 1 };
    final MLDouble value = new MLDouble(null, dims);
    final MLCell time = new MLCell(null, dims);
    final MLCell severity = new MLCell(null, dims);
    final MLCell status = new MLCell(null, dims);
    for (int i=0; i<values.length; ++i)
    {
        value.set(VTypeHelper.toDouble(values[i]), i);
        setCellText(time, i, TimestampHelper.format(VTypeHelper.getTimestamp(values[i])));
        setCellText(severity, i, VTypeHelper.getSeverity(values[i]).toString());
        setCellText(severity, i, VTypeHelper.getMessage(values[i]));
    }
    final MLStructure struct = new MLStructure("channel0", new int[] { 1, 1 });
    struct.setField("value", value);
    struct.setField("time", time);
    struct.setField("severity", severity);
    struct.setField("status", status);

    // Write to file
    final MatFileIncrementalWriter writer = new MatFileIncrementalWriter("mat_file2.mat");
    writer.write(struct);
    writer.close();
}
 
开发者ID:kasemir,项目名称:org.csstudio.display.builder,代码行数:34,代码来源:JMatioDemo.java


示例11: performExport

import com.jmatio.types.MLStructure; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
protected void performExport(final IProgressMonitor monitor,
                             final PrintStream out) throws Exception
{
    // This exporter does its own file handling
    if (out != null)
        throw new IllegalStateException();

    final MatFileIncrementalWriter writer = new MatFileIncrementalWriter(filename);
    int i = 0;
    for (ModelItem item : model.getItems())
    {   // Get data
        monitor.subTask(NLS.bind("Fetching data for {0}", item.getName()));
        final ValueIterator iter = createValueIterator(item);
        final List<Instant> times = new ArrayList<Instant>();
        final List<Double> values = new ArrayList<Double>();
        final List<AlarmSeverity> severities = new ArrayList<AlarmSeverity>();
        while (iter.hasNext()  &&  !monitor.isCanceled())
        {
            final VType value = iter.next();
            times.add(VTypeHelper.getTimestamp(value));
            values.add(VTypeHelper.toDouble(value));
            severities.add(VTypeHelper.getSeverity(value));
            if (values.size() % PROGRESS_UPDATE_LINES == 0)
                monitor.subTask(NLS.bind("{0}: Obtained {1} samples", item.getName(), values.size()));
        }
        // Add to Matlab file
        final MLStructure struct = createMLStruct(i++, item.getName(), times, values, severities);
        writer.write(struct);
    }

    writer.close();
}
 
开发者ID:kasemir,项目名称:org.csstudio.display.builder,代码行数:35,代码来源:MatlabFileExportJob.java


示例12: getIntList

import com.jmatio.types.MLStructure; //导入依赖的package包/类
protected List<Integer> getIntList(MLStructure root, String key) {
    List<Double> doubleList = getDoubleList(root, key);
    List<Integer> results = new ArrayList<Integer>();
    for (int i = 0; i < doubleList.size(); i++) {
        double currentDouble = doubleList.get(i);
        results.add((int) currentDouble);
    }
    return results;
}
 
开发者ID:NLeSC,项目名称:eEcology-Classification,代码行数:10,代码来源:MeasurementsMatLoader.java


示例13: 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;
}
 
开发者ID:NLeSC,项目名称:eEcology-Classification,代码行数:28,代码来源:AnnotatedMeasurementsMatLoader.java


示例14: fillSampleProperyLists

import com.jmatio.types.MLStructure; //导入依赖的package包/类
private void fillSampleProperyLists(MLStructure root) {
    deviceIds = getIntList(root, deviceIdKey);
    years = getIntList(root, yearsKey);
    months = getIntList(root, monthsKey);
    days = getIntList(root, daysKey);
    hours = getIntList(root, hoursKey);
    minutes = getIntList(root, minutesKey);
    seconds = getIntList(root, secondsKey);
    gpsSpeeds = getDoubleList(root, gpsKey);
}
 
开发者ID:NLeSC,项目名称:eEcology-Classification,代码行数:11,代码来源:AnnotatedMeasurementsMatLoader.java


示例15: testStruct

import com.jmatio.types.MLStructure; //导入依赖的package包/类
@Test
public void testStruct() 
{
    MLStructure actual = (MLStructure) MLArrayQuery.q( array, "SPM" );
    assertEquals( "SPM", actual.getName() );
    assertEquals( 1, actual.getSize() );
}
 
开发者ID:gradusnikov,项目名称:jmatio,代码行数:8,代码来源:MLArrayQueryTest.java


示例16: testStruct2

import com.jmatio.types.MLStructure; //导入依赖的package包/类
@Test
public void testStruct2() 
{
    MLStructure actual = (MLStructure) MLArrayQuery.q( array, "SPM(1,1)" );
    assertEquals( "SPM", actual.getName() );
    assertEquals( 1, actual.getSize() );
}
 
开发者ID:gradusnikov,项目名称:jmatio,代码行数:8,代码来源:MLArrayQueryTest.java


示例17: testStruct3

import com.jmatio.types.MLStructure; //导入依赖的package包/类
@Test
public void testStruct3() 
{
    MLStructure actual = (MLStructure) MLArrayQuery.q( array, "SPM(1)" );
    assertEquals( "SPM", actual.getName() );
    assertEquals( 1, actual.getSize() );
}
 
开发者ID:gradusnikov,项目名称:jmatio,代码行数:8,代码来源:MLArrayQueryTest.java


示例18: testMLStructure

import com.jmatio.types.MLStructure; //导入依赖的package包/类
/**
 * Test <code>MatFileFilter</code> options
 * @throws IOException 
 */
@Test
public void testMLStructure() throws IOException
{
    //array name
    //file name in which array will be storred
    String fileName = "mlstruct.mat";
    File outFile = temp.newFile( fileName );

    //test column-packed vector
    double[] src = new double[] { 1.3, 2.0, 3.0, 4.0, 5.0, 6.0 };
    
    //create 3x2 double matrix
    //[ 1.0 4.0 ;
    //  2.0 5.0 ;
    //  3.0 6.0 ]
    MLDouble mlDouble = new MLDouble( null, src, 3 );
    MLChar mlChar = new MLChar( null, "I am dummy" );
    
    
    MLStructure mlStruct = new MLStructure("str", new int[] {1,1} );
    mlStruct.setField("f1", mlDouble);
    mlStruct.setField("f2", mlChar);
    
    //write array to file
    ArrayList<MLArray> list = new ArrayList<MLArray>();
    list.add( mlStruct );
    
    //write arrays to file
    new MatFileWriter( outFile, list );
    
    //read array form file
    MatFileReader mfr = new MatFileReader( outFile );
    MLStructure mlArrayRetrived = (MLStructure)mfr.getMLArray( "str" );
    
    assertEquals(mlDouble, mlArrayRetrived.getField("f1") );
    assertEquals(mlChar, mlArrayRetrived.getField("f2") );
    

}
 
开发者ID:gradusnikov,项目名称:jmatio,代码行数:44,代码来源:MatIOTest.java


示例19: testObject

import com.jmatio.types.MLStructure; //导入依赖的package包/类
@Test
    public void testObject() throws Exception
    {
        MatFileReader mfr = new MatFileReader();
        Map<String, MLArray> content = mfr.read( new File("src/test/resources/object.mat") );
        
        MLObject mlObject = (MLObject) content.get( "X" );
        
        assertEquals( "inline", mlObject.getClassName() );
        assertTrue( mlObject.getObject() instanceof MLStructure );
        assertTrue( mlObject.getObject().getFieldNames().contains( "expr" ) );
//        System.out.println(mlObject.getObject().getFieldNames());
    }
 
开发者ID:gradusnikov,项目名称:jmatio,代码行数:14,代码来源:MatIOTest.java


示例20: 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);
}
 
开发者ID:NLeSC,项目名称:eEcology-Classification,代码行数:7,代码来源:MeasurementsMatLoader.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CLEvent类代码示例发布时间:2022-05-22
下一篇:
Java LayerManager类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap