forked from maik-nack/OptimizationSolver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIVector.h
76 lines (63 loc) · 2.27 KB
/
IVector.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#ifndef IVECTOR_H
#define IVECTOR_H
#include "error.h"
#include "SHARED_EXPORT.h"
class SHARED_EXPORT IVector
{
public:
enum InterfaceTypes
{
INTERFACE_0,
DIMENSION_INTERFACE_IMPL
};
enum NormType
{
NORM_1,
NORM_2,
NORM_INF,
DIMENSION_NORM
};
virtual int getId() const = 0;
/*factories*/
static IVector* createVector(unsigned int size, double const* vals);
/*operations*/
virtual int add(IVector const* const right) = 0;
virtual int subtract(IVector const* const right) = 0;
virtual int multiplyByScalar(double scalar) = 0;
virtual int dotProduct(IVector const* const right, double& res) const = 0;
virtual int crossProduct(IVector const* const right)
{
qt_assert("NOT IMPLEMENTED", __FILE__, __LINE__);
return ERR_NOT_IMPLEMENTED;
}
/*static operations*/
static IVector* add(IVector const* const left, IVector const* const right);
static IVector* subtract(IVector const* const left, IVector const* const right);
static IVector* multiplyByScalar(IVector const* const left, double scalar);
static IVector* crossProduct(IVector const* const left, IVector const* const right)
{
qt_assert("NOT IMPLEMENTED", __FILE__, __LINE__);
return static_cast<IVector*>(0);
}
/*comparators*/
virtual int gt(IVector const* const right, NormType type, bool& result) const = 0;
virtual int lt(IVector const* const right, NormType type, bool& result) const = 0;
virtual int eq(IVector const* const right, NormType type, bool& result, double precision) const = 0;
/*utils*/
virtual unsigned int getDim() const = 0;
virtual int norm(NormType type, double& res) const = 0;
virtual int setCoord(unsigned int index, double elem) = 0;
virtual int getCoord(unsigned int index, double & elem) const = 0;
virtual int setAllCoords(unsigned int dim, double* coords) = 0;
virtual int getCoordsPtr(unsigned int & dim, double const*& elem) const = 0;
virtual IVector* clone() const = 0;
/*dtor*/
virtual ~IVector() {};
protected:
IVector() = default;
private:
/*non default copyable*/
IVector(const IVector& other) = delete;
void operator=(const IVector& other) = delete;
};
#endif // IVECTOR_H