C++: Get Size of Eigen::Matrix

Essay - Published: 2016.04.11 | 1 min read (82 words)

DISCLOSURE: If you buy through affiliate links, I may earn a small commission. (disclosures)

**Problem: **I’m using the Eigen library in C++. I have a Matrix and want to check the size of it within my code. How can I do this?

**Solution: **The best way to go about this is to call the .rows() and .cols() functions on the Matrix. This will return the number of rows and columns in your matrix, respectively.

Here’s an example code snippet to show you how it might be implemented:

[https://gist.github.com/SIRHAMY/577f03949a048ede0fab]

Want more like this?

The best way to support my work is to like / comment / share this post on your favorite socials.