Class Format

Inheritance Relationships

Base Type

Derived Type

Class Documentation

class sparsebase::format::Format : public sparsebase::utils::Identifiable

Base class representing a Sparse Data Format (like CSR, COO etc.)

Format is base class representing a Sparse Data Format. All Sparse Data Format Objects (like CSR and COO) are derived from Format. Most of the library uses Format pointers as input and output. By itself Format has very little functionality besides giving size information. Often a user will have to use the AsAbsolute() function to convert it to a concrete format.

Subclassed by sparsebase::format::FormatImplementation

Public Functions

virtual ~Format() = default

Returns a type identifier for the concrete format class.

Returns

A type_index object from the standard C++ library that represents the type of the underlying concrete object. For example, a CSR and a COO object will have different identifiers. But also, objects of the same class with varying template types (like CSR<int,int,int> and CSR<int,int,float) will also have different identifiers.

virtual Format *Clone() const = 0

Performs a deep copy of the Format object and returns the pointer to the newly created object

virtual std::vector<DimensionType> get_dimensions() const = 0

Returns the sizes of all dimensions as a vector.

virtual DimensionType get_num_nnz() const = 0

Returns the number of non-zero elements stored.

virtual DimensionType get_order() const = 0

Returns the number of dimensions.

virtual context::Context *get_context() const = 0

Returns the context for the format instance.

virtual std::type_index get_id() const = 0

Returns the type_index for the context for the format instance.

virtual std::shared_ptr<converter::Converter const> get_converter() const = 0

Returns a pointer at the converter of this format instance.

template<typename T>
inline std::remove_pointer<T>::type *AsAbsolute()

Sets a new converter for this format instance.

Templated function that can be used to cast to a concrete format class

Template Parameters

T – a concrete format class (for example: CSR<int,int,int>)

Returns

A concrete format pointer to this object (for example: CSR<int,int,int>*)

template<template<typename...> typename T>
inline void *AsAbsolute()
template<typename T>
inline bool IsAbsolute()

Templated function that can be used to check the concrete type of this object

Template Parameters

T – a concrete format class (for example: CSR<int,int,int>)

Returns

true if the type of this object is T