VecF32.generate constructor

VecF32.generate(
  1. int length,
  2. double generator(
    1. int i
    )
)

Implementation

factory VecF32.generate(int length, double Function(int i) generator) {
  final pp = calloc<cvg.VecF32>()..ref.length = length;
  pp.ref.ptr = calloc<ffi.Float>(length);
  for (var i = 0; i < length; i++) {
    final v = generator(i);
    pp.ref.ptr[i] = v;
  }
  return VecF32.fromPointer(pp);
}