(C++) Flood::Matrix
February 24, 2017 · View on GitHub
(C++) Flood::Matrix
Flood::Matrix is the Flood version of a matrix.
Flood::Matrix example
int main() { const int n_rows = 3; const int n_cols = 4; //Flood::Matrix is y-x ordered Flood::Matrix<int> m(n_rows,n_cols,0.0); const int x1 = 0; const int y1 = 0; m[y1][x1] = 1; const int x2 = 1; const int y2 = 2; m[y2][x2] = 2; const int x3 = 3; const int y3 = 1; m[y3][x3] = 3; std::cout << m; }
Screen output:
1 0 0 0 0 0 0 3 0 2 0 0
Flood::Matrix code snippets
//From http://www.richelbilderbeek.nl/CppFloodMatrix.htm void mutate(Flood::Matrix<double>& m, const double mut) { const int maxy = m.get_rows_number(); const int maxx = m.get_columns_number(); for (int y=0; y!=maxy; ++y) { for (int x=0; x!=maxx; ++x) { m[y][x] += (GetRandomUniform() * (2.0 * mut) - mut); } } }