protected void fillMemData(Object data,int[] posits,int length,Object output,int outputOffset,int dim){
  if (data instanceof Object[]) {
    Object[] xo=(Object[])data;
    fillMemData(xo[posits[dim]],posits,length,output,outputOffset,dim + 1);
  }
 else {
    int startFrom=posits[dim];
    int startTo=outputOffset;
    int copyLength=length;
    if (posits[dim] < 0) {
      startFrom-=posits[dim];
      startTo-=posits[dim];
      copyLength+=posits[dim];
    }
    if (posits[dim] + length > this.dims[dim]) {
      copyLength-=posits[dim] + length - this.dims[dim];
    }
    System.arraycopy(data,startFrom,output,startTo,copyLength);
  }
}

protected void fillMemData ( Object data , int [ ] posits , int length , Object output , int outputOffset , int dim ) { if ( data instanceof Object [ ] ) { Object [ ] xo = ( Object [ ] ) data ; fillMemData ( xo [ posits [ dim ] ] , posits , length , output , outputOffset , dim + 1 ) ; } else { int startFrom = posits [ dim ] ; int startTo = outputOffset ; int copyLength = length ; if ( posits [ dim ] < 0 ) { startFrom -= posits [ dim ] ; startTo -= posits [ dim ] ; copyLength += posits [ dim ] ; } if ( posits [ dim ] + length > this . dims [ dim ] ) { copyLength -= posits [ dim ] + length - this . dims [ dim ] ; } System . arraycopy ( data , startFrom , output , startTo , copyLength ) ; } }
fill a single segment from memory . this routine is called recursively to handle multi - dimensional arrays . e . g . , if data is three - dimensional , this will recurse two levels until we get a call with a single dimensional datum . at that point the appropriate data will be copied into the output .
