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


Java MLChar类代码示例

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


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

示例1: readStringsArrayFromMat

import com.jmatio.types.MLChar; //导入依赖的package包/类
public static String[] readStringsArrayFromMat(Path matFile, String stringsArrayName) throws IOException {
    Objects.requireNonNull(matFile, "mat file is null");
    Objects.requireNonNull(stringsArrayName, "strings array name is null");
    MatFileReader matFileReader = new MatFileReader();
    Map<String, MLArray> matFileContent = matFileReader.read(matFile.toFile());
    MLCell stringsArray = (MLCell) matFileContent.get(stringsArrayName);
    String[] strings = new String[stringsArray.getN()];
    for (int i = 0; i < stringsArray.getN(); i++) {
        strings[i] = ((MLChar) stringsArray.get(0, i)).getString(0);
    }
    return strings;
}
 
开发者ID:itesla,项目名称:ipst,代码行数:13,代码来源:Utils.java

示例2: writeMatlabFile1

import com.jmatio.types.MLChar; //导入依赖的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

示例3: createMLStruct

import com.jmatio.types.MLChar; //导入依赖的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

示例4: writeToMatlab

import com.jmatio.types.MLChar; //导入依赖的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

示例5: testMLCharUnicode

import com.jmatio.types.MLChar; //导入依赖的package包/类
@Test
public void testMLCharUnicode() throws Exception
{
    //array name
    String name = "chararr";
    //file name in which array will be storred
    String fileName = "mlcharUTF.mat";
    File outFile = temp.newFile( fileName );
    //temp
    String valueS;

    //create MLChar array of a name "chararr" containig one
    //string value "dummy"
    MLChar mlChar = new MLChar(name, new String[] { "\u017C\u00F3\u0142w", "\u017C\u00F3\u0142i"} );
    MatFileWriter writer = new MatFileWriter();
    writer.write(outFile, Arrays.asList( (MLArray) mlChar ) );
    
    MatFileReader reader = new MatFileReader( outFile );
    MLChar mlChar2 = (MLChar) reader.getMLArray(name);

    assertEquals("\u017C\u00F3\u0142w", mlChar.getString(0) );
    assertEquals("\u017C\u00F3\u0142w", mlChar2.getString(0) );
    assertEquals("\u017C\u00F3\u0142i", mlChar2.getString(1) );        
}
 
开发者ID:gradusnikov,项目名称:jmatio,代码行数:25,代码来源:MatIOTest.java

示例6: testMLStructureFieldNames

import com.jmatio.types.MLChar; //导入依赖的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.MLChar; //导入依赖的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.MLChar; //导入依赖的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: MCSMatFileReader

import com.jmatio.types.MLChar; //导入依赖的package包/类
public MCSMatFileReader(Path matFile) throws Exception {
    Objects.requireNonNull(matFile, "mat file is null");
    MatFileReader sampledDataFileReader = new MatFileReader();
    matFileContent = sampledDataFileReader.read(matFile.toFile());
    String errorMessage = Utils.MLCharToString((MLChar) matFileContent.get("errmsg"));
    if (!("Ok".equalsIgnoreCase(errorMessage))) {
        throw new MatlabException(errorMessage);
    }
}
 
开发者ID:itesla,项目名称:ipst,代码行数:10,代码来源:MCSMatFileReader.java

示例10: histoDataHeadersAsMLChar

import com.jmatio.types.MLChar; //导入依赖的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

示例11: putStochasticVariablesIntoMLStructure

import com.jmatio.types.MLChar; //导入依赖的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

示例12: injectionCountriesAsMLChar

import com.jmatio.types.MLChar; //导入依赖的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

示例13: computeBinSampling

import com.jmatio.types.MLChar; //导入依赖的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

示例14: MLCharToString

import com.jmatio.types.MLChar; //导入依赖的package包/类
public static String MLCharToString(MLChar mlchar) {
    StringBuffer sb = new StringBuffer();
    for (int m = 0; m < mlchar.getM(); m++) {
        for (int n = 0; n < mlchar.getN(); n++) {
            sb.append(mlchar.getChar(m, n));
        }
    }
    return sb.toString();
}
 
开发者ID:itesla,项目名称:ipst,代码行数:10,代码来源:Utils.java

示例15: prepareVocabulary

import com.jmatio.types.MLChar; //导入依赖的package包/类
private void prepareVocabulary() {
	this.keepIndex = new HashSet<Integer>();

	final MLDouble keepIndex = (MLDouble) this.content.get("voc_keep_terms_index");
	if(keepIndex != null){
		final double[] filterIndexArr = keepIndex.getArray()[0];
		
		for (final double d : filterIndexArr) {
			this.keepIndex.add((int) d - 1);
		}
		
	}
	
	final MLCell vocLoaded = (MLCell) this.content.get("voc");
	if(vocLoaded!=null){
		this.indexToVoc = new HashMap<Integer, Integer>();
		final ArrayList<MLArray> vocArr = vocLoaded.cells();
		int index = 0;
		int vocIndex = 0;
		this.voc = new HashMap<Integer, String>();
		for (final MLArray vocArrItem : vocArr) {
			final MLChar vocChar = (MLChar) vocArrItem;
			final String vocString = vocChar.getString(0);
			if (filter && this.keepIndex.contains(index)) {
				this.voc.put(vocIndex, vocString);
				this.indexToVoc.put(index, vocIndex);
				vocIndex++;
			}
			index++;
		}
	} else {
		
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:35,代码来源:BillMatlabFileDataGenerator.java


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