swh:1:snp:af87cd67498ef4fe47c76ed3e7caffe5b61facaf
Raw File
Tip revision: b604d25f6fae57dca2b25814d36b078b31da26c4 authored by Unknown Author on 23 August 2002, 12:10:17 UTC
This commit was manufactured by cvs2svn to create tag 'v3-03-08'.
Tip revision: b604d25
Quad.cxx
#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;
}
back to top