Gecode::Matrix< A > Class Template Reference
Functionality by programming task » Programming models » Direct modeling support

Matrix-interface for arrays. More...

`#include <minimodel.hh>`

## Public Types

typedef ArrayTraits< A >::ValueType | ValueType
| The type of elements of this array.
typedef ArrayTraits< A >::ArgsType | ArgsType
| The type of the Args-array type for ValueType values.

## Public Member Functions

| Matrix (A a, int w, int h)
| Basic constructor.
| Matrix (A a, int n)
| Basic constructor.
int | width (void) const
| Return the width of the matrix.
int | height (void) const
| Return the height of the matrix.
ArgsType const | get_array (void) const
| Return an Args-array of the contents of the matrix.
ValueType & | operator() (int c, int r)
| Access element (c, r) of the matrix.
const ValueType & | operator() (int c, int r) const
| Access element (c, r) of the matrix.
Slice< A > | slice (int fc, int tc, int fr, int tr) const
| Access slice of the matrix.
Slice< A > | row (int r) const
| Access row r.
Slice< A > | col (int c) const
| Access column c.

## Related Symbols

(Note that these are not member symbols.)
template<class Char, class Traits, class A>
std::basic_ostream< Char, Traits > & | operator<< (std::basic_ostream< Char, Traits > &os, const Matrix< A > &m)
template<class Char, class Traits, class A>
std::basic_ostream< Char, Traits > & | operator<< (std::basic_ostream< Char, Traits > &os, const Slice< A > &s)
void | element (Home home, const Matrix< IntArgs > &m, IntVar x, IntVar y, IntVar z, IntPropLevel ipl=IPL_DEF)
| Element constraint for matrix.
void | element (Home home, const Matrix< IntArgs > &m, IntVar x, IntVar y, BoolVar z, IntPropLevel ipl=IPL_DEF)
| Element constraint for matrix.
void | element (Home home, const Matrix< IntVarArgs > &m, IntVar x, IntVar y, IntVar z, IntPropLevel ipl=IPL_DEF)
| Element constraint for matrix.
void | element (Home home, const Matrix< BoolVarArgs > &m, IntVar x, IntVar y, BoolVar z, IntPropLevel ipln=IPL_DEF)
| Element constraint for matrix.
void | element (Home home, const Matrix< IntSetArgs > &m, IntVar x, IntVar y, SetVar z)
| Element constraint for matrix.
void | element (Home home, const Matrix< SetVarArgs > &m, IntVar x, IntVar y, SetVar z)
| Element constraint for matrix.
template<class A>
SymmetryHandle | rows_interchange (const Matrix< A > &m)
| Interchangeable rows symmetry specification.
template<class A>
SymmetryHandle | columns_interchange (const Matrix< A > &m)
| Interchangeable columns symmetry specification.
template<class A>
SymmetryHandle | rows_reflect (const Matrix< A > &m)
| Reflect rows symmetry specification.
template<class A>
SymmetryHandle | columns_reflect (const Matrix< A > &m)
| Reflect columns symmetry specification.
template<class A>
SymmetryHandle | diagonal_reflect (const Matrix< A > &m)
| Reflect around main diagonal symmetry specification.

## Detailed Description

template<class A>
class Gecode::Matrix< A >

Matrix-interface for arrays.

This class allows for wrapping some array and accessing it as a matrix.

Note
  This is a light-weight wrapper, and is not intended for storing variables directly instead of in an array.

Definition at line 2161 of file minimodel.hh.

## Member Typedef Documentation

## ValueType

template<class A>

typedef ArrayTraits<A>::ValueType Gecode::Matrix< A >::ValueType

The type of elements of this array.

Definition at line 2164 of file minimodel.hh.

## ArgsType

template<class A>

typedef ArrayTraits<A>::ArgsType Gecode::Matrix< A >::ArgsType

The type of the Args-array type for ValueType values.

Definition at line 2166 of file minimodel.hh.

## Constructor & Destructor Documentation

## Matrix() [1/2]

template<class A>

Gecode::Matrix< A >::Matrix | ( | A | a,
|  | int | w,
|  | int | h )

inline

Basic constructor.

Constructs a Matrix from the array a, using w and h as the width and height of the matrix.

The elements in the wrapped array a are accessed in row-major order.

Exceptions

  MiniModel::ArgumentSizeMismatch | Raised if the parameters w and h doesn't match the size of the array a.

Definition at line 127 of file matrix.hpp.

## Matrix() [2/2]

template<class A>

Gecode::Matrix< A >::Matrix | ( | A | a,
|  | int | n )

inline

Basic constructor.

Constructs a square Matrix from the array a, using n as the length of the sides.

The elements in the wrapped array a are accessed in row-major order.

Exceptions

  MiniModel::ArgumentSizeMismatch | Raised if the parameter n doesn't match the size of the array a.

Definition at line 135 of file matrix.hpp.

## Member Function Documentation

## width()

template<class A>

int Gecode::Matrix< A >::width | ( | void |  | ) | const

inline

Return the width of the matrix.

Definition at line 143 of file matrix.hpp.

## height()

template<class A>

int Gecode::Matrix< A >::height | ( | void |  | ) | const

inline

Return the height of the matrix.

Definition at line 146 of file matrix.hpp.

## get_array()

template<class A>

Matrix< A >::ArgsType const Gecode::Matrix< A >::get_array | ( | void |  | ) | const

inline

Return an Args-array of the contents of the matrix.

Definition at line 149 of file matrix.hpp.

## operator()() [1/2]

template<class A>

Matrix< A >::ValueType & Gecode::Matrix< A >::operator() | ( | int | c,
|  | int | r )

inline

Access element (c, r) of the matrix.

Exceptions

  MiniModel::ArgumentOutOfRange | Raised if c or r are out of range.

Definition at line 155 of file matrix.hpp.

## operator()() [2/2]

template<class A>

const Matrix< A >::ValueType & Gecode::Matrix< A >::operator() | ( | int | c,
|  | int | r ) const

inline

Access element (c, r) of the matrix.

Exceptions

  MiniModel::ArgumentOutOfRange | Raised if c or r are out of range.

Definition at line 163 of file matrix.hpp.

## slice()

template<class A>

Slice< A > Gecode::Matrix< A >::slice | ( | int | fc,
|  | int | tc,
|  | int | fr,
|  | int | tr ) const

inline

Access slice of the matrix.

This function allows accessing a slice of the matrix, located at columns and rows . The result of this function is an object that can be converted into either a Matrix<ArgsType> or into ArgsType.

For further information, see Slice.

Definition at line 171 of file matrix.hpp.

## row()

template<class A>

Slice< A > Gecode::Matrix< A >::row | ( | int | r | ) | const

inline

Access row r.

Definition at line 177 of file matrix.hpp.

## col()

template<class A>

Slice< A > Gecode::Matrix< A >::col | ( | int | c | ) | const

inline

Access column c.

Definition at line 183 of file matrix.hpp.

## Friends And Related Symbol Documentation

## operator<<() [1/2]

template<class Char, class Traits, class A>

std::basic_ostream< Char, Traits > & operator<< | ( | std::basic_ostream< Char, Traits > & | os,
|  | const Matrix< A > & | m )

related

Print matrix m

Definition at line 183 of file matrix.hpp.

## operator<<() [2/2]

template<class Char, class Traits, class A>

std::basic_ostream< Char, Traits > & operator<< | ( | std::basic_ostream< Char, Traits > & | os,
|  | const Slice< A > & | s )

related

Print slice s

Definition at line 183 of file matrix.hpp.

## element() [1/6]

template<class A>

void element | ( | Home | home,
|  | const Matrix< IntArgs > & | m,
|  | IntVar | x,
|  | IntVar | y,
|  | IntVar | z,
|  | IntPropLevel | ipl = IPL_DEF )

related

Element constraint for matrix.

Here, x and y are the coordinates and z is the value at position m(x,y).

Definition at line 208 of file matrix.hpp.

## element() [2/6]

template<class A>

void element | ( | Home | home,
|  | const Matrix< IntArgs > & | m,
|  | IntVar | x,
|  | IntVar | y,
|  | BoolVar | z,
|  | IntPropLevel | ipl = IPL_DEF )

related

Element constraint for matrix.

Here, x and y are the coordinates and z is the value at position m(x,y).

Definition at line 213 of file matrix.hpp.

## element() [3/6]

template<class A>

void element | ( | Home | home,
|  | const Matrix< IntVarArgs > & | m,
|  | IntVar | x,
|  | IntVar | y,
|  | IntVar | z,
|  | IntPropLevel | ipl = IPL_DEF )

related

Element constraint for matrix.

Here, x and y are the coordinates and z is the value at position m(x,y).

Definition at line 218 of file matrix.hpp.

## element() [4/6]

template<class A>

void element | ( | Home | home,
|  | const Matrix< BoolVarArgs > & | m,
|  | IntVar | x,
|  | IntVar | y,
|  | BoolVar | z,
|  | IntPropLevel | ipln = IPL_DEF )

related

Element constraint for matrix.

Here, x and y are the coordinates and z is the value at position m(x,y).

Definition at line 223 of file matrix.hpp.

## element() [5/6]

template<class A>

void element | ( | Home | home,
|  | const Matrix< IntSetArgs > & | m,
|  | IntVar | x,
|  | IntVar | y,
|  | SetVar | z )

related

Element constraint for matrix.

Here, x and y are the coordinates and z is the value at position m(x,y).

Definition at line 230 of file matrix.hpp.

## element() [6/6]

template<class A>

void element | ( | Home | home,
|  | const Matrix< SetVarArgs > & | m,
|  | IntVar | x,
|  | IntVar | y,
|  | SetVar | z )

related

Element constraint for matrix.

Here, x and y are the coordinates and z is the value at position m(x,y).

Definition at line 235 of file matrix.hpp.

## rows_interchange()

template<class A>

SymmetryHandle rows_interchange | ( | const Matrix< A > & | m | ) |

related

Interchangeable rows symmetry specification.

Definition at line 40 of file ldsb.hpp.

## columns_interchange()

template<class A>

SymmetryHandle columns_interchange | ( | const Matrix< A > & | m | ) |

related

Interchangeable columns symmetry specification.

Definition at line 51 of file ldsb.hpp.

## rows_reflect()

template<class A>

SymmetryHandle rows_reflect | ( | const Matrix< A > & | m | ) |

related

Reflect rows symmetry specification.

Definition at line 62 of file ldsb.hpp.

## columns_reflect()

template<class A>

SymmetryHandle columns_reflect | ( | const Matrix< A > & | m | ) |

related

Reflect columns symmetry specification.

Definition at line 85 of file ldsb.hpp.

## diagonal_reflect()

template<class A>

SymmetryHandle diagonal_reflect | ( | const Matrix< A > & | m | ) |

related

Reflect around main diagonal symmetry specification.

The matrix \m must be square.

Definition at line 108 of file ldsb.hpp.

The documentation for this class was generated from the following files:

- gecode/minimodel.hh
- gecode/minimodel/matrix.hpp