Computational Science Asked on February 4, 2021
I need to have a sparse matrix whose elements are not simple numbers, but objects, e.g. a couple of floating point values and a bunch of integer indices.
I am wondering if Eigen has something similar, beyond its Eigen::SparseMatrix< _Scalar, _Options, _StorageIndex >
class template (the only sparse matrix I have found so far), which only accepts a scalar template parameter.
I know I can use a SoA (Structure of Arrays) approach, but in this specific case, for data locality reasons, I am trying with an AoS (Array of Structures) one.
Certainly. There are a few things you have to define for your type that are listed on this page in the documentation:
https://eigen.tuxfamily.org/dox/TopicCustomizing_CustomScalar.html
It basically boils down to defining arithmetic operators appropriately for your type, plus specializing a traits template NumTraits that describes your type. The link above has a few examples that you can follow.
Answered by Tyler Olsen on February 4, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP