The easiest and fastest way to achieve this:
Eigen::MatrixXd A1(3,3), B(3,1), A2;
...
A2 = A1;
A2.diagonal() -= B;
of course, it is better to use a type VectorXdfor vectors (here for B), and finally, if it Bis a constant, you can use the array facilities:
A2.diagonal().array() -= 1;