42#ifndef TEUCHOS_TABULAR_OUTPUTTER_HPP
43#define TEUCHOS_TABULAR_OUTPUTTER_HPP
46#include "Teuchos_FancyOStream.hpp"
48#include "Teuchos_Tuple.hpp"
51#include "Teuchos_Exceptions.hpp"
69 enum { numFieldTypes = 3 };
73 enum { numFieldJustifications = 2 };
77 enum { numFloatingOutputTypes = 2 };
107 void pushFieldSpec(
const std::string &fieldName,
118 void setFieldTypePrecision(
const EFieldType fieldType,
const int prec );
125 void outputField(
const T& t );
146 std::string fieldName;
147 EFieldType fieldType;
148 EFieldJustification fieldJustification;
149 EFloatingOutputType floatingOutputType;
156 static const std::string fieldSpacer_;
161#pragma warning(disable:4251)
163 Array<FieldSpec> fieldSpecs_;
164 RCP<FancyOStream> out_;
165 Tuple<int,numFieldTypes> fieldTypePrecision_;
179 double adjustTime(
const double &time_in )
181 return ( time_in > 0.0 ? time_in : -1.0 );
186 void startTimer(
const int numLoops)
190 numLoops_ = numLoops;
199 const double relTime =
200 adjustTime(timer_.totalElapsedTime()) / numLoops_;
214#define TEUCHOS_START_PERF_OUTPUT_TIMER(OUTPUTTER, NUMLOOPS) \
215 (OUTPUTTER).startTimer(NUMLOOPS); \
216 for ( int k = 0; k < (NUMLOOPS); ++k )
220#define TEUCHOS_START_PERF_OUTPUT_TIMER_INNERLOOP(OUTPUTTER, NUMLOOPS, NUMINNERLOOPS) \
221 (OUTPUTTER).startTimer((NUMLOOPS)*(NUMINNERLOOPS)); \
222 for ( int k = 0; k < (NUMLOOPS); ++k )
226#define TEUCHOS_START_PERF_OUTPUT_TIMER_INNERLOOP(OUTPUTTER, NUMLOOPS, NUMINNERLOOPS) \
227 (OUTPUTTER).startTimer((NUMLOOPS)*(NUMINNERLOOPS)); \
228 for ( int k = 0; k < (NUMLOOPS); ++k )
234#define TEUCHOS_END_PERF_OUTPUT_TIMER(OUTPUTTER, VARNAME) \
235 const double VARNAME = (OUTPUTTER).stopTimer(); \
236 (OUTPUTTER).outputField(VARNAME)
254 "Error, you can not output a field until you print the header with"
258 !(currFieldIdx_ <
as<int>(fieldSpecs_.size())),
260 "Error, you have already output all of the "
261 << fieldSpecs_.size() <<
" fields for this tabular output."
262 " You must call nextRow() before outputting to the next row."
266 FieldSpec &
fieldSpec = fieldSpecs_[currFieldIdx_];
268 *out_ << fieldSpacer_ << std::setprecision(
fieldSpec.precision);
284 *out_ << std::scientific;
Templated array class derived from the STL std::vector.
Reference-counted pointer class and non-member templated function implementations.
Basic wall-clock timer class.
Base exception class for Teuchos.
Smart reference counting pointer class for automatic garbage collection.
Utility class that makes it easy to create formatted tables of output.
void outputField(const T &t)
Output to the next field.
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
This macro is designed to be a short version of TEUCHOS_TEST_FOR_EXCEPTION() that is easier to call.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...