本文整理汇总了C++中DoubleMatrix::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ DoubleMatrix::empty方法的具体用法?C++ DoubleMatrix::empty怎么用?C++ DoubleMatrix::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DoubleMatrix
的用法示例。
在下文中一共展示了DoubleMatrix::empty方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetMatrix
double
MatlabEngine::GetScalar( const string& inExp )
{
DoubleMatrix result = GetMatrix( inExp );
if( result.empty() || result[ 0 ].empty() )
{
bcierr << "Could not get scalar value \"" << inExp << "\"" << endl;
result.resize( 1, vector<double>( 1 ) );
}
return result[ 0 ][ 0 ];
}
示例2: mxCreateNumericMatrix
bool
MatlabEngine::PutMatrix( const string& inExp, const DoubleMatrix& inValue )
{
int sizeDim2 = inValue.empty() ? 0 : inValue[ 0 ].size();
mxArray* val = mxCreateNumericMatrix( inValue.size(), sizeDim2, mxDOUBLE_CLASS, mxREAL );
double* data = mxGetPr( val );
if( data )
{
int indices[] = { 0, 0 };
for( size_t i = 0; i < inValue.size(); ++i )
{
indices[ 0 ] = i;
for( size_t j = 0; j < inValue[ i ].size(); ++j )
{
indices[ 1 ] = j;
data[ mxCalcSingleSubscript( val, 2, indices ) ] = inValue[ i ][ j ];
}
}
}
bool success = PutMxArray( inExp, val );
mxDestroyArray( val );
return success;
}
示例3: PutMxArray
bool
MatlabEngine::PutMatrix( const string& inExp, const DoubleMatrix& inValue )
{
mwSize sizeDim2 = static_cast<mwSize>( inValue.empty() ? 0 : inValue[ 0 ].size() );
mxArray* val = mxCreateNumericMatrix_( static_cast<mwSize>( inValue.size() ), sizeDim2, mxDOUBLE_CLASS, mxREAL );
double* data = mxGetPr_( val );
if( data )
{
mwIndex indices[] = { 0, 0 };
for( mwIndex i = 0; i < static_cast<mwIndex>( inValue.size() ); ++i )
{
indices[ 0 ] = i;
for( mwIndex j = 0; j < static_cast<mwIndex>( inValue[ i ].size() ); ++j )
{
indices[ 1 ] = j;
data[ mxCalcSingleSubscript_( val, 2, indices ) ] = inValue[ i ][ j ];
}
}
}
bool success = PutMxArray( inExp, val );
mxDestroyArray_( val );
return success;
}