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
23using namespace o2::gpu;
24
25void 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
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
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
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
Definition of ChebyshevFit1D class.
int32_t i
uint32_t j
Definition RawData.h:0
uint32_t c
Definition RawData.h:2
GLboolean GLboolean GLboolean GLboolean a
Definition glcorearb.h:1233
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"