SG++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sgpp::optimization::Printer Class Reference

Singleton class to facilitate debugging output. More...

#include <Printer.hpp>

Public Member Functions

void disableStatusPrinting ()
 Disable the printStatus... More...
 
void enableStatusPrinting ()
 Enable the printStatus... More...
 
double getLastDurationSecs () const
 
size_t getLineLengthLimit ()
 
MutexTypegetMutex ()
 
std::ostream * getStream () const
 
int getVerbosity () const
 
bool isStatusPrintingEnabled ()
 
void printIterativeGridGenerator (const IterativeGridGenerator &gridGen) const
 Print a grid (grid points and function values). More...
 
void printSLE (SLE &system) const
 Print a system of linear equations. More...
 
void printStatusBegin (const std::string &msg)
 Call at the beginning of a time-consuming operation. More...
 
void printStatusEnd (const std::string &msg="")
 Call at the end of a time-consuming operation. More...
 
void printStatusIdentation ()
 Internal function printing the indentation. More...
 
void printStatusNewLine ()
 End the last status update and place the cursor in a newline. More...
 
void printStatusUpdate (const std::string &msg)
 Call for printing status updates on the operation. More...
 
void setLineLengthLimit (size_t lineLengthLimit)
 
void setStream (std::ostream *stream)
 
void setVerbosity (int level)
 

Static Public Member Functions

static PrintergetInstance ()
 

Static Public Attributes

static const int DEFAULT_VERBOSITY = 0
 default verbosity More...
 

Protected Attributes

