DHART
Loading...
Searching...
No Matches
HF::SpatialStructures::CSRPtrs Struct Reference

A struct to hold all necessary information for a CSR. More...

#include <graph.h>

+ Collaboration diagram for HF::SpatialStructures::CSRPtrs:

Public Member Functions

bool AreValid ()
 Verify the CSR referenced by this instance is valid. More...
 
float * CSRPtrs::data_begin () const
 Returns the base address of the data buffer More...
 
int * CSRPtrs::inner_begin () const
 Returns the address of one-past the last element within the data buffer More...
 
int * CSRPtrs::inner_end () const
 Returns the address of one-past the last element within the inner_indices buffer More...
 
int * CSRPtrs::outer_begin () const
 Returns the base address of the outer_indices buffer More...
 
int * CSRPtrs::outer_end () const
 Returns the address of one-past the last element within the outer_indices buffer More...
 
float * CSRPtrs::row_begin (int row_number) const
 Returns the address of the first non-zero element of row_number within the CSR data buffer More...
 
float * CSRPtrs::row_end (int row_number) const
 Returns the address of the first non-zero element of row_number + 1, i.e. the base address of the next row within the CSR data buffer More...
 
int * CSRPtrs::col_begin (int row_number) const
 Returns the address of the element that determines the column where the first non-zero value begins within row_number More...
 
int * CSRPtrs::col_end (int row_number) const
 Returns the address of the element that denotes the end of a 'subarray' within inner_indices More...
 

Public Attributes

int nnz
 Number of non-zeros contained by the CSR. More...
 
int rows
 Number of rows in this CSR. More...
 
int cols
 Number of columns in this CSR. More...
 
float * data
 Stores the coefficient values of the non-zeros. More...
 
int * outer_indices
 Stores for each column (resp. row) the index of the first non-zero in the previous two arrays. More...
 
int * inner_indices
 Stores the row (resp. column) indices of the non-zeros. More...
 

Detailed Description

A struct to hold all necessary information for a CSR.

Remarks
This can be used by external clients to recreate or map to an existing CSR. For more information on what these arrays contain see https://eigen.tuxfamily.org/dox/group__TutorialSparse.html

Definition at line 54 of file graph.h.

Member Function Documentation

◆ AreValid()

bool HF::SpatialStructures::CSRPtrs::AreValid ( )
inline

Verify the CSR referenced by this instance is valid.

Returns
True if data, outer_indices, and inner_indices are non-null, false otherwise,

Simply checks that all the contained arrays are not null.

Remarks
For now, this just checks if any of the arrays are null since Eigen arrays will return null pointers if they are in an invalid state (uninitialized, uncompressed, etc).
// be sure to #include "graph.h", and #include <memory>
std::unique_ptr<float[]> data(new float[16]);
std::unique_ptr<int[]> outer_indices(new int[16]);
std::unique_ptr<int[]> inner_indices(new int[16]);
float* p_data = data.get();
int* p_outer_indices = outer_indices.get();
int* p_inner_indices = inner_indices.get();
HF::SpatialStructures::CSRPtrs csr = { 16, 16, 16, p_data, p_outer_indices, p_inner_indices };
bool validity = csr.AreValid(); // validity == true, since all pointer fields are non-null
A struct to hold all necessary information for a CSR.
Definition: graph.h:54
bool AreValid()
Verify the CSR referenced by this instance is valid.
Definition: graph.h:93
int * outer_indices
Stores for each column (resp. row) the index of the first non-zero in the previous two arrays.
Definition: graph.h:60
int * inner_indices
Stores the row (resp. column) indices of the non-zeros.
Definition: graph.h:61
float * data
Stores the coefficient values of the non-zeros.
Definition: graph.h:59

Definition at line 93 of file graph.h.

References data, inner_indices, and outer_indices.

◆ CSRPtrs::col_begin()

int * HF::SpatialStructures::CSRPtrs::CSRPtrs::col_begin ( int  row_number) const
inline

Returns the address of the element that determines the column where the first non-zero value begins within row_number

Parameters
row_numberThe desired row number for the CSR such that the address returned is of the value that dictates where the first non-zero value begins within row_number
Returns
The address of the value that represents the column index of the first non-zero value within row_number
// TODO example

Definition at line 312 of file graph.h.

References inner_indices, outer_indices, and rows.

◆ CSRPtrs::col_end()

int * HF::SpatialStructures::CSRPtrs::CSRPtrs::col_end ( int  row_number) const
inline

Returns the address of the element that denotes the end of a 'subarray' within inner_indices

Parameters
row_numberThe desired row number for the CSR such that the address returned is one-past the last value for a 'subarray' within inner_indices
Returns
The address of the value that represents the column index of the first non-zero value for row_number + 1
// TODO example

Definition at line 344 of file graph.h.

References CSRPtrs::inner_end(), inner_indices, outer_indices, and rows.

+ Here is the call graph for this function:

◆ CSRPtrs::data_begin()

float * HF::SpatialStructures::CSRPtrs::CSRPtrs::data_begin ( ) const
inline

