My Project
FPGAMatrix.hpp
1 /*
2  Copyright 2020 Equinor ASA
3 
4  This file is part of the Open Porous Media project (OPM).
5 
6  OPM is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  OPM is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with OPM. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #ifndef FPGA_MATRIX_HEADER_INCLUDED
21 #define FPGA_MATRIX_HEADER_INCLUDED
22 
23 #include <vector>
24 
25 namespace bda
26 {
27 
30 class Matrix {
31 
32 public:
33 
37  Matrix(int N_, int nnzs_)
38  : nnzValues(new double[nnzs_]),
39  colIndices(new int[nnzs_]),
40  rowPointers(new int[N_+1]),
41  N(N_),
42  nnzs(nnzs_)
43  {}
44 
47  delete[] nnzValues;
48  delete[] colIndices;
49  delete[] rowPointers;
50  }
51 
52 
69  int toRDF(int numColors, std::vector<int>& nodesPerColor,
70  std::vector<std::vector<int> >& colIndicesInColor, int nnzsPerRowLimit,
71  std::vector<std::vector<double> >& ubNnzValues, short int *ubColIndices, int *nnzValsSizes, unsigned char *NROffsets, int *colorSizes);
72 
73  double *nnzValues;
74  int *colIndices;
75  int *rowPointers;
76  int N;
77  int nnzs;
78 };
79 
80 void sortRow(int *colIndices, double *data, int left, int right);
81 
82 } // end namespace bda
83 
84 #endif // FPGA_MATRIX_HEADER_INCLUDED
This struct resembles a csr matrix, only doubles are supported The data is stored in contiguous memor...
Definition: FPGAMatrix.hpp:30
Matrix(int N_, int nnzs_)
Allocate Matrix and data arrays with given sizes.
Definition: FPGAMatrix.hpp:37
~Matrix()
All constructors allocate new memory, so always delete here.
Definition: FPGAMatrix.hpp:46
int toRDF(int numColors, std::vector< int > &nodesPerColor, std::vector< std::vector< int > > &colIndicesInColor, int nnzsPerRowLimit, std::vector< std::vector< double > > &ubNnzValues, short int *ubColIndices, int *nnzValsSizes, unsigned char *NROffsets, int *colorSizes)
Converts this matrix to the dataformat used by the FPGA.
Definition: FPGAMatrix.cpp:89