bool cursorInClearLine
 is current line empty? (false if there's an old status update) More...
 
std::string indentation
 indentation More...
 
int indentationLevel
 current indentation level (can be less than statusLevel) More...
 
double lastDuration
 length of last operation in seconds More...
 
size_t lastMsgLength
 length of the last status message in characters More...
 
size_t lineLengthLimit
 maximum length of lines, 0 if unbounded More...
 
MutexType mutex
 internal mutex More...
 
int statusLevel
 current status level More...
 
bool statusPrintingEnabled
 whether status printing is enabled More...
 
std::ostream * stream
 stream used for printing (default std::cout) More...
 
int verbose
 verbosity level More...
 
std::stack< base::SGppStopwatchwatches
 stack of stop watches (started at time of printStatusBegin() calls) More...
 

Static Protected Attributes

static const char INDENTATION_CHAR = ' '
 
static const size_t INDENTATION_LENGTH = 4
 

Detailed Description

Singleton class to facilitate debugging output.

Use with the sgpp::printer instance.

The status printing functions won't print anything if

Member Function Documentation

Printer & sgpp::optimization::Printer::getInstance ( )
static
Returns
singleton instance

Referenced by sgpp::optimization::OperationMultipleHierarchisationFundamentalSpline::doDehierarchisation(), sgpp::optimization::OperationMultipleHierarchisationModFundamentalSpline::doDehierarchisation(), sgpp::optimization::OperationMultipleHierarchisationFundamentalSpline::doHierarchisation(), sgpp::optimization::OperationMultipleHierarchisationModFundamentalSpline::doHierarchisation(), sgpp::optimization::IterativeGridGeneratorSOO::generate(), sgpp::optimization::IterativeGridGeneratorLinearSurplus::generate(), sgpp::optimization::IterativeGridGeneratorRitterNovak::generate(), sgpp::optimization::optimizer::CMAES::optimize(), sgpp::optimization::optimizer::Rprop::optimize(), sgpp::optimization::optimizer::AdaptiveGradientDescent::optimize(), sgpp::optimization::optimizer::BFGS::optimize(), sgpp::optimization::optimizer::GradientDescent::optimize(), sgpp::optimization::optimizer::NelderMead::optimize(), sgpp::optimization::optimizer::LogBarrier::optimize(), sgpp::optimization::optimizer::DifferentialEvolution::optimize(), sgpp::optimization::optimizer::NLCG::optimize(), sgpp::optimization::optimizer::MultiStart::optimize(), sgpp::optimization::optimizer::AugmentedLagrangian::optimize(), sgpp::optimization::optimizer::SquaredPenalty::optimize(), sgpp::optimization::optimizer::LevenbergMarquardt::optimize(), sgpp::optimization::optimizer::AdaptiveNewton::optimize(), sgpp::optimization::optimizer::Newton::optimize(), sgpp::optimization::sle_solver::GaussianElimination::solve(), sgpp::optimization::sle_solver::Gmmpp::solve(), sgpp::optimization::sle_solver::Eigen::solve(), sgpp::optimization::sle_solver::Armadillo::solve(), sgpp::optimization::sle_solver::UMFPACK::solve(), sgpp::optimization::sle_solver::Auto::solve(), and sgpp::optimization::sle_solver::BiCGStab::solve().

double sgpp::optimization::Printer::getLastDurationSecs ( ) const
Returns
running-time of the last operation terminated by printStatusEnd()

References lastDuration.

size_t sgpp::optimization::Printer::getLineLengthLimit ( )
Returns
maximum length of lines, 0 if unbounded

References lineLengthLimit.

MutexType & sgpp::optimization::Printer::getMutex ( )
Returns
internal mutex

References mutex.

Referenced by sgpp::optimization::optimizer::MultiStart::optimize().

std::ostream * sgpp::optimization::Printer::getStream ( ) const
Returns
stream used for printing (default std::cout)

References stream.

int sgpp::optimization::Printer::getVerbosity ( ) const
inline
Returns
current verbosity level

References verbose.

void sgpp::optimization::Printer::printIterativeGridGenerator ( const IterativeGridGenerator gridGen) const
void sgpp::optimization::Printer::printSLE ( SLE system) const

Print a system of linear equations.

Parameters
systemsystem to be printed

References sgpp::optimization::SLE::getDimension(), and sgpp::optimization::SLE::getMatrixEntry().

void sgpp::optimization::Printer::printStatusBegin ( const std::string &  msg)

Call at the beginning of a time-consuming operation.

Locks and unlocks an OpenMP mutex.

Parameters
msgshort description of the operation

References cursorInClearLine, indentationLevel, lastMsgLength, mutex, printStatusIdentation(), printStatusNewLine(), statusLevel, statusPrintingEnabled, verbose, and watches.

Referenced by sgpp::optimization::OperationMultipleHierarchisationFundamentalSpline::doDehierarchisation(), sgpp::optimization::OperationMultipleHierarchisationModFundamentalSpline::doDehierarchisation(), sgpp::optimization::OperationMultipleHierarchisationFundamentalSpline::doHierarchisation(), sgpp::optimization::OperationMultipleHierarchisationModFundamentalSpline::doHierarchisation(), sgpp::optimization::IterativeGridGeneratorSOO::generate(), sgpp::optimization::IterativeGridGeneratorLinearSurplus::generate(), sgpp::optimization::IterativeGridGeneratorRitterNovak::generate(), sgpp::optimization::optimizer::CMAES::optimize(), sgpp::optimization::optimizer::Rprop::optimize(), sgpp::optimization::optimizer::AdaptiveGradientDescent::optimize(), sgpp::optimization::optimizer::BFGS::optimize(), sgpp::optimization::optimizer::GradientDescent::optimize(), sgpp::optimization::optimizer::NelderMead::optimize(), sgpp::optimization::optimizer::LogBarrier::optimize(), sgpp::optimization::optimizer::DifferentialEvolution::optimize(), sgpp::optimization::optimizer::NLCG::optimize(), sgpp::optimization::optimizer::MultiStart::optimize(), sgpp::optimization::optimizer::AugmentedLagrangian::optimize(), sgpp::optimization::optimizer::SquaredPenalty::optimize(), sgpp::optimization::optimizer::LevenbergMarquardt::optimize(), sgpp::optimization::optimizer::AdaptiveNewton::optimize(), sgpp::optimization::optimizer::Newton::optimize(), sgpp::optimization::sle_solver::GaussianElimination::solve(), sgpp::optimization::sle_solver::Gmmpp::solve(), sgpp::optimization::sle_solver::Eigen::solve(), sgpp::optimization::sle_solver::Armadillo::solve(), sgpp::optimization::sle_solver::UMFPACK::solve(), sgpp::optimization::sle_solver::Auto::solve(), and sgpp::optimization::sle_solver::BiCGStab::solve().

void sgpp::optimization::Printer::printStatusEnd ( const std::string &  msg = "")

Call at the end of a time-consuming operation.

Locks and unlocks an OpenMP mutex.

Retrieve the running time of the operation with getLastDurationSecs() (also works with nested calls of printStatusBegin()).

Parameters
msgshort description of the result, e.g. "success" or "error" (optional)

References cursorInClearLine, indentationLevel, lastDuration, lastMsgLength, mutex, printStatusIdentation(), printStatusNewLine(), statusLevel, statusPrintingEnabled, sgpp::base::SGppStopwatch::stop(), verbose, and watches.

Referenced by sgpp::optimization::OperationMultipleHierarchisationFundamentalSpline::doDehierarchisation(), sgpp::optimization::OperationMultipleHierarchisationModFundamentalSpline::doDehierarchisation(), sgpp::optimization::OperationMultipleHierarchisationFundamentalSpline::doHierarchisation(), sgpp::optimization::OperationMultipleHierarchisationModFundamentalSpline::doHierarchisation(), sgpp::optimization::IterativeGridGeneratorSOO::generate(), sgpp::optimization::IterativeGridGeneratorLinearSurplus::generate(), sgpp::optimization::IterativeGridGeneratorRitterNovak::generate(), sgpp::optimization::optimizer::CMAES::optimize(), sgpp::optimization::optimizer::Rprop::optimize(), sgpp::optimization::optimizer::AdaptiveGradientDescent::optimize(), sgpp::optimization::optimizer::BFGS::optimize(), sgpp::optimization::optimizer::GradientDescent::optimize(), sgpp::optimization::optimizer::NelderMead::optimize(), sgpp::optimization::optimizer::LogBarrier::optimize(), sgpp::optimization::optimizer::DifferentialEvolution::optimize(), sgpp::optimization::optimizer::NLCG::optimize(), sgpp::optimization::optimizer::MultiStart::optimize(), sgpp::optimization::optimizer::AugmentedLagrangian::optimize(), sgpp::optimization::optimizer::SquaredPenalty::optimize(), sgpp::optimization::optimizer::LevenbergMarquardt::optimize(), sgpp::optimization::optimizer::AdaptiveNewton::optimize(), sgpp::optimization::optimizer::Newton::optimize(), sgpp::optimization::sle_solver::GaussianElimination::solve(), sgpp::optimization::sle_solver::Armadillo::solve(), sgpp::optimization::sle_solver::Eigen::solve(), sgpp::optimization::sle_solver::UMFPACK::solve(), sgpp::optimization::sle_solver::Auto::solve(), and sgpp::optimization::sle_solver::BiCGStab::solve().

void sgpp::optimization::Printer::printStatusIdentation ( )

Internal function printing the indentation.

References indentation, indentationLevel, statusLevel, statusPrintingEnabled, and verbose.

Referenced by printStatusBegin(), printStatusEnd(), and printStatusUpdate().

void sgpp::optimization::Printer::printStatusUpdate ( const std::string &  msg)

Call for printing status updates on the operation.

The last status is erased, if printStatusNewLine has not been called before. Locks and unlocks an OpenMP mutex.

Parameters
msgstatus message

References cursorInClearLine, INDENTATION_LENGTH, indentationLevel, lastMsgLength, lineLengthLimit, mutex, printStatusIdentation(), statusLevel, statusPrintingEnabled, and verbose.

Referenced by sgpp::optimization::IterativeGridGeneratorSOO::generate(), sgpp::optimization::IterativeGridGeneratorLinearSurplus::generate(), sgpp::optimization::IterativeGridGeneratorRitterNovak::generate(), sgpp::optimization::optimizer::CMAES::optimize(), sgpp::optimization::optimizer::AdaptiveGradientDescent::optimize(), sgpp::optimization::optimizer::Rprop::optimize(), sgpp::optimization::optimizer::BFGS::optimize(), sgpp::optimization::optimizer::GradientDescent::optimize(), sgpp::optimization::optimizer::NelderMead::optimize(), sgpp::optimization::optimizer::LogBarrier::optimize(), sgpp::optimization::optimizer::DifferentialEvolution::optimize(), sgpp::optimization::optimizer::NLCG::optimize(), sgpp::optimization::optimizer::MultiStart::optimize(), sgpp::optimization::optimizer::AugmentedLagrangian::optimize(), sgpp::optimization::optimizer::SquaredPenalty::optimize(), sgpp::optimization::optimizer::LevenbergMarquardt::optimize(), sgpp::optimization::optimizer::AdaptiveNewton::optimize(), sgpp::optimization::optimizer::Newton::optimize(), sgpp::optimization::sle_solver::Gmmpp::solve(), sgpp::optimization::sle_solver::GaussianElimination::solve(), sgpp::optimization::sle_solver::Armadillo::solve(), sgpp::optimization::sle_solver::Eigen::solve(), sgpp::optimization::sle_solver::UMFPACK::solve(), sgpp::optimization::sle_solver::Auto::solve(), and sgpp::optimization::sle_solver::BiCGStab::solve().

void sgpp::optimization::Printer::setLineLengthLimit ( size_t  lineLengthLimit)
Parameters
lineLengthLimitmaximum length of lines, 0 if unbounded

References lineLengthLimit.

void sgpp::optimization::Printer::setStream ( std::ostream *  stream)
Parameters
streamstream used for printing (default std::cout)

References stream.

void sgpp::optimization::Printer::setVerbosity ( int  level)
inline
Parameters
levelnew verbosity level

References verbose.

Member Data Documentation

bool sgpp::optimization::Printer::cursorInClearLine
protected

is current line empty? (false if there's an old status update)

Referenced by printStatusBegin(), printStatusEnd(), printStatusNewLine(), and printStatusUpdate().

const int sgpp::optimization::Printer::DEFAULT_VERBOSITY = 0
static

default verbosity

std::string sgpp::optimization::Printer::indentation
protected

indentation

Referenced by printStatusIdentation().

const char sgpp::optimization::Printer::INDENTATION_CHAR = ' '
staticprotected
const size_t sgpp::optimization::Printer::INDENTATION_LENGTH = 4
staticprotected

Referenced by printStatusUpdate().

int sgpp::optimization::Printer::indentationLevel
protected

current indentation level (can be less than statusLevel)

Referenced by printStatusBegin(), printStatusEnd(), printStatusIdentation(), and printStatusUpdate().

double sgpp::optimization::Printer::lastDuration
protected

length of last operation in seconds

Referenced by getLastDurationSecs(), and printStatusEnd().

size_t sgpp::optimization::Printer::lastMsgLength
protected

length of the last status message in characters

Referenced by printStatusBegin(), printStatusEnd(), printStatusNewLine(), and printStatusUpdate().

size_t sgpp::optimization::Printer::lineLengthLimit
protected

maximum length of lines, 0 if unbounded

Referenced by getLineLengthLimit(), printStatusUpdate(), and setLineLengthLimit().

int sgpp::optimization::Printer::statusLevel
protected
bool sgpp::optimization::Printer::statusPrintingEnabled
protected
std::ostream* sgpp::optimization::Printer::stream
protected

stream used for printing (default std::cout)

Referenced by getStream(), and setStream().

std::stack<base::SGppStopwatch> sgpp::optimization::Printer::watches
protected

stack of stop watches (started at time of printStatusBegin() calls)

Referenced by printStatusBegin(), and printStatusEnd().


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