SPH
SparseMatrix.h
Go to the documentation of this file.
1 #pragma once
2 
7 
12 
14 
16 class SparseMatrix {
17 private:
18  class Impl;
20 
21 public:
23 
25  SparseMatrix(const Size rows, const Size cols);
26 
28 
30  void resize(const Size rows, const Size cols);
31 
35  void insert(const Size i, const Size j, const Float value);
36 
38  enum class Solver {
40  LU,
41 
44  CG,
45 
47  LSCG,
48 
50  BICGSTAB,
51  };
52 
58  Expected<Array<Float>> solve(const Array<Float>& values, const Solver solver, const Float tolerance = 0.);
59 };
60 
Generic dynamically allocated resizable storage.
Simplified implementation of std::unique_ptr, using only default deleter.
NAMESPACE_SPH_BEGIN
Definition: BarnesHut.cpp:13
Wrapper of type containing either a value or an error message.
uint32_t Size
Integral type used to index arrays (by default).
Definition: Globals.h:16
double Float
Precision used withing the code. Use Float instead of float or double where precision is important.
Definition: Globals.h:13
#define NAMESPACE_SPH_END
Definition: Object.h:12
Wrapper of another pointer-like object with reference-like const correctness.
Wrapper of type that either contains a value of given type, or an error message.
Definition: Expected.h:25
Const-propagating wrapper for object with point semantics.
Sparse representation of matrix of arbitrary dimension.
Definition: SparseMatrix.h:16
void insert(const Size i, const Size j, const Float value)
Adds a values to given element of the matrix.
SparseMatrix(const Size rows, const Size cols)
Constructs square n x m empty matrix.
void resize(const Size rows, const Size cols)
Changes the size of the matrix, removing all previous entries.
Expected< Array< Float > > solve(const Array< Float > &values, const Solver solver, const Float tolerance=0.)
Solver
Solvers of sparse systems.
Definition: SparseMatrix.h:38
@ BICGSTAB
Stabilized bi-conjugate gradient method, can be used for any square matrix.
@ LSCG
Least-square conjugate gradient, can be used for any matrix.
@ LU
LU factorization, precise but very slow for large problems.