Open
Description
Summary:
Introduce SPD Toeplitz matrix type to math library.
Description:
Implementation details:
#include <stan/math/prim/scal/err/check_less_or_equal.hpp>
template <typename T>
class spd_toeplitz {
const Eigen::Matrix<T, Eigen::Dynamic, 1> band_vals_;
const int non_zero_dim_;
const int dim_;
spd_toeplitz(Eigen::Matrix<T, Eigen::Dynamic, 1> band_vals, int dim)
: {
check_less_or_equal("Size of band values",
"Toeplitz row and column dimensions",
band_vals.size(), dim);
dim_(dim);
non_zero_dim_(band_vals.size());
for (int i = 0; i < non_zero_dim_; ++i)
band_vals_.coeffRef(i) = band_vals.coeffRef(i);
// Illustrative purposes only
// We won't need to store the zeros explicitly,
// but we will need the size of the non-zero
// entries
for (int i = non_zero_dim_; i < dim_; ++i)
band_vals_.coeffRef(i) = 0;
}
var& operator()(int i) {
check_bounded("Row index", "non-zero entries", i, 0, non_zero_dim_);
return band_vals_.coeffRef(ind);
}
};
When vals_.size() < dim
, only fill bands corresponding to implied non-zero entries in the matrix.
Current Version:
v2.11.0