GDAL
alg
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
/*
37
* Matrix class with double entries.
38
* The elements are stored in column major order in a vector.
39
*/
40
struct
GDALMatrix
41
{
43
GDALMatrix() =
default
;
44
47
GDALMatrix(
int
rows,
int
cols)
48
: n_rows(rows), n_cols(cols), v(rows * cols, 0.)
49
{
50
}
51
53
inline
int
getNumRows()
const
54
{
55
return
n_rows;
56
}
57
59
inline
int
getNumCols()
const
60
{
61
return
n_cols;
62
}
63
65
inline
double
&operator()(
int
row,
int
col)
66
{
67
return
v[row + col *
static_cast<
size_t
>
(n_rows)];
68
}
69
71
inline
double
operator()(
int
row,
int
col)
const
72
{
73
return
v[row + col *
static_cast<
size_t
>
(n_rows)];
74
}
75
77
double
const
*data()
const
78
{
79
return
v.data();
80
}
81
83
double
*data()
84
{
85
return
v.data();
86
}
87
89
void
resize(
int
iRows,
int
iCols)
90
{
91
n_rows = iRows;
92
n_cols = iCols;
93
v.clear();
94
v.resize(
static_cast<
size_t
>
(iRows) * iCols);
95
}
96
97
private
:
98
int
n_rows = 0;
99
int
n_cols = 0;
100
std::vector<double> v;
101
};
102
103
bool
GDALLinearSystemSolve(GDALMatrix &A, GDALMatrix &RHS, GDALMatrix &X);
104
105
#endif
/* #ifndef GDALLINEARSYSTEM_H_INCLUDED */
106
Generated by
1.9.1