Skip to content

Commit 008ca82

Browse files
committed
Update
1 parent 29bb80a commit 008ca82

3 files changed

Lines changed: 7 additions & 6 deletions

File tree

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Computes the matrix-vector product sqrt(M)·v using a recursive algorithm.
33
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:
44
```c++
5-
inline operator()(real* out_Mv, real * a_v);
5+
inline operator()(real* in_v, real * out_Mv);
66
```
77
This function must fill "out" with the result of performing the M·v dot product- > out = M·a_v.
88
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.
@@ -24,10 +24,11 @@ Create the module:
2424
```
2525
Write a functor that computes the product between the original matrix and a given vector, "v":
2626
```c++
27-
//A functor that will return the result of multiplying a certain matrix times a given vector
28-
struct MatrixDot{
27+
//A functor that will return the result of multiplying a certain matrix times a given vector.
28+
//Must inherit from lanczos::MatrixDot
29+
struct DiagonalMatrix: public lanczos::MatrixDot{
2930
int size;
30-
MatrixDot(int size): size(size){}
31+
DiagonalMatrix(int size): size(size){}
3132

3233
void operator()(real* v, real* Mv){
3334
//An example diagonal matrix

example.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ struct DiagonalMatrix: public lanczos::MatrixDot{
2323
int size;
2424
DiagonalMatrix(int size): size(size){}
2525

26-
virtual void operator()(real* v, real* Mv) override{
26+
void operator()(real* v, real* Mv){
2727
//an example diagonal matrix
2828
for(int i=0; i<size; i++){
2929
Mv[i] = (2+i/10.0)*v[i];

include/LanczosAlgorithm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*Raul P. Pelaez 2022. Lanczos Algotihm,
22
Computes the matrix-vector product sqrt(M)·v using a recursive algorithm.
33
For that, it requires a functor in which the () operator takes an output real* array and an input real* (both device memory) as:
4-
inline __host__ __device__ operator()(real* out_Mv, real * in_v);
4+
inline void operator()(real* in_v, real * out_Mv);
55
This function must fill "out" with the result of performing the M·v dot product- > out = M·a_v.
66
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.
77
If M·v performs a dense M-V product, the cost of the algorithm would be O(m·N^2).

0 commit comments

Comments
 (0)