BZDEV: Array<T,N>::reverse() and transpose()

From: Todd Veldhuizen (tveldhui@oonumerics.org)
Date: Wed Jun 17 1998 - 09:26:04 EST


I've decided to change the meaning of Array<T,N>::transpose() slightly.
Instead of transposing the array itself, the method will now return
a "view" of the transposed array, leaving the original array intact.
A second version, transposeSelf(), will apply the transpose to the
array itself. Similarly with reverse(): there is now a reverse()
and a reverseSelf().

As far as I know, this is the first change I've made to the
array interface which has the potential to break existing
code. Hopefully there aren't many people already using transpose(),
since it is a fairly recent addition.

Array<T,N> reverse(int dimension);
void reverseSelf(int dimension);
This method reverses the array in the specified dimension.
For example, if tt(reverse(firstDim)) is invoked on a
2-dimensional array, then the ordering of rows in the
array will be reversed; tt(reverse(secondDim)) would
reverse the order of the columns. Note that this is
implemented by twiddling the strides of the array, and
doesn't cause any data copying. The first version
returns a reversed "view" of the array data; the second
version applies the reversal to the array itself.

Array<T,N> transpose(int dimension1,
                                      int dimension2, ...);
void transposeSelf(int dimension1,
                                      int dimension2, ...);
These methods permute the dimensions of the array. The
dimensions of the array are reordered so that the first dimension is
tt(dimension1), the second is tt(dimension2), and so on. The
arguments should be a permutation of the symbols tt(firstDim,
secondDim, ...). Note that this is implemented by twiddling the
strides of the array, and doesn't cause any data copying.
The first version returns a transposed "view" of the array data;
the second version transposes the array itself.

--------------------- blitz-dev list --------------------------------
* To subscribe/unsubscribe: mail to majordomo@oonumerics.org, with
"subscribe blitz-dev" or "unsubscribe blitz-dev" in the body of the message
* Blitz++ web page: http://oonumerics.org/blitz/



This archive was generated by hypermail 2b29 : Wed Feb 20 2002 - 04:30:05 EST