本文整理汇总了Java中com.jmatio.types.MLDouble类的典型用法代码示例。如果您正苦于以下问题:Java MLDouble类的具体用法?Java MLDouble怎么用?Java MLDouble使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MLDouble类属于com.jmatio.types包,在下文中一共展示了MLDouble类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: doImportGTfromMatlab
import com.jmatio.types.MLDouble; //导入依赖的package包/类
synchronized public void doImportGTfromMatlab() {
JFileChooser chooser = new JFileChooser();
chooser.setDialogTitle("Choose ground truth file");
chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
chooser.setMultiSelectionEnabled(false);
if (chooser.showOpenDialog(chip.getAeViewer().getFilterFrame()) == JFileChooser.APPROVE_OPTION) {
try {
vxGTframe = ((MLDouble) (new MatFileReader(chooser.getSelectedFile().getPath())).getMLArray("vxGT")).getArray();
vyGTframe = ((MLDouble) (new MatFileReader(chooser.getSelectedFile().getPath())).getMLArray("vyGT")).getArray();
tsGTframe = ((MLDouble) (new MatFileReader(chooser.getSelectedFile().getPath())).getMLArray("ts")).getArray();
importedGTfromMatlab = true;
log.info("Imported ground truth file");
} catch (IOException ex) {
log.log(Level.SEVERE, null, ex);
}
}
}
开发者ID:SensorsINI,项目名称:jaer,代码行数:18,代码来源:AbstractMotionFlowIMU.java
示例2: getSampledData
import com.jmatio.types.MLDouble; //导入依赖的package包/类
public SampledData getSampledData() {
// get generators active power
MLDouble pGen = (MLDouble) matFileContent.get("PGEN");
double[][] generatorsActivePower = null;
if (pGen != null) {
generatorsActivePower = pGen.getArray();
}
// get loads active power
MLDouble pLoad = (MLDouble) matFileContent.get("PLOAD");
double[][] loadsActivePower = null;
if (pLoad != null) {
loadsActivePower = pLoad.getArray();
}
// get loads reactive power
MLDouble qLoad = (MLDouble) matFileContent.get("QLOAD");
double[][] loadsReactivePower = null;
if (qLoad != null) {
loadsReactivePower = qLoad.getArray();
}
SampledData sampledData = new SampledData(generatorsActivePower, loadsActivePower, loadsReactivePower);
return sampledData;
}
开发者ID:itesla,项目名称:ipst,代码行数:24,代码来源:MCSMatFileReader.java
示例3: writeHistoricalData
import com.jmatio.types.MLDouble; //导入依赖的package包/类
public void writeHistoricalData(ForecastErrorsHistoricalData forecastErrorsHistoricalData) throws IOException {
Objects.requireNonNull(forecastErrorsHistoricalData, "forecast errors historical data is null");
// LOGGER.debug("Preparing stochastic variables mat data");
// MLStructure stochasticVariables = stochasticVariablesAsMLStructure(forecastErrorsHistoricalData.getStochasticVariables());
LOGGER.debug("Preparing injections mat data");
MLCell injections = histoDataHeadersAsMLChar(forecastErrorsHistoricalData.getForecastsData().columnKeyList());
LOGGER.debug("Preparing injections countries mat data");
MLCell injectionsCountries = injectionCountriesAsMLChar(forecastErrorsHistoricalData.getStochasticVariables());
LOGGER.debug("Preparing forecasts mat data");
MLDouble forecastsData = histoDataAsMLDouble("forec_filt", forecastErrorsHistoricalData.getForecastsData());
LOGGER.debug("Preparing snapshots mat data");
MLDouble snapshotsData = histoDataAsMLDouble("snap_filt", forecastErrorsHistoricalData.getSnapshotsData());
LOGGER.debug("Saving mat data into " + matFile.toString());
List<MLArray> mlarray = new ArrayList<>();
// mlarray.add((MLArray) stochasticVariables );
mlarray.add((MLArray) injections);
mlarray.add((MLArray) forecastsData);
mlarray.add((MLArray) snapshotsData);
mlarray.add((MLArray) injectionsCountries);
MatFileWriter writer = new MatFileWriter();
writer.write(matFile.toFile(), mlarray);
}
开发者ID:itesla,项目名称:ipst,代码行数:23,代码来源:FEAMatFileWriter.java
示例4: histoDataAsMLDouble
import com.jmatio.types.MLDouble; //导入依赖的package包/类
private MLDouble histoDataAsMLDouble(String name, ArrayTable<Integer, String, Float> histoData) {
int rowsSize = histoData.rowKeySet().size();
int colsSize = histoData.columnKeySet().size();
MLDouble mlDouble = new MLDouble(name, new int[] {rowsSize, colsSize});
int i = 0;
for (Integer rowKey : histoData.rowKeyList()) {
int j = 0;
for (String colkey : histoData.columnKeyList()) {
Float v = histoData.get(rowKey, colkey);
mlDouble.set(new Double(v), i, j);
j++;
}
i++;
}
return mlDouble;
}
开发者ID:itesla,项目名称:ipst,代码行数:17,代码来源:FEAMatFileWriter.java
示例5: readMDoubleFromCSVFile
import com.jmatio.types.MLDouble; //导入依赖的package包/类
public static MLDouble readMDoubleFromCSVFile(Path inFilePath, String mName, int nrows, int ncols, char delimiter) throws NumberFormatException, IOException {
MLDouble mlDouble = new MLDouble(mName, new int[] {nrows, ncols});
CsvReader cvsReader = new CsvReader(inFilePath.toString());
cvsReader.setDelimiter(delimiter);
int i = 0;
while (cvsReader.readRecord()) {
String[] rows = cvsReader.getValues();
int j = 0;
for (String col : rows) {
mlDouble.set(new Double(col), i, j);
j++;
}
i++;
}
return mlDouble;
}
开发者ID:itesla,项目名称:ipst,代码行数:17,代码来源:Utils.java
示例6: fromFile
import com.jmatio.types.MLDouble; //导入依赖的package包/类
public static Matrix fromFile(File file, Object... parameters) throws IOException {
String key = null;
if (parameters != null && parameters.length > 0 && parameters[0] instanceof String) {
key = (String) parameters[0];
}
MatFileReader reader = new MatFileReader();
Map<String, MLArray> map = reader.read(file);
if (key == null) {
key = map.keySet().iterator().next();
}
MLArray array = map.get(key);
if (array == null) {
throw new RuntimeException("matrix with label [" + key + "] was not found in .mat file");
} else if (array instanceof MLDouble) {
return new MLDenseDoubleMatrix((MLDouble) array);
} else {
throw new RuntimeException("This type is not yet supported: " + array.getClass());
}
}
开发者ID:ujmp,项目名称:universal-java-matrix-package,代码行数:20,代码来源:ImportMatrixMAT.java
示例7: writeMatlabFile1
import com.jmatio.types.MLDouble; //导入依赖的package包/类
public void writeMatlabFile1() throws Exception
{
//1. First create example arrays
double[] src = new double[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 };
MLDouble mlDouble = new MLDouble( "double_arr", src, 2 );
MLChar mlChar = new MLChar( "char_arr", "I am dummy" );
//2. write arrays to file
ArrayList<MLArray> list = new ArrayList<MLArray>();
list.add( mlDouble );
list.add( mlChar );
MatFileIncrementalWriter writer = new MatFileIncrementalWriter("mat_file.mat");
writer.write(mlDouble);
writer.write(mlChar);
writer.close();
}
开发者ID:kasemir,项目名称:org.csstudio.display.builder,代码行数:18,代码来源:JMatioDemo.java
示例8: createMLStruct
import com.jmatio.types.MLDouble; //导入依赖的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
示例9: writeToMatlab
import com.jmatio.types.MLDouble; //导入依赖的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
示例10: writeToMatlab
import com.jmatio.types.MLDouble; //导入依赖的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
示例11: prepareFolds
import com.jmatio.types.MLDouble; //导入依赖的package包/类
private void prepareFolds() {
final MLArray setfolds = this.content.get("set_fold");
if(setfolds==null) return;
if (setfolds.isCell()) {
this.folds = new ArrayList<Fold>();
final MLCell foldcells = (MLCell) setfolds;
final int nfolds = foldcells.getM();
System.out.println(String.format("Found %d folds", nfolds));
for (int i = 0; i < nfolds; i++) {
final MLDouble training = (MLDouble) foldcells.get(i, 0);
final MLDouble test = (MLDouble) foldcells.get(i, 1);
final MLDouble validation = (MLDouble) foldcells.get(i, 2);
final Fold f = new Fold(toIntArray(training), toIntArray(test),
toIntArray(validation));
folds.add(f);
}
} else {
throw new RuntimeException(
"Can't find set_folds in expected format");
}
}
开发者ID:openimaj,项目名称:openimaj,代码行数:23,代码来源:BillMatlabFileDataGenerator.java
示例12: parseAnnotations
import com.jmatio.types.MLDouble; //导入依赖的package包/类
private void parseAnnotations(FileObject annotationFile) throws IOException {
if (!annotationFile.exists()) {
return;
}
final MatFileReader reader = new MatFileReader(annotationFile.getContent().getInputStream());
final MLDouble boxes = (MLDouble) reader.getMLArray("box_coord");
this.bounds = new Rectangle(
(float) (double) boxes.getReal(2) - 1,
(float) (double) boxes.getReal(0) - 1,
(float) (boxes.getReal(3) - boxes.getReal(2)) - 1,
(float) (boxes.getReal(1) - boxes.getReal(0)) - 1);
final double[][] contourData = ((MLDouble) reader.getMLArray("obj_contour")).getArray();
this.contour = new Polygon();
for (int i = 0; i < contourData[0].length; i++) {
contour.points.add(
new Point2dImpl((float) contourData[0][i] + bounds.x - 1,
(float) contourData[1][i] + bounds.y - 1)
);
}
contour.close();
}
开发者ID:openimaj,项目名称:openimaj,代码行数:25,代码来源:Caltech101.java
示例13: testMLStructureFieldNames
import com.jmatio.types.MLDouble; //导入依赖的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
示例14: testDoubleFromMatlabCreatedFile
import com.jmatio.types.MLDouble; //导入依赖的package包/类
/**
* Regression bug
*
* @throws Exception
*/
@Test
public void testDoubleFromMatlabCreatedFile() throws Exception
{
//array name
String name = "arr";
//file name in which array will be stored
String fileName = "src/test/resources/matnativedouble.mat";
//test column-packed vector
double[] src = new double[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 };
MLDouble mlDouble = new MLDouble( name, src, 3 );
//read array form file
MatFileReader mfr = new MatFileReader( fileName );
MLArray mlArrayRetrived = mfr.getMLArray( name );
//test if MLArray objects are equal
assertEquals("Test if value red from file equals value stored", mlDouble, mlArrayRetrived);
}
开发者ID:gradusnikov,项目名称:jmatio,代码行数:25,代码来源:MatIOTest.java
示例15: testDoubleFromMatlabCreatedFile2
import com.jmatio.types.MLDouble; //导入依赖的package包/类
/**
* Regression bug.
* <pre><code>
* Matlab code:
* >> arr = [1.1, 4.4; 2.2, 5.5; 3.3, 6.6];
* >> save('matnativedouble2', arr);
* </code></pre>
*
* @throws IOException
*/
@Test
public void testDoubleFromMatlabCreatedFile2() throws IOException
{
//array name
String name = "arr";
//file name in which array will be stored
String fileName = "src/test/resources/matnativedouble2.mat";
//test column-packed vector
double[] src = new double[] { 1.1, 2.2, 3.3, 4.4, 5.5, 6.6 };
MLDouble mlDouble = new MLDouble( name, src, 3 );
//read array form file
MatFileReader mfr = new MatFileReader( fileName );
MLArray mlArrayRetrived = mfr.getMLArray( name );
//test if MLArray objects are equal
assertEquals("Test if value red from file equals value stored", mlDouble, mlArrayRetrived);
}
开发者ID:gradusnikov,项目名称:jmatio,代码行数:31,代码来源:MatIOTest.java
示例16: exportFlowToMatlab
import com.jmatio.types.MLDouble; //导入依赖的package包/类
public void exportFlowToMatlab(final int tmin, final int tmax) {
if (!exportedFlowToMatlab) {
int firstTs = dirPacket.getFirstTimestamp();
if (firstTs > tmin && firstTs < tmax) {
if (vxOut == null) {
vxOut = new double[sizey][sizex];
vyOut = new double[sizey][sizex];
}
for (Object o : dirPacket) {
ApsDvsMotionOrientationEvent ev = (ApsDvsMotionOrientationEvent) o;
if (ev.hasDirection) {
vxOut[ev.y][ev.x] = ev.velocity.x;
vyOut[ev.y][ev.x] = ev.velocity.y;
}
}
}
if (firstTs > tmax && vxOut != null) {
ArrayList list = new ArrayList();
list.add(new MLDouble("vx", vxOut));
list.add(new MLDouble("vy", vyOut));
try {
MatFileWriter matFileWriter = new MatFileWriter(loggingFolder + "/flowExport.mat", list);
} catch (IOException ex) {
log.log(Level.SEVERE, null, ex);
}
log.log(Level.INFO, "Exported motion flow to {0}/flowExport.mat", loggingFolder);
exportedFlowToMatlab = true;
vxOut = null;
vyOut = null;
}
}
}
开发者ID:SensorsINI,项目名称:jaer,代码行数:33,代码来源:AbstractMotionFlowIMU.java
示例17: putBusDataIntoMLStructure
import com.jmatio.types.MLDouble; //导入依赖的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
示例18: putGeneratorDataIntoMLStructure
import com.jmatio.types.MLDouble; //导入依赖的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
示例19: readDoublesMatrixFromMat
import com.jmatio.types.MLDouble; //导入依赖的package包/类
public static double[][] readDoublesMatrixFromMat(Path matFile, String doublesMatrixName) throws IOException {
Objects.requireNonNull(matFile, "mat file is null");
MatFileReader matFileReader = new MatFileReader();
Map<String, MLArray> matFileContent = matFileReader.read(matFile.toFile());
MLDouble doublesMatrix = (MLDouble) matFileContent.get(doublesMatrixName);
double[][] doubles = null;
if (doublesMatrix != null) {
doubles = doublesMatrix.getArray();
}
return doubles;
}
开发者ID:itesla,项目名称:ipst,代码行数:12,代码来源:Utils.java
示例20: computeBinSampling
import com.jmatio.types.MLDouble; //导入依赖的package包/类
public double[][] computeBinSampling(double[] marginalExpectations, int nSamples) throws Exception {
Objects.requireNonNull(marginalExpectations);
if (marginalExpectations.length == 0) {
throw new IllegalArgumentException("empty marginalExpectations array");
}
if (nSamples <= 0) {
throw new IllegalArgumentException("number of samples must be positive");
}
try (CommandExecutor executor = computationManager.newCommandExecutor(createEnv(), WORKING_DIR_PREFIX, config.isDebug())) {
Path workingDir = executor.getWorkingDir();
Utils.writeWP41BinaryIndependentSamplingInputFile(workingDir.resolve(B1INPUTFILENAME), marginalExpectations);
LOGGER.info("binsampler, asking for {} samples", nSamples);
Command cmd = createBinSamplerCmd(workingDir.resolve(B1INPUTFILENAME), nSamples);
ExecutionReport report = executor.start(new CommandExecution(cmd, 1, priority));
report.log();
LOGGER.debug("Retrieving binsampler results from file {}", B1OUTPUTFILENAME);
MatFileReader mfr = new MatFileReader();
Map<String, MLArray> content;
content = mfr.read(workingDir.resolve(B1OUTPUTFILENAME).toFile());
String errMsg = Utils.MLCharToString((MLChar) content.get("errmsg"));
if (!("Ok".equalsIgnoreCase(errMsg))) {
throw new MatlabException(errMsg);
}
MLArray xNew = content.get("STATUS");
Objects.requireNonNull(xNew);
MLDouble mld = (MLDouble) xNew;
double[][] retMat = mld.getArray();
return retMat;
}
}
开发者ID:itesla,项目名称:ipst,代码行数:37,代码来源:SamplerWp41.java
注:本文中的com.jmatio.types.MLDouble类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论