30 using auto_const_t =
typename Base::template auto_const_t<U>;
40 auto_const_t<T>* m_data =
nullptr;
46 MUDA_GENERIC
Dense1DT() MUDA_NOEXCEPT =
default;
48 MUDA_GENERIC
Dense1DT(auto_const_t<T>* p,
int dim) MUDA_NOEXCEPT : m_data(p),
55 template <
bool OtherIsConst>
57 MUDA_REQUIRES(!OtherIsConst)
58 : m_data(other.data())
61 static_assert(OtherIsConst,
"Only non-const viewer can be convert to const viewer");
64 MUDA_GENERIC
auto as_const()
const MUDA_NOEXCEPT
69 MUDA_GENERIC auto_const_t<T>& operator()(
int x)
const MUDA_NOEXCEPT
72 return m_data[map(x)];
75 MUDA_GENERIC auto_const_t<T>* data()
const MUDA_NOEXCEPT {
return m_data; }
77 MUDA_GENERIC
int total_size()
const MUDA_NOEXCEPT {
return m_dim; }
79 MUDA_GENERIC
int dim()
const MUDA_NOEXCEPT {
return m_dim; }
81 MUDA_GENERIC
ThisViewer subview(
int offset)
const MUDA_NOEXCEPT
83 auto size = this->m_dim - offset;
84 if constexpr(DEBUG_VIEWER)
87 MUDA_KERNEL_ERROR(
"Dense1D[%s:%s]: subview out of range, offset=%d size=%d m_dim=(%d). %s(%d)",
96 return ThisViewer{this->m_data + offset, size};
99 MUDA_GENERIC
ThisViewer subview(
int offset,
int size)
const MUDA_NOEXCEPT
101 if constexpr(DEBUG_VIEWER)
103 if(offset < 0 || offset + size > m_dim)
104 MUDA_KERNEL_ERROR(
"Dense1D[%s:%s]: subview out of range, offset=%d size=%d m_dim=(%d). %s(%d)",
111 this->kernel_line());
113 return ThisViewer{this->m_data + offset, size};
117 MUDA_INLINE MUDA_GENERIC
void check()
const MUDA_NOEXCEPT
119 if constexpr(DEBUG_VIEWER)
120 if(m_data ==
nullptr)
121 MUDA_KERNEL_ERROR(
"Dense1D[%s:%s]: m_data is null. %s(%d)",
125 this->kernel_line());
128 MUDA_GENERIC
int map(
int x)
const MUDA_NOEXCEPT
130 if constexpr(DEBUG_VIEWER)
131 if(!(x >= 0 && x < m_dim))
132 MUDA_KERNEL_ERROR(
"Dense1D[%s:%s]: out of range, index=(%d) m_dim=(%d). %s(%d)",
138 this->kernel_line());