mirror of
https://github.com/PaddiM8/kalker.git
synced 2025-06-26 12:42:15 +02:00
Don't allow multiplication of vectors of different sizes
This commit is contained in:
parent
0aabade786
commit
3b740423f7
@ -696,6 +696,10 @@ impl KalkValue {
|
|||||||
.collect(),
|
.collect(),
|
||||||
),
|
),
|
||||||
(KalkValue::Vector(values), KalkValue::Vector(values_rhs)) => {
|
(KalkValue::Vector(values), KalkValue::Vector(values_rhs)) => {
|
||||||
|
if values.len() != values_rhs.len() {
|
||||||
|
return KalkValue::nan();
|
||||||
|
}
|
||||||
|
|
||||||
let mut sum = KalkValue::from(0f64);
|
let mut sum = KalkValue::from(0f64);
|
||||||
for (value, value_rhs) in values.iter().zip(values_rhs) {
|
for (value, value_rhs) in values.iter().zip(values_rhs) {
|
||||||
sum = sum.add_without_unit(&value.clone().mul_without_unit(value_rhs));
|
sum = sum.add_without_unit(&value.clone().mul_without_unit(value_rhs));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user