#include <ArrayGenSimple_Type.h>
Inheritance diagram for ArrayGenSimple(Type)::

Public Methods | |
| 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) | |
| ArrayGenSimple(Type) (const ArrayGenSimple(Type) &X) | |
| ~ArrayGenSimple(Type) () | |
| 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 (Type *a, int n, int base=0) |
| 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 |
| ArrayGenSimple(Type)& | operator= (Type a) |
| ArrayGenSimple(Type)& | operator= (const ArrayGenSimple(Type) &a) |
| void | fill (const Type &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) |
NAME: ArrayGenSimple(Type) - general array with operator= and printing
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 arguments and "operator=", "operator>>" and "operator<<". There are no assumptions that the entries in the array can be used in arithmetic operations like +, -, * and /.
The present class has class "VecSimplest(Type)" as a virtual base class.
|
|
See documentation for class "ArrayGenSimplest(Type)". |
|
|
See documentation of one of the overloaded constructor. |
|
|
See documentation of one of the overloaded constructor. |
|
|
See documentation of one of the overloaded constructor. |
|
|
See documentation of one of the overloaded constructor. |
|
|
See documentation of one of the overloaded constructor. |
|
|
|
|
|
Reimplemented from VecSimple(Type). Reimplemented in ArrayGen(Type), and ArrayGenSel(Type). |
|
|
Reimplemented from ArrayGenSimplest(Type). Reimplemented in ArrayGen(Type). |
|
|
Reimplemented from ArrayGenSimplest(Type). Reimplemented in ArrayGen(Type). |
|
|
Reimplemented from ArrayGenSimplest(Type). Reimplemented in ArrayGen(Type). |
|
|
Reimplemented from ArrayGenSimplest(Type). Reimplemented in ArrayGen(Type). |
|
|
Reimplemented from ArrayGenSimplest(Type). Reimplemented in ArrayGen(Type). |
|
|
Reimplemented from ArrayGenSimplest(Type). Reimplemented in ArrayGen(Type). |
|
|
Reimplemented from ArrayGenSimplest(Type). Reimplemented in ArrayGen(Type). |
|
|
Reimplemented from ArrayGenSimplest(Type). Reimplemented in ArrayGen(Type). |
|
|
|
|
|
|
|
|
prints the contents of the vector. See documentation of the function "scan". Reimplemented from VecSimple(Type). Reimplemented in ArrayGen(Type), and ArrayGenSel(Type). |
|
|
sets the format to ASCII and calls "print". Reimplemented from VecSimple(Type). Reimplemented in ArrayGen(Type). |
|
|
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 ArrayGenSimplest(Type). Reimplemented in ArrayGen(Type), and ArrayGenSel(Type). |
|
|
See documentation of one of the overloaded functions. Reimplemented from ArrayGenSimplest(Type). Reimplemented in ArrayGen(Type), and ArrayGenSel(Type). |
|
|
See documentation of one of the overloaded functions. Reimplemented from ArrayGenSimplest(Type). Reimplemented in ArrayGen(Type), and ArrayGenSel(Type). |
|
|
See documentation of one of the overloaded functions. Reimplemented from ArrayGenSimplest(Type). Reimplemented in ArrayGen(Type), and ArrayGenSel(Type). |
|
|
See documentation of one of the overloaded functions. Reimplemented from ArrayGenSimplest(Type). Reimplemented in ArrayGen(Type), and ArrayGenSel(Type). |
|
|
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 $
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
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]
Reimplemented from VecSimple(Type). Reimplemented in ArrayGen(Type), and ArrayGenSel(Type). |