HMLP: High-performance Machine Learning Primitives
vector.hpp
1 #ifndef _PVFMM_VECTOR_HPP_
2 #define _PVFMM_VECTOR_HPP_
3 
4 #include <pvfmm/common.hpp>
5 
6 #include <vector>
7 #include <cstdlib>
8 #include <cstdint>
9 
10 namespace pvfmm {
11 
12 template <class ValueType> class Vector {
13 
14  public:
15  typedef ValueType ValType;
16 
17  Vector();
18 
19  Vector(Long dim_, Iterator<ValueType> data_ = Iterator<ValueType>(NULL), bool own_data_ = true);
20 
21  Vector(const Vector& V);
22 
23  Vector(const std::vector<ValueType>& V);
24 
25  ~Vector();
26 
27  void Swap(Vector<ValueType>& v1);
28 
29  void ReInit(Long dim_, Iterator<ValueType> data_ = NULL, bool own_data_ = true);
30 
31  void Write(const char* fname) const;
32 
33  void Read(const char* fname);
34 
35  Long Dim() const;
36 
37  Long Capacity() const;
38 
39  void SetZero();
40 
41  Iterator<ValueType> Begin();
42 
43  ConstIterator<ValueType> Begin() const;
44 
45  void PushBack(const ValueType& x);
46 
47  Vector& operator=(const Vector& V);
48 
49  Vector& operator=(const std::vector<ValueType>& V);
50 
51  ValueType& operator[](Long j);
52 
53  const ValueType& operator[](Long j) const;
54 
55  private:
56  Long dim;
57  Long capacity;
58  Iterator<ValueType> data_ptr;
59  bool own_data;
60 };
61 
62 template <class ValueType> std::ostream& operator<<(std::ostream& output, const Vector<ValueType>& V);
63 
64 } // end namespace
65 
66 #include <pvfmm/vector.txx>
67 
68 #endif //_PVFMM_VECTOR_HPP_
Definition: cheb_utils.hpp:12