| 59 | */ |
| 60 | template<class A> |
| 61 | SymmetryHandle |
| 62 | rows_reflect(const Matrix<A>& m) { |
| 63 | int nrows = m.height(); |
| 64 | int ncols = m.width(); |
| 65 | // Length of each sequence in the symmetry. |
| 66 | int length = (nrows/2) * ncols; |
| 67 | typename Matrix<A>::ArgsType xs(length * 2); |
| 68 | for (int i = 0 ; i < length ; i++) { |
| 69 | // Break position i into its coordinates |
| 70 | int r1 = i/ncols; |
| 71 | int c1 = i%ncols; |
| 72 | // r2 is the row symmetric with r1 |
| 73 | int r2 = nrows - r1 - 1; |
| 74 | // The column remains the same |
| 75 | int c2 = c1; |
| 76 | xs[i] = m(c1,r1); |
| 77 | xs[length+i] = m(c2,r2); |
| 78 | } |
| 79 | return VariableSequenceSymmetry(xs, length); |
| 80 | } |
| 81 | |
| 82 | /** \brief Reflect columns symmetry specification. |
| 83 | */ |
no test coverage detected