From 9ac13354f559b4d7388948d423999b23dca99989 Mon Sep 17 00:00:00 2001 From: Matthias Kretz Date: Thu, 9 Mar 2017 12:43:52 +0100 Subject: [PATCH] Remove spline example The license is incompatible with free distribution Signed-off-by: Matthias Kretz --- examples/spline/CMakeLists.txt | 3 - examples/spline/main.cpp | 465 --------------------------------- examples/spline/spline.cpp | 260 ------------------ examples/spline/spline.h | 181 ------------- examples/spline/spline2.h | 250 ------------------ examples/spline/spline3.h | 206 --------------- 6 files changed, 1365 deletions(-) delete mode 100644 examples/spline/CMakeLists.txt delete mode 100644 examples/spline/main.cpp delete mode 100644 examples/spline/spline.cpp delete mode 100644 examples/spline/spline.h delete mode 100644 examples/spline/spline2.h delete mode 100644 examples/spline/spline3.h diff --git a/examples/spline/CMakeLists.txt b/examples/spline/CMakeLists.txt deleted file mode 100644 index c8139291c..000000000 --- a/examples/spline/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -AddCompilerFlag(-fno-stack-protector) # Ubuntu adds -fstack-protector-strong / it's not a GCC default -AddCompilerFlag(-mno-vzeroupper) -build_example(spline main.cpp spline.cpp) diff --git a/examples/spline/main.cpp b/examples/spline/main.cpp deleted file mode 100644 index 647be485f..000000000 --- a/examples/spline/main.cpp +++ /dev/null @@ -1,465 +0,0 @@ -/*{{{ - Copyright © 2015 Matthias Kretz - - Permission to use, copy, modify, and distribute this software - and its documentation for any purpose and without fee is hereby - granted, provided that the above copyright notice appear in all - copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. - -}}}*/ -// includes {{{1 -#include -#include -#include -#include -#include "../tsc.h" -#include "spline.h" -#include "spline2.h" -#include "spline3.h" - -// settings {{{1 -constexpr int NumberOfEvaluations = 10000; -constexpr int FirstMapSize = 4; -constexpr int MaxMapSize = 256; -constexpr int Repetitions = 100; -constexpr auto StepMultiplier = 1.25; - -enum DisabledTests { - DisabledTestsBegin = -999999, - Horizontal3, - DisabledTestsEnd -}; -enum EnabledTests { - Scalar, - Alice, - Float4, - Float16, - Float12, - Float12Interleaved, - Horizontal1, - Horizontal2, - Autovectorized, - NBenchmarks -}; - -std::string testName(int i) -{ - switch (i) { - case Scalar: return "Scalar"; - case Alice: return "Alice"; - case Float4: return "Float4"; - case Float16: return "Float16"; - case Float12: return "Float12"; - case Float12Interleaved: return "F12Interl."; - case Horizontal1: return "Horiz.1"; - case Horizontal2: return "Horiz.2"; - case Horizontal3: return "Horiz.3"; - case Autovectorized: return "Autovec"; - default: return ""; - } -} - -// EnabledTests::operator++ {{{1 -EnabledTests &operator++(EnabledTests &x) -{ - return x = static_cast(static_cast(x) + 1); -} - -// operator<< overloads {{{1 -std::ostream &operator<<(std::ostream &s, const Point2 &xyz) -{ - using std::setw; - return s << '[' << setw(7) << xyz[0] << ", " << setw(7) << xyz[1] << ']'; -} -std::ostream &operator<<(std::ostream &s, const Point2V &xyz) -{ - return s << '[' << xyz[0] << ", " << xyz[1] << ']'; -} -std::ostream &operator<<(std::ostream &s, const Point3 &xyz) -{ - using std::setw; - return s << '[' << setw(7) << xyz[0] << ", " << setw(7) << xyz[1] << ", " << setw(7) - << xyz[2] << ']'; -} -std::ostream &operator<<(std::ostream &s, const Point3V &xyz) -{ - return s << '[' << xyz[0] << ", " << xyz[1] << ", " << xyz[2] << ']'; -} - -// VectorizeBuffer {{{1 -template struct VectorizeBuffer -{ - typedef Vc::simdize InputV; - InputV input; - int entries = 0; - int operator()(Input x) - { - assign(input, entries, x); - entries = (entries + 1) % InputV::size(); - return entries; - } -}; - -// TestInfo {{{1 -struct TestInfo -{ - bool enabled = false; - int id = -1; - TestInfo(EnabledTests t) : enabled(true), id(t) {} - TestInfo(EnabledTests t, EnabledTests) : enabled(true), id(t) {} - TestInfo(EnabledTests t, EnabledTests, EnabledTests) : enabled(true), id(t) {} - TestInfo(EnabledTests t, EnabledTests, DisabledTests) : enabled(true), id(t) {} - TestInfo(EnabledTests t, DisabledTests) : enabled(true), id(t) {} - TestInfo(EnabledTests t, DisabledTests, EnabledTests) : enabled(true), id(t) {} - TestInfo(EnabledTests t, DisabledTests, DisabledTests) : enabled(true), id(t) {} - - TestInfo(DisabledTests) : enabled(false) {} - TestInfo(DisabledTests, EnabledTests t) : enabled(true), id(t) {} - TestInfo(DisabledTests, DisabledTests) : enabled(false) {} - TestInfo(DisabledTests, EnabledTests t, EnabledTests) : enabled(true), id(t) {} - TestInfo(DisabledTests, DisabledTests, EnabledTests t) : enabled(true), id(t) {} - TestInfo(DisabledTests, DisabledTests, DisabledTests) : enabled(false) {} - - TestInfo(DisabledTests, EnabledTests t, DisabledTests) : enabled(true), id(t) {} - - operator bool() const { return enabled; } - operator int() const { return id; } - operator long() const { return id; } - operator long long() const { return id; } -}; -// Runner Lambda {{{1 -struct Runner -{ - // data members{{{2 - TimeStampCounter tsc; - double mean[NBenchmarks] = {}; - double stddev[NBenchmarks] = {}; - const std::vector &searchPoints; - - // Runner::Runner{{{2 - Runner(const std::vector &p) : searchPoints(p) {} - - void recordTsc(int Test, double norm) //{{{2 - { - const double x = tsc.cycles() / norm; - mean[Test] += x; - stddev[Test] += x * x; - } - template void printRatio(I i, J j) //{{{2 - { - if (TestInfo(i) && TestInfo(j)) { - const auto ratio = mean[i] / mean[j]; - std::cout << std::setprecision(3) << std::setw(9) << ratio; - std::cout << std::setprecision(3) << std::setw(9) - << ratio * std::sqrt(stddev[i] * stddev[i] / (mean[i] * mean[i]) + - stddev[j] * stddev[j] / (mean[j] * mean[j])); - } - } - // benchmarkSearch{{{2 - template void benchmark(const TestInfo Test, F &&fun, double err = 20) - { - do { - mean[Test] = 0; - stddev[Test] = 0; - - for (const auto &p : searchPoints) { - fun(p); - } // one cache warm-up run to remove one outlier - for (auto rep = Repetitions; rep; --rep) { - tsc.start(); - for (const auto &p : searchPoints) { - fun(p); - } - tsc.stop(); - recordTsc(Test, NumberOfEvaluations); - } - - mean[Test] /= Repetitions; - stddev[Test] /= Repetitions; - stddev[Test] = std::sqrt(stddev[Test] - mean[Test] * mean[Test]); - } while (stddev[Test] * err > mean[Test]); - std::cout << std::setw(9) << std::setprecision(3) << mean[Test]; - std::cout << std::setw(9) << std::setprecision(3) << stddev[Test]; - std::cout << std::flush; - } - //}}}2 -}; -template void fakeRead(T &&x) -{ -#ifdef Vc_GNU_ASM - asm("" ::"m"(x)); -#else - (void)(&x == &x); -#endif -} -int Vc_CDECL main() // {{{1 -{ - // output header {{{2 - using std::cout; - using std::setw; - using std::setprecision; - cout << "NumberOfEvaluations: " << NumberOfEvaluations << '\n'; - cout << "Repetitions: " << Repetitions << '\n'; - cout << setw(8) << "MapSize"; - for (int i = 0; i < NBenchmarks; ++i) { - cout << setw(18) << testName(i); - } - if (TestInfo(Scalar)) { - for (int i = 0; i < NBenchmarks; ++i) { - if (i != Scalar) { - cout << setw(18) << "Scalar/" + testName(i); - } - } - } - cout << std::endl; - - // random number generator {{{2 - std::default_random_engine randomEngine(1); - std::uniform_real_distribution uniform(-1.f, 1.f); - - // random search points {{{2 - std::vector searchPoints; - searchPoints.reserve(NumberOfEvaluations); - searchPoints.emplace_back(Point2{{-1.f, -1.f}}); - searchPoints.emplace_back(Point2{{+1.f, +1.f}}); - for (int i = 2; i < NumberOfEvaluations; ++i) { - searchPoints.emplace_back(Point2{{uniform(randomEngine), uniform(randomEngine)}}); - } - - // MapSize loop {{{2 - for (int MapSize = FirstMapSize; MapSize <= MaxMapSize; MapSize *= StepMultiplier) { - Runner runner(searchPoints); - cout << setw(8) << MapSize * MapSize << std::flush; - - // initialize map with random values {{{2 - Spline spline(-1.f, 1.f, MapSize, -1.f, 1.f, MapSize); - Spline2 spline2(-1.f, 1.f, MapSize, -1.f, 1.f, MapSize); - Spline3 spline3(-1.f, 1.f, MapSize, -1.f, 1.f, MapSize); - for (int i = 0; i < spline.GetNPoints(); ++i) { - const float xyz[3] = {uniform(randomEngine), uniform(randomEngine), - uniform(randomEngine)}; - spline.Fill(i, xyz); - spline2.Fill(i, xyz); - spline3.Fill(i, xyz); - } - - // run Benchmarks {{{2 - for (EnabledTests i = EnabledTests(0); i < NBenchmarks; ++i) { - VectorizeBuffer vectorizer; - switch (int(i)) { - case Scalar: // {{{3 - runner.benchmark(i, [&](const Point2 &p) { - const auto &p2 = spline.GetValueScalar(p); - fakeRead(p2); - }); - break; - case Alice: // {{{3 - runner.benchmark(i, [&](const Point2 &p) { - const auto &p2 = spline.GetValueAlice(p); - fakeRead(p2); - }); - break; - case Autovectorized: // {{{3 - runner.benchmark(i, [&](const Point2 &p) { - const auto &p2 = spline.GetValueAutovec(p); - fakeRead(p2); - }); - break; - case Float4: // {{{3 - runner.benchmark(i, [&](const Point2 &p) { - const auto &p2 = spline.GetValue(p); - fakeRead(p2); - }); - break; - case Float16: // {{{3 - runner.benchmark(i, [&](const Point2 &p) { - const auto &p2 = spline.GetValue16(p); - fakeRead(p2); - }); - break; - case Float12: // {{{3 - runner.benchmark(i, [&](const Point2 &p) { - const auto &p2 = spline2.GetValue(p); - fakeRead(p2); - }); - break; - case Float12Interleaved: // {{{3 - runner.benchmark(i, [&](const Point2 &p) { - const auto &p2 = spline3.GetValue(p); - fakeRead(p2); - }); - break; - case Horizontal1: // {{{3 - runner.benchmark(i, [&](const Point2 &p) { - if (0 == vectorizer(p)) { - const auto &p2 = spline.GetValue(vectorizer.input); - fakeRead(p2); - } - }); - break; - case Horizontal2: // {{{3 - runner.benchmark(i, [&](const Point2 &p) { - if (0 == vectorizer(p)) { - const auto &p2 = spline2.GetValue(vectorizer.input); - fakeRead(p2); - } - }); - break; - case Horizontal3: // {{{3 - runner.benchmark(i, [&](const Point2 &p) { - if (0 == vectorizer(p)) { - const auto &p2 = spline3.GetValue(vectorizer.input); - fakeRead(p2); - } - }); - break; - default: // {{{3 - break; - } - } - // print search timings {{{2 - if (TestInfo(Scalar)) { - for (EnabledTests i = EnabledTests(0); i < NBenchmarks; ++i) { - if (i != Scalar) { - runner.printRatio(Scalar, i); - } - } - } - cout << std::flush; - - // verify equivalence {{{2 - { - bool failed = false; - VectorizeBuffer vectorizer2; - VectorizeBuffer vectorizer3; - for (const auto &p : searchPoints) { - const auto &ps = spline.GetValueScalar(p); - if (TestInfo(Alice)) { //{{{3 - const auto &pv = spline.GetValueAlice(p); - for (int i = 0; i < 3; ++i) { - if (std::abs(ps[i] - pv[i]) > 0.00001f) { - std::cout << "\nAlice not equal at " << p << ": " << ps - << " vs. " << pv; - failed = true; - break; - } - } - } - if (TestInfo(Autovectorized)) { //{{{3 - const auto &pv = spline.GetValueAutovec(p); - for (int i = 0; i < 3; ++i) { - if (std::abs(ps[i] - pv[i]) > 0.00001f) { - std::cout << "\nAutovectorized not equal at " << p << ": " << ps - << " vs. " << pv; - failed = true; - break; - } - } - } - if (TestInfo(Float4)) { //{{{3 - const auto &pv = spline.GetValue(p); - for (int i = 0; i < 3; ++i) { - if (std::abs(ps[i] - pv[i]) > 0.00001f) { - std::cout << "\nFloat4 not equal at " << p << ": " << ps - << " vs. " << pv; - failed = true; - break; - } - } - } - if (TestInfo(Float16)) { //{{{3 - const auto &pv = spline.GetValue16(p); - for (int i = 0; i < 3; ++i) { - if (std::abs(ps[i] - pv[i]) > 0.00001f) { - std::cout << "\nFloat16 not equal at " << p << ": " << ps - << " vs. " << pv; - failed = true; - break; - } - } - } - if (TestInfo(Float12)) { //{{{3 - const auto &pv = spline2.GetValue(p); - for (int i = 0; i < 3; ++i) { - if (std::abs(ps[i] - pv[i]) > 0.00001f) { - std::cout << "\nFloat12 not equal at " << p << ": " << ps - << " vs. " << pv; - failed = true; - break; - } - } - } - if (TestInfo(Float12Interleaved)) { //{{{3 - const auto &pv = spline3.GetValue(p); - for (int i = 0; i < 3; ++i) { - if (std::abs(ps[i] - pv[i]) > 0.00001f) { - std::cout << "\nFloat12Interleaved not equal at " << p << ": " << ps - << " vs. " << pv; - failed = true; - break; - } - } - } - vectorizer3(ps); - if (0 == vectorizer2(p)) { - if (TestInfo(Horizontal1)) { //{{{3 - const auto &pv = spline.GetValue(vectorizer2.input); - for (int i = 0; i < 3; ++i) { - if (any_of(abs(vectorizer3.input[i] - pv[i]) > 0.00001f)) { - cout << "\nHorizontal1 not equal at " << vectorizer2.input - << ": " << vectorizer3.input << " vs. " << pv; - failed = true; - break; - } - } - } - if (TestInfo(Horizontal2)) { //{{{3 - const auto &pv = spline2.GetValue(vectorizer2.input); - for (int i = 0; i < 3; ++i) { - if (any_of(abs(vectorizer3.input[i] - pv[i]) > 0.00001f)) { - cout << "\nHorizontal2 not equal at \n" << vectorizer2.input - << ":\n" << vectorizer3.input << " vs.\n" << pv; - failed = true; - break; - } - } - } - if (TestInfo(Horizontal3)) { //{{{3 - const auto &pv = spline3.GetValue(vectorizer2.input); - for (int i = 0; i < 3; ++i) { - if (any_of(abs(vectorizer3.input[i] - pv[i]) > 0.00001f)) { - cout << "\nHorizontal3 not equal at \n" << vectorizer2.input - << ":\n" << vectorizer3.input << " vs.\n" << pv; - failed = true; - break; - } - } - } - } //{{{3 - } - if (failed) { - //std::cout << '\n' << spline. << '\n'; - return 1; - } else { - cout << " ✓"; - } - } - cout << std::endl; - } - return 0; -} // }}}1 - -// vim: foldmethod=marker diff --git a/examples/spline/spline.cpp b/examples/spline/spline.cpp deleted file mode 100644 index d93514a40..000000000 --- a/examples/spline/spline.cpp +++ /dev/null @@ -1,260 +0,0 @@ -/*{{{ - Copyright © 2015 Matthias Kretz - - Permission to use, copy, modify, and distribute this software - and its documentation for any purpose and without fee is hereby - granted, provided that the above copyright notice appear in all - copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. - - -This work is derived from a class in ALICE with the following copyright notice: - ************************************************************************** - * This file is property of and copyright by the ALICE HLT Project * - * ALICE Experiment at CERN, All rights reserved. * - * * - * Primary Authors: Sergey Gorbunov * - * for The ALICE HLT Project. * - * * - * Permission to use, copy, modify and distribute this software and its * - * documentation strictly for non-commercial purposes is hereby granted * - * without fee, provided that the above copyright notice appears in all * - * copies and that both the copyright notice and this permission notice * - * appear in the supporting documentation. The authors make no claims * - * about the suitability of this software for any purpose. It is * - * provided "as is" without express or implied warranty. * - ************************************************************************** -}}}*/ - -#include "spline.h" -#include - -#include -#include - -using namespace std; - -Spline::Spline(float minA, float maxA, int nBinsA, float minB, float maxB, //{{{1 - int nBinsB) - : fNA(nBinsA < 4 ? 4 : nBinsA) - , fNB(nBinsB < 4 ? 4 : nBinsB) - , fN(fNA * fNB) - , fMinA(minA) - , fMinB(minB) - , fStepA(((maxA <= minA ? minA + 1 : maxA) - minA) / (fNA - 1)) - , fStepB(((maxB <= minB ? minB + 1 : maxB) - minB) / (fNB - 1)) - , fScaleA(1.f / fStepA) - , fScaleB(1.f / fStepB) - , fXYZ(fN, DataPoint::Zero()) -{ -} - -// spline 3-st order, 4 points, da = a - point 1 {{{1 -template static inline T GetSpline3(T v0, T v1, T v2, T v3, T x) -{ - const T dv = v2 - v1; - const T z0 = 0.5f * (v2 - v0); - const T z1 = 0.5f * (v3 - v1); - return (x * x) * ((z1 - dv) * (x - 1) + (z0 - dv) * (x - 2)) + (z0 * x + v1); - //return x * x * ((z1 - dv + z0 - dv) * (x - 1) - (z0 - dv)) + z0 * x + v1; -} - -template static inline T GetSpline3(const T *v, T x) -{ - return GetSpline3(v[0], v[1], v[2], v[3], x); -} - -Point3 Spline::GetValue(Point2 ab) const //{{{1 -{ - float da1, db1; - int iA, iB; - std::tie(iA, iB, da1, db1) = - evaluatePosition(ab, {{fMinA, fMinB}}, {{fScaleA, fScaleB}}, fNA, fNB); - int ind = iA * fNB + iB; - - typedef Vc::SimdArray float4; - const float4 da = da1; - const float4 db = db1; - - float4 v[4]; - const float4 *m = &fXYZ[0]; - - for (int i = 0; i < 4; i++) { - v[i] = GetSpline3(m[ind + 0], m[ind + 1], m[ind + 2], m[ind + 3], db); - ind += fNB; - } - float4 res = GetSpline3(v[0], v[1], v[2], v[3], da); - return {{res[0], res[1], res[2]}}; -} - -Point3 Spline::GetValue16(Point2 ab) const //{{{1 -{ - float da1, db1; - int iA, iB; - std::tie(iA, iB, da1, db1) = - evaluatePosition(ab, {{fMinA, fMinB}}, {{fScaleA, fScaleB}}, fNA, fNB); - - typedef Vc::SimdArray float4; - typedef Vc::SimdArray float16; - const float4 da = da1; - const float16 db = db1; - - const float4 *m0 = &fXYZ[iA * fNB + iB]; - const float4 *m1 = m0 + fNB; - const float4 *m2 = m1 + fNB; - const float4 *m3 = m2 + fNB; - const float16 v0123 = - GetSpline3(Vc::simd_cast(m0[0], m1[0], m2[0], m3[0]), - Vc::simd_cast(m0[1], m1[1], m2[1], m3[1]), - Vc::simd_cast(m0[2], m1[2], m2[2], m3[2]), - Vc::simd_cast(m0[3], m1[3], m2[3], m3[3]), db); - const float4 res = - GetSpline3(Vc::simd_cast(v0123), Vc::simd_cast(v0123), - Vc::simd_cast(v0123), Vc::simd_cast(v0123), da); - return {{res[0], res[1], res[2]}}; -} - -Point3 Spline::GetValueScalar(Point2 ab) const //{{{1 -{ - float da, db; - int iA, iB; - std::tie(iA, iB, da, db) = - evaluatePosition(ab, {{fMinA, fMinB}}, {{fScaleA, fScaleB}}, fNA, fNB); - int ind = iA * fNB + iB; - - float vx[4]; - float vy[4]; - float vz[4]; - for (int i = 0; i < 4; i++) { - vx[i] = GetSpline3(fXYZ[ind][0], fXYZ[ind + 1][0], fXYZ[ind + 2][0], - fXYZ[ind + 3][0], db); - vy[i] = GetSpline3(fXYZ[ind][1], fXYZ[ind + 1][1], fXYZ[ind + 2][1], - fXYZ[ind + 3][1], db); - vz[i] = GetSpline3(fXYZ[ind][2], fXYZ[ind + 1][2], fXYZ[ind + 2][2], - fXYZ[ind + 3][2], db); - ind += fNB; - } - return {{GetSpline3(vx, da), GetSpline3(vy, da), GetSpline3(vz, da)}}; -} - -Point3 Spline::GetValueAutovec(Point2 ab) const //{{{1 -{ - float da, db; - int iA, iB; - std::tie(iA, iB, da, db) = - evaluatePosition(ab, {{fMinA, fMinB}}, {{fScaleA, fScaleB}}, fNA, fNB); - int ind = iA * fNB + iB; - - float vx[4]; - float vy[4]; - float vz[4]; - const float *m = reinterpret_cast(&fXYZ[0]); - for (int i = 0; i < 4; i++) { - int ind4 = ind * 4; - vx[i] = GetSpline3(m[ind4 + 0], m[ind4 + 4], m[ind4 + 8], m[ind4 + 12], db); - vy[i] = GetSpline3(m[ind4 + 1], m[ind4 + 5], m[ind4 + 9], m[ind4 + 13], db); - vz[i] = GetSpline3(m[ind4 + 2], m[ind4 + 6], m[ind4 + 10], m[ind4 + 14], db); - ind += fNB; - } - return {{GetSpline3(vx, da), GetSpline3(vy, da), GetSpline3(vz, da)}}; -} - -Point3V Spline::GetValue(const Point2V &ab) const //{{{1 -{ - index_v iA, iB; - float_v da, db; - std::tie(iA, iB, da, db) = - evaluatePosition(ab, {{fMinA, fMinB}}, {{fScaleA, fScaleB}}, fNA, fNB); - - float_v vx[4]; - float_v vy[4]; - float_v vz[4]; - auto ind = iA * fNB + iB; - const auto map = Vc::make_interleave_wrapper(&fXYZ[0]); - for (int i = 0; i < 4; i++) { - float_v x[4], y[4], z[4]; - Vc::tie(x[0], y[0], z[0]) = map[ind]; - Vc::tie(x[1], y[1], z[1]) = map[ind + 1]; - Vc::tie(x[2], y[2], z[2]) = map[ind + 2]; - Vc::tie(x[3], y[3], z[3]) = map[ind + 3]; - vx[i] = GetSpline3(x[0], x[1], x[2], x[3], db); - vy[i] = GetSpline3(y[0], y[1], y[2], y[3], db); - vz[i] = GetSpline3(z[0], z[1], z[2], z[3], db); - ind += fNB; - } - Point3V XYZ; - XYZ[0] = GetSpline3(vx, da); - XYZ[1] = GetSpline3(vy, da); - XYZ[2] = GetSpline3(vz, da); - return XYZ; -} - -// Point3 Spline::GetValueAlice(Point2 ab) const {{{1 -#ifdef Vc_GCC -#pragma GCC diagnostic ignored "-Wold-style-cast" -__attribute__((optimize("no-tree-vectorize"))) -#endif -Point3 Spline::GetValueAlice(Point2 ab) const -{ - float lA = (ab[0] - fMinA) * fScaleA - 1.f; - int iA = (int)lA; - if (lA < 0) iA = 0; - else if (iA > fNA - 4) iA = fNA - 4; - - float lB = (ab[1] - fMinB) * fScaleB - 1.f; - int iB = (int)lB; - if (lB < 0) iB = 0; - else if (iB > fNB - 4) iB = fNB - 4; - - Point3 XYZ; - if (Vc::float_v::Size == 4) { - Vc::float_v da = lA - iA; - Vc::float_v db = lB - iB; - - Vc::float_v v[4]; - int ind = iA * fNB + iB; - const Vc::float_v *m = reinterpret_cast(&fXYZ[0]); - - for (int i = 0; i < 4; i++) { - v[i] = GetSpline3(m[ind + 0], m[ind + 1], m[ind + 2], m[ind + 3], db); - ind += fNB; - } - Vc::float_v res = GetSpline3(v[0], v[1], v[2], v[3], da); - XYZ[0] = res[0]; - XYZ[1] = res[1]; - XYZ[2] = res[2]; - } else { - float da = lA - iA; - float db = lB - iB; - - float vx[4]; - float vy[4]; - float vz[4]; - int ind = iA * fNB + iB; - const float *m = reinterpret_cast(&fXYZ[0]); - for (int i = 0; i < 4; i++) { - int ind4 = ind * 4; - vx[i] = GetSpline3(m[ind4 + 0], m[ind4 + 4], m[ind4 + 8], m[ind4 + 12], db); - vy[i] = GetSpline3(m[ind4 + 1], m[ind4 + 5], m[ind4 + 9], m[ind4 + 13], db); - vz[i] = GetSpline3(m[ind4 + 2], m[ind4 + 6], m[ind4 + 10], m[ind4 + 14], db); - ind += fNB; - } - XYZ[0] = GetSpline3(vx, da); - XYZ[1] = GetSpline3(vy, da); - XYZ[2] = GetSpline3(vz, da); - } - return XYZ; -} -// vim: foldmethod=marker diff --git a/examples/spline/spline.h b/examples/spline/spline.h deleted file mode 100644 index b6753c49b..000000000 --- a/examples/spline/spline.h +++ /dev/null @@ -1,181 +0,0 @@ -/*{{{ - Copyright © 2015 Matthias Kretz - - Permission to use, copy, modify, and distribute this software - and its documentation for any purpose and without fee is hereby - granted, provided that the above copyright notice appear in all - copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. - - -This work is derived from a class in ALICE with the following copyright notice: - ************************************************************************** - * This file is property of and copyright by the ALICE HLT Project * - * ALICE Experiment at CERN, All rights reserved. * - * * - * Primary Authors: Sergey Gorbunov * - * for The ALICE HLT Project. * - * * - * Permission to use, copy, modify and distribute this software and its * - * documentation strictly for non-commercial purposes is hereby granted * - * without fee, provided that the above copyright notice appears in all * - * copies and that both the copyright notice and this permission notice * - * appear in the supporting documentation. The authors make no claims * - * about the suitability of this software for any purpose. It is * - * provided "as is" without express or implied warranty. * - ************************************************************************** -}}}*/ - -#ifndef SPLINE_H_ -#define SPLINE_H_ - -#include -#include -#include -#include -#include - -//* This file is property of and copyright by the ALICE HLT Project * -//* ALICE Experiment at CERN, All rights reserved. * -//* See cxx source for full Copyright notice * - -typedef std::array Point2; -typedef std::array Point3; - -typedef Vc::simdize Point2V; -typedef Vc::simdize Point3V; - -class Spline -{ -public: - Spline(float minA, float maxA, int nBinsA, float minB, float maxB, int nBinsB); - - /** Filling of points */ - template void Fill(F &&func); - /** Filling of points */ - void Fill(int ind, float x, float y, float z); - /** Filling of points */ - void Fill(int ind, const float XYZ[]); - - /** Get A,B by the point index */ - std::pair GetAB(int ind) const; - - /** Calculate interpolated value at the given point(s) */ - Point3 GetValue(Point2) const; - Point3 GetValue16(Point2 ab) const; - Point3 GetValueScalar(Point2) const; - Point3 GetValueAutovec(Point2 ab) const; - Point3V GetValue(const Point2V &) const; - Point3 GetValueAlice(Point2 ab) const; - - /** Get size of the grid */ - int GetMapSize() const; - - /** Get N of point on the grid */ - int GetNPoints() const; - -private: - /** copy constructor prohibited */ - Spline(const Spline &); - /** assignment operator prohibited */ - Spline &operator=(const Spline &); - - /** spline 2-nd order, 3 points, da = a - point 1 */ - static float GetSpline2(float *v, float da); - - const int fNA; // N points A axis - const int fNB; // N points A axis - const int fN; // N points total - const float fMinA; // min A axis - const float fMinB; // min B axis - const float fStepA; // step between points A axis - const float fStepB; // step between points B axis - const float fScaleA; // scale A axis - const float fScaleB; // scale B axis - typedef Vc::SimdArray DataPoint; - Vc::vector fXYZ; // array of points, {X,Y,Z,0} values -}; - -inline void Spline::Fill(int ind, float x, float y, float z) -{ - fXYZ[ind][0] = x; - fXYZ[ind][1] = y; - fXYZ[ind][2] = z; -} - -inline void Spline::Fill(int ind, const float XYZ[]) -{ - Fill(ind, XYZ[0], XYZ[1], XYZ[2]); -} - -template inline void Spline::Fill(F &&func) -{ - for (int i = 0; i < GetNPoints(); i++) { - float a, b; - std::tie(a, b) = GetAB(i); - std::array xyz = func(a, b); - Fill(i, xyz[0], xyz[1], xyz[2]); - } -} - -inline std::pair Spline::GetAB(int ind) const -{ - return std::make_pair(fMinA + (ind / fNA) * fStepA, fMinB + (ind % fNB) * fStepB); -} - -inline int Spline::GetMapSize() const { return 4 * sizeof(float) * fN; } - -inline int Spline::GetNPoints() const { return fN; } - -inline float Spline::GetSpline2(float *v, float x) -{ - return 0.5f * x * ((v[0] + v[2] - v[1] - v[1]) * x + v[2] - v[0]) + v[1]; -} - -inline std::tuple evaluatePosition(Point2 ab, Point2 min, - Point2 scale, int na, int nb) -{ - const float lA = (ab[0] - min[0]) * scale[0] - 1.f; - const int iA = std::min(na - 4.f, std::max(lA, 0.f)); - - const float lB = (ab[1] - min[1]) * scale[1] - 1.f; - const int iB = std::min(nb - 4.f, std::max(lB, 0.f)); - - const float da = lA - iA; - const float db = lB - iB; - - return std::make_tuple(iA, iB, da, db); -} - -using Vc::float_v; -typedef float_v::IndexType index_v; -inline std::tuple evaluatePosition(Point2V ab, - Point2 min, - Point2 scale, - int na, int nb) -{ - const float_v lA = (ab[0] - min[0]) * scale[0] - 1.f; - const auto iA = static_cast(std::min(na - 4.f, std::max(lA, 0.f))); - - const float_v lB = (ab[1] - min[1]) * scale[1] - 1.f; - const auto iB = static_cast(std::min(nb - 4.f, std::max(lB, 0.f))); - - const float_v da = lA - Vc::simd_cast(iA); - const float_v db = lB - Vc::simd_cast(iB); - - return std::make_tuple(iA, iB, da, db); -} - -#endif // SPLINE_H_ diff --git a/examples/spline/spline2.h b/examples/spline/spline2.h deleted file mode 100644 index 7458518fc..000000000 --- a/examples/spline/spline2.h +++ /dev/null @@ -1,250 +0,0 @@ -/*{{{ - Copyright © 2015 Matthias Kretz - - Permission to use, copy, modify, and distribute this software - and its documentation for any purpose and without fee is hereby - granted, provided that the above copyright notice appear in all - copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. - - -This work is derived from a class in ALICE with the following copyright notice: - ************************************************************************** - * This file is property of and copyright by the ALICE HLT Project * - * ALICE Experiment at CERN, All rights reserved. * - * * - * Primary Authors: Sergey Gorbunov * - * for The ALICE HLT Project. * - * * - * Permission to use, copy, modify and distribute this software and its * - * documentation strictly for non-commercial purposes is hereby granted * - * without fee, provided that the above copyright notice appears in all * - * copies and that both the copyright notice and this permission notice * - * appear in the supporting documentation. The authors make no claims * - * about the suitability of this software for any purpose. It is * - * provided "as is" without express or implied warranty. * - ************************************************************************** -}}}*/ - -#ifndef SPLINE2_H_ -#define SPLINE2_H_ - -#include -#include -#include -#include -#include -#include "spline.h" - -//* This file is property of and copyright by the ALICE HLT Project * -//* ALICE Experiment at CERN, All rights reserved. * -//* See cxx source for full Copyright notice * - -class Spline2 -{ -public: - typedef std::array Point2; - typedef std::array Point3; - - typedef Vc::simdize Point2V; - typedef Vc::simdize Point3V; - - Spline2(float minA, float maxA, int nBinsA, float minB, float maxB, int nBinsB); - - /** Filling of points */ - template void Fill(F &&func); - /** Filling of points */ - void Fill(int ind, float x, float y, float z); - /** Filling of points */ - void Fill(int ind, const float XYZ[]); - - /** Get A,B by the point index */ - std::pair GetAB(int ind) const; - - /** Calculate interpolated value at the given point(s) */ - Point3 GetValue(Point2) const; - Point3V GetValue(Point2V ab) const; - - /** Get size of the grid */ - int GetMapSize() const; - - /** Get N of point on the grid */ - int GetNPoints() const; - -private: - /** copy constructor prohibited */ - Spline2(const Spline2 &); - /** assignment operator prohibited */ - Spline2 &operator=(const Spline2 &); - - /** spline 2-nd order, 3 points, da = a - point 1 */ - static float GetSpline2(float *v, float da); - - const int fNA; // N points A axis - const int fNB; // N points A axis - const int fN; // N points total - const float fMinA; // min A axis - const float fMinB; // min B axis - const float fStepA; // step between points A axis - const float fStepB; // step between points B axis - const float fScaleA; // scale A axis - const float fScaleB; // scale B axis - Vc::vector> fXYZ; // array of points, {X,Y,Z,0} values -}; - -inline void Spline2::Fill(int ind, float x, float y, float z) -{ - ind = ind / fNB + fNA * (ind % fNB); - fXYZ[ind] = x; - fXYZ[ind + fN] = y; - fXYZ[ind + 2 * fN] = z; -} - -inline void Spline2::Fill(int ind, const float XYZ[]) -{ - Fill(ind, XYZ[0], XYZ[1], XYZ[2]); -} - -template inline void Spline2::Fill(F &&func) -{ - for (int i = 0; i < GetNPoints(); i++) { - float a, b; - std::tie(a, b) = GetAB(i); - std::array xyz = func(a, b); - Fill(i, xyz[0], xyz[1], xyz[2]); - } -} - -inline std::pair Spline2::GetAB(int ind) const -{ - return std::make_pair(fMinA + (ind / fNA) * fStepA, fMinB + (ind % fNB) * fStepB); -} - -inline int Spline2::GetMapSize() const { return 4 * sizeof(float) * fN; } - -inline int Spline2::GetNPoints() const { return fN; } - -inline float Spline2::GetSpline2(float *v, float x) -{ - return 0.5f * x * ((v[0] + v[2] - v[1] - v[1]) * x + v[2] - v[0]) + v[1]; -} - -// spline 3-st order, 4 points, da = a - point 1 {{{1 -template static Vc_ALWAYS_INLINE T GetSpline3(T v0, T v1, T v2, T v3, T x) -{ - const T dv = v2 - v1; - const T z0 = 0.5f * (v2 - v0); - const T z1 = 0.5f * (v3 - v1); - return (x * x) * ((z1 - dv) * (x - 1) + (z0 - dv) * (x - 2)) + (z0 * x + v1); -} - -template static Vc_ALWAYS_INLINE T GetSpline3(const T v[], T x) -{ - return GetSpline3(v[0], v[1], v[2], v[3], x); -} - -inline Point3 Spline2::GetValue(Point2 ab) const //{{{1 -{ - float da1, db1; - int iA, iB; - std::tie(iA, iB, da1, db1) = - evaluatePosition(ab, {{fMinA, fMinB}}, {{fScaleA, fScaleB}}, fNA, fNB); - - typedef Vc::SimdArray float4; - typedef Vc::SimdArray float12; - const float4 da = da1; - const float12 db = db1; - - const float *m0 = &fXYZ[iA + iB * fNA]; - const float *m1 = m0 + fNA; - const float *m2 = m1 + fNA; - const float *m3 = m2 + fNA; - - const float12 xyz = GetSpline3( - Vc::simd_cast(float4(m0), float4(m0 + fN), float4(m0 + 2 * fN)), - Vc::simd_cast(float4(m1), float4(m1 + fN), float4(m1 + 2 * fN)), - Vc::simd_cast(float4(m2), float4(m2 + fN), float4(m2 + 2 * fN)), - Vc::simd_cast(float4(m3), float4(m3 + fN), float4(m3 + 2 * fN)), db); - - float4 v[4]; - Vc::tie(v[0], v[1], v[2], v[3]) = - Vc::transpose(Vc::simd_cast(xyz), Vc::simd_cast(xyz), - Vc::simd_cast(xyz), float4::Zero()); - - float4 res = GetSpline3(v[0], v[1], v[2], v[3], da); - return {{res[0], res[1], res[2]}}; -} - -inline Spline2::Point3V Spline2::GetValue(Point2V ab) const //{{{1 -{ - index_v iA, iB; - float_v da, db; - std::tie(iA, iB, da, db) = - evaluatePosition(ab, {{fMinA, fMinB}}, {{fScaleA, fScaleB}}, fNA, fNB); - - auto ind = iA + iB * fNA; - Point3V xyz; - - { - float_v x[4][4]; - Vc::tie(x[0][0], x[1][0], x[2][0], x[3][0]) = fXYZ[ind]; - Vc::tie(x[0][1], x[1][1], x[2][1], x[3][1]) = fXYZ[ind + fNA]; - Vc::tie(x[0][2], x[1][2], x[2][2], x[3][2]) = fXYZ[ind + 2 * fNA]; - Vc::tie(x[0][3], x[1][3], x[2][3], x[3][3]) = fXYZ[ind + 3 * fNA]; - xyz[0] = GetSpline3(GetSpline3(x[0], db), GetSpline3(x[1], db), - GetSpline3(x[2], db), GetSpline3(x[3], db), da); - } - ind += fN; - { - float_v y[4][4]; - Vc::tie(y[0][0], y[1][0], y[2][0], y[3][0]) = fXYZ[ind]; - Vc::tie(y[0][1], y[1][1], y[2][1], y[3][1]) = fXYZ[ind + fNA]; - Vc::tie(y[0][2], y[1][2], y[2][2], y[3][2]) = fXYZ[ind + 2 * fNA]; - Vc::tie(y[0][3], y[1][3], y[2][3], y[3][3]) = fXYZ[ind + 3 * fNA]; - xyz[1] = GetSpline3(GetSpline3(y[0], db), GetSpline3(y[1], db), - GetSpline3(y[2], db), GetSpline3(y[3], db), da); - } - ind += fN; - { - float_v z[4][4]; - Vc::tie(z[0][0], z[1][0], z[2][0], z[3][0]) = fXYZ[ind]; - Vc::tie(z[0][1], z[1][1], z[2][1], z[3][1]) = fXYZ[ind + fNA]; - Vc::tie(z[0][2], z[1][2], z[2][2], z[3][2]) = fXYZ[ind + 2 * fNA]; - Vc::tie(z[0][3], z[1][3], z[2][3], z[3][3]) = fXYZ[ind + 3 * fNA]; - xyz[2] = GetSpline3(GetSpline3(z[0], db), GetSpline3(z[1], db), - GetSpline3(z[2], db), GetSpline3(z[3], db), da); - } - return xyz; -} - -inline Spline2::Spline2(float minA, float maxA, int nBinsA, float minB, //{{{1 - float maxB, int nBinsB) - : fNA(nBinsA < 4 ? 4 : nBinsA) - , fNB(nBinsB < 4 ? 4 : nBinsB) - , fN(fNA * fNB) - , fMinA(minA) - , fMinB(minB) - , fStepA(((maxA <= minA ? minA + 1 : maxA) - minA) / (fNA - 1)) - , fStepB(((maxB <= minB ? minB + 1 : maxB) - minB) / (fNB - 1)) - , fScaleA(1.f / fStepA) - , fScaleB(1.f / fStepB) - , fXYZ(3 * fN, 0.f) -{ -} -//}}}1 - -#endif // SPLINE2_H_ - -// vim: foldmethod=marker diff --git a/examples/spline/spline3.h b/examples/spline/spline3.h deleted file mode 100644 index da17a1739..000000000 --- a/examples/spline/spline3.h +++ /dev/null @@ -1,206 +0,0 @@ -/*{{{ - Copyright © 2015 Matthias Kretz - - Permission to use, copy, modify, and distribute this software - and its documentation for any purpose and without fee is hereby - granted, provided that the above copyright notice appear in all - copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. - - -This work is derived from a class in ALICE with the following copyright notice: - ************************************************************************** - * This file is property of and copyright by the ALICE HLT Project * - * ALICE Experiment at CERN, All rights reserved. * - * * - * Primary Authors: Sergey Gorbunov * - * for The ALICE HLT Project. * - * * - * Permission to use, copy, modify and distribute this software and its * - * documentation strictly for non-commercial purposes is hereby granted * - * without fee, provided that the above copyright notice appears in all * - * copies and that both the copyright notice and this permission notice * - * appear in the supporting documentation. The authors make no claims * - * about the suitability of this software for any purpose. It is * - * provided "as is" without express or implied warranty. * - ************************************************************************** -}}}*/ - -#ifndef SPLINE3_H_ -#define SPLINE3_H_ - -#include -#include -#include -#include -#include -#include "spline2.h" - -//* This file is property of and copyright by the ALICE HLT Project * -//* ALICE Experiment at CERN, All rights reserved. * -//* See cxx source for full Copyright notice * - -class Spline3 -{ -public: - Spline3(float minA, float maxA, int nBinsA, float minB, float maxB, int nBinsB); - - /** Filling of points */ - template void Fill(F &&func); - /** Filling of points */ - void Fill(int ind, float x, float y, float z); - /** Filling of points */ - void Fill(int ind, const float XYZ[]); - - /** Get A,B by the point index */ - std::pair GetAB(int ind) const; - - /** Calculate interpolated value at the given point(s) */ - Point3 GetValue(Point2) const; - Point3V GetValue(const Point2V &ab) const; - - /** Get size of the grid */ - int GetMapSize() const; - - /** Get N of point on the grid */ - int GetNPoints() const; - -private: - /** copy constructor prohibited */ - Spline3(const Spline3 &); - /** assignment operator prohibited */ - Spline3 &operator=(const Spline3 &); - - const int fNA; // N points A axis - const int fNB; // N points A axis - const int fN; // N points total - const float fMinA; // min A axis - const float fMinB; // min B axis - const float fStepA; // step between points A axis - const float fStepB; // step between points B axis - const float fScaleA; // scale A axis - const float fScaleB; // scale B axis - Vc::vector fXYZ; -}; - -inline void Spline3::Fill(int ind, float x, float y, float z) -{ - ind = ind / fNB + fNA * (ind % fNB); - fXYZ[ind][0] = x; - fXYZ[ind][1] = y; - fXYZ[ind][2] = z; -} - -inline void Spline3::Fill(int ind, const float XYZ[]) -{ - Fill(ind, XYZ[0], XYZ[1], XYZ[2]); -} - -template inline void Spline3::Fill(F &&func) -{ - for (int i = 0; i < GetNPoints(); i++) { - float a, b; - std::tie(a, b) = GetAB(i); - std::array xyz = func(a, b); - Fill(i, xyz[0], xyz[1], xyz[2]); - } -} - -inline std::pair Spline3::GetAB(int ind) const -{ - return std::make_pair(fMinA + (ind / fNA) * fStepA, fMinB + (ind % fNB) * fStepB); -} - -inline int Spline3::GetMapSize() const { return 4 * sizeof(float) * fN; } - -inline int Spline3::GetNPoints() const { return fN; } - -inline Point3 Spline3::GetValue(Point2 ab) const //{{{1 -{ - float da1, db1; - int iA, iB; - std::tie(iA, iB, da1, db1) = - evaluatePosition(ab, {{fMinA, fMinB}}, {{fScaleA, fScaleB}}, fNA, fNB); - - typedef Vc::SimdArray float4; - typedef Vc::SimdArray float12; - const float4 da = da1; - const float12 db = db1; - - const float *m0 = &fXYZ[iA + iB * fNA][0]; - const float *m1 = m0 + fNA * 3; - const float *m2 = m1 + fNA * 3; - const float *m3 = m2 + fNA * 3; - - const float12 xyz = GetSpline3(float12(m0), // x0 y0 z0 x1 y1 z1 x2 y2 z2 x3 y3 z3 - float12(m1), float12(m2), float12(m3), db); - - const float4 t0 = Vc::simd_cast(xyz); // x0 y0 z0 x1 - const float4 t1 = Vc::simd_cast(xyz); // y1 z1 x2 y2 - const float4 t2 = Vc::simd_cast(xyz); // z2 x3 y3 z3 - - const float4 res = - GetSpline3(t0, t0.shifted(3, t1), t1.shifted(2, t2), t2.shifted(1), da); - return {{res[0], res[1], res[2]}}; -} - -Point3V Spline3::GetValue(const Point2V &ab) const //{{{1 -{ - index_v iA, iB; - float_v da, db; - std::tie(iA, iB, da, db) = - evaluatePosition(ab, {{fMinA, fMinB}}, {{fScaleA, fScaleB}}, fNA, fNB); - - float_v vx[4]; - float_v vy[4]; - float_v vz[4]; - auto ind = iA + iB * fNA; - for (int i = 0; i < 4; i++) { - float_v x[4], y[4], z[4]; - Vc::tie(x[0], y[0], z[0]) = fXYZ[ind][0]; - Vc::tie(x[1], y[1], z[1]) = fXYZ[ind + fNA][0]; - Vc::tie(x[2], y[2], z[2]) = fXYZ[ind + 2 * fNA][0]; - Vc::tie(x[3], y[3], z[3]) = fXYZ[ind + 3 * fNA][0]; - vx[i] = GetSpline3(x[0], x[1], x[2], x[3], db); - vy[i] = GetSpline3(y[0], y[1], y[2], y[3], db); - vz[i] = GetSpline3(z[0], z[1], z[2], z[3], db); - ind += 1; - } - Point3V XYZ; - XYZ[0] = GetSpline3(vx, da); - XYZ[1] = GetSpline3(vy, da); - XYZ[2] = GetSpline3(vz, da); - return XYZ; -} - -inline Spline3::Spline3(float minA, float maxA, int nBinsA, float minB, //{{{1 - float maxB, int nBinsB) - : fNA(nBinsA < 4 ? 4 : nBinsA) - , fNB(nBinsB < 4 ? 4 : nBinsB) - , fN(fNA * fNB) - , fMinA(minA) - , fMinB(minB) - , fStepA(((maxA <= minA ? minA + 1 : maxA) - minA) / (fNA - 1)) - , fStepB(((maxB <= minB ? minB + 1 : maxB) - minB) / (fNB - 1)) - , fScaleA(1.f / fStepA) - , fScaleB(1.f / fStepB) - , fXYZ(fN) -{ -} -//}}}1 - -#endif // SPLINE3_H_ - -// vim: foldmethod=marker