Sophie

Sophie

distrib > Fedora > 18 > x86_64 > by-pkgid > 8c86774a3e53d77cc119f53a2b94a57a > files > 1166

root-tutorial-5.34.14-2.fc18.noarch.rpm

#include <math.h>
#include "Riostream.h"
#include "Quad.h"

Quad::Quad(Float_t a,Float_t b,Float_t c)
{
   fA = a;
   fB = b;
   fC = c;
}

Quad::~Quad()
{
   cout << "deleting object with coeffts: "
        << fA << "," << fB << "," << fC << endl;
}

void Quad::Solve() const
{
   Float_t temp = fB*fB -4*fA*fC;
   if (temp > 0) {
      temp = sqrt(temp);
      cout << "There are two roots: "
           << ( -fB - temp ) / (2.*fA)
           << " and "
           << ( -fB + temp ) / (2.*fA)
           << endl;
   } else {
      if (temp == 0) {
         cout << "There are two equal roots: "
         << -fB / (2.*fA) << endl;
      } else {
         cout << "There are no roots" << endl;
      }
   }
}

Float_t Quad::Evaluate(Float_t x) const
{
  return fA*x*x + fB*x + fC;
  return 0;
}