24 return cyclic ? points_num : points_num - 1;
53 const int last_src_index =
src.size() - 1;
57 const int prev_index = indices[i];
58 const float factor = factors[i];
59 const bool is_cyclic_case = prev_index == last_src_index;
61 dst[dst_mask[i]] = math::interpolate(src.last(), src.first(), factor);
64 dst[dst_mask[i]] = math::interpolate(src[prev_index], src[prev_index + 1], factor);
83 int segment_index = -1;
98 const float sample_length,
104 const Span<float> lengths = accumulated_segment_lengths;
110 if (hint !=
nullptr && hint->segment_index >= 0) {
111 const float length_in_segment = sample_length - hint->segment_start;
112 const float factor = length_in_segment * hint->segment_length_inv;
113 if (factor >= 0.0f && factor < 1.0f) {
114 r_segment_index = hint->segment_index;
120 const float total_length = lengths.
last();
121 if (sample_length >= total_length) {
123 r_segment_index = lengths.
size() - 1;
128 const int prev_point_index = std::upper_bound(lengths.
begin(), lengths.
end(), sample_length) -
130 const float segment_start = prev_point_index == 0 ? 0.0f : lengths[prev_point_index - 1];
131 const float segment_end = lengths[prev_point_index];
132 const float segment_length = segment_end - segment_start;
134 const float length_in_segment = sample_length - segment_start;
135 const float factor = length_in_segment * segment_length_inv;
137 r_segment_index = prev_point_index;
140 if (hint !=
nullptr) {
141 hint->segment_index = r_segment_index;
142 hint->segment_start = segment_start;
143 hint->segment_length_inv = segment_length_inv;
157 bool include_last_point,
void to_best_mask_type(const Fn &fn) const
constexpr int64_t size() const
constexpr T & last(const int64_t n=0) const
constexpr IndexRange index_range() const
constexpr const T & first() const
constexpr const T & last(const int64_t n=0) const
constexpr int64_t size() const
constexpr const T * end() const
constexpr const T * begin() const
SyclQueue void void * src
ccl_gpu_kernel_postfix int ccl_global int * indices
int segments_num(const int points_num, const bool cyclic)
void accumulate_lengths(const Span< T > values, const bool cyclic, MutableSpan< float > lengths)
void interpolate_to_masked(const Span< T > src, const Span< int > indices, const Span< float > factors, const IndexMask dst_mask, MutableSpan< T > dst)
void sample_at_lengths(Span< float > accumulated_segment_lengths, Span< float > sample_lengths, MutableSpan< int > r_segment_indices, MutableSpan< float > r_factors)
void sample_at_length(const Span< float > accumulated_segment_lengths, const float sample_length, int &r_segment_index, float &r_factor, SampleSegmentHint *hint=nullptr)
void interpolate(const Span< T > src, const Span< int > indices, const Span< float > factors, MutableSpan< T > dst)
void sample_uniform(Span< float > accumulated_segment_lengths, bool include_last_point, MutableSpan< int > r_segment_indices, MutableSpan< float > r_factors)
T length(const vec_base< T, Size > &a)
T distance(const T &a, const T &b)
T safe_divide(const T &a, const T &b)