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


Java MLUInt8类代码示例

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


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

示例1: testBenchmarkUInt8

import com.jmatio.types.MLUInt8; //导入依赖的package包/类
@Test 
public void testBenchmarkUInt8() throws Exception
{
    final String fileName = "bigbyte.mat";
    final String name = "bigbyte";
    File outFile = temp.newFile( fileName );
    final int SIZE = 1024;    
    
    
    MLUInt8 mluint8 = new MLUInt8( name, new int[] { SIZE, SIZE } );
    
    //write array to file
    ArrayList<MLArray> list = new ArrayList<MLArray>();
    list.add( mluint8 );
    
    //write arrays to file
    new MatFileWriter( outFile, list );
    
    //read array form file
    MatFileReader mfr = new MatFileReader( outFile );
    MLArray mlArrayRetrived = mfr.getMLArray( name );
    
    final long start = System.nanoTime();
    for ( int i = 0; i < mlArrayRetrived.getSize(); i++ )
    {
        ((MLNumericArray<?>)mlArrayRetrived).get(i);
    }
    final long stop = System.nanoTime();
    System.out.println("--> " + (stop - start)/1e6 +  "[ns]");
           
    //test if MLArray objects are equal
    assertEquals("Test if value red from file equals value stored", mluint8, mlArrayRetrived);
}
 
开发者ID:gradusnikov,项目名称:jmatio,代码行数:34,代码来源:MatIOTest.java

示例2: testLogical

import com.jmatio.types.MLUInt8; //导入依赖的package包/类
@Test
public void testLogical() throws IOException
{
    String name = "bool";
    String fileName = "src/test/resources/logical.mat";
    
    MatFileReader reader = new MatFileReader( fileName );
    
    MLUInt8 mlArray = (MLUInt8) reader.getMLArray( name );
    assertEquals( 1, (int) mlArray.get(0) );
    assertEquals( 0, (int) mlArray.get(1) );
}
 
开发者ID:gradusnikov,项目名称:jmatio,代码行数:13,代码来源:MatIOTest.java

示例3: testMLUInt8Array

import com.jmatio.types.MLUInt8; //导入依赖的package包/类
/**
 * Tests <code>MLUint8</code> reading and writing.
 * 
 * @throws IOException
 */
@Test 
public void testMLUInt8Array() throws IOException
{
    //array name
    String name = "arr";
    //file name in which array will be storred
    String fileName = "mluint8tst.mat";
    File outFile = temp.newFile( fileName );
    
    //test column-packed vector
    byte[] src = new byte[] { 1, 2, 3, 4, 5, 6 };
    //test 2D array coresponding to test vector
    byte[][] src2D = new byte[][] { { 1, 4 },
                                    { 2, 5 },
                                    { 3, 6 }
                                    };

    //create 3x2 double matrix
    //[ 1.0 4.0 ;
    //  2.0 5.0 ;
    //  3.0 6.0 ]
    MLUInt8 mluint8 = new MLUInt8( name, src, 3 );
    
    //write array to file
    ArrayList<MLArray> list = new ArrayList<MLArray>();
    list.add( mluint8 );
    
    //write arrays to file
    new MatFileWriter( outFile, list );
    
    //read array form file
    MatFileReader mfr = new MatFileReader( outFile );
    MLArray mlArrayRetrived = mfr.getMLArray( name );
    
    //test if MLArray objects are equal
    assertEquals("Test if value red from file equals value stored", mluint8, mlArrayRetrived);
    
    //test if 2D array match
    for ( int i = 0; i < src2D.length; i++ )
    {
        boolean result = Arrays.equals( src2D[i], ((MLUInt8)mlArrayRetrived ).getArray()[i] );
        assertEquals( "2D array match", true, result );
    }
    
    //test new constructor
    MLArray mlMLUInt82D = new MLUInt8(name, src2D );
    //compare it with original
    assertEquals( "Test if double[][] constructor produces the same matrix as normal one", mlMLUInt82D, mluint8 );
}
 
开发者ID:gradusnikov,项目名称:jmatio,代码行数:55,代码来源:MatIOTest.java


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