validateEqualLengthVectors static method
Ensures all vectors in a 2D dataset have the same length.
Example input:
[
1.0, 2.0,
2.5, 3.1,
4.2, 5.0
]
Implementation
static void validateEqualLengthVectors(List<List<double>> data) {
if (data.isEmpty) return;
final int length = data[0].length;
for (var vector in data) {
if (vector.length != length) {
throw ArgumentError('All vectors must have the same number of elements.');
}
}
}