stan-dev / stan-dev/math

Create symmetric positive definite Toeplitz matrix type

Open
#356 4 comments 0 reactions 1 assignee View on GitHub

@rtrangucci is already working on this.

Since Aug 17, 2016.

feature new function
Dominant language
C++
Stars
839
Forks
220
Avg merge
2d 4h
Merged PRs (30d)
14

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.