linearAlgebraSolverLib
Loading...
Searching...
No Matches
vector.hpp
1#pragma once
2
3// preprocessor statements
4#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
5 #if defined(COMPILEDLL)
6 #define LINEARALGEBRALIB_EXPORT __declspec(dllexport)
7 #elif defined(COMPILELIB)
8 #define LINEARALGEBRALIB_EXPORT
9 #else
10 #define LINEARALGEBRALIB_EXPORT __declspec(dllimport)
11 #endif
12#else
13 #define LINEARALGEBRALIB_EXPORT
14#endif
15
16// c++ include headers
17#include <iostream>
18#include <vector>
19#include <cassert>
20#include <cmath>
21
22// third-party include headers
23
24// linear algebra solver library include headers
25
26// helper classes
27
28namespace linearAlgebraLib {
29
41class Vector {
44public:
45 using VectorType = std::vector<double>;
47
50public:
51 LINEARALGEBRALIB_EXPORT Vector(const unsigned &size);
53
56public:
57 LINEARALGEBRALIB_EXPORT unsigned size() const;
58 LINEARALGEBRALIB_EXPORT Vector transpose();
59 LINEARALGEBRALIB_EXPORT double getL2Norm() const;
61
64
66
69public:
70 LINEARALGEBRALIB_EXPORT const double &operator[](unsigned index) const;
71 LINEARALGEBRALIB_EXPORT double &operator[](unsigned index);
72
73 LINEARALGEBRALIB_EXPORT Vector operator+(const Vector &other);
74 LINEARALGEBRALIB_EXPORT Vector operator-(const Vector &other);
75
76 LINEARALGEBRALIB_EXPORT Vector &operator*(const double &scaleFactor);
77 LINEARALGEBRALIB_EXPORT friend Vector operator*(const double &scaleFactor, Vector vector);
78 LINEARALGEBRALIB_EXPORT double operator*(const Vector &other);
79
80 LINEARALGEBRALIB_EXPORT friend std::ostream &operator<<(std::ostream &out, const Vector &vector);
82
85
87
90private:
91 VectorType _vector;
92 bool _isRowVector = false;
94};
95
96} // namespace linearAlgebraLib
A vector class with overloaded operators to facilitate arithmetic vector operations.
Definition vector.hpp:41