Skip to content

Commit

Permalink
Speed up Vector.filled
Browse files Browse the repository at this point in the history
  • Loading branch information
gyrdym committed Jun 6, 2024
1 parent 8495b23 commit 8d9e7b1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Approx. 0.3 second (MacBook Pro 2019), Dart version: 2.16.0
// Approx. 0.23 second (MacBook Pro 2019), Dart version: 2.16.0

import 'package:benchmark_harness/benchmark_harness.dart';
import 'package:ml_linalg/vector.dart';
Expand Down
8 changes: 5 additions & 3 deletions lib/src/vector/float32x4_vector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,13 @@ class Float32x4Vector with IterableMixin<double> implements Vector {
}

_numOfBuckets = _getNumOfBuckets(length, _bucketSize);
final list = Float32List(_numOfBuckets * _bucketSize);
final list = Float32x4List(_numOfBuckets);
_buffer = list.buffer;

for (var i = 0; i < length; i++) {
list[i] = value.toDouble();
final simdValue = Float32x4.splat(value.toDouble());

for (var i = 0; i < _numOfBuckets; i++) {
list[i] = simdValue;
}
}

Expand Down

0 comments on commit 8d9e7b1

Please sign in to comment.