GDAL

- Main Page
- Related Pages
- Classes
- Files
- Download
- Issue Tracker

- File List
- File Members

gdallinearsystem.h
1 /******************************************************************************
2 *
3 * Project: GDAL
4 * Purpose: Linear system solver
5 * Author: VIZRT Development Team.
6 *
7 ******************************************************************************
8 * Copyright (c) 2017 Alan Thomas <alant@outlook.com.au>
9 *
10 * Permission is hereby granted, free of charge, to any person obtaining a
11 * copy of this software and associated documentation files (the "Software"),
12 * to deal in the Software without restriction, including without limitation
13 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 * and/or sell copies of the Software, and to permit persons to whom the
15 * Software is furnished to do so, subject to the following conditions:
16 *
17 * The above copyright notice and this permission notice shall be included
18 * in all copies or substantial portions of the Software.
19 *
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26 * DEALINGS IN THE SOFTWARE.
27 ****************************************************************************/
28
31 #ifndef GDALLINEARSYSTEM_H_INCLUDED
32 #define GDALLINEARSYSTEM_H_INCLUDED
33
34 #include <vector>
35 /*
36 * Matrix class with double entries.
37 * The elements are stored in column major order in a vector.
38 */
39 struct GDALMatrix
40 {
42 GDALMatrix() = default;
45 GDALMatrix(int rows, int cols) : n_rows(rows), n_cols(cols), v(rows * cols, 0.) {}
47 inline int getNumRows() const { return n_rows; }
49 inline int getNumCols() const { return n_cols; }
51 inline double & operator()(int row, int col) { return v[row + col * n_rows]; }
53 inline double operator()(int row, int col) const { return v[row + col * n_rows]; }
55 double const * data() const { return v.data(); }
57 double * data() { return v.data(); }
59 void resize(int iRows, int iCols)
60 {
61 n_rows = iRows;
62 n_cols = iCols;
63 v.clear();
64 v.resize(iRows * iCols);
65 }
66 private:
67 int n_rows = 0;
68 int n_cols = 0;
69 std::vector<double> v;
70 };
71
72 bool GDALLinearSystemSolve( GDALMatrix & A, GDALMatrix & RHS, GDALMatrix & X );
73
74
75 #endif /* #ifndef GDALLINEARSYSTEM_H_INCLUDED */
76