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. 找不到reportviewer控件在哪儿

    請自行加入ReportViewer(9.0)到工具箱之中. 如下圖,

  2. Centos7 安装MySQL8.0.15

    1.删除原有的mariadb,不然mysql装不进去 mariadb-libs-5.5.52-1.el7.x86_64 rpm -qa|grep mariadb rpm -e --nodeps mar ...

  3. Halcon小函数的封装和代码导出

    一.Halcon小函数的封装和修改 1.名词解释: 算子:指Halcon中最基础.最底层的函数(即你看不到它的代码实现),一个算子只有一句话,例如threshold算子. 小函数:由多个算子组合成的函 ...

  4. Python发送邮件不需要发件人密码认证

    #!/usr/bin/python # coding: UTF-8 import smtplib from email.mime.text import MIMEText receivers_list ...

  5. apk签名方法

    生成签名文件: 1.右击项目管理器 选择 Export...  菜单: 2.在弹出的Export窗口中选择 Android->Export Android Application 后 next: ...

  6. iCn3D结构查看器的实现方法

    iCn3D Structure Viewer:iCn3D结构查看器 演示效果如下: 上面只是一个Basic UI的演示,如果要Advanced UI的话可以去NCBI官网看API

  7. Django入门与实践-第14章:用户注册(完结)

    http://127.0.0.1:8000/signup/ django-admin startapp accounts INSTALLED_APPS = [ 'accounts', ] # mypr ...

  8. 关于EmitMapper,映射配置

    public static T Snapshoot<T>(this XtraForm form, T obj) { var config = new DefaultMapConfig(); ...

  9. Web Service测试工具小汇

    1..NET WebService Studio 这款工具出自微软内部,最大的优点是可视化很好,不用去看那些XML文件,WebService的基础内容就有XML,但是测试中Case过多,每次测试结果都 ...

  10. vs2010点调试,显示系统找不到指定的文件

    首先,查看“项目”-“属性”-“链接器”-“常规”-“输出文件”,路劲是否是“bin/xxx.exe”,如果是请继续看我的解答,否则请忽略下面的内容.原因是用VS2010加载调试以前的VC6.0下的程 ...