Stan  1.0
probability, sampling & optimization
Public Member Functions | List of all members
stan::io::csv_writer Class Reference

Writes Stan variables in comma-separated-value format to an output stream. More...

#include <csv_writer.hpp>

Public Member Functions

void comma ()
 Write a comma. More...
 
 csv_writer (std::ostream &o)
 Construct a CSV writer that writes to the specified output stream. More...
 
void newline ()
 Write a newline character. More...
 
void write (int n)
 Write a value. More...
 
void write (double x)
 Write a value. More...
 
void write (const Eigen::Matrix< double, Eigen::Dynamic, 1 > &v)
 Write a value. More...
 
void write (const Eigen::Matrix< double, 1, Eigen::Dynamic > &rv)
 Write a value. More...
 
void write (const Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > &m)
 Write a value. More...
 
void write_col_major (const Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > &m)
 Write a value in column-major order. More...
 
void write (const std::string &s)
 Write a value. More...
 

Detailed Description

Writes Stan variables in comma-separated-value format to an output stream.

All output is written to the same line and separated by commas. Use the newline() method to advance to the next line of CSV output.

Definition at line 19 of file csv_writer.hpp.

Constructor & Destructor Documentation

◆ csv_writer()

stan::io::csv_writer::csv_writer ( std::ostream &  o)
inline

Construct a CSV writer that writes to the specified output stream.

Parameters
oOutput stream on which to write.

Definition at line 47 of file csv_writer.hpp.

Member Function Documentation

◆ comma()

void stan::io::csv_writer::comma ( )
inline

Write a comma.

On the first call do nothing, subsequently write a comma.

Definition at line 32 of file csv_writer.hpp.

◆ newline()

void stan::io::csv_writer::newline ( )
inline

Write a newline character.

End a line of output and start a new line. This method needs to be called rather than writing a newline to the output stream because it resets the comma flag.

Definition at line 59 of file csv_writer.hpp.

◆ write() [1/6]

void stan::io::csv_writer::write ( const Eigen::Matrix< double, 1, Eigen::Dynamic > &  rv)
inline

Write a value.

Write the specified row vector to the output stream on the current line.

Parameters
rvRow vector of doubles to write.

Definition at line 112 of file csv_writer.hpp.

◆ write() [2/6]

void stan::io::csv_writer::write ( const Eigen::Matrix< double, Eigen::Dynamic, 1 > &  v)
inline

Write a value.

Write the specified vector to the output stream on the current line.

Parameters
vVector of doubles to write.

Definition at line 98 of file csv_writer.hpp.

◆ write() [3/6]

void stan::io::csv_writer::write ( const Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > &  m)
inline

Write a value.

Write the specified matrix to the output stream in row-major order.

Parameters
mMatrix to write.

Definition at line 126 of file csv_writer.hpp.

◆ write() [4/6]

void stan::io::csv_writer::write ( const std::string &  s)
inline

Write a value.

Write the specified string to the output stream with quotes around it and quotes inside escaped to double quotes.

Parameters
sString to write.

Definition at line 157 of file csv_writer.hpp.

◆ write() [5/6]

void stan::io::csv_writer::write ( double  x)
inline

Write a value.

Write the specified double to the output stream on the current line.

Parameters
xDouble to write.

Definition at line 85 of file csv_writer.hpp.

◆ write() [6/6]

void stan::io::csv_writer::write ( int  n)
inline

Write a value.

Write the specified integer to the output stream on the current line.

Parameters
nInteger to write.

Definition at line 72 of file csv_writer.hpp.

◆ write_col_major()

void stan::io::csv_writer::write_col_major ( const Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > &  m)
inline

Write a value in column-major order.

Write the specified matrix to the output stream in column-major order.

Parameters
mMatrix of doubles to write.

Definition at line 141 of file csv_writer.hpp.


The documentation for this class was generated from the following file:

     [ Stan Home Page ] © 2011–2012, Stan Development Team.