Project
Loading...
Searching...
No Matches
ChebyshevFit1D.cxx
Go to the documentation of this file.
1
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3
// All rights not expressly granted are reserved.
4
//
5
// This software is distributed under the terms of the GNU General Public
6
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7
//
8
// In applying this license CERN does not waive the privileges and immunities
9
// granted to it by virtue of its status as an Intergovernmental Organization
10
// or submit itself to any jurisdiction.
11
16
17
#if !defined(GPUCA_GPUCODE) && !defined(GPUCA_STANDALONE)
// code invisible on GPU and in the standalone compilation
18
19
#include "
ChebyshevFit1D.h
"
20
#include "
GPUCommonLogger.h
"
21
#include <cmath>
22
23
using namespace
o2::gpu
;
24
25
void
ChebyshevFit1D::reset
(int32_t order,
double
xMin,
double
xMax)
26
{
27
if
(order < 0) {
28
order = 0;
29
}
30
mN = order + 1;
31
mXmin = xMin;
32
mXscale = (xMax - xMin > 1.e-8) ? 2. / (xMax - mXmin) : 2.;
33
34
mA.resize(mN * mN);
35
mB.resize(mN + 1);
36
mC.resize(mN + 1);
37
mT.resize(mN + 1);
38
reset
();
39
}
40
41
void
ChebyshevFit1D::reset
()
42
{
43
for
(int32_t
i
= 0;
i
<= mN;
i
++) {
44
mB[
i
] = 0.;
45
mC[
i
] = 0.;
46
mT[
i
] = 0.;
47
}
48
49
for
(int32_t
i
= 0;
i
< mN * mN;
i
++) {
50
mA[
i
] = 0.;
51
}
52
mM = 0;
53
}
54
55
void
ChebyshevFit1D::print
()
56
{
57
LOG
(info) <<
""
;
58
double
* Ai = mA.data();
59
for
(int32_t
i
= 0;
i
< mN;
i
++, Ai += mN) {
60
for
(int32_t
j
= 0;
j
< mN;
j
++) {
61
LOG
(info) << Ai[
j
] <<
" "
;
62
}
63
LOG
(info) <<
" | "
<< mB[
i
];
64
}
65
}
66
67
void
ChebyshevFit1D::fit
()
68
{
69
for
(int32_t
i
= 0;
i
< mN;
i
++) {
70
for
(int32_t
j
= 0;
j
<
i
;
j
++) {
71
mA[
i
* mN +
j
] = mA[
j
* mN +
i
];
72
}
73
}
74
//print();
75
{
76
double
* Ai = mA.data();
77
for
(int32_t
i
= 0;
i
< mN;
i
++, Ai += mN) {
78
double
a
= Ai[
i
];
79
if
(fabs(
a
) < 1.e-6) {
80
Ai[
i
] = 0;
81
continue
;
82
}
83
double
* Aj = Ai + mN;
84
for
(int32_t
j
=
i
+ 1;
j
< mN;
j
++, Aj += mN) {
85
double
c
= Aj[
i
] /
a
;
86
for
(int32_t k =
i
+ 1; k < mN; k++) {
87
Aj[k] -=
c
* Ai[k];
88
}
89
mB[
j
] -=
c
* mB[
i
];
90
}
91
//print();
92
}
93
}
94
{
95
double
* Ai = mA.data() + (mN - 1) * mN;
96
for
(int32_t
i
= mN - 1;
i
>= 0;
i
--, Ai -= mN) {
97
double
s = mB[
i
];
98
for
(int32_t k =
i
+ 1; k < mN; k++) {
99
s -= mC[k] * Ai[k];
100
}
101
mC[
i
] = (fabs(Ai[
i
]) > 1.e-6) ? (s / Ai[
i
]) : 0.;
102
}
103
}
104
/*
105
for (int32_t i = 0; i < mN; i++) {
106
LOG(info) << mC[i] << " ";
107
}
108
LOG(info) ;
109
*/
110
}
111
112
#endif
ChebyshevFit1D.h
Definition of ChebyshevFit1D class.
i
int32_t i
Definition
GPUCommonAlgorithm.h:443
GPUCommonLogger.h
j
uint32_t j
Definition
RawData.h:0
c
uint32_t c
Definition
RawData.h:2
o2::gpu::ChebyshevFit1D::reset
void reset()
Definition
ChebyshevFit1D.cxx:41
o2::gpu::ChebyshevFit1D::fit
void fit()
Definition
ChebyshevFit1D.cxx:67
o2::gpu::ChebyshevFit1D::print
void print()
Definition
ChebyshevFit1D.cxx:55
a
GLboolean GLboolean GLboolean GLboolean a
Definition
glcorearb.h:1233
o2::gpu
Definition
TrackTRD.h:35
o2::gpu::a
a
Definition
GPUCommonMath.h:326
LOG
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
GPU
TPCFastTransformation
ChebyshevFit1D.cxx
Generated on Tue Feb 25 2025 22:51:09 for Project by
1.9.8