GEOS 3.15.0dev
Public Member Functions | Static Public Member Functions | List of all members
geos::algorithm::distance::DiscreteFrechetDistance::CsrMatrix Class Reference

#include <DiscreteFrechetDistance.h>

Inheritance diagram for geos::algorithm::distance::DiscreteFrechetDistance::CsrMatrix:
geos::algorithm::distance::DiscreteFrechetDistance::MatrixStorage

Public Member Functions

 CsrMatrix (std::size_t numRows, std::size_t numCols, double defaultValue, std::size_t expectedValues)
 
 CsrMatrix (std::size_t numRows, std::size_t numCols, double defaultValue)
 
std::pair< bool, std::size_t > cppBinarySearch (const std::vector< std::size_t > &vec, std::size_t fromIndex, std::size_t toIndex, std::size_t key) const
 
std::pair< bool, std::size_t > indexOf (std::size_t i, std::size_t j) const
 
double get (std::size_t i, std::size_t j) const override
 
void set (std::size_t i, std::size_t j, double value) override
 
bool isValueSet (std::size_t i, std::size_t j) const override
 
void ensureCapacity (std::size_t required)
 
- Public Member Functions inherited from geos::algorithm::distance::DiscreteFrechetDistance::MatrixStorage
 MatrixStorage (std::size_t numRows, std::size_t numCols, double defaultValue)
 

Static Public Member Functions

static std::size_t expectedValuesHeuristic (std::size_t numRows, std::size_t numCols)
 

Additional Inherited Members

- Public Attributes inherited from geos::algorithm::distance::DiscreteFrechetDistance::MatrixStorage
std::size_t m_numRows
 
std::size_t m_numCols
 
double m_defaultValue
 

Detailed Description

A matrix implementation that adheres to the Compressed sparse row format. Note: Unfortunately not as fast as hoped.

Member Function Documentation

◆ cppBinarySearch()

std::pair< bool, std::size_t > geos::algorithm::distance::DiscreteFrechetDistance::CsrMatrix::cppBinarySearch ( const std::vector< std::size_t > &  vec,
std::size_t  fromIndex,
std::size_t  toIndex,
std::size_t  key 
) const
inline

A work-alike for Java Arrays.binarySearch(), used for searching ordered arrays. This variant searches for the key value within a bounded subset of the array.

Parameters
vecthe vector to search
fromIndexthe lower bound index for the search
toIndexthe upper bound index for the search
keythe value to hunt for
Returns
a pair with the first item being true if the key was found and false otherwise, and the second being the index of the key found, or the insertion point of the key if not found

◆ ensureCapacity()

void geos::algorithm::distance::DiscreteFrechetDistance::CsrMatrix::ensureCapacity ( std::size_t  required)
inline

Ensures that the column index vector (m_ci) and value vector (m_v) are sufficiently large.

Parameters
requiredthe number of items to store in the matrix

◆ expectedValuesHeuristic()

static std::size_t geos::algorithm::distance::DiscreteFrechetDistance::CsrMatrix::expectedValuesHeuristic ( std::size_t  numRows,
std::size_t  numCols 
)
inlinestatic

Computes an initial value for the number of expected values

Parameters
numRowsthe number of rows
numColsthe number of columns
Returns
the expected number of values in the sparse matrix

◆ get()

double geos::algorithm::distance::DiscreteFrechetDistance::CsrMatrix::get ( std::size_t  i,
std::size_t  j 
) const
inlineoverridevirtual

Gets the matrix value at i, j

Parameters
ithe row index
jthe column index
Returns
The matrix value at i, j

Implements geos::algorithm::distance::DiscreteFrechetDistance::MatrixStorage.

◆ isValueSet()

bool geos::algorithm::distance::DiscreteFrechetDistance::CsrMatrix::isValueSet ( std::size_t  i,
std::size_t  j 
) const
inlineoverridevirtual

Gets a flag indicating if the matrix has a set value, e.g. one that is different than MatrixStorage defaultValue.

Parameters
ithe row index
jthe column index
Returns
a flag indicating if the matrix has a set value

Implements geos::algorithm::distance::DiscreteFrechetDistance::MatrixStorage.

◆ set()

void geos::algorithm::distance::DiscreteFrechetDistance::CsrMatrix::set ( std::size_t  i,
std::size_t  j,
double  value 
)
inlineoverridevirtual

Sets the matrix value at i, j

Parameters
ithe row index
jthe column index
valueThe matrix value to set at i, j

Implements geos::algorithm::distance::DiscreteFrechetDistance::MatrixStorage.


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