All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines
Classes | Public Member Functions
QGpCoreWave::ModalStorage Class Reference

Storage for modal computation. More...

#include <ModalStorage.h>

Inheritance diagram for QGpCoreWave::ModalStorage:
QGpCoreWave::Dispersion QGpCoreWave::Ellipticity

List of all members.

Classes

class  Iterator

Public Member Functions

void abs ()
Curve< Point2Dcurve (int iMode) const
void exp10 ()
ModalRefinelastRefine ()
void log10 ()
 ModalStorage ()
 ModalStorage (int nModes, const QVector< double > *x)
RealValuemode (int index)
const RealValuemode (int index) const
int modeCount () const
ModalStorageoperator= (const ModalStorage &o)
ModalRefinerefineAdd (double x)
RefineIterator refineBegin () const
void refineClear ()
int refineCount () const
RefineIterator refineEnd () const
void refineSort ()
void set (int nModes, const QVector< double > *x)
void toStream (QTextStream &s, int modeIndex=-1) const
void writeReport (QDataStream &s) const
const QVector< double > * x () const
double x (int ix) const
int xCount () const
 ~ModalStorage ()

Detailed Description

Storage for modal computation.

Storage for modal computation such as dispersion curve, ellipticity or spac


Constructor & Destructor Documentation

Init a empty storage. Use set() before using this object.

References TRACE.

Referenced by QGpCoreWave::Dispersion::deltaK().

{
  TRACE;
  _nModes=0;
  _nX=0;
  _values=0;
  _x=0;
}
QGpCoreWave::ModalStorage::ModalStorage ( int  nModes,
const QVector< double > *  x 
) [inline]

Init storage with nModes and with the list of x o (not owned by this object)

{set(nModes, x);}

Delete stored values but not the list of x provided in constructor's arguments

{delete [] _values;}

Member Function Documentation

Transforms all values into their absolute value

References QGpCoreTools::RealValue::abs().

Referenced by QGpCoreWave::DispersionFactory::calculate(), EllipticityReader::parse(), and QGpCoreWave::EllipticityFactory::peakMisfit().

{
  int nValues=_nModes * _nX;
  for(int i=0; i<nValues;i++) {
    _values[i].abs();
  }
  for(RefineList::iterator it=_refines.begin(); it!=_refines.end(); it++) {
    for(int i=0; i<_nModes; i++) {
      it->setValue(i, fabs(it->value(i).value()));
    }
  }
}

Return a curve for mode iMode, mixing refines and original samples, removing invalid values

References QGpCoreTools::Curve< pointType >::append(), QGpCoreWave::ModalStorage::Iterator::atEnd(), QGpCoreTools::Value< numberType >::isValid(), and QGpCoreTools::Value< numberType >::value().

{
  double xFactor=0.5/M_PI;
  Curve<Point2D> points;
  for(Iterator it(this, iMode); !it.atEnd(); ++it) {
    const RealValue & val=it.value();
    if(val.isValid())
      points.append(Point2D( it.x() * xFactor, val.value()) );
  }
  return points;
}

Transforms all values into their exp10

References QGpCoreTools::RealValue::exp10().

{
  int nValues=_nModes * _nX;
  for(int i=0; i<nValues;i++) {
    _values[i].exp10();
  }
  for(RefineList::iterator it=_refines.begin(); it!=_refines.end(); it++) {
    for(int i=0; i<_nModes; i++) {
      it->setValue(i, ::pow(10.0, it->value(i).value()));
    }
  }
}
{return _refines.last();}

Transforms all values into their log10.

References QGpCoreTools::RealValue::log10().

{
  int nValues=_nModes * _nX;
  for(int i=0; i<nValues;i++) {
    _values[i].log10();
  }
  for(RefineList::iterator it=_refines.begin(); it!=_refines.end(); it++) {
    for(int i=0; i<_nModes; i++) {
      it->setValue(i, ::log10(it->value(i).value()));
    }
  }
}
RealValue* QGpCoreWave::ModalStorage::mode ( int  index) [inline]
const RealValue* QGpCoreWave::ModalStorage::mode ( int  index) const [inline]
{return _values+index*_nX;}
int QGpCoreWave::ModalStorage::modeCount ( ) const [inline]
ModalStorage & QGpCoreWave::ModalStorage::operator= ( const ModalStorage o)

Copy operator, only list of x remains shared.

References TRACE.

{
  TRACE;
  _nModes=o._nModes;
  _nX=o._nX;
  _x=o._x;
  int nValues=_nModes*_nX;
  delete [] _values;
  _values=new RealValue[nValues];
  memcpy (_values, o._values, nValues*sizeof(RealValue));
  return *this;
}

References QGpCoreWave::ModalRefine::setValid().

Referenced by QGpCoreWave::Dispersion::refine().

                                   {
    _refines.append(ModalRefine(_nModes, x));
    _refines.last().setValid(false);
    return _refines.last();
  }

Referenced by QGpCoreWave::ModalStorage::Iterator::Iterator().

{return _refines.begin();}
{_refines.clear();}
{return _refines.count();}

Referenced by QGpCoreWave::ModalStorage::Iterator::Iterator().

{return _refines.end();}

Referenced by QGpCoreWave::Ellipticity::peakMisfit().

{qSort(_refines);}
void QGpCoreWave::ModalStorage::set ( int  nModes,
const QVector< double > *  x 
)

Init storage with nModes and with the list of x o (not owned by this object)

References TRACE, and x().

{
  TRACE;
  _nModes=nModes;
  _nX=x->count();
  _values=new RealValue [ _nModes * _nX ];
  _x=x;
}
void QGpCoreWave::ModalStorage::toStream ( QTextStream &  s,
int  modeIndex = -1 
) const

Output to stream s, mixing refines and original samples, removing invalid values. If modeIndex is negative, all modes are ouput.

References QGpCoreWave::ModalStorage::Iterator::atEnd(), QGpCoreTools::Value< numberType >::isValid(), TRACE, and QGpCoreTools::Value< numberType >::value().

Referenced by EllipticityReader::parse(), DispersionReader::parse(), and SpacReader::parse().

{
  TRACE;
  static const QString fmt("%1 %2\n");
  double xFactor=0.5/M_PI;
  for (int im=0; im<_nModes; im++) {
    if(modeIndex<0 || im==modeIndex) {
      s << "# Mode " << im << "\n";
      for (Iterator it(this, im); !it.atEnd(); ++it) {
        const RealValue& val=it.value();
        if (val.isValid())
          s << fmt.arg(it.x()*xFactor, 0, 'g', 15).arg(val.value(), 0, 'g', 15);
      }
    }
  }
}
void QGpCoreWave::ModalStorage::writeReport ( QDataStream &  s) const

Save all to report (including frequency), mixing refines and original samples, removing invalid values

Begin with a table of the number of samples per mode

4 nm Modes For each mode: 4 number of samples for this mode mode, nx[im] nx[im]*2*8 values x,y

References QGpCoreWave::ModalStorage::Iterator::atEnd(), QGpCoreTools::Value< numberType >::isValid(), TRACE, and QGpCoreTools::Value< numberType >::value().

{
  TRACE;
  double xFactor=0.5/M_PI;
  s << _nModes;
  for(int im=0; im < _nModes;im++ ) {
    // room for sample per mode table
    int xCountReal=0;
    qint64 nSamplesPos=s.device() ->pos();
    s << xCountReal;
    for(Iterator it(this, im); !it.atEnd(); ++it) {
      const RealValue & val=it.value();
      if(val.isValid()) {
        s << it.x() * xFactor << val.value();
        xCountReal++;
      }
    }
    // Write the real number of x at the beginning
    qint64 curPos=s.device() ->pos();
    s.device() ->seek(nSamplesPos);
    s << xCountReal;
    s.device() ->seek(curPos);
  }
}
const QVector<double>* QGpCoreWave::ModalStorage::x ( ) const [inline]
double QGpCoreWave::ModalStorage::x ( int  ix) const [inline]
{return _x->at(ix);}
int QGpCoreWave::ModalStorage::xCount ( ) const [inline]

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines