monotone_matrix_search() and sorted_matrix_search() are techniques that deal with the problem of efficiently finding largest entries in matrices with certain structural properties. Many concrete problems can be modelled as matrix search problems, and for some of them we provide explicit solutions that allow you to solve them without knowing about the matrix search technique. Examples are, the computation of all furthest neighbors for the vertices of a convex polygon, maximal k-gons inscribed into a planar point set, and computing rectangular p-centers.

monotone_matrix_search() 和 sorted_matrix_search()处理的问题是在一定结构属性的矩阵中高效寻找最大入口。很多具体的问题可以建模为矩阵搜索问题,有些问题我们可以在你不知道矩阵搜索技术的情况下提供显式解决问题的方法。这方面的例子有:计算一个凸多边形的顶点集的所有最远邻居,一个平面点集的内接最大k边形(k-gon)和求一个矩形p心。

Example

本例我们建立一个随机的向量 a=(ai)i=1,…,5 (由0-99中均匀分布产生)并创建一个笛卡尔矩阵M,矩阵中包含所有ai+aj,i,j∈{1,…,5},如果a排序,则M也排序。则我们可以使用 sorted_matrix_search() 来计算M中a的最大入口的上界。

In the following program we build a random vector a=(ai)i=1,…,5 (elements drawn uniformly from {0,…,99}) and construct a Cartesian matrix M containing as elements all sums ai+aj,i,j∈{1,…,5}. If a is sorted, M is sorted as well. So we can apply sorted_matrix_search() to compute the upper bound for the maximal entry of a in M.

File Matrix_search/sorted_matrix_search.cpp

#include <CGAL/Random.h>
#include <CGAL/Cartesian_matrix.h>
#include <CGAL/sorted_matrix_search.h>
#include <vector>
#include <algorithm>
#include <iterator>
#include <boost/functional.hpp>
 
typedef int Value;
typedef std::vector<Value> Vector;
typedef Vector::iterator Value_iterator;
typedef std::vector<Vector> Vector_cont;
typedef CGAL::Cartesian_matrix<std::plus<int>,
Value_iterator,
Value_iterator> Matrix;
 
int main()
{
// set of vectors the matrices are build from:
Vector_cont vectors;
 
// generate a random vector and sort it:
Vector a;
const int n = 5;
for (int i = 0; i < n; ++i)
a.push_back(CGAL::get_default_random()(100));
std::sort(a.begin(), a.end());
std::cout << "a = ( ";
std::copy(a.begin(), a.end(), std::ostream_iterator<int>(std::cout," "));
std::cout << ")\n";
 
// build a Cartesian matrix from a:
Matrix M(a.begin(), a.end(), a.begin(), a.end());
 
// search for an upper bound for max(a):
Value bound = a[n-1];
Value upper_bound =
&M, &M + 1,
CGAL::sorted_matrix_search_traits_adaptor(
boost::bind2nd(std::greater_equal<Value>(), bound), M));
std::cout << "Upper bound for " << bound << " is "
<< upper_bound << "." << std::endl;
 
return 0;
}

Monotone and Sorted Matrix Search ( Arithmetic and Algebra) CGAL 4.13 -User Manual的更多相关文章

  1. Algebraic Foundations ( Arithmetic and Algebra) CGAL 4.13 -User Manual

    理解: 本节主要介绍CGAL的代数结构和概念之间的互操作.与传统数论不同,CGAL的代数结构关注于实数轴的“可嵌入”特征.它没有将所有传统数的集合映射到自己的代数结构概念中,避免使用“数的类型”这一术 ...

  2. Modular Arithmetic ( Arithmetic and Algebra) CGAL 4.13 -User Manual

    1 Introduction Modular arithmetic is a fundamental tool in modern algebra systems. In conjunction wi ...

  3. Linear and Quadratic Programming Solver ( Arithmetic and Algebra) CGAL 4.13 -User Manual

    1 Which Programs can be Solved? This package lets you solve convex quadratic programs of the general ...

  4. Algebraic Kernel ( Arithmetic and Algebra) CGAL 4.13 -User Manual

    1 Introduction Real solving of polynomials is a fundamental problem with a wide application range. T ...

  5. Polynomial ( Arithmetic and Algebra) CGAL 4.13 -User Manual

    1 Fundamentals A polynomial is either zero, or can be written as the sum of one or more non-zero ter ...

  6. 【LeetCode】378. Kth Smallest Element in a Sorted Matrix 解题报告(Python)

    [LeetCode]378. Kth Smallest Element in a Sorted Matrix 解题报告(Python) 标签: LeetCode 题目地址:https://leetco ...

  7. sorted matrix - search & find-k-th

    sorted matrix ( Young Matrix ) search for a given value in the matrix: 1) starting from upper-right ...

  8. 【leetcode】378. Kth Smallest Element in a Sorted Matrix(TOP k 问题)

    Given an n x n matrix where each of the rows and columns is sorted in ascending order, return the kt ...

  9. 378. Kth Smallest Element in a Sorted Matrix(java,优先队列)

    题目: Given a n x n matrix where each of the rows and columns are sorted in ascending order, find the ...

随机推荐

  1. [PHP] 转义字符 Escape character

    \n is a symbol for new line \t is a symbol for tab and \r is for 'return'

  2. Codeforces 677C. Coloring Trees dp

    C. Coloring Trees time limit per test:2 seconds memory limit per test:256 megabytes input:standard i ...

  3. Codeforces 600A. Extract Numbers 模拟

    A. Extract Numbers time limit per test: 2 seconds memory limit per test: 256 megabytes input: standa ...

  4. [Git]Git的常用命令

    Update: git status git diff wq git commit -am "why update files" git push Add: git add . g ...

  5. Java数据结构和算法(五)二叉排序树(BST)

    Java数据结构和算法(五)二叉排序树(BST) 数据结构与算法目录(https://www.cnblogs.com/binarylei/p/10115867.html) 二叉排序树(Binary S ...

  6. 深入浅出 JMS(二) - ActiveMQ 入门指南

    深入浅出 JMS(二) - ActiveMQ 入门指南 上篇博文深入浅出 JMS(一) – JMS 基本概念,我们介绍了消息通信的规范JMS,这篇博文介绍一款开源的 JMS 具体实现-- Active ...

  7. 一次HBase问题的解决过程(Status: INCONSISTENT)

    ==版本信息== HBase:2.7.1 Storm:1.0.1 RocketMQ:3.4.6(阿里版) ==问题描述== 2018年9月3号晚上23点左右,例行巡检系统运行状况时, 发现Storm消 ...

  8. hdu-1179(匈牙利算法)

    题目链接: 思路:找n个巫师和m个魔棒匹配的问题,匈牙利算法模板 匈牙利算法:https://blog.csdn.net/sunny_hun/article/details/80627351 #inc ...

  9. 【C#】VS2015开发环境的安装和配置(转)

    出处: http://www.cnblogs.com/rainmj/p/5636518.html http://www.cnblogs.com/rainmj/p/5636529.html http:/ ...

  10. Android 长时间运行任务说明

    android 4.0 后,小米手机需要授权 自动启动 (在安全中心权限里设置),不然AlarmManager设置系统闹钟将不起作用