Garfield++ v1r0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
cubic.h
Go to the documentation of this file.
1#ifndef CUBIC_H
2#define CUBIC_H
3
4#include <complex>
5
6/*
7Copyright (c) 2005 Igor B. Smirnov
8
9The file can be used, copied, modified, and distributed
10according to the terms of GNU Lesser General Public License version 2.1
11as published by the Free Software Foundation,
12and provided that the above copyright notice, this permission notice,
13and notices about any modifications of the original text
14appear in all copies and in supporting documentation.
15The file is provided "as is" without express or implied warranty.
16*/
17
18class Cubic {
19 public:
20 typedef std::complex<double> double_complex;
21 inline double a(void) const { return da; }
22 inline double b(void) const { return db; }
23 inline double c(void) const { return dc; }
24 inline double d(void) const { return dd; }
25 inline double s_xzero(void) const {
26 return s_dxzero;
27 } // for debug
28 inline void put_a(double fa) {
29 da = fa;
30 s_dxzero = 0;
31 }
32 inline void put_b(double fb) {
33 db = fb;
34 s_dxzero = 0;
35 }
36 inline void put_c(double fc) {
37 dc = fc;
38 s_dxzero = 0;
39 }
40 inline void put_d(double fd) {
41 dd = fd;
42 s_dxzero = 0;
43 }
44
45 Cubic(void) : da(0.0), db(0.0), dc(0.0), dd(0.0), s_dxzero(0) {}
46 Cubic(double fa, double fb, double fc, double fd)
47 : da(fa), db(fb), dc(fc), dd(fd), s_dxzero(0) {}
48
49 inline double y(double x) const {
50 return da * x * x * x + db * x * x + dc * x + dd;
51 }
52
54 double_complex& z3) const;
55 // They are not ordered and analysed
56 int find_real_zero(double z[3]) const;
57 // returns number of solutions
58 // Analysed and ordered real solutions
59
60 // returns number of solutions
61 // first is the least.
62 int find_maxmin(double xmm[2], double ymm[2],
63 int s_mm[2]) const; // 1 - maximum, -1 - minimum, 0 - non
64 private:
65 static const double_complex iu;
66 double da, db, dc, dd;
67 mutable int s_dxzero;
68 mutable double_complex dz1;
69 mutable double_complex dz2;
70 mutable double_complex dz3;
71};
72
73std::ostream& operator<<(std::ostream& file, const Cubic& f);
74
75#endif
Definition: cubic.h:18
double s_xzero(void) const
Definition: cubic.h:25
double b(void) const
Definition: cubic.h:22
int find_maxmin(double xmm[2], double ymm[2], int s_mm[2]) const
Definition: cubic.cpp:122
void put_b(double fb)
Definition: cubic.h:32
void put_d(double fd)
Definition: cubic.h:40
void put_a(double fa)
Definition: cubic.h:28
int find_real_zero(double z[3]) const
Definition: cubic.cpp:76
double c(void) const
Definition: cubic.h:23
Cubic(void)
Definition: cubic.h:45
double d(void) const
Definition: cubic.h:24
Cubic(double fa, double fb, double fc, double fd)
Definition: cubic.h:46
double y(double x) const
Definition: cubic.h:49
void put_c(double fc)
Definition: cubic.h:36
double a(void) const
Definition: cubic.h:21
void find_zero(double_complex &z1, double_complex &z2, double_complex &z3) const
Definition: cubic.cpp:25
std::complex< double > double_complex
Definition: cubic.h:20
std::ostream & operator<<(std::ostream &file, const Cubic &f)
Definition: cubic.cpp:150