PARALUTION  1.0.0
PARALUTION
host_matrix_coo.hpp
Go to the documentation of this file.
1 #ifndef PARALUTION_HOST_MATRIX_COO_HPP_
2 #define PARALUTION_HOST_MATRIX_COO_HPP_
3 
4 #include "../base_vector.hpp"
5 #include "../base_matrix.hpp"
6 #include "../matrix_formats.hpp"
7 
8 namespace paralution {
9 
10 template <typename ValueType>
11 class HostMatrixCOO : public HostMatrix<ValueType> {
12 
13 public:
14 
15  HostMatrixCOO();
16  HostMatrixCOO(const Paralution_Backend_Descriptor local_backend);
17  virtual ~HostMatrixCOO();
18 
19  virtual void info(void) const;
20  virtual unsigned int get_mat_format(void) const { return COO; }
21 
22  virtual void Clear(void);
23  virtual void AllocateCOO(const int nnz, const int nrow, const int ncol);
24 
25  virtual void SetDataPtrCOO(int **row, int **col, ValueType **val,
26  const int nnz, const int nrow, const int ncol);
27  virtual void LeaveDataPtrCOO(int **row, int **col, ValueType **val);
28 
29  virtual bool Scale(const ValueType alpha);
30  virtual bool ScaleDiagonal(const ValueType alpha);
31  virtual bool ScaleOffDiagonal(const ValueType alpha);
32  virtual bool AddScalar(const ValueType alpha);
33  virtual bool AddScalarDiagonal(const ValueType alpha);
34  virtual bool AddScalarOffDiagonal(const ValueType alpha);
35 
36  virtual bool ConvertFrom(const BaseMatrix<ValueType> &mat);
37 
38  virtual bool Permute(const BaseVector<int> &permutation);
39  virtual bool PermuteBackward(const BaseVector<int> &permutation);
40 
41  virtual void CopyFromCOO(const int *row, const int *col, const ValueType *val);
42  virtual void CopyToCOO(int *row, int *col, ValueType *val) const;
43 
44  virtual void CopyFrom(const BaseMatrix<ValueType> &mat);
45  virtual void CopyTo(BaseMatrix<ValueType> *mat) const;
46 
47  virtual bool ReadFileMTX(const std::string);
48  virtual bool WriteFileMTX(const std::string) const;
49 
50  virtual void Apply(const BaseVector<ValueType> &in, BaseVector<ValueType> *out) const;
51  virtual void ApplyAdd(const BaseVector<ValueType> &in, const ValueType scalar,
52  BaseVector<ValueType> *out) const;
53 
54 private:
55 
57 
58  friend class BaseVector<ValueType>;
59  friend class HostVector<ValueType>;
60  friend class HostMatrixCSR<ValueType>;
61  friend class HostMatrixDIA<ValueType>;
62  friend class HostMatrixELL<ValueType>;
63  friend class HostMatrixHYB<ValueType>;
64  friend class HostMatrixDENSE<ValueType>;
65 
66  friend class GPUAcceleratorMatrixCOO<ValueType>;
67  friend class OCLAcceleratorMatrixCOO<ValueType>;
68  friend class MICAcceleratorMatrixCOO<ValueType>;
69 
70 };
71 
72 
73 }
74 
75 #endif // PARALUTION_HOST_MATRIX_COO_HPP_
virtual void SetDataPtrCOO(int **row, int **col, ValueType **val, const int nnz, const int nrow, const int ncol)
Initialize a COO matrix on the Host with externally allocated data.
Definition: host_matrix_coo.cpp:116
virtual bool AddScalar(const ValueType alpha)
Add alpha to all values.
Definition: host_matrix_coo.cpp:608
Definition: base_matrix.hpp:24
virtual bool Permute(const BaseVector< int > &permutation)
Perform (forward) permutation of the matrix.
Definition: host_matrix_coo.cpp:496
Definition: base_matrix.hpp:80
Definition: base_matrix.hpp:14
virtual bool Scale(const ValueType alpha)
Scale all values.
Definition: host_matrix_coo.cpp:567
virtual bool ConvertFrom(const BaseMatrix< ValueType > &mat)
Convert the matrix from another matrix (with different structure)
Definition: host_matrix_coo.cpp:263
virtual void Clear(void)
Clear (free) the matrix.
Definition: host_matrix_coo.cpp:73
virtual bool ScaleDiagonal(const ValueType alpha)
Scale the diagonal entries of the matrix with alpha.
Definition: host_matrix_coo.cpp:580
nnz
Definition: pcg_example.m:8
virtual bool AddScalarOffDiagonal(const ValueType alpha)
Add alpha to the off-diagonal entries of the matrix.
Definition: host_matrix_coo.cpp:635
virtual void CopyFrom(const BaseMatrix< ValueType > &mat)
Copy from another matrix.
Definition: host_matrix_coo.cpp:213
const IndexType const IndexType const IndexType const ValueType const ValueType scalar
Definition: cuda_kernels_coo.hpp:91
virtual void ApplyAdd(const BaseVector< ValueType > &in, const ValueType scalar, BaseVector< ValueType > *out) const
Apply and add the matrix to vector, out = out + scalar*this*in;.
Definition: host_matrix_coo.cpp:473
virtual void CopyFromCOO(const int *row, const int *col, const ValueType *val)
Copy from COO array (the matrix has to be allocated)
Definition: host_matrix_coo.cpp:161
Definition: base_vector.hpp:10
virtual void CopyTo(BaseMatrix< ValueType > *mat) const
Copy to another matrix.
Definition: host_matrix_coo.cpp:256
MatrixCOO< ValueType, int > mat_
Definition: host_matrix_coo.hpp:56
Definition: base_matrix.hpp:61
virtual bool PermuteBackward(const BaseVector< int > &permutation)
Perform (backward) permutation of the matrix.
Definition: host_matrix_coo.cpp:526
virtual unsigned int get_mat_format(void) const
Return the matrix format id (see matrix_formats.hpp)
Definition: host_matrix_coo.hpp:20
virtual bool WriteFileMTX(const std::string) const
Write matrix to MTX (Matrix Market Format) file.
Definition: host_matrix_coo.cpp:324
virtual bool ReadFileMTX(const std::string)
Read matrix from MTX (Matrix Market Format) file.
Definition: host_matrix_coo.cpp:297
Definition: base_matrix.hpp:42
Definition: base_matrix.hpp:20
Definition: base_matrix.hpp:22
virtual void Apply(const BaseVector< ValueType > &in, BaseVector< ValueType > *out) const
Apply the matrix to vector, out = this*in;.
Definition: host_matrix_coo.cpp:446
virtual void LeaveDataPtrCOO(int **row, int **col, ValueType **val)
Leave a COO matrix to Host pointers.
Definition: host_matrix_coo.cpp:139
Base class for all host/accelerator matrices.
Definition: base_matrix.hpp:92
virtual void AllocateCOO(const int nnz, const int nrow, const int ncol)
Allocate COO Matrix.
Definition: host_matrix_coo.cpp:89
virtual void info(void) const
Shows simple info about the object.
Definition: host_matrix_coo.cpp:65
Definition: backend_manager.cpp:43
virtual void CopyToCOO(int *row, int *col, ValueType *val) const
Copy to COO array (the arrays have to be allocated)
Definition: host_matrix_coo.cpp:187
virtual ~HostMatrixCOO()
Definition: host_matrix_coo.cpp:56
HostMatrixCOO()
Definition: host_matrix_coo.cpp:34
Definition: matrix_formats.hpp:24
virtual bool AddScalarDiagonal(const ValueType alpha)
Add alpha to the diagonal entries of the matrix.
Definition: host_matrix_coo.cpp:621
virtual bool ScaleOffDiagonal(const ValueType alpha)
Scale the off-diagonal entries of the matrix with alpha.
Definition: host_matrix_coo.cpp:594
Definition: base_matrix.hpp:18