forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSpline2D.h
More file actions
113 lines (99 loc) · 3.64 KB
/
Spline2D.h
File metadata and controls
113 lines (99 loc) · 3.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
/// \file Spline2D.h
/// \brief Definition of Spline2D class
///
/// \author Sergey Gorbunov <sergey.gorbunov@cern.ch>
#ifndef ALICEO2_GPUCOMMON_TPCFASTTRANSFORMATION_SPLINE2D_H
#define ALICEO2_GPUCOMMON_TPCFASTTRANSFORMATION_SPLINE2D_H
#include "Spline1D.h"
#include "Spline2DSpec.h"
#include "FlatObject.h"
#include "GPUCommonDef.h"
#if !defined(__CLING__) && !defined(G__ROOT) && !defined(GPUCA_GPUCODE) && !defined(GPUCA_NO_VC)
#include <Vc/Vc>
#include <Vc/SimdArray>
#endif
class TFile;
namespace o2
{
namespace gpu
{
///
/// The Spline2D class performs a cubic spline interpolation on an two-dimensional nonunifom grid.
/// The class is an extension of the Spline1D class.
/// See Spline1D.h for more details.
///
/// The spline S(x1,x2) approximates a function F(x1,x2):R^2->R^m,
/// with 2-dimensional domain and multi-dimensional codomain.
/// x1,x2 belong to [x1min,x1max] x [x2min,x2max].
///
/// --- Example of creating a spline ---
///
/// auto F = [&](double x1, double x2, double f[] ) {
/// f[0] = 1.f + x1 + x2*x2; // F(x1,x2)
/// };
/// const int32_t nKnotsU=2;
/// const int32_t nKnotsV=3;
/// int32_t knotsU[nKnotsU] = {0, 1};
/// int32_t knotsV[nKnotsV] = {0, 2, 5};
/// Spline2D<float,1> spline(nKnotsU, knotsU, nKnotsV, knotsV ); // spline with 1-dimensional codomain
/// spline.approximateFunction(0., 1., 0.,1., F); //initialize spline to approximate F on [0., 1.]x[0., 1.] area
/// float S = spline.interpolate(.1, .3 ); // interpolated value at (.1,.3)
///
/// --- See also Spline2DHelper::test();
///
/// ==================================================================================================
///
/// Declare the Spline1D class as a template with one optional parameters.
///
/// Class specializations depend on the XdimT, YdimT values. They can be found in SplineSpecs.h
///
/// \param DataT data type: float or double
/// \param YdimT
/// YdimT > 0 : the number of Y dimensions is known at the compile time and is equal to XdimT
/// YdimT = 0 : the number of Y dimensions will be set in the runtime
/// YdimT < 0 : the number of Y dimensions will be set in the runtime, and it will not exceed abs(YdimT)
///
template <typename DataT, int32_t YdimT = 0>
class Spline2D
: public Spline2DSpec<DataT, YdimT, SplineUtil::getSpec(YdimT)>
{
typedef Spline2DContainer<DataT> TVeryBase;
typedef Spline2DSpec<DataT, YdimT, SplineUtil::getSpec(YdimT)> TBase;
public:
typedef typename TVeryBase::SafetyLevel SafetyLevel;
typedef typename TVeryBase::Knot Knot;
#if !defined(GPUCA_GPUCODE)
using TBase::TBase; // inherit constructors
/// Assignment operator
Spline2D& operator=(const Spline2D& v)
{
TVeryBase::cloneFromObject(v, nullptr);
return *this;
}
#else
/// Disable constructors for the GPU implementation
Spline2D() = delete;
Spline2D(const Spline2D&) = delete;
#endif
#if !defined(GPUCA_GPUCODE) && !defined(GPUCA_STANDALONE)
/// read a class object from the file
static Spline2D* readFromFile(TFile& inpf, const char* name)
{
return (Spline2D*)TVeryBase::readFromFile(inpf, name);
}
#endif
ClassDefNV(Spline2D, 0);
};
} // namespace gpu
} // namespace o2
#endif