.. _program_listing_file_src_sparsebase_format_coo.h: Program Listing for File coo.h ============================== |exhale_lsh| :ref:`Return to documentation for file ` (``src/sparsebase/format/coo.h``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp #include "sparsebase/config.h" #include "sparsebase/context/cpu_context.h" #include "sparsebase/format/format_order_two.h" #include "sparsebase/utils/exception.h" #include "sparsebase/utils/utils.h" #ifndef SPARSEBASE_PROJECT_COO_H #define SPARSEBASE_PROJECT_COO_H namespace sparsebase::format { template class COO : public utils::IdentifiableImplementation< COO, FormatOrderTwo> { public: COO(IDType n, IDType m, NNZType nnz, IDType *row, IDType *col, ValueType *vals, Ownership own = kNotOwned, bool ignore_sort = false); COO(const COO &); COO(COO &&); COO &operator=( const COO &); Format *Clone() const override; virtual ~COO(); IDType *get_col() const; IDType *get_row() const; ValueType *get_vals() const; IDType *release_col(); IDType *release_row(); ValueType *release_vals(); void set_row(IDType *, Ownership own = kNotOwned); void set_col(IDType *, Ownership own = kNotOwned); void set_vals(ValueType *, Ownership own = kNotOwned); virtual bool RowIsOwned(); virtual bool ColIsOwned(); virtual bool ValsIsOwned(); protected: std::unique_ptr> col_; std::unique_ptr> row_; std::unique_ptr> vals_; }; template template struct format::FormatOrderTwo::TypeConverter< COO, ToIDType, ToNNZType, ToValueType> { COO *operator()( FormatOrderTwo *source, bool is_move_conversion) { COO *coo = source->template As(); auto dims = coo->get_dimensions(); auto num_nnz = coo->get_num_nnz(); ToIDType *new_col; ToIDType *new_row; ToValueType *new_vals; if (!is_move_conversion || !std::is_same_v) { new_col = utils::ConvertArrayType(coo->get_col(), num_nnz); } else { if constexpr (std::is_same_v) { new_col = coo->release_col(); } } if (!is_move_conversion || !std::is_same_v) { new_row = utils::ConvertArrayType(coo->get_row(), num_nnz); } else { if constexpr (std::is_same_v) { new_row = coo->release_row(); } } if (!is_move_conversion || !std::is_same_v) { new_vals = utils::ConvertArrayType(coo->get_vals(), num_nnz); } else { if constexpr (std::is_same_v) { new_vals = coo->release_vals(); } } return new COO( dims[0], dims[1], num_nnz, new_row, new_col, new_vals, kOwned); } }; } // namespace sparsebase::format #ifdef _HEADER_ONLY #include "coo.cc" #endif #endif // SPARSEBASE_PROJECT_COO_H