23namespace vctr::expressions
26template <
size_t extent,
class SrcType, is::rangeWithValueType<ValueType<SrcType>> RangeType>
27requires is::realFloatNumber<ValueType<SrcType>>
33 VCTR_COMMON_UNARY_EXPRESSION_MEMBERS (
Map, src)
35 void applyRuntimeArgs (RangeType newSrcRange, RangeType newDstRange)
37 srcRangeStartNegated = -newSrcRange.getStart();
38 srcDstLenRatio = newDstRange.getLength() / newSrcRange.getLength();
39 dstRangeStart = newDstRange.getStart();
42 VCTR_FORCEDINLINE
constexpr value_type operator[] (
size_t i)
const
44 return (src[i] + srcRangeStartNegated) * srcDstLenRatio + dstRangeStart;
49 VCTR_FORCEDINLINE
const value_type* evalNextVectorOpInExpressionChain (value_type* dst)
const
52 const auto s = size();
54 Expression::Accelerate::add (src.evalNextVectorOpInExpressionChain (dst), srcRangeStartNegated, dst, s);
55 Expression::Accelerate::mul (dst, srcDstLenRatio, dst, s);
56 Expression::Accelerate::add (dst, dstRangeStart, dst, s);
61 VCTR_FORCEDINLINE
const value_type* evalNextVectorOpInExpressionChain (value_type* dst)
const
64 const auto s = size();
66 Expression::IPP::add (src.evalNextVectorOpInExpressionChain (dst), srcRangeStartNegated, dst, s);
67 Expression::IPP::mul (dst, srcDstLenRatio, dst, s);
68 Expression::IPP::add (dst, dstRangeStart, dst, s);
75 value_type srcRangeStartNegated = 0;
76 value_type srcDstLenRatio = 0;
77 value_type dstRangeStart = 0;
80template <
size_t extent,
class SrcType, is::rangeWithValueType<ValueType<SrcType>> RangeType>
87 VCTR_COMMON_UNARY_EXPRESSION_MEMBERS (
MapFrom0To1, src)
89 void applyRuntimeArgs (RangeType newDstRange)
91 dstRangeStart = newDstRange.getStart();
92 dstRangeLen = newDstRange.getLength();
95 VCTR_FORCEDINLINE
constexpr value_type operator[] (
size_t i)
const
97 return src[i] * dstRangeLen + dstRangeStart;
102 VCTR_FORCEDINLINE
const value_type* evalNextVectorOpInExpressionChain (value_type* dst)
const
105 const auto s = size();
107 Expression::Accelerate::mul (src.evalNextVectorOpInExpressionChain (dst), dstRangeLen, dst, s);
108 Expression::Accelerate::add (dst, dstRangeStart, dst, s);
113 VCTR_FORCEDINLINE
const value_type* evalNextVectorOpInExpressionChain (value_type* dst)
const
116 const auto s = size();
118 Expression::IPP::mul (src.evalNextVectorOpInExpressionChain (dst), dstRangeLen, dst, s);
119 Expression::IPP::add (dst, dstRangeStart, dst, s);
126 value_type dstRangeStart = 0;
127 value_type dstRangeLen = 0;
130template <
size_t extent,
class SrcType, is::rangeWithValueType<ValueType<SrcType>> RangeType>
137 VCTR_COMMON_UNARY_EXPRESSION_MEMBERS (
MapTo0To1, src)
139 void applyRuntimeArgs (RangeType newSrcRange)
141 srcRangeStartNegated = -newSrcRange.getStart();
142 srcRangeLen = newSrcRange.getLength();
145 VCTR_FORCEDINLINE
constexpr value_type operator[] (
size_t i)
const
147 return (src[i] + srcRangeStartNegated) / srcRangeLen;
152 VCTR_FORCEDINLINE
const value_type* evalNextVectorOpInExpressionChain (value_type* dst)
const
155 const auto s = size();
157 Expression::Accelerate::add (src.evalNextVectorOpInExpressionChain (dst), srcRangeStartNegated, dst, s);
158 Expression::Accelerate::div (dst, srcRangeLen, dst, s);
163 VCTR_FORCEDINLINE
const value_type* evalNextVectorOpInExpressionChain (value_type* dst)
const
166 const auto s = size();
168 Expression::IPP::add (src.evalNextVectorOpInExpressionChain (dst), srcRangeStartNegated, dst, s);
169 Expression::IPP::div (dst, srcRangeLen, dst, s);
176 value_type srcRangeStartNegated = 0;
177 value_type srcRangeLen = 0;
191template <is::range RangeType>
192auto map (RangeType&& srcValueRange, RangeType&& dstValueRange)
194 return makeTemplateExpressionChainBuilderWithRuntimeArgs<expressions::Map, std::remove_cvref_t<RangeType>> (std::forward<RangeType> (srcValueRange), std::forward<RangeType> (dstValueRange));
203template <is::realFloatNumber T>
204auto map (T srcValueRangeStart, T srcValueRangeEnd, T dstValueRangeStart, T dstValueRangeEnd)
206 return map (
Range (srcValueRangeStart, srcValueRangeEnd),
Range (dstValueRangeStart, dstValueRangeEnd));
215template <is::range RangeType>
218 return makeTemplateExpressionChainBuilderWithRuntimeArgs<expressions::MapFrom0To1, std::remove_cvref_t<RangeType>> (std::forward<RangeType> (dstValueRange));
227template <is::realFloatNumber T>
239template <is::range RangeType>
242 return makeTemplateExpressionChainBuilderWithRuntimeArgs<expressions::MapTo0To1, std::remove_cvref_t<RangeType>> (std::forward<RangeType> (srcValueRange));
251template <is::realFloatNumber T>
252auto mapTo0To1 (T srcValueRangeStart, T srcValueRangeEnd)
A simple range class.
Definition: Range.h:32
Constrains a type to represent a real valued floating point number.
Definition: NumericTypeConcepts.h:79
A combined concept to check if Apple Accelerate is a suitable option for a real valued floating point...
Definition: ContainerAndExpressionConcepts.h:242
A combined concept to check if Intel IPP is a suitable option for a real valued floating point vector...
Definition: ContainerAndExpressionConcepts.h:266
auto mapFrom0To1(RangeType &&dstValueRange)
Maps all source element values from the range [0.0 to 1.0] to values in dstValueRange.
Definition: Map.h:216
auto mapTo0To1(RangeType &&srcValueRange)
Maps all source element values from srcValueRange to values in the range [0.0 to 1....
Definition: Map.h:240
auto map(RangeType &&srcValueRange, RangeType &&dstValueRange)
Maps all source element values from srcValueRange to values in dstValueRange.
Definition: Map.h:192
The main namespace of the VCTR project.
Definition: Array.h:24
typename detail::ValueType< std::remove_cvref_t< T > >::Type ValueType
If T is an expression template, it equals its return type, if it's a type that defines value_type as ...
Definition: Traits.h:201
The base class to every expression template.
Definition: ExpressionTemplate.h:37