Diffpack Documentation


Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

ArrayGen(Type) Class Reference

generalized, multi-dimensional array with arithmetic operations (arbitrary base). More...

#include <ArrayGen_Type.h>

Inheritance diagram for ArrayGen(Type)::

Vec_Type ArrayGenSimple_Type VecSort_Type Vector_Type VecSimple_Type ArrayGenSimplest_Type VecSimple_Type HandleId VecSimplest_Type VecSimplest_Type VecSimplest_Type ArrayGenSel_Type List of all members.

Public Methods

 ArrayGen(Type) ()
 ArrayGen(Type) (int n1)
 ArrayGen(Type) (int n1, int n2)
 ArrayGen(Type) (int n1, int n2, int n3)
 ArrayGen(Type) (const Ptv(int) &n)
 ArrayGen(Type) (const ArrayGen(Type) &X)
 ArrayGen(Type) (const Vector(prm_Type) &pm)
virtual ~ArrayGen(Type) ()
bool compatible (const Vec(Type) &a)
bool compatible (const ArrayGen(Type) &a)
virtual bool makeItSimilar (Handle(Vector(Type)) &v) const
virtual bool redim (const Vector(prm_Type) &pm)
bool redim (int n1)
bool redim (int n1, int n2)
bool redim (int n1, int n2, int n3)
bool redim (const Ptv(int) &n)
virtual void fill (const Vector(Type) &X)
virtual void fill (const Type &a)
ArrayGen(Type)& operator= (const ArrayGen(Type) &X)
ArrayGen(Type)& operator= (const Type &a)
ArrayGen(Type)& operator= (const ArrayGenSel(Type) &X)
void fill (Type start, Type stop)
Type& operator() (int i)
Type& operator() (int i, int j)
Type& operator() (int i, int j, int k)
Type& operator() (const Ptv(int) &index)
const Type& operator() (int i) const
const Type& operator() (int i, int j) const
const Type& operator() (int i, int j, int k) const
const Type& operator() (const Ptv(int) &index) const
virtual void print (Os os, const char *header=NULL, int nentries_per_line=3) const
virtual void printAscii (Os os, const char *header=NULL) const
virtual void scan (Is is)
CLASS_INFO VIRTUAL_CAST (ArrayGen(Type)) private
bool compatible (const VecSimplest(Type) &X) const
void printAscii (Os os, const char *, int) const
bool redim (Type *a, int n, int base=0)

Friends

class  ArrayGenSel(Type)
Osoperator<< (Os &os, const ArrayGen(Type) &x)
Isoperator>> (Is &is, ArrayGen(Type) &x)

Detailed Description

generalized, multi-dimensional array with arithmetic operations (arbitrary base).

NAME: ArrayGen(Type) - generalized, multi-dimensional array with arithmetic operations (arbitrary base)

DESCRIPTION:

