public static AffineTransformation reorderAxesTransformation ( int dim , int ... axes ) { double [ ] [ ] m = zeroMatrix ( dim + 1 ) ; // insert ones appropriately: for ( int i = 0 ; i < axes . length ; i ++ ) { assert ( 0 < axes [ i ] && axes [ i ] <= dim ) ; m [ i ] [ axes [ i ] - 1 ] = 1.0 ; } int useddim = 1 ; for ( int i = axes . length ; i < dim + 1 ; i ++ ) { // find next "unused" dimension. { boolean search = true ; while ( search ) { search = false ; for ( int a : axes ) { if ( a == useddim ) { search = true ; useddim ++ ; break ; } } } } m [ i ] [ useddim - 1 ] = 1.0 ; useddim ++ ; } assert ( useddim - 2 == dim ) ; return new AffineTransformation ( dim , m , null ) ; }
Generate a transformation that reorders axes in the given way .