encodeVectorBlob function

Uint8List encodeVectorBlob(
  1. Vector v
)

Encode v as the canonical BLOB layout: LE uint32 dim, then dim × LE float32 values.

Implementation

Uint8List encodeVectorBlob(Vector v) {
  final out = Uint8List(4 + 4 * v.dim);
  final bd = ByteData.sublistView(out);
  bd.setUint32(0, v.dim, Endian.little);
  for (var i = 0; i < v.dim; i++) {
    bd.setFloat32(4 + 4 * i, v.values[i], Endian.little);
  }
  return out;
}