Search code examples
fortranlapackblasintel-mkl

are there any functions in BLAS that can perform skew-symmetric matrix-vector products?


I'm thinking of performing some calculations with Intel-MKL, specifically the matrix-vector Sparse BLAS functions for a program in Fortran.

I can express my calculations in matrices that happen to be sparse and skew-symmetric

From what I can see, Sparse BLAS has sparse functions for general and symmetric matrices, so I wanted to know if I there was a way to work with a sparse skew-symmetric matrix instead, because I imagine it would reduce memory footprint.


Solution

  • TLDR; MKL Sparse BLAS can do matrix-vector multiplications with a sparse matrix expressed as the upper/lower triangle by the mkl_scsrmv subroutine subroutine and supplying 'A' to the first element in the matrix descriptor array.

    Ok I managed to find the answer to my question when I started testing the general MKL Sparse BLAS matrix-vector multiplication in CSR format (mkl_?csrmv)

    I learnt that there is a character array that is used to describe the input matrix (matdescra). The first character in this array can be set to 'A' which causes the subroutine to interpret the input matrix as skew-symmetric. For example (not necessarily a good one),

    Given a matrix, A, and and vector, x,:

    A = [ 0  1  2      x = [ 1
         -1  0  3            2
         -2 -3  0 ]           3 ]
    

    The upper-triangle of A can be represented as

    val = [1, 2, 3]
    col = [2, 3, 3]
    rowstart = [1, 3, 3]
    rowend = [3 3 4]
    

    and with the character array matdescra = ['A', 'U', 'N', 'F'], The matrix-vector product is obtained by

    call mkl_scsrmv('n', 3, 3, 1., matdescra, val, rowstart, rowend, x, 1., y
    

    where the output (a vector) is added to the vector-array, y.