NVIDIA / CUDALibrarySamples

CUDA Library Samples
Other
1.5k stars 311 forks source link

Incorrect matrix product in example for cusparseSpSM CSR #175

Closed BenVanDerMeer closed 6 months ago

BenVanDerMeer commented 6 months ago

In the examples for cusparseSpSM CSR (https://github.com/NVIDIA/CUDALibrarySamples/tree/master/cuSPARSE/spsm_csr). The given matrix product is incorrect, and the A matrix isn't even triangular? Not sure what's happening here.

malmasri7 commented 6 months ago

Hi @BenVanDerMeer, The formula should be op(A) * X = alpha * op(Y), where X is the output and Y is the input (RHS). [To fix soon] SpSM and SpSV take a square sparse matrix and use cusparseSpMatSetAttribute() to specify the fill mode: lower/upper and diagonal type: unit/non-unit. Please let me know if you have more questions.

BenVanDerMeer commented 6 months ago

Hi @malmasri7, thanks for that. I see now that the lower fill and non-unit diagonal mode effectively "mask" the A matrix to the lower triangular part, so the values 2, 3, and 7 are ignored. I had assumed that only a triangular matrix was allowed to be inputted, and the upper or lower fill mode would flag it as upper or lower.