IPosition shape (3,10,10,3); Array <Float> array (shape); // ...initialize and manipulate the array... cout << "result: " << array;
Write out an ascii representation of an array of any dimensionality. Arrays of dimensionality 3 or greater are written out vector by vector, preceeded by the position of the start of the vector. If the origin of the array isn't zero it is printed. The shape of the array is always printed.
Write a formatted copy of the array to the LogIO output object. Merely calls the ostream operator<< in turn.
Read an ascii representation of an array. All types with an << operator can be handled. The basic format of the input should be:
[element element element ....]Elements are separated by whitespace, or a comma, optionally surrounded by white space.
Some input routines read fields between blank spaces. This is (at the moment) especially true for Quantities and Strings. In those cases the separator should be blank (or a comma following a blank), and the end ']' should have a blank in front. A crude fix for String arrays having separators , and ] without blanks preceding has been made; but slows routines downThe default input is a vector of unspecified length. The input shape can be changed by pre-pending the input with:
{[shape]}where shape is an unsigned integer vector. The shape will be used to check the input length; and, depending on the possibility, to resize/reshape the result. However, reshaping of e.g. a Vector to a Matrix cannot be done, and the result will stay in the form asked.
{T[shape]}the order will be reversed.
General read support function for matrices.
In principle these functions will not be
used by general user, but could be. They can be used by Array type
classes (like Slice, Lattice) to do the work of comparable input
functions as the one for Arrays.
In these functions p is the shape
of the returned Block x. This shape is either deduced from the user
specification; made equal to (1, nelements) if no user shape is
given; is set to ip if specified. The function will return False (and
p = (0)) in the case of an invalid input element; a number of elements
input not equal to ip (if specified); the shape given by user as input
does not conform to ip (if given) or the number of elements input.
trans will be True if transpose asked by user; or if forced by it.
Read or write a binary representation of an Array to a file. Very
useful for saving arrays and restoring them later.
The putArray function is put in for forwards compatibility
of images (so new images can be read with old release).
Matrix<Float> picture(256, 256); picture = 0.0; String fileName="picture.data"; // operations to populate picture // ... writeAsciiMatrix (picture, fileName);
These routines read and write a Matrix of data. The first line of input will be examined to determine the number of columns in the matrix. The maximum number of columns provided for is 100. Each item may be up to 50 characters long.
Each item must be separated from others by one (or more) blank column. The "line" may be up to 1024 characters long. Each subsequent line must contain the SAME number of items as the first line but may be any length (up to 1024 characters).
The matrix need NOT be square.
The matrix should be declared but NOT dimensioned in the calling program.
These two functions read and write a Vector of data. The input may be arranged in any format (i.e. It may be recorded as one value per line or it may be recorded with all values on a single line). Values must be separated by whitespace.
Matrix<Float> picture(256, 256); picture = 0.0; String fileName="picture.data"; // operations to populate picture // ... writeAsciiMatrix (picture, fileName);
These routines read and write a Matrix of data. The first line of input will be examined to determine the number of columns in the matrix. The maximum number of columns provided for is 100. Each item may be up to 50 characters long.
Each item must be separated from others by one (or more) blank column. The "line" may be up to 1024 characters long. Each subsequent line must contain the SAME number of items as the first line but may be any length (up to 1024 characters).
The matrix need NOT be square.
The matrix should be declared but NOT dimensioned in the calling program.
These two functions read and write a Vector of data. The input may be arranged in any format (i.e. It may be recorded as one value per line or it may be recorded with all values on a single line). Values must be separated by whitespace.