Registered Member
|
I am using Eigen3 Arrays to store Nx2 complex numbers to represent 2 complex series of datapoints vs time. I need to perform some operations (similar to norms, for example) on these arrays (which I can do using a DenseBase plugin), but I also need to store some meta-data information about the arrays (eg they are a time-series so I need to store the time step between datapoints).
To do this I create an Eigen Array and store it in a shared pointer. I then pass this as an argument in the constructor of a class that holds the meta-data as well as the shared pointer. In this way I can work on the Eigen Array directly and avoid needing to provide all the Array accessors, and I can work on the meta-data+array object as well, depending on need. But it's not a great solution as it removes a level of data hiding (I avoid major problems with this by ensuring that the majority of the use of the Array/Meta-data class is via read only const, but it's not ideal). I am wondering if there is an alternative, such as inheriting from Array, but I notice in http://eigen.tuxfamily.org/dox-devel/To ... Eigen.html that this is really not recommended. Can I ask why this is so? Are there any suggestions for how to implement the above in an improved manner? Thanks. |
Moderator
|
inheriting Array or Matrix is fine as long as you know what you are doing. For instance, is Foo inherit Array, then adding to Foo objects and evaluating them ( (foo0+foo1).eval() ) wont give you a Foo but an Array. That said, in your case, I'm not sure there is any benefit of inheriting Array, instead of having a custom class storing an Array and your additional members but well go as you prefer.
|
Registered Member
|
Thanks. I think it would be valuable to provide a bit more detail in the docs about the implications of inheriting from Matrix. Your description was enough to put me off!
|
Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot], q.ignora