From c2f77a461046b1f76e2841693159f63c2ace4fce Mon Sep 17 00:00:00 2001 From: mazestic Date: Mon, 7 Aug 2023 15:48:48 +0200 Subject: [PATCH] Add variadic BasketAutoDiff aggregate (#106) --- Ponca/src/Fitting/basket.h | 27 +++++++++++++++++++++++++++ tests/src/basket.cpp | 12 ++++++++++++ 2 files changed, 39 insertions(+) diff --git a/Ponca/src/Fitting/basket.h b/Ponca/src/Fitting/basket.h index 453709f1c..4a406f248 100644 --- a/Ponca/src/Fitting/basket.h +++ b/Ponca/src/Fitting/basket.h @@ -69,6 +69,26 @@ namespace internal struct BasketDiffAggregate : BasketDiffAggregateImpl { }; + + template class... Exts> + struct BasketAutoDiffAggregateImpl : BasketAggregateImpl // Same impl + { + }; + + template class Ext0, + template class... Exts> + struct BasketAutoDiffAggregate + { + private: + using Base = Ext0>; + using Aggregate = typename BasketAutoDiffAggregateImpl::type; + + public: + using type = typename Base::template DDerType>; + }; } #endif @@ -241,5 +261,12 @@ namespace internal } }; // class Basket + template class Ext0, + template class... Exts> + class BasketAutoDiff : public internal::BasketAutoDiffAggregate::type + { + }; // class BasketAutoDiff + } //namespace Ponca diff --git a/tests/src/basket.cpp b/tests/src/basket.cpp index f89d87b04..dd2ef3c90 100644 --- a/tests/src/basket.cpp +++ b/tests/src/basket.cpp @@ -193,6 +193,14 @@ void hasSamePlaneDerivatives(const Fit1& fit1, const Fit2& fit2) { VERIFY(dnor1.isApprox( dnor2 )); } +// For BasketAutoDiff +template +struct TestExt0 : public T +{ + template + using DDerType = OrientedSphereDerImpl; +}; + template void callSubTests() { @@ -230,6 +238,10 @@ void callSubTests() using HybridSpaceDiff = BasketDiff; using HybridScaleSpaceDiff = BasketDiff; + //! [BasketAutoDiff] + using AutoDiff = BasketAutoDiff; + //! [BasketAutoDiff] + KdTreetree; Scalar scale = generateData(tree);