PARALUTION  1.0.0
PARALUTION
vector.hpp
Go to the documentation of this file.
1 #ifndef PARALUTION_VECTOR_HPP_
2 #define PARALUTION_VECTOR_HPP_
3 
4 #include "base_paralution.hpp"
5 
6 #include <iostream>
7 #include <string>
8 #include <cstdlib>
9 
10 namespace paralution {
11 
12 template <typename ValueType>
13 class LocalVector;
14 
15 // Vector
16 template <typename ValueType>
17 class Vector : public BaseParalution<ValueType> {
18 
19 public:
20 
21  Vector();
22  virtual ~Vector();
23 
25  virtual int get_size(void) const = 0;
26 
29  virtual bool Check(void) const = 0;
30 
32  virtual void Clear() = 0;
33 
35  virtual void Zeros() = 0;
36 
38  virtual void Ones() = 0;
39 
41  virtual void SetValues(const ValueType val) = 0;
42 
44  virtual void SetRandom(const ValueType a = -1.0, const ValueType b = 1.0, const int seed = 0) = 0;
45 
47  virtual void ReadFileASCII(const std::string) = 0;
48 
50  virtual void WriteFileASCII(const std::string) const = 0;
51 
53  virtual void ReadFileBinary(const std::string) = 0;
54 
56  virtual void WriteFileBinary(const std::string) const = 0;
57 
59  virtual void CopyFrom(const LocalVector<ValueType> &src);
60 
62  virtual void CopyFromAsync(const LocalVector<ValueType> &src);
63 
65  virtual void CopyFromFloat(const LocalVector<float> &src);
66 
68  virtual void CopyFromDouble(const LocalVector<double> &src);
69 
71  virtual void CloneFrom(const LocalVector<ValueType> &src);
72 
74  virtual void AddScale(const LocalVector<ValueType> &x, const ValueType alpha);
75 
77  virtual void ScaleAdd(const ValueType alpha, const LocalVector<ValueType> &x);
78 
80  virtual void ScaleAddScale(const ValueType alpha, const LocalVector<ValueType> &x,
81  const ValueType beta);
82 
84  virtual void ScaleAdd2(const ValueType alpha, const LocalVector<ValueType> &x,
85  const ValueType beta, const LocalVector<ValueType> &y, const ValueType gamma);
86 
88  virtual void Scale(const ValueType alpha) = 0;
89 
91  virtual void PartialSum(const LocalVector<ValueType> &x);
92 
94  virtual ValueType Dot(const LocalVector<ValueType> &x) const;
95 
97  virtual ValueType DotNonConj(const LocalVector<ValueType> &x) const;
98 
100  virtual ValueType Norm(void) const = 0;
101 
103  virtual ValueType Reduce(void) const = 0;
104 
106  virtual ValueType Asum(void) const = 0;
107 
109  virtual int Amax(ValueType &value) const = 0;
110 
112  virtual void PointWiseMult(const LocalVector<ValueType> &x);
113 
115  virtual void PointWiseMult(const LocalVector<ValueType> &x, const LocalVector<ValueType> &y);
116 
118  virtual void Power(const double power) = 0;
119 
120 };
121 
122 
123 }
124 
125 #endif // PARALUTION_VECTOR_HPP_
virtual void SetRandom(const ValueType a=-1.0, const ValueType b=1.0, const int seed=0)=0
Set random values from interval [a,b].
virtual ValueType Asum(void) const =0
Compute the sum of the absolute values of the vector (L1 norm), return = sum(|this|) ...
virtual bool Check(void) const =0
Return true if the vector is ok (empty vector is also ok) and false if some of values are NaN...
virtual void ReadFileBinary(const std::string)=0
Read vector from binary file.
virtual void PointWiseMult(const LocalVector< ValueType > &x)
Perform point-wise multiplication (element-wise) of type this = this * x.
Definition: vector.cpp:128
virtual void CopyFromAsync(const LocalVector< ValueType > &src)
Async copy.
Definition: vector.cpp:40
virtual ~Vector()
Definition: vector.cpp:21
virtual void ScaleAddScale(const ValueType alpha, const LocalVector< ValueType > &x, const ValueType beta)
Perform vector update of type this = alpha*this + x*beta.
Definition: vector.cpp:151
virtual void CopyFromFloat(const LocalVector< float > &src)
Copy values from float vector.
Definition: vector.cpp:51
virtual int Amax(ValueType &value) const =0
Compute the absolute max value of the vector, return = index(max(|this|))
Definition: vector.hpp:17
virtual ValueType DotNonConj(const LocalVector< ValueType > &x) const
Compute non-conjugate dot (scalar) product, return this^T y.
Definition: vector.cpp:117
virtual ValueType Reduce(void) const =0
Reduce the vector.
virtual void Scale(const ValueType alpha)=0
Perform vector scaling this = alpha*this.
const IndexType const IndexType const IndexType const ValueType const ValueType const ValueType ValueType * y
Definition: cuda_kernels_coo.hpp:91
virtual void Clear()=0
Clear (free) the vector.
virtual void WriteFileASCII(const std::string) const =0
Write vector to ASCII file.
virtual void ReadFileASCII(const std::string)=0
Read vector from ASCII file.
void power(const int mic_dev, const int size, const double val, ValueType *vec)
Definition: mic_vector_kernel.cpp:241
virtual void WriteFileBinary(const std::string) const =0
Write vector to binary file.
virtual void PartialSum(const LocalVector< ValueType > &x)
Computes partial sum.
Definition: vector.cpp:174
virtual void CopyFrom(const LocalVector< ValueType > &src)
Copy values from another local vector.
Definition: vector.cpp:29
Base class for operator and vector (i.e. global/local matrix/stencil/vector) classes, all the backend-related interface and data are defined here.
Definition: base_paralution.hpp:41
virtual void Ones()=0
Set the values of the vector to one.
virtual void CopyFromDouble(const LocalVector< double > &src)
Copy values from double vector.
Definition: vector.cpp:62
Vector()
Definition: vector.cpp:11
virtual ValueType Dot(const LocalVector< ValueType > &x) const
Compute dot (scalar) product, return this^T y.
Definition: vector.cpp:106
Definition: backend_manager.cpp:43
virtual void Power(const double power)=0
Perform power operation to a vector.
virtual int get_size(void) const =0
Return the size of the vector.
const IndexType const IndexType const IndexType const ValueType const ValueType const ValueType * x
Definition: cuda_kernels_coo.hpp:91
virtual void Zeros()=0
Set the values of the vector to zero.
virtual void SetValues(const ValueType val)=0
Set the values of the vector to given argument.
virtual ValueType Norm(void) const =0
Compute L2 norm of the vector, return = srqt(this^T this)
virtual void AddScale(const LocalVector< ValueType > &x, const ValueType alpha)
Perform vector update of type this = this + alpha*x.
Definition: vector.cpp:84
virtual void CloneFrom(const LocalVector< ValueType > &src)
Clone the entire vector (data+backend descr) from another local vector.
Definition: vector.cpp:73
b(1:n)
virtual void ScaleAdd2(const ValueType alpha, const LocalVector< ValueType > &x, const ValueType beta, const LocalVector< ValueType > &y, const ValueType gamma)
Perform vector update of type this = alpha*this + x*beta + y*gamma.
Definition: vector.cpp:162
virtual void ScaleAdd(const ValueType alpha, const LocalVector< ValueType > &x)
Perform vector update of type this = alpha*this + x.
Definition: vector.cpp:95
Definition: host_vector.hpp:13