In-place manipulation of matrix elements

#include <iostream> #include <vector> #include <cmath> using namespace std; int main() { vector<vector <double>> A = { {10, 11, 12, 13}, {14, 15, 16, 17}, {18, 19, 20, 21}, {22, 23, 24, 25} }; for(vector<double> &v : A) { for(double &val : v) { val *= (1 + sqrt(5)) /2.0; } } // Check values for(vector<double> v : A) { for(double val : v) { cout << val << " "; } cout << endl; } /* 16.1803 17.7984 19.4164 21.0344 22.6525 24.2705 25.8885 27.5066 29.1246 30.7426 32.3607 33.9787 35.5967 37.2148 38.8328 40.4508 */ }