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>
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);
136 if constexpr (std::is_same<T, T_INT>::value) m_storage.set_fill_value(value->as_int());
137 if constexpr (std::is_same<T, T_UINT>::value) m_storage.set_fill_value(value->as_uint());
138 if constexpr (std::is_same<T, T_FLOAT>::value) m_storage.set_fill_value(value->as_float());
147 auto reduce = resolve_duplicates.template cast_safe<TOpBinary<T, T, T>>();
151 get<CpuLil<T>>()->reduce = reduce->function;
153 get<CpuDok<T>>()->reduce = reduce->function;
182 auto& Ax = get<CpuDok<T>>()->Ax;
184 value = m_storage.get_fill_value();
186 if (entry != Ax.end()) {
187 value =
static_cast<int32_t
>(entry->second);
196 auto& Ax = get<CpuDok<T>>()->Ax;
198 value = m_storage.get_fill_value();
200 if (entry != Ax.end()) {
201 value =
static_cast<uint32_t
>(entry->second);
210 auto& Ax = get<CpuDok<T>>()->Ax;
212 value = m_storage.get_fill_value();
214 if (entry != Ax.end()) {
215 value =
static_cast<float>(entry->second);
227 const auto key_size =
sizeof(
uint);
228 const auto value_size =
sizeof(T);
229 const auto elements_count = keys1->get_size() / key_size;
231 if (elements_count != values->get_size() / value_size) {
234 if (elements_count * key_size != keys1->get_size()) {
237 if (elements_count * key_size != keys2->get_size()) {
244 coo.
Ai.resize(elements_count);
245 coo.
Aj.resize(elements_count);
246 coo.
Ax.resize(elements_count);
249 keys1->read(0, key_size * elements_count, coo.
Ai.data());
250 keys2->read(0, key_size * elements_count, coo.
Aj.data());
251 values->read(0, value_size * elements_count, coo.
Ax.data());
257 const auto key_size =
sizeof(
uint);
258 const auto value_size =
sizeof(T);
263 const auto elements_count = coo.
Ai.size();
265 keys1 =
MemView::make(coo.
Ai.data(), key_size * elements_count,
false);
266 keys2 =
MemView::make(coo.
Aj.data(), key_size * elements_count,
false);
267 values =
MemView::make(coo.
Ax.data(), value_size * elements_count,
false);
274 m_storage.invalidate();
304 return m_storage.is_valid(format);
309 static std::unique_ptr<StorageManagerMatrix<T>> storage_manager;
311 if (!storage_manager) {
312 storage_manager = std::make_unique<StorageManagerMatrix<T>>();
316 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
void set_dims(uint n_rows, uint n_cols)
Definition tdecoration.hpp:93
uint values
Definition tdecoration.hpp:58
Matrix interface implementation with type information bound.
Definition tmatrix.hpp:57
~TMatrix() override=default
T get_fill_value() const
Definition tmatrix.hpp:88
Decorator * get()
Definition tmatrix.hpp:81
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:291
void validate_rwd(FormatMatrix format)
Definition tmatrix.hpp:285
bool is_valid(FormatMatrix format) const
Definition tmatrix.hpp:303
void validate_wd(F format, Storage &storage)
Definition storage_manager.hpp:212
static StorageManagerMatrix< T > * get_storage_manager()
Definition tmatrix.hpp:308
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:179
const std::string & get_label() const override
Definition tmatrix.hpp:121
void validate_rw(FormatMatrix format)
Definition tmatrix.hpp:279
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:193
Status clear() override
Definition tmatrix.hpp:273
Status set_int(uint row_id, uint col_id, std::int32_t value) override
Definition tmatrix.hpp:160
Status set_uint(uint row_id, uint col_id, std::uint32_t value) override
Definition tmatrix.hpp:166
Status get_float(uint row_id, uint col_id, float &value) override
Definition tmatrix.hpp:207
Status read(ref_ptr< MemView > &keys1, ref_ptr< MemView > &keys2, ref_ptr< MemView > &values) override
Definition tmatrix.hpp:256
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:172
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:297
Status build(const ref_ptr< MemView > &keys1, const ref_ptr< MemView > &keys2, const ref_ptr< MemView > &values) override
Definition tmatrix.hpp:222
Status set_reduce(ref_ptr< OpBinary > resolve_duplicates) override
Definition tmatrix.hpp:146
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