67 #ifndef TRIANGULARMATRIX_HH 68 #define TRIANGULARMATRIX_HH 94 typedef typename std::vector<T>::size_type
size_type;
95 typedef typename std::vector<T>::reference
reference;
97 typedef typename std::vector<T>::iterator
iterator;
128 _data.resize( width*(width-1)/2, defaultVal);
129 _rowStart.resize( width-1);
130 int lineWidth =
static_cast<int>(width-2);
131 int rowStartIndex = -1;
132 for(
int i = 0; i < static_cast<int>(width - 1); ++i)
134 _rowStart[i] = rowStartIndex;
135 rowStartIndex += lineWidth;
178 return _data[_rowStart[row]+col];
192 const_reference
operator()(size_type row, size_type col)
const 194 return _data[_rowStart[row]+col];
225 const_iterator
begin()
const {
return _data.begin(); }
226 iterator
begin() {
return _data.begin(); }
227 const_iterator
end()
const {
return _data.end(); }
228 iterator
end() {
return _data.end(); }
231 std::vector<int> _rowStart;
232 std::vector<T> _data;
std::vector< T >::reference reference
const_iterator end() const
The TriangularMatrix class is an upper triangular matrix without diagonal elements.
size_type size() const
to be compatible with other standard containers
size_type nElements() const
TriangularMatrix(size_type width, const T &defaultVal=T())
std::vector< T >::iterator iterator
reference operator[](size_type index)
1dim element access, accessing data in lexicographical order (e.g.
const_iterator begin() const
std::vector< T >::const_reference const_reference
const_reference operator[](size_type index) const
void resizeWidth(size_type width, const T &defaultVal=T())
resize triangular matrix to new width.
const_reference operator()(size_type row, size_type col) const
const 2dim element access.
std::vector< T >::size_type size_type
std::vector< T >::const_iterator const_iterator
reference operator()(size_type row, size_type col)
2dim element access.