當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。