nawidgc
nawidgc

Reputation: 29

Accessing multiple elements of a matrix in C++

I have following Matlab code:

A = rand(4); % just for an example
B = A(1:3,1:2); 

Thus B will be a 3x2 matrix and will contain elements of A starting from first row to third row and first column to second column. I could certainly do this in C++ with a for loop, but is there an easier way (like Matlab) to do this?

Upvotes: 0

Views: 127

Answers (2)

gire
gire

Reputation: 1105

You are looking for something like the Armadillo library

Check here the conversion table between Matlab/Octave and C++

Upvotes: 2

CodingJack
CodingJack

Reputation: 81

I suggest Eigen for working with matrixes http://eigen.tuxfamily.org/index.php?title=Main_Page.

Upvotes: -1

Related Questions