Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BasketAutoDiff aggregate type #113

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Ponca/src/Fitting/basket.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,20 @@ namespace internal
struct BasketDiffAggregate : BasketDiffAggregateImpl<BasketType, Type, BasketType, PrimitiveDer, Exts...>
{
};

/*! \brief Internal class used to build the BasketAutoDiff structure */
template <class P, class W, int Type,
template <class, class, typename> class Ext0,
template <class, class, typename> class... Exts>
struct BasketAutoDiffAggregate
{
private:
using Base = Ext0<P, W, PrimitiveBase<P, W>>;
using Aggregate = typename BasketAggregateImpl<P, W, Base, Exts...>::type; // Same impl

public:
using type = typename Base::template DDerType<P, W, Type, PrimitiveDer<P, W, Type, Aggregate>>;
};
}
#endif

Expand Down Expand Up @@ -241,5 +255,12 @@ namespace internal
}
}; // class Basket

template <class P, class W, int Type,
template <class, class, typename> class Ext0,
template <class, class, typename> class... Exts>
class BasketAutoDiff : public internal::BasketAutoDiffAggregate<P, W, Type, Ext0, Exts...>::type
{
}; // class BasketAutoDiff

} //namespace Ponca

12 changes: 12 additions & 0 deletions tests/src/basket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,14 @@ void hasSamePlaneDerivatives(const Fit1& fit1, const Fit2& fit2) {
VERIFY(dnor1.isApprox( dnor2 ));
}

// For BasketAutoDiff
template <class P, class W, typename T>
struct AutoDiffExt : public T
{
template <class D, class W_, int Di, typename TT>
using DDerType = OrientedSphereDerImpl<D, W_, Di, TT>;
};

template<typename Scalar, int Dim>
void callSubTests()
{
Expand Down Expand Up @@ -230,6 +238,10 @@ void callSubTests()
using HybridSpaceDiff = BasketDiff<Hybrid, FitSpaceDer, CovariancePlaneDer>;
using HybridScaleSpaceDiff = BasketDiff<Hybrid, FitScaleSpaceDer, CovariancePlaneDer>;

//! [BasketAutoDiff]
using AutoDiff = BasketAutoDiff<Point, WeightFunc, FitScaleDer, AutoDiffExt>;
//! [BasketAutoDiff]

KdTree<Point>tree;
Scalar scale = generateData(tree);

Expand Down
Loading