You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+14-9Lines changed: 14 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,15 @@
1
1
# Lanczos solver,
2
2
Computes the matrix-vector product sqrt(M)·v using a recursive algorithm.
3
-
For that, it requires a functor in which the () operator takes an output real* array and an input real* (both in device memory if compiled in CUDA mode or host memory otherwise) as:
3
+
For that, it requires a functor with a "dot" function that takes an output real* array and an input real* (both in device memory if compiled in CUDA mode or host memory otherwise) as:
4
4
```c++
5
-
inlinevoidoperator()(real* in_v, real * out_Mv);
5
+
virtualvoiddot(real* in_v, real * out_Mv) override;
6
6
```
7
+
The functor must inherit ```lanczos::MatrixDot``` (see example.cu).
7
8
This function must fill "out" with the result of performing the M·v dot product- > out = M·a_v.
8
9
If M has size NxN and the cost of the dot product is O(M). The total cost of the algorithm is O(m·M). Where m << N.
9
10
If M·v performs a dense M-V product, the cost of the algorithm would be O(m·N^2).
10
11
11
-
This is a header-only library, although a shared library can be
12
+
This is a header-only library, although a shared library can be compiled instead.
12
13
13
14
## Usage:
14
15
@@ -19,8 +20,8 @@ Let us go through the remaining one, a GPU-only example.
19
20
20
21
Create the module:
21
22
```c++
22
-
real tolerance = 1e-6;
23
-
lanczos::Solver lanczos(tolerance);
23
+
24
+
lanczos::Solver lanczos;
24
25
```
25
26
Write a functor that computes the product between the original matrix and a given vector, "v":
26
27
```c++
@@ -30,7 +31,7 @@ struct DiagonalMatrix: public lanczos::MatrixDot{
30
31
int size;
31
32
DiagonalMatrix(int size): size(size){}
32
33
33
-
void operator()(real* v, real* Mv){
34
+
void dot(real* v, real* Mv) override{
34
35
//An example diagonal matrix
35
36
for(int i=0; i<size; i++){
36
37
Mv[i] = 2*v[i];
@@ -54,10 +55,14 @@ Provide the solver with an instance of the functor and the target vector:
0 commit comments