本文整理汇总了Java中com.jmatio.types.MLNumericArray类的典型用法代码示例。如果您正苦于以下问题:Java MLNumericArray类的具体用法?Java MLNumericArray怎么用?Java MLNumericArray使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MLNumericArray类属于com.jmatio.types包,在下文中一共展示了MLNumericArray类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testBenchmarkUInt8
import com.jmatio.types.MLNumericArray; //导入依赖的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);
}
示例2: getContent
import com.jmatio.types.MLNumericArray; //导入依赖的package包/类
/**
* Returns the content of the field/cell/object.
*
* @param array
* the parent structure/cell
* @param m
* column or -1
* @param n
* row or -1
* @return if both m and n are -1, returns {@link MLArray}, if n is -1, returns
* content under index m, if both m and n are not-negative, returns
* content of (m,n)
*/
public Object getContent( MLArray array, int m, int n )
{
int type = array.getType();
Object result = null;
switch ( type )
{
case MLArray.mxINT8_CLASS:
case MLArray.mxINT16_CLASS:
case MLArray.mxINT32_CLASS:
case MLArray.mxINT64_CLASS:
case MLArray.mxUINT8_CLASS:
case MLArray.mxUINT16_CLASS:
case MLArray.mxUINT32_CLASS:
case MLArray.mxUINT64_CLASS:
case MLArray.mxSINGLE_CLASS:
case MLArray.mxDOUBLE_CLASS:
MLNumericArray<?> numeric = (MLNumericArray<?>) array;
if ( m > -1 && n > -1 )
{
result = numeric.get( m, n );
}
else if ( m > -1 )
{
result = numeric.get( m );
}
else
{
result = array;
}
break;
case MLArray.mxCHAR_CLASS:
MLChar mlchar = (MLChar) array;
if ( m > -1 && n > -1 )
{
result = mlchar.getChar( m, n );
}
else if ( m > -1 )
{
result = mlchar.getString( m );
}
else
{
result = mlchar;
}
break;
case MLArray.mxCELL_CLASS:
MLCell mlcell = (MLCell) array;
if ( m > -1 && n > -1 )
{
result = getContent( mlcell.get( m, n ), 0, -1);
}
else if ( m > -1 )
{
result = getContent( mlcell.get( m ), 0, -1 );
}
else
{
result = getContent( mlcell.get( 0 ), -1, -1 );
}
break;
default:
result = array;
}
return result;
}