本文整理汇总了C++中Matrix::GetRealPart方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix::GetRealPart方法的具体用法?C++ Matrix::GetRealPart怎么用?C++ Matrix::GetRealPart使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix
的用法示例。
在下文中一共展示了Matrix::GetRealPart方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: image
void RealPartImage
( const Matrix<T>& A, string basename="matrix", FileFormat format=PNG )
{
DEBUG_CSE
#ifdef EL_HAVE_QT5
typedef Base<T> Real;
const Int m = A.Height();
const Int n = A.Width();
// Compute the maximum and minimum values
double minVal=0, maxVal=0;
if( m != 0 && n != 0 )
{
minVal = maxVal = double(A.GetRealPart( 0, 0 ));
for( Int j=0; j<n; ++j )
{
for( Int i=0; i<m; ++i )
{
minVal = Min( minVal, double(A.GetRealPart(i,j)) );
maxVal = Max( maxVal, double(A.GetRealPart(i,j)) );
}
}
}
// TODO: Parameterize these instead
const Int mPix = 2*m;
const Int nPix = 2*n;
const double mRatio = double(m) / double(mPix);
const double nRatio = double(n) / double(nPix);
QImage image( nPix, mPix, QImage::Format_RGB32 );
for( Int jPix=0; jPix<nPix; ++jPix )
{
const Int j = nRatio*jPix;
for( Int iPix=0; iPix<mPix; ++iPix )
{
const Int i = mRatio*iPix;
QRgb color =
SampleColorMap( double(A.GetRealPart(i,j)), minVal, maxVal );
image.setPixel( jPix, iPix, color );
}
}
SaveQImage( image, basename, format );
#else
LogicError("Qt5 not available");
#endif // ifdef EL_HAVE_QT5
}
示例2: MatrixMarket
void MatrixMarket( const Matrix<T>& A, string basename="matrix" )
{
EL_DEBUG_CSE
string filename = basename + "." + FileExtension(MATRIX_MARKET);
ofstream file( filename.c_str(), std::ios::binary );
if( !file.is_open() )
RuntimeError("Could not open ",filename);
// Write the header
// ================
{
ostringstream os;
os << "%%MatrixMarket matrix array ";
if( IsComplex<T>::value )
os << "complex ";
else
os << "real ";
os << "general\n";
file << os.str();
}
// Write the size line
// ===================
const Int m = A.Height();
const Int n = A.Width();
file << BuildString(m," ",n,"\n");
// Write the entries
// =================
for( Int j=0; j<n; ++j )
{
for( Int i=0; i<m; ++i )
{
ostringstream os;
os << A.GetRealPart(i,j);
if( IsComplex<T>::value )
os << " " << A.GetImagPart(i,j);
os << "\n";
file << os.str();
}
}
}