Matrix

Defined in matrix.hpp

template<class Label = uint32_t, class Ordinal = Label, class LabelStorage = Label*, class OrdinalStorage = Ordinal*, bool weighted = false, class Weight = float, class WeightStorage = Weight*>
class SymMatrix : public pigo::CSR<uint32_t, uint32_t, uint32_t*, uint32_t*, false, float, float*>

Used to load symmetric matrices from disk.

This class provides a matrix-specific naming on top of CSRs.

tparam Label

the label data type. This type needs to be able to support the largest value read inside of the Matrix.

tparam Ordinal

the ordinal data type. This type needs to support large enough values to hold the number of non-zeros in the Matrix. It defaults to Label.

tparam LabelStorage

the storage type of the endpoints of the CSR. This can either be vector (std::vector<Label>), a pointer (Label*), or a shared_ptr (std::shared_ptr<Label>).

tparam OrdinalStorage

the storage type of the offsets of the CSR. This can either be vector (std::vector<Ordinal>), a pointer (Ordinal*), or a shared_ptr (std::shared_ptr<Ordinal>).

tparam weighted

if true, support and use weights

tparam Weight

the weight data type.

tparam WeightStorage

the storage type for the weights. This can be a raw pointer (Weight*), a std::vector (std::vector<Weight>), or a std::shared_ptr<Weight>.

template<class Label = uint32_t, class Ordinal = Label, class LabelStorage = Label*, class OrdinalStorage = Ordinal*, bool weighted = false, class Weight = float, class WeightStorage = Weight*>
class pigo::Matrix

Used to hold regular (non-symmetric) matrices.

This contains both a CSR and a CSC

tparam Label

the label data type. This type needs to be able to support the largest value read inside of the Matrix.

tparam Ordinal

the ordinal data type. This type needs to support large enough values to hold the number of non-zeros in the Matrix. It defaults to Label.

tparam LabelStorage

the storage type of the endpoints of the CSR/CSC. This can either be vector (std::vector<Label>), a pointer (Label*), or a shared_ptr (std::shared_ptr<Label>).

tparam OrdinalStorage

the storage type of the offsets of the CSR/CSC. This can either be vector (std::vector<Ordinal>), a pointer (Ordinal*), or a shared_ptr (std::shared_ptr<Ordinal>).

tparam weighted

if true, support and use weights

tparam Weight

the weight data type.

tparam WeightStorage

the storage type for the weights. This can be a raw pointer (Weight*), a std::vector (std::vector<Weight>), or a std::shared_ptr<Weight>.

Public Functions

template<class COOLabel, class COOOrdinal, class COOStorage, bool COOsym, bool COOut, bool COOsl, class COOW, class COOWS>
inline Matrix(COO<COOLabel, COOOrdinal, COOStorage, COOsym, COOut, COOsl, weighted, COOW, COOWS> &coo)

Initialize from a COO.

This creates a Matrix from an already-loaded COO.

This first copies the COO and transposes the copy, setting that as the CSC.

Template Parameters
  • COOLabel – the label for the COO format

  • COOOrdinal – the ordinal for the COO format

  • COOStorage – the storage format of the COO

  • COOsym – whether the COO is symmetrized

  • COOut – whether the COO only keeps the upper triangle

  • COOsl – whether the COO removes self loops

  • COOW – the weight type of the COO

  • COOWS – the weight storage type of the COO

Parameters

coo – the COO object to load the CSR from

inline Matrix(std::string filename)

Build a Matrix from a file.

Parameters

filename – the file to read and load

inline void free()

Free the associated memory.

inline Ordinal nrows()

Return the number of rows.

inline Ordinal ncols()

Return the number of columns.

inline CSR<Label, Ordinal, LabelStorage, OrdinalStorage, weighted, Weight, WeightStorage> &csr()

Return the CSR.

inline CSC<Label, Ordinal, LabelStorage, OrdinalStorage, weighted, Weight, WeightStorage> &csc()

Return the CSC.