fastMap<T> abstract method
Returns a new vector from mapped elements of the original vector.
Mapping function mapper
should accept argument only of Float32x4 or
Float64x2 data type (depends on dtype value, e.g. if dtype equals
DType.float32 - the argument should be of Float32x4 type). The data
types mentioned above allow to perform mapping much faster than
the regular map method
import 'dart:typed_data';
import 'package:ml_linalg/vector.dart';
final vector = Vector.fromList([1.0, 2.0, 3.0, 4.0, 5.0, 6.0],
dtype: DType.float32);
final mapped = vector.fastMap((Float32x4 element) => element.scale(3.0));
print(mapped);
The output:
(3.0, 6.0, 9.0, 12.0, 15.0, 18.0)
Implementation
Vector fastMap<T>(T Function(T element) mapper);