Index transpose ( int index1 , int index2 ) { if ( ( index1 < 0 ) || ( index1 >= rank ) ) throw new IllegalArgumentException ( ) ; if ( ( index2 < 0 ) || ( index2 >= rank ) ) throw new IllegalArgumentException ( ) ; Index newIndex = ( Index ) this . clone ( ) ; newIndex . stride [ index1 ] = stride [ index2 ] ; newIndex . stride [ index2 ] = stride [ index1 ] ; newIndex . shape [ index1 ] = shape [ index2 ] ; newIndex . shape [ index2 ] = shape [ index1 ] ; /* if (name != null) { newIndex.name[index1] = name[index2]; newIndex.name[index2] = name[index1]; } */ newIndex . fastIterator = false ; newIndex . precalc ( ) ; // any subclass-specific optimizations return newIndex ; }
create a new Index based on current one except transpose two of the indices .