Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
QuadExpr Class Reference

#include <QuadExpr.h>

Public Member Functions

 QuadExpr (double v)
 
double Quadratic () const
 
double Linear () const
 
double Constant () const
 
double Eval (double x) const
 
QuadExproperator+= (const QuadExpr &e)
 
QuadExproperator-= (const QuadExpr &e)
 
QuadExproperator*= (const QuadExpr &e)
 
QuadExpr operator+ (const QuadExpr &e) const
 
QuadExpr operator- (const QuadExpr &e) const
 
QuadExpr operator* (const QuadExpr &e) const
 
QuadExpr operator+ (double v) const
 
QuadExpr operator- (double v) const
 
QuadExpr operator* (double v) const
 

Static Public Member Functions

static QuadExpr X ()
 

Protected Attributes

double a
 
double b
 
double c
 

Detailed Description

Definition at line 8 of file QuadExpr.h.

Constructor & Destructor Documentation

QuadExpr::QuadExpr ( double  v)
inline

Definition at line 11 of file QuadExpr.h.

11 : a(0), b(0), c(v) {}
double a
Definition: QuadExpr.h:34
double c
Definition: QuadExpr.h:34
double b
Definition: QuadExpr.h:34

Member Function Documentation

double QuadExpr::Constant ( ) const
inline

Definition at line 17 of file QuadExpr.h.

17 {return c;}
double c
Definition: QuadExpr.h:34
double QuadExpr::Eval ( double  x) const

Definition at line 69 of file QuadExpr.cxx.

70 {
71  return a*x*x + b*x + c;
72 }
double a
Definition: QuadExpr.h:34
double c
Definition: QuadExpr.h:34
double b
Definition: QuadExpr.h:34
list x
Definition: train.py:276
double QuadExpr::Linear ( ) const
inline

Definition at line 16 of file QuadExpr.h.

16 {return b;}
double b
Definition: QuadExpr.h:34
QuadExpr QuadExpr::operator* ( const QuadExpr e) const

Definition at line 45 of file QuadExpr.cxx.

46 {
47  if((b != 0 && e.a != 0) ||
48  (a != 0 && e.b != 0) ||
49  (a != 0 && e.a != 0)){
50  std::cout << "(" << *this << ") * (" << e << ")"
51  << " does not result in a quadratic expression." << std::endl;
52  abort();
53  }
54 
55  QuadExpr ret(0);
56  ret.c = c*e.c;
57  ret.b = c*e.b + b*e.c;
58  ret.a = c*e.a + a*e.c + b*e.b;
59 
60  return ret;
61 }
double a
Definition: QuadExpr.h:34
double c
Definition: QuadExpr.h:34
double b
Definition: QuadExpr.h:34
QTextStream & endl(QTextStream &s)
QuadExpr QuadExpr::operator* ( double  v) const
inline

Definition at line 31 of file QuadExpr.h.

31 {return (*this)*QuadExpr(v);}
QuadExpr(double v)
Definition: QuadExpr.h:11
QuadExpr & QuadExpr::operator*= ( const QuadExpr e)

Definition at line 63 of file QuadExpr.cxx.

64 {
65  *this = *this * e;
66  return *this;
67 }
const double e
QuadExpr QuadExpr::operator+ ( const QuadExpr e) const

Definition at line 23 of file QuadExpr.cxx.

24 {
25  QuadExpr ret = *this;
26  ret += e;
27  return ret;
28 }
const double e
QuadExpr QuadExpr::operator+ ( double  v) const
inline

Definition at line 29 of file QuadExpr.h.

29 {return (*this)+QuadExpr(v);}
QuadExpr(double v)
Definition: QuadExpr.h:11
QuadExpr & QuadExpr::operator+= ( const QuadExpr e)

Definition at line 15 of file QuadExpr.cxx.

16 {
17  a += e.a;
18  b += e.b;
19  c += e.c;
20  return *this;
21 }
double a
Definition: QuadExpr.h:34
double c
Definition: QuadExpr.h:34
double b
Definition: QuadExpr.h:34
QuadExpr QuadExpr::operator- ( const QuadExpr e) const

Definition at line 38 of file QuadExpr.cxx.

39 {
40  QuadExpr ret = *this;
41  ret -= e;
42  return ret;
43 }
const double e
QuadExpr QuadExpr::operator- ( double  v) const
inline

Definition at line 30 of file QuadExpr.h.

30 {return (*this)-QuadExpr(v);}
QuadExpr(double v)
Definition: QuadExpr.h:11
QuadExpr & QuadExpr::operator-= ( const QuadExpr e)

Definition at line 30 of file QuadExpr.cxx.

31 {
32  a -= e.a;
33  b -= e.b;
34  c -= e.c;
35  return *this;
36 }
double a
Definition: QuadExpr.h:34
double c
Definition: QuadExpr.h:34
double b
Definition: QuadExpr.h:34
double QuadExpr::Quadratic ( ) const
inline

Definition at line 15 of file QuadExpr.h.

15 {return a;}
double a
Definition: QuadExpr.h:34
QuadExpr QuadExpr::X ( )
static

Definition at line 8 of file QuadExpr.cxx.

9 {
10  QuadExpr ret(0);
11  ret.b = 1;
12  return ret;
13 }

Member Data Documentation

double QuadExpr::a
protected

Definition at line 34 of file QuadExpr.h.

double QuadExpr::b
protected

Definition at line 34 of file QuadExpr.h.

double QuadExpr::c
protected

Definition at line 34 of file QuadExpr.h.


The documentation for this class was generated from the following files: