Converts G1 element @x into an array of bytes. If @compress is True, 
    the point will be compressed resulting in a much shorter string of bytes.
324117
def serializeG1(x, compress=True):
    
    assertType(x, G1Element)
    return _serialize(x, compress, librelic.g1_size_bin_abi,
        librelic.g1_write_bin_abi)
73491
def _numpy_bytes_to_char(arr):
    
    # ensure the array is contiguous
    arr = np.array(arr, copy=False, order='C', dtype=np.string_)
    return arr.reshape(arr.shape + (1,)).view('S1')
1163394
public final byte[] compress(byte[] in) {
    switch (this.compressMode) {
      case GZIP:
        return gzipCompress(in);
      case ZIP:
        return zipCompress(in);
      default:
        return gzipCompress(in);
    }

  }
1355858
public static void longToByteArray(long lValue, byte[] buffer, int nStartIndex) {
	buffer[nStartIndex] = (byte) (lValue >>> 56);
	buffer[nStartIndex + 1] = (byte) ((lValue >>> 48) & 0x0ff);
	buffer[nStartIndex + 2] = (byte) ((lValue >>> 40) & 0x0ff);
	buffer[nStartIndex + 3] = (byte) ((lValue >>> 32) & 0x0ff);
	buffer[nStartIndex + 4] = (byte) ((lValue >>> 24) & 0x0ff);
	buffer[nStartIndex + 5] = (byte) ((lValue >>> 16) & 0x0ff);
	buffer[nStartIndex + 6] = (byte) ((lValue >>> 8) & 0x0ff);
	buffer[nStartIndex + 7] = (byte) lValue;
    }
660477
static int lowLevelCompressBytes(
      final byte[] byteArray,          // input
      final int numBytesToEncode,      // input, must be an int
      final short[] encodingTable,     // input
      final int[] compressedWords) {   // output

    int nextWordIndex = 0;
    long bitBuf = 0;  // bits are packed into this first, then are flushed to compressedWords
    int bufBits = 0;  // number of bits currently in bitbuf; must be between 0 and 31

    for (int byteIndex = 0; byteIndex < numBytesToEncode; byteIndex++) {
      final int theByte = byteArray[byteIndex] & 0XFF;
      final long codeInfo = (encodingTable[theByte] & 0XFFFFL);
      final long codeVal = codeInfo & 0XFFFL;
      final int codeWordLength = (int) (codeInfo >>> 12);
      bitBuf |= (codeVal << bufBits);
      bufBits += codeWordLength;
      //MAYBE_FLUSH_BITBUF(compressedWords, nextWordIndex);
      if (bufBits >= 32) {
        compressedWords[nextWordIndex++] = (int) bitBuf;
        bitBuf >>>= 32;
        bufBits -= 32;
      }
    }

    //Pad the bitstream with 11 zero-bits so that the decompressor's 12-bit peek
    // can't overrun its input.
    bufBits += 11;
    //MAYBE_FLUSH_BITBUF(compressedWords, nextWordIndex);
    if (bufBits >= 32) {
      compressedWords[nextWordIndex++] = (int) bitBuf;
      bitBuf >>>= 32;
      bufBits -= 32;
    }

    if (bufBits > 0) { // We are done encoding now, so we flush the bit buffer.
      assert (bufBits < 32);
      compressedWords[nextWordIndex++] = (int) bitBuf;
    }
    return nextWordIndex;
  }
336321
protected byte[] decompress(byte[] in) {
    switch (this.compressMode) {
      case GZIP:
        return gzipDecompress(in);
      case ZIP:
        return zipDecompress(in);
      default:
        return gzipDecompress(in);
    }
  }
209446
function compact(arr) {
  if (!Array.isArray(arr)) {
    throw new Error('expected an array');
  }
  var result = [];
  var len = arr.length;
  for (var i = 0; i < len; i++) {
    var elem = arr[i];
    if (elem) {
      result.push(elem);
    }
  }
  return result;
}
823669
public static byte[] compress(final String strg) {

        final ByteArrayOutputStream output = new ByteArrayOutputStream();

        if (!isOnlyAscii(strg)) {
            final byte[] bytes = strg.getBytes(Charsets.UTF_8);
            output.write(UNCOMPRESSED_FLAG);
            output.write(bytes, 0, bytes.length);
            return output.toByteArray();
        }

        final StringBuilder verb = new StringBuilder();

        final CharBuffer charBuffer = CharBuffer.wrap(strg);
        int inlen;

        // loop through input looking for matches in codebook
        while ((inlen = charBuffer.remaining()) > 0) {
            int h1, h2, h3;
            charBuffer.mark();
            h1 = h2 = charBuffer.get() << 3;
            if (inlen > 1) {
                h2 += charBuffer.get();
            }
            if (inlen > 2) {
                h3 = h2 ^ charBuffer.get();
            } else {
                h3 = 0;
            }
            charBuffer.reset();

            int j = 7;
            if (j > inlen) {
                j = inlen;
            }

            boolean found = false;

            /*
             * Try to lookup substrings into the codebook, starting from the longer to the shorter
             * substrings
             */
            for (; j > 0; j--) {
                CharBuffer slot;
                if (j == 1) {
                    slot = CharBuffer.wrap(CODEBOOK[h1 % 241]);
                } else if (j == 2) {
                    slot = CharBuffer.wrap(CODEBOOK[h2 % 241]);
                } else {
                    slot = CharBuffer.wrap(CODEBOOK[h3 % 241]);
                }

                final int slotLength = slot.length();
                int slotIndex = 0;
                int slotEndIndex = slotIndex + j + 1;
                while (slotLength > 0 && slotEndIndex <= slotLength) {
                    if (slot.get(slotIndex) == j
                            && inlen >= j
                            && slot.subSequence(slotIndex + 1, slotEndIndex).toString()
                                    .equals(charBuffer.subSequence(0, j).toString())) {
                        // Match found in codebook
                        // Add verbatim data if needed
                        if (verb.length() > 0) {
                            // output the verbatim data now
                            outputVerb(output, verb.toString());
                            verb.setLength(0);
                        }

                        // Add encoded data and ditch unnecessary part of input
                        // string
                        output.write(slot.get(slot.get(slotIndex) + 1 + slotIndex));
                        charBuffer.position(charBuffer.position() + j);
                        inlen -= j;
                        found = true;
                        break;
                    } else {
                        slotIndex++;
                        slotEndIndex = slotIndex + j + 1;
                    }
                }
            }

            // match not found, add to verbatim
            if (!found) {
                if (inlen > 0) {
                    inlen--;
                    verb.append(charBuffer.subSequence(0, 1).toString());
                }
                charBuffer.position(charBuffer.position() + 1);
            }

            // If the verbatim buffer is getting too long or we're at the end of
            // the doc throw the verbatim buffer to the output queue
            final int verbLength = verb.length();
            if (verbLength == 255 || verbLength > 0 && inlen == 0) {
                outputVerb(output, verb.toString());
                verb.setLength(0);
            }

        }
        return output.toByteArray();
    }
