Bertini 2 - C++ Core
Software for Numerical Algebraic Geometry
Loading...
Searching...
No Matches
utility.hpp File Reference

utilities for start system code. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

template<typename T>
std::vector< T > bertini::IndexToSubscript (T index, std::vector< T > const &dimensions)
 Convert a zero-based index to a zero-based subscript vector.
 

Detailed Description

utilities for start system code.

Function Documentation

◆ IndexToSubscript()

template<typename T>
std::vector< T > bertini::IndexToSubscript ( T index,
std::vector< T > const & dimensions )

Convert a zero-based index to a zero-based subscript vector.

Throws std::out_of_range if the index is out-of-range based on the dimensions.

This goes from front to back, top to bottom. So

[0 2 4 [(0,0) (0,1) (0,2) 1 3 5] (1,0) (1,1) (1,2)]

etc for higher-dimensional arrays. The functionality here is identical to that of Matlab's analagous call.

Parameters
indexThe index you want to convert.
dimensionsThe dimensions of the object you are subscripting or indexing into.
Returns
A vector containing the subscripts for the input index.
Exceptions
std::out_of_range,ifthe index is impossible to convert.