28 #ifndef SPLA_TMATRIX_HPP
29 #define SPLA_TMATRIX_HPP
65 void set_label(std::string label)
override;
66 const std::string&
get_label()
const override;
80 template<
typename Decorator>
81 Decorator*
get() {
return m_storage.template get<Decorator>(); }
99 m_storage.set_dims(n_rows, n_cols);
104 return m_storage.get_n_rows();
108 return m_storage.get_n_cols();
112 return get_ttype<T>().template as<Type>();
117 m_label = std::move(label);
133 m_storage.invalidate();
135 if constexpr (std::is_same<T, T_INT>::value) m_storage.set_fill_value(value->as_int());
136 if constexpr (std::is_same<T, T_UINT>::value) m_storage.set_fill_value(value->as_uint());
137 if constexpr (std::is_same<T, T_FLOAT>::value) m_storage.set_fill_value(value->as_float());
146 auto reduce = resolve_duplicates.template cast_safe<TOpBinary<T, T, T>>();
150 get<CpuLil<T>>()->reduce = reduce->function;
152 get<CpuDok<T>>()->reduce = reduce->function;
181 auto& Ax = get<CpuDok<T>>()->Ax;
183 value = m_storage.get_fill_value();
185 if (entry != Ax.end()) {
186 value =
static_cast<int32_t
>(entry->second);
195 auto& Ax = get<CpuDok<T>>()->Ax;
197 value = m_storage.get_fill_value();
199 if (entry != Ax.end()) {
200 value =
static_cast<uint32_t
>(entry->second);
209 auto& Ax = get<CpuDok<T>>()->Ax;
211 value = m_storage.get_fill_value();
213 if (entry != Ax.end()) {
214 value =
static_cast<float>(entry->second);
226 const auto key_size =
sizeof(
uint);
227 const auto value_size =
sizeof(T);
228 const auto elements_count = keys1->get_size() / key_size;
230 if (elements_count != values->get_size() / value_size) {
233 if (elements_count * key_size != keys1->get_size()) {
236 if (elements_count * key_size != keys2->get_size()) {
243 coo.
Ai.resize(elements_count);
244 coo.
Aj.resize(elements_count);
245 coo.
Ax.resize(elements_count);
248 keys1->read(0, key_size * elements_count, coo.
Ai.data());
249 keys2->read(0, key_size * elements_count, coo.
Aj.data());
250 values->read(0, value_size * elements_count, coo.
Ax.data());
256 const auto key_size =
sizeof(
uint);
257 const auto value_size =
sizeof(T);
262 const auto elements_count = coo.
Ai.size();
264 keys1 =
MemView::make(coo.
Ai.data(), key_size * elements_count,
false);
265 keys2 =
MemView::make(coo.
Aj.data(), key_size * elements_count,
false);
266 values =
MemView::make(coo.
Ax.data(), value_size * elements_count,
false);
273 m_storage.invalidate();
303 return m_storage.is_valid(format);
308 static std::unique_ptr<StorageManagerMatrix<T>> storage_manager;
310 if (!storage_manager) {
311 storage_manager = std::make_unique<StorageManagerMatrix<T>>();
315 return storage_manager.get();
Status of library operation execution.
CPU list of coordinates matrix format.
Definition: cpu_formats.hpp:148
std::vector< uint > Aj
Definition: cpu_formats.hpp:155
std::vector< T > Ax
Definition: cpu_formats.hpp:156
std::vector< uint > Ai
Definition: cpu_formats.hpp:154
std::pair< uint, uint > Key
Definition: cpu_formats.hpp:134
CPU list-of-list matrix format for fast incremental build.
Definition: cpu_formats.hpp:107
Generalized M x N dimensional matrix object.
Definition: matrix.hpp:48
static ref_ptr< MemView > make()
Definition: memview.cpp:67
General format converter for vector or matrix decoration storage.
Definition: storage_manager.hpp:57
Storage for decorators with data of a particular vector or matrix object.
Definition: tdecoration.hpp:70
uint values
Definition: tdecoration.hpp:58
Matrix interface implementation with type information bound.
Definition: tmatrix.hpp:57
~TMatrix() override=default
Decorator * get()
Definition: tmatrix.hpp:81
T get_fill_value() const
Definition: tmatrix.hpp:88
Automates reference counting and behaves as shared smart pointer.
Definition: ref.hpp:117
ref_ptr< Type > get_type() override
Definition: tmatrix.hpp:111
TMatrix(uint n_rows, uint n_cols)
Definition: tmatrix.hpp:98
void validate_wd(FormatMatrix format)
Definition: tmatrix.hpp:290
void validate_rwd(FormatMatrix format)
Definition: tmatrix.hpp:284
bool is_valid(FormatMatrix format) const
Definition: tmatrix.hpp:302
void validate_wd(F format, Storage &storage)
Definition: storage_manager.hpp:212
static StorageManagerMatrix< T > * get_storage_manager()
Definition: tmatrix.hpp:307
void validate_rw(F format, Storage &storage)
Definition: storage_manager.hpp:128
Status get_int(uint row_id, uint col_id, int32_t &value) override
Definition: tmatrix.hpp:178
const std::string & get_label() const override
Definition: tmatrix.hpp:121
void validate_rw(FormatMatrix format)
Definition: tmatrix.hpp:278
Status set_fill_value(const ref_ptr< Scalar > &value) override
Definition: tmatrix.hpp:131
uint get_n_cols() override
Definition: tmatrix.hpp:107
Status get_uint(uint row_id, uint col_id, uint32_t &value) override
Definition: tmatrix.hpp:192
Status clear() override
Definition: tmatrix.hpp:272
Status set_int(uint row_id, uint col_id, std::int32_t value) override
Definition: tmatrix.hpp:159
Status set_uint(uint row_id, uint col_id, std::uint32_t value) override
Definition: tmatrix.hpp:165
Status get_float(uint row_id, uint col_id, float &value) override
Definition: tmatrix.hpp:206
Status read(ref_ptr< MemView > &keys1, ref_ptr< MemView > &keys2, ref_ptr< MemView > &values) override
Definition: tmatrix.hpp:255
void set_label(std::string label) override
Definition: tmatrix.hpp:116
void cpu_lil_add_element(uint row_id, uint col_id, T element, CpuLil< T > &lil)
Definition: cpu_format_lil.hpp:55
void validate_ctor(F format, Storage &storage)
Definition: storage_manager.hpp:121
void validate_rwd(F format, Storage &storage)
Definition: storage_manager.hpp:206
Status set_float(uint row_id, uint col_id, float value) override
Definition: tmatrix.hpp:171
Status set_format(FormatMatrix format) override
Definition: tmatrix.hpp:126
uint get_n_rows() override
Definition: tmatrix.hpp:103
void validate_ctor(FormatMatrix format)
Definition: tmatrix.hpp:296
Status build(const ref_ptr< MemView > &keys1, const ref_ptr< MemView > &keys2, const ref_ptr< MemView > &values) override
Definition: tmatrix.hpp:221
Status set_reduce(ref_ptr< OpBinary > resolve_duplicates) override
Definition: tmatrix.hpp:145
std::uint32_t uint
Library index and size type.
Definition: config.hpp:56
#define LOG_MSG(status, msg)
Definition: logger.hpp:66
Definition: algorithm.hpp:37
void register_formats_matrix(StorageManagerMatrix< T > &manager)
Definition: storage_manager_matrix.hpp:51