Diffpack Documentation


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

ArrayGenSel(Type) Class Reference

subset of general array with arithmetic operations. More...

#include <ArrayGenSel_Type.h>

Inheritance diagram for ArrayGenSel(Type)::

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

Public Methods

 ArrayGenSel(Type) ()
 ArrayGenSel(Type) (int n1)
 ArrayGenSel(Type) (int n1, int n2)
 ArrayGenSel(Type) (int n1, int n2, int n3)
 ArrayGenSel(Type) (const Ptv(int) &n)
 ArrayGenSel(Type) (const IndexSet &I, int offset)
 ArrayGenSel(Type) (const IndexSet &I, const Ptv(int) &offset)
 ArrayGenSel(Type) (const ArrayGenSel(Type) &X)
 ArrayGenSel(Type) (const Vector(prm_Type) &pm)
 ~ArrayGenSel(Type) ()
virtual int getNoEntries () const
bool hasIndexSet () const
IndexSetgetIndexSet () const
bool compatible (const IndexSet &I) const
bool compatible (const Vec(Type) &a)
bool compatible (const ArrayGen(Type) &a)
bool compatible (const ArrayGenSel(Type) &a)
void attach (ArrayGen(Type) &values)
void pureCopy (const ArrayGen(Type) &values)
void activate ()
void activate (const IndexSet &I)
bool redim (int n1)
bool redim (int n1, int n2)
bool redim (int n1, int n2, int n3)
bool redim (const Ptv(int) &n)
bool redim (const IndexSet &I, int offset=0)
bool redim (const IndexSet &I, const Ptv(int) &offset)
virtual bool redim (const Vector(prm_Type) &pm)
virtual bool makeItSimilar (Handle(Vector(Type)) &v) const
virtual void fill (const Vector(Type) &X)
virtual void fill (const Type &a)
void fill (Type start, Type stop)
ArrayGenSel(Type)& operator= (const ArrayGenSel(Type) &X)
ArrayGenSel(Type)& operator= (const ArrayGen(Type) &X)
ArrayGenSel(Type)& operator= (const Type &a)
void fillSel (const IndexSet &I, Type a)
virtual void add (const Vector(Type) &yb, const Vector(Type) &zb)
virtual void add (const Vector(Type) &yb, char s, const Vector(Type) &zb)
virtual void add (const Vector(Type) &yb, Type b, const Vector(Type) &zb)
virtual void add (Type a, const Vector(Type) &yb, Type b, const Vector(Type) &zb)
virtual void add (const Vector(Type) &y, int power, Type front_factor)
virtual void add (Type value)
virtual void apply (Func(Type) f)
virtual void mult (Type value)
virtual Type inner (const Vector(Type) &yb) const
virtual real norm (Norm_type lp=l2) const
virtual real normDiff (const Vector(Type) &y, Norm_type lp=l2) const
virtual void printSel (Os os, const char *header=NULL, int nentries_per_line=3) const
virtual void printSelAscii (Os os, const char *header=NULL) const
void print (Os os, const char *header=NULL, int nentries_per_line=3) const
virtual void scan (Is is)
CLASS_INFO VIRTUAL_CAST (ArrayGenSel(Type)) private
bool compatible (const ArrayGenSimplest(Type) &a, bool error_message=true)
bool redim (Type *a, int n, int base=0)

Protected Methods

void reset ()

Friends

Osoperator<< (Os &os, const Vec(Type) &x)
Isoperator>> (Is &is, Vec(Type) &x)

Detailed Description

subset of general array with arithmetic operations.

NAME: ArrayGenSel(Type) - subset of general array with arithmetic operations

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 through inheritance from class "ArrayGen(Type)". The bases of the indices can be arbitrary. It is assumed that the entries in the array can be used in arithmetic operations like +, -, * and /. In contrast to "ArrayGen(Type)", the current class can mark a subset of the total collection of vector entries as active.

In terms of finite difference stencils, this option allows us to disable nodes close to the grid borders. That is, these points will not contribute to arithmetic operations such as vector additions and inner products. The information needed for disabling nodes is extracted from a set of indicies, the index set must be represented by a class derived from the abstract base class "IndexSet". The index set will mark corresponding entries as active. Please notice that the subset mechanism does not influence vector assignments in terms of operators of member functions.


Constructor & Destructor Documentation

ArrayGenSel(Type)::ArrayGenSel_Type ( )
 

There are several constructors, besides the specialized constructor with an index set as argument, the documentation of the constructors are found within the documentation of class "ArrayGen(Type)" and class "ArrayGenSimplest(Type)". The constructor with the argument of an index set "I" and an integer "offset" allocates an array, using the size of "I". The offset size is appended to each end of the spatial dimension and the indices given by "I" are marked as active.

