# Cross-covariance of 2 sample sets.

`calcCovarMarix`

works great for calculating the auto-covariance matrix of a given sample set.

Now, how does one calculate the cross-covariance of 2 sample sets?

Example: every row of a matrix is a sample. Samples are random vectors with possibly differing amount of variables:

```
Mat A = [[1, 2],
[2, 3]]
Mat B = [[3, 4, 5],
[4, 5, 6]]
```

In MATLAB one can simply do `cov(A, B)`

. How would one do it in C++ OpenCV?

Did you miss https://docs.scipy.org/doc/numpy/refe...

Or are you using C++?

My bad, I'm using C++. Edited Q.

I found this as well: https://www.mathworks.com/help/matlab...

Go to the section More About > Covariance.

Also check out: https://en.wikipedia.org/wiki/Cross-c...

Is that what you're looking for? If so, please let me know, and I'll see what I can do about writing some C++ code for you.

Yes, those resources are relevant.

The thing is, I could implement it myself from scratch using the definition found at https://en.wikipedia.org/wiki/Cross-c... .

However, it would probably be slow. And I expected something 'basic' as this to be present in OpenCV. Especially since

`calcCovarMatrix`

exists.again, please explain your use case, and your expectations.

The expectation should be pretty clear: I want the cross-covariance matrix of 2 sample sets, calculated using C++ OpenCV.