# How to do element wise division in java using Mat.mul?

Suppose I have to Mat,i want to do element wise division(m1./m2), Then how to do it using Mat.mul method?

edit retag close merge delete

what are m1, m2, exactly ? why do you want to use mult() for division ?

you can replace division by multiplication only, if m2 is a scalar.

( 2016-12-22 03:19:27 -0600 )edit

Mat m1=new Mat(); Mat m2=new Mat();

Now I want to divide m1 & m2 elementwise, So what should be scalar value?

( 2016-12-22 03:29:44 -0600 )edit

ok, let me clarify, if m is a matrix, and you have a number, like 5, you can replace the m/5 division by multiplying by 0.2. (but this is only valid for single numbers (Scalars))

( 2016-12-22 03:35:30 -0600 )edit

Sort by ยป oldest newest most voted

i guess, the problem is, that you found a Mat.mul() member function, but there is no Mat.div() or similar.

use Core.divide(src1, src2, dst) in that case.

more

But will Core.divide do element wise division?

( 2016-12-22 03:30:59 -0600 )edit

yes, that's element-wise. (there is a matrix multiplication in maths, but no such counterpart for division).

( 2016-12-22 03:33:25 -0600 )edit

oh I forgot that thing, Thank you for help berak....:D

( 2016-12-22 03:34:36 -0600 )edit

Official site

GitHub

Wiki

Documentation