Vector.zero constructor

Vector.zero(
  1. int length, {
  2. DType dtype = DType.float32,
})

Creates a vector filled with zeroes with length equal to length.

A usage example:

import 'package:ml_linalg/vector.dart';

final vector = Vector.zero(5, dtype: DType.float32);

print(vector);

the output will be like that:

(0.0, 0.0, 0.0, 0.0, 0.0)

Implementation

factory Vector.zero(
  int length, {
  DType dtype = DType.float32,
}) {
  switch (dtype) {
    case DType.float32:
      return Float32x4Vector.zero(
        length,
        CacheManagerFactoryImpl().create(vectorCacheKeys),
        const Float32x4Helper(),
      );

    case DType.float64:
      return Float64x2Vector.zero(
        length,
        CacheManagerFactoryImpl().create(vectorCacheKeys),
        const Float64x2Helper(),
      );

    default:
      throw UnimplementedError(
          'Vector of $dtype type is not implemented yet');
  }
}