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

Function columns_reflect

gecode/minimodel/ldsb.hpp:85–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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