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


Java MLCell.set方法代码示例

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


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

示例1: writeToMatlab

import com.jmatio.types.MLCell; //导入方法依赖的package包/类
/**
 * Write a CSV wordIndex to a {@link MLCell} writen to a .mat data file
 * 
 * @param path
 * @throws IOException
 */
public static void writeToMatlab(String path) throws IOException {
	final Path wordMatPath = new Path(path + "/words/wordIndex.mat");
	final FileSystem fs = HadoopToolsUtil.getFileSystem(wordMatPath);
	final LinkedHashMap<String, IndependentPair<Long, Long>> wordIndex = readWordCountLines(path);
	final MLCell wordCell = new MLCell("words", new int[] { wordIndex.size(), 2 });

	System.out.println("... reading words");
	for (final Entry<String, IndependentPair<Long, Long>> ent : wordIndex.entrySet()) {
		final String word = ent.getKey();
		final int wordCellIndex = (int) (long) ent.getValue().secondObject();
		final long count = ent.getValue().firstObject();
		wordCell.set(new MLChar(null, word), wordCellIndex, 0);
		wordCell.set(new MLDouble(null, new double[][] { new double[] { count } }), wordCellIndex, 1);
	}
	final ArrayList<MLArray> list = new ArrayList<MLArray>();
	list.add(wordCell);
	new MatFileWriter(Channels.newChannel(fs.create(wordMatPath)), list);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:25,代码来源:WordIndex.java

示例2: writeToMatlab

import com.jmatio.types.MLCell; //导入方法依赖的package包/类
/**
 * Write a CSV timeIndex to a {@link MLCell} writen to a .mat data file
 * @param path
 * @throws IOException
 */
public static void writeToMatlab(String path) throws IOException {
	Path timeMatPath = new Path(path + "/times/timeIndex.mat");
	FileSystem fs = HadoopToolsUtil.getFileSystem(timeMatPath);
	LinkedHashMap<Long, IndependentPair<Long, Long>> timeIndex = readTimeCountLines(path);
	MLCell timeCell = new MLCell("times",new int[]{timeIndex.size(),2});
	
	System.out.println("... reading times");
	for (Entry<Long, IndependentPair<Long, Long>> ent : timeIndex.entrySet()) {
		long time = (long)ent.getKey();
		int timeCellIndex = (int)(long)ent.getValue().secondObject();
		long count = ent.getValue().firstObject();
		timeCell.set(new MLDouble(null, new double[][]{new double[]{time}}), timeCellIndex,0);
		timeCell.set(new MLDouble(null, new double[][]{new double[]{count}}), timeCellIndex,1);
	}
	ArrayList<MLArray> list = new ArrayList<MLArray>();
	list.add(timeCell);
	new MatFileWriter(Channels.newChannel(fs.create(timeMatPath)),list );
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:24,代码来源:TimeIndex.java

示例3: histoDataHeadersAsMLChar

import com.jmatio.types.MLCell; //导入方法依赖的package包/类
private MLCell histoDataHeadersAsMLChar(List<String> histoDataHeaders) {
    int colsSize = histoDataHeaders.size() - 2;
    MLCell injections = new MLCell("inj_ID", new int[]{1, colsSize});
    int i = 0;
    for (String colkey : histoDataHeaders) {
        if (colkey.equals("forecastTime") || colkey.equals("datetime")) {
            continue;
        }
        injections.set(new MLChar("", colkey), 0, i);
        i++;
    }
    return injections;
}
 
开发者ID:itesla,项目名称:ipst,代码行数:14,代码来源:FEAMatFileWriter.java

示例4: injectionCountriesAsMLChar

import com.jmatio.types.MLCell; //导入方法依赖的package包/类
private MLCell injectionCountriesAsMLChar(List<StochasticVariable> stochasticVariables) {
    int colsSize = stochasticVariables.size() * 2;
    MLCell injectionsCountries = new MLCell("nat_ID", new int[]{1, colsSize});
    int i = 0;
    for (StochasticVariable injection : stochasticVariables) {
        injectionsCountries.set(new MLChar("", injection.getCountry().name()), 0, i);
        i++;
        injectionsCountries.set(new MLChar("", injection.getCountry().name()), 0, i); // twice, for P and Q
        i++;
    }
    return injectionsCountries;
}
 
开发者ID:itesla,项目名称:ipst,代码行数:13,代码来源:FEAMatFileWriter.java

示例5: setCellText

import com.jmatio.types.MLCell; //导入方法依赖的package包/类
private void setCellText(final MLCell cell, final int index, final String text)
{
    cell.set(new MLChar(null, text), index);
}
 
开发者ID:kasemir,项目名称:org.csstudio.display.builder,代码行数:5,代码来源:JMatioDemo.java

示例6: testMLCell

import com.jmatio.types.MLCell; //导入方法依赖的package包/类
/**
 * Test <code>MatFileFilter</code> options
 * @throws IOException 
 */
@Test 
public void testMLCell() throws IOException
{
    //array name
    String name = "doublearr";
    String name2 = "name";
    //file name in which array will be storred
    String fileName = "mlcell.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( name, src, 3 );
    MLChar mlChar = new MLChar( name2, "none" );
    
    
    MLCell mlCell = new MLCell("cl", new int[] {2,1} );
    mlCell.set(mlChar, 0);
    mlCell.set(mlDouble, 1);
    
    //write array to file
    ArrayList<MLArray> list = new ArrayList<MLArray>();
    list.add( mlCell );
    
    //write arrays to file
    new MatFileWriter( outFile, list );
    
    //read array form file
    MatFileReader mfr = new MatFileReader( outFile );
    MLCell mlArrayRetrived = (MLCell)mfr.getMLArray( "cl" );
    
    assertEquals(mlDouble, mlArrayRetrived.get(1) );
    assertEquals(mlChar, mlArrayRetrived.get(0) );
    

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

示例7: setCellText

import com.jmatio.types.MLCell; //导入方法依赖的package包/类
/** Set element of cell array to text
 *  @param cell Cell array to update
 *  @param index Index of cell element
 *  @param text Text to place in cell element
 */
private void setCellText(final MLCell cell, final int index, final String text)
{
    cell.set(new MLChar(null, text), index);
}
 
开发者ID:kasemir,项目名称:org.csstudio.display.builder,代码行数:10,代码来源:MatlabFileExportJob.java


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