Index

NAME

ArrayGenSimple(Type) - general array with operator= and printing


INCLUDE

include "ArrayGenSimple_Type.h"

SYNTAX

 class ArrayGenSimple(Type) : public virtual VecSimple(Type),
                              public ArrayGenSimplest(Type)
 {
   // recall: virtual base class VecSimplest(Type)

 public:

   //---------- constructors and destructor:

   ArrayGenSimple(Type) ();
   ArrayGenSimple(Type) (int n1);
   ArrayGenSimple(Type) (int n1, int n2);
   ArrayGenSimple(Type) (int n1, int n2, int n3);
   ArrayGenSimple(Type) (const Ptv(int)& n);         // multiple index
   ArrayGenSimple(Type) (const ArrayGenSimple(Type)& X);
  ~ArrayGenSimple(Type) () {}

   //---------- redim :

   bool redim (int n1)
     { return ArrayGenSimplest(Type)::redim(n1); }

   bool redim (int n1, int n2)
     { return ArrayGenSimplest(Type)::redim(n1,n2); }

   bool redim (int n1, int n2, int n3)
     { return ArrayGenSimplest(Type)::redim(n1,n2,n3); }

   bool redim (const Ptv(int)& n)
     { return ArrayGenSimplest(Type)::redim(n); }

   bool redim (Type* a, int n, int base = 0)
     { return ArrayGenSimplest(Type)::redim(a,n,base); }

   //---------- indexing operators :

   Type& operator () (int i)
     { return ArrayGenSimplest(Type)::operator()(i); }

   Type& operator () (int i, int j)
     { return ArrayGenSimplest(Type)::operator()(i,j); }

   Type& operator () (int i, int j, int k)
     { return ArrayGenSimplest(Type)::operator()(i,j,k); }

   Type& operator () (const Ptv(int)& index)
     { return ArrayGenSimplest(Type)::operator()(index); }

   const Type& operator () (int i) const
     { return ArrayGenSimplest(Type)::operator()(i); }

   const Type& operator () (int i, int j) const
     { return ArrayGenSimplest(Type)::operator()(i,j); }

   const Type& operator () (int i, int j, int k) const
     { return ArrayGenSimplest(Type)::operator()(i,j,k); }

   const Type& operator () (const Ptv(int)& index) const
     { return ArrayGenSimplest(Type)::operator()(index); }


   //----------- various standard functions :

   ArrayGenSimple(Type)& operator = (Type a)      { fill(a); return *this; }
   ArrayGenSimple(Type)& operator = (const ArrayGenSimple(Type)& a);
   void fill (const Type& a)   { VecSimple(Type)::fill(a); }

   void print      (Os os, const char* header = NULL,
                    int nentries_per_line = 3) const;
   void printAscii (Os os, const char* header = NULL,
                    int nentries_per_line = 3) const;
   void scan (Is is);

   //CLASS_INFO: not used
 };



KEYWORDS

array, finite difference methods, point operators, general array,
multi-dimensional array



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 below).   The  only  requirement  of  the  array
entries  is that class Type must have a constructor without argu­
ments and operator=, operator>> and  operator<<.   There  are  no
assumptions  that  the entries in the array can be used in arith­
metic operations like +, -, * and /.

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



CONSTRUCTORS AND INITIALIZATION

See documentation for class ArrayGenSimplest(Type).



MEMBER FUNCTIONS

The member functions should be self-explanatory if the documenta­
tion of the classes VecSimplest(Type), VecSimple(Type) and Array­
GenSimplest(Type) has been studied.



EXAMPLES

See documentation for class ArrayGenSimplest(Type).



SEE ALSO

class ArrayGenSimplest(Type), class VecSimple(Type)


DEVELOPED BY

SINTEF Applied Mathematics, Oslo, Norway, and University of Oslo,
Dept. of Mathematics, Norway


AUTHOR

Hans Petter Langtangen, SINTEF/UiO