template<typename T>
vinecopulib::TriangularArray class

Triangular arrays.

A triangular array behaves like a matrix with the structure

x x x x x
x x x x
x x x
x x
x

and all other elements omitted. This structure appears naturally in the representation of a vine copula model and related algorithms. Each row corresponds to one tree in the vine, starting from the top. In each tree (=row), each column represents an edge.

For truncated vine models the last few trees are omitted. For example, a 3-truncated version of the above array contains the elements

x x x x x
x x x x
x x x

Only the elements indicated by xs are stored and can be accessed.

The data structure is templated and any type or class can be used to fill the entries (xs) of the triangular array.

Constructors, destructors, conversion operators

TriangularArray(size_t d) explicit
Construct a triangular array of dimension d.
TriangularArray(size_t d, size_t trunc_lvl)
Construct a truncated triangular array.
TriangularArray(const std::vector<std::vector<T>>& rows) explicit
Construct a truncated triangular array from nested vector.

Public functions

auto operator()(size_t row, size_t column) -> T&
Access one element of the trapezoid (writable).
auto operator()(size_t row, size_t column) const -> T
Access one element of the trapezoid (non-writable).
auto operator==(const TriangularArray<T>& rhs) const -> bool
Equality operator to compare two TriangularArray objects.
void truncate(size_t trunc_lvl)
Truncates the trapezoid. If the trapezoid is already truncated at a level less than trunc_lvl, the function does nothing.
auto get_trunc_lvl() const -> size_t
Get the truncation level of the underlying vine..
auto get_dim() const -> size_t
auto str() const -> std::string
represent triangular array as a string.

Function documentation

template<typename T>
vinecopulib::TriangularArray<T>::TriangularArray(size_t d) explicit

Construct a triangular array of dimension d.

Parameters
d The dimension of the underlying vine.

The array has d-1 columns and d-1 rows.

template<typename T>
vinecopulib::TriangularArray<T>::TriangularArray(size_t d, size_t trunc_lvl)

Construct a truncated triangular array.

Parameters
d The dimension of the vine.
trunc_lvl The truncation level.

The array has d-1 columns and min(trunc_lvl, d-1) rows.

template<typename T>
vinecopulib::TriangularArray<T>::TriangularArray(const std::vector<std::vector<T>>& rows) explicit

Construct a truncated triangular array from nested vector.

Parameters
rows A vector of rows; the length of the first row defines the dimension of the triangular array. The number of rows defines the truncation level.

An arrax of dimension d has d-1 columns and min(trunc_lvl, d-1) rows.

template<typename T>
T& vinecopulib::TriangularArray<T>::operator()(size_t row, size_t column)

Access one element of the trapezoid (writable).

Parameters
row The row level.
column The column in this row.

template<typename T>
T vinecopulib::TriangularArray<T>::operator()(size_t row, size_t column) const

Access one element of the trapezoid (non-writable).

Parameters
row The row level.
column The column in this row.

template<typename T>
bool vinecopulib::TriangularArray<T>::operator==(const TriangularArray<T>& rhs) const

Equality operator to compare two TriangularArray objects.

Parameters
rhs Right-hand-side of the equality operator.

template<typename T>
void vinecopulib::TriangularArray<T>::truncate(size_t trunc_lvl)

Truncates the trapezoid. If the trapezoid is already truncated at a level less than trunc_lvl, the function does nothing.

Parameters
trunc_lvl The truncation level.

template<typename T>
size_t vinecopulib::TriangularArray<T>::get_dim() const

Get the dimension of the underlying vine (the matrix has d-1 columns and. min(trunv_lvl, d-1) rows).