reduced flop count

This commit is contained in:
Nguyen Quy Anh
2026-05-03 05:57:34 +02:00
parent 89dfdf7785
commit e9533ab925
10 changed files with 236 additions and 166 deletions
+6 -2
View File
@@ -15,9 +15,13 @@ struct Vector2d {
*this = *this + v;
return *this;
}
// # 4 flops = 1 SQRT, 2 MULTs, 1 ADD
Vector2d reverse_sign() { return Vector2d(-x, -y); }
// # 1 ADD, 2 MULTs, 1 SQRT
double norm() { return sqrt(x * x + y * y); }
// # 3 flops = 2 MULTs, 1 ADD
// # 1 ADD, 2 MULTs
double dot(Vector2d v) { return x * v.x + y * v.y; }
void reset() {
x = 0;