With your code
Eigen::Matrix4f A;
Eigen::Matrix4f B = A;
then B is a deep copy of A - see below:
int main(int argc, char* argv[]) {
Eigen::Matrix4f A;
A << 1, 2, 3, 4,
5, 6, 7, 8,
9, 10, 11, 12,
13, 14, 15, 16;
Eigen::Matrix4f B = A;
std::cout << "------------------ original A:\n" << A << "\n";
std::cout << "------------------ original B:\n" << B << "\n\n";
// changing A(0, 3) does not change B:
A(0, 3) = 40;
std::cout << "------------------ A after the update:\n" << A << "\n";
std::cout << "------------------ B remains what it was:\n" << B << "\n";
return 0;
}
A
will modifyB
, but modifyingB
should not modifyA
? – Syntactics