本文整理汇总了C++中QTextStream::setRealNumberNotation方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextStream::setRealNumberNotation方法的具体用法?C++ QTextStream::setRealNumberNotation怎么用?C++ QTextStream::setRealNumberNotation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextStream
的用法示例。
在下文中一共展示了QTextStream::setRealNumberNotation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: file
void Vector<scalar, CPU>::save(std::string fname)
{
QFile file(fname.c_str());
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
{
qDebug() << "Vector (CPU): Problem with opening [" << fname.c_str() <<"] to save vector data";
return;
}
QTextStream out (&file);
out.setRealNumberNotation(QTextStream::ScientificNotation);
for (int i = 0; i < size; i++)
out << data[i] << "\n";
file.close();
}
示例2: fstr
void RadMainWindow :: stc1FFTTest (void)
{
QString fName = QFileDialog::getOpenFileName (this, tr("Open File"), QDir::currentPath(), tr("All files (*.*)"));
if (fName.isEmpty())
return;
QVector<double> v001;
QFile f001 (fName);
f001.open (QIODevice::ReadOnly);
QString rfftStr;
QTextStream fstr (&f001);
rfftStr = fstr.readLine();// >> rfftStr;
//qDebug () << __PRETTY_FUNCTION__ << rfftStr;
QStringList fftStrList = rfftStr.split(QString("\t"));
//fstr >> v001;
int n = fftStrList.size();
qDebug () << __PRETTY_FUNCTION__ << n;
QFile fftc ("stc1c.dat");
fftc.open (QIODevice::WriteOnly);
QTextStream fftcStr (&fftc);
for (int i=0; i<n; i++)
{
bool ok;
Q_UNUSED (ok);
//QStringList fftstr = fftStrList[i].split(QString(" "));
QByteArray fftBuf (fftStrList[i].mid(0, fftStrList[i].count()-1).toUtf8());
if (i<=10)
qDebug () << __PRETTY_FUNCTION__ << fftBuf;
QTextStream strBuf (fftBuf);
double x, y;// = fftstr[0].toDouble (&ok);
QString sp;
strBuf >> x >> sp >> y ;
/// strBuf >> y;
if (sp.contains("-"))
y *= -1.0;
if (i<=10)
qDebug () << __PRETTY_FUNCTION__ << x << sp << y;
fftcStr << x << " " << y << endl;
v001.append (x);
v001.append (y);
}
// for (int i=0; i<v001.size(); i++)
// qDebug () << __PRETTY_FUNCTION__ << v001[i];
int n2 = FFT_Transform::pow2roundup(v001.size()/2);//1024;
complex<double> * x = new complex<double>[n2];
//double * x = new double [n2];
for (int i=0; i<n2; i++)
x[i] = complex<double>(0.0, 0.0);
for (int i=0; i<n; i++)
{
x[i] = complex<double>(v001[2*i], v001[2*i+1]);
fftcStr << real (x[i]) << " " << imag (x[i]) << endl;
}
FFT_Transform fft;// = new FFT_Transform;
complex<double> * xfft = new complex<double> [n2];
xfft = fft (x, n2, n2, FFTW_BACKWARD, FFTW_ESTIMATE );//| FFTW_MEASURE);
QString fSaveName = QFileDialog::getSaveFileName (this, tr("Save File"), QDir::currentPath(), tr("All files (*.*)"));
if (fSaveName.isEmpty())
{
delete [] xfft;
delete [] x;
return;
}
QFile fSave(fSaveName);
fSave.open (QIODevice::WriteOnly);
QTextStream fftRes (&fSave);
complex<double> * xfftrev = new complex<double> [n2];
xfftrev = fft (xfft, n2, n2, FFTW_FORWARD, FFTW_ESTIMATE );//| FFTW_MEASURE);
fftRes.setRealNumberNotation (QTextStream::FixedNotation);
for (int i=0; i<n2; i++)
{
double r = real (xfft[i])/n2;
double im = imag (xfft[i])/n2;
fftRes << qSetFieldWidth(10) << qSetRealNumberPrecision(16) << real (x[i]) << " "
<< qSetFieldWidth(10) << qSetRealNumberPrecision(16) << imag (x[i]) << "i ";
scientific (fftRes);
fftRes
<< qSetFieldWidth(10) << qSetRealNumberPrecision(16) << r << " "
<< qSetFieldWidth(10) << qSetRealNumberPrecision(16) << im << "i ";
fixed (fftRes);
fftRes
<< qSetFieldWidth(10) << qSetRealNumberPrecision(16) << real (xfftrev[i]) << " "
<< qSetFieldWidth(10) << qSetRealNumberPrecision(16) << imag (xfftrev[i]) << "i"
<< endl;
}
delete [] xfft;
delete [] x;
}