Here is a new pair of member functions. If you want to incorporate them
into Blitz++ please do so. The diffs below are for the 20001213
snapshot.
Array<T,N> transpose(TinyVector<int,N> newDimensions);
and
void transposeSelf(TinyVector<int,N> newDimensions);
Basically the same as the old transpose and transposeSelf functions, but
they take a TinyVector of the new dimension ordering.
Derrick Bass
Here are the diffs:
*** array.h.orig Mon Oct 30 10:27:41 2000
--- array.h Tue Feb 27 04:25:07 2001
***************
*** 992,997 ****
--- 992,1002 ----
int r3=0, int r4=0, int r5=0, int r6=0, int r7=0, int r8=0,
int
r9=0, int r10=0);
+ void transposeSelf(const
+ TinyVector<int, N_rank>& );
+ T_array transpose(const
+ TinyVector<int, N_rank>& );
+
int rank() const
{ return N_rank; }
*** methods.cc.orig Mon Jun 19 05:26:13 2000
--- methods.cc Tue Feb 27 03:46:59 2001
***************
*** 282,287 ****
--- 282,296 ----
}
template<class T_numtype, int N_rank>
+ Array<T_numtype, N_rank> Array<T_numtype, N_rank>::transpose(
+ const TinyVector<int, N_rank>& r)
+ {
+ T_array B(*this);
+ B.transposeSelf(r);
+ return B;
+ }
+
+ template<class T_numtype, int N_rank>
void Array<T_numtype, N_rank>::transposeSelf(int r0, int r1, int r2,
int r3,
int r4, int r5, int r6, int r7, int r8, int r9, int r10)
{
***************
*** 305,310 ****
--- 314,331 ----
doTranspose(8, r8, x);
doTranspose(9, r9, x);
doTranspose(10, r10, x);
+ }
+
+ template<class T_numtype, int N_rank>
+ void Array<T_numtype, N_rank>::transposeSelf(const TinyVector<int,
N_rank>& r)
+ {
+ // Create a temporary reference copy of this array
+ Array<T_numtype, N_rank> x(*this);
+
+ // Now reorder the dimensions using the supplied permutation
+ for(int i=0; i<N_rank; ++i) {
+ doTranspose(i, r[i], x);
+ }
}
template<class T_numtype, int N_rank>
--------------------- blitz-dev list --------------------------------
* To subscribe/unsubscribe: use the handy web form at
http://oonumerics.org/blitz/lists.html
This archive was generated by hypermail 2b29 : Wed Feb 20 2002 - 04:30:12 EST