86template <
unsigned NDim>
class MultiHistogram;
90class PrincipalProjection;
95template <
int INDEX>
class DataArg;
98template <
int INDEX>
class CoordArg;
145template <
class A>
class Coord;
147template <
class A>
class CoordWeighted;
148template <
class A>
class DataFromHandle;
151template <
class A>
class Central;
155template <
class A>
class Whitened;
157template <
class A>
class Global;
246namespace acc_detail {
257struct Error___Tag_modifiers_of_same_kind_must_not_be_combined;
260template <class A, class S=typename acc_detail::ModifierRule<A>::type>
263 typedef typename StandardizeTag<S>::type type;
268struct StandardizeTag<A, A>
274template <
class A,
class B>
275struct StandardizeTag<A, Error___Tag_modifiers_of_same_kind_must_not_be_combined<B> >
276 :
public Error___Tag_modifiers_of_same_kind_must_not_be_combined<B>
279namespace acc_detail {
283enum { MinPriority = 1,
284 AccumulatorPriority = 32,
285 PrepareDataPriority = 16,
286 NormalizePriority = 8,
287 AccessDataPriority = 4,
288 WeightingPriority = 2,
291 SubstitutionMask = PrepareDataPriority | AccessDataPriority | WeightingPriority | GlobalPriority };
294struct ModifierPriority
296 static const int value = AccumulatorPriority;
299#define VIGRA_MODIFIER_PRIORITY(MODIFIER, VALUE) \
301struct ModifierPriority<MODIFIER<A> > \
303 static const int value = VALUE; \
306VIGRA_MODIFIER_PRIORITY(Global, GlobalPriority)
308VIGRA_MODIFIER_PRIORITY(Weighted, WeightingPriority)
310VIGRA_MODIFIER_PRIORITY(Coord, AccessDataPriority)
311VIGRA_MODIFIER_PRIORITY(DataFromHandle, AccessDataPriority)
313VIGRA_MODIFIER_PRIORITY(DivideByCount, NormalizePriority)
314VIGRA_MODIFIER_PRIORITY(RootDivideByCount, NormalizePriority)
315VIGRA_MODIFIER_PRIORITY(DivideUnbiased, NormalizePriority)
316VIGRA_MODIFIER_PRIORITY(RootDivideUnbiased, NormalizePriority)
318VIGRA_MODIFIER_PRIORITY(Central, PrepareDataPriority)
319VIGRA_MODIFIER_PRIORITY(Principal, PrepareDataPriority)
320VIGRA_MODIFIER_PRIORITY(Whitened, PrepareDataPriority)
323VIGRA_MODIFIER_PRIORITY(StandardQuantiles, AccumulatorPriority)
325#undef VIGRA_MODIFIER_PRIORITY
328template <class A, int TARGET_PRIORITY, int PRIORITY=ModifierPriority<A>::value>
329struct HasModifierPriority
331 typedef VigraFalseType type;
332 static const bool value =
false;
335template <
class A,
int TARGET_PRIORITY>
336struct HasModifierPriority<A, TARGET_PRIORITY, TARGET_PRIORITY>
338 typedef VigraTrueType type;
339 static const bool value =
true;
342template <
class A,
template <
class>
class B,
int TARGET_PRIORITY,
int PRIORITY>
343struct HasModifierPriority<B<A>, TARGET_PRIORITY, PRIORITY>
344:
public HasModifierPriority<A, TARGET_PRIORITY>
347template <
class A,
template <
class>
class B,
int TARGET_PRIORITY>
348struct HasModifierPriority<B<A>, TARGET_PRIORITY, TARGET_PRIORITY>
350 typedef VigraTrueType type;
351 static const bool value =
true;
355template <
class A,
class B>
356struct ModifierCompare
358 static const int p1 = ModifierPriority<A>::value;
359 static const int p2 = ModifierPriority<B>::value;
360 static const int value = p1 < p2
368struct ModifierCompareToInner;
370template <
class A,
template <
class>
class B>
371struct ModifierCompareToInner<B<A> >
372:
public ModifierCompare<B<A>, A>
376template <class A, int compare=ModifierCompareToInner<A>::value>
381struct ModifierOrder<A, -1>
387template <
class A,
template <
class>
class B,
template <
class>
class C>
388struct ModifierOrder<C<B<A> >, 0>
390 typedef Error___Tag_modifiers_of_same_kind_must_not_be_combined<C<B<A> > > type;
394template <
class A,
template <
class>
class B,
template <
class>
class C>
395struct ModifierOrder<C<B<A> >, 1>
397 typedef B<C<A> > type;
400#define VIGRA_CLEANUP_DATA_PREPARATION_MODIFIERS(OUTER, INNER, RESULT) \
402struct ModifierOrder<OUTER<INNER<A > >, 0> \
404 typedef RESULT<A > type; \
408VIGRA_CLEANUP_DATA_PREPARATION_MODIFIERS(Central, Central, Central)
409VIGRA_CLEANUP_DATA_PREPARATION_MODIFIERS(Principal, Principal, Principal)
410VIGRA_CLEANUP_DATA_PREPARATION_MODIFIERS(Whitened, Whitened, Whitened)
413VIGRA_CLEANUP_DATA_PREPARATION_MODIFIERS(Principal, Central, Principal)
414VIGRA_CLEANUP_DATA_PREPARATION_MODIFIERS(Whitened, Central, Whitened)
415VIGRA_CLEANUP_DATA_PREPARATION_MODIFIERS(Whitened, Principal, Whitened)
418VIGRA_CLEANUP_DATA_PREPARATION_MODIFIERS(DataFromHandle, Coord, Coord)
420#undef VIGRA_CLEANUP_DATA_PREPARATION_MODIFIERS
423template <
class A,
template <
class>
class B>
424struct ModifierRule<B<B<A> > >
429template <class A, int PRIORITY=ModifierPriority<A>::value>
430struct RecurseModifier;
432template <
class A,
template <
class>
class B,
int PRIORITY>
433struct RecurseModifier<B<A>, PRIORITY>
435 typedef typename ModifierOrder<B<typename StandardizeTag<A>::type> >::type type;
438template <
class A,
template <
class>
class B>
439struct RecurseModifier<B<A>, AccumulatorPriority>
447template <
class A,
template <
class>
class B>
448struct ModifierRule<B<A> >
449:
public RecurseModifier<B<A> >
455#define VIGRA_REDUCE_MODFIER(TEMPLATE, SOURCE, TARGET) \
456template <TEMPLATE > \
457struct ModifierRule<SOURCE > \
459 typedef TARGET type; \
465VIGRA_REDUCE_MODFIER(VIGRA_VOID, Central<CoordinateSystem>, CoordinateSystem)
467VIGRA_REDUCE_MODFIER(VIGRA_VOID, Whitened<CoordinateSystem>, Principal<CoordinateSystem>)
470VIGRA_REDUCE_MODFIER(template <class>
class A, A<Count>,
Count)
471VIGRA_REDUCE_MODFIER(VIGRA_VOID, Weighted<Count>, Weighted<Count>)
472VIGRA_REDUCE_MODFIER(VIGRA_VOID, CoordWeighted<Count>, Weighted<Count>)
473VIGRA_REDUCE_MODFIER(VIGRA_VOID, Global<Count>, Global<Count>)
476VIGRA_REDUCE_MODFIER(
unsigned N, Moment<N>, DivideByCount<PowerSum<N> >)
477VIGRA_REDUCE_MODFIER(
unsigned N, CentralMoment<N>, DivideByCount<Central<PowerSum<N> > >)
478VIGRA_REDUCE_MODFIER(class A, CoordWeighted<A>, Weighted<Coord<A> >)
481VIGRA_REDUCE_MODFIER(VIGRA_VOID, Central<Centralize>, Centralize)
482VIGRA_REDUCE_MODFIER(VIGRA_VOID, Central<Skewness>, Skewness)
483VIGRA_REDUCE_MODFIER(VIGRA_VOID, Central<Kurtosis>, Kurtosis)
484VIGRA_REDUCE_MODFIER(VIGRA_VOID, Central<FlatScatterMatrix>, FlatScatterMatrix)
485VIGRA_REDUCE_MODFIER(VIGRA_VOID, Central<ScatterMatrixEigensystem>, ScatterMatrixEigensystem)
487VIGRA_REDUCE_MODFIER(VIGRA_VOID, Principal<Centralize>, PrincipalProjection)
488VIGRA_REDUCE_MODFIER(VIGRA_VOID, Whitened<Centralize>, Whiten)
489VIGRA_REDUCE_MODFIER(VIGRA_VOID, Principal<PrincipalProjection>, PrincipalProjection)
490VIGRA_REDUCE_MODFIER(VIGRA_VOID, Whitened<PrincipalProjection>, Whiten)
491VIGRA_REDUCE_MODFIER(VIGRA_VOID, Whitened<Whiten>, Whiten)
494VIGRA_REDUCE_MODFIER(template <class> class A, A<RegionContour>, RegionContour)
496VIGRA_REDUCE_MODFIER(template <class>
class A, A<ConvexHull>, ConvexHull)
497VIGRA_REDUCE_MODFIER(template <class>
class A, A<ConvexHullFeatures>, ConvexHullFeatures)
499VIGRA_REDUCE_MODFIER(template <class>
class A, A<RegionPerimeter>, RegionPerimeter)
500VIGRA_REDUCE_MODFIER(template <class>
class A, A<RegionCircularity>, RegionCircularity)
501VIGRA_REDUCE_MODFIER(template <class>
class A, A<RegionEccentricity>, RegionEccentricity)
502VIGRA_REDUCE_MODFIER(VIGRA_VOID, Weighted<RegionEccentricity>, Weighted<RegionEccentricity>)
506struct ModifierRule<AbsPowerSum<N> >
508 typedef typename IfBool<(N % 2 == 0), PowerSum<N>, AbsPowerSum<N> >::type type;
512#undef VIGRA_REDUCE_MODFIER
515struct ShouldBeWeighted
517 typedef VigraFalseType type;
518 static const bool value =
false;
522struct ShouldBeWeighted<ArgMinWeight>
524 typedef VigraTrueType type;
525 static const bool value =
true;
529struct ShouldBeWeighted<ArgMaxWeight>
531 typedef VigraTrueType type;
532 static const bool value =
true;
535template <
class A,
template <
class>
class B>
536struct ShouldBeWeighted<B<A> >
537:
public ShouldBeWeighted<A>
543struct IsCoordinateFeature
545 typedef VigraFalseType type;
546 static const bool value =
false;
549template <
class A,
template <
class>
class B>
550struct IsCoordinateFeature<B<A> >
552 typedef typename IsCoordinateFeature<A>::type type;
553 static const bool value = IsCoordinateFeature<A>::value;
557struct IsCoordinateFeature<Coord<A> >
559 typedef VigraTrueType type;
560 static const bool value =
true;
564struct IsPrincipalFeature
566 typedef VigraFalseType type;
567 static const bool value =
false;
570template <
class A,
template <
class>
class B>
571struct IsPrincipalFeature<B<A> >
573 typedef typename IsPrincipalFeature<A>::type type;
574 static const bool value = IsPrincipalFeature<A>::value;
578struct IsPrincipalFeature<Principal<A> >
580 typedef VigraTrueType type;
581 static const bool value =
true;
585struct IsPrincipalFeature<Whitened<A> >
587 typedef VigraTrueType type;
588 static const bool value =
true;
597namespace acc_detail {
600struct DefaultModifier;
603struct ModifierPriority<DefaultModifier<A> >
605 static const int value = ModifierPriority<A>::value << 1;
608template <class A, int TargetPriority, int Priority=ModifierPriority<A>::value>
609struct InsertDefaultModifier
611 typedef DefaultModifier<
typename InsertDefaultModifier<A, (TargetPriority << 1)>::type> type;
614template <
class A,
int TargetPriority>
615struct InsertDefaultModifier<A, TargetPriority, TargetPriority>
620template <class A, int TargetPriority, int Priority=ModifierPriority<A>::value>
623template <
class A,
int TargetPriority>
624struct TagLongForm<A, TargetPriority, MaxPriority>
626 typedef typename InsertDefaultModifier<A, TargetPriority>::type type;
629template <
class A,
template <
class>
class B,
int TargetPriority>
630struct TagLongForm<B<A>, TargetPriority, MaxPriority>
632 typedef typename InsertDefaultModifier<B<A>, TargetPriority>::type type;
635template <
class A,
template <
class>
class B,
int TargetPriority,
int Priority>
636struct TagLongForm<B<A>, TargetPriority, Priority>
638 typedef typename TagLongForm<A, (Priority << 1)>::type Inner;
639 typedef typename InsertDefaultModifier<B<Inner>, TargetPriority>::type type;
642template <
class A,
template <
class>
class B,
int TargetPriority>
643struct TagLongForm<B<A>, TargetPriority, TargetPriority>
645 typedef typename TagLongForm<A, (TargetPriority << 1)>::type Inner;
646 typedef B<Inner> type;
650struct LongModifierRule
656template <class A, class S=typename LongModifierRule<A>::type>
657struct StandardizeTagLongForm
659 typedef typename StandardizeTagLongForm<S>::type type;
664struct StandardizeTagLongForm<A, A>
669template <
class A,
template <
class>
class B>
670struct LongModifierRule<B<A> >
672 typedef B<typename LongModifierRule<A>::type> type;
676struct LongModifierRule<DefaultModifier<A> >
681#define VIGRA_DROP_DATA_PREPARATION_MODIFIERS(SOURCE, TARGET) \
683struct LongModifierRule<SOURCE > \
685 typedef TARGET type; \
688VIGRA_DROP_DATA_PREPARATION_MODIFIERS(Central<Sum>,
Sum)
689VIGRA_DROP_DATA_PREPARATION_MODIFIERS(Principal<Sum>,
Sum)
690VIGRA_DROP_DATA_PREPARATION_MODIFIERS(Whitened<Sum>,
Sum)
691VIGRA_DROP_DATA_PREPARATION_MODIFIERS(Principal<FlatScatterMatrix>, FlatScatterMatrix)
692VIGRA_DROP_DATA_PREPARATION_MODIFIERS(Whitened<FlatScatterMatrix>, FlatScatterMatrix)
693VIGRA_DROP_DATA_PREPARATION_MODIFIERS(Principal<ScatterMatrixEigensystem>, ScatterMatrixEigensystem)
694VIGRA_DROP_DATA_PREPARATION_MODIFIERS(Whitened<ScatterMatrixEigensystem>, ScatterMatrixEigensystem)
696#undef VIGRA_DROP_DATA_PREPARATION_MODIFIERS
699struct CheckSubstitutionFlag
701 static const bool value = (ModifierPriority<A>::value & SubstitutionMask) != 0;
704template <
class A,
class B,
705 bool substitute=CheckSubstitutionFlag<A>::value>
706struct SubstituteModifiers;
708template <
class A,
class B>
709struct SubstituteModifiers<A, B, false>
714template <
class A,
template <
class>
class AA,
class B,
template <
class>
class BB>
715struct SubstituteModifiers<AA<A>, BB<B>, true>
717 typedef AA<typename SubstituteModifiers<A, B>::type> type;
720template <
class A,
class B,
template <
class>
class BB>
721struct SubstituteModifiers<DefaultModifier<A>, BB<B>, true>
723 typedef BB<typename SubstituteModifiers<A, B>::type> type;
726template <
class A,
template <
class>
class AA,
class B,
template <
class>
class BB>
727struct SubstituteModifiers<AA<A>, BB<B>, false>
729 typedef BB<typename SubstituteModifiers<A, B>::type> type;
734template <
class A,
class B>
735struct TransferModifiers
737 typedef typename StandardizeTag<A>::type StdA;
738 typedef typename StandardizeTag<B>::type StdB;
739 typedef typename acc_detail::TagLongForm<StdA, acc_detail::MinPriority>::type AA;
740 typedef typename acc_detail::TagLongForm<StdB, acc_detail::MinPriority>::type BB;
741 typedef typename acc_detail::SubstituteModifiers<AA, BB>::type AB;
742 typedef typename acc_detail::StandardizeTagLongForm<AB>::type StdAB;
743 typedef typename StandardizeTag<StdAB>::type type;
746template <
class A,
class HEAD,
class TAIL>
747struct TransferModifiers<A, TypeList<HEAD, TAIL> >
749 typedef TypeList<typename TransferModifiers<A, HEAD>::type,
750 typename TransferModifiers<A, TAIL>::type> type;
754struct TransferModifiers<A, void>
759template <
class TargetTag,
class A=
typename TargetTag::Dependencies>
760struct StandardizeDependencies
762:
public StandardizeDependencies<TargetTag, typename A::type>
766template <
class TargetTag,
class HEAD,
class TAIL>
767struct StandardizeDependencies<TargetTag, TypeList<HEAD, TAIL> >
769 typedef typename StandardizeTag<TargetTag>::type Target;
770 typedef typename TransferModifiers<Target, TypeList<HEAD, TAIL> >::type type;
773template <
class TargetTag>
774struct StandardizeDependencies<TargetTag, void>