55501
public static byte [] serialize(Serializable serializable, boolean compress) throws IOException {
        requireNonNull(serializable);

        try (ByteArrayOutputStream o = new ByteArrayOutputStream();
             ObjectOutputStream oos = new ObjectOutputStream(compress ? new GZIPOutputStream(o) : o)) {
            oos.writeObject(serializable);
            oos.flush();
            oos.close();  //must close before getting bytes because GZip streams require it.
            return o.toByteArray();
        }
    }
900269
def int_to_bytes(i, minlen=1, order='big'):  # pragma: no cover
        """"""
        blen = max(minlen, PGPObject.int_byte_len(i), 1)

        if six.PY2:
            r = iter(_ * 8 for _ in (range(blen) if order == 'little' else range(blen - 1, -1, -1)))
            return bytes(bytearray((i >> c) & 0xff for c in r))

        return i.to_bytes(blen, order)
210589
function (bytes) {
    var out = [], i, tmp=0;
    for (i=0; i<bytes.length; i++) {
      tmp = tmp << 8 | bytes[i];
      if ((i&3) === 3) {
        out.push(tmp);
        tmp = 0;
      }
    }
    if (i&3) {
      out.push(sjcl.bitArray.partial(8*(i&3), tmp));
    }
    return out;
  }
1111563
private double[][] getAugmentedData(double[][] x) {
        double[][] ret = new double[x.length + p][p];
        double padding = c * Math.sqrt(lambda2);
        for (int i = 0; i < x.length; i++) {
            for (int j = 0; j < p; j++) {
                ret[i][j] = c * x[i][j];
            }
        }
        for (int i = x.length; i < ret.length; i++) {
            ret[i][i - x.length] = padding;
        }
        return ret;
    }
749980
private static long byteArrayToLong(byte[] ba, int offset) {
		long l = 0;

		for (int i = 0; i < SIZE_OF_LONG; ++i) {
			l |= (ba[offset + SIZE_OF_LONG - 1 - i] & 0xffL) << (i << 3);
		}

		return l;
	}
1131084
def serializeGt(x, compress=True):
    
    assertType(x, GtElement)
    return _serialize(x, compress, librelic.gt_size_bin_abi,
        librelic.gt_write_bin_abi)
1329773
public byte[] convertBlock(int[] input, int inPos, byte[] output, int numOfComponents, int startCoordinate,
                               int row, int scanlineStride) {
        int index = 0, inputOffset = 0, bounds = 0;
        int len = output.length;

        for (int i = 0; i < DCTSIZE; i++) {
            index = startCoordinate + i * scanlineStride;
            bounds = row * scanlineStride;

            for (int j = 0; j < DCTSIZE; j++) {
                if (index >= len) {
                    return output;
                }

                if (index < bounds) {
                    for (int c = 0; c < numOfComponents; c++) {
                        output[index++] = (byte) (255 - (input[inputOffset++] & 0xFF));
                    }
                } else {
                    inputOffset += numOfComponents;
                }
            }

            row++;
        }

        return output;
    }
1307984
protected byte[] compress(final byte[] in) {
        if (in == null) {
            throw new NullPointerException("Can't compress null");
        }

        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        GZIPOutputStream gz = null;

        try {
            gz = new GZIPOutputStream(bos);
            gz.write(in);
        } catch (IOException e) {
            throw new RuntimeException("IO exception compressing data", e);
        } finally {
            close(gz);
            close(bos);
        }

        return bos.toByteArray();
    }
1253549
@Override
    public final byte[] decompress(byte[] compressed) {
        Assert.notNull(compressed, "compressed bytes cannot be null.");

        try {
            return doDecompress(compressed);
        } catch (IOException e) {
            throw new CompressionException("Unable to decompress bytes.", e);
        }
    }