Navigation: Up, Table of Contents, Bibliography, Index, Title Page

Monotone Matrix Search

In this section we describe a general function to compute the maxima for all rows of a totally monotone matrix. More precisely, monotony for matrices is defined as follows.

Let K be a totally ordered set, tex2html_wrap_inline11 a matrix over K and for tex2html_wrap_inline13 :

displaymath15

the (leftmost) column containing the maximum entry in row i. M is called monotone, iff

displaymath19

M is totally monotone, iff all of its submatrices are monotone (or equivalently: iff all tex2html_wrap_inline21 submatrices are monotone).

#include <CGAL/monotone_matrix_search.h>

template < class Matrix, class RandomAccessIC, class Compare_strictly >
void
monotone_matrix_search (
Matrix m,
RandomAccessIC t,
Compare_strictly compare_strictly = less< Matrix::Value >())

computes the maximum (as specified bycompare_strictly) entry for each row of m and writes the corresponding column to t, i.e. t[i] is set to the index of the column containing the maximum element in row i. The maximum mr of a row r is the leftmost element for which compare_strictly(mr,x) is false for all elements x in r.

Precondition

  1. Matrix satisfies the requirements stated in section reference,
  2. Value type of RandomAccessIC is int,
  3. t points to a structure of size at least m.number_of_rows() and
  4. if compare_strictly is defined, it has to be an adaptable binary function: Matrix::Value × Matrix::Value bool describing a strict (non-reflexive) total ordering on Matrix::Value.

Implementation

The implementation uses an algorithm by Aggarwal et al.[AKM+87]. The runtime is linear in the number of rows and columns of the matrix.


Next: Class declaration of Mms_matrix
Navigation: Up, Table of Contents, Bibliography, Index, Title Page
The GALIA project. Jan 18, 2000.