# Can anyone explain the dtype parameter of OpenCV's c++ multiply [closed]

I have 2 matrices with contents as below

```
a=
1 2 3
4 5 6
7 8 9
b=
1 2 3
4 5 6
7 8 9
```

when I multiply with dtype parameter as below

```
Mat a = Mat(3 3 CV_8U data);
Mat b = Mat(3 3 CV_8U data);
multiply(a b dest 1.0 2);
```

.... I get this as result I was hoping someone could explain this to me as a noob to the multiply function but not matrix multiplication

```
1 0 4
16 0 25
49 0 64
```

can't reproduce.

uchar data[] = { 1,2,3,4,5,6,7,8,9 };

Mat a = Mat(3, 3, CV_8U, data);

Mat b = Mat(3, 3, CV_8U, data);

Mat dest;

multiply(a, b, dest, 1.0, 2);

cerr << dest << endl;

(multiply does

per-elementmultiplication, not matrix-wise. and dtype is the type of the result-matrix, CV_16U in your case.)not only that your code lacks all commas, thus does not compile, i'm amazed, how on earth you produced that 'zero' column ...

well it would make some sense, if you printed out bytes (while having a ushort mat)

@berak Thanks for your reply, I apologize I put in a quick example, hoping for a dtype explanation. The example was just to get the ball rolling...I could just honestly use a tutorial on how to derive the dtype param...lets say I was working with 2 64 bit float Mats or 32S?. Nothing seems to be online for this, It would be great if this could be the first online resource for this ?

dtype is not something you derive, but user input. ie, you may have wanted the multiply output to be double (to achieve higher precision).

usually it's set to -1 meaning, take the src type for dst