Esempio n. 1
0
void ParityTest::runTest() {

    int sampling = getSampling();
    int evenCount = 0;
    int oddCount = 0;
    int array[sampling];
    ostringstream ss;

    for(int i = 0 ; i < getSampling() ; i++) {
        array[i] = getGenerator()->toGenerate();
        if ((array[i] % 2) == 0)
            evenCount++;
        else
            oddCount++;
    }

    ss << "Generator " << getGenerator()->getGeneratorName() << " gave me numbers:\n";
    for (int i = 0 ; i < sampling ; i++ ) {
        ss << array[i] << "   ";
        if ((i+1) % 5 == 0)
            ss << endl;
    }
    ss << "Numbers have:\n";
    ss << evenCount << " even numbers\n";
    ss << "and\n";
    ss << oddCount <<" odd numbers\n";
    ss << "Proportion even/odd is: \n";
    ss << (double) oddCount / (double) evenCount << endl;

    addInResultText(ss.str());

}
Esempio n. 2
0
EdgeSample EdgeCell::endSample(Time time) const
{
    QList<EdgeSample> sampling = getSampling(time);
    if(sampling.isEmpty())
        return EdgeSample();
    else
        return sampling.last();
}
Esempio n. 3
0
void SeriesTest::runTest() {

  int sampling = getSampling();
  int array[sampling];
  int increaseCount = 0;
  int decreaseCount = 0;
  int maxIncreaseSerie = 0;
  int maxDecreaseSerie = 0;
  int nonStopIncreaseCount = 0;
  int nonStopDecreaseCount = 0;

  ostringstream ss;
  array[0] = getGenerator()->toGenerate();
  for(int i = 0 ; i < getSampling() - 1 ; i++){
    array[i+1] = getGenerator()->toGenerate();
    if (array[i] < array[i+1]){
      nonStopDecreaseCount = 0;
      increaseCount++;
      nonStopIncreaseCount++;
    }
    else {
      nonStopIncreaseCount = 0;
      decreaseCount++;
      nonStopDecreaseCount++;
    }
    if (nonStopIncreaseCount > maxIncreaseSerie)
      maxIncreaseSerie = nonStopIncreaseCount;
    if (nonStopDecreaseCount > maxDecreaseSerie)
      maxDecreaseSerie = nonStopDecreaseCount;
  }

  ss << "Generator " << getGenerator()->getGeneratorName() << " gave me numbers:\n";
  for (int i = 0 ; i < sampling ; i++ ){
    ss << array[i] << "   ";
    if ((i+1) % 5 == 0)
      ss << endl;
  }
  ss << "All increase cases: " << increaseCount << endl;
  ss << "All decrease cases: " << decreaseCount << endl;
  ss << "Max series:\n";
  ss << "inc: " << maxIncreaseSerie << endl;
  ss << "dec: " << maxDecreaseSerie << endl;
  addInResultText(ss.str());

}
Esempio n. 4
0
void EdgeCell::exportSVG(Time t, QTextStream & out)
{
    QList<EdgeSample> samples = getSampling(t);
    LinearSpline ls(samples);
    if(isClosed())
        ls.makeLoop();

    out << "<path d=\"";
    ls.exportSVG(out);
    out << "\" style=\""
        << "fill:rgb("
        << (int) (color_[0]*255) << ","
        << (int) (color_[1]*255) << ","
        << (int) (color_[2]*255) << ");"
        << "fill-opacity:" << color_[3] << ";"
        << "fill-rule:nonzero;stroke:none\" />\n";
}