ldsb.hpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 namespace Gecode {
00035
00038 template<class A>
00039 SymmetryHandle
00040 rows_interchange(const Matrix<A>& m) {
00041 typename Matrix<A>::ArgsType xs;
00042 for (int r = 0 ; r < m.height() ; r++)
00043 xs << m.row(r);
00044 return VariableSequenceSymmetry(xs, m.width());
00045 }
00046
00049 template<class A>
00050 SymmetryHandle
00051 columns_interchange(const Matrix<A>& m) {
00052 typename Matrix<A>::ArgsType xs;
00053 for (int c = 0 ; c < m.width() ; c++)
00054 xs << m.col(c);
00055 return VariableSequenceSymmetry(xs, m.height());
00056 }
00057
00060 template<class A>
00061 SymmetryHandle
00062 rows_reflect(const Matrix<A>& m) {
00063 int nrows = m.height();
00064 int ncols = m.width();
00065
00066 int length = (nrows/2) * ncols;
00067 typename Matrix<A>::ArgsType xs(length * 2);
00068 for (int i = 0 ; i < length ; i++) {
00069
00070 int r1 = i/ncols;
00071 int c1 = i%ncols;
00072
00073 int r2 = nrows - r1 - 1;
00074
00075 int c2 = c1;
00076 xs[i] = m(c1,r1);
00077 xs[length+i] = m(c2,r2);
00078 }
00079 return VariableSequenceSymmetry(xs, length);
00080 }
00081
00084 template<class A>
00085 SymmetryHandle columns_reflect(const Matrix<A>& m) {
00086 int nrows = m.height();
00087 int ncols = m.width();
00088
00089 int length = (ncols/2) * nrows;
00090 typename Matrix<A>::ArgsType xs(length * 2);
00091 for (int i = 0 ; i < length ; i++) {
00092
00093 int r1 = i/ncols;
00094 int c1 = i%ncols;
00095
00096 int c2 = ncols - c1 - 1;
00097
00098 int r2 = r1;
00099 xs[i] = m(c1,r1);
00100 xs[length+i] = m(c2,r2);
00101 }
00102 return VariableSequenceSymmetry(xs, length);
00103 }
00104
00107 template<class A>
00108 SymmetryHandle diagonal_reflect(const Matrix<A>& m) {
00109 int nrows = m.height();
00110 int ncols = m.width();
00111
00112 typename Matrix<A>::ArgsType a1;
00113 typename Matrix<A>::ArgsType a2;
00114
00115 for (int i = 0 ; i < nrows ; i++) {
00116 for (int j = i+1 ; j < ncols ; j++) {
00117 a1 << m(j,i);
00118 a2 << m(i,j);
00119 }
00120 }
00121
00122 typename Matrix<A>::ArgsType aboth;
00123 aboth << a1;
00124 aboth << a2;
00125 return VariableSequenceSymmetry(aboth, a1.size());
00126 }
00127 }
00128
00129