MCPcopy Create free account
hub / github.com/Gecode/gecode / rows_reflect

Function rows_reflect

gecode/minimodel/ldsb.hpp:61–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 */

Callers 1

setupMethod · 0.85

Calls 4

mFunction · 0.85
VariableSequenceSymmetryFunction · 0.50
heightMethod · 0.45
widthMethod · 0.45

Tested by

no test coverage detected