@Override public void setInteger( final int f ) { set( f >= 1 ); }
@Override public void setInteger( final int f ) { set( f >= 1 ); }
@Override public void setInteger( final long f ) { set( f >= 1 ); }
@Override public void setInteger( final long f ) { set( f >= 1 ); }
@Override public void setBigInteger( final BigInteger b ) { set( b.compareTo(BigInteger.ZERO) > 0 ); }
@Override public void setBigInteger( final BigInteger b ) { set( b.compareTo(BigInteger.ZERO) > 0 ); }
@Override public BoolType get() { type.set( source.get().contains( label ) ); return type; }
@Override public BoolType get() { if ( source.get().get() ) { for ( int d = 0; d < n; ++d ) { final long pos = getLongPosition( d ); if ( pos <= min[ d ] || pos >= max[ d ] ) { type.set( true ); return type; } } for ( int i = 0; i < offsets.length; ++i ) { source.move( offsets[ i ] ); if ( !source.get().get() ) { source.move( resets[ i ] ); type.set( true ); return type; } } source.move( resets[ resets.length - 1 ] ); } type.set( false ); return type; }
@Test public void test() { final FunctionRandomAccessible< BoolType > function = new FunctionRandomAccessible< BoolType >( 4, (pos, val) -> val.set( pos.getDoublePosition(0) > 0 && pos.getDoublePosition(1) > 1 && pos.getDoublePosition(2) > 2 && pos.getDoublePosition(3) > 3 ), BoolType::new ); FunctionRandomAccessible<BoolType>.FunctionRandomAccess access = function.randomAccess(); access.setPosition( new long[] {1, 2, 3, 4} ); assertTrue( access.get().get() ); access.setPosition( new long[] {0, 2, 3, 4} ); assertTrue( !access.get().get() ); access.setPosition( new long[] {1, 0, 3, 4} ); assertTrue( !access.get().get() ); access.setPosition( new long[] {1, 2, -10, 4} ); assertTrue( !access.get().get() ); access.setPosition( new long[] {10, 50, 5, 5} ); assertTrue( access.get().get() ); }
@Test public void test() { final FunctionRealRandomAccessible< BoolType > function = new FunctionRealRandomAccessible< BoolType >( 4, (pos, val) -> val.set( pos.getDoublePosition(0) > 0 && pos.getDoublePosition(1) > 1 && pos.getDoublePosition(2) > 2 && pos.getDoublePosition(3) > 3 ), BoolType::new ); FunctionRealRandomAccessible<BoolType>.RealFunctionRealRandomAccess access = function.realRandomAccess(); access.setPosition( new double[] {1, 2, 3, 4} ); assertTrue( access.get().get() ); access.setPosition( new double[] {0, 2, 3, 4} ); assertTrue( !access.get().get() ); access.setPosition( new double[] {1, 0, 3, 4} ); assertTrue( !access.get().get() ); access.setPosition( new double[] {1, 2, -10, 4} ); assertTrue( !access.get().get() ); access.setPosition( new double[] {10, 50, 5, 5} ); assertTrue( access.get().get() ); }