Garfield++ v1r0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
parabol.h
Go to the documentation of this file.
1#ifndef PARABOL_H
2#define PARABOL_H
3/*
4Manipulating with parabola and solution of square equation.
5The main class is colled with a cut of the last character: Parabol
6to assure absence of coincidences with any other libraries and user files.
7THis was inpired by a significant problem with link. The programs
8contating this class oftenly don't want to be linked due to missing of
9references to functions from this class, if the file compiled from
10parabol.c is just included in library. The class parabol does not
11contain anything special, but this often happens. Why - unknown.
12The mentioned change of name did nto solve this problem.
13The only solution is the inclusion of the object file parabol.o in the list
14of command supplied to linker.
15In general, this is very simple class, see definition.
16
17
18Copyright (c) 2001 I. B. Smirnov
19
20Permission to use, copy, modify, distribute and sell this file
21and its documentation for any purpose is hereby granted without fee,
22provided that the above copyright notice, this permission notice,
23and notices about any modifications of the original text
24appear in all copies and in supporting documentation.
25It is provided "as is" without express or implied warranty.
26*/
27
31
32class Parabol // a is omited to avoid coincidences with any other libraries
33 {
34 public:
35 inline double a(void) const { return da; }
36 inline double b(void) const { return db; }
37 inline double c(void) const { return dc; }
38 inline void put_a(double fa) {
39 da = fa;
40 s_det = 0;
41 s_dxzero = 0;
42 }
43 inline void put_b(double fb) {
44 db = fb;
45 s_det = 0;
46 s_dxzero = 0;
47 }
48 inline void put_c(double fc) {
49 dc = fc;
50 s_det = 0;
51 s_dxzero = 0;
52 }
53
54 Parabol(void) : da(0.0), db(0.0), dc(0.0), s_det(0), s_dxzero(0) {}
55 Parabol(const Parabol& f);
56 Parabol(double fa, double fb, double fc)
57 : da(fa), db(fb), dc(fc), s_det(0), s_dxzero(0) {}
58 Parabol(double x[3], double y[3]); // creates parabola by 3 points
59 Parabol(double x[3], double y[3], int);
60 // creates parabola by 3 points, in one of each ,
61 // in the third one, the derivative of the function is supplied instead of
62 // the function. int is any, to differ from previous constructor
63 Parabol(double x1, double x2, double x3, double y1, double y2,
64 double y3); // creates parabola by 3 points
65
66 inline double y(double x) { return da * x * x + db * x + dc; }
67
68 int find_zero(double xzero[2]) const; // returns number of solutions
69 // first is the least.
70 double find_maxmin(void);
71
72 inline double determinant(void) const {
74 if (s_det == 0) {
75 t.s_det = 1;
76 t.det = db * db - 4 * da * dc;
77 }
78 return det;
79 }
80
81 private:
82 double da, db, dc;
83 mutable int s_det;
84 mutable double det;
85 mutable int s_dxzero;
86 mutable int qdxzero;
87 mutable double dxzero[2];
88};
89
90std::ostream& operator<<(std::ostream& file, const Parabol& f);
91
92#endif
double b(void) const
Definition: parabol.h:36
Parabol(double fa, double fb, double fc)
Definition: parabol.h:56
void put_c(double fc)
Definition: parabol.h:48
double a(void) const
Definition: parabol.h:35
void put_b(double fb)
Definition: parabol.h:43
double y(double x)
Definition: parabol.h:66
Parabol(void)
Definition: parabol.h:54
void put_a(double fa)
Definition: parabol.h:38
double determinant(void) const
Definition: parabol.h:72
int find_zero(double xzero[2]) const
Definition: parabol.cpp:234
double find_maxmin(void)
Definition: parabol.cpp:279
double c(void) const
Definition: parabol.h:37
#define convmut(type)
std::ostream & operator<<(std::ostream &file, const Parabol &f)
Definition: parabol.cpp:285