/** Adds an equation to the system. * * @param equation an equation with the same number of variables of the system. */ public void add(final Modulo2Equation equation) { if (equation.bitVector.length() != numVars) throw new IllegalArgumentException("The number of variables in the equation (" + equation.bitVector.length() + ") does not match the number of variables of the system (" + numVars + ")"); equations.add(equation); }
public long longestCommonPrefixLength(final LongArrayBitVector v) { final long minLength = Math.min(v.length(), length()); final long words = (minLength + BITS_PER_WORD - 1) >> LOG2_BITS_PER_WORD; final long[] bits = this.bits; final long[] vBits = v.bits; for (int i = 0; i < words; i++) if (bits[i] != vBits[i]) return Math.min(minLength, (i << LOG2_BITS_PER_WORD) + Long.numberOfTrailingZeros(bits[i] ^ vBits[i])); return minLength; }
public long longestCommonPrefixLength( final LongArrayBitVector v ) { final long minLength = Math.min( v.length(), length() ); final long words = ( minLength + BITS_PER_WORD - 1 ) >> LOG2_BITS_PER_WORD; final long[] bits = this.bits; final long[] vBits = v.bits; for ( int i = 0; i < words; i++ ) if ( bits[ i ] != vBits[ i ] ) return Math.min( minLength, i * BITS_PER_WORD + Fast.leastSignificantBit( bits[ i ] ^ vBits[ i ] ) ); return minLength; }
public long longestCommonPrefixLength( final LongArrayBitVector v ) { final long minLength = Math.min( v.length(), length() ); final long words = ( minLength + BITS_PER_WORD - 1 ) >> LOG2_BITS_PER_WORD; final long[] bits = this.bits; final long[] vBits = v.bits; for ( int i = 0; i < words; i++ ) if ( bits[ i ] != vBits[ i ] ) return Math.min( minLength, i * BITS_PER_WORD + Fast.leastSignificantBit( bits[ i ] ^ vBits[ i ] ) ); return minLength; }
public boolean equals( final LongArrayBitVector v ) { if ( length != v.length() ) return false; int i = numWords( length ); while( i-- != 0 ) if ( bits[ i ] != v.bits[ i ] ) return false; return true; }
/** Creates a new empty bit vector of given length. * * @param length the size (in bits) of the new bit vector. */ public static LongArrayBitVector ofLength( final long length ) { return new LongArrayBitVector( length ).length( length ); }
public boolean equals( final LongArrayBitVector v ) { if ( length != v.length() ) return false; int i = numWords( length ); while( i-- != 0 ) if ( bits[ i ] != v.bits[ i ] ) return false; return true; }
public boolean equals(final LongArrayBitVector v) { if (length != v.length()) return false; int i = numWords(length); while(i-- != 0) if (bits[i] != v.bits[i]) return false; return true; }
/** Returns the number of bits used by this structure. * * @return the number of bits used by this structure. */ public long numBits() { if (n == 0) return 0; return (marker != null ? rank.numBits() + marker.length() : 0) + (data != null ? data.size64() : 0) * width + offsetAndSeed.length * (long)Long.SIZE; }
public boolean check(final LongArrayBitVector solutions) { assert solutions.length() == numVars * 2; final long[] solutionBits = solutions.bits(); for(final Modulo3Equation equation: equations) if (equation.c != Modulo3Equation.scalarProduct(equation.bits, solutionBits) % 3) return false; return true; }
/** Returns true if this node is the exit node of a string. * * @param v the string. * @param transform the transformation strategy used to build the trie this node belongs to. * @return true if the string exits at this node. */ public boolean isExitNodeOf(final LongArrayBitVector v, TransformationStrategy<? super U> transform) { return isExitNodeOf(v.length(), v.longestCommonPrefixLength(extent(transform)), transform); }
/** Returns an array containing the variables in increasing order. * * <p>Mainly for debugging purposes. * * @return an array containing the variables in increasing order. */ public int[] variables() { final IntArrayList variables = new IntArrayList(); for(int i = 0; i < bitVector.length(); i++) if (bitVector.getBoolean(i)) variables.add(i); return variables.toIntArray(); }