Skip to content
Snippets Groups Projects
Forked from Core Modules / dune-common
Source project has a limited visibility.
  • Christian Engwer's avatar
    bdf74dca
    [densematrix] use the correct scaling parameter for usmv and friends · bdf74dca
    Christian Engwer authored
    In the current state the scaling parameter for matrix-vector products
    (e.g. the alpha parameter for DenseMatrix<...>::usmv) is the
    field_type of the matrix. I you consider mixed precision, like in the
    xblas library, you would actually want the scaling to be of the same
    accuracy as the output vector; an other reason is vectorization for
    one matrix and multiple vectors.
    
    The patch contains two changes:
    
    a) the FieldTraits are extended, so that the contain specializations
       for C and C++ vectors
    b) the thre matrix implementations are changed, such that they deduce
       the type as FieldTraits<Y>::field_type, where Y is the type of the
       result vector.
    
    In the case of identity matrix the old implementation was laso completely wrong, as it used
    Y::axpy to implement usmv and Y::axpy expects alpha to be Y::value_type, so that we already
    had a type clash, which just went unnoticed, as we never used mixed-types.
    bdf74dca
    History
    [densematrix] use the correct scaling parameter for usmv and friends
    Christian Engwer authored
    In the current state the scaling parameter for matrix-vector products
    (e.g. the alpha parameter for DenseMatrix<...>::usmv) is the
    field_type of the matrix. I you consider mixed precision, like in the
    xblas library, you would actually want the scaling to be of the same
    accuracy as the output vector; an other reason is vectorization for
    one matrix and multiple vectors.
    
    The patch contains two changes:
    
    a) the FieldTraits are extended, so that the contain specializations
       for C and C++ vectors
    b) the thre matrix implementations are changed, such that they deduce
       the type as FieldTraits<Y>::field_type, where Y is the type of the
       result vector.
    
    In the case of identity matrix the old implementation was laso completely wrong, as it used
    Y::axpy to implement usmv and Y::axpy expects alpha to be Y::value_type, so that we already
    had a type clash, which just went unnoticed, as we never used mixed-types.