Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eigen: Get scalar type from array type is documented?

I want to know if getting the scalar type from the array type by ArrayType::Scalar is documented for the Eigen library.

The following compiles (g++ test.cpp -I<Path to Eigen> -frtti)

#include <Eigen/Eigen>
#include <typeinfo>
#include <iostream>
int main() {
    Eigen::ArrayXf::Scalar i = 0;
    std::cout << typeid(i).name() << "\n";
}

Result (float type as expected):

f

That also works for MatrixXf type.

like image 693
hamster on wheels Avatar asked Oct 20 '25 07:10

hamster on wheels


1 Answers

Yes. It is documented by doxygen, at least for DenseBase. I found it when I searched for "scalar" in https://eigen.tuxfamily.org/dox/

template<typename Derived>
typedef internal::traits<Derived>::Scalar Eigen::DenseBase< Derived >::Scalar

The numeric type of the expression' coefficients, e.g. float, double, int or std::complex, etc.

like image 110
hamster on wheels Avatar answered Oct 21 '25 21:10

hamster on wheels



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!