LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
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 10 of file QuadExpr.h.

References X().

Referenced by operator*(), operator+(), operator-(), and operator-().

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

Member Function Documentation

double QuadExpr::Constant ( ) const
inline

Definition at line 16 of file QuadExpr.h.

References c, e, Eval(), operator*(), operator*=(), operator+(), operator+=(), operator-(), operator-=(), and x.

Referenced by operator<<().

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

Definition at line 67 of file QuadExpr.cxx.

References a, b, and c.

Referenced by Constant(), Iterate(), and SolvePair().

68 {
69  return a * x * x + b * x + c;
70 }
Float_t x
Definition: compare.C:6
double a
Definition: QuadExpr.h:33
double c
Definition: QuadExpr.h:33
double b
Definition: QuadExpr.h:33
double QuadExpr::Linear ( ) const
inline

Definition at line 15 of file QuadExpr.h.

References b.

Referenced by Iterate(), operator<<(), and SolvePair().

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

Definition at line 45 of file QuadExpr.cxx.

References a, b, and c.

Referenced by Constant().

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

Definition at line 30 of file QuadExpr.h.

References QuadExpr().

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

Definition at line 61 of file QuadExpr.cxx.

References e.

Referenced by Constant().

62 {
63  *this = *this * e;
64  return *this;
65 }
Float_t e
Definition: plot.C:35
QuadExpr QuadExpr::operator+ ( const QuadExpr e) const

Definition at line 23 of file QuadExpr.cxx.

References e.

Referenced by Constant().

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

Definition at line 28 of file QuadExpr.h.

References QuadExpr().

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

Definition at line 15 of file QuadExpr.cxx.

References a, b, and c.

Referenced by Constant().

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

Definition at line 38 of file QuadExpr.cxx.

References e.

Referenced by Constant().

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

Definition at line 29 of file QuadExpr.h.

References QuadExpr().

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

Definition at line 30 of file QuadExpr.cxx.

References a, b, and c.

Referenced by Constant().

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

Definition at line 14 of file QuadExpr.h.

References a.

Referenced by Iterate(), operator<<(), and SolvePair().

14 { return a; }
double a
Definition: QuadExpr.h:33
QuadExpr QuadExpr::X ( )
static

Definition at line 8 of file QuadExpr.cxx.

References b.

Referenced by Metric(), and QuadExpr().

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

Member Data Documentation

double QuadExpr::a
protected

Definition at line 33 of file QuadExpr.h.

Referenced by Eval(), operator*(), operator+=(), operator-=(), and Quadratic().

double QuadExpr::b
protected

Definition at line 33 of file QuadExpr.h.

Referenced by Eval(), Linear(), operator*(), operator+=(), operator-=(), and X().

double QuadExpr::c
protected

Definition at line 33 of file QuadExpr.h.

Referenced by Constant(), Eval(), operator*(), operator+=(), and operator-=().


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