/** * get "corners" of an interval as a list of points. */ public static List< RealLocalizable > getCorners( final RealInterval interval ) { final ArrayList< RealLocalizable > corners = new ArrayList<>(); final int n = interval.numDimensions(); final int[] tmp = new int[ n ]; Arrays.fill( tmp, 2 ); final LocalizingZeroMinIntervalIterator i = new LocalizingZeroMinIntervalIterator( tmp ); while ( i.hasNext() ) { i.fwd(); final RealPoint p = new RealPoint( n ); for ( int d = 0; d < n; ++d ) p.setPosition( i.getIntPosition( d ) == 0 ? interval.realMin( d ) : interval.realMax( d ), d ); corners.add( p ); } return corners; } }
final long loopSize = myChunk.getLoopSize(); final LocalizingZeroMinIntervalIterator cursorDim = new LocalizingZeroMinIntervalIterator( fakeSize ); final T sum = integral.firstElement().createVariable(); cursorDim.jumpFwd( myChunk.getStartPosition() ); cursorDim.fwd(); cursorDim.localize( tmp2 );
@Override public void fwd() { driver.fwd(); if ( driver.getIndex() == centralPositionIndex ) driver.fwd(); for ( int d = 0; d < numDimensions; ++d ) randomAccess.setPosition( positionMinus1[ d ] + driver.getLongPosition( d ), d ); }
public LocalNeighborhoodCursor( final LocalNeighborhoodCursor< T > cursor ) { this.source = cursor.source; this.randomAccess = source.randomAccess(); this.randomAccess.setPosition( cursor.randomAccess ); this.numDimensions = cursor.numDimensions(); this.tmp = cursor.tmp.clone(); this.positionMinus1 = cursor.positionMinus1.clone(); final int[] dim = new int[ numDimensions ]; for ( int d = 0; d < numDimensions; ++d ) dim[ d ] = 3; this.driver = new LocalizingZeroMinIntervalIterator( dim ); this.driver.jumpFwd( cursor.driver.getIndex() ); this.centralPositionIndex = cursor.centralPositionIndex; }
/** * Create new {@link LocalNeighborhoodCursor} on a {@link RandomAccessible} at a certain location. * * Note: the location can be updated without need to re-instantiate all the times. * * @param source - the data as {@link RandomAccessible} * @param center - the center location of the 3x3x3...x3 environment that will be skipped */ public LocalNeighborhoodCursor( final RandomAccessible< T > source, final long[] center ) { this.source = source; this.randomAccess = source.randomAccess(); this.numDimensions = source.numDimensions(); this.tmp = new long[ numDimensions ]; this.positionMinus1 = new long[ numDimensions ]; final int[] dim = new int[ numDimensions ]; final int[] dim2 = new int[ numDimensions ]; for ( int d = 0; d < numDimensions; ++d ) { dim[ d ] = 3; dim2[ d ] = 1; positionMinus1[ d ] = center[ d ] - 1; } this.driver = new LocalizingZeroMinIntervalIterator( dim ); this.centralPositionIndex = IntervalIndexer.positionToIndex( dim2, dim ); }
@Override public boolean hasNext() { return driver.hasNext(); }
public LocalNeighborhoodCursor( final LocalNeighborhoodCursor< T > cursor ) { this.source = cursor.source; this.randomAccess = source.randomAccess(); this.randomAccess.setPosition( cursor.randomAccess ); this.numDimensions = cursor.numDimensions(); this.tmp = cursor.tmp.clone(); this.positionMinus1 = cursor.positionMinus1.clone(); final int[] dim = new int[ numDimensions ]; for ( int d = 0; d < numDimensions; ++d ) dim[ d ] = 3; this.driver = new LocalizingZeroMinIntervalIterator( dim ); this.driver.jumpFwd( cursor.driver.getIndex() ); this.centralPositionIndex = cursor.centralPositionIndex; }
this.driver = new LocalizingZeroMinIntervalIterator( dim ); this.centralPositionIndex = IntervalIndexer.positionToIndex( dim2, dim );
@Override public boolean hasNext() { return driver.hasNext(); }
fakeSize[ countDim++ ] = dataSize[ d ]; final LocalizingZeroMinIntervalIterator cursorDim = new LocalizingZeroMinIntervalIterator( fakeSize ); while ( cursorDim.hasNext() ) cursorDim.fwd(); if ( cursorDim.getIntPosition( 0 ) % numThreads == myNumber ) cursorDim.localize( fakeSize );
final LocalizingZeroMinIntervalIterator cursor = new LocalizingZeroMinIntervalIterator( effectiveSize ); cursor.jumpFwd( start ); cursor.fwd(); cursor.localize( tmp );
@Override public void fwd() { driver.fwd(); if ( driver.getIndex() == centralPositionIndex ) driver.fwd(); for ( int d = 0; d < numDimensions; ++d ) randomAccess.setPosition( positionMinus1[ d ] + driver.getLongPosition( d ), d ); }
/** * Create new {@link LocalNeighborhoodCursor} on a {@link RandomAccessible} at a certain location. * * Note: the location can be updated without need to re-instantiate all the times. * * @param source - the data as {@link RandomAccessible} * @param center - the center location of the 3x3x3...x3 environment that will be skipped */ public LocalNeighborhoodCursor( final RandomAccessible< T > source, final Localizable center ) { this.source = source; this.randomAccess = source.randomAccess(); this.numDimensions = source.numDimensions(); this.tmp = new long[ numDimensions ]; this.positionMinus1 = new long[ numDimensions ]; final int[] dim = new int[ numDimensions ]; final int[] dim2 = new int[ numDimensions ]; for ( int d = 0; d < numDimensions; ++d ) { dim[ d ] = 3; dim2[ d ] = 1; positionMinus1[ d ] = center.getLongPosition( d ) - 1; } this.driver = new LocalizingZeroMinIntervalIterator( dim ); this.centralPositionIndex = IntervalIndexer.positionToIndex( dim2, dim ); }
new LocalizingZeroMinIntervalIterator(fakeSize); while (cursorDim.hasNext()) { cursorDim.fwd(); if (cursorDim.getIntPosition(0) % numThreads == myNumber) { cursorDim.localize(fakeSize);
final long loopSize = myChunk.getLoopSize(); final LocalizingZeroMinIntervalIterator cursorDim = new LocalizingZeroMinIntervalIterator( fakeSize ); final T sum = integral.firstElement().createVariable(); cursorDim.jumpFwd( myChunk.getStartPosition() ); cursorDim.fwd(); cursorDim.localize( tmp );
this.driver = new LocalizingZeroMinIntervalIterator( dim ); this.centralPositionIndex = IntervalIndexer.positionToIndex( dim2, dim );
final LocalizingZeroMinIntervalIterator cursor = new LocalizingZeroMinIntervalIterator( numBlocks ); final ArrayList< Block > blockList = new ArrayList< Block >(); while ( cursor.hasNext() ) cursor.fwd(); cursor.localize( currentBlock );
final Localizable offsetOutput = outputLineIterator.getOffset(); final LocalizingZeroMinIntervalIterator cursorDim = new LocalizingZeroMinIntervalIterator( fakeSize ); while( cursorDim.hasNext() ) cursorDim.fwd(); if ( numThreads == 1 || cursorDim.getIntPosition( 0 ) % numThreads == myNumber ) cursorDim.localize( fakeSize );
final LocalizingZeroMinIntervalIterator cursor = new LocalizingZeroMinIntervalIterator( numBlocks ); final ArrayList< Block > blockList = new ArrayList< Block >(); while ( cursor.hasNext() ) cursor.fwd(); cursor.localize( currentBlock );
final LocalizingZeroMinIntervalIterator cursor = new LocalizingZeroMinIntervalIterator( numBlocks ); final ArrayList< Block > blockList = new ArrayList< Block >(); while ( cursor.hasNext() ) cursor.fwd(); cursor.localize( currentBlock );