ArrayGenSel(Type)::ArrayGenSel_Type ( int n1 )
 

See documentation of one of the overloaded constructor.

ArrayGenSel(Type)::ArrayGenSel_Type ( int n1,
int n2 )
 

See documentation of one of the overloaded constructor.

ArrayGenSel(Type)::ArrayGenSel_Type ( int n1,
int n2,
int n3 )
 

See documentation of one of the overloaded constructor.

ArrayGenSel(Type)::ArrayGenSel_Type ( const Ptv(int) & n )
 

See documentation of one of the overloaded constructor.

ArrayGenSel(Type)::ArrayGenSel_Type ( const IndexSet & I,
int offset )
 

See documentation of one of the overloaded constructor.

ArrayGenSel(Type)::ArrayGenSel_Type ( const IndexSet & I,
const Ptv(int) & offset )
 

See documentation of one of the overloaded constructor.

ArrayGenSel(Type)::ArrayGenSel_Type ( const ArrayGenSel(Type) & X )
 

See documentation of one of the overloaded constructor.

ArrayGenSel(Type)::ArrayGenSel_Type ( const Vector(prm_Type) & pm )
 

See documentation of one of the overloaded constructor.

ArrayGenSel(Type)::~ArrayGenSel(Type) ( )
 


Member Function Documentation

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

Reimplemented from ArrayGen(Type).

void ArrayGenSel(Type)::activate ( const IndexSet & I )
 

See documentation of one of the overloaded functions.

void ArrayGenSel(Type)::activate ( )
 

make it possible to mark selected array entries as active (others are then non-active in computations). If no argument is present all the array entries are marked, otherwise the index set given as argument is used to mark active entries.

void ArrayGenSel(Type)::add ( Type value ) [virtual]
 

See documentation of one of the overloaded functions.

Reimplemented from Vec(Type).

void ArrayGenSel(Type)::add ( const Vector(Type) & y,
int power,
Type front_factor ) [virtual]
 

See documentation of one of the overloaded functions.

Reimplemented from Vec(Type).

void ArrayGenSel(Type)::add ( Type a,
const Vector(Type) & yb,
Type b,
const Vector(Type) & zb ) [virtual]
 

See documentation of one of the overloaded functions.

Reimplemented from Vec(Type).

void ArrayGenSel(Type)::add ( const Vector(Type) & yb,
Type b,
const Vector(Type) & zb ) [virtual]
 

See documentation of one of the overloaded functions.

Reimplemented from Vec(Type).

void ArrayGenSel(Type)::add ( const Vector(Type) & yb,
char s,
const Vector(Type) & zb ) [virtual]
 

See documentation of one of the overloaded functions.

Reimplemented from Vec(Type).

void ArrayGenSel(Type)::add ( const Vector(Type) & yb,
const Vector(Type) & zb ) [virtual]
 

vector additions use only entries that are marked as active. This is also true for other arithmetic operations like "apply", "mult", "inner", "norm" and "normDiff".

Reimplemented from Vec(Type).

void ArrayGenSel(Type)::apply ( Func(Type) f ) [virtual]
 

given a function pointer "f", this transformation is applied to every entry of the vector object.

Reimplemented from Vec(Type).

void ArrayGenSel(Type)::attach ( ArrayGen(Type) & values )
 

borrow the values of a "ArrayGen" object. This function is not completely safe since the borrowed object might be deleted. Use the function with care!

bool ArrayGenSel(Type)::compatible ( const ArrayGenSimplest(Type) & a,
bool error_message = true ) [inline]
 

See documentation of one of the overloaded functions.

Reimplemented from ArrayGenSimplest(Type).

bool ArrayGenSel(Type)::compatible ( const ArrayGenSel(Type) & a ) [inline]
 

See documentation of one of the overloaded functions.

bool ArrayGenSel(Type)::compatible ( const ArrayGen(Type) & a ) [inline]
 

See documentation of one of the overloaded functions.

Reimplemented from ArrayGen(Type).

bool ArrayGenSel(Type)::compatible ( const Vec(Type) & a ) [inline]
 

See documentation of one of the overloaded functions.

Reimplemented from ArrayGen(Type).

bool ArrayGenSel(Type)::compatible ( const IndexSet & I ) const
 

the version with an index set argument checks if the indices are well defined corresponding to the size of the array. If so "true" is returned, otherwise "false" is returned. The other versions checks compability with different vector types and compatibility requires that the memomory segments have equal length (the case where an "ArrayGenSel" object, neglecting the ghost boundary, is mathematically compatible with an "ArrayGen" object is not treated).

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

See documentation of one of the overloaded functions.

Reimplemented from ArrayGen(Type).

void ArrayGenSel(Type)::fill ( const Type & a ) [inline, virtual]
 

