Examples of MLArray


Examples of com.jmatio.types.MLArray

            case MatDataTypes.miMATRIX:
               
                //read in the matrix
                int pos = buf.position();
               
                MLArray element = readMatrix( buf, true );
               
                if ( element != null )
                {
                    data.put( element.getName(), element );
                }
                else
                {
                    int readedBytes = buf.position() - pos;
                    int toread = tag.size - readedBytes;
View Full Code Here

Examples of com.jmatio.types.MLArray

     * @throws IOException when error occurs while reading the buffer.
     */
    private MLArray readMatrix(ByteBuffer buf, boolean isRoot ) throws IOException
    {
        //result
        MLArray mlArray;
        ISMatTag tag;
       
        //read flags
        int[] flags = readFlags(buf);
        int attributes = ( flags.length != 0 ) ? flags[0] : 0;
        int nzmax = ( flags.length != 0 ) ? flags[1] : 0;
        int type = attributes & 0xff;
       
        //read Array dimension
        int[] dims = readDimension(buf);
       
        //read array Name
        String name = readName(buf);
       
        //if this array is filtered out return immediately
        if ( isRoot && !filter.matches(name) )
        {
            return null;
        }
       

        //read data >> consider changing it to stategy pattern
        switch ( type )
        {
            case MLArray.mxSTRUCT_CLASS:
               
                MLStructure struct = new MLStructure(name, dims, type, attributes);
               
                //field name length - this subelement always uses the compressed data element format
                tag = new ISMatTag(buf);
                int maxlen = buf.getInt(); //maximum field length

                //////  read fields data as Int8
                tag = new ISMatTag(buf);
                //calculate number of fields
                int numOfFields = tag.size/maxlen;
               
                //padding after field names
                int padding = (tag.size%8) != 0 ? 8-(tag.size%8) : 0;

                String[] fieldNames = new String[numOfFields];
                for ( int i = 0; i < numOfFields; i++ )
                {
                    byte[] names = new byte[maxlen];
                    buf.get(names);
                    fieldNames[i] = zeroEndByteArrayToString(names);
                }
                buf.position( buf.position() + padding );
                //read fields
                for ( int index = 0; index < struct.getM()*struct.getN(); index++ )
                {
                    for ( int i = 0; i < numOfFields; i++ )
                    {
                        //read matrix recursively
                        tag = new ISMatTag(buf);
                        MLArray fieldValue = readMatrix( buf, false);
                        struct.setField(fieldNames[i], fieldValue, index);
                    }
                }
                mlArray = struct;
                break;
            case MLArray.mxCELL_CLASS:
                MLCell cell = new MLCell(name, dims, type, attributes);
                for ( int i = 0; i < cell.getM()*cell.getN(); i++ )
                {
                    tag = new ISMatTag(buf);
                    //read matrix recursively
                    MLArray cellmatrix = readMatrix( buf, false);
                    cell.set(cellmatrix, i);
                }
                mlArray = cell;
                break;
            case MLArray.mxDOUBLE_CLASS:
View Full Code Here

Examples of com.jmatio.types.MLArray

  Iterator <String> varsIter = varsSet.iterator();
  boolean isRoot = true;
  while (varsIter.hasNext())  {  // for all .mat file variables
        String currentVariable = varsIter.next()// get the String of the Matlab variable
            //  the value to which the read file maps the specified array name. Returns null if the file contains no content for this name.
        MLArray  objArrayRetrived = mfr.getMLArray(currentVariable);
        if (objArrayRetrived instanceof  MLDouble) {
            // public MLArray getMLArray(String name)
        // Returns the value to which the read file maps the specified array name. Returns null if the file contains no content for this name.
// Returns: - the MLArray to which this file maps the specified name, or null if the file contains no content for this name.
         MLDouble mlArrayRetrived = (MLDouble)mfr.getMLArray(currentVariable);
View Full Code Here

Examples of com.jmatio.types.MLArray

            xhtml.startDocument();
            xhtml.newline();
            //Loop through each variable
            for (Map.Entry<String, MLArray> entry : mfr.getContent().entrySet()) {
                String varName = entry.getKey();
                MLArray varData = entry.getValue();

                xhtml.element("p", varName + ":" + String.valueOf(varData));

                // If the variable is a structure, extract variable info from structure
                if (varData.isStruct()){
                    MLStructure mlStructure = (MLStructure) mfr.getMLArray(varName);
                    xhtml.startElement("ul");
                    xhtml.newline();
                    for (MLArray element : mlStructure.getAllFields()){
                        xhtml.startElement("li");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.