Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
larreco
larreco
SpacePointSolver
QuadExpr.cxx
Go to the documentation of this file.
1
#include "
QuadExpr.h
"
2
3
#include <cstdlib>
4
#include <iostream>
5
#include <ostream>
6
#include <string>
7
8
QuadExpr
QuadExpr::X
()
9
{
10
QuadExpr
ret(0);
11
ret.
b
= 1;
12
return
ret;
13
}
14
15
QuadExpr
&
QuadExpr::operator+=
(
const
QuadExpr
&
e
)
16
{
17
a
+= e.
a
;
18
b
+= e.
b
;
19
c
+= e.
c
;
20
return
*
this
;
21
}
22
23
QuadExpr
QuadExpr::operator+
(
const
QuadExpr
&
e
)
const
24
{
25
QuadExpr
ret = *
this
;
26
ret +=
e
;
27
return
ret;
28
}
29
30
QuadExpr
&
QuadExpr::operator-=
(
const
QuadExpr
&
e
)
31
{
32
a
-= e.
a
;
33
b
-= e.
b
;
34
c
-= e.
c
;
35
return
*
this
;
36
}
37
38
QuadExpr
QuadExpr::operator-
(
const
QuadExpr
&
e
)
const
39
{
40
QuadExpr
ret = *
this
;
41
ret -=
e
;
42
return
ret;
43
}
44
45
QuadExpr
QuadExpr::operator*
(
const
QuadExpr
&
e
)
const
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
}
62
63
QuadExpr
&
QuadExpr::operator*=
(
const
QuadExpr
&
e
)
64
{
65
*
this
= *
this
*
e
;
66
return
*
this
;
67
}
68
69
double
QuadExpr::Eval
(
double
x
)
const
70
{
71
return
a
*x*x +
b
*x +
c
;
72
}
73
74
std::ostream&
operator<<
(std::ostream& os,
const
QuadExpr
&
e
)
75
{
76
os << e.
Quadratic
() <<
"*x^2 + "
<< e.
Linear
() <<
"*x + "
<< e.
Constant
();
77
return
os;
78
}
QuadExpr::operator-=
QuadExpr & operator-=(const QuadExpr &e)
Definition:
QuadExpr.cxx:30
QuadExpr::operator*
QuadExpr operator*(const QuadExpr &e) const
Definition:
QuadExpr.cxx:45
QuadExpr::operator+=
QuadExpr & operator+=(const QuadExpr &e)
Definition:
QuadExpr.cxx:15
QuadExpr::Linear
double Linear() const
Definition:
QuadExpr.h:16
QuadExpr::a
double a
Definition:
QuadExpr.h:34
operator<<
std::ostream & operator<<(std::ostream &os, const QuadExpr &e)
Definition:
QuadExpr.cxx:74
QuadExpr.h
QuadExpr::c
double c
Definition:
QuadExpr.h:34
QuadExpr::operator-
QuadExpr operator-(const QuadExpr &e) const
Definition:
QuadExpr.cxx:38
QuadExpr::b
double b
Definition:
QuadExpr.h:34
e
const double e
Definition:
gUpMuFluxGen.cxx:165
QuadExpr::operator*=
QuadExpr & operator*=(const QuadExpr &e)
Definition:
QuadExpr.cxx:63
QuadExpr::X
static QuadExpr X()
Definition:
QuadExpr.cxx:8
QuadExpr::Constant
double Constant() const
Definition:
QuadExpr.h:17
QuadExpr::Eval
double Eval(double x) const
Definition:
QuadExpr.cxx:69
train.x
list x
Definition:
train.py:276
QuadExpr::operator+
QuadExpr operator+(const QuadExpr &e) const
Definition:
QuadExpr.cxx:23
QuadExpr
Definition:
QuadExpr.h:8
endl
QTextStream & endl(QTextStream &s)
Definition:
qtextstream.cpp:2030
QuadExpr::Quadratic
double Quadratic() const
Definition:
QuadExpr.h:15
Generated by
1.8.11