Index reduce ( int dim ) { if ( ( dim < 0 ) || ( dim >= rank ) ) throw new IllegalArgumentException ( "illegal reduce dim " + dim ) ; if ( shape [ dim ] != 1 ) throw new IllegalArgumentException ( "illegal reduce dim " + dim + " : length != 1" ) ; Index newindex = Index . factory ( rank - 1 ) ; newindex . offset = offset ; int count = 0 ; for ( int ii = 0 ; ii < rank ; ii ++ ) { if ( ii != dim ) { newindex . shape [ count ] = shape [ ii ] ; newindex . stride [ count ] = stride [ ii ] ; //if (name != null) newindex.name[count] = name[ii]; count ++ ; } } newindex . size = computeSize ( newindex . shape ) ; newindex . fastIterator = fastIterator ; newindex . precalc ( ) ; // any subclass-specific optimizations return newindex ; }
Create a new Index based on current one by eliminating the specified dimension ;