summaryrefslogtreecommitdiff
path: root/inc/vec.h
diff options
context:
space:
mode:
Diffstat (limited to 'inc/vec.h')
-rw-r--r--inc/vec.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/inc/vec.h b/inc/vec.h
new file mode 100644
index 0000000..68482d5
--- /dev/null
+++ b/inc/vec.h
@@ -0,0 +1,44 @@
+// vec.h
+#ifndef VEC_H
+#define VEC_H
+
+#include <iostream>
+#include <vector>
+#include <stdexcept>
+
+template<typename T>
+class Vec {
+private:
+ std::vector<T> data;
+
+public:
+ Vec() = default;
+ Vec(const std::vector<T>& values) : data(values) {}
+
+ // Vector-Vector Operations
+ Vec<T> operator+(const Vec<T>& other) const;
+ Vec<T> operator-(const Vec<T>& other) const;
+ Vec<T> operator*(const Vec<T>& other) const;
+ Vec<T> operator/(const Vec<T>& other) const;
+ Vec<T> operator%(const Vec<T>& other) const;
+
+ // Vector-Scalar Operations
+ Vec<T> operator+(T scalar) const;
+ Vec<T> operator-(T scalar) const;
+ Vec<T> operator*(T scalar) const;
+ Vec<T> operator/(T scalar) const;
+ Vec<T> operator%(T scalar) const;
+
+ // Utility
+ void print() const;
+ size_t size() const { return data.size(); }
+
+ // Friend scalar-vector operations
+ friend Vec<T> operator+(T scalar, const Vec<T>& vec) { return vec + scalar; }
+ friend Vec<T> operator-(T scalar, const Vec<T>& vec);
+ friend Vec<T> operator*(T scalar, const Vec<T>& vec) { return vec * scalar; }
+ friend Vec<T> operator/(T scalar, const Vec<T>& vec);
+ friend Vec<T> operator%(T scalar, const Vec<T>& vec);
+};
+
+#endif