Closed WenyinWei closed 4 years ago
Thanks for your suggestion!
One of the reasons why this is not implemented is that adding a scalar might also be ambiguous: Do you want to add the scalar to all entries of the matrix? Or just the diagonal? Keep in mind that e.g. for eigenvalues one usually writes (A - \lambda * Id), whereas A -= \lambda
as per your suggestion would mean something totally different. I would expect that
A += lambda;
y = prod(A, x);
leads to the same y
as
y = prod(A,x);
y += lambda * x;
by expanding the mathematical form (A + \lambda * id) x = Ax + \lambda x .
Oh, Karl, how quickly you reply. Yes, I am adding the scalar to all entries of the matrix and treat ViennaCL as an integrated backend for various GPUs. In fact, I utilize matrix class to construct 3D mesh class which may be not so relevant with the BLAS operations. The class is a basic of FDTD with regular rectangle physical coordinate and I wanna make it corporate with ViennaFVM in the future.
I guess the += & -= operators are not essential for the BLAS operation, so it may be out of ViennaCL team interest. I can manage it by newing a scalar matrix. I would appreciate it if the next update of ViennaCL can supplement the operators.
Hello, are the matrix_base class operators overloading += -= (ScalarType) missing? Now if I want to add a numeric to a matrix, I have to
my_matrix += scalar_matrix<vcl_ScalarT> (row, column, value);
Directly use the scalar would be rather swift, right?my_matrix += value;