Inlining + Reorganization + Roofline
This commit is contained in:
committed by
Linus Baumberger
parent
43f11a661b
commit
b86c856e08
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
#include <math.h>
|
||||
|
||||
struct Vector2d {
|
||||
double x, y;
|
||||
Vector2d(double a, double b) : x(a), y(b) {}
|
||||
Vector2d() : x(.0), y(.0) {}
|
||||
Vector2d operator+(Vector2d v) const { return Vector2d(v.x + x, v.y + y); }
|
||||
Vector2d operator-(Vector2d v) const { return Vector2d(x - v.x, y - v.y); }
|
||||
Vector2d operator-(double a) const { return Vector2d(x - a, y - a); }
|
||||
Vector2d operator+(double a) const { return Vector2d(x + a, y + a); }
|
||||
Vector2d operator/(double a) const { return Vector2d(x / a, y / a); }
|
||||
Vector2d operator*(double a) const { return Vector2d(x * a, y * a); }
|
||||
Vector2d operator+=(const Vector2d &v) {
|
||||
*this = *this + v;
|
||||
return *this;
|
||||
}
|
||||
Vector2d operator-=(const Vector2d &v) {
|
||||
*this = *this - v;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Vector2d reverse_sign() { return Vector2d(-x, -y); }
|
||||
|
||||
// # 1 ADD, 2 MULTs, 1 SQRT
|
||||
double norm() { return sqrt(x * x + y * y); }
|
||||
|
||||
// # 1 ADD, 2 MULTs
|
||||
double dot(Vector2d v) { return x * v.x + y * v.y; }
|
||||
void reset() {
|
||||
x = 0;
|
||||
y = 0;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user