The class implements a multi-dimensional array in terms of a standard, one-dimensional C array. The multi-dimensional feature is created by offering subscript operators for one, two, three and "Ptv(int)" indices. The bases of the indices can be arbitrary (see the example for class "ArrayGenSimplest(Type)". It is assumed that the entries in the array can be used in arithmetic operations like "+", "-", "*" and "/".

Please note that "ArrayGen(Type)" is simply a standard vector with the possibility of multi-dimensional indexing.

The present class has class "VecSimplest(Type)" as a virtual base class.


Constructor & Destructor Documentation

ArrayGen(Type)::ArrayGen_Type ( )
 

With respect to the constructors taking multiple integers or "Ptv(int)" arguments, see the documentation for class "ArrayGenSimplest(Type)". In addition, there is a copy constructor and a version based on the parameter class "Vector_prm(Type)", see class "Vec(Type)" for further details.

ArrayGen(Type)::ArrayGen_Type ( int n1 )
 

See documentation of one of the overloaded constructor.

ArrayGen(Type)::ArrayGen_Type ( int n1,
int n2 )
 

See documentation of one of the overloaded constructor.

ArrayGen(Type)::ArrayGen_Type ( int n1,
int n2,
int n3 )
 

See documentation of one of the overloaded constructor.

ArrayGen(Type)::ArrayGen_Type ( const Ptv(int) & n )
 

See documentation of one of the overloaded constructor.

ArrayGen(Type)::ArrayGen_Type ( const ArrayGen(Type) & X )
 

See documentation of one of the overloaded constructor.

ArrayGen(Type)::ArrayGen_Type ( const Vector(prm_Type) & pm )
 

See documentation of one of the overloaded constructor.

ArrayGen(Type)::~ArrayGen(Type) ( ) [virtual]
 


Member Function Documentation

CLASS_INFO ArrayGen(Type)::VIRTUAL_CAST ( ArrayGen(Type) ) [inline]
 

Reimplemented in ArrayGenSel(Type).

bool ArrayGen(Type)::compatible ( const VecSimplest(Type) & X ) const [inline]
 

See documentation of one of the overloaded functions.

Reimplemented from ArrayGenSimplest(Type).

bool ArrayGen(Type)::compatible ( const ArrayGen(Type) & a )
 

See documentation of one of the overloaded functions.

Reimplemented in ArrayGenSel(Type).

bool ArrayGen(Type)::compatible ( const Vec(Type) & a )
 

checks compatibility between the input vector and the current object with respect to the total length.

Reimplemented in ArrayGenSel(Type).

void ArrayGen(Type)::fill ( Type start,
Type stop ) [inline]
 

See documentation of one of the overloaded functions.

Reimplemented from Vec(Type).

Reimplemented in ArrayGenSel(Type).

void ArrayGen(Type)::fill ( const Type & a ) [virtual]
 

Reimplemented from ArrayGenSimple(Type).

Reimplemented in ArrayGenSel(Type).

void ArrayGen(Type)::fill ( const Vector(Type) & X ) [virtual]
 

the version with one argument (inherited from class "VecSimple") fills all array entries with the argument value. The version with two arguments, "start" and "stop", fills the vector with values that are uniformly distributed in the closed interval from "start" to "stop" (in ascending order).

Reimplemented from Vec(Type).

Reimplemented in ArrayGenSel(Type).

bool ArrayGen(Type)::makeItSimilar ( Handle(Vector(Type)) & v ) const [virtual]
 

the "Vector(Type)" object given as input is initialized to be an imprint of the current object. This implies that the input handle "v" should be empty or refer to a vector of type "Vec(Type)". In cases where the input handle is empty, a new "Vec(Type): object is allocated and rebound to "v". Please note that this function does not copy the actual vector entries.

Reimplemented from Vec(Type).

Reimplemented in ArrayGenSel(Type).

const Type & ArrayGen(Type)::operator() ( const Ptv(int) & index ) const [inline]
 

Reimplemented from ArrayGenSimple(Type).

const Type & ArrayGen(Type)::operator() ( int i,
int j,
int k ) const [inline]
 

Reimplemented from ArrayGenSimple(Type).

const Type & ArrayGen(Type)::operator() ( int i,
int j ) const [inline]
 

Reimplemented from ArrayGenSimple(Type).

const Type & ArrayGen(Type)::operator() ( int i ) const [inline]
 

Reimplemented from ArrayGenSimple(Type).

Type & ArrayGen(Type)::operator() ( const Ptv(int) & index ) [inline]
 

Reimplemented from ArrayGenSimple(Type).

Type & ArrayGen(Type)::operator() ( int i,
int j,
int k ) [inline]
 

Reimplemented from ArrayGenSimple(Type).

Type & ArrayGen(Type)::operator() ( int i,
int j ) [inline]
 

Reimplemented from ArrayGenSimple(Type).

Type & ArrayGen(Type)::operator() ( int i ) [inline]
 

Reimplemented from ArrayGenSimple(Type).

ArrayGen(Type) & ArrayGen(Type)::operator= ( const ArrayGenSel(Type) & X )
 

Reimplemented in ArrayGenSel(Type).

ArrayGen(Type) & ArrayGen(Type)::operator= ( const Type & a ) [inline]
 

the version that takes another "VecSimple(Type)" as argument makes the object a copy of the vector argument, that is, the object is redimensioned according to the dimensions of "X" and thereafter each entry is set equal to the corresponding entry in "X". The version that takes a "Type" value as argument sets all the entries in the vector to have this value.

Reimplemented from Vec(Type).

Reimplemented in ArrayGenSel(Type).

ArrayGen(Type) & ArrayGen(Type)::operator= ( const ArrayGen(Type) & X ) [inline]
 

Reimplemented in ArrayGenSel(Type).

void ArrayGen(Type)::print ( Os os,
const char * header = NULL,
int nentries_per_line = 3 ) const [virtual]
 

prints the contents of the vector. See documentation of the function "scan".

Reimplemented from ArrayGenSimple(Type).

Reimplemented in ArrayGenSel(Type).

void ArrayGen(Type)::printAscii ( Os os,
const char * header,
int nentries_per_line ) const [inline]
 

sets the format to ASCII and calls "print".

Reimplemented from ArrayGenSimple(Type).

void ArrayGen(Type)::printAscii ( Os os,
const char * header = NULL ) const [virtual]
 

Reimplemented from Vec(Type).

bool ArrayGen(Type)::redim ( Type * a,
int n,
int base = 0 ) [inline]
 

redimensions the array. With this function one can change the dimension of the array, and the number of entries of each dimension. The base is set to 1.

Reimplemented from ArrayGenSimple(Type).

Reimplemented in ArrayGenSel(Type).

bool ArrayGen(Type)::redim ( const Ptv(int) & n ) [inline]
 

See documentation of one of the overloaded functions.

Reimplemented from ArrayGenSimple(Type).

Reimplemented in ArrayGenSel(Type).

bool ArrayGen(Type)::redim ( int n1,
int n2,
int n3 ) [inline]
 

See documentation of one of the overloaded functions.

Reimplemented from ArrayGenSimple(Type).

Reimplemented in ArrayGenSel(Type).

bool ArrayGen(Type)::redim ( int n1,
int n2 ) [inline]
 

See documentation of one of the overloaded functions.

Reimplemented from ArrayGenSimple(Type).

Reimplemented in ArrayGenSel(Type).

bool ArrayGen(Type)::redim ( int n1 ) [inline]
 

See documentation of one of the overloaded functions.

Reimplemented from ArrayGenSimple(Type).

Reimplemented in ArrayGenSel(Type).

bool ArrayGen(Type)::redim ( const Vector(prm_Type) & pm ) [inline, virtual]
 

one "redim" function is inherited from class "VecSimplest" and redimensions the internal array. The other "redim" function takes a "Vector_prm(Type)" argument and is used in conjuction with a baseclass pointer to "Vector". The function enables redimensioning of any object in the "Vector" hierarchy and is typically used by equation solvers and equation system objects to redimension a vector of unknown class type. A similar function in the "Matrix" hierarchy is easier to understand.

Reimplemented from Vec(Type).

Reimplemented in ArrayGenSel(Type).

void ArrayGen(Type)::scan ( Is is ) [virtual]
 

reads the vector from an "Is" object. The entries of an array can be written and read in two main formats, the binary format or the ascii format. When "print" is invoked, the format is determined by the state of the "Os" object (the result of the "getFormat" function). Each of the ascii/binary formats can have a header or not. The header is present if "print" is called with a non-"NULL" "header" string. In "scan" one detects the header if the first non-space character is "[". If the header is present, its syntax is like this:

      [size]X text $
where "size" is the size of the array (for a vector it is the length, for a matrix it is a string on the form "rxc", where "r" is the number of rows and "c" is the number of columns), "X" is a character that equals "b" in case of a binary format or space in case of an ascii format. "text" is the "header" string given to "print". In "scan" this string is ignored, but it is available in the internal "Is" buffer so the programmer can in principle extract the header after "scan" is called.

After the header a character "@" follows if the format is binary, if not, a space appears. Hence one can detect whether the format is binary or ascii even when the header does not appear. After the "@", the binary format has two binary numbers: The number of array entries and the size of each entry.

If the header is present and the format is ascii, there will be "nentires_per_line" array entries on each output line. There array index will also be written. In all other cases, the array entries are written with no index, but in the ascii format there will be an extra space.

With a header the "scan" functions can read the dimensions of the array and call "redim" before reading the entries. Without a header the dimensions of the array must be correct BEFORE "scan" is called. In other words, a file containing the array entries only can only be read when the number of entries is known. The function "scanFromFile" can, however, read an unknown number of entries from file into a vector with wrong dimensions (see documentation below). If the format is binary, the "scan" function detects the array length and redimensions the array, but a warning is issued. The reason is that, without a header, the main rule is that the programmer must have redimensioned the array on beforehand.

After the header the data appears. If they are written in binary mode, the first non-white character (after the header) is "@". Then, in binary format, the number of items must appear and after that the size of each item. Then the data appear in binary format. If the "@" character is not present, the data appear in ascii format.

Let us present some examples on valid data files. First the most comprehensive form:

      [3]  Example of a data file with much additional information such as
      indices for each vector entry. This file is in ascii format.
  
      (1)=1.2
      (2)=3.4
      (3)=1.8

Here is an ascii format file with as little information as possible (a NULL header was given when calling "print":

      1.2 3.4 1.8
An equivalent form may be

      1.2 3.4
      1.8

Finally we show a binary file without header. To indicate a binary number (f.ex. 8.1) we use the notation [B8.1].

      @[B3][B4][B1.2][B3.4][B1.8]
Observe that the item is a float and that the size of the item is "sizeof(float)" which equals 4. There is a comprehensive demonstration and test program for the various ascii and binary file formats of arrays in the directory "$DPR/src/app/class-verify/category2/arrayprint".

Reimplemented from ArrayGenSimple(Type).

Reimplemented in ArrayGenSel(Type).


Friends And Related Function Documentation

class ArrayGenSel(Type) [friend]
 

Os & operator<< ( Os & os,
const ArrayGen(Type) & x ) [friend]
 

Is & operator>> ( Is & is,
ArrayGen(Type) & x ) [friend]
 


The documentation for this class was generated from the following file:
Copyright © 2003 inuTech GmbH. All rights reserved.