-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVector.hxx
87 lines (61 loc) · 1.79 KB
/
Vector.hxx
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
77
78
79
80
81
82
83
84
85
86
87
#ifndef LINALG_FILE_VECTOR_HXX
#include "Allocator.hxx"
namespace linalg
{
//! Class for basic vectors
template<class T, class Allocator =
typename DefaultAllocator<T>::allocator>
class Vector
{
protected:
//! Number of elements
size_t m_;
//! Pointer to stored elements
T* data_;
public:
Vector();
explicit Vector(size_t n);
Vector(const Vector<T, Allocator>& A);
~Vector();
void Clear();
int GetM() const;
size_t GetSize() const;
T* GetData() const;
void* GetDataVoid() const;
void Reallocate(size_t);
void Resize(size_t);
void SetData(size_t, T*);
void Nullify();
T& operator()(size_t);
const T& operator()(size_t) const;
Vector<T, Allocator>& operator=(const Vector<T, Allocator>&);
Vector<T, Allocator>& operator*=(const T&);
void PushBack(const T& x);
void PushBack(const Vector<T, Allocator>& x);
void Zero();
void Fill(const T& x);
void FillRand();
void Write(string FileName, bool with_size = true) const;
void Write(ostream& FileStream, bool with_size = true) const;
void WriteText(const string&) const;
void WriteText(ostream&) const;
void ReadText(const string&);
void ReadText(istream&);
};
template<class T>
void GetRand(T& x);
template<class T>
void GetRand(complex<T>& x);
template<class T>
T DotProd(const Vector<T>& x, Vector<T>& y);
template<class T>
T Norm2(const Vector<T>& x);
template<class T>
T Norm2(const Vector<complex<T> >& x);
template<class T>
void Add(const T& alpha, const Vector<T>& x, Vector<T>& y);
template<class T, class Allocator>
ostream& operator<<(ostream& out, const Vector<T, Allocator>&);
}
#define LINALG_FILE_VECTOR_HXX
#endif