For example, I want to multiply the scalar, Gamma, by the NxN matrix, A, and return the result as the NxN matrix, B, i.e. B = Gamma * A.
First, I create DenseMatrix64F A
, DenseMatrix64F B
and double Gamma
. Then, I would like to use the method:
org.ejml.ops.CommonOps.mult(Gamma, A, B);
I get a compiler error that Gamma
is double
that cannot be applied to mult()
in CommonOps
. The webpage for the mult
method is here.
I don't know where I am going wrong. Please could you help me solve the problem?
To perform element-by-element scalar multiplication, use
org.ejml.CommonOps.scale
.In your case, try:
In your example, the error arises because the three-argument form of
org.ejml.CommonOps.mult
expects the first argument to be of typeDenseMatrix64F
, as in:As such, when you pass in a
double
as the first argument you will get a compiler error. Moreover,mult
performs matrix multiplication c = a * b, which is not necessary for your example.