FVector.join constructor

FVector.join(
  1. List<FVector> vectors
)

Builds a new FVector composed from multiple other FVector's

Implementation

factory FVector.join(List<FVector> vectors) {
  int nRows = vectors.fold(
      0, (int previousValue, element) => previousValue + element.nRows);
  Float32List newColumnData = Float32List(roundUp4(nRows));
  int currentVec = 0;
  int src = 0;
  for (int dest = 0; dest < nRows; ++dest) {
    while (src == vectors[currentVec].length) {
      src = 0;
      currentVec++;
    }
    newColumnData[dest] = vectors[currentVec][src];
    src++;
  }
  return FVector.fromBuffer(nRows, newColumnData.buffer.asFloat32x4List());
}