FreePOOMA  2.4.1
Public Member Functions
PrintArray Class Reference

PrintArray is a utility program for Array objects, used to print (nicely) the contents of an array to a provided stream. More...

#include <PrintArray.h>

List of all members.

Public Member Functions

 PrintArray (int domainWidth=3, int dataWidth=10, int dataPrecision=4, int carReturn=-1, bool scientific=false, int spacing=1)
 PrintArray (const PrintArray &a)
 ~PrintArray ()
template<class S , class A , class DomainType >
void print (S &s, const A &a, const DomainType &d) const
template<class S , class A >
void print (S &s, const A &a) const
int domainWidth () const
void setDomainWidth (int val)
int dataWidth () const
void setDataWidth (int val)
int dataPrecision () const
void setDataPrecision (int val)
int carReturn () const
void setCarReturn (int val)
bool scientific () const
void setScientific (bool val)
int spacing () const
void setSpacing (int val)
void setFormatParameters (PrintArray &pa)

Detailed Description

PrintArray is a utility program for Array objects, used to print (nicely) the contents of an array to a provided stream.

All the data in the array will be printed in ascii format; if you want to display just a portion of an array, take a view of the array and give that to the print() method. This will display the indexes as zero-based, unit-stride. To avoid this, pass in both the Array and a domain object (such as a Range<>) specifying the view, and the global-index-space indices will be displayed.

CONSTRUCTING A PrintArray: -------------------------- When you construct a PrintArray, you can give it several format parameters to control how to display the array. These parameters are, in the order they are given in the constructor (all have default values):

domain width: the number of spaces that will be used to print out domain numbers. If it is 3, say, then domains will be printed like [003:008]

data width: the number of spaces, total, used to print out data values.

data precision: the number of digits past the decimal point displayed when data values are printed

carriage return: if this value is < 0, then for each row of values from the array, no carriage return is printed until the end of the row. If this number is > 0, it represents the maximum number of values that will be printed before a return. Only the first set of numbers for a row of the array will have a domain prefix included.

scientific notation: a boolean flag, if true numbers are printed using scientific notation, e.g. 10e-14

data spacing: the number of spaces to print between values

PRINTING ARRAY OBJECTS WITH A PrintArray: ----------------------------------------- PrintArray is not templated, so that you can reuse the same formatter for different array's. It has one templated member function 'print':

template<class S, class A> void print(S &s, const A &a) const

template<class S, class A, class DomainType> void print(S &s, const A &a, DomainType &d) const

where 'S' must be a class with an ostream-like interface (such as cout, or an Inform object), 'A' must be a class with an array interface, and 'DomainType' must be a class with a Domain interface. The first 'print' prototype will take data from 'a' and print it to the stream using the current format settings. The second prototype will print the view of 'a' specified by 'd' and print it, showing the global index values from the full domain of 'a'.

1-D arrays just have the one row printed, perhaps on multiple lines if carReturn is > 0. 2-D arrays are printed as a table, with each line prefixed by the domain it includes. For example: [00:02][00] = 0 0 0 [00:02][01] = 0 0 0 prints the values for [0:2][0:1] of a 2D array. 3-D and higher arrays have a sequence of 2-D slices printed for them, each slice separated by a line indicating which slice it is, and a separator. Example: [0:2:1][0:3:1][2]: ---------------------------------------------------- [00:02][00][02] = 0 0 0 [00:02][01][02] = 0 0 0 [00:02][02][02] = 0 0 0 [00:02][03][02] = 0 0 0


Constructor & Destructor Documentation

PrintArray::PrintArray ( int  domainWidth = 3,
int  dataWidth = 10,
int  dataPrecision = 4,
int  carReturn = -1,
bool  scientific = false,
int  spacing = 1 
) [inline]

References PAssert.

PrintArray::PrintArray ( const PrintArray a) [inline]

Member Function Documentation

template<class S , class A , class DomainType >
void PrintArray::print ( S &  s,
const A &  a,
const DomainType &  d 
) const [inline]

References Pooma::blockAndEvaluate().

Referenced by operator<<(), and print().

template<class S , class A >
void PrintArray::print ( S &  s,
const A &  a 
) const [inline]
int PrintArray::domainWidth ( ) const [inline]
void PrintArray::setDomainWidth ( int  val) [inline]

References PAssert.

int PrintArray::dataWidth ( ) const [inline]
void PrintArray::setDataWidth ( int  val) [inline]

References PAssert.

int PrintArray::dataPrecision ( ) const [inline]
void PrintArray::setDataPrecision ( int  val) [inline]

References PAssert.

int PrintArray::carReturn ( ) const [inline]
void PrintArray::setCarReturn ( int  val) [inline]
bool PrintArray::scientific ( ) const [inline]
void PrintArray::setScientific ( bool  val) [inline]
int PrintArray::spacing ( ) const [inline]
void PrintArray::setSpacing ( int  val) [inline]

References PAssert.


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