Skip to content

Commit

Permalink
add signatures for blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveBronder committed Jan 5, 2024
1 parent 6e7c832 commit ed0449a
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/stan/callbacks/unique_stream_writer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,39 @@ class unique_stream_writer final : public writer {
", ", "", "", "\n", "", "");
*output_ << values.transpose().format(CommaInitFmt);
}
/**
* Writes a set of values in csv format followed by a newline.
*
* Note: the precision of the output is determined by the settings
* of the stream on construction.
*
* @param[in] v Values in a block representing an Eigen column vector
*/
virtual void operator()(const Eigen::Block<Eigen::Matrix<double, -1, -1>, -1, 1, true>) {
if (output_ == nullptr)
return;
Eigen::IOFormat CommaInitFmt(Eigen::StreamPrecision, Eigen::DontAlignCols,
", ", "", "", "\n", "", "");
*output_ << values.transpose().format(CommaInitFmt);
}

/**
* Writes a set of values in csv format followed by a newline.
*
* Note: the precision of the output is determined by the settings
* of the stream on construction.
*
* @param[in] v Values in a block representing an Eigen row vector
*/
virtual void operator()(const Eigen::Block<Eigen::Matrix<double, -1, -1>, 1, -1, true>) {
if (output_ == nullptr)
return;
Eigen::IOFormat CommaInitFmt(Eigen::StreamPrecision, Eigen::DontAlignCols,
", ", "", "", "\n", "", "");
*output_ << values.format(CommaInitFmt);

}


/**
* Writes the comment_prefix to the stream followed by a newline.
Expand Down
21 changes: 21 additions & 0 deletions src/stan/callbacks/writer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,27 @@ class writer {
* @param[in] v Values in an Eigen row vector
*/
virtual void operator()(const Eigen::Matrix<double, 1, -1>& values) {}

/**
* Writes a set of values in csv format followed by a newline.
*
* Note: the precision of the output is determined by the settings
* of the stream on construction.
*
* @param[in] v Values in a block representing an Eigen column vector
*/
virtual void operator()(const Eigen::Block<Eigen::Matrix<double, -1, -1>, -1, 1, true>) {}

/**
* Writes a set of values in csv format followed by a newline.
*
* Note: the precision of the output is determined by the settings
* of the stream on construction.
*
* @param[in] v Values in a block representing an Eigen row vector
*/
virtual void operator()(const Eigen::Block<Eigen::Matrix<double, -1, -1>, 1, -1, true>) {}

};

} // namespace callbacks
Expand Down

0 comments on commit ed0449a

Please sign in to comment.