| 83 | */ |
| 84 | template<class A> |
| 85 | SymmetryHandle columns_reflect(const Matrix<A>& m) { |
| 86 | int nrows = m.height(); |
| 87 | int ncols = m.width(); |
| 88 | // Length of each sequence in the symmetry. |
| 89 | int length = (ncols/2) * nrows; |
| 90 | typename Matrix<A>::ArgsType xs(length * 2); |
| 91 | for (int i = 0 ; i < length ; i++) { |
| 92 | // Break position i into its coordinates |
| 93 | int r1 = i/ncols; |
| 94 | int c1 = i%ncols; |
| 95 | // c2 is the column symmetric with c1 |
| 96 | int c2 = ncols - c1 - 1; |
| 97 | // The row remains the same |
| 98 | int r2 = r1; |
| 99 | xs[i] = m(c1,r1); |
| 100 | xs[length+i] = m(c2,r2); |
| 101 | } |
| 102 | return VariableSequenceSymmetry(xs, length); |
| 103 | } |
| 104 | |
| 105 | /** \brief Reflect around main diagonal symmetry specification. |
| 106 | */ |
no test coverage detected