本文整理汇总了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);
}
示例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 );
}
示例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;
}
示例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;
}
示例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);
}
示例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) );
}
示例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);
}