18 using auto_const_t =
typename Base::template auto_const_t<U>;
21 using SegmentVector = Eigen::Matrix<T, N, 1>;
29 MUDA_GENERIC
CDoublet(
int index,
const SegmentVector& segment)
31 , segment_value(segment)
35 const SegmentVector& segment_value;
40 int m_total_segment_count = 0;
43 int m_doublet_index_offset = 0;
44 int m_doublet_count = 0;
45 int m_total_doublet_count = 0;
48 int m_subvector_offset = 0;
49 int m_subvector_extent = 0;
52 auto_const_t<int>* m_segment_indices;
53 auto_const_t<SegmentVector>* m_segment_values;
58 int doublet_index_offset,
60 int total_doublet_count,
63 auto_const_t<int>* segment_indices,
64 auto_const_t<SegmentVector>* segment_values)
65 : m_total_segment_count(total_segment_count)
66 , m_doublet_index_offset(doublet_index_offset)
67 , m_doublet_count(doublet_count)
68 , m_total_doublet_count(total_doublet_count)
69 , m_subvector_offset(subvector_offset)
70 , m_subvector_extent(subvector_extent)
71 , m_segment_indices(segment_indices)
72 , m_segment_values(segment_values)
74 MUDA_KERNEL_ASSERT(doublet_index_offset + doublet_count <= total_doublet_count,
75 "DoubletVectorViewer: out of range, m_total_doublet_count=%d, "
76 "your doublet_index_offset=%d, doublet_count=%d",
77 m_total_doublet_count,
81 MUDA_KERNEL_ASSERT(subvector_offset + subvector_extent <= total_segment_count,
82 "DoubletVectorViewer: out of range, m_total_segment_count=%d, "
83 "your subvector_offset=%d, subvector_extent=%d",
84 m_total_segment_count,
91 MUDA_GENERIC ConstViewer as_const() const noexcept
93 return ConstViewer{m_total_segment_count,
94 m_doublet_index_offset,
96 m_total_doublet_count,
103 MUDA_GENERIC
operator ConstViewer() const noexcept {
return as_const(); }
106 MUDA_GENERIC
int doublet_count() const noexcept {
return m_doublet_count; }
107 MUDA_GENERIC
int total_doublet_count() const noexcept
109 return m_total_doublet_count;
112 MUDA_GENERIC CDoublet operator()(
int i)
const
114 auto index = get_index(i);
115 auto global_i = m_segment_indices[index];
116 auto sub_i = global_i - m_subvector_offset;
118 check_in_subvector(sub_i);
119 return CDoublet{sub_i, m_segment_values[index]};
123 MUDA_INLINE MUDA_GENERIC
int get_index(
int i)
const noexcept
125 MUDA_KERNEL_ASSERT(i >= 0 && i < m_doublet_count,
126 "DoubletVectorViewer [%s:%s]: index out of range, m_doublet_count=%d, your index=%d",
131 auto index = i + m_doublet_index_offset;
135 MUDA_INLINE MUDA_GENERIC
void check_in_subvector(
int i)
const noexcept
137 MUDA_KERNEL_ASSERT(i >= 0 && i < m_subvector_extent,
138 "DoubletVectorViewer [%s:%s]: index out of range, m_subvector_extent=%d, your index=%d",
220 template <
typename U>
221 using auto_const_t =
typename Base::template auto_const_t<U>;
230 MUDA_GENERIC CDoublet(
int index,
const T& segment)
241 int m_total_count = 0;
244 int m_doublet_index_offset = 0;
245 int m_doublet_count = 0;
246 int m_total_doublet_count = 0;
249 int m_subvector_offset = 0;
250 int m_subvector_extent = 0;
252 auto_const_t<int>* m_indices;
253 auto_const_t<T>* m_values;
258 int doublet_index_offset,
260 int total_doublet_count,
261 int subvector_offset,
262 int subvector_extent,
263 auto_const_t<int>* indices,
264 auto_const_t<T>* values)
265 : m_total_count(total_count)
266 , m_doublet_index_offset(doublet_index_offset)
267 , m_doublet_count(doublet_count)
268 , m_total_doublet_count(total_doublet_count)
272 MUDA_KERNEL_ASSERT(doublet_index_offset + doublet_count <= total_doublet_count,
273 "DoubletVectorViewer: out of range, m_total_doublet_count=%d, "
274 "your doublet_index_offset=%d, doublet_count=%d",
275 m_total_doublet_count,
276 doublet_index_offset,
279 MUDA_KERNEL_ASSERT(subvector_offset + subvector_extent <= total_count,
280 "DoubletVectorViewer: out of range, m_total_segment_count=%d, "
281 "your subvector_offset=%d, subvector_extent=%d",
289 MUDA_GENERIC ConstViewer as_const() const noexcept
291 return ConstViewer{m_total_count,
292 m_doublet_index_offset,
294 m_total_doublet_count,
301 MUDA_GENERIC
operator ConstViewer() const noexcept {
return as_const(); }
305 MUDA_GENERIC CDoublet operator()(
int i)
const
307 check_in_subvector(i);
308 auto index = get_index(i);
309 auto global_i = m_indices[index];
310 auto sub_i = global_i - m_subvector_offset;
312 return CDoublet{sub_i, m_values[index]};
315 MUDA_GENERIC
int extent() const noexcept {
return m_subvector_extent; }
316 MUDA_GENERIC
int total_extent() const noexcept {
return m_total_count; }
318 MUDA_GENERIC
int subvector_offset() const noexcept
320 return m_subvector_offset;
323 MUDA_GENERIC
int doublet_count() const noexcept {
return m_doublet_count; }
324 MUDA_GENERIC
int total_doublet_count() const noexcept
326 return m_total_doublet_count;
330 MUDA_INLINE MUDA_GENERIC
int get_index(
int i)
const noexcept
333 MUDA_KERNEL_ASSERT(i >= 0 && i < m_doublet_count,
334 "DoubletVectorViewer [%s:%s]: index out of range, m_doublet_count=%d, your index=%d",
339 auto index = i + m_doublet_index_offset;
343 MUDA_INLINE MUDA_GENERIC
void check_in_subvector(
int i)
const noexcept
345 MUDA_KERNEL_ASSERT(i >= 0 && i < m_subvector_extent,
346 "DoubletVectorViewer [%s:%s]: index out of range, m_subvector_extent=%d, your index=%d",