private void readObject(final ObjectInputStream s) throws IOException, ClassNotFoundException { s.defaultReadObject(); subinventory16 = LongArrayBitVector.wrap(subinventory).asLongBigList(Short.SIZE); bits = bitVector.bits(); }
private void readObject(final ObjectInputStream s) throws IOException, ClassNotFoundException { s.defaultReadObject(); subinventory16 = LongArrayBitVector.wrap(subinventory).asLongBigList(Short.SIZE); bits = bitVector.bits(); }
protected Modulo3Equation(final Modulo3Equation equation){ this.c = equation.c; this.bitVector = equation.bitVector.copy(); this.bits = this.bitVector.bits(); this.list = this.bitVector.asLongBigList(2); this.firstVar = equation.firstVar; this.firstCoeff = equation.firstCoeff; this.isEmpty = equation.isEmpty; }
/** Creates a new equation. * * @param c the constant term. * @param numVars the number of variables. */ public Modulo3Equation(final long c, final int numVars) { this.c = c; this.bitVector = LongArrayBitVector.ofLength(numVars * 2); this.bits = bitVector.bits(); this.list = bitVector.asLongBigList(2); this.firstVar = Integer.MAX_VALUE; this.isEmpty = true; }
public boolean check(final long[] solution) { assert solution.length == numVars; final LongArrayBitVector solutions = LongArrayBitVector.ofLength(numVars * 2); final LongBigList list = solutions.asLongBigList(2); for(int i = solution.length; i-- != 0;) list.set(i, solution[i]); return check(solutions); }
/** Solves the system using Gaussian elimination and write the solution * in an array of longs (mainly for testing purposes). * * @param solution an array where the solution will be written. * @return true if the system is solvable. */ public boolean gaussianElimination(final long[] solution) { assert solution.length == numVars; final LongArrayBitVector solutions = LongArrayBitVector.ofLength(numVars * 2); if (! gaussianElimination(solutions)) return false; final LongBigList list = solutions.asLongBigList(2); for(int i = solution.length; i-- != 0;) solution[i] = list.getLong(i); return true; }
final LongBigList a = LongArrayBitVector.wrap(x).asLongBigList(registerSize); final LongBigList b = LongArrayBitVector.wrap(y).asLongBigList(registerSize); for(int i = 0; i < m; i++) { long pos = (i + 1) * (long)registerSize - 1; LongBigList a = LongArrayBitVector.wrap(t).asLongBigList(registerSize); LongBigList b = LongArrayBitVector.wrap(y).asLongBigList(registerSize); for(int i = 0; i < Long.SIZE * l / registerSize; i++) a.set(i, Math.max(a.getLong(i), b.getLong(i)));
final LongArrayBitVector bitVector = LongArrayBitVector.ofLength(registerSize * Math.min(CHUNK_SIZE, sizeInRegisters - ((long)i << CHUNK_SHIFT))); bits[i] = bitVector.bits(); registers[i] = bitVector.asLongBigList(registerSize);
/** Creates a new shift-add-xor signed string map using a given hash map. * * @param iterator an iterator enumerating a set of strings. * @param map a minimal perfect hash for the strings enumerated by <code>iterator</code>; it must support {@link Function#size() size()} * and have default return value -1. * @param signatureWidth the width, in bits, of the signature of each string. */ public ShiftAddXorSignedStringMap( final Iterator<? extends CharSequence> iterator, final Object2LongFunction<? extends CharSequence> map, final int signatureWidth ) { CharSequence s; this.function = map; this.width = signatureWidth; this.defRetValue = -1; shift = Long.SIZE - width; mask = width == Long.SIZE ? 0 : ( 1L << width ) - 1; final int n = map.size(); signatures = LongArrayBitVector.getInstance().asLongBigList( signatureWidth ).length( n ); for( int i = 0; i < n; i++ ) { s = iterator.next(); signatures.set( map.getLong( s ), signature( s ) ); } if ( iterator.hasNext() ) throw new IllegalStateException( "Iterator provides more than " + n + " elements" ); }
/** Creates a new shift-add-xor signed string map using a given hash map. * * @param iterator an iterator enumerating a set of strings. * @param map a minimal perfect hash for the strings enumerated by <code>iterator</code>; it must support {@link Function#size() size()} * and have default return value -1. * @param signatureWidth the width, in bits, of the signature of each string. */ public ShiftAddXorSignedStringMap( final Iterator<? extends CharSequence> iterator, final Object2LongFunction<? extends CharSequence> map, final int signatureWidth ) { CharSequence s; this.function = map; this.width = signatureWidth; this.defRetValue = -1; shift = Long.SIZE - width; mask = width == Long.SIZE ? 0 : ( 1L << width ) - 1; final int n = map.size(); signatures = LongArrayBitVector.getInstance().asLongBigList( signatureWidth ).length( n ); for( int i = 0; i < n; i++ ) { s = iterator.next(); signatures.set( map.getLong( s ), signature( s ) ); } if ( iterator.hasNext() ) throw new IllegalStateException( "Iterator provides more than " + n + " elements" ); }
/** Creates a new shift-add-xor signed string map using a given hash map. * * @param iterator an iterator enumerating a set of strings. * @param map a minimal perfect hash for the strings enumerated by <code>iterator</code>; it must support {@link Function#size() size()} * and have default return value -1. * @param signatureWidth the width, in bits, of the signature of each string. */ public ShiftAddXorSignedStringMap(final Iterator<? extends CharSequence> iterator, final Object2LongFunction<? extends CharSequence> map, final int signatureWidth) { CharSequence s; this.function = map; this.width = signatureWidth; this.defRetValue = -1; shift = Long.SIZE - width; mask = width == Long.SIZE ? 0 : (1L << width) - 1; final int n = map.size(); signatures = LongArrayBitVector.getInstance().asLongBigList(signatureWidth); signatures.size(n); for(int i = 0; i < n; i++) { s = iterator.next(); signatures.set(map.getLong(s), signature(s)); } if (iterator.hasNext()) throw new IllegalStateException("Iterator provides more than " + n + " elements"); }
/** Creates a new shift-add-xor signed string map using a given hash map. * * @param iterator an iterator enumerating a set of strings. * @param map a minimal perfect hash for the strings enumerated by <code>iterator</code>; it must support {@link Function#size() size()} * and have default return value -1. * @param signatureWidth the width, in bits, of the signature of each string. */ public ShiftAddXorSignedStringMap(final Iterator<? extends CharSequence> iterator, final Object2LongFunction<? extends CharSequence> map, final int signatureWidth) { CharSequence s; this.function = map; this.width = signatureWidth; this.defRetValue = -1; shift = Long.SIZE - width; mask = width == Long.SIZE ? 0 : (1L << width) - 1; final long n = map instanceof Size64 ? ((Size64)map).size64() : map.size(); (signatures = LongArrayBitVector.getInstance().asLongBigList(signatureWidth)).size(n); for(long i = 0; i < n; i++) { s = iterator.next(); signatures.set(map.getLong(s), signature(s)); } if (iterator.hasNext()) throw new IllegalStateException("Iterator provides more than " + n + " elements"); }
/** Solves the system using Gaussian elimination and write the solution * in a bit vector. * * @param solution a bit vector where the solution will be written using * two bits per value. * @return true if the system is solvable. */ public boolean gaussianElimination(final LongArrayBitVector solution) { assert solution.length() == numVars * 2; for (final Modulo3Equation equation: equations) equation.updateFirstVar(); if (! echelonForm()) return false; final long[] solutionBits = solution.bits(); final LongBigList solutionList = solution.asLongBigList(2); for (int i = equations.size(); i-- != 0;) { final Modulo3Equation equation = equations.get(i); if (equation.isIdentity()) continue; assert solutionList.getLong(equation.firstVar) == 0 : equation.firstVar; long sum = (equation.c - Modulo3Equation.scalarProduct(equation.bits, solutionBits)) % 3; if (sum < 0) sum += 3; solutionList.set(equation.firstVar, sum == 0 ? 0 : equation.firstCoeff == sum ? 1 : 2); } return true; } /** Solves the system using lazy Gaussian elimination.
l = length == 0 ? 0 : Math.max(0, Fast.mostSignificantBit(upperBound / length)); final long lowerBitsMask = (1L << l) - 1; final LongBigList lowerBitsList = LongArrayBitVector.getInstance().asLongBigList(l); lowerBitsList.size(length); final BitVector upperBitsVector = LongArrayBitVector.getInstance().length(length + (upperBound >>> l) + 1);
lowerLBitsMask = (1L << l) - 1; final LongArrayBitVector lowerBitsVector = LongArrayBitVector.getInstance(); final LongBigList lowerBitsList = lowerBitsVector.asLongBigList(l); lowerBitsList.size(m); upperBits = LongArrayBitVector.getInstance().length(m + (n >>> l) + 1);
final long lowerBitsMask = (1L << l) - 1; final LongArrayBitVector lowerBitsVector = LongArrayBitVector.getInstance(); final LongBigList lowerBitsList = lowerBitsVector.asLongBigList(l); lowerBitsList.size(length); final BitVector upperBits = LongArrayBitVector.getInstance().length(length + (upperBound >>> l) + 1);
for(int i = bits.length; i-- != 0;) resultRegisters[i] = (LongArrayBitVector.wrap(resultBits[i] = new long[bits[i].length])).asLongBigList(registerSize);
/** Generate a list of signatures using the lowest bits of the first hash in this store. * * <p>For this method to work, this store must contain ranks. * * @param signatureWidth the width in bits of the signatures. * @param pl a progress logger. */ public LongBigList signatures(final int signatureWidth, final ProgressLogger pl) throws IOException { final LongBigList signatures = LongArrayBitVector.getInstance().asLongBigList(signatureWidth); final long signatureMask = -1L >>> Long.SIZE - signatureWidth; signatures.size(size()); pl.expectedUpdates = size(); pl.itemsName = "signatures"; pl.start("Signing..."); for (final ChunkedHashStore.Chunk chunk : this) { final Iterator<long[]> chunkIterator = chunk.iterator(); for(int i = chunk.size(); i-- != 0;) { final long[] quadruple = chunkIterator.next(); signatures.set(quadruple[3], signatureMask & quadruple[0]); pl.lightUpdate(); } } pl.done(); return signatures; }
final long numSmall = minCostSmall / (minIndex + 1); final long numLarge = minCostLarge / width; (small = LongArrayBitVector.getInstance().asLongBigList(minIndex)).size(numSmall); (marker = LongArrayBitVector.getInstance()).length(length); (large = LongArrayBitVector.getInstance().asLongBigList(width)).size(numLarge); (small = LongArrayBitVector.getInstance().asLongBigList(minIndex)).size(length); marker = null; large = null;
final LongBigList t = LongArrayBitVector.getInstance().asLongBigList(Fast.length(sizeInBits)); while (offsetsIterator.hasNext()) t.add(offsetsIterator.nextLong());