See documentation of one of the overloaded functions.

Reimplemented from ArrayGen(Type).

void ArrayGenSel(Type)::fill ( const Vector(Type) & X ) [inline, virtual]
 

assigns the specified value to all the elements of the array.

Reimplemented from ArrayGen(Type).

void ArrayGenSel(Type)::fillSel ( const IndexSet & I,
Type a )
 

the elements corresponding to the index set in the argument is assigned to a given value.

IndexSet & ArrayGenSel(Type)::getIndexSet ( ) const
 

return the index set (class "IndexSet") contained by the class.

int ArrayGenSel(Type)::getNoEntries ( ) const [virtual]
 

return the number of 'active' vector entries.

Reimplemented from Vec(Type).

bool ArrayGenSel(Type)::hasIndexSet ( ) const
 

Type ArrayGenSel(Type)::inner ( const Vector(Type) & yb ) const [virtual]
 

computes the inner product of two vectors. If both vectors contain complex values, the complex conjugate of the first vector is used.

Reimplemented from Vec(Type).

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

as in the other classes derived from "Vector(Type)", this function reinitializes an existing "ArrayGenSel(Type)" object or allocates a new one. In both cases, the handle "v" refers to an object with the same attributes as the current one. In particular, the referenced object will inherit the present marking of active entries. Please note that this function does not copy the actual vector entries.

Reimplemented from ArrayGen(Type).

void ArrayGenSel(Type)::mult ( Type value ) [virtual]
 

all vector entries are multiplied with a given constant "value".

Reimplemented from Vec(Type).

real ArrayGenSel(Type)::norm ( Norm_type lp = l2 ) const [virtual]
 

computes the norm of the vector. There are several norms available (see "enum" "Norm_type"): "l1" is the discrete

       `$`L`_`1`$ norm (`$\`sum`_{`i=1`}^`n ``v`_`i`|$`), "L1" is the
       (`$`(1/n)`\`sum`_{`i=1`}^`n``v`_`i`|$`), "l2" is the discrete
v`_`i`^`2`}$`), while "L2" is the corresponding continuous norm (`$\`sqrt`{`(1/n)`\`sum`_{`i=1`}^`n v`_`i`^`2`}$`). Finally, "Linf" is the `$`L`_{\`infty`}$` norm (`$\`max`_`i
       ``v`_`i`|$`).

Reimplemented from Vec(Type).

real ArrayGenSel(Type)::normDiff ( const Vector(Type) & y,
Norm_type lp = l2 ) const [virtual]
 

similar to "norm", but computes the norm of the vector difference between the current object and the argument vector.

Reimplemented from Vec(Type).

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

See documentation of one of the overloaded functions.

Reimplemented from ArrayGen(Type).

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

See documentation of one of the overloaded functions.

Reimplemented from ArrayGen(Type).

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

performs a "fill" operation.

Reimplemented from ArrayGen(Type).

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

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

Reimplemented from ArrayGen(Type).

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

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

void ArrayGenSel(Type)::pureCopy ( const ArrayGen(Type) & values )
 

make a pure copy of an "ArrayGen" object, that is, allocated the vector and copy the values.

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

See documentation of one of the overloaded functions.

Reimplemented from ArrayGen(Type).

bool ArrayGenSel(Type)::redim ( const Vector(prm_Type) & pm ) [virtual]
 

See documentation of one of the overloaded functions.

Reimplemented from ArrayGen(Type).

bool ArrayGenSel(Type)::redim ( const IndexSet & I,
const Ptv(int) & offset )
 

See documentation of one of the overloaded functions.

bool ArrayGenSel(Type)::redim ( const IndexSet & I,
int offset = 0 )
 

See documentation of one of the overloaded functions.

bool ArrayGenSel(Type)::redim ( const Ptv(int) & n )
 

See documentation of one of the overloaded functions.

Reimplemented from ArrayGen(Type).

bool ArrayGenSel(Type)::redim ( int n1,
int n2,
int n3 )
 

See documentation of one of the overloaded functions.

Reimplemented from ArrayGen(Type).

bool ArrayGenSel(Type)::redim ( int n1,
int n2 )
 

See documentation of one of the overloaded functions.

Reimplemented from ArrayGen(Type).

bool ArrayGenSel(Type)::redim ( int n1 )
 

reallocates the array, c.f. the construcors.

Reimplemented from ArrayGen(Type).

void ArrayGenSel(Type)::reset ( ) [protected, virtual]
 

Reimplemented from Vector(Type).

void ArrayGenSel(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 ArrayGen(Type).


Friends And Related Function Documentation

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

calls the function "print".

Reimplemented from Vec(Type).

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

calls the function "scan".

Reimplemented from Vec(Type).


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