Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::matgraph_detail Namespace Reference

Functions

template<typename GT >
GT::Nodeget_node (DynArray< typename GT::Node * > &nodes, long i)
 Get node pointer from sorted node array by index.
 
template<typename GT >
GT::Nodeget_node (const DynArray< typename GT::Node * > &nodes, long i)
 Get node pointer from sorted node array by index (const version).
 
template<typename GT >
long node_index (const DynArray< typename GT::Node * > &nodes, long n, typename GT::Node *p)
 Find index of node in sorted array using binary search.
 
long index_array (long i, long j, long n) noexcept
 Convert 2D matrix indices to 1D array index.
 
long checked_index_array (long i, long j, long n)
 Validate and convert indices to linear index.
 
template<typename Entry >
Entryread_matrix (const DynArray< Entry > &mat, long i, long j, long n)
 Read matrix entry if it exists.
 
template<typename Entry >
void write_matrix (DynArray< Entry > &mat, long i, long j, long n, const Entry &entry)
 Write entry to matrix.
 

Function Documentation

◆ checked_index_array()

long Aleph::matgraph_detail::checked_index_array ( long  i,
long  j,
long  n 
)
inline

Validate and convert indices to linear index.

Parameters
iRow index
jColumn index
nMatrix dimension
Returns
Linear index
Exceptions
std::out_of_rangeif i or j >= n

Definition at line 154 of file tpl_matgraph.H.

References ah_out_of_range_error_if, index_array(), and Aleph::maps().

Referenced by Aleph::Matrix_Graph< GT, SA >::operator()(), Aleph::Ady_Mat< GT, __Entry_Type, SA >::operator()(), Aleph::Matrix_Graph< GT, SA >::operator()(), Aleph::Ady_Mat< GT, __Entry_Type, SA >::operator()(), read_matrix(), TEST(), TEST(), and write_matrix().

◆ get_node() [1/2]

template<typename GT >
GT::Node * Aleph::matgraph_detail::get_node ( const DynArray< typename GT::Node * > &  nodes,
long  i 
)
inline

Get node pointer from sorted node array by index (const version).

Template Parameters
GTGraph type
Parameters
nodesSorted array of node pointers
iIndex to retrieve
Returns
Pointer to node at index i
Exceptions
std::out_of_rangeif i >= nodes.size()

Definition at line 109 of file tpl_matgraph.H.

References ah_out_of_range_error_if, Aleph::maps(), nodes, and Aleph::HTList::size().

◆ get_node() [2/2]

template<typename GT >
GT::Node * Aleph::matgraph_detail::get_node ( DynArray< typename GT::Node * > &  nodes,
long  i 
)
inline

Get node pointer from sorted node array by index.

Template Parameters
GTGraph type
Parameters
nodesSorted array of node pointers
iIndex to retrieve
Returns
Pointer to node at index i
Exceptions
std::out_of_rangeif i >= nodes.size()

Definition at line 92 of file tpl_matgraph.H.

References ah_out_of_range_error_if, Aleph::maps(), nodes, and Aleph::HTList::size().

◆ index_array()

long Aleph::matgraph_detail::index_array ( long  i,
long  j,
long  n 
)
inlinenoexcept

◆ node_index()

template<typename GT >
long Aleph::matgraph_detail::node_index ( const DynArray< typename GT::Node * > &  nodes,
long  n,
typename GT::Node p 
)
inline

Find index of node in sorted array using binary search.

Template Parameters
GTGraph type
Parameters
nodesSorted array of node pointers
nNumber of nodes
pNode pointer to find
Returns
Index of node, or -1 if not found

Definition at line 126 of file tpl_matgraph.H.

References Aleph::binary_search(), and nodes.

◆ read_matrix()

template<typename Entry >
Entry * Aleph::matgraph_detail::read_matrix ( const DynArray< Entry > &  mat,
long  i,
long  j,
long  n 
)
inline

Read matrix entry if it exists.

Template Parameters
EntryEntry type
Parameters
matDynamic array storing matrix
iRow index
jColumn index
nMatrix dimension
Returns
Pointer to entry if exists, nullptr otherwise

Definition at line 172 of file tpl_matgraph.H.

References Aleph::DynArray< T >::access(), checked_index_array(), Aleph::DynArray< T >::exist(), and Aleph::maps().

◆ write_matrix()

template<typename Entry >
void Aleph::matgraph_detail::write_matrix ( DynArray< Entry > &  mat,
long  i,
long  j,
long  n,
const Entry entry 
)
inline

Write entry to matrix.

Template Parameters
EntryEntry type
Parameters
matDynamic array storing matrix
iRow index
jColumn index
nMatrix dimension
entryValue to write

Definition at line 191 of file tpl_matgraph.H.

References checked_index_array().