Skip to content

#396 please add "BCRSMatrix += Scalar" operator

Metadata

Property Value
Reported by Jö Fahlke (jorrit@jorrit.de)
Reported at May 19, 2008 17:15
Type Feature Request
Version Git (pre2.4) [autotools]
Operating System Unspecified / All
Last edited by Jö Fahlke (jorrit@jorrit.de)
Last edited at May 19, 2008 17:20

Description

The operator should add unity times the scalar to the matrix. For example adding the unit matrix to matrix A then becomes A += 1. I currently use the following implementation:

  template<typename B, typename A>
  BCRSMatrix<B, A> &
  operator+=(BCRSMatrix<B, A> &M, typename B::field_type scalar)
  {
    assert(M.N() == M.M());
    for(int i = 0; i < M.N(); ++i)
      M[i][i] += scalar;
    return M;
  }

(This uses operator+=(FieldMatrix, Scalar) from #395 (closed) indirectly)