Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ armadillo - assign values to column

Tags:

c++

armadillo

How can I assign values to a column of an armadillo matrix?

Let's say I have a 2x2 matrix (initialized to zeros) and I want to fill the second column with arbitrary values e.g [1; 3]

In MATLAB I would do something like:

A(:,2)=[1; 3]

However when I try:

A.col(1) << 1 << endr << 3 << endr;

I get en error as operator << is not supported by subviews.

Thanks a lot for your help!

like image 265
Nfys Avatar asked May 26 '15 07:05

Nfys


1 Answers

How about

A.col(1) = vec({1,2});

If you're working with C++11 ?

like image 127
Oncaphillis Avatar answered Oct 04 '22 00:10

Oncaphillis