Vector.filled constructor
Creates a vector of length equal to length
filled with value
.
A usage example:
import 'package:ml_linalg/vector.dart';
final vector = Vector.filled(5, 2, dtype: DType.float32);
print(vector);
the output will be like that:
(2.0, 2.0, 2.0, 2.0, 2.0)
Implementation
factory Vector.filled(
int length,
num value, {
DType dtype = DType.float32,
}) {
switch (dtype) {
case DType.float32:
return Float32x4Vector.filled(
length,
value,
CacheManagerFactoryImpl().create(vectorCacheKeys),
const Float32x4Helper(),
);
case DType.float64:
return Float64x2Vector.filled(
length,
value,
CacheManagerFactoryImpl().create(vectorCacheKeys),
const Float64x2Helper(),
);
default:
throw UnimplementedError(
'Vector of $dtype type is not implemented yet');
}
}