Vector.fromList constructor
Creates a vector from a source
.
A usage example:
import 'package:ml_linalg/vector.dart';
final vector = Vector.fromList([1, 2, 3, 4, 5], dtype: DType.float32);
print(vector);
the output will be like that:
(1.0, 2.0, 3.0, 4.0, 5.0)
Implementation
factory Vector.fromList(
List<num> source, {
DType dtype = DType.float32,
}) {
switch (dtype) {
case DType.float32:
return Float32x4Vector.fromList(
source,
CacheManagerFactoryImpl().create(vectorCacheKeys),
const Float32x4Helper(),
);
case DType.float64:
return Float64x2Vector.fromList(
source,
CacheManagerFactoryImpl().create(vectorCacheKeys),
const Float64x2Helper(),
);
default:
throw UnimplementedError(
'Vector of $dtype type is not implemented yet');
}
}