flatten method
Implementation
List<double> flatten(List array, int nBlocks, int blockSize) {
//if(array.isEmpty) return [];
final firstElem = array[0];
if (firstElem is num || firstElem is double || firstElem is int) {
List<double> array2 = [];
for (final element in array) {
array2.add(element.toDouble());
}
return array2;
}
final n = nBlocks * blockSize;
Float32List? r = arrayCacheF32[n];
if (r == null) {
r = Float32List(n);
arrayCacheF32[n] = r;
}
if (nBlocks != 0) {
for (int i = 0; i < nBlocks; i++) {
List<num> data = array[i].storage.toList();
data.asMap().forEach((index, element) {
int idx = i * blockSize + index;
r![idx] = element.toDouble();
});
}
}
return r;
}