Returns the base address of the data buffer

Returns
The base address of the data buffer

If the data field has not given an address, data_begin will return nullptr.

// TODO example

Definition at line 111 of file graph.h.

References data.

◆ CSRPtrs::inner_begin()

int * HF::SpatialStructures::CSRPtrs::CSRPtrs::inner_begin ( ) const
inline

Returns the address of one-past the last element within the data buffer

Returns
The address of one-past the last element within the data buffer
\code
    // TODO example
/endcode

/ inline float* CSRPtrs::data_end() const { if (nnz > 0) { return data ? data + nnz : nullptr; }

return nullptr; }

/// /// Returns the base address of the inner_indices buffer /// ///

Returns
/// The base address of the inner_indices buffer ///

// If the inner_indices field has not been given an address, inner_begin will return nullptr.

/*!

// TODO example

Definition at line 153 of file graph.h.

References inner_indices.

◆ CSRPtrs::inner_end()

int * HF::SpatialStructures::CSRPtrs::CSRPtrs::inner_end ( ) const
inline

Returns the address of one-past the last element within the inner_indices buffer

Returns
The address of one-past the last element within the inner_indices buffer

\detials If the inner_indices field has not been given an address, and/or the nnz field has not been given a value, inner_end will return nullptr.

// TODO example

Definition at line 174 of file graph.h.

References inner_indices, and nnz.

Referenced by CSRPtrs::col_end().

+ Here is the caller graph for this function:

◆ CSRPtrs::outer_begin()

int * HF::SpatialStructures::CSRPtrs::CSRPtrs::outer_begin ( ) const
inline

Returns the base address of the outer_indices buffer

Returns
The base address of the outer_indices buffer
// TODO example

Definition at line 196 of file graph.h.

References outer_indices.

◆ CSRPtrs::outer_end()

int * HF::SpatialStructures::CSRPtrs::CSRPtrs::outer_end ( ) const
inline

Returns the address of one-past the last element within the outer_indices buffer

Returns
The address of one-past the last element within the outer_indices buffer
// TODO example

Definition at line 215 of file graph.h.

References outer_indices, and rows.

◆ CSRPtrs::row_begin()

float * HF::SpatialStructures::CSRPtrs::CSRPtrs::row_begin ( int  row_number) const
inline

Returns the address of the first non-zero element of row_number within the CSR data buffer

Parameters
row_numberThe desired row number to access within the CSR
Returns
The address of the first non-zero element within the CSR data buffer at row_number
// TODO example

Definition at line 241 of file graph.h.

References data, outer_indices, and rows.

◆ CSRPtrs::row_end()

float * HF::SpatialStructures::CSRPtrs::CSRPtrs::row_end ( int  row_number) const
inline

Returns the address of the first non-zero element of row_number + 1, i.e. the base address of the next row within the CSR data buffer

Parameters
row_numberThe desired row number for the CSR such that the address returned is the address pointing to the beginning element for the subsequent row
Returns
The address of the first non-zero element for row_number + 1 – unless row_number + 1 == csr.rows, then data_end() is returned
// TODO example

Definition at line 274 of file graph.h.

References data, outer_indices, and rows.

Member Data Documentation

◆ cols

int HF::SpatialStructures::CSRPtrs::cols

Number of columns in this CSR.

Definition at line 57 of file graph.h.

◆ data

float* HF::SpatialStructures::CSRPtrs::data

Stores the coefficient values of the non-zeros.

Definition at line 59 of file graph.h.

Referenced by AreValid(), CSRPtrs::data_begin(), CSRPtrs::row_begin(), and CSRPtrs::row_end().

◆ inner_indices

int* HF::SpatialStructures::CSRPtrs::inner_indices

Stores the row (resp. column) indices of the non-zeros.

Definition at line 61 of file graph.h.

Referenced by AreValid(), CSRPtrs::col_begin(), CSRPtrs::col_end(), CSRPtrs::inner_begin(), and CSRPtrs::inner_end().

◆ nnz

int HF::SpatialStructures::CSRPtrs::nnz

Number of non-zeros contained by the CSR.

Definition at line 55 of file graph.h.

Referenced by CSRPtrs::inner_end(), and GetCSRPointers().

◆ outer_indices

int* HF::SpatialStructures::CSRPtrs::outer_indices

Stores for each column (resp. row) the index of the first non-zero in the previous two arrays.

Definition at line 60 of file graph.h.

Referenced by AreValid(), CSRPtrs::col_begin(), CSRPtrs::col_end(), CSRPtrs::outer_begin(), CSRPtrs::outer_end(), CSRPtrs::row_begin(), and CSRPtrs::row_end().

◆ rows

int HF::SpatialStructures::CSRPtrs::rows

Number of rows in this CSR.

Definition at line 56 of file graph.h.

Referenced by CSRPtrs::col_begin(), CSRPtrs::col_end(), CSRPtrs::outer_end(), CSRPtrs::row_begin(), and CSRPtrs::row_end().


The documentation for this struct was generated from the following file: