.. _program_listing_file_src_sparsebase_format_csc.h: Program Listing for File csc.h ============================== |exhale_lsh| :ref:`Return to documentation for file ` (``src/sparsebase/format/csc.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_CSC_H #define SPARSEBASE_PROJECT_CSC_H namespace sparsebase::format { template class CSC : public utils::IdentifiableImplementation< CSC, FormatOrderTwo> { public: CSC(IDType n, IDType m, NNZType *col_ptr, IDType *col, ValueType *vals, Ownership own = kNotOwned, bool ignore_sort = false); CSC(const CSC &); CSC(CSC &&); CSC &operator=( const CSC &); Format *Clone() const override; virtual ~CSC(); NNZType *get_col_ptr() const; IDType *get_row() const; ValueType *get_vals() const; NNZType *release_col_ptr(); IDType *release_row(); ValueType *release_vals(); void set_col_ptr(NNZType *, Ownership own = kNotOwned); void set_row(IDType *, Ownership own = kNotOwned); void set_vals(ValueType *, Ownership own = kNotOwned); virtual bool ColPtrIsOwned(); virtual bool RowIsOwned(); virtual bool ValsIsOwned(); protected: std::unique_ptr> col_ptr_; std::unique_ptr> row_; std::unique_ptr> vals_; }; template template struct format::FormatOrderTwo::TypeConverter< CSC, ToIDType, ToNNZType, ToValueType> { CSC *operator()( FormatOrderTwo *source, bool is_move_conversion) { CSC *csc = source->template As(); auto dims = csc->get_dimensions(); auto num_nnz = csc->get_num_nnz(); ToNNZType *new_col_ptr; ToIDType *new_row; ToValueType *new_vals; if (!is_move_conversion || !std::is_same_v) { new_col_ptr = utils::ConvertArrayType(csc->get_col_ptr(), dims[0] + 1); } else { if constexpr (std::is_same_v) new_col_ptr = csc->release_col_ptr(); } if (!is_move_conversion || !std::is_same_v) { new_row = utils::ConvertArrayType(csc->get_row(), num_nnz); } else { if constexpr (std::is_same_v) new_row = csc->release_row(); } if (!is_move_conversion || !std::is_same_v) { new_vals = utils::ConvertArrayType(csc->get_vals(), num_nnz); } else { if constexpr (std::is_same_v) new_vals = csc->release_vals(); } return new CSC( dims[0], dims[1], new_col_ptr, new_row, new_vals, kOwned); } }; } // namespace sparsebase::format #ifdef _HEADER_ONLY #include "csc.cc" #endif #endif // SPARSEBASE_PROJECT_CSC_H