Construct a Mat of pointers to a Mat

asked Apr 30 '15

Hi all!

I've tried to google this a lot - but without any luck. Hope you can help!

Basically I want to construct the following cyclic matrix

M =
|a *b *c|
|
b c *a|
|
c *a *b|

where the elements are pointers to a 1D Mat

v = (a b c)

Such that whenever I change a value in the vector the matrix is then updated accordingly, and I can multiply the matrix M with another matrix for instance.

Am I supposed to use something like Ptr<mat> to initialise M? And how do I assign pointers to this matrix? I'm using C++.

Best Al

Preview: (hide)

Comments

i don't think this is possible. also, Mat is a smartpointer on it's own already, so moving the address of it around will inevitably lead to refcounting trouble.

since constructing a new Mat like: Mat_<float> m(3,3); m<<a,c,b,b,c,a,c,a,b; is so easy, i would not even bother to go 'artistic' here.

berak gravatar imageberak (Apr 30 '15)edit

Or you can implement this data structure yourself, it shouldn't be too hard.. once you have that you can easily create conversion functions from/to this data structure. Happy coding :)!

boaz001 gravatar imageboaz001 (May 1 '15)edit