Sentinel Sentinel - 1 month ago 14
C++ Question

Armadillo C++ Matrix Library - simplest way to initialize all values in a matrix to 999?

I'm very new to Armadillo but after searching around I can't find any answer to this. I need a matrix with all values initialized to a number like 999. Do I have to iterate through the whole thing and set them manually? Feel like there should be a better way.

Answer

According to documentation classes Mat, Col, Row, Cube have method fill.

Example:

mat A(5,5);
A.fill(999.0);