Merge branch 'master' into Aos_2-traits_concept-efif

This commit is contained in:
Efi Fogel 2025-01-21 21:30:42 +02:00
commit 669d83b469
953 changed files with 16984 additions and 21645 deletions

View File

@ -0,0 +1,55 @@
# Use an official Fedora as a parent image for the build stage
FROM fedora:latest AS sources_deps
# Set environment variables to non-interactive
ENV DEBIAN_FRONTEND=noninteractive
# Install dependencies
RUN dnf update -y && dnf install -y \
wget \
make \
gcc \
gcc-c++ \
patch \
cmake \
bison \
flex \
unzip \
python3 \
&& dnf clean all
# Copy the patch file to the build context
COPY cgal-NO_ADDITIONAL_DETAILS.patch .
FROM sources_deps AS build
# Build and install Doxygen from sources
ARG DOXYGEN_VERSION=1.9.6
ARG MAKEFLAGS=-j$(nproc)
RUN if [ -n "$DEBUG"];then set -x && make --version && ls -lZ /tmp && id; fi \
&& DOXYGEN_VERSION_UNDERSCORE=$(echo ${DOXYGEN_VERSION} | sed 's/\./_/g') \
&& wget https://github.com/doxygen/doxygen/archive/refs/tags/Release_${DOXYGEN_VERSION_UNDERSCORE}.zip \
&& unzip Release_${DOXYGEN_VERSION_UNDERSCORE}.zip \
&& cd doxygen-Release_${DOXYGEN_VERSION_UNDERSCORE} \
&& patch -p1 < ../cgal-NO_ADDITIONAL_DETAILS.patch \
&& mkdir build \
&& cd build \
&& cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release .. \
&& cmake --build . \
&& cmake --install . \
&& mkdir -p /usr/local/share/doc/doxygen && cp ../LICENSE /usr/local/share/doc/doxygen/LICENSE.TXT \
&& cd ../.. \
&& rm -rf doxygen-Release_${DOXYGEN_VERSION_UNDERSCORE} Release_${DOXYGEN_VERSION_UNDERSCORE}.zip
# Use a smaller base image for the final stage
FROM fedora:latest
# Install necessary runtime dependencies
RUN set -x \
&& dnf update -y && dnf install -y graphviz 'perl(Getopt::Std)' tex-bibtex cmake python3-lxml python3-pyquery \
&& dnf clean all
# Copy Doxygen from the build stage
COPY --from=build /usr/local/bin/doxygen /usr/local/bin
COPY --from=build /usr/local/share/doc/doxygen/LICENSE.TXT /usr/local/share/doc/doxygen/LICENSE.TXT
RUN doxygen --version

View File

@ -0,0 +1,23 @@
SHELL := /bin/bash
DOXYGEN_VERSIONS := 1.12.0 1.11.0 1.10.0 1.9.8 1.9.7 1.9.6
.PHONY: all build-% push-% build push
all: build
@echo "Use `$(MAKE) push` to push the images to the registry."
build-%:
@echo "MAKEFLAGS: $(MAKEFLAGS)"
@echo "Building Doxygen version $*..."
if [ "$$(getenforce || true)" == "Enforcing" ]; then Z=:z; else Z=; fi; \
F="$(MAKEFLAGS)"; F=$${F##*fifo:}; F=$${F%% *}; \
if [ -p "$$F" ]; then echo "The GNU make FIFO file exists:"; ls -l $$F; VOLUME_ARGS="-v $$F:$$F$$Z"; echo -- $$VOLUME_ARGS; fi; \
podman build --build-arg DOXYGEN_VERSION=$* --build-arg "MAKEFLAGS=$(MAKEFLAGS)" $$VOLUME_ARGS -t cgal/doxygen:$* .
push-%: build-%
@echo "Pushing cgal/doxygen:$*..."
podman push cgal/doxygen:$*
build: $(foreach version,$(DOXYGEN_VERSIONS),build-$(version))
push: $(foreach version,$(DOXYGEN_VERSIONS),push-$(version))

View File

@ -0,0 +1,44 @@
diff --git a/src/config.xml b/src/config.xml
index 13910958a6..31f1354e44 100644
--- a/src/config.xml
+++ b/src/config.xml
@@ -893,6 +893,18 @@ Go to the <a href="commands.html">next</a> section or return to the
\note This will also disable the warnings about undocumented members
that are normally produced when \ref cfg_warnings "WARNINGS" is
set to \c YES.
+]]>
+ </docs>
+ </option>
+ </group>
+ <group name='Build' docs='Build related configuration options'>
+ <option type='bool' id='NO_ADDITIONAL_DETAILS' defval='0'>
+ <docs>
+<![CDATA[
+ When the \c EXTRACT_ALL tag is set to \c YES and a member or class
+ as no documentation, no detailed section will be produced if
+ the \c NO_ADDITIONAL_DETAILS tag is set to \c YES.
+ This tag has no effect if the \c EXTRACT_ALL tag is set to \c NO.
]]>
</docs>
</option>
diff --git a/src/memberdef.cpp b/src/memberdef.cpp
index 08d9bf24c5..ab04e994c5 100644
--- a/src/memberdef.cpp
+++ b/src/memberdef.cpp
@@ -2501,6 +2501,7 @@ bool MemberDefImpl::hasDetailedDescription() const
if (!m_hasDetailedDescriptionCached)
{
bool extractAll = Config_getBool(EXTRACT_ALL);
+ bool xAllNoDetailedSec = Config_getBool(NO_ADDITIONAL_DETAILS);
bool alwaysDetailedSec = Config_getBool(ALWAYS_DETAILED_SEC);
bool repeatBrief = Config_getBool(REPEAT_BRIEF);
bool briefMemberDesc = Config_getBool(BRIEF_MEMBER_DESC);
@@ -2512,7 +2513,7 @@ bool MemberDefImpl::hasDetailedDescription() const
// the member has detailed documentation because the user added some comments
bool docFilter =
// extract all is enabled
- extractAll ||
+ (extractAll && !xAllNoDetailedSec) ||
// has detailed docs
!documentation().isEmpty() ||
// has inbody docs

View File

@ -0,0 +1,16 @@
{
"name": "CGAL Doxygen Dev Container, version 1.12.0, with CGAL patch",
"image": "docker.io/cgal/doxygen:1.12.0",
"features": {
"ghcr.io/devcontainers/features/git:1.3.2": {}
},
"customizations": {
"vscode": {
"extensions": [
"ms-vscode.cmake-tools",
"bbenoist.Doxygen",
"ms-vscode.cpptools"
]
}
},
}

View File

@ -0,0 +1,29 @@
[distrobox-doxygen-1.12.0]
image=cgal/doxygen:1.12.0
exported_bins="/usr/local/bin/doxygen /usr/bin/perl /usr/bin/cmake /usr/bin/python3"
exported_bins_path=$HOME/.local/bin-doxygen-1.12.0
[distrobox-doxygen-1.11.0]
image=cgal/doxygen:1.11.0
exported_bins="/usr/local/bin/doxygen /usr/bin/perl /usr/bin/cmake /usr/bin/python3"
exported_bins_path=$HOME/.local/bin-doxygen-1.11.0
[distrobox-doxygen-1.10.0]
image=cgal/doxygen:1.10.0
exported_bins="/usr/local/bin/doxygen /usr/bin/perl /usr/bin/cmake /usr/bin/python3"
exported_bins_path=$HOME/.local/bin-doxygen-1.10.0
[distrobox-doxygen-1.9.8]
image=cgal/doxygen:1.9.8
exported_bins="/usr/local/bin/doxygen /usr/bin/perl /usr/bin/cmake /usr/bin/python3"
exported_bins_path=$HOME/.local/bin-doxygen-1.9.8
[distrobox-doxygen-1.9.7]
image=cgal/doxygen:1.9.7
exported_bins="/usr/local/bin/doxygen /usr/bin/perl /usr/bin/cmake /usr/bin/python3"
exported_bins_path=$HOME/.local/bin-doxygen-1.9.7
[distrobox-doxygen-1.9.6]
image=cgal/doxygen:1.9.6
exported_bins="/usr/local/bin/doxygen /usr/bin/perl /usr/bin/cmake /usr/bin/python3"
exported_bins_path=$HOME/.local/bin-doxygen-1.9.6

1
.gitattributes vendored
View File

@ -58,7 +58,6 @@ Scripts/developer_scripts/check_svn_keywords text eol=lf
Scripts/developer_scripts/create_cgal_test text eol=lf
Scripts/developer_scripts/create_cgal_test_with_cmake text eol=lf
Scripts/developer_scripts/create_internal_release text eol=lf
Scripts/developer_scripts/create_macosx_installer text eol=lf
Scripts/developer_scripts/create_new_release text eol=lf
Scripts/developer_scripts/detect_files_with_mixed_eol_styles text eol=lf
Scripts/developer_scripts/detect_packages_licenses text eol=lf

View File

@ -1,3 +1,11 @@
---
name: Issue
about: Use this template for reporting issues with CGAL
title: ''
labels: ''
assignees: ''
---
_Please use the following template to help us solving your issue._
## Issue Details

1
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@ -0,0 +1 @@
blank_issues_enabled: false

View File

@ -1,56 +1,115 @@
name: Documentation
name: Build Documentation
on:
workflow_dispatch:
inputs:
pr_number:
description: 'Pull request number for which the documentation should be built'
type: number
required: true
doc_version:
description: 'Version number of the documentation build'
type: string
required: true
force_build:
description: 'Force the build of the documentation'
type: boolean
required: false
default: false
issue_comment:
types: [created]
env:
author_association: ${{ github.event.comment.author_association }}
comment_body: ${{ github.event.comment.body }}
permissions:
contents: read # to fetch code (actions/checkout)
jobs:
build:
permissions:
contents: read # to fetch code (actions/checkout)
pull-requests: write # to create comment
pre_build_checks:
runs-on: ubuntu-latest
name: Trigger the build?
outputs:
trigger_build: ${{ steps.get_doc_version.outputs.result && steps.get_doc_version.outputs.result != '' }}
force_build: ${{ steps.check_comment_body.outputs.force_build }}
pr_number: ${{ steps.get_pr_number.outputs.pr_number }}
doc_version: ${{ steps.get_doc_version.outputs.result }}
steps:
- uses: actions/github-script@v7
id: get_round
- name: Display inputs
run: |
echo "pr_number=${{ inputs.pr_number || github.event.issue.number }}"
echo "doc_version=${{ inputs.doc_version }}"
echo "force_build=${{ inputs.force_build || startsWith(env.comment_body, '/force-build:') }}"
- name: Check comment body
id: check_comment_body
env:
trigger_build: ${{ inputs && inputs.pr_number || startsWith(env.comment_body, '/build:') || startsWith(env.comment_body, '/force-build:') }}
force_build: ${{ inputs && inputs.force_build || startsWith(env.comment_body, '/force-build:') }}
if: inputs.pr_number || startsWith(env.comment_body, '/build:') || startsWith(env.comment_body, '/force-build:')
run: |
if [ "${trigger_build}" = "false" ]; then
echo "No build requested"
exit 1
fi
echo "force_build=${force_build}" >> $GITHUB_OUTPUT
echo "trigger_build=${trigger_build}" >> $GITHUB_OUTPUT
- name: Check permissions
if: ( steps.check_comment_body.outputs.trigger_build || false ) && (inputs.pr_number || env.author_association == 'OWNER' || env.author_association == 'MEMBER')
run: echo "Authorized"
- name: No permissions
if: ( steps.check_comment_body.outputs.trigger_build || false ) && (! inputs.pr_number && env.author_association != 'OWNER' && env.author_association != 'MEMBER' )
run: |
echo 'ERROR: User ${{ github.actor }} is not allowed to trigger the build of the documentation with /build:* or /force-build:*'
exit 1
- name: Get PR number
if: ( steps.check_comment_body.outputs.trigger_build || false )
id: get_pr_number
env:
pr_number: ${{ inputs.pr_number || github.event.issue.number }}
run: echo "pr_number=$pr_number" >> $GITHUB_OUTPUT
- name: Get doc version
if: ( steps.check_comment_body.outputs.trigger_build || false )
uses: actions/github-script@v7
id: get_doc_version
with:
result-encoding: string
script: |
const asso = context.payload.comment.author_association
if(asso == 'OWNER' || asso == 'MEMBER') {
if ( context.payload.input && context.payload.inputs.doc_version ) {
return context.payload.inputs.doc_version
}
const body = context.payload.comment.body
if(body.includes("build:")) {
const re = /\/(force-)?build:(\w+)\s*/;
if(re.test(body)) {
const res = re.exec(body)
if(body.includes("force-")) {
return res[2]+":yes"
return res[2]
}
else{
return res[2]+":no"
}
}
}
}
return 'stop'
- uses: actions/github-script@v7
if: steps.get_round.outputs.result != 'stop'
id: get_pr_number
with:
result-encoding: string
script: |
//get pullrequest url
const pr_number = context.payload.issue.number
return pr_number
throw new Error('No version found')
build_doc:
name: |
${{ format('{0}: Build Documentation version "{1}"', github.actor, needs.pre_build_checks.outputs.doc_version) }}
needs: pre_build_checks
permissions:
contents: read # to fetch code (actions/checkout)
pull-requests: write # to create comment
runs-on: ubuntu-latest
env:
force_build: ${{ needs.pre_build_checks.outputs.force_build }}
pr_number: ${{ needs.pre_build_checks.outputs.pr_number }}
doc_version: ${{ needs.pre_build_checks.outputs.doc_version }}
if: ${{ fromJSON(needs.pre_build_checks.outputs.trigger_build || false) }}
steps:
- name: Emoji-comment
if: github.event_name == 'issue_comment'
continue-on-error: true
uses: actions/github-script@v7
if: steps.get_round.outputs.result != 'stop'
with:
script: |
github.rest.reactions.createForIssueComment({
@ -62,17 +121,23 @@ jobs:
- uses: actions/checkout@v4
name: "checkout branch"
if: steps.get_round.outputs.result != 'stop'
with:
repository: ${{ github.repository }}
ref: refs/pull/${{ steps.get_pr_number.outputs.result }}/merge
fetch-depth: 2
ref: refs/pull/${{ env.pr_number }}/head
fetch-depth: 0
- name: install dependencies
if: steps.get_round.outputs.result != 'stop'
- name: Install dependencies
run: |
set -x
sudo apt-get update && sudo apt-get install -y graphviz ssh bibtex2html
# Install Github CLI `gh`
(type -p wget >/dev/null || (sudo apt update && sudo apt-get install wget -y))
sudo mkdir -p -m 755 /etc/apt/keyrings
wget -qO- https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null
sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
sudo apt-get update && sudo apt-get install -y gh cmake graphviz ssh bibtex2html
sudo pip install lxml
sudo pip install pyquery
wget --no-verbose -O doxygen_exe https://cgal.geometryfactory.com/~cgaltest/doxygen_1_9_6_patched/doxygen
@ -81,36 +146,40 @@ jobs:
git config --global user.email "cgal@geometryfactory.com"
git config --global user.name "cgaltest"
- name: configure all
if: steps.get_round.outputs.result != 'stop'
- name: CMake configuration of Documentation/doc
run: |
set -ex
mkdir -p build_doc && cd build_doc && cmake ../Documentation/doc
- name: Build and Upload Doc
- name: Build and upload Doc
id: build_and_run
if: steps.get_round.outputs.result != 'stop'
env:
GH_TOKEN: ${{ github.token }}
run: |
set -ex
PR_NUMBER=${{ steps.get_pr_number.outputs.result }}
TMP_ROUND=${{ steps.get_round.outputs.result }}
ROUND=$(echo $TMP_ROUND | cut -d ":" -f 1)
force=$(echo $TMP_ROUND | cut -d ":" -f 2)
wget --no-verbose cgal.github.io -O tmp.html
if ! egrep -q "\/$PR_NUMBER\/$ROUND" tmp.html || [ "$force" = "yes" ]; then
PR_NUMBER=$pr_number
ROUND=$doc_version
force=$force_build
wget --no-verbose cgal.github.io -O index.html
if ! egrep -qF "/$PR_NUMBER/$ROUND" index.html || [ "$force" = "yes" ]; then
#list impacted packages
LIST_OF_PKGS=$(git diff --name-only HEAD^1 HEAD |cut -s -d/ -f1 |sort -u | xargs -I {} echo {} && ls -d {}/package_info 2>/dev/null |cut -d/ -f1 |egrep -v Installation||true)
LIST_OF_PKGS=$(git diff --name-only origin/master...HEAD |cut -s -d/ -f1 |sort -u | xargs -I {} echo {} && ls -d {}/package_info 2>/dev/null |cut -d/ -f1 |egrep -v Installation||true)
if [ "$LIST_OF_PKGS" = "" ]; then
echo "DoxygenError=No package affected." >> $GITHUB_OUTPUT
exit 1
fi
for p in $LIST_OF_PKGS; do
if [ -f $p/doc/$p/dependencies ]; then
LIST_OF_PKGS="$LIST_OF_PKGS $(cat $p/doc/$p/dependencies)"
fi
done
LIST_OF_PKGS=$(echo $LIST_OF_PKGS | tr ' ' '\n' | sort -u)
cd build_doc && make -j$(nproc) doc
make -j$(nproc) doc_with_postprocessing 2>tmp.log
if [ -s tmp.log ]; then
content=`cat ./tmp.log`
make -j$(nproc) doc_with_postprocessing 2>build.log
if [ -s build.log ]; then
delimiter="$(openssl rand -hex 8)"
echo "DoxygenError<<${delimiter}" >> "${GITHUB_OUTPUT}"
cat tmp.log >> "${GITHUB_OUTPUT}"
cat build.log >> "${GITHUB_OUTPUT}"
echo "${delimiter}" >> "${GITHUB_OUTPUT}"
exit 1
fi
@ -118,18 +187,16 @@ jobs:
git clone https://CGAL:${{ secrets.PUSH_TO_CGAL_GITHUB_IO_TOKEN }}@github.com/CGAL/cgal.github.io.git
mkdir -p cgal.github.io/${PR_NUMBER}/$ROUND
rm cgal.github.io/${PR_NUMBER}/$ROUND/* -rf
for f in $LIST_OF_PKGS
for f in $LIST_OF_PKGS Manual
do
if [ -d ./build_doc/doc_output/$f ]; then
cp -r ./build_doc/doc_output/$f ./cgal.github.io/${PR_NUMBER}/$ROUND
fi
done
cp -r ./build_doc/doc_output/Manual ./cgal.github.io/${PR_NUMBER}/$ROUND
cd ./cgal.github.io
egrep -v " ${PR_NUMBER}\." index.html > tmp.html || true
echo "<li><a href=https://cgal.github.io/${PR_NUMBER}/$ROUND/Manual/index.html>Manual for PR ${PR_NUMBER} ($ROUND).</a></li>" >> ./tmp.html
mv tmp.html index.html
git add ${PR_NUMBER}/$ROUND index.html && git commit -q --amend -m "base commit" && git push -q -f -u origin master
echo "<li><a href=https://cgal.github.io/${PR_NUMBER}/$ROUND/Manual/index.html>Manual for PR ${PR_NUMBER} ($ROUND).</a></li>" >> ./index.html
./cleanup.bash
git add ${PR_NUMBER}/$ROUND index.html && git commit -q --amend -m "sole commit" && git push -q -f -u origin master
else
echo "DoxygenError=This round already exists. Overwrite it with /force-build." >> $GITHUB_OUTPUT
exit 1
@ -137,13 +204,11 @@ jobs:
- name: Post address
uses: actions/github-script@v7
if: ${{ success() && steps.get_round.outputs.result != 'stop' }}
if: ${{ success() }}
with:
script: |
const tmp_round = "${{ steps.get_round.outputs.result }}";
const id = tmp_round.indexOf(":");
const round = tmp_round.substring(0,id);
const address = "The documentation is built. It will be available, after a few minutes, here: https://cgal.github.io/${{ steps.get_pr_number.outputs.result }}/"+round+"/Manual/index.html"
const round = "${{ env.doc_version }}"
const address = "The documentation is built. It will be available, after a few minutes, here: https://cgal.github.io/${{ env.pr_number }}/"+round+"/Manual/index.html"
github.rest.issues.createComment({
owner: "CGAL",
repo: "cgal",
@ -155,7 +220,7 @@ jobs:
env:
ERRORMSG: ${{steps.build_and_run.outputs.DoxygenError}}
uses: actions/github-script@v7
if: ${{ failure() && steps.get_round.outputs.result != 'stop' }}
if: ${{ failure() }}
with:
script: |
const error = process.env.ERRORMSG

View File

@ -7,9 +7,8 @@ permissions:
jobs:
build:
if: github.repository == 'CGAL/cgal' || github.event_name != 'push'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: install dependencies

View File

@ -7,9 +7,8 @@ permissions:
jobs:
cmake-testsuite:
if: github.repository == 'CGAL/cgal' || github.event_name != 'push'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: install dependencies
@ -21,9 +20,8 @@ jobs:
ctest -L Installation -j $(getconf _NPROCESSORS_ONLN)
cmake-testsuite-with-qt:
if: github.repository == 'CGAL/cgal' || github.event_name != 'push'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: install dependencies

View File

@ -1,27 +1,33 @@
name: Documentation Removal
on:
workflow_dispatch:
inputs:
PR_NUMBER:
description: 'Pull request number for which the documentation should be removed'
type: number
required: true
pull_request_target:
types: [closed, removed, workflow_dispatch]
types: [closed]
permissions:
contents: read
jobs:
build:
delete_doc:
permissions:
contents: write # for Git to git push
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: delete directory
- name: delete directory ${{ github.event.inputs.PR_NUMBER || github.event.pull_request.number }}/ in cgal.github.io
env:
PR_NUMBER: ${{ github.event.inputs.PR_NUMBER || github.event.pull_request.number }}
run: |
set -x
git config --global user.email "cgal@geometryfactory.com"
git config --global user.name "cgaltest"
git clone https://CGAL:${{ secrets.PUSH_TO_CGAL_GITHUB_IO_TOKEN }}@github.com/CGAL/cgal.github.io.git
PR_NUMBER=$(python -c "import json; import os; y = json.load(open(os.environ['GITHUB_EVENT_PATH'])); print(y[\"number\"])")
cd cgal.github.io/
egrep -v " ${PR_NUMBER}\." index.html > tmp.html || true
if [ -n "$(diff -q ./index.html ./tmp.html)" ]; then

View File

@ -1,75 +0,0 @@
name: Filter Testsuite
on:
issue_comment:
types: [created]
workflow_dispatch:
permissions: {}
jobs:
build:
permissions:
pull-requests: write # to create comment
if: (github.event.comment.user.login == 'sloriot' || github.event.comment.user.login == 'lrineau') && contains(github.event.comment.body, '/testme')
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v7
id: get_label
with:
result-encoding: string
script: |
//get branch name and username
const pr_url = context.payload.issue.pull_request.url
const pr_content = await github.request(pr_url)
const label = pr_content.data.head.label
const base = pr_content.data.base.ref
console.log(label)
return label+":"+base
- name: Run Testsuite
run: |
mkdir -p ~/.ssh
#ssh key
(
cat <<EOF
${{ secrets.ssh_key }}
EOF
)>> ~/.ssh/id_rsa
chmod 600 /home/runner/.ssh/id_rsa
#ssh public key
(
cat <<EOF
${{ secrets.ssh_key_pub }}
EOF
)>> ~/.ssh/id_rsa.pub
chmod 644 /home/runner/.ssh/id_rsa.pub
#known hosts
wget --no-check-certificate https://cgal.geometryfactory.com/CGAL/ssh_known_hosts -O ~/.ssh/known_hosts
#config file
wget --no-check-certificate https://cgal.geometryfactory.com/CGAL/ssh_config -O ~/.ssh/config
#list of hosts
wget --no-check-certificate https://cgal.geometryfactory.com/CGAL/ssh_host_list -O ~/ssh_host_list
#ssh command
LABEL="${{ steps.get_label.outputs.result }}"
USER_NAME=$(echo $LABEL | cut -d':' -f 1)
BRANCH_NAME=$(echo $LABEL | cut -d':' -f 2)
BASE=$(echo $LABEL | cut -d':' -f 3)
PR_NUMBER=${{ github.event.issue.number }}
mapfile -t HOSTS < ~/ssh_host_list;
for i in ${!HOSTS[@]}; do
HOST=$(echo ${HOSTS[$i]}|cut -d' ' -f 1 )
PATH_TO_SCRIPT=$(echo ${HOSTS[$i]}|cut -d' ' -f 2 )
echo "ssh ${HOST} ${PATH_TO_SCRIPT}/run_testsuite_from_branch_name.sh $USER_NAME $BRANCH_NAME $BASE $PR_NUMBER"
ssh ${HOST} "${PATH_TO_SCRIPT}/run_testsuite_from_branch_name.sh $USER_NAME $BRANCH_NAME $BASE $PR_NUMBER"
done
- name: Post address
uses: actions/github-script@v7
with:
script: |
const address = "Testsuite launched. Results will appear on the following page: https://cgal.geometryfactory.com/~cgaltest/test_suite/TESTRESULTS/index.shtml "
github.issues.createComment({
owner: "CGAL",
repo: "cgal",
issue_number: ${{ github.event.issue.number }},
body: address
});

View File

@ -10,17 +10,18 @@ jobs:
reuse:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: REUSE version
uses: fsfe/reuse-action@v4
- name: Checkout
uses: actions/checkout@v4
- name: Display reuse-tool version
uses: fsfe/reuse-action@v5
with:
args: --version
- name: REUSE lint
uses: fsfe/reuse-action@v4
- name: REUSE Compliance Check
uses: fsfe/reuse-action@v5
with:
args: --include-submodules lint
- name: REUSE SPDX SBOM
uses: fsfe/reuse-action@v4
uses: fsfe/reuse-action@v5
with:
args: spdx
- name: install dependencies
@ -29,7 +30,7 @@ jobs:
run: |
mkdir -p ./release
cmake -DDESTINATION=./release -DCGAL_VERSION=9.9 -P ./Scripts/developer_scripts/cgal_create_release_with_cmake.cmake
- name: REUSE lint release tarball
uses: fsfe/reuse-action@v4
- name: REUSE Compliance Check of release tarball
uses: fsfe/reuse-action@v5
with:
args: --root ./release/CGAL-9.9 --include-submodules lint

2
.gitignore vendored
View File

@ -1058,7 +1058,7 @@ cmake_install.cmake
*~
.#*
# MacOS file https://en.wikipedia.org/wiki/.DS_Store
# macOS file https://en.wikipedia.org/wiki/.DS_Store
.DS_Store
# Binaries:

7
.markdownlint.json Normal file
View File

@ -0,0 +1,7 @@
{
"default": true,
"line-length": false,
"no-duplicate-heading": {
"siblings_only": true
}
}

View File

@ -14,7 +14,7 @@ find_package(Qt6 QUIET COMPONENTS Gui OpenGL)
if(CGAL_Qt6_FOUND AND Qt6_FOUND)
add_definitions(-DQT_NO_KEYWORDS)
add_compile_definitions(QT_NO_KEYWORDS)
# Instruct CMake to run moc/ui/rcc automatically when needed.
set(CMAKE_AUTOMOC ON)

View File

@ -551,7 +551,7 @@ public:
traits.intersection(query, singleton_data());
break;
default: // if(size() >= 2)
root_node()->template traversal_with_priority_and_group_traversal(m_primitives, query, traits, m_primitives.size(), 0, group_traversal_bound);
root_node()->traversal_with_priority_and_group_traversal(m_primitives, query, traits, m_primitives.size(), 0, group_traversal_bound);
}
}

View File

@ -56,7 +56,7 @@ public:
/**
* @brief General traversal query
* @param query the query
* @param traits the traversal traits that define the traversal behaviour
* @param traits the traversal traits that define the traversal behavior
* @param nb_primitives the number of primitive
*
* General traversal query. The traits class allows using it for the various

View File

@ -426,7 +426,7 @@ void test_algebraic_structure_intern(
//commutative
assert(a+b+c==c+b+a);
assert(a*b*c==c*b*a);
//distributiv
//distributive
assert((a-b)*c==a*c-b*c);
assert((a+b)*c==a*c+b*c);
//binom

View File

@ -10,7 +10,7 @@ namespace CGAL {
\section Algebraic_kernel_dIntroduction Introduction
Real solving of polynomials is a fundamental problem with a wide application range.
This package is targeted at providing black-box implementations of state-of-the-art
This package provides black-box implementations of
algorithms to determine, compare, and approximate real roots of univariate polynomials
and bivariate polynomial systems. Such a black-box is called an *Algebraic Kernel*.
Since this package is aimed at providing more than one implementation, the interface of
@ -283,41 +283,6 @@ is not stored internally in terms of an `Algebraic_real_1` object.
Querying such a representation by calling `Compute_y_2` is a
time-consuming step, and should be avoided for efficiency reasons if possible.
\subsection Algebraic_kernel_dAlgebraicKernelsBasedon Algebraic Kernels Based on RS
The package offers two univariate algebraic kernels that are based on
the library RS \cgalCite{cgal:r-rs}, namely `Algebraic_kernel_rs_gmpz_d_1`
and `Algebraic_kernel_rs_gmpq_d_1`. As the names indicate,
the kernels are based on the library RS \cgalCite{cgal:r-rs} and support univariate
polynomials over `Gmpz` or `Gmpq`, respectively.
In general we encourage to use `Algebraic_kernel_rs_gmpz_d_1`
instead of `Algebraic_kernel_rs_gmpq_d_1`. This is caused by
the fact that the most efficient way to compute operations (such as gcd)
on polynomials with rational coefficients is to use the corresponding
implementation for polynomials with integer coefficients. That is,
the `Algebraic_kernel_rs_gmpq_d_1` is slightly slower due to
overhead caused by the necessary conversions. However, since this may
not always be a major issue, the `Algebraic_kernel_rs_gmpq_d_1`
is provided for convenience.
The core of both kernels is the implementation of the interval Descartes
algorithm \cgalCite{cgal:rz-jcam-04} of the library RS \cgalCite{cgal:r-rs},
which is used to isolate the roots of the polynomial.
The RS library restricts its attention to univariate integer
polynomials and some substantial gain of efficiency can be made by using a kernel
that does not follow the generic programming paradigm, by avoiding
interfaces between layers. Specifically, working with
only one number type allows to optimize some polynomial operations
as well as memory handling. The implementation of these kernels
make heavy use of the \mpfr \cgalCite{cgal:mt-mpfr} and \mpfi \cgalCite{cgal:r-mpfi}
libraries, and of their \cgal interfaces, `Gmpfr` and `Gmpfi`.
The algebraic numbers (roots of the polynomials) are represented
in the two RS kernels by a `Gmpfi` interval and a pointer to
the polynomial of which they are roots. See \cgalCite{cgal:lpt-wea-09}
for more details on the implementation, tests of these kernels,
comparisons with other algebraic kernels and discussions about the
efficiency.
\section Algebraic_kernel_dExamples Examples
@ -376,12 +341,13 @@ Michael Hemmer and Michael Kerber, respectively. Notwithstanding, the authors al
contribution of all authors of the \exacus project,
particularly the contribution of Arno Eigenwillig, Sebastian Limbach and Pavel Emeliyanenko.
The two univariate kernels that interface the library RS \cgalCite{cgal:r-rs} were
written by Luis Pe&ntilde;aranda and Sylvain Lazard.
In 2010, two univariate kernels that interface the library RS \cgalCite{cgal:r-rs} were
written by Luis Peñaranda and Sylvain Lazard \cgalCite{cgal:2009-ESA}.
Both models interface the library RS \cgalCite{cgal:r-rs} by Fabrice Rouillier.
The authors want to thank Fabrice Rouillier and Elias Tsigaridas for
strong support and many useful discussions that lead to the integration of RS.
Due to lack of maintenance, these kernels have been removed in 2024.
*/
} /* namespace CGAL */

View File

@ -1,59 +0,0 @@
namespace CGAL {
/*!
\ingroup PkgAlgebraicKernelDModels
\anchor Algebraic_kernel_rs_gmpq_d_1
This univariate algebraic kernel uses the Rs library to perform
rational univariate polynomial root isolation. It is a model of the
`AlgebraicKernel_d_1` concept. Due to the fact that RS can only
isolate integer polynomials, the operations of this kernel have the
overhead of converting the polynomials to integer.
\cgalModels{AlgebraicKernel_d_1}
\sa `Algebraic_kernel_rs_gmpz_d_1`
*/
class Algebraic_kernel_rs_gmpq_d_1 {
public:
/// \name Types
/// @{
/*!
It is a typedef to `CGAL::Gmpq`.
*/
typedef unspecified_type Coefficient;
/*!
It is defined as `CGAL::Polynomial<CGAL::Gmpq>`.
*/
typedef unspecified_type Polynomial_1;
/*!
Type that represents the real roots of
integer univariate polynomials, containing a pointer to the polynomial of
which the represented algebraic number is root and and a `CGAL::Gmpfi`
isolating interval.
*/
typedef unspecified_type Algebraic_real_1;
/*!
Since the isolating intervals of the roots have type
`CGAL::Gmpfi`, the bounds have type `CGAL::Gmpfr`.
*/
typedef unspecified_type Bound;
/*!
The multiplicity is an `int`.
*/
typedef unspecified_type Multiplicity_type;
/// @}
}; /* end Algebraic_kernel_rs_gmpq_d_1 */
} /* end namespace CGAL */

View File

@ -1,57 +0,0 @@
namespace CGAL {
/*!
\ingroup PkgAlgebraicKernelDModels
\anchor Algebraic_kernel_rs_gmpz_d_1
This univariate algebraic kernel uses the Rs library to perform
integer univariate polynomial root isolation. It is a model of the
`AlgebraicKernel_d_1` concept.
\cgalModels{AlgebraicKernel_d_1}
\sa `Algebraic_kernel_rs_gmpz_d_1`
*/
class Algebraic_kernel_rs_gmpz_d_1 {
public:
/// \name Types
/// @{
/*!
It is a typedef to `CGAL::Gmpz`.
*/
typedef unspecified_type Coefficient;
/*!
It is defined as `CGAL::Polynomial<CGAL::Gmpz>`.
*/
typedef unspecified_type Polynomial_1;
/*!
Type that represents the real roots of
integer univariate polynomials, containing a pointer to the polynomial of
which the represented algebraic number is root and and a `CGAL::Gmpfi`
isolating interval.
*/
typedef unspecified_type Algebraic_real_1;
/*!
Since the isolating intervals of the roots have type
`CGAL::Gmpfi`, the bounds have type `CGAL::Gmpfr`.
*/
typedef unspecified_type Bound;
/*!
The multiplicity is an `int`.
*/
typedef unspecified_type Multiplicity_type;
/// @}
}; /* end Algebraic_kernel_rs_gmpz_d_1 */
} /* end namespace CGAL */

View File

@ -9,8 +9,7 @@ algebraic functionalities on univariate polynomials of general degree \f$ d\f$.
\cgalRefines{CopyConstructible,Assignable}
\cgalHasModelsBegin
\cgalHasModels{CGAL::Algebraic_kernel_rs_gmpz_d_1}
\cgalHasModels{CGAL::Algebraic_kernel_rs_gmpq_d_1}
\cgalHasModels{CGAL::Algebraic_kernel_d_1}
\cgalHasModelsEnd
\sa `AlgebraicKernel_d_2`
@ -172,4 +171,3 @@ AlgebraicKernel_d_1::Bound_between_1 bound_between_1_object() const;
/// @}
}; /* end AlgebraicKernel_d_1 */

View File

@ -8,6 +8,11 @@ for solving and handling bivariate polynomial systems of general degree \f$ d\f$
\cgalRefines{AlgebraicKernel_d_1,CopyConstructible,Assignable}
\cgalHasModelsBegin
\cgalHasModels{CGAL::Algebraic_kernel_d_2}
\cgalHasModelsEnd
\sa `AlgebraicKernel_d_1`
*/
@ -176,4 +181,3 @@ AlgebraicKernel_d_2::Bound_between_x_2 bound_between_x_2_object() const;
/// @}
}; /* end AlgebraicKernel_d_2 */

View File

@ -21,12 +21,11 @@
\cgalPkgPicture{Algebraic_kernel_d.png}
\cgalPkgSummaryBegin
\cgalPkgAuthors{Eric Berberich, Michael Hemmer, Michael Kerber, Sylvain Lazard, Luis Peñaranda, and Monique Teillaud}
\cgalPkgDesc{Real solving of polynomials is a fundamental problem with a wide application range. This package is targeted to provide black-box implementations of state-of-the-art algorithms to determine, compare and approximate real roots of univariate polynomials and bivariate polynomial systems. Such a black-box is called an *Algebraic %Kernel*. So far the package only provides models for the univariate kernel. Nevertheless, it already defines concepts for the bivariate kernel, since this settles the interface for upcoming implementations.}
\cgalPkgDesc{Real solving of polynomials is a fundamental problem with a wide application range. This package is targeted to provide black-box implementation algorithms to determine, compare and approximate real roots of univariate polynomials and bivariate polynomial systems. Such a black-box is called an *Algebraic %Kernel*. So far the package only provides models for the univariate kernel. Nevertheless, it already defines concepts for the bivariate kernel, since this settles the interface for upcoming implementations.}
\cgalPkgManuals{Chapter_Algebraic_Kernel,PkgAlgebraicKernelDRef}
\cgalPkgSummaryEnd
\cgalPkgShortInfoBegin
\cgalPkgSince{3.6}
\cgalPkgDependsOn{Some models depend on \ref thirdpartyRS3.}
\cgalPkgBib{cgal:bht-ak}
\cgalPkgLicense{\ref licensesLGPL "LGPL"}
\cgalPkgShortInfoEnd
@ -100,8 +99,4 @@
- `CGAL::Algebraic_kernel_d_1<Coeff>`
- `CGAL::Algebraic_kernel_d_2<Coeff>`
- `CGAL::Algebraic_kernel_rs_gmpz_d_1`
- `CGAL::Algebraic_kernel_rs_gmpq_d_1`
*/

View File

@ -65,7 +65,7 @@ class Bitstream_descartes;
/*
* \brief Thrown whenever a non-specialised virtual member function is called
* \brief Thrown whenever a non-specialized virtual member function is called
*/
class Virtual_method_exception {};
@ -128,7 +128,7 @@ public:
/*!
* Constructor computing an interval containing all real roots of \c f,
* and initialising the Bitstream Descartes tree
* and initializing the Bitstream Descartes tree
*/
Generic_descartes_rep(Bitstream_descartes_type type,
Polynomial f,
@ -170,7 +170,7 @@ public:
/*!
* Constructor that copies the Bitstream tree given from outside
* and initialising the Bitstream Descartes tree
* and initializing the Bitstream Descartes tree
* The tree must "fit" to the polynomial
*/
Generic_descartes_rep(Bitstream_descartes_type type,
@ -367,7 +367,7 @@ public:
/*!
* \brief When does the isolation algorithm terminate?
*
* This method must be specialised by derived classes
* This method must be specialized by derived classes
*/
virtual bool termination_condition() {
throw Virtual_method_exception();
@ -378,7 +378,7 @@ public:
* \brief gives an opportunity to process the nodes after
* the subdivision steps are finished
*
* This method must be specialised by derived classes, but can
* This method must be specialized by derived classes, but can
* remain empty in many cases.
*/
virtual void process_nodes() {
@ -389,7 +389,7 @@ public:
/*! \brief returns whether the \c i th root is definitely a simple root
* of the isolated polynomial
*
* Must be specialised by derived class
* Must be specialized by derived class
*/
virtual bool is_certainly_simple_root(int) const {
throw Virtual_method_exception();
@ -399,7 +399,7 @@ public:
/*! \brief returns whether the \c i th root is definitely a multiple root
* of the isolated polynomial
*
* Must be specialised by derived class
* Must be specialized by derived class
*/
virtual bool is_certainly_multiple_root(int) const {
throw Virtual_method_exception();
@ -1082,7 +1082,7 @@ protected:
* variant of the Bitstream Descartes method: The Square_free_descartes_tag
* starts the usual Bitstream method for square free integer polynomials.
* With the M_k_descartes tag, it is able to handle one multiple root in
* favourable situations, the Backshear_descartes_tag allows to isolate
* favorable situations, the Backshear_descartes_tag allows to isolate
* even more complicated polynomials, if the multiple roots with even
* multiplicity can be refined from outside. See the corresponding
* constructors for more information.

View File

@ -865,7 +865,7 @@ public:
by trying randomly and checking. This randomization means
the same polynomial and same initial interval may give rise
to different intervals each time this class is used.
As indicated in the paper, we favour subdivision ratios
As indicated in the paper, we favor subdivision ratios
with a small denominator. Hence we first try denominator
2 (subdivision at midpoint), then denominator 16, and
only then the "proper" denominator prescribed by theory.

View File

@ -469,7 +469,7 @@ public:
* (\c SHEAR_ONLY_AT_IRRATIONAL_STRATEGY)
* is to \c shear the curve
* if a degenerate situation is detected during the analysis,
* except at rational x-coordinates where the curve can be analysed
* except at rational x-coordinates where the curve can be analyzed
* more directly. The analysis
* is then performed in the sheared system, and finally translated back
* into the original system.
@ -520,7 +520,7 @@ private:
void set_event_lines(InputIterator1 event_begin,
InputIterator1 event_end,
InputIterator2 intermediate_begin,
InputIterator2 CGAL_precondition_code(intermediate_end)) const {
InputIterator2 CGAL_assertion_code(intermediate_end)) const {
if(! this->ptr()->event_coordinates) {

View File

@ -875,7 +875,7 @@ private:
* Checks intersection with symbolic methods
*/
bool check_candidate_symbolically(Status_line_CA_1& e1,size_type ,
Status_line_CA_1& CGAL_precondition_code(e2),size_type ,
Status_line_CA_1& CGAL_assertion_code(e2),size_type ,
size_type k) const {
Polynomial_1 p = -coprincipal_subresultants(k-1);
Polynomial_1 q = principal_subresultants(k)*Coefficient(k);
@ -1173,7 +1173,7 @@ private:
/*
* \brief reduces the number of possible intersections
*
* At the position given by the event lins \c e1 and \c e2 and the slice
* At the position given by the event lines \c e1 and \c e2 and the slice
* info object \c slice, the points on the event lines are further refined
* until there are only \c n possible intersection points. The method can
* be interrupted if all possible intersection points are known to have

View File

@ -140,7 +140,7 @@ public:
virtual ~LRU_hashed_map()
{ }
/*! \brief implements cache-like behaviour of the map
/*! \brief implements cache-like behavior of the map
*
* If the object is not in the map, it is constructed using \c Creator
* and added to the map
@ -312,7 +312,7 @@ public:
~LRU_hashed_map_with_kernel()
{ }
/*! \brief implements cache-like behaviour of the map
/*! \brief implements cache-like behavior of the map
*
* If the object is not in the map, it is constructed using \c Creator
* and added to the map

View File

@ -65,7 +65,7 @@ template < class PolynomialIterator,
int gen_agebraic_reals_with_mults( PolynomialIterator fac,
PolynomialIterator fac_end,
IntIterator mul,
IntIterator CGAL_precondition_code(mul_end),
IntIterator CGAL_assertion_code(mul_end),
AlgebraicRealOutputIterator oi_root,
IntOutputIterator oi_mult){

View File

@ -331,7 +331,7 @@ public:
const typename Curve_pair_analysis_2
::Curve_analysis_2& c1,
const typename Curve_pair_analysis_2
::Curve_analysis_2& CGAL_precondition_code(c2)) const
::Curve_analysis_2& CGAL_assertion_code(c2)) const
{
CGAL_precondition(0 <= j && j < number_of_events());

View File

@ -25,7 +25,7 @@ namespace CGAL {
/*!
* \brief Exception class for not sufficiently generic positions.
*
* Must be thrown whenever a curve cannot be analysed because its position
* Must be thrown whenever a curve cannot be analyzed because its position
* is not "good enough".
*/
class Non_generic_position_exception {
@ -40,7 +40,7 @@ namespace CGAL {
/*!
* \brief Exception class for not sufficiently generic positions.
*
* Must be thrown whenever a curve cannot be analysed because its position
* Must be thrown whenever a curve cannot be analyzed because its position
* is not "good enough".
*/
template<typename Polynomial>

View File

@ -76,7 +76,7 @@
/**
* If set, the curve and curve pair analysis are using specialized code
* to analyse conic curves, i.e. curves of degree 2
* to analyze conic curves, i.e. curves of degree 2
*/
#ifndef CGAL_ACK_USE_SPECIAL_TREATMENT_FOR_CONIX
#define CGAL_ACK_USE_SPECIAL_TREATMENT_FOR_CONIX 0

View File

@ -1,114 +0,0 @@
// Copyright (c) 2006-2013 INRIA Nancy-Grand Est (France). All rights reserved.
//
// This file is part of CGAL (www.cgal.org)
//
// $URL$
// $Id$
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author: Luis Peñaranda <luis.penaranda@gmx.com>
#ifndef CGAL_ALGEBRAIC_KERNEL_RS_GMPQ_D_1
#define CGAL_ALGEBRAIC_KERNEL_RS_GMPQ_D_1
#include <CGAL/disable_warnings.h>
#include <CGAL/Gmpq.h>
#include <CGAL/Gmpfr.h>
#include <CGAL/Polynomial.h>
#include "RS/rs2_isolator_1.h"
#ifdef CGAL_USE_RS3
#include "RS/rs23_k_isolator_1.h"
#include "RS/rs3_refiner_1.h"
#include "RS/rs3_k_refiner_1.h"
#else
#include "RS/bisection_refiner_1.h"
#endif
#ifdef CGAL_RS_USE_NATIVE_GMPQ_KERNEL
#include "RS/ak_1.h"
#else
#include "RS/ak_z_1.h"
#endif
// The RS algebraic kernel for non-Gmpz types comes in two flavors. The
// native kernel converts, before each operation, the input polynomial to a
// Polynomial<Gmpz>. The z-kernel only converts to a Polynomial<Gmpz>
// before isolation and stores both polynomials in the algebraic number.
// The latter is the default behavior, but the former can be selected by
// setting the compilation flag CGAL_RS_USE_NATIVE_GMPQ_KERNEL.
namespace CGAL{
#ifdef CGAL_RS_USE_NATIVE_GMPQ_KERNEL // Use the native kernel.
// Choice of the isolator: RS default or RS-k.
#ifdef CGAL_RS_USE_K
typedef CGAL::RS23_k_isolator_1<CGAL::Polynomial<CGAL::Gmpq>,CGAL::Gmpfr>
QIsolator;
#else
typedef CGAL::RS2::RS2_isolator_1<CGAL::Polynomial<CGAL::Gmpq>,CGAL::Gmpfr>
QIsolator;
#endif
// Choice of the refiner: bisection, RS3 or RS3-k.
#ifdef CGAL_USE_RS3
#ifdef CGAL_RS_USE_K
typedef CGAL::RS3::RS3_k_refiner_1<CGAL::Polynomial<CGAL::Gmpq>,CGAL::Gmpfr>
QRefiner;
#else
typedef CGAL::RS3::RS3_refiner_1<CGAL::Polynomial<CGAL::Gmpq>,CGAL::Gmpfr>
QRefiner;
#endif
#else
typedef CGAL::Bisection_refiner_1<CGAL::Polynomial<CGAL::Gmpq>,CGAL::Gmpfr>
QRefiner;
#endif
typedef CGAL::RS_AK1::Algebraic_kernel_1<
CGAL::Polynomial<CGAL::Gmpq>,
CGAL::Gmpfr,
QIsolator,
QRefiner>
Algebraic_kernel_rs_gmpq_d_1;
#else // Use the z-kernel.
// Choice of the z-isolator: RS default or RS-k.
#ifdef CGAL_RS_USE_K
typedef CGAL::RS23_k_isolator_1<CGAL::Polynomial<CGAL::Gmpz>,CGAL::Gmpfr>
ZIsolator;
#else
typedef CGAL::RS2::RS2_isolator_1<CGAL::Polynomial<CGAL::Gmpz>,CGAL::Gmpfr>
ZIsolator;
#endif
// Choice of the z-refiner: bisection, RS3 or RS3-k.
#ifdef CGAL_USE_RS3
#ifdef CGAL_RS_USE_K
typedef CGAL::RS3::RS3_k_refiner_1<CGAL::Polynomial<CGAL::Gmpz>,CGAL::Gmpfr>
ZRefiner;
#else
typedef CGAL::RS3::RS3_refiner_1<CGAL::Polynomial<CGAL::Gmpz>,CGAL::Gmpfr>
ZRefiner;
#endif
#else
typedef CGAL::Bisection_refiner_1<CGAL::Polynomial<CGAL::Gmpz>,CGAL::Gmpfr>
ZRefiner;
#endif
typedef CGAL::RS_AK1::Algebraic_kernel_z_1<
CGAL::Polynomial<CGAL::Gmpq>,
CGAL::Polynomial<CGAL::Gmpz>,
CGAL::RS_AK1::Polynomial_converter_1<CGAL::Polynomial<CGAL::Gmpq>,
CGAL::Polynomial<CGAL::Gmpz> >,
CGAL::Gmpfr,
ZIsolator,
ZRefiner>
Algebraic_kernel_rs_gmpq_d_1;
#endif
} // namespace CGAL
#include <CGAL/enable_warnings.h>
#endif // CGAL_ALGEBRAIC_KERNEL_RS_GMPQ_D_1

View File

@ -1,65 +0,0 @@
// Copyright (c) 2006-2013 INRIA Nancy-Grand Est (France). All rights reserved.
//
// This file is part of CGAL (www.cgal.org)
//
// $URL$
// $Id$
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author: Luis Peñaranda <luis.penaranda@gmx.com>
#ifndef CGAL_ALGEBRAIC_KERNEL_RS_GMPZ_D_1
#define CGAL_ALGEBRAIC_KERNEL_RS_GMPZ_D_1
#include <CGAL/disable_warnings.h>
#include <CGAL/Gmpz.h>
#include <CGAL/Gmpfr.h>
#include <CGAL/Polynomial.h>
#include "RS/rs2_isolator_1.h"
#ifdef CGAL_USE_RS3
#include "RS/rs23_k_isolator_1.h"
#include "RS/rs3_refiner_1.h"
#include "RS/rs3_k_refiner_1.h"
#else
#include "RS/bisection_refiner_1.h"
#endif
#include "RS/ak_1.h"
namespace CGAL{
// Choice of the isolator: RS default or RS-k.
#ifdef CGAL_RS_USE_K
typedef CGAL::RS23_k_isolator_1<CGAL::Polynomial<CGAL::Gmpz>,CGAL::Gmpfr>
Isolator;
#else
typedef CGAL::RS2::RS2_isolator_1<CGAL::Polynomial<CGAL::Gmpz>,CGAL::Gmpfr>
Isolator;
#endif
// Choice of the refiner: bisection, RS3 or RS3-k.
#ifdef CGAL_USE_RS3
#ifdef CGAL_RS_USE_K
typedef CGAL::RS3::RS3_k_refiner_1<CGAL::Polynomial<CGAL::Gmpz>,CGAL::Gmpfr>
Refiner;
#else
typedef CGAL::RS3::RS3_refiner_1<CGAL::Polynomial<CGAL::Gmpz>,CGAL::Gmpfr>
Refiner;
#endif
#else
typedef CGAL::Bisection_refiner_1<CGAL::Polynomial<CGAL::Gmpz>,CGAL::Gmpfr>
Refiner;
#endif
typedef CGAL::RS_AK1::Algebraic_kernel_1<
CGAL::Polynomial<CGAL::Gmpz>,
CGAL::Gmpfr,
Isolator,
Refiner>
Algebraic_kernel_rs_gmpz_d_1;
}
#include <CGAL/enable_warnings.h>
#endif // CGAL_ALGEBRAIC_KERNEL_RS_GMPZ_D_1

View File

@ -1,30 +0,0 @@
// Copyright (c) 2006-2013 INRIA Nancy-Grand Est (France). All rights reserved.
//
// This file is part of CGAL (www.cgal.org)
//
// $URL$
// $Id$
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author: Luis Peñaranda <luis.penaranda@gmx.com>
#ifndef CGAL_RS_GMPFR_MAKE_UNIQUE_H
#define CGAL_RS_GMPFR_MAKE_UNIQUE_H
#include <CGAL/Gmpfr.h>
// Make sure a number does not share references. If it does, copy it.
#ifdef CGAL_GMPFR_NO_REFCOUNT
# define CGAL_RS_GMPFR_MAKE_UNIQUE(_number,_tempvar) {};
#else // CGAL_GMPFR_NO_REFCOUNT
# define CGAL_RS_GMPFR_MAKE_UNIQUE(_number,_tempvar) \
if(!_number.is_unique()){ \
Gmpfr _tempvar(0,_number.get_precision()); \
mpfr_set(_tempvar.fr(),_number.fr(),GMP_RNDN); \
_number=_tempvar; \
CGAL_assertion_code(_tempvar=Gmpfr();) \
CGAL_assertion(_number.is_unique()); \
}
#endif // CGAL_GMPFR_NO_REFCOUNT
#endif // CGAL_RS_GMPFR_MAKE_UNIQUE_H

View File

@ -1,172 +0,0 @@
// Copyright (c) 2006-2013 INRIA Nancy-Grand Est (France). All rights reserved.
//
// This file is part of CGAL (www.cgal.org)
//
// $URL$
// $Id$
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author: Luis Peñaranda <luis.penaranda@gmx.com>
#ifndef CGAL_RS_AK_1_H
#define CGAL_RS_AK_1_H
#include <cstddef> // included only to define size_t
#include <CGAL/Polynomial_traits_d.h>
#include "algebraic_1.h"
#include "comparator_1.h"
#include "signat_1.h"
#include "functors_1.h"
namespace CGAL{
namespace RS_AK1{
template <class Polynomial_,
class Bound_,
class Isolator_,
class Refiner_,
class Ptraits_=CGAL::Polynomial_traits_d<Polynomial_> >
class Algebraic_kernel_1{
public:
typedef Polynomial_ Polynomial_1;
typedef typename Polynomial_1::NT Coefficient;
typedef Bound_ Bound;
private:
typedef Isolator_ Isolator;
typedef Refiner_ Refiner;
typedef Ptraits_ Ptraits;
typedef CGAL::RS_AK1::Signat_1<Polynomial_1,Bound>
Signat;
typedef CGAL::RS_AK1::Simple_comparator_1<Polynomial_1,
Bound,
Refiner,
Signat,
Ptraits>
Comparator;
public:
typedef CGAL::RS_AK1::Algebraic_1<Polynomial_1,
Bound,
Refiner,
Comparator,
Ptraits>
Algebraic_real_1;
typedef size_t size_type;
typedef unsigned Multiplicity_type;
// default constructor and destructor
public:
Algebraic_kernel_1(){};
~Algebraic_kernel_1(){};
// functors from the CGAL concept
public:
typedef CGAL::RS_AK1::Construct_algebraic_real_1<Polynomial_1,
Algebraic_real_1,
Bound,
Coefficient,
Isolator>
Construct_algebraic_real_1;
typedef CGAL::RS_AK1::Compute_polynomial_1<Polynomial_1,
Algebraic_real_1>
Compute_polynomial_1;
typedef CGAL::RS_AK1::Isolate_1<Polynomial_1,
Bound,
Algebraic_real_1,
Isolator,
Comparator,
Signat,
Ptraits>
Isolate_1;
typedef typename Ptraits::Is_square_free Is_square_free_1;
typedef typename Ptraits::Make_square_free Make_square_free_1;
typedef typename Ptraits::Square_free_factorize
Square_free_factorize_1;
typedef CGAL::RS_AK1::Is_coprime_1<Polynomial_1,Ptraits>
Is_coprime_1;
typedef CGAL::RS_AK1::Make_coprime_1<Polynomial_1,Ptraits>
Make_coprime_1;
typedef CGAL::RS_AK1::Solve_1<Polynomial_1,
Bound,
Algebraic_real_1,
Isolator,
Signat,
Ptraits>
Solve_1;
typedef CGAL::RS_AK1::Number_of_solutions_1<Polynomial_1,Isolator>
Number_of_solutions_1;
typedef CGAL::RS_AK1::Sign_at_1<Polynomial_1,
Bound,
Algebraic_real_1,
Refiner,
Signat,
Ptraits>
Sign_at_1;
typedef CGAL::RS_AK1::Is_zero_at_1<Polynomial_1,
Bound,
Algebraic_real_1,
Refiner,
Signat,
Ptraits>
Is_zero_at_1;
typedef CGAL::RS_AK1::Compare_1<Algebraic_real_1,
Bound,
Comparator>
Compare_1;
typedef CGAL::RS_AK1::Bound_between_1<Algebraic_real_1,
Bound,
Comparator>
Bound_between_1;
typedef CGAL::RS_AK1::Approximate_absolute_1<Polynomial_1,
Bound,
Algebraic_real_1,
Refiner>
Approximate_absolute_1;
typedef CGAL::RS_AK1::Approximate_relative_1<Polynomial_1,
Bound,
Algebraic_real_1,
Refiner>
Approximate_relative_1;
#define CREATE_FUNCTION_OBJECT(T,N) \
T N##_object()const{return T();}
CREATE_FUNCTION_OBJECT(Construct_algebraic_real_1,
construct_algebraic_real_1)
CREATE_FUNCTION_OBJECT(Compute_polynomial_1,
compute_polynomial_1)
CREATE_FUNCTION_OBJECT(Isolate_1,
isolate_1)
CREATE_FUNCTION_OBJECT(Is_square_free_1,
is_square_free_1)
CREATE_FUNCTION_OBJECT(Make_square_free_1,
make_square_free_1)
CREATE_FUNCTION_OBJECT(Square_free_factorize_1,
square_free_factorize_1)
CREATE_FUNCTION_OBJECT(Is_coprime_1,
is_coprime_1)
CREATE_FUNCTION_OBJECT(Make_coprime_1,
make_coprime_1)
CREATE_FUNCTION_OBJECT(Solve_1,
solve_1)
CREATE_FUNCTION_OBJECT(Number_of_solutions_1,
number_of_solutions_1)
CREATE_FUNCTION_OBJECT(Sign_at_1,
sign_at_1)
CREATE_FUNCTION_OBJECT(Is_zero_at_1,
is_zero_at_1)
CREATE_FUNCTION_OBJECT(Compare_1,
compare_1)
CREATE_FUNCTION_OBJECT(Bound_between_1,
bound_between_1)
CREATE_FUNCTION_OBJECT(Approximate_absolute_1,
approximate_absolute_1)
CREATE_FUNCTION_OBJECT(Approximate_relative_1,
approximate_relative_1)
#undef CREATE_FUNCTION_OBJECT
}; // class Algebraic_kernel_1
} // namespace RS_AK1
} // namespace CGAL
#endif // CGAL_RS_AK_1_H

View File

@ -1,202 +0,0 @@
// Copyright (c) 2006-2013 INRIA Nancy-Grand Est (France). All rights reserved.
//
// This file is part of CGAL (www.cgal.org)
//
// $URL$
// $Id$
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author: Luis Peñaranda <luis.penaranda@gmx.com>
#ifndef CGAL_RS_AK_Z_1_H
#define CGAL_RS_AK_Z_1_H
#include <cstddef> // included only to define size_t
#include <CGAL/Polynomial_traits_d.h>
#include "algebraic_z_1.h"
#include "comparator_1.h"
#include "signat_1.h"
#include "functors_z_1.h"
// This file defines the "Z-algebraic kernel". This kind of kernel performs
// all the internal operations using an integer polynomial type (the name
// "Z" comes from there). For this, a converter functor (passed as a
// template parameter) is used, which converts the input polynomial to the
// integer representation.
namespace CGAL{
namespace RS_AK1{
template <class ExtPolynomial_,
class IntPolynomial_,
class PolConverter_,
class Bound_,
class Isolator_,
class Refiner_,
class Ptraits_=CGAL::Polynomial_traits_d<ExtPolynomial_>,
class ZPtraits_=CGAL::Polynomial_traits_d<IntPolynomial_> >
class Algebraic_kernel_z_1{
public:
typedef ExtPolynomial_ Polynomial_1;
typedef IntPolynomial_ ZPolynomial_1;
typedef PolConverter_ PolConverter;
typedef typename Polynomial_1::NT Coefficient;
typedef Bound_ Bound;
private:
typedef Isolator_ Isolator;
typedef Refiner_ Refiner;
typedef Ptraits_ Ptraits;
typedef ZPtraits_ ZPtraits;
typedef CGAL::RS_AK1::Signat_1<ZPolynomial_1,Bound>
Signat;
typedef CGAL::RS_AK1::Simple_comparator_1<ZPolynomial_1,
Bound,
Refiner,
Signat,
ZPtraits>
Comparator;
public:
typedef CGAL::RS_AK1::Algebraic_z_1<Polynomial_1,
ZPolynomial_1,
Bound,
Refiner,
Comparator,
Ptraits,
ZPtraits>
Algebraic_real_1;
typedef size_t size_type;
typedef unsigned Multiplicity_type;
// default constructor and destructor
public:
Algebraic_kernel_z_1(){};
~Algebraic_kernel_z_1(){};
// functors from the CGAL concept
public:
typedef CGAL::RS_AK1::Construct_algebraic_real_z_1<Polynomial_1,
ZPolynomial_1,
PolConverter,
Algebraic_real_1,
Bound,
Coefficient,
Isolator>
Construct_algebraic_real_1;
typedef CGAL::RS_AK1::Compute_polynomial_z_1<Polynomial_1,
Algebraic_real_1>
Compute_polynomial_1;
typedef CGAL::RS_AK1::Isolate_z_1<Polynomial_1,
ZPolynomial_1,
PolConverter,
Bound,
Algebraic_real_1,
Isolator,
Comparator,
Signat,
Ptraits,
ZPtraits>
Isolate_1;
typedef typename Ptraits::Is_square_free Is_square_free_1;
typedef typename Ptraits::Make_square_free Make_square_free_1;
typedef typename Ptraits::Square_free_factorize Square_free_factorize_1;
typedef CGAL::RS_AK1::Is_coprime_z_1<Polynomial_1,Ptraits>
Is_coprime_1;
typedef CGAL::RS_AK1::Make_coprime_z_1<Polynomial_1,Ptraits>
Make_coprime_1;
typedef CGAL::RS_AK1::Solve_z_1<Polynomial_1,
ZPolynomial_1,
PolConverter,
Bound,
Algebraic_real_1,
Isolator,
Signat,
Ptraits,
ZPtraits>
Solve_1;
typedef CGAL::RS_AK1::Number_of_solutions_z_1<Polynomial_1,
ZPolynomial_1,
PolConverter,
Isolator>
Number_of_solutions_1;
typedef CGAL::RS_AK1::Sign_at_z_1<Polynomial_1,
ZPolynomial_1,
PolConverter,
Bound,
Algebraic_real_1,
Refiner,
Signat,
Ptraits,
ZPtraits>
Sign_at_1;
typedef CGAL::RS_AK1::Is_zero_at_z_1<Polynomial_1,
ZPolynomial_1,
PolConverter,
Bound,
Algebraic_real_1,
Refiner,
Signat,
Ptraits,
ZPtraits>
Is_zero_at_1;
typedef CGAL::RS_AK1::Compare_z_1<Algebraic_real_1,
Bound,
Comparator>
Compare_1;
typedef CGAL::RS_AK1::Bound_between_z_1<Algebraic_real_1,
Bound,
Comparator>
Bound_between_1;
typedef CGAL::RS_AK1::Approximate_absolute_z_1<Polynomial_1,
Bound,
Algebraic_real_1,
Refiner>
Approximate_absolute_1;
typedef CGAL::RS_AK1::Approximate_relative_z_1<Polynomial_1,
Bound,
Algebraic_real_1,
Refiner>
Approximate_relative_1;
#define CREATE_FUNCTION_OBJECT(T,N) \
T N##_object()const{return T();}
CREATE_FUNCTION_OBJECT(Construct_algebraic_real_1,
construct_algebraic_real_1)
CREATE_FUNCTION_OBJECT(Compute_polynomial_1,
compute_polynomial_1)
CREATE_FUNCTION_OBJECT(Isolate_1,
isolate_1)
CREATE_FUNCTION_OBJECT(Is_square_free_1,
is_square_free_1)
CREATE_FUNCTION_OBJECT(Make_square_free_1,
make_square_free_1)
CREATE_FUNCTION_OBJECT(Square_free_factorize_1,
square_free_factorize_1)
CREATE_FUNCTION_OBJECT(Is_coprime_1,
is_coprime_1)
CREATE_FUNCTION_OBJECT(Make_coprime_1,
make_coprime_1)
CREATE_FUNCTION_OBJECT(Solve_1,
solve_1)
CREATE_FUNCTION_OBJECT(Number_of_solutions_1,
number_of_solutions_1)
CREATE_FUNCTION_OBJECT(Sign_at_1,
sign_at_1)
CREATE_FUNCTION_OBJECT(Is_zero_at_1,
is_zero_at_1)
CREATE_FUNCTION_OBJECT(Compare_1,
compare_1)
CREATE_FUNCTION_OBJECT(Bound_between_1,
bound_between_1)
CREATE_FUNCTION_OBJECT(Approximate_absolute_1,
approximate_absolute_1)
CREATE_FUNCTION_OBJECT(Approximate_relative_1,
approximate_relative_1)
#undef CREATE_FUNCTION_OBJECT
}; // class Algebraic_kernel_z_1
} // namespace RS_AK1
} // namespace CGAL
#endif // CGAL_RS_AK_Z_1_H

View File

@ -1,353 +0,0 @@
// Copyright (c) 2006-2013 INRIA Nancy-Grand Est (France). All rights reserved.
//
// This file is part of CGAL (www.cgal.org)
//
// $URL$
// $Id$
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author: Luis Peñaranda <luis.penaranda@gmx.com>
#ifndef CGAL_RS_ALGEBRAIC_1_H
#define CGAL_RS_ALGEBRAIC_1_H
#include <boost/operators.hpp>
#include <CGAL/Real_embeddable_traits.h>
#include <CGAL/Gmpq.h>
#include <iostream>
namespace CGAL{
namespace RS_AK1{
// This class represents the simplest algebraic number one can think about.
// One algebraic number is represented by the polynomial of which it is
// root and the two endpoints of an interval that contains it, and no other
// root. Polynomial type and bound type are the first two template
// parameters.
//
// The third template parameter is a refiner, a function object that
// receives the polynomial and the bounds defining an algebraic number and
// an integer p, and modifies the two bounds until the difference between
// the two bounds is less than x*2^(-p), where x is the value of the
// represented algebraic number. The signature of a refiner must be:
// void
// Refiner_()(const Polynomial_&,Bound_&,Bound_&,int p);
//
// The fourth template argument is a comparator, a function object that
// receives the polynomials and bounds defining two algebraic numbers and
// just compares them, returning a CGAL::Comparison_result. The signature
// of a comparator must be:
// CGAL::Comparison_result
// Comparator_()(const Polynomial_&,Bound_&,Bound_&,
// const Polynomial_&,Bound_&,Bound_&);
// The comparator can modify the bounds, with the condition that the
// algebraic numbers remain consistent (one and only one root on each
// interval).
template <class Polynomial_,
class Bound_,
class Refiner_,
class Comparator_,
class Ptraits_>
class Algebraic_1:
boost::totally_ordered<Algebraic_1<Polynomial_,
Bound_,
Refiner_,
Comparator_,
Ptraits_>,
double>{
protected:
typedef Polynomial_ Polynomial;
typedef Bound_ Bound;
typedef Refiner_ Refiner;
typedef Comparator_ Comparator;
typedef Ptraits_ Ptraits;
typedef typename Ptraits::Coefficient_type Coefficient;
typedef typename Ptraits::Scale Scale;
typedef Algebraic_1<Polynomial,
Bound,
Refiner,
Comparator,
Ptraits>
Algebraic;
Polynomial pol;
mutable Bound left,right;
public:
Algebraic_1(){};
Algebraic_1(const Polynomial &p,
const Bound &l,
const Bound &r):pol(p),left(l),right(r){
CGAL_assertion(l<=r);
}
Algebraic_1(const Algebraic &a):
pol(a.pol),left(a.left),right(a.right){}
// XXX: This assumes that Gmpq is constructible from bound type and
// that polynomial coefficient type is constructible from mpz_t.
Algebraic_1(const Bound &b):left(b),right(b){
typedef typename Ptraits::Shift shift;
Gmpq q(b);
pol=Coefficient(mpq_denref(q.mpq()))*
shift()(Polynomial(1),1,0)-
Coefficient(mpq_numref(q.mpq()));
CGAL_assertion(left==right&&left==b);
}
// XXX: This implementation assumes that the bound type is Gmpfr
// and that T can be exactly converted to Gmpq. This constructor
// can handle types such as int, unsigned and long.
template <class T>
Algebraic_1(const T &t){
typedef typename Ptraits::Shift shift;
CGAL::Gmpq q(t);
pol=Coefficient(mpq_denref(q.mpq()))*
shift()(Polynomial(1),1,0)-
Coefficient(mpq_numref(q.mpq()));
left=Bound(t,std::round_toward_neg_infinity);
right=Bound(t,std::round_toward_infinity);
CGAL_assertion(left<=t&&right>=t);
}
// XXX: This constructor assumes the bound is a Gmpfr.
Algebraic_1(const CGAL::Gmpq &q){
typedef typename Ptraits::Shift shift;
pol=Coefficient(mpq_denref(q.mpq()))*
shift()(Polynomial(1),1,0)-
Coefficient(mpq_numref(q.mpq()));
left=Bound();
right=Bound();
mpfr_t b;
mpfr_init(b);
mpfr_set_q(b,q.mpq(),GMP_RNDD);
mpfr_swap(b,left.fr());
mpfr_set_q(b,q.mpq(),GMP_RNDU);
mpfr_swap(b,right.fr());
mpfr_clear(b);
CGAL_assertion(left<=q&&right>=q);
}
~Algebraic_1(){}
Algebraic_1& operator=(const Algebraic &a){
pol=a.get_pol();
left=a.get_left();
right=a.get_right();
return *this;
}
Polynomial get_pol()const{return pol;}
Bound& get_left()const{return left;}
Bound& get_right()const{return right;}
Algebraic operator-()const{
return Algebraic(Scale()(get_pol(),Coefficient(-1)),
-right,
-left);
}
#define CGAL_RS_COMPARE_ALGEBRAIC(_a) \
(Comparator()(get_pol(),get_left(),get_right(), \
(_a).get_pol(),(_a).get_left(),(_a).get_right()))
Comparison_result compare(Algebraic a)const{
return CGAL_RS_COMPARE_ALGEBRAIC(a);
};
#define CGAL_RS_COMPARE_ALGEBRAIC_TYPE(_t) \
bool operator<(_t t)const \
{Algebraic a(t);return CGAL_RS_COMPARE_ALGEBRAIC(a)==CGAL::SMALLER;} \
bool operator>(_t t)const \
{Algebraic a(t);return CGAL_RS_COMPARE_ALGEBRAIC(a)==CGAL::LARGER;} \
bool operator==(_t t)const \
{Algebraic a(t);return CGAL_RS_COMPARE_ALGEBRAIC(a)==CGAL::EQUAL;}
bool operator==(Algebraic a)const
{return CGAL_RS_COMPARE_ALGEBRAIC(a)==CGAL::EQUAL;}
bool operator!=(Algebraic a)const
{return CGAL_RS_COMPARE_ALGEBRAIC(a)!=CGAL::EQUAL;}
bool operator<(Algebraic a)const
{return CGAL_RS_COMPARE_ALGEBRAIC(a)==CGAL::SMALLER;}
bool operator<=(Algebraic a)const
{return CGAL_RS_COMPARE_ALGEBRAIC(a)!=CGAL::LARGER;}
bool operator>(Algebraic a)const
{return CGAL_RS_COMPARE_ALGEBRAIC(a)==CGAL::LARGER;}
bool operator>=(Algebraic a)const
{return CGAL_RS_COMPARE_ALGEBRAIC(a)!=CGAL::SMALLER;}
CGAL_RS_COMPARE_ALGEBRAIC_TYPE(double)
#undef CGAL_RS_COMPARE_ALGEBRAIC_TYPE
#undef CGAL_RS_COMPARE_ALGEBRAIC
#ifdef IEEE_DBL_MANT_DIG
#define CGAL_RS_DBL_PREC IEEE_DBL_MANT_DIG
#else
#define CGAL_RS_DBL_PREC 53
#endif
// This function is const because left and right are mutable.
double to_double()const{
typedef Real_embeddable_traits<Bound> RT;
typedef typename RT::To_double TD;
Refiner()(pol,left,right,CGAL_RS_DBL_PREC);
CGAL_assertion(TD()(left)==TD()(right));
return TD()(left);
}
std::pair<double,double> to_interval()const{
typedef Real_embeddable_traits<Bound> RT;
typedef typename RT::To_interval TI;
return std::make_pair(TI()(get_left()).first,
TI()(get_right()).second);
}
#undef CGAL_RS_DBL_PREC
void set_left(const Bound &l)const{
left=l;
}
void set_right(const Bound &r)const{
right=r;
}
void set_pol(const Polynomial &p){
pol=p;
}
}; // class Algebraic_1
} // namespace RS_AK1
// We define Algebraic_1 as real-embeddable
template <class Polynomial_,
class Bound_,
class Refiner_,
class Comparator_,
class Ptraits_>
class Real_embeddable_traits<RS_AK1::Algebraic_1<Polynomial_,
Bound_,
Refiner_,
Comparator_,
Ptraits_> >:
public INTERN_RET::Real_embeddable_traits_base<
RS_AK1::Algebraic_1<Polynomial_,
Bound_,
Refiner_,
Comparator_,
Ptraits_>,
CGAL::Tag_true>{
typedef Polynomial_ P;
typedef Bound_ B;
typedef Refiner_ R;
typedef Comparator_ C;
typedef Ptraits_ T;
public:
typedef RS_AK1::Algebraic_1<P,B,R,C,T> Type;
typedef CGAL::Tag_true Is_real_embeddable;
typedef bool Boolean;
typedef CGAL::Sign Sign;
typedef CGAL::Comparison_result Comparison_result;
typedef INTERN_RET::Real_embeddable_traits_base<Type,CGAL::Tag_true>
Base;
typedef typename Base::Compare Compare;
class Sgn:public CGAL::cpp98::unary_function<Type,CGAL::Sign>{
public:
CGAL::Sign operator()(const Type &a)const{
return Compare()(a,Type(0));
}
};
class To_double:public CGAL::cpp98::unary_function<Type,double>{
public:
double operator()(const Type &a)const{return a.to_double();}
};
class To_interval:
public CGAL::cpp98::unary_function<Type,std::pair<double,double> >{
public:
std::pair<double,double> operator()(const Type &a)const{
return a.to_interval();
}
};
class Is_zero:public CGAL::cpp98::unary_function<Type,Boolean>{
public:
bool operator()(const Type &a)const{
return Sgn()(a)==CGAL::ZERO;
}
};
class Is_finite:public CGAL::cpp98::unary_function<Type,Boolean>{
public:
bool operator()(const Type&)const{return true;}
};
class Abs:public CGAL::cpp98::unary_function<Type,Type>{
public:
Type operator()(const Type &a)const{
return Sgn()(a)==CGAL::NEGATIVE?-a:a;
}
};
};
template <class P,class B,class R,class C,class T>
inline
RS_AK1::Algebraic_1<P,B,R,C,T> min
BOOST_PREVENT_MACRO_SUBSTITUTION(RS_AK1::Algebraic_1<P,B,R,C,T> a,
RS_AK1::Algebraic_1<P,B,R,C,T> b){
return(a<b?a:b);
}
template <class P,class B,class R,class C,class T>
inline
RS_AK1::Algebraic_1<P,B,R,C,T> max
BOOST_PREVENT_MACRO_SUBSTITUTION(RS_AK1::Algebraic_1<P,B,R,C,T> a,
RS_AK1::Algebraic_1<P,B,R,C,T> b){
return(a>b?a:b);
}
template <class P,class B,class R,class C,class T>
inline
std::ostream& operator<<(std::ostream &o,
const RS_AK1::Algebraic_1<P,B,R,C,T> &a){
return(o<<'['<<a.get_pol()<<','<<
a.get_left()<<','<<
a.get_right()<<']');
}
// XXX: This function works, but it will be nice to rewrite it cleanly.
template <class P,class B,class R,class C,class T>
inline
std::istream& operator>>(std::istream &i,
RS_AK1::Algebraic_1<P,B,R,C,T> &a){
std::istream::int_type c;
P pol;
B lb,rb;
c=i.get();
if(c!='['){
CGAL_error_msg("error reading istream, \'[\' expected");
return i;
}
i>>pol;
c=i.get();
if(c!=','){
CGAL_error_msg("error reading istream, \',\' expected");
return i;
}
i>>lb;
c=i.get();
if(c!=','){
CGAL_error_msg("error reading istream, \',\' expected");
return i;
}
i>>rb;
c=i.get();
if(c!=']'){
CGAL_error_msg("error reading istream, \']\' expected");
return i;
}
a=RS_AK1::Algebraic_1<P,B,R,C,T>(pol,lb,rb);
return i;
}
} // namespace CGAL
#endif // CGAL_RS_ALGEBRAIC_1_H

View File

@ -1,351 +0,0 @@
// Copyright (c) 2006-2013 INRIA Nancy-Grand Est (France). All rights reserved.
//
// This file is part of CGAL (www.cgal.org)
//
// $URL$
// $Id$
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author: Luis Peñaranda <luis.penaranda@gmx.com>
#ifndef CGAL_RS_ALGEBRAIC_Z_1_H
#define CGAL_RS_ALGEBRAIC_Z_1_H
#include "algebraic_1.h"
namespace CGAL{
namespace RS_AK1{
// This class represents an algebraic number storing two polynomials of
// which it is root: one of them is the given polynomial; the other one is
// an integer polynomial, which is used to perform the operations such as
// refinements. Since RS works only with integer polynomials, this
// architecture permits to convert the input polynomials only once.
template <class Polynomial_,
class ZPolynomial_,
class Bound_,
class ZRefiner_,
class ZComparator_,
class Ptraits_,
class ZPtraits_>
class Algebraic_z_1:
public Algebraic_1<Polynomial_,Bound_,ZRefiner_,ZComparator_,ZPtraits_>,
boost::totally_ordered<Algebraic_z_1<Polynomial_,
ZPolynomial_,
Bound_,
ZRefiner_,
ZComparator_,
Ptraits_,
ZPtraits_>,
double>{
protected:
typedef Polynomial_ Polynomial;
typedef ZPolynomial_ ZPolynomial;
typedef Bound_ Bound;
typedef ZRefiner_ ZRefiner;
typedef ZComparator_ ZComparator;
typedef ZPtraits_ ZPtraits;
typedef typename ZPtraits::Coefficient_type ZCoefficient;
typedef typename ZPtraits::Scale ZScale;
typedef Ptraits_ Ptraits;
typedef typename Ptraits::Coefficient_type Coefficient;
typedef typename Ptraits::Scale Scale;
typedef Algebraic_1<Polynomial,Bound,ZRefiner,ZComparator,ZPtraits>
Algebraic_base;
typedef Algebraic_z_1<Polynomial,
ZPolynomial,
Bound,
ZRefiner,
ZComparator,
Ptraits,
ZPtraits>
Algebraic;
ZPolynomial zpol;
public:
Algebraic_z_1(){};
Algebraic_z_1(const Polynomial &p,
const ZPolynomial &zp,
const Bound &l,
const Bound &r):Algebraic_base(p,l,r),zpol(zp){
CGAL_assertion(l<=r);
}
Algebraic_z_1(const Algebraic &a):
Algebraic_base(a.pol,a.left,a.right),zpol(a.zpol){}
Algebraic_z_1(const Bound &b){
typedef typename Ptraits::Shift Shift;
typedef typename ZPtraits::Shift ZShift;
this->left=b;
this->right=b;
Gmpq q(b);
this->pol=Coefficient(mpq_denref(q.mpq()))*
Shift()(Polynomial(1),1,0)-
Coefficient(mpq_numref(q.mpq()));
zpol=ZCoefficient(mpq_denref(q.mpq()))*
ZShift()(ZPolynomial(1),1,0)-
ZCoefficient(mpq_numref(q.mpq()));
CGAL_assertion(this->left==this->right);
CGAL_assertion(this->left==b);
}
template <class T>
Algebraic_z_1(const T &t){
typedef typename Ptraits::Shift Shift;
typedef typename ZPtraits::Shift ZShift;
CGAL::Gmpq q(t);
this->pol=Coefficient(mpq_denref(q.mpq()))*
Shift()(Polynomial(1),1,0)-
Coefficient(mpq_numref(q.mpq()));
zpol=ZCoefficient(mpq_denref(q.mpq()))*
ZShift()(ZPolynomial(1),1,0)-
ZCoefficient(mpq_numref(q.mpq()));
this->left=Bound(t,std::round_toward_neg_infinity);
this->right=Bound(t,std::round_toward_infinity);
CGAL_assertion(this->left<=t&&this->right>=t);
}
Algebraic_z_1(const CGAL::Gmpq &q){
typedef typename Ptraits::Shift Shift;
typedef typename ZPtraits::Shift ZShift;
this->pol=Coefficient(mpq_denref(q.mpq()))*
Shift()(Polynomial(1),1,0)-
Coefficient(mpq_numref(q.mpq()));
zpol=ZCoefficient(mpq_denref(q.mpq()))*
ZShift()(ZPolynomial(1),1,0)-
ZCoefficient(mpq_numref(q.mpq()));
this->left=Bound();
this->right=Bound();
mpfr_t b;
mpfr_init(b);
mpfr_set_q(b,q.mpq(),GMP_RNDD);
mpfr_swap(b,this->left.fr());
mpfr_set_q(b,q.mpq(),GMP_RNDU);
mpfr_swap(b,this->right.fr());
mpfr_clear(b);
CGAL_assertion(this->left<=q&&this->right>=q);
}
~Algebraic_z_1(){}
ZPolynomial get_zpol()const{return zpol;}
void set_zpol(const ZPolynomial &p){zpol=p;}
Algebraic operator-()const{
return Algebraic(Scale()(this->get_pol(),Coefficient(-1)),
ZScale()(get_zpol(),ZCoefficient(-1)),
-this->right,
-this->left);
}
#define CGAL_RS_COMPARE_ALGEBRAIC_Z(_a) \
(ZComparator()(get_zpol(),this->get_left(),this->get_right(), \
(_a).get_zpol(),(_a).get_left(),(_a).get_right()))
Comparison_result compare(Algebraic a)const{
return CGAL_RS_COMPARE_ALGEBRAIC_Z(a);
};
#define CGAL_RS_COMPARE_ALGEBRAIC_Z_TYPE(_t) \
bool operator<(_t t)const \
{Algebraic a(t);return CGAL_RS_COMPARE_ALGEBRAIC_Z(a)==CGAL::SMALLER;} \
bool operator>(_t t)const \
{Algebraic a(t);return CGAL_RS_COMPARE_ALGEBRAIC_Z(a)==CGAL::LARGER;} \
bool operator==(_t t)const \
{Algebraic a(t);return CGAL_RS_COMPARE_ALGEBRAIC_Z(a)==CGAL::EQUAL;}
bool operator==(Algebraic a)const
{return CGAL_RS_COMPARE_ALGEBRAIC_Z(a)==CGAL::EQUAL;}
bool operator!=(Algebraic a)const
{return CGAL_RS_COMPARE_ALGEBRAIC_Z(a)!=CGAL::EQUAL;}
bool operator<(Algebraic a)const
{return CGAL_RS_COMPARE_ALGEBRAIC_Z(a)==CGAL::SMALLER;}
bool operator<=(Algebraic a)const
{return CGAL_RS_COMPARE_ALGEBRAIC_Z(a)!=CGAL::LARGER;}
bool operator>(Algebraic a)const
{return CGAL_RS_COMPARE_ALGEBRAIC_Z(a)==CGAL::LARGER;}
bool operator>=(Algebraic a)const
{return CGAL_RS_COMPARE_ALGEBRAIC_Z(a)!=CGAL::SMALLER;}
CGAL_RS_COMPARE_ALGEBRAIC_Z_TYPE(double)
#undef CGAL_RS_COMPARE_ALGEBRAIC_Z_TYPE
#undef CGAL_RS_COMPARE_ALGEBRAIC_Z
#ifdef IEEE_DBL_MANT_DIG
#define CGAL_RS_DBL_PREC IEEE_DBL_MANT_DIG
#else
#define CGAL_RS_DBL_PREC 53
#endif
double to_double()const{
typedef Real_embeddable_traits<Bound> RT;
typedef typename RT::To_double TD;
ZRefiner()(get_zpol(),
this->get_left(),
this->get_right(),
CGAL_RS_DBL_PREC);
CGAL_assertion(TD()(this->get_left())==TD()(this->get_right()));
return TD()(this->get_left());
}
std::pair<double,double> to_interval()const{
typedef Real_embeddable_traits<Bound> RT;
typedef typename RT::To_interval TI;
return std::make_pair(TI()(this->get_left()).first,
TI()(this->get_right()).second);
}
#undef CGAL_RS_DBL_PREC
}; // class Algebraic_z_1
} // namespace RS_AK1
// We define Algebraic_z_1 as real-embeddable
template <class Polynomial_,
class ZPolynomial_,
class Bound_,
class ZRefiner_,
class ZComparator_,
class Ptraits_,
class ZPtraits_>
class Real_embeddable_traits<RS_AK1::Algebraic_z_1<Polynomial_,
ZPolynomial_,
Bound_,
ZRefiner_,
ZComparator_,
Ptraits_,
ZPtraits_> >:
public INTERN_RET::Real_embeddable_traits_base<
RS_AK1::Algebraic_z_1<Polynomial_,
ZPolynomial_,
Bound_,
ZRefiner_,
ZComparator_,
Ptraits_,
ZPtraits_>,
CGAL::Tag_true>{
typedef Polynomial_ P;
typedef ZPolynomial_ ZP;
typedef Bound_ B;
typedef ZRefiner_ R;
typedef ZComparator_ C;
typedef Ptraits_ T;
typedef ZPtraits_ ZT;
public:
typedef RS_AK1::Algebraic_z_1<P,ZP,B,R,C,T,ZT> Type;
typedef CGAL::Tag_true Is_real_embeddable;
typedef bool Boolean;
typedef CGAL::Sign Sign;
typedef CGAL::Comparison_result Comparison_result;
typedef INTERN_RET::Real_embeddable_traits_base<Type,CGAL::Tag_true>
Base;
typedef typename Base::Compare Compare;
class Sgn:public CGAL::cpp98::unary_function<Type,CGAL::Sign>{
public:
CGAL::Sign operator()(const Type &a)const{
return Compare()(a,Type(0));
}
};
class To_double:public CGAL::cpp98::unary_function<Type,double>{
public:
double operator()(const Type &a)const{return a.to_double();}
};
class To_interval:
public CGAL::cpp98::unary_function<Type,std::pair<double,double> >{
public:
std::pair<double,double> operator()(const Type &a)const{
return a.to_interval();
}
};
class Is_zero:public CGAL::cpp98::unary_function<Type,Boolean>{
public:
bool operator()(const Type &a)const{
return Sgn()(a)==CGAL::ZERO;
}
};
class Is_finite:public CGAL::cpp98::unary_function<Type,Boolean>{
public:
bool operator()(const Type&)const{return true;}
};
class Abs:public CGAL::cpp98::unary_function<Type,Type>{
public:
Type operator()(const Type &a)const{
return Sgn()(a)==CGAL::NEGATIVE?-a:a;
}
};
};
template <class P,class ZP,class B,class R,class C,class T,class ZT>
inline
RS_AK1::Algebraic_z_1<P,ZP,B,R,C,T,ZT> min
BOOST_PREVENT_MACRO_SUBSTITUTION(RS_AK1::Algebraic_z_1<P,ZP,B,R,C,T,ZT> a,
RS_AK1::Algebraic_z_1<P,ZP,B,R,C,T,ZT> b){
return(a<b?a:b);
}
template <class P,class ZP,class B,class R,class C,class T,class ZT>
inline
RS_AK1::Algebraic_z_1<P,ZP,B,R,C,T,ZT> max
BOOST_PREVENT_MACRO_SUBSTITUTION(RS_AK1::Algebraic_z_1<P,ZP,B,R,C,T,ZT> a,
RS_AK1::Algebraic_z_1<P,ZP,B,R,C,T,ZT> b){
return(a>b?a:b);
}
template <class P,class ZP,class B,class R,class C,class T,class ZT>
inline
std::ostream& operator<<(std::ostream &o,
const RS_AK1::Algebraic_z_1<P,ZP,B,R,C,T,ZT> &a){
return(o<<'['<<a.get_pol()<<','<<
a.get_zpol()<<','<<
a.get_left()<<','<<
a.get_right()<<']');
}
template <class P,class ZP,class B,class R,class C,class T,class ZT>
inline
std::istream& operator>>(std::istream &i,
RS_AK1::Algebraic_z_1<P,ZP,B,R,C,T,ZT> &a){
std::istream::int_type c;
P pol;
ZP zpol;
B lb,rb;
c=i.get();
if(c!='['){
CGAL_error_msg("error reading istream, \'[\' expected");
return i;
}
i>>pol;
c=i.get();
if(c!=','){
CGAL_error_msg("error reading istream, \',\' expected");
return i;
}
i>>zpol;
c=i.get();
if(c!=','){
CGAL_error_msg("error reading istream, \',\' expected");
return i;
}
i>>lb;
c=i.get();
if(c!=','){
CGAL_error_msg("error reading istream, \',\' expected");
return i;
}
i>>rb;
c=i.get();
if(c!=']'){
CGAL_error_msg("error reading istream, \']\' expected");
return i;
}
a=RS_AK1::Algebraic_z_1<P,ZP,B,R,C,T,ZT>(pol,zpol,lb,rb);
return i;
}
} // namespace CGAL
#endif // CGAL_RS_ALGEBRAIC_Z_1_H

View File

@ -1,165 +0,0 @@
// Copyright (c) 2006-2013 INRIA Nancy-Grand Est (France). All rights reserved.
//
// This file is part of CGAL (www.cgal.org)
//
// $URL$
// $Id$
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author: Luis Peñaranda <luis.penaranda@gmx.com>
// This file contains the simplest refiner, that bisects the interval a given
// number of times.
#ifndef CGAL_RS_BISECTION_REFINER_1_H
#define CGAL_RS_BISECTION_REFINER_1_H
#include <CGAL/Polynomial_traits_d.h>
#include "signat_1.h"
#include "Gmpfr_make_unique.h"
namespace CGAL{
template <class Polynomial_,class Bound_>
struct Bisection_refiner_1{
typedef CGAL::RS_AK1::Signat_1<Polynomial_,Bound_> Signat;
void operator()(const Polynomial_&,Bound_&,Bound_&,int);
}; // class Bisection_refiner_1
// TODO: Write in a generic way, if possible (see next function).
template <class Polynomial_,class Bound_>
void
Bisection_refiner_1<Polynomial_,Bound_>::
operator()(const Polynomial_&,Bound_&,Bound_&,int){
CGAL_error_msg("bisection refiner not implemented for these types");
return;
}
// This works with any type of polynomial, but only for Gmpfr bounds.
// TODO: Beyond writing generically, optimize this function. This would
// remove the need for the next function, which is essentially the same.
template<>
void
Bisection_refiner_1<Polynomial<Gmpz>,Gmpfr>::
operator()(const Polynomial<Gmpz> &pol,Gmpfr &left,Gmpfr &right,int prec){
typedef Polynomial<Gmpz> Polynomial;
typedef Polynomial_traits_d<Polynomial> Ptraits;
typedef Ptraits::Make_square_free Sfpart;
typedef CGAL::RS_AK1::Signat_1<Polynomial,Gmpfr>
Signat;
CGAL_precondition(left<=right);
//std::cout<<"refining ["<<left<<","<<right<<"]"<<std::endl;
CGAL_RS_GMPFR_MAKE_UNIQUE(left,temp_left);
CGAL_RS_GMPFR_MAKE_UNIQUE(right,temp_right);
Polynomial sfpp=Sfpart()(pol);
Signat signof(sfpp);
CGAL::Sign sl,sc;
mp_prec_t pl,pc;
mpfr_t center;
sl=signof(left);
CGAL_precondition(sl!=signof(right)||(left==right&&sl==ZERO));
if(sl==ZERO)
return;
pl=left.get_precision();
pc=right.get_precision();
pc=(pl>pc?pl:pc)+(mp_prec_t)prec;
mpfr_init2(center,pc);
CGAL_assertion_code(int round=)
mpfr_prec_round(left.fr(),pc,GMP_RNDN);
CGAL_assertion(!round);
CGAL_assertion_code(round=)
mpfr_prec_round(right.fr(),pc,GMP_RNDN);
CGAL_assertion(!round);
for(int i=0;i<prec;++i){
CGAL_assertion_code(round=)
mpfr_add(center,left.fr(),right.fr(),GMP_RNDN);
CGAL_assertion(!round);
CGAL_assertion_code(round=)
mpfr_div_2ui(center,center,1,GMP_RNDN);
CGAL_assertion(!round);
sc=signof(Gmpfr(center));
if(sc==ZERO){ // we have a root
CGAL_assertion_code(round=)
mpfr_set(left.fr(),center,GMP_RNDN);
CGAL_assertion(!round);
mpfr_swap(right.fr(),center);
break;
}
if(sc==sl)
mpfr_swap(left.fr(),center);
else
mpfr_swap(right.fr(),center);
}
mpfr_clear(center);
CGAL_postcondition(left<=right);
//std::cout<<"ref root is ["<<left<<","<<right<<"]"<<std::endl;
return;
}
template<>
void
Bisection_refiner_1<Polynomial<Gmpq>,Gmpfr>::
operator()(const Polynomial<Gmpq> &pol,Gmpfr &left,Gmpfr &right,int prec){
typedef Polynomial<Gmpq> Polynomial;
typedef Polynomial_traits_d<Polynomial> Ptraits;
typedef Ptraits::Make_square_free Sfpart;
typedef CGAL::RS_AK1::Signat_1<Polynomial,Gmpfr>
Signat;
CGAL_precondition(left<=right);
//std::cout<<"refining ["<<left<<","<<right<<"]"<<std::endl;
CGAL_RS_GMPFR_MAKE_UNIQUE(left,temp_left);
CGAL_RS_GMPFR_MAKE_UNIQUE(right,temp_right);
Polynomial sfpp=Sfpart()(pol);
Signat signof(sfpp);
CGAL::Sign sl,sc;
mp_prec_t pl,pc;
mpfr_t center;
sl=signof(left);
CGAL_precondition(sl!=signof(right)||(left==right&&sl==ZERO));
if(sl==ZERO)
return;
pl=left.get_precision();
pc=right.get_precision();
pc=(pl>pc?pl:pc)+(mp_prec_t)prec;
mpfr_init2(center,pc);
CGAL_assertion_code(int round=)
mpfr_prec_round(left.fr(),pc,GMP_RNDN);
CGAL_assertion(!round);
CGAL_assertion_code(round=)
mpfr_prec_round(right.fr(),pc,GMP_RNDN);
CGAL_assertion(!round);
for(int i=0;i<prec;++i){
CGAL_assertion_code(round=)
mpfr_add(center,left.fr(),right.fr(),GMP_RNDN);
CGAL_assertion(!round);
CGAL_assertion_code(round=)
mpfr_div_2ui(center,center,1,GMP_RNDN);
CGAL_assertion(!round);
sc=signof(Gmpfr(center));
if(sc==ZERO){ // we have a root
CGAL_assertion_code(round=)
mpfr_set(left.fr(),center,GMP_RNDN);
CGAL_assertion(!round);
mpfr_swap(right.fr(),center);
break;
}
if(sc==sl)
mpfr_swap(left.fr(),center);
else
mpfr_swap(right.fr(),center);
}
mpfr_clear(center);
CGAL_postcondition(left<=right);
//std::cout<<"ref root is ["<<left<<","<<right<<"]"<<std::endl;
return;
}
} // namespace CGAL
#endif // CGAL_RS_BISECTION_REFINER_1_H

View File

@ -1,81 +0,0 @@
// Copyright (c) 2006-2013 INRIA Nancy-Grand Est (France). All rights reserved.
//
// This file is part of CGAL (www.cgal.org)
//
// $URL$
// $Id$
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author: Luis Peñaranda <luis.penaranda@gmx.com>
#ifndef CGAL_RS_COMPARATOR_1_H
#define CGAL_RS_COMPARATOR_1_H
namespace CGAL{
namespace RS_AK1{
template <class Polynomial_,
class Bound_,
class Refiner_,
class Signat_,
class Ptraits_>
struct Simple_comparator_1{
typedef Polynomial_ Polynomial;
typedef Bound_ Bound;
typedef Refiner_ Refiner;
typedef Signat_ Signat;
typedef Ptraits_ Ptraits;
typedef typename Ptraits::Gcd_up_to_constant_factor Gcd;
typedef typename Ptraits::Degree Degree;
CGAL::Comparison_result
operator()(const Polynomial &p1,Bound &l1,Bound &r1,
const Polynomial &p2,Bound &l2,Bound &r2)const{
CGAL_precondition(l1<=r1&&l2<=r2);
if(l1<=l2){
if(r1<l2)
return SMALLER;
}else{
if(r2<l1)
return LARGER;
}
Polynomial G=Gcd()(p1,p2);
if(Degree()(G)==0)
return compare_unequal(p1,l1,r1,p2,l2,r2);
Signat sg(G);
CGAL::Sign sleft=sg(l1>l2?l1:l2);
if(sleft==ZERO)
return EQUAL;
CGAL::Sign sright=sg(r1<r2?r1:r2);
if(sleft!=sright)
return EQUAL;
else
return compare_unequal(p1,l1,r1,p2,l2,r2);
}
// This function compares two algebraic numbers, assuming that they
// are not equal.
CGAL::Comparison_result
compare_unequal(const Polynomial &p1,Bound &l1,Bound &r1,
const Polynomial &p2,Bound &l2,Bound &r2)const{
CGAL_precondition(l1<=r1&&l2<=r2);
int prec=CGAL::max(
CGAL::max(l1.get_precision(),
r1.get_precision()),
CGAL::max(l2.get_precision(),
r2.get_precision()));
do{
prec*=2;
Refiner()(p1,l1,r1,prec);
Refiner()(p2,l2,r2,prec);
CGAL_assertion(l1<=r1&&l2<=r2);
}while(l1<=l2?r1>=l2:r2>=l1);
return (r1<l2?SMALLER:LARGER);
}
}; // struct Simple_comparator_1
} // namespace RS_AK1
} // namespace CGAL
#endif // CGAL_RS_COMPARATOR_1_H

View File

@ -1,430 +0,0 @@
// Copyright (c) 2006-2013 INRIA Nancy-Grand Est (France). All rights reserved.
//
// This file is part of CGAL (www.cgal.org)
//
// $URL$
// $Id$
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author: Luis Peñaranda <luis.penaranda@gmx.com>
#ifndef CGAL_RS_DYADIC_H
#define CGAL_RS_DYADIC_H
#include <stdio.h>
#include <math.h>
#include <gmp.h>
#include <mpfr.h>
#include <CGAL/assertions.h>
// for c++, compile with -lgmpxx
#ifdef __cplusplus
#include <iostream>
#endif
#define CGALRS_dyadic_struct __mpfr_struct
#define CGALRS_dyadic_t mpfr_t
#define CGALRS_dyadic_ptr mpfr_ptr
#define CGALRS_dyadic_srcptr mpfr_srcptr
// some auxiliary defines
#define CGALRS_dyadic_set_prec(D,P) \
( mpfr_set_prec( (D), (P)>MPFR_PREC_MIN?(P):MPFR_PREC_MIN) )
#define CGALRS_dyadic_prec_round(D,P) \
( mpfr_prec_round( (D), (P)>MPFR_PREC_MIN?(P):MPFR_PREC_MIN, GMP_RNDN) )
#define CGALRS_dyadic_set_exp(D,E) \
( CGAL_assertion( (E) <= mpfr_get_emax() && \
(E) >= mpfr_get_emin() ) ,\
mpfr_set_exp(D,E) )
// init functions
#define CGALRS_dyadic_init(D) mpfr_init2(D,MPFR_PREC_MIN)
#define CGALRS_dyadic_init2(D,P) mpfr_init2(D,P)
#define CGALRS_dyadic_clear(D) mpfr_clear(D)
inline void CGALRS_dyadic_set(CGALRS_dyadic_ptr rop,CGALRS_dyadic_srcptr op){
if(rop!=op){
CGALRS_dyadic_set_prec(rop,mpfr_get_prec(op));
mpfr_set(rop,op,GMP_RNDN);
}
CGAL_assertion(mpfr_equal_p(rop,op)!=0);
}
inline void CGALRS_dyadic_set_z(CGALRS_dyadic_ptr rop,mpz_srcptr z){
size_t prec;
prec=mpz_sizeinbase(z,2)-(mpz_tstbit(z,0)?0:mpz_scan1(z,0));
CGALRS_dyadic_set_prec(rop,prec);
mpfr_set_z(rop,z,GMP_RNDN);
CGAL_assertion(!mpfr_cmp_z(rop,z));
}
inline void CGALRS_dyadic_set_si(CGALRS_dyadic_ptr rop,long s){
CGALRS_dyadic_set_prec(rop,sizeof(long));
mpfr_set_si(rop,s,GMP_RNDN);
CGAL_assertion(!mpfr_cmp_si(rop,s));
}
inline void CGALRS_dyadic_set_ui(CGALRS_dyadic_ptr rop,unsigned long u){
CGALRS_dyadic_set_prec(rop,sizeof(unsigned long));
mpfr_set_ui(rop,u,GMP_RNDN);
CGAL_assertion(!mpfr_cmp_ui(rop,u));
}
inline void CGALRS_dyadic_set_fr(CGALRS_dyadic_ptr rop,mpfr_srcptr op){
if(rop!=op){
CGALRS_dyadic_set_prec(rop,mpfr_get_prec(op));
mpfr_set(rop,op,GMP_RNDN);
CGAL_assertion(mpfr_equal_p(rop,op)!=0);
}
}
#define CGALRS_dyadic_init_set(R,D) \
( CGALRS_dyadic_init(R), CGALRS_dyadic_set((R), (D)) )
#define CGALRS_dyadic_init_set_z(R,Z) \
( CGALRS_dyadic_init(R), CGALRS_dyadic_set_z((R), (Z)) )
#define CGALRS_dyadic_init_set_si(R,I) \
( CGALRS_dyadic_init(R), CGALRS_dyadic_set_si((R), (I)) )
#define CGALRS_dyadic_init_set_ui(R,I) \
( CGALRS_dyadic_init(R), CGALRS_dyadic_set_ui((R), (I)) )
#define CGALRS_dyadic_init_set_fr(R,F) \
( CGALRS_dyadic_init(R), CGALRS_dyadic_set_fr((R), (F)) )
#define CGALRS_dyadic_get_fr(M,D) mpfr_set(M,D,GMP_RNDN)
#define CGALRS_dyadic_get_d(D,RM) mpfr_get_d(D,RM)
inline void CGALRS_dyadic_get_exactfr(mpfr_ptr rop,CGALRS_dyadic_srcptr op){
if(rop!=op){
CGALRS_dyadic_set_prec(rop,mpfr_get_prec(op));
mpfr_set(rop,op,GMP_RNDN);
CGAL_assertion(mpfr_equal_p(rop,op)!=0);
}
}
#define CGALRS_dyadic_canonicalize(D) ()
// comparison functions
#define CGALRS_dyadic_sgn(D) mpfr_sgn(D)
#define CGALRS_dyadic_zero(D) mpfr_zero_p(D)
#define CGALRS_dyadic_cmp(D,E) mpfr_cmp(D,E)
// arithmetic functions
#define CGALRS_dyadic_add(R,D,E) CGALRS_dyadic_ll_add(R,D,E,0)
#define CGALRS_dyadic_sub(R,D,E) CGALRS_dyadic_ll_sub(R,D,E,0)
#define CGALRS_dyadic_mul(R,D,E) CGALRS_dyadic_ll_mul(R,D,E,0)
inline void CGALRS_dyadic_neg(CGALRS_dyadic_ptr rop,CGALRS_dyadic_srcptr op){
if(rop!=op)
CGALRS_dyadic_set_prec(rop,mpfr_get_prec(op));
mpfr_neg(rop,op,GMP_RNDN);
CGAL_assertion(
rop==op||
(!mpfr_cmpabs(rop,op)&&
((CGALRS_dyadic_zero(op)&&CGALRS_dyadic_zero(rop))||
(CGALRS_dyadic_sgn(op)!=CGALRS_dyadic_sgn(rop)))));
}
// low-level addition:
// add op1 and op2 and reserve b bits for future lowlevel operations
inline void CGALRS_dyadic_ll_add(CGALRS_dyadic_ptr rop,
CGALRS_dyadic_srcptr op1,
CGALRS_dyadic_srcptr op2,
mp_prec_t b){
mp_exp_t l,r,temp1,temp2;
mp_prec_t rop_prec;
if(mpfr_zero_p(op1)){
if(rop!=op2)
CGALRS_dyadic_set(rop,op2);
return;
}
if(mpfr_zero_p(op2)){
if(rop!=op1)
CGALRS_dyadic_set(rop,op1);
return;
}
l=mpfr_get_exp(op1)>mpfr_get_exp(op2)?
mpfr_get_exp(op1):
mpfr_get_exp(op2);
temp1=mpfr_get_exp(op1)-(mp_exp_t)mpfr_get_prec(op1);
temp2=mpfr_get_exp(op2)-(mp_exp_t)mpfr_get_prec(op2);
r=temp1>temp2?temp2:temp1;
CGAL_assertion(l>r);
rop_prec=b+1+(mp_prec_t)(l-r);
CGAL_assertion(rop_prec>=mpfr_get_prec(op1)&&
rop_prec>=mpfr_get_prec(op2));
if(rop==op1||rop==op2)
CGALRS_dyadic_prec_round(rop,rop_prec);
else
CGALRS_dyadic_set_prec(rop,rop_prec);
CGAL_assertion_code(int round=)
mpfr_add(rop,op1,op2,GMP_RNDN);
CGAL_assertion(!round);
}
inline void CGALRS_dyadic_add_z(CGALRS_dyadic_ptr rop,
CGALRS_dyadic_srcptr op1,
mpz_srcptr z){
mp_exp_t l,r;
mp_prec_t rop_prec;
if(mpfr_zero_p(op1)){
CGALRS_dyadic_set_z(rop,z);
return;
}
if(!mpz_sgn(z)){
if(rop!=op1)
CGALRS_dyadic_set(rop,op1);
return;
}
l=mpfr_get_exp(op1)>(mp_exp_t)mpz_sizeinbase(z,2)?
mpfr_get_exp(op1):
mpz_sizeinbase(z,2);
r=mpfr_get_exp(op1)-(mp_exp_t)mpfr_get_prec(op1)<0?
mpfr_get_exp(op1)-(mp_exp_t)mpfr_get_prec(op1):
0;
CGAL_assertion(l>r);
rop_prec=1+(mp_prec_t)(l-r);
CGAL_assertion(rop_prec>=mpfr_get_prec(op1)&&
rop_prec>=(mp_prec_t)mpz_sizeinbase(z,2));
if(rop==op1)
CGALRS_dyadic_prec_round(rop,rop_prec);
else
CGALRS_dyadic_set_prec(rop,rop_prec);
CGAL_assertion_code(int round=)
mpfr_add_z(rop,op1,z,GMP_RNDN);
CGAL_assertion(!round);
}
// low-level subtraction:
// subtract op2 to op1 and reserve b bits for future lowlevel operations
inline void CGALRS_dyadic_ll_sub(CGALRS_dyadic_ptr rop,
CGALRS_dyadic_srcptr op1,
CGALRS_dyadic_srcptr op2,
mp_prec_t b){
mp_exp_t l,r,temp1,temp2;
mp_prec_t rop_prec;
if(mpfr_zero_p(op1)){
CGALRS_dyadic_neg(rop,op2);
return;
}
if(mpfr_zero_p(op2)){
if(rop!=op1)
CGALRS_dyadic_set(rop,op1);
return;
}
l=mpfr_get_exp(op1)>mpfr_get_exp(op2)?
mpfr_get_exp(op1):
mpfr_get_exp(op2);
temp1=mpfr_get_exp(op1)-(mp_exp_t)mpfr_get_prec(op1);
temp2=mpfr_get_exp(op2)-(mp_exp_t)mpfr_get_prec(op2);
r=temp1>temp2?temp2:temp1;
CGAL_assertion(l>r);
rop_prec=b+1+(mp_prec_t)(l-r);
CGAL_assertion(rop_prec>=mpfr_get_prec(op1)&&
rop_prec>=mpfr_get_prec(op2));
if(rop==op1||rop==op2)
CGALRS_dyadic_prec_round(rop,rop_prec);
else
CGALRS_dyadic_set_prec(rop,rop_prec);
CGAL_assertion_code(int round=)
mpfr_sub(rop,op1,op2,GMP_RNDN);
CGAL_assertion(!round);
}
// low-level multiplication:
// multiply op1 and op2 and reserve b bits for future lowlevel operations
inline void CGALRS_dyadic_ll_mul(CGALRS_dyadic_ptr rop,
CGALRS_dyadic_srcptr op1,
CGALRS_dyadic_srcptr op2,
mp_prec_t b){
if(rop==op1||rop==op2)
CGALRS_dyadic_prec_round(rop,b+mpfr_get_prec(op1)+mpfr_get_prec(op2));
else
CGALRS_dyadic_set_prec(rop,b+mpfr_get_prec(op1)+mpfr_get_prec(op2));
CGAL_assertion_code(int round=)
mpfr_mul(rop,op1,op2,GMP_RNDN);
CGAL_assertion(!round);
}
inline void CGALRS_dyadic_mul_z(CGALRS_dyadic_ptr rop,
CGALRS_dyadic_srcptr op1,
mpz_srcptr z){
if(rop==op1)
CGALRS_dyadic_prec_round(
rop,
mpfr_get_prec(op1)+mpz_sizeinbase(z,2));
else
CGALRS_dyadic_set_prec(
rop,
mpfr_get_prec(op1)+mpz_sizeinbase(z,2));
CGAL_assertion_code(int round=)
mpfr_mul_z(rop,op1,z,GMP_RNDN);
CGAL_assertion(!round);
}
inline void CGALRS_dyadic_mul_si(CGALRS_dyadic_ptr rop,
CGALRS_dyadic_srcptr op1,
long s){
if(rop==op1)
CGALRS_dyadic_prec_round(rop,mpfr_get_prec(op1)+sizeof(long));
else
CGALRS_dyadic_set_prec(rop,mpfr_get_prec(op1)+sizeof(long));
CGAL_assertion_code(int round=)
mpfr_mul_si(rop,op1,s,GMP_RNDN);
CGAL_assertion(!round);
}
inline void CGALRS_dyadic_mul_ui(CGALRS_dyadic_ptr rop,
CGALRS_dyadic_srcptr op1,
unsigned long u){
if(rop==op1)
CGALRS_dyadic_prec_round(
rop,
mpfr_get_prec(op1)+sizeof(unsigned long));
else
CGALRS_dyadic_set_prec(
rop,
mpfr_get_prec(op1)+sizeof(unsigned long));
CGAL_assertion_code(int round=)
mpfr_mul_ui(rop,op1,u,GMP_RNDN);
CGAL_assertion(!round);
}
inline void CGALRS_dyadic_pow_ui(CGALRS_dyadic_ptr rop,
CGALRS_dyadic_srcptr op1,
unsigned long u){
if(!u){
CGAL_assertion_msg(!mpfr_zero_p(op1),"0^0");
CGALRS_dyadic_set_ui(rop,1);
return;
}
if(u==1){
if(rop!=op1)
CGALRS_dyadic_set(rop,op1);
return;
}
if(mpfr_zero_p(op1)){
CGAL_assertion_msg(u!=0,"0^0");
CGALRS_dyadic_set_ui(rop,0);
return;
}
if(!mpfr_cmp_ui(op1,1)){
if(rop!=op1)
CGALRS_dyadic_set(rop,op1);
return;
}
if(rop==op1)
CGALRS_dyadic_prec_round(rop,u*mpfr_get_prec(op1));
else
CGALRS_dyadic_set_prec(rop,u*mpfr_get_prec(op1));
CGAL_assertion_code(int round=)
mpfr_pow_ui(rop,op1,u,GMP_RNDN);
CGAL_assertion(!round);
}
inline void CGALRS_dyadic_addmul(CGALRS_dyadic_ptr rop,
CGALRS_dyadic_srcptr op1,
CGALRS_dyadic_srcptr op2){
CGALRS_dyadic_t temp;
CGALRS_dyadic_init(temp);
CGALRS_dyadic_mul(temp,op1,op2);
CGALRS_dyadic_add(rop,rop,temp);
CGALRS_dyadic_clear(temp);
}
inline void CGALRS_dyadic_addmul_si(CGALRS_dyadic_ptr rop,
CGALRS_dyadic_srcptr op1,
long op2){
CGALRS_dyadic_t temp;
CGALRS_dyadic_init(temp);
CGALRS_dyadic_mul_si(temp,op1,op2);
CGALRS_dyadic_add(rop,rop,temp);
CGALRS_dyadic_clear(temp);
}
inline void CGALRS_dyadic_addmul_ui(CGALRS_dyadic_ptr rop,
CGALRS_dyadic_srcptr op1,
unsigned long u){
//CGALRS_dyadic_t temp;
//CGALRS_dyadic_init(temp);
//CGALRS_dyadic_mul_ui(temp,op1,u);
//CGALRS_dyadic_add(rop,rop,temp);
//CGALRS_dyadic_clear(temp);
CGALRS_dyadic_t temp;
mp_exp_t l,r,temp1,temp2;
mp_prec_t rop_prec;
if(u==0||mpfr_zero_p(op1))
return;
if(u==1){
CGALRS_dyadic_add(rop,rop,op1);
return;
}
// TODO: if(op1==1)
// calculate temp=op1*u
mpfr_init2(temp,mpfr_get_prec(op1)+sizeof(unsigned int));
CGAL_assertion_code(int round1=)
mpfr_mul_ui(temp,op1,u,GMP_RNDN);
CGAL_assertion(!round1);
// calculate the precision needed for rop
l=mpfr_get_exp(op1)>0?mpfr_get_exp(op1):0;
temp1=mpfr_get_exp(op1)-(mp_exp_t)mpfr_get_prec(op1);
temp2=sizeof(unsigned long);
r=temp1>temp2?temp2:temp1;
CGAL_assertion(l>r);
rop_prec=sizeof(unsigned long)+1+(mp_prec_t)(l-r);
CGAL_assertion(rop_prec>=mpfr_get_prec(op1)&&
rop_prec>=mpfr_get_prec(rop));
// set precision and add
CGALRS_dyadic_prec_round(rop,rop_prec);
CGAL_assertion_code(int round2=)
mpfr_add(rop,rop,temp,GMP_RNDN);
CGAL_assertion(!round2);
}
inline void CGALRS_dyadic_mul_2exp(CGALRS_dyadic_ptr rop,
CGALRS_dyadic_srcptr op1,
unsigned long ui){
// mpfr_mul_2ui does change the mantissa!
if(rop==op1)
CGALRS_dyadic_prec_round(
rop,
sizeof(unsigned long)+mpfr_get_prec(op1));
else
CGALRS_dyadic_set_prec(
rop,
sizeof(unsigned long)+mpfr_get_prec(op1));
CGAL_assertion_code(int round=)
mpfr_mul_2ui(rop,op1,ui,GMP_RNDN);
CGAL_assertion(!round);
}
inline void CGALRS_dyadic_div_2exp(CGALRS_dyadic_ptr rop,
CGALRS_dyadic_srcptr op1,
unsigned long ui){
// mpfr_div_2ui does not change the mantissa... am I sure?
CGAL_assertion_code(int round=)
mpfr_div_2ui(rop,op1,ui,GMP_RNDN);
CGAL_assertion(!round);
}
// miscellaneous functions
#define CGALRS_dyadic_midpoint(R,D,E) \
( CGALRS_dyadic_ll_add(R,D,E,1) , mpfr_div_2ui(R,R,1,GMP_RNDN) )
#define CGALRS_dyadic_swap(D,E) mpfr_swap(D,E)
// I/O functions
#define CGALRS_dyadic_out_str(F,D) mpfr_out_str(F,10,0,D,GMP_RNDN)
#ifdef __cplusplus
inline std::ostream& operator<<(std::ostream &s,CGALRS_dyadic_srcptr op){
mp_exp_t exponent;
mpz_t mantissa;
mpz_init(mantissa);
exponent=mpfr_get_z_exp(mantissa,op);
s<<"["<<mantissa<<","<<exponent<<"]";
return s;
}
#endif
#endif // CGAL_RS_DYADIC_H

View File

@ -1,52 +0,0 @@
// Copyright (c) 2006-2013 INRIA Nancy-Grand Est (France). All rights reserved.
//
// This file is part of CGAL (www.cgal.org)
//
// $URL$
// $Id$
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author: Luis Peñaranda <luis.penaranda@gmx.com>
#ifndef CGAL_RS_EXACT_SIGNAT_1_H
#define CGAL_RS_EXACT_SIGNAT_1_H
#include <CGAL/Polynomial_traits_d.h>
#include "dyadic.h"
namespace CGAL{
namespace RS_AK1{
template <class Polynomial_,class Bound_>
struct ExactSignat_1{
typedef Polynomial_ Polynomial;
typedef Bound_ Bound;
typedef CGAL::Polynomial_traits_d<Polynomial> PT;
typedef typename PT::Degree Degree;
Polynomial pol;
ExactSignat_1(const Polynomial &p):pol(p){};
CGAL::Sign operator()(const Bound&)const;
}; // struct ExactSignat_1
template <>
inline CGAL::Sign
ExactSignat_1<Polynomial<Gmpz>,Gmpfr>::operator()(const Gmpfr &x)const{
int d=Degree()(pol);
if(d==0)
return pol[0].sign();
// Construct a Gmpfr containing exactly the leading coefficient.
Gmpfr h(pol[d],pol[d].bit_size());
CGAL_assertion(h==pol[d]);
// Horner's evaluation.
for(int i=1;i<d;++i){
CGALRS_dyadic_mul(h.fr(),h.fr(),x.fr());
CGALRS_dyadic_add_z(h.fr(),h.fr(),pol[d-i].mpz());
}
// TODO: We can avoid doing the last addition.
return h.sign();
}
} // namespace RS_AK1
} // namespace CGAL
#endif // CGAL_RS_EXACT_SIGNAT_1_H

View File

@ -1,648 +0,0 @@
// Copyright (c) 2006-2013 INRIA Nancy-Grand Est (France). All rights reserved.
//
// This file is part of CGAL (www.cgal.org)
//
// $URL$
// $Id$
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author: Luis Peñaranda <luis.penaranda@gmx.com>
#ifndef CGAL_RS_FUNCTORS_1_H
#define CGAL_RS_FUNCTORS_1_H
#include <vector>
#include <CGAL/Gmpfi.h>
namespace CGAL{
namespace RS_AK1{
template <class Polynomial_,
class Algebraic_,
class Bound_,
class Coefficient_,
class Isolator_>
struct Construct_algebraic_real_1{
typedef Polynomial_ Polynomial;
typedef Algebraic_ Algebraic;
typedef Bound_ Bound;
typedef Coefficient_ Coefficient;
typedef Isolator_ Isolator;
typedef Algebraic result_type;
template <class T>
Algebraic operator()(const T &a)const{
return Algebraic(a);
}
Algebraic operator()(const Polynomial &p,size_t i)const{
Isolator isol(p);
return Algebraic(p,isol.left_bound(i),isol.right_bound(i));
}
Algebraic operator()(const Polynomial &p,
const Bound &l,
const Bound &r)const{
return Algebraic(p,l,r);
}
}; // struct Construct_algebraic_1
template <class Polynomial_,class Algebraic_>
struct Compute_polynomial_1:
public CGAL::cpp98::unary_function<Algebraic_,Polynomial_>{
typedef Polynomial_ Polynomial;
typedef Algebraic_ Algebraic;
Polynomial operator()(const Algebraic &x)const{
return x.get_pol();
}
}; // struct Compute_polynomial_1
template <class Polynomial_,class Ptraits_>
struct Is_coprime_1:
public CGAL::cpp98::binary_function<Polynomial_,Polynomial_,bool>{
typedef Polynomial_ Polynomial;
typedef Ptraits_ Ptraits;
typedef typename Ptraits::Gcd_up_to_constant_factor Gcd;
typedef typename Ptraits::Degree Degree;
inline bool operator()(const Polynomial &p1,const Polynomial &p2)const{
return Degree()(Gcd()(p1,p2))==0;
}
}; // struct Is_coprime_1
template <class Polynomial_,class Ptraits_>
struct Make_coprime_1{
typedef Polynomial_ Polynomial;
typedef Ptraits_ Ptraits;
typedef typename Ptraits::Gcd_up_to_constant_factor Gcd;
typedef typename Ptraits::Degree Degree;
typedef typename Ptraits::Integral_division_up_to_constant_factor
IDiv;
bool operator()(const Polynomial &p1,
const Polynomial &p2,
Polynomial &g,
Polynomial &q1,
Polynomial &q2)const{
g=Gcd()(p1,p2);
q1=IDiv()(p1,g);
q2=IDiv()(p2,g);
return Degree()(Gcd()(p1,p2))==0;
}
}; // struct Make_coprime_1
template <class Polynomial_,
class Bound_,
class Algebraic_,
class Isolator_,
class Signat_,
class Ptraits_>
struct Solve_1{
typedef Polynomial_ Polynomial_1;
typedef Bound_ Bound;
typedef Algebraic_ Algebraic;
typedef Isolator_ Isolator;
typedef Signat_ Signat;
typedef Ptraits_ Ptraits;
typedef typename Ptraits::Gcd_up_to_constant_factor Gcd;
typedef typename Ptraits::Square_free_factorize_up_to_constant_factor
Sqfr;
typedef typename Ptraits::Degree Degree;
typedef typename Ptraits::Make_square_free Sfpart;
template <class OutputIterator>
OutputIterator operator()(const Polynomial_1 &p,
OutputIterator res)const{
typedef std::pair<Polynomial_1,int> polmult;
typedef std::vector<polmult> sqvec;
Polynomial_1 sfp=Sfpart()(p);
sqvec sfv;
Sqfr()(p,std::back_inserter(sfv));
Isolator isol(sfp);
int *m=(int*)calloc(isol.number_of_real_roots(),sizeof(int));
for(typename sqvec::iterator i=sfv.begin();i!=sfv.end();++i){
int k=Degree()(i->first);
Signat signof(i->first);
for(int j=0;k&&j<isol.number_of_real_roots();++j){
if(!m[j]){
CGAL::Sign sg_l=
signof(isol.left_bound(j));
CGAL::Sign sg_r=
signof(isol.right_bound(j));
if((sg_l!=sg_r)||
((sg_l==CGAL::ZERO)&&
(sg_r==CGAL::ZERO))){
m[j]=i->second;
--k;
}
}
}
}
for(int l=0;l<isol.number_of_real_roots();++l)
*res++=std::make_pair(Algebraic(p,
isol.left_bound(l),
isol.right_bound(l)),
m[l]);
free(m);
return res;
}
template <class OutputIterator>
OutputIterator operator()(const Polynomial_1 &p,
bool,
OutputIterator res)const{
Isolator isol(p);
for(int l=0;l<isol.number_of_real_roots();++l)
*res++=Algebraic(p,
isol.left_bound(l),
isol.right_bound(l));
return res;
}
template <class OutputIterator>
OutputIterator operator()(const Polynomial_1 &p,
const Bound &l,
const Bound &u,
OutputIterator res)const{
typedef std::vector<Algebraic> RV;
typedef std::pair<Polynomial_1,int> PM;
typedef std::vector<PM> PMV;
typedef typename PMV::iterator PMVI;
CGAL_precondition_msg(l<=u,
"left bound must be <= right bound");
RV roots; // all roots of the polynomial
this->operator()(p,false,std::back_inserter(roots));
size_t nb_roots=roots.size();
// indices of the first and last roots to be reported:
size_t index_l=0,index_u;
while(index_l<nb_roots&&roots[index_l]<l)
++index_l;
CGAL_assertion(index_l<=nb_roots);
if(index_l==nb_roots)
return res;
index_u=index_l;
while(index_u<nb_roots&&roots[index_u]<u)
++index_u;
CGAL_assertion(index_u<=nb_roots);
if(index_u==index_l)
return res;
// now, we have to return roots in [index_l,index_u)
PMV sfv;
Sqfr()(p,std::back_inserter(sfv)); // square-free fact. of p
// array to store the multiplicities
int *m=(int*)calloc(nb_roots,sizeof(int));
// we iterate over all the pairs <root,mult> and match the
// roots in the interval [index_l,index_u)
for(PMVI i=sfv.begin();i!=sfv.end();++i){
int k=Degree()(i->first);
Signat signof(i->first);
for(size_t j=index_l;k&&j<index_u;++j){
if(!m[j]){
CGAL::Sign sg_l=
signof(roots[j].get_left());
CGAL::Sign sg_r=
signof(roots[j].get_right());
if((sg_l!=sg_r)||
((sg_l==CGAL::ZERO)&&
(sg_r==CGAL::ZERO))){
m[j]=i->second;
--k;
}
}
}
}
for(size_t l=index_l;l<index_u;++l)
*res++=std::make_pair(roots[l],m[l]);
free(m);
return res;
}
template <class OutputIterator>
OutputIterator operator()(const Polynomial_1 &p,
bool known_to_be_square_free,
const Bound &l,
const Bound &u,
OutputIterator res)const{
typedef std::vector<Algebraic> RV;
typedef typename RV::iterator RVI;
CGAL_precondition_msg(l<=u,
"left bound must be <= right bound");
RV roots;
this->operator()(p,
known_to_be_square_free,
std::back_inserter(roots));
for(RVI it=roots.begin();it!=roots.end();it++)
if(*it>=l&&*it<=u)
*res++=*it;
return res;
}
}; // struct Solve_1
template <class Polynomial_,
class Bound_,
class Algebraic_,
class Refiner_,
class Signat_,
class Ptraits_>
class Sign_at_1:
public CGAL::cpp98::binary_function<Polynomial_,Algebraic_,CGAL::Sign>{
// This implementation will work with any polynomial type whose
// coefficient type is explicit interoperable with Gmpfi.
// TODO: Make this function generic.
public:
typedef Polynomial_ Polynomial_1;
typedef Bound_ Bound;
typedef Algebraic_ Algebraic;
typedef Refiner_ Refiner;
typedef Signat_ Signat;
typedef Ptraits_ Ptraits;
private:
CGAL::Uncertain<CGAL::Sign> eval_interv(const Polynomial_1 &p,
const Bound &l,
const Bound &r)const{
typedef typename Ptraits::Substitute Subst;
std::vector<CGAL::Gmpfi> substitutions;
substitutions.push_back(CGAL::Gmpfi(l,r));
CGAL::Gmpfi eval=Subst()(p,
substitutions.begin(),
substitutions.end());
return eval.sign();
}
// This function assumes that the sign of the evaluation is not zero,
// it just refines x until having the correct sign.
CGAL::Sign refine_and_return(const Polynomial_1 &p,Algebraic x)const{
CGAL::Gmpfr xl(x.get_left());
CGAL::Gmpfr xr(x.get_right());
CGAL::Uncertain<CGAL::Sign> s;
for(;;){
Refiner()(x.get_pol(),
xl,
xr,
2*CGAL::max(xl.get_precision(),
xr.get_precision()));
s=eval_interv(p,xl,xr);
if(!s.is_same(Uncertain<CGAL::Sign>::indeterminate())){
x.set_left(xl);
x.set_right(xr);
return s;
}
}
}
public:
CGAL::Sign operator()(const Polynomial_1 &p,Algebraic x)const{
typedef typename Ptraits::Gcd_up_to_constant_factor Gcd;
typedef typename Ptraits::Make_square_free Sfpart;
typedef typename Ptraits::Degree Degree;
typedef typename Ptraits::Differentiate Deriv;
CGAL::Uncertain<CGAL::Sign> unknown=
Uncertain<CGAL::Sign>::indeterminate();
CGAL::Uncertain<CGAL::Sign> s=eval_interv(p,
x.get_left(),
x.get_right());
if(!s.is_same(unknown))
return s;
// We are not sure about the sign. We calculate the gcd in
// order to know if both polynomials have common roots.
Polynomial_1 sfpp=Sfpart()(p);
Polynomial_1 gcd=Gcd()(sfpp,Sfpart()(x.get_pol()));
if(Degree()(gcd)==0)
return refine_and_return(p,x);
// At this point, gcd is not 1; we proceed as follows:
// -we refine x until having p monotonic in x's interval (to be
// sure that p has at most one root on that interval),
// -if the gcd has a root on this interval, both roots are
// equal (we return 0), otherwise, we refine until having a
// result.
// How to assure that p is monotonic in an interval: when its
// derivative is never zero in that interval.
Polynomial_1 dsfpp=Deriv()(sfpp);
CGAL::Gmpfr xl(x.get_left());
CGAL::Gmpfr xr(x.get_right());
while(eval_interv(dsfpp,xl,xr).is_same(unknown)){
Refiner()(x.get_pol(),
xl,
xr,
2*CGAL::max(xl.get_precision(),
xr.get_precision()));
}
x.set_left(xl);
x.set_right(xr);
// How to know that the gcd has a root: evaluate endpoints.
CGAL::Sign sleft,sright;
Signat sign_at_gcd(gcd);
if((sleft=sign_at_gcd(x.get_left()))==CGAL::ZERO||
(sright=sign_at_gcd(x.get_right()))==CGAL::ZERO||
(sleft!=sright))
return CGAL::ZERO;
return refine_and_return(p,x);
}
}; // struct Sign_at_1
template <class Polynomial_,
class Bound_,
class Algebraic_,
class Refiner_,
class Signat_,
class Ptraits_>
class Is_zero_at_1:
public CGAL::cpp98::binary_function<Polynomial_,Algebraic_,bool>{
// This implementation will work with any polynomial type whose
// coefficient type is explicit interoperable with Gmpfi.
// TODO: Make this function generic.
public:
typedef Polynomial_ Polynomial_1;
typedef Bound_ Bound;
typedef Algebraic_ Algebraic;
typedef Refiner_ Refiner;
typedef Signat_ Signat;
typedef Ptraits_ Ptraits;
private:
CGAL::Uncertain<CGAL::Sign> eval_interv(const Polynomial_1 &p,
const Bound &l,
const Bound &r)const{
typedef typename Ptraits::Substitute Subst;
std::vector<CGAL::Gmpfi> substitutions;
substitutions.push_back(CGAL::Gmpfi(l,r));
CGAL::Gmpfi eval=Subst()(p,
substitutions.begin(),
substitutions.end());
return eval.sign();
}
public:
bool operator()(const Polynomial_1 &p,Algebraic x)const{
typedef typename Ptraits::Gcd_up_to_constant_factor Gcd;
typedef typename Ptraits::Make_square_free Sfpart;
typedef typename Ptraits::Degree Degree;
typedef typename Ptraits::Differentiate Deriv;
CGAL::Uncertain<CGAL::Sign> unknown=
Uncertain<CGAL::Sign>::indeterminate();
CGAL::Uncertain<CGAL::Sign> s=eval_interv(p,
x.get_left(),
x.get_right());
if(!s.is_same(unknown))
return (s==CGAL::ZERO);
// We are not sure about the sign. We calculate the gcd in
// order to know if both polynomials have common roots.
Polynomial_1 sfpp=Sfpart()(p);
Polynomial_1 gcd=Gcd()(sfpp,Sfpart()(x.get_pol()));
if(Degree()(gcd)==0)
return false;
// At this point, gcd is not 1; we proceed as follows:
// -we refine x until having p monotonic in x's interval (to be
// sure that p has at most one root on that interval),
// -if the gcd has a root on this interval, both roots are
// equal (we return 0), otherwise, we refine until having a
// result.
// How to assure that p is monotonic in an interval: when its
// derivative is never zero in that interval.
Polynomial_1 dsfpp=Deriv()(sfpp);
CGAL::Gmpfr xl(x.get_left());
CGAL::Gmpfr xr(x.get_right());
while(eval_interv(dsfpp,xl,xr).is_same(unknown)){
Refiner()(x.get_pol(),
xl,
xr,
2*CGAL::max(xl.get_precision(),
xr.get_precision()));
}
x.set_left(xl);
x.set_right(xr);
// How to know that the gcd has a root: evaluate endpoints.
CGAL::Sign sleft,sright;
Signat sign_at_gcd(gcd);
return((sleft=sign_at_gcd(x.get_left()))==CGAL::ZERO||
(sright=sign_at_gcd(x.get_right()))==CGAL::ZERO||
(sleft!=sright));
}
}; // class Is_zero_at_1
// TODO: it says in the manual that this should return a size_type, but test
// programs assume that this is equal to int
template <class Polynomial_,class Isolator_>
struct Number_of_solutions_1:
public CGAL::cpp98::unary_function<Polynomial_,int>{
typedef Polynomial_ Polynomial_1;
typedef Isolator_ Isolator;
size_t operator()(const Polynomial_1 &p)const{
// TODO: make sure that p is square free (precondition)
Isolator isol(p);
return isol.number_of_real_roots();
}
}; // struct Number_of_solutions_1
// This functor not only compares two algebraic numbers. In case they are
// different, it refines them until they do not overlap.
template <class Algebraic_,
class Bound_,
class Comparator_>
struct Compare_1:
public CGAL::cpp98::binary_function<Algebraic_,Algebraic_,CGAL::Comparison_result>{
typedef Algebraic_ Algebraic;
typedef Bound_ Bound;
typedef Comparator_ Comparator;
CGAL::Comparison_result operator()(Algebraic a,Algebraic b)const{
Bound al=a.get_left();
Bound ar=a.get_right();
Bound bl=b.get_left();
Bound br=b.get_right();
CGAL::Comparison_result c=Comparator()(a.get_pol(),al,ar,
b.get_pol(),bl,br);
a.set_left(al);
a.set_right(ar);
b.set_left(bl);
b.set_right(br);
return c;
}
CGAL::Comparison_result operator()(Algebraic a,const Bound &b)const{
Bound al=a.get_left();
Bound ar=a.get_right();
Algebraic balg(b);
CGAL::Comparison_result c=Comparator()(a.get_pol(),al,ar,
balg.get_pol(),b,b);
a.set_left(al);
a.set_right(ar);
return c;
}
template <class T>
CGAL::Comparison_result operator()(Algebraic a,const T &b)const{
Bound al=a.get_left();
Bound ar=a.get_right();
Algebraic balg(b);
CGAL::Comparison_result c=Comparator()(a.get_pol(),
al,
ar,
balg.get_pol(),
balg.get_left(),
balg.get_right());
a.set_left(al);
a.set_right(ar);
return c;
}
}; // class Compare_1
template <class Algebraic_,
class Bound_,
class Comparator_>
struct Bound_between_1:
public CGAL::cpp98::binary_function<Algebraic_,Algebraic_,Bound_>{
typedef Algebraic_ Algebraic;
typedef Bound_ Bound;
typedef Comparator_ Comparator;
Bound operator()(Algebraic a,Algebraic b)const{
typedef Compare_1<Algebraic,Bound,Comparator> Compare;
typename Bound::Precision_type prec;
switch(Compare()(a,b)){
case CGAL::LARGER:
CGAL_assertion(b.get_right()<a.get_left());
prec=CGAL::max(b.get_right().get_precision(),
a.get_left().get_precision());
return Bound::add(b.get_right(),
a.get_left(),
1+prec)/2;
break;
case CGAL::SMALLER:
CGAL_assertion(a.get_right()<b.get_left());
prec=CGAL::max(a.get_right().get_precision(),
b.get_left().get_precision());
return Bound::add(a.get_right(),
b.get_left(),
1+prec)/2;
break;
default:
CGAL_error_msg(
"bound between two equal numbers");
}
}
}; // struct Bound_between_1
template <class Polynomial_,
class Bound_,
class Algebraic_,
class Isolator_,
class Comparator_,
class Signat_,
class Ptraits_>
struct Isolate_1:
public CGAL::cpp98::binary_function<Algebraic_,Polynomial_,std::pair<Bound_,Bound_> >{
typedef Polynomial_ Polynomial_1;
typedef Bound_ Bound;
typedef Algebraic_ Algebraic;
typedef Isolator_ Isolator;
typedef Comparator_ Comparator;
typedef Signat_ Signat;
typedef Ptraits_ Ptraits;
std::pair<Bound,Bound>
operator()(const Algebraic &a,const Polynomial_1 &p)const{
std::vector<Algebraic> roots;
std::back_insert_iterator<std::vector<Algebraic> > rit(roots);
typedef Solve_1<Polynomial_1,
Bound,
Algebraic,
Isolator,
Signat,
Ptraits> Solve;
typedef Compare_1<Algebraic,Bound,Comparator> Compare;
Solve()(p,false,rit);
for(typename std::vector<Algebraic>::size_type i=0;
i<roots.size();
++i){
// we use the comparison functor, that makes both
// intervals disjoint iff the algebraic numbers they
// represent are not equal
Compare()(a,roots[i]);
}
return std::make_pair(a.left(),a.right());
}
}; // Isolate_1
template <class Polynomial_,
class Bound_,
class Algebraic_,
class Refiner_>
struct Approximate_absolute_1:
public CGAL::cpp98::binary_function<Algebraic_,int,std::pair<Bound_,Bound_> >{
typedef Polynomial_ Polynomial_1;
typedef Bound_ Bound;
typedef Algebraic_ Algebraic;
typedef Refiner_ Refiner;
// This implementation assumes that Bound is Gmpfr.
// TODO: make generic.
std::pair<Bound,Bound> operator()(const Algebraic &x,const int &a)const{
Bound xl(x.get_left()),xr(x.get_right());
// refsteps=log2(xl-xr)
mpfr_t temp;
mpfr_init(temp);
mpfr_sub(temp,xr.fr(),xl.fr(),GMP_RNDU);
mpfr_log2(temp,temp,GMP_RNDU);
long refsteps=mpfr_get_si(temp,GMP_RNDU);
mpfr_clear(temp);
Refiner()(x.get_pol(),xl,xr,CGAL::abs(refsteps+a));
x.set_left(xl);
x.set_right(xr);
CGAL_assertion(a>0?
(xr-xl)*CGAL::ipower(Bound(2),a)<=Bound(1):
(xr-xl)<=CGAL::ipower(Bound(2),-a));
return std::make_pair(xl,xr);
}
}; // struct Approximate_absolute_1
template <class Polynomial_,
class Bound_,
class Algebraic_,
class Refiner_>
struct Approximate_relative_1:
public CGAL::cpp98::binary_function<Algebraic_,int,std::pair<Bound_,Bound_> >{
typedef Polynomial_ Polynomial_1;
typedef Bound_ Bound;
typedef Algebraic_ Algebraic;
typedef Refiner_ Refiner;
std::pair<Bound,Bound> operator()(const Algebraic &x,const int &a)const{
if(CGAL::is_zero(x))
return std::make_pair(Bound(0),Bound(0));
Bound error=CGAL::ipower(Bound(2),CGAL::abs(a));
Bound xl(x.get_left()),xr(x.get_right());
Bound max_b=(CGAL::max)(CGAL::abs(xr),CGAL::abs(xl));
while(a>0?(xr-xl)*error>max_b:(xr-xl)>error*max_b){
Refiner()(x.get_pol(),
xl,
xr,
std::max<unsigned>(
CGAL::abs(a),
CGAL::max(xl.get_precision(),
xr.get_precision())));
max_b=(CGAL::max)(CGAL::abs(xr),CGAL::abs(xl));
}
x.set_left(xl);
x.set_right(xr);
CGAL_assertion(
a>0?
(xr-xl)*CGAL::ipower(Bound(2),a)<=max_b:
(xr-xl)<=CGAL::ipower(Bound(2),-a)*max_b);
return std::make_pair(xl,xr);
}
}; // struct Approximate_relative_1
} // namespace RS_AK1
} // namespace CGAL
#endif // CGAL_RS_FUNCTORS_1_H

View File

@ -1,699 +0,0 @@
// Copyright (c) 2006-2013 INRIA Nancy-Grand Est (France). All rights reserved.
//
// This file is part of CGAL (www.cgal.org)
//
// $URL$
// $Id$
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author: Luis Peñaranda <luis.penaranda@gmx.com>
#ifndef CGAL_RS_FUNCTORS_Z_1_H
#define CGAL_RS_FUNCTORS_Z_1_H
#include <vector>
#include <CGAL/Gmpfi.h>
namespace CGAL{
namespace RS_AK1{
template <class Polynomial_,
class ZPolynomial_,
class PolConverter_,
class Algebraic_,
class Bound_,
class Coefficient_,
class Isolator_>
struct Construct_algebraic_real_z_1{
typedef Polynomial_ Polynomial;
typedef ZPolynomial_ ZPolynomial;
typedef PolConverter_ PolConverter;
typedef Algebraic_ Algebraic;
typedef Bound_ Bound;
typedef Coefficient_ Coefficient;
typedef Isolator_ Isolator;
typedef Algebraic result_type;
template <class T>
Algebraic operator()(const T &a)const{
return Algebraic(a);
}
Algebraic operator()(const Polynomial &p,size_t i)const{
ZPolynomial zp=PolConverter()(p);
Isolator isol(zp);
return Algebraic(p,
zp,
isol.left_bound(i),
isol.right_bound(i));
}
Algebraic operator()(const Polynomial &p,
const Bound &l,
const Bound &r)const{
return Algebraic(p,PolConverter()(p),l,r);
}
}; // struct Construct_algebraic_real_z_1
template <class Polynomial_,class Algebraic_>
struct Compute_polynomial_z_1:
public CGAL::cpp98::unary_function<Algebraic_,Polynomial_>{
typedef Polynomial_ Polynomial;
typedef Algebraic_ Algebraic;
Polynomial operator()(const Algebraic &x)const{
return x.get_pol();
}
}; // struct Compute_polynomial_z_1
template <class Polynomial_,class Ptraits_>
struct Is_coprime_z_1:
public CGAL::cpp98::binary_function<Polynomial_,Polynomial_,bool>{
typedef Polynomial_ Polynomial;
typedef Ptraits_ Ptraits;
typedef typename Ptraits::Gcd_up_to_constant_factor Gcd;
typedef typename Ptraits::Degree Degree;
inline bool operator()(const Polynomial &p1,const Polynomial &p2)const{
return Degree()(Gcd()(p1,p2))==0;
}
}; // struct Is_coprime_z_1
template <class Polynomial_,class Ptraits_>
struct Make_coprime_z_1{
typedef Polynomial_ Polynomial;
typedef Ptraits_ Ptraits;
typedef typename Ptraits::Gcd_up_to_constant_factor Gcd;
typedef typename Ptraits::Degree Degree;
typedef typename Ptraits::Integral_division_up_to_constant_factor
IDiv;
bool operator()(const Polynomial &p1,
const Polynomial &p2,
Polynomial &g,
Polynomial &q1,
Polynomial &q2)const{
g=Gcd()(p1,p2);
q1=IDiv()(p1,g);
q2=IDiv()(p2,g);
return Degree()(Gcd()(p1,p2))==0;
}
}; // struct Make_coprime_z_1
template <class Polynomial_,
class ZPolynomial_,
class PolConverter_,
class Bound_,
class Algebraic_,
class Isolator_,
class Signat_,
class Ptraits_,
class ZPtraits_>
struct Solve_z_1{
typedef Polynomial_ Polynomial_1;
typedef ZPolynomial_ ZPolynomial_1;
typedef PolConverter_ PolConverter;
typedef Bound_ Bound;
typedef Algebraic_ Algebraic;
typedef Isolator_ Isolator;
typedef Signat_ ZSignat;
typedef Ptraits_ Ptraits;
typedef typename Ptraits::Gcd_up_to_constant_factor Gcd;
typedef typename Ptraits::Square_free_factorize_up_to_constant_factor
Sqfr;
typedef typename Ptraits::Degree Degree;
typedef typename Ptraits::Make_square_free Sfpart;
typedef ZPtraits_ ZPtraits;
typedef typename ZPtraits::Gcd_up_to_constant_factor ZGcd;
typedef typename ZPtraits::Square_free_factorize_up_to_constant_factor
ZSqfr;
typedef typename ZPtraits::Degree ZDegree;
typedef typename ZPtraits::Make_square_free ZSfpart;
template <class OutputIterator>
OutputIterator operator()(const Polynomial_1 &p,
OutputIterator res)const{
typedef std::pair<ZPolynomial_1,int> zpolmult;
typedef std::vector<zpolmult> zsqvec;
ZPolynomial_1 zp=PolConverter()(p);
Polynomial_1 sfp=Sfpart()(p);
ZPolynomial_1 zsfp=PolConverter()(sfp);
zsqvec zsfv;
ZSqfr()(zp,std::back_inserter(zsfv));
Isolator isol(zsfp);
int *m=(int*)calloc(isol.number_of_real_roots(),sizeof(int));
for(typename zsqvec::iterator i=zsfv.begin();i!=zsfv.end();++i){
int k=ZDegree()(i->first);
ZSignat signof(i->first);
for(int j=0;k&&j<isol.number_of_real_roots();++j){
if(!m[j]){
CGAL::Sign sg_l=
signof(isol.left_bound(j));
CGAL::Sign sg_r=
signof(isol.right_bound(j));
if((sg_l!=sg_r)||
((sg_l==CGAL::ZERO)&&
(sg_r==CGAL::ZERO))){
m[j]=i->second;
--k;
}
}
}
}
for(int l=0;l<isol.number_of_real_roots();++l)
*res++=std::make_pair(Algebraic(sfp,
zsfp,
isol.left_bound(l),
isol.right_bound(l)),
m[l]);
free(m);
return res;
}
template <class OutputIterator>
OutputIterator operator()(const Polynomial_1 &p,
bool,
OutputIterator res)const{
ZPolynomial_1 zp=PolConverter()(p);
Isolator isol(zp);
for(int l=0;l<isol.number_of_real_roots();++l)
*res++=Algebraic(p,
zp,
isol.left_bound(l),
isol.right_bound(l));
return res;
}
template <class OutputIterator>
OutputIterator operator()(const Polynomial_1 &p,
const Bound &l,
const Bound &u,
OutputIterator res)const{
typedef std::vector<Algebraic> RV;
typedef std::pair<Polynomial_1,int> PM;
typedef std::vector<PM> PMV;
typedef typename PMV::iterator PMVI;
CGAL_precondition_msg(l<=u,
"left bound must be <= right bound");
RV roots; // all roots of the polynomial
this->operator()(p,false,std::back_inserter(roots));
size_t nb_roots=roots.size();
// indices of the first and last roots to be reported:
size_t index_l=0,index_u;
while(index_l<nb_roots&&roots[index_l]<l)
++index_l;
CGAL_assertion(index_l<=nb_roots);
if(index_l==nb_roots)
return res;
index_u=index_l;
while(index_u<nb_roots&&roots[index_u]<u)
++index_u;
CGAL_assertion(index_u<=nb_roots);
if(index_u==index_l)
return res;
// now, we have to return roots in [index_l,index_u)
PMV sfv;
Sqfr()(p,std::back_inserter(sfv)); // square-free fact. of p
// array to store the multiplicities
int *m=(int*)calloc(nb_roots,sizeof(int));
// we iterate over all the pairs <root,mult> and match the
// roots in the interval [index_l,index_u)
for(PMVI i=sfv.begin();i!=sfv.end();++i){
ZPolynomial_1 zifirst=PolConverter()(i->first);
int k=ZDegree()(zifirst);
ZSignat signof(zifirst);
for(size_t j=index_l;k&&j<index_u;++j){
if(!m[j]){
CGAL::Sign sg_l=
signof(roots[j].get_left());
CGAL::Sign sg_r=
signof(roots[j].get_right());
if((sg_l!=sg_r)||
((sg_l==CGAL::ZERO)&&
(sg_r==CGAL::ZERO))){
m[j]=i->second;
--k;
}
}
}
}
for(size_t l=index_l;l<index_u;++l)
*res++=std::make_pair(roots[l],m[l]);
free(m);
return res;
}
template <class OutputIterator>
OutputIterator operator()(const Polynomial_1 &p,
bool known_to_be_square_free,
const Bound &l,
const Bound &u,
OutputIterator res)const{
typedef std::vector<Algebraic> RV;
typedef typename RV::iterator RVI;
CGAL_precondition_msg(l<=u,
"left bound must be <= right bound");
RV roots;
this->operator()(p,
known_to_be_square_free,
std::back_inserter(roots));
for(RVI it=roots.begin();it!=roots.end();it++)
if(*it>=l&&*it<=u)
*res++=*it;
return res;
}
}; // struct Solve_z_1
template <class Polynomial_,
class ZPolynomial_,
class PolConverter_,
class Bound_,
class Algebraic_,
class Refiner_,
class Signat_,
class Ptraits_,
class ZPtraits_>
class Sign_at_z_1:
public CGAL::cpp98::binary_function<Polynomial_,Algebraic_,CGAL::Sign>{
// This implementation will work with any polynomial type whose
// coefficient type is explicit interoperable with Gmpfi.
// TODO: Make this function generic.
public:
typedef Polynomial_ Polynomial_1;
typedef ZPolynomial_ ZPolynomial_1;
typedef PolConverter_ PolConverter;
typedef Bound_ Bound;
typedef Algebraic_ Algebraic;
typedef Refiner_ Refiner;
typedef Signat_ ZSignat;
typedef Ptraits_ Ptraits;
typedef ZPtraits_ ZPtraits;
private:
CGAL::Uncertain<CGAL::Sign> eval_interv(const Polynomial_1 &p,
const Bound &l,
const Bound &r)const{
typedef typename Ptraits::Substitute Subst;
std::vector<CGAL::Gmpfi> substitutions;
substitutions.push_back(CGAL::Gmpfi(l,r));
CGAL::Gmpfi eval=Subst()(p,
substitutions.begin(),
substitutions.end());
return eval.sign();
}
// This function assumes that the sign of the evaluation is not zero,
// it just refines x until having the correct sign.
CGAL::Sign refine_and_return(const Polynomial_1 &p,Algebraic x)const{
CGAL::Gmpfr xl(x.get_left());
CGAL::Gmpfr xr(x.get_right());
CGAL::Uncertain<CGAL::Sign> s;
for(;;){
Refiner()(x.get_zpol(),
xl,
xr,
2*CGAL::max(xl.get_precision(),
xr.get_precision()));
s=eval_interv(p,xl,xr);
if(!s.is_same(Uncertain<CGAL::Sign>::indeterminate())){
x.set_left(xl);
x.set_right(xr);
return s;
}
}
}
public:
CGAL::Sign operator()(const Polynomial_1 &p,Algebraic x)const{
typedef typename Ptraits::Gcd_up_to_constant_factor Gcd;
typedef typename Ptraits::Make_square_free Sfpart;
typedef typename Ptraits::Degree Degree;
typedef typename Ptraits::Differentiate Deriv;
CGAL::Uncertain<CGAL::Sign> unknown=
Uncertain<CGAL::Sign>::indeterminate();
CGAL::Uncertain<CGAL::Sign> s=eval_interv(p,
x.get_left(),
x.get_right());
if(!s.is_same(unknown))
return s;
// We are not sure about the sign. We calculate the gcd in
// order to know if both polynomials have common roots.
Polynomial_1 sfpp=Sfpart()(p);
Polynomial_1 gcd=Gcd()(sfpp,Sfpart()(x.get_pol()));
if(Degree()(gcd)==0)
return refine_and_return(p,x);
// At this point, gcd is not 1; we proceed as follows:
// -we refine x until having p monotonic in x's interval (to be
// sure that p has at most one root on that interval),
// -if the gcd has a root on this interval, both roots are
// equal (we return 0), otherwise, we refine until having a
// result.
// How to assure that p is monotonic in an interval: when its
// derivative is never zero in that interval.
Polynomial_1 dsfpp=Deriv()(sfpp);
CGAL::Gmpfr xl(x.get_left());
CGAL::Gmpfr xr(x.get_right());
while(eval_interv(dsfpp,xl,xr).is_same(unknown)){
Refiner()(x.get_zpol(),
xl,
xr,
2*CGAL::max(xl.get_precision(),
xr.get_precision()));
}
x.set_left(xl);
x.set_right(xr);
// How to know that the gcd has a root: evaluate endpoints.
CGAL::Sign sleft,sright;
ZSignat sign_at_gcd(PolConverter()(gcd));
if((sleft=sign_at_gcd(x.get_left()))==CGAL::ZERO||
(sright=sign_at_gcd(x.get_right()))==CGAL::ZERO||
(sleft!=sright))
return CGAL::ZERO;
return refine_and_return(p,x);
}
}; // struct Sign_at_z_1
template <class Polynomial_,
class ZPolynomial_,
class PolConverter_,
class Bound_,
class Algebraic_,
class Refiner_,
class Signat_,
class Ptraits_,
class ZPtraits_>
class Is_zero_at_z_1:
public CGAL::cpp98::binary_function<Polynomial_,Algebraic_,bool>{
// This implementation will work with any polynomial type whose
// coefficient type is explicit interoperable with Gmpfi.
// TODO: Make this function generic.
public:
typedef Polynomial_ Polynomial_1;
typedef ZPolynomial_ ZPolynomial_1;
typedef PolConverter_ PolConverter;
typedef Bound_ Bound;
typedef Algebraic_ Algebraic;
typedef Refiner_ Refiner;
typedef Signat_ ZSignat;
typedef Ptraits_ Ptraits;
typedef ZPtraits_ ZPtraits;
private:
CGAL::Uncertain<CGAL::Sign> eval_interv(const Polynomial_1 &p,
const Bound &l,
const Bound &r)const{
typedef typename Ptraits::Substitute Subst;
std::vector<CGAL::Gmpfi> substitutions;
substitutions.push_back(CGAL::Gmpfi(l,r));
CGAL::Gmpfi eval=Subst()(p,
substitutions.begin(),
substitutions.end());
return eval.sign();
}
public:
bool operator()(const Polynomial_1 &p,Algebraic x)const{
typedef typename Ptraits::Gcd_up_to_constant_factor Gcd;
typedef typename Ptraits::Make_square_free Sfpart;
typedef typename Ptraits::Degree Degree;
typedef typename Ptraits::Differentiate Deriv;
CGAL::Uncertain<CGAL::Sign> unknown=
Uncertain<CGAL::Sign>::indeterminate();
CGAL::Uncertain<CGAL::Sign> s=eval_interv(p,
x.get_left(),
x.get_right());
if(!s.is_same(unknown))
return (s==CGAL::ZERO);
// We are not sure about the sign. We calculate the gcd in
// order to know if both polynomials have common roots.
Polynomial_1 sfpp=Sfpart()(p);
Polynomial_1 gcd=Gcd()(sfpp,Sfpart()(x.get_pol()));
if(Degree()(gcd)==0)
return false;
// At this point, gcd is not 1; we proceed as follows:
// -we refine x until having p monotonic in x's interval (to be
// sure that p has at most one root on that interval),
// -if the gcd has a root on this interval, both roots are
// equal (we return 0), otherwise, we refine until having a
// result.
// How to assure that p is monotonic in an interval: when its
// derivative is never zero in that interval.
Polynomial_1 dsfpp=Deriv()(sfpp);
CGAL::Gmpfr xl(x.get_left());
CGAL::Gmpfr xr(x.get_right());
while(eval_interv(dsfpp,xl,xr).is_same(unknown)){
Refiner()(x.get_zpol(),
xl,
xr,
2*CGAL::max(xl.get_precision(),
xr.get_precision()));
}
x.set_left(xl);
x.set_right(xr);
// How to know that the gcd has a root: evaluate endpoints.
CGAL::Sign sleft,sright;
ZSignat sign_at_gcd(PolConverter()(gcd));
return((sleft=sign_at_gcd(x.get_left()))==CGAL::ZERO||
(sright=sign_at_gcd(x.get_right()))==CGAL::ZERO||
(sleft!=sright));
}
}; // class Is_zero_at_z_1
// TODO: it says in the manual that this should return a size_type, but test
// programs assume that this is equal to int
template <class Polynomial_,
class ZPolynomial_,
class PolConverter_,
class Isolator_>
struct Number_of_solutions_z_1:
public CGAL::cpp98::unary_function<Polynomial_,int>{
typedef Polynomial_ Polynomial_1;
typedef ZPolynomial_ ZPolynomial_1;
typedef PolConverter_ PolConverter;
typedef Isolator_ Isolator;
size_t operator()(const Polynomial_1 &p)const{
// TODO: make sure that p is square free (precondition)
Isolator isol(PolConverter()(p));
return isol.number_of_real_roots();
}
}; // struct Number_of_solutions_z_1
// This functor not only compares two algebraic numbers. In case they are
// different, it refines them until they do not overlap.
template <class Algebraic_,
class Bound_,
class Comparator_>
struct Compare_z_1:
public CGAL::cpp98::binary_function<Algebraic_,Algebraic_,CGAL::Comparison_result>{
typedef Algebraic_ Algebraic;
typedef Bound_ Bound;
typedef Comparator_ Comparator;
CGAL::Comparison_result operator()(Algebraic a,Algebraic b)const{
Bound al=a.get_left();
Bound ar=a.get_right();
Bound bl=b.get_left();
Bound br=b.get_right();
CGAL::Comparison_result c=Comparator()(a.get_zpol(),al,ar,
b.get_zpol(),bl,br);
a.set_left(al);
a.set_right(ar);
b.set_left(bl);
b.set_right(br);
return c;
}
CGAL::Comparison_result operator()(Algebraic a,const Bound &b)const{
Bound al=a.get_left();
Bound ar=a.get_right();
Algebraic balg(b);
CGAL::Comparison_result c=Comparator()(a.get_zpol(),al,ar,
balg.get_zpol(),b,b);
a.set_left(al);
a.set_right(ar);
return c;
}
template <class T>
CGAL::Comparison_result operator()(Algebraic a,const T &b)const{
Bound al=a.get_left();
Bound ar=a.get_right();
Algebraic balg(b);
CGAL::Comparison_result c=Comparator()(a.get_zpol(),
al,
ar,
balg.get_zpol(),
balg.get_left(),
balg.get_right());
a.set_left(al);
a.set_right(ar);
return c;
}
}; // class Compare_z_1
template <class Algebraic_,
class Bound_,
class Comparator_>
struct Bound_between_z_1:
public CGAL::cpp98::binary_function<Algebraic_,Algebraic_,Bound_>{
typedef Algebraic_ Algebraic;
typedef Bound_ Bound;
typedef Comparator_ Comparator;
Bound operator()(Algebraic a,Algebraic b)const{
typedef Compare_z_1<Algebraic,Bound,Comparator> Compare;
typename Bound::Precision_type prec;
switch(Compare()(a,b)){
case CGAL::LARGER:
CGAL_assertion(b.get_right()<a.get_left());
prec=CGAL::max(b.get_right().get_precision(),
a.get_left().get_precision());
return Bound::add(b.get_right(),
a.get_left(),
1+prec)/2;
break;
case CGAL::SMALLER:
CGAL_assertion(a.get_right()<b.get_left());
prec=CGAL::max(a.get_right().get_precision(),
b.get_left().get_precision());
return Bound::add(a.get_right(),
b.get_left(),
1+prec)/2;
break;
default:
CGAL_error_msg(
"bound between two equal numbers");
}
}
}; // struct Bound_between_z_1
template <class Polynomial_,
class ZPolynomial_,
class PolConverter_,
class Bound_,
class Algebraic_,
class Isolator_,
class Comparator_,
class Signat_,
class Ptraits_,
class ZPtraits_>
struct Isolate_z_1:
public CGAL::cpp98::binary_function<Algebraic_,Polynomial_,std::pair<Bound_,Bound_> >{
typedef Polynomial_ Polynomial_1;
typedef ZPolynomial_ ZPolynomial_1;
typedef PolConverter_ PolConverter;
typedef Bound_ Bound;
typedef Algebraic_ Algebraic;
typedef Isolator_ Isolator;
typedef Comparator_ Comparator;
typedef Signat_ Signat;
typedef Ptraits_ Ptraits;
typedef ZPtraits_ ZPtraits;
std::pair<Bound,Bound>
operator()(const Algebraic &a,const Polynomial_1 &p)const{
std::vector<Algebraic> roots;
std::back_insert_iterator<std::vector<Algebraic> > rit(roots);
typedef Solve_z_1<Polynomial_1,
ZPolynomial_1,
PolConverter,
Bound,
Algebraic,
Isolator,
Signat,
Ptraits,
ZPtraits> Solve;
typedef Compare_z_1<Algebraic,Bound,Comparator> Compare;
Solve()(p,false,rit);
for(typename std::vector<Algebraic>::size_type i=0;
i<roots.size();
++i){
// we use the comparison functor, that makes both
// intervals disjoint iff the algebraic numbers they
// represent are not equal
Compare()(a,roots[i]);
}
return std::make_pair(a.left(),a.right());
}
}; // Isolate_z_1
template <class Polynomial_,
class Bound_,
class Algebraic_,
class Refiner_>
struct Approximate_absolute_z_1:
public CGAL::cpp98::binary_function<Algebraic_,int,std::pair<Bound_,Bound_> >{
typedef Polynomial_ Polynomial_1;
typedef Bound_ Bound;
typedef Algebraic_ Algebraic;
typedef Refiner_ Refiner;
// This implementation assumes that Bound is Gmpfr.
// TODO: make generic.
std::pair<Bound,Bound> operator()(const Algebraic &x,const int &a)const{
Bound xl(x.get_left()),xr(x.get_right());
// refsteps=log2(xl-xr)
mpfr_t temp;
mpfr_init(temp);
mpfr_sub(temp,xr.fr(),xl.fr(),GMP_RNDU);
mpfr_log2(temp,temp,GMP_RNDU);
long refsteps=mpfr_get_si(temp,GMP_RNDU);
mpfr_clear(temp);
Refiner()(x.get_zpol(),xl,xr,CGAL::abs(refsteps+a));
x.set_left(xl);
x.set_right(xr);
CGAL_assertion(a>0?
(xr-xl)*CGAL::ipower(Bound(2),a)<=Bound(1):
(xr-xl)<=CGAL::ipower(Bound(2),-a));
return std::make_pair(xl,xr);
}
}; // struct Approximate_absolute_z_1
template <class Polynomial_,
class Bound_,
class Algebraic_,
class Refiner_>
struct Approximate_relative_z_1:
public CGAL::cpp98::binary_function<Algebraic_,int,std::pair<Bound_,Bound_> >{
typedef Polynomial_ Polynomial_1;
typedef Bound_ Bound;
typedef Algebraic_ Algebraic;
typedef Refiner_ Refiner;
std::pair<Bound,Bound> operator()(const Algebraic &x,const int &a)const{
if(CGAL::is_zero(x))
return std::make_pair(Bound(0),Bound(0));
Bound error=CGAL::ipower(Bound(2),CGAL::abs(a));
Bound xl(x.get_left()),xr(x.get_right());
Bound max_b=(CGAL::max)(CGAL::abs(xr),CGAL::abs(xl));
while(a>0?(xr-xl)*error>max_b:(xr-xl)>error*max_b){
Refiner()(x.get_zpol(),
xl,
xr,
std::max<unsigned>(
CGAL::abs(a),
CGAL::max(xl.get_precision(),
xr.get_precision())));
max_b=(CGAL::max)(CGAL::abs(xr),CGAL::abs(xl));
}
x.set_left(xl);
x.set_right(xr);
CGAL_assertion(
a>0?
(xr-xl)*CGAL::ipower(Bound(2),a)<=max_b:
(xr-xl)<=CGAL::ipower(Bound(2),-a)*max_b);
return std::make_pair(xl,xr);
}
}; // struct Approximate_relative_z_1
} // namespace RS_AK1
} // namespace CGAL
#endif // CGAL_RS_FUNCTORS_Z_1_H

View File

@ -1,49 +0,0 @@
// Copyright (c) 2006-2013 INRIA Nancy-Grand Est (France). All rights reserved.
//
// This file is part of CGAL (www.cgal.org)
//
// $URL$
// $Id$
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author: Luis Peñaranda <luis.penaranda@gmx.com>
#ifndef CGAL_RS_POLYNOMIAL_CONVERTER_1_H
#define CGAL_RS_POLYNOMIAL_CONVERTER_1_H
namespace CGAL{
namespace RS_AK1{
template <class InputPolynomial_,class OutputPolynomial_>
struct Polynomial_converter_1:
public CGAL::cpp98::unary_function<InputPolynomial_,OutputPolynomial_>{
typedef InputPolynomial_ InpPolynomial_1;
typedef OutputPolynomial_ OutPolynomial_1;
OutPolynomial_1 operator()(const InpPolynomial_1&)const;
}; // class Polynomial_converter_1
template <>
Polynomial<Gmpz>
Polynomial_converter_1<Polynomial<Gmpq>,Polynomial<Gmpz> >::operator()(
const Polynomial<Gmpq> &p)const{
std::vector<Gmpz> outcoeffs;
unsigned degree=p.degree();
mpz_t lcm;
mpz_init(lcm);
mpz_lcm(lcm,mpq_denref(p[0].mpq()),mpq_denref(p[degree].mpq()));
for(unsigned i=1;i<degree;++i)
mpz_lcm(lcm,lcm,mpq_denref(p[i].mpq()));
for(unsigned i=0;i<=degree;++i){
Gmpz c;
mpz_divexact(c.mpz(),lcm,mpq_denref(p[i].mpq()));
mpz_mul(c.mpz(),c.mpz(),mpq_numref(p[i].mpq()));
outcoeffs.push_back(c);
}
mpz_clear(lcm);
return Polynomial<Gmpz>(outcoeffs.begin(),outcoeffs.end());
}
} // namespace RS_AK1
} // namespace CGAL
#endif // CGAL_RS_POLYNOMIAL_CONVERTER_1_H

View File

@ -1,140 +0,0 @@
// Copyright (c) 2006-2013 INRIA Nancy-Grand Est (France). All rights reserved.
//
// This file is part of CGAL (www.cgal.org)
//
// $URL$
// $Id$
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author: Luis Peñaranda <luis.penaranda@gmx.com>
#ifndef CGAL_RS_RS23_K_ISOLATOR_1_H
#define CGAL_RS_RS23_K_ISOLATOR_1_H
// This file includes an isolator. Its particularity is that is isolates the
// roots with RS2, and the refines them until reaching Kantorovich criterion.
// This can take long, but the later refinements will be extremely fast with
// RS3. The functor is not in RS2 neither in RS3 namespace, because it uses
// functions from both.
#include "rs2_calls.h"
#include "rs3_k_refiner_1.h"
#include <CGAL/Gmpfi.h>
#include <vector>
namespace CGAL{
template <class Polynomial_,class Bound_>
class RS23_k_isolator_1{
public:
typedef Polynomial_ Polynomial;
typedef Bound_ Bound;
private:
typedef Gmpfi Interval;
public:
RS23_k_isolator_1(const Polynomial&);
Polynomial polynomial()const;
int number_of_real_roots()const;
bool is_exact_root(int i)const;
Bound left_bound(int i)const;
Bound right_bound(int i)const;
private:
Polynomial _polynomial;
std::vector<Interval> _real_roots;
};
template <class Polynomial_,class Bound_>
RS23_k_isolator_1<Polynomial_,Bound_>::
RS23_k_isolator_1(const Polynomial_ &){
CGAL_error_msg("not implemented for these polynomial/bound types");
}
template <>
RS23_k_isolator_1<CGAL::Polynomial<CGAL::Gmpz>,Gmpfr>::
RS23_k_isolator_1(const CGAL::Polynomial<CGAL::Gmpz> &p):_polynomial(p){
typedef CGAL::Polynomial<CGAL::Gmpz> Pol;
typedef CGAL::Gmpfr Bound;
typedef CGAL::RS3::RS3_k_refiner_1<Pol,Bound> KRefiner;
int numsols;
std::vector<Gmpfi> intervals;
RS2::RS2_calls::init_solver();
RS2::RS2_calls::create_rs_upoly(p,rs_get_default_up());
set_rs_precisol(0);
set_rs_verbose(0);
rs_run_algo((char*)"UISOLE");
RS2::RS2_calls::insert_roots(std::back_inserter(intervals));
// RS2 computed the isolating intervals. Now, we use RS3 to refine each
// root until reaching Kantorovich criterion, before adding it to the
// root vector.
numsols=intervals.size();
for(int j=0;j<numsols;++j){
Gmpfr left(intervals[j].inf());
Gmpfr right(intervals[j].sup());
CGAL_assertion(left<=right);
KRefiner()(p,left,right,53);
_real_roots.push_back(intervals[j]);
}
}
template <>
RS23_k_isolator_1<CGAL::Polynomial<CGAL::Gmpq>,Gmpfr>::
RS23_k_isolator_1(const CGAL::Polynomial<CGAL::Gmpq> &qp):_polynomial(qp){
typedef CGAL::Polynomial<CGAL::Gmpz> ZPol;
typedef CGAL::Gmpfr Bound;
typedef CGAL::RS3::RS3_k_refiner_1<ZPol,Bound> ZKRefiner;
int numsols;
std::vector<Gmpfi> intervals;
CGAL::Polynomial<CGAL::Gmpz> zp=CGAL::RS_AK1::Polynomial_converter_1<
CGAL::Polynomial<Gmpq>,
CGAL::Polynomial<Gmpz> >()(qp);
RS2::RS2_calls::init_solver();
RS2::RS2_calls::create_rs_upoly(zp,rs_get_default_up());
set_rs_precisol(0);
set_rs_verbose(0);
rs_run_algo((char*)"UISOLE");
RS2::RS2_calls::insert_roots(std::back_inserter(intervals));
// RS2 computed the isolating intervals. Now, we use RS3 to refine each
// root until reaching Kantorovich criterion, before adding it to the
// root vector.
numsols=intervals.size();
for(int j=0;j<numsols;++j){
Gmpfr left(intervals[j].inf());
Gmpfr right(intervals[j].sup());
ZKRefiner()(zp,left,right,53);
_real_roots.push_back(intervals[j]);
}
}
template <class Polynomial_,class Bound_>
Polynomial_
RS23_k_isolator_1<Polynomial_,Bound_>::polynomial()const{
return _polynomial;
}
template <class Polynomial_,class Bound_>
int
RS23_k_isolator_1<Polynomial_,Bound_>::number_of_real_roots()const{
return _real_roots.size();
}
template <class Polynomial_,class Bound_>
bool
RS23_k_isolator_1<Polynomial_,Bound_>::is_exact_root(int i)const{
return _real_roots[i].inf()==_real_roots[i].sup();
}
template <class Polynomial_,class Bound_>
Bound_
RS23_k_isolator_1<Polynomial_,Bound_>::left_bound(int i)const{
return _real_roots[i].inf();
}
template <class Polynomial_,class Bound_>
Bound_
RS23_k_isolator_1<Polynomial_,Bound_>::right_bound(int i)const{
return _real_roots[i].sup();
}
} // namespace CGAL
#endif // CGAL_RS_RS23_K_ISOLATOR_1_H

View File

@ -1,141 +0,0 @@
// Copyright (c) 2006-2013 INRIA Nancy-Grand Est (France). All rights reserved.
//
// This file is part of CGAL (www.cgal.org)
//
// $URL$
// $Id$
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author: Luis Peñaranda <luis.penaranda@gmx.com>
#ifndef CGAL_RS_RS2_CALLS_H
#define CGAL_RS_RS2_CALLS_H
#include <CGAL/Gmpz.h>
#include <CGAL/Gmpfr.h>
#include <CGAL/Gmpfi.h>
#include <CGAL/Polynomial.h>
#include <CGAL/tss.h>
#include <rs_exports.h>
#ifdef CGAL_RS_OLD_INCLUDES
#define CGALRS_PTR(a) long int a
#else
#define CGALRS_PTR(a) void *a
#endif
// RS3 does not work with MPFR 3.1.3 to 3.1.6. In case RS3 is enabled and
// the version of MPFR is one of those buggy versions, abort the compilation
// and instruct the user to update MPFR or don't use RS3.
#ifdef CGAL_USE_RS3
static_assert(
MPFR_VERSION_MAJOR!=3 ||
MPFR_VERSION_MINOR!=1 ||
MPFR_VERSION_PATCHLEVEL<3 || MPFR_VERSION_PATCHLEVEL>6,
"RS3 does not work with MPFR versions 3.1.3 to 3.1.6. "
"Please update MPFR or disable RS3.");
#endif // CGAL_USE_RS3
namespace CGAL{
namespace RS2{
struct RS2_calls{
static void init_solver(){
CGAL_STATIC_THREAD_LOCAL_VARIABLE(bool, first,true);
if(first){
first=false;
rs_init_rs();
rs_reset_all();
}else
rs_reset_all();
}
static void create_rs_upoly(CGAL::Polynomial<CGAL::Gmpz> poly,
CGALRS_PTR(ident_pol)){
CGALRS_PTR(ident_mon);
CGALRS_PTR(ident_coeff);
rs_import_uppring((char*)"T");
for(int i=0;i<=poly.degree();++i)
if(mpz_sgn(poly[i].mpz())){ // don't add if == 0
ident_mon=rs_export_new_mon_upp_bz();
ident_coeff=rs_export_new_gmp();
rs_import_bz_gmp(ident_coeff,
TO_RSPTR_IN(&(poly[i].mpz())));
rs_dset_mon_upp_bz(ident_mon,ident_coeff,i);
rs_dappend_list_mon_upp_bz(ident_pol,
ident_mon);
}
}
static int affiche_sols_eqs(mpfi_ptr *x){
CGALRS_PTR(ident_sols_eqs);
CGALRS_PTR(ident_node);
CGALRS_PTR(ident_vect);
CGALRS_PTR(ident_elt);
int nb_elts;
ident_sols_eqs=rs_get_default_sols_eqs();
nb_elts=rs_export_list_vect_ibfr_nb(ident_sols_eqs);
ident_node=rs_export_list_vect_ibfr_firstnode(ident_sols_eqs);
mpfi_t *roots=(mpfi_t*)malloc(nb_elts*sizeof(mpfi_t));
for(int i=0;i<nb_elts;++i){
ident_vect=rs_export_list_vect_ibfr_monnode
(ident_node);
CGAL_assertion_msg(rs_export_dim_vect_ibfr
(ident_vect)==1,
"vector dimension must be 1");
ident_elt=rs_export_elt_vect_ibfr(ident_vect,0);
mpfi_ptr root_pointer=
(mpfi_ptr)rs_export_ibfr_mpfi(ident_elt);
mpfi_init2(roots[i],mpfi_get_prec(root_pointer));
mpfi_set(roots[i],root_pointer);
x[i]=roots[i];
// This doesn't work because RS relocates the
// mpfrs that form the mpfi. Nevertheless, the
// mpfi address is not changed.
//x[i]=(mpfi_ptr)rs_export_ibfr_mpfi(ident_elt);
ident_node=rs_export_list_vect_ibfr_nextnode
(ident_node);
}
return nb_elts;
}
template<class OutputIterator>
static OutputIterator insert_roots(OutputIterator x){
CGALRS_PTR(ident_sols_eqs);
CGALRS_PTR(ident_node);
CGALRS_PTR(ident_vect);
CGALRS_PTR(ident_elt);
int nb_elts;
ident_sols_eqs=rs_get_default_sols_eqs();
nb_elts=rs_export_list_vect_ibfr_nb(ident_sols_eqs);
ident_node=rs_export_list_vect_ibfr_firstnode(ident_sols_eqs);
for(int i=0;i<nb_elts;++i){
ident_vect=rs_export_list_vect_ibfr_monnode
(ident_node);
CGAL_assertion_msg(rs_export_dim_vect_ibfr
(ident_vect)==1,
"vector dimension must be 1");
ident_elt=rs_export_elt_vect_ibfr(ident_vect,0);
mpfi_ptr root_pointer=
(mpfi_ptr)rs_export_ibfr_mpfi(ident_elt);
mp_prec_t root_prec=mpfi_get_prec(root_pointer);
// Construct Gmpfr's with pointers to endpoints.
Gmpfr left(&(root_pointer->left),root_prec);
Gmpfr right(&(root_pointer->right),root_prec);
CGAL_assertion(left<=right);
// Copy them, to have the data out of RS memory.
*x++=Gmpfi(left,right,root_prec+1);
ident_node=rs_export_list_vect_ibfr_nextnode
(ident_node);
}
return x;
}
}; // struct RS2_calls
} // namespace RS2
} // namespace CGAL
#endif // CGAL_RS_RS2_CALLS_H

View File

@ -1,114 +0,0 @@
// Copyright (c) 2006-2013 INRIA Nancy-Grand Est (France). All rights reserved.
//
// This file is part of CGAL (www.cgal.org)
//
// $URL$
// $Id$
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author: Luis Peñaranda <luis.penaranda@gmx.com>
#ifndef CGAL_RS_RS2_ISOLATOR_1_H
#define CGAL_RS_RS2_ISOLATOR_1_H
#include "rs2_calls.h"
#include "polynomial_converter_1.h"
#include <CGAL/Gmpfi.h>
#include <vector>
namespace CGAL{
namespace RS2{
template <class Polynomial_,class Bound_>
class RS2_isolator_1{
public:
typedef Polynomial_ Polynomial;
typedef Bound_ Bound;
private:
typedef Gmpfi Interval;
public:
RS2_isolator_1(const Polynomial&);
Polynomial polynomial()const;
int number_of_real_roots()const;
bool is_exact_root(int i)const;
Bound left_bound(int i)const;
Bound right_bound(int i)const;
private:
Polynomial _polynomial;
std::vector<Interval> _real_roots;
};
template <class Polynomial_,class Bound_>
RS2_isolator_1<Polynomial_,Bound_>::
RS2_isolator_1(const Polynomial_ &){
CGAL_error_msg("not implemented for these polynomial/bound types");
}
// Isolator of Gmpz polynomials and Gmpfr bounds (the best case for RS).
template <>
RS2_isolator_1<CGAL::Polynomial<CGAL::Gmpz>,Gmpfr>::
RS2_isolator_1(const CGAL::Polynomial<CGAL::Gmpz> &p):_polynomial(p){
//mpz_t *coeffs=(mpz_t*)malloc((degree+1)*sizeof(mpz_t));
//mpfi_ptr *intervals_mpfi=(mpfi_ptr*)malloc(degree*sizeof(mpfi_ptr));
//for(unsigned i=0;i<=degree;++i)
// coeffs[i][0]=*(p[i].mpz());
RS2::RS2_calls::init_solver();
RS2::RS2_calls::create_rs_upoly(p,rs_get_default_up());
//free(coeffs);
set_rs_precisol(0);
set_rs_verbose(0);
rs_run_algo((char*)"UISOLE");
RS2::RS2_calls::insert_roots(std::back_inserter(_real_roots));
}
// Isolator of Gmpq polynomials and Gmpfr bounds. The polynomial must be
// converted to a Gmpz one with the same roots.
template <>
RS2_isolator_1<CGAL::Polynomial<CGAL::Gmpq>,Gmpfr>::
RS2_isolator_1(const CGAL::Polynomial<CGAL::Gmpq> &p):_polynomial(p){
RS2::RS2_calls::init_solver();
RS2::RS2_calls::create_rs_upoly(
CGAL::RS_AK1::Polynomial_converter_1<
CGAL::Polynomial<Gmpq>,
CGAL::Polynomial<Gmpz> >()(p),
rs_get_default_up());
set_rs_precisol(0);
set_rs_verbose(0);
rs_run_algo((char*)"UISOLE");
RS2::RS2_calls::insert_roots(std::back_inserter(_real_roots));
}
template <class Polynomial_,class Bound_>
Polynomial_
RS2_isolator_1<Polynomial_,Bound_>::polynomial()const{
return _polynomial;
}
template <class Polynomial_,class Bound_>
int
RS2_isolator_1<Polynomial_,Bound_>::number_of_real_roots()const{
return _real_roots.size();
}
template <class Polynomial_,class Bound_>
bool
RS2_isolator_1<Polynomial_,Bound_>::is_exact_root(int i)const{
return _real_roots[i].inf()==_real_roots[i].sup();
}
template <class Polynomial_,class Bound_>
Bound_
RS2_isolator_1<Polynomial_,Bound_>::left_bound(int i)const{
return _real_roots[i].inf();
}
template <class Polynomial_,class Bound_>
Bound_
RS2_isolator_1<Polynomial_,Bound_>::right_bound(int i)const{
return _real_roots[i].sup();
}
} // namespace RS2
} // namespace CGAL
#endif // CGAL_RS_RS2_ISOLATOR_1_H

View File

@ -1,157 +0,0 @@
// Copyright (c) 2006-2013 INRIA Nancy-Grand Est (France). All rights reserved.
//
// This file is part of CGAL (www.cgal.org)
//
// $URL$
// $Id$
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author: Luis Peñaranda <luis.penaranda@gmx.com>
#ifndef CGAL_RS_RS3_K_REFINER_1_H
#define CGAL_RS_RS3_K_REFINER_1_H
#include <CGAL/Polynomial_traits_d.h>
#include "polynomial_converter_1.h"
#include "rs2_calls.h"
#include <rs3_fncts.h>
#include "Gmpfr_make_unique.h"
// If we want assertions, we need to evaluate.
#ifndef CGAL_NO_PRECONDITIONS
#include "signat_1.h"
#endif
namespace CGAL{
namespace RS3{
template <class Polynomial_,class Bound_>
struct RS3_k_refiner_1{
void operator()(const Polynomial_&,Bound_&,Bound_&,int);
}; // class RS3_k_refiner_1
template <class Polynomial_,class Bound_>
void
RS3_k_refiner_1<Polynomial_,Bound_>::
operator()(const Polynomial_&,Bound_&,Bound_&,int){
CGAL_error_msg("RS3 k-refiner not implemented for these types");
return;
}
template<>
void
RS3_k_refiner_1<Polynomial<Gmpz>,Gmpfr>::
operator()
(const Polynomial<Gmpz> &pol,Gmpfr &left,Gmpfr &right,int prec){
typedef Polynomial<Gmpz> Polynomial;
typedef Polynomial_traits_d<Polynomial> Ptraits;
typedef Ptraits::Degree Degree;
CGAL_precondition(left<=right);
#ifndef CGAL_NO_PRECONDITIONS
typedef Ptraits::Make_square_free Sfpart;
typedef CGAL::RS_AK1::Signat_1<Polynomial,Gmpfr>
Signat;
Polynomial sfpp=Sfpart()(pol);
Signat signof(sfpp);
CGAL::Sign sl=signof(left);
CGAL_precondition(sl!=signof(right)||(left==right&&sl==ZERO));
#endif
//std::cout<<"refining ["<<left<<","<<right<<"]"<<std::endl;
int deg=Degree()(pol);
mpz_t* coefficients=(mpz_t*)malloc((deg+1)*sizeof(mpz_t));
__mpfi_struct interval;
CGAL_RS_GMPFR_MAKE_UNIQUE(left,temp_left);
CGAL_RS_GMPFR_MAKE_UNIQUE(right,temp_right);
interval.left=*(left.fr());
interval.right=*(right.fr());
for(int i=0;i<=deg;++i)
coefficients[i][0]=*(pol[i].mpz());
RS2::RS2_calls::init_solver();
rs3_refine_u_root(&interval,
coefficients,
deg,
prec+CGAL::max(left.get_precision(),
right.get_precision()),
1,
1);
free(coefficients);
mpfr_clear(left.fr());
mpfr_clear(right.fr());
mpfr_custom_init_set(left.fr(),
mpfr_custom_get_kind(&interval.left),
mpfr_custom_get_exp(&interval.left),
mpfr_get_prec(&interval.left),
mpfr_custom_get_mantissa(&interval.left));
mpfr_custom_init_set(right.fr(),
mpfr_custom_get_kind(&interval.right),
mpfr_custom_get_exp(&interval.right),
mpfr_get_prec(&interval.right),
mpfr_custom_get_mantissa(&interval.right));
CGAL_postcondition(left<=right);
//std::cout<<"ref root is ["<<left<<","<<right<<"]"<<std::endl;
return;
}
template<>
void
RS3_k_refiner_1<Polynomial<Gmpq>,Gmpfr>::
operator()
(const Polynomial<Gmpq> &qpol,Gmpfr &left,Gmpfr &right,int prec){
typedef Polynomial<Gmpz> ZPolynomial;
typedef Polynomial_traits_d<ZPolynomial> ZPtraits;
typedef ZPtraits::Degree ZDegree;
CGAL_precondition(left<=right);
#ifndef CGAL_NO_PRECONDITIONS
typedef ZPtraits::Make_square_free ZSfpart;
typedef CGAL::RS_AK1::Signat_1<ZPolynomial,Gmpfr>
Signat;
#endif
//std::cout<<"refining ["<<left<<","<<right<<"]"<<std::endl;
Polynomial<Gmpz> zpol=CGAL::RS_AK1::Polynomial_converter_1<
CGAL::Polynomial<Gmpq>,
CGAL::Polynomial<Gmpz> >()(qpol);
#ifndef CGAL_NO_PRECONDITIONS
ZPolynomial zsfpp=ZSfpart()(zpol);
Signat signof(zsfpp);
CGAL::Sign sl=signof(left);
CGAL_precondition(sl!=signof(right)||(left==right&&sl==ZERO));
#endif
int deg=ZDegree()(zpol);
mpz_t* coefficients=(mpz_t*)malloc((deg+1)*sizeof(mpz_t));
__mpfi_struct interval;
CGAL_RS_GMPFR_MAKE_UNIQUE(left,temp_left);
CGAL_RS_GMPFR_MAKE_UNIQUE(right,temp_right);
interval.left=*(left.fr());
interval.right=*(right.fr());
for(int i=0;i<=deg;++i)
coefficients[i][0]=*(zpol[i].mpz());
RS2::RS2_calls::init_solver();
rs3_refine_u_root(&interval,
coefficients,
deg,
prec+CGAL::max(left.get_precision(),
right.get_precision()),
1,
1);
free(coefficients);
mpfr_clear(left.fr());
mpfr_clear(right.fr());
mpfr_custom_init_set(left.fr(),
mpfr_custom_get_kind(&interval.left),
mpfr_custom_get_exp(&interval.left),
mpfr_get_prec(&interval.left),
mpfr_custom_get_mantissa(&interval.left));
mpfr_custom_init_set(right.fr(),
mpfr_custom_get_kind(&interval.right),
mpfr_custom_get_exp(&interval.right),
mpfr_get_prec(&interval.right),
mpfr_custom_get_mantissa(&interval.right));
CGAL_postcondition(left<=right);
//std::cout<<"ref root is ["<<left<<","<<right<<"]"<<std::endl;
return;
}
} // namespace RS3
} // namespace CGAL
#endif // CGAL_RS_RS3_K_REFINER_1_H

View File

@ -1,169 +0,0 @@
// Copyright (c) 2006-2013 INRIA Nancy-Grand Est (France). All rights reserved.
//
// This file is part of CGAL (www.cgal.org)
//
// $URL$
// $Id$
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author: Luis Peñaranda <luis.penaranda@gmx.com>
#ifndef CGAL_RS_RS3_REFINER_1_H
#define CGAL_RS_RS3_REFINER_1_H
#include <CGAL/Polynomial_traits_d.h>
#include "rs2_calls.h"
#include <rs3_fncts.h>
#include "Gmpfr_make_unique.h"
// If we want assertions, we need to evaluate.
#ifndef CGAL_NO_PRECONDITIONS
#include "signat_1.h"
#endif
namespace CGAL{
namespace RS3{
template <class Polynomial_,class Bound_>
struct RS3_refiner_1{
void operator()(const Polynomial_&,Bound_&,Bound_&,int,int=0);
}; // class RS3_refiner_1
template <class Polynomial_,class Bound_>
void
RS3_refiner_1<Polynomial_,Bound_>::
operator()(const Polynomial_&,Bound_&,Bound_&,int,int){
CGAL_error_msg("RS3 refiner not implemented for these types");
return;
}
template<>
void
RS3_refiner_1<Polynomial<Gmpz>,Gmpfr>::
operator()
(const Polynomial<Gmpz> &pol,Gmpfr &left,Gmpfr &right,int prec,int k){
typedef Polynomial<Gmpz> Polynomial;
typedef Polynomial_traits_d<Polynomial> Ptraits;
typedef Ptraits::Degree Degree;
CGAL_precondition(left<=right);
#ifndef CGAL_NO_PRECONDITIONS
typedef Ptraits::Make_square_free Sfpart;
typedef CGAL::RS_AK1::Signat_1<Polynomial,Gmpfr>
Signat;
Polynomial sfpp=Sfpart()(pol);
Signat signof(sfpp);
CGAL::Sign sl=signof(left);
CGAL_precondition(sl!=signof(right)||(left==right&&sl==ZERO));
#endif
//std::cout<<"refining ["<<left<<","<<right<<"]"<<std::endl;
int deg=Degree()(pol);
mpz_t* coefficients=(mpz_t*)malloc((deg+1)*sizeof(mpz_t));
__mpfi_struct interval;
// Make sure the endpoints do not share references.
CGAL_RS_GMPFR_MAKE_UNIQUE(left,temp_left);
CGAL_RS_GMPFR_MAKE_UNIQUE(right,temp_right);
// Construct the mpfi_t interval which will be refined.
interval.left=*(left.fr());
interval.right=*(right.fr());
// Construct the polynomial which will be refined (copy pointers).
for(int i=0;i<=deg;++i)
coefficients[i][0]=*(pol[i].mpz());
// Call RS.
RS2::RS2_calls::init_solver();
rs3_refine_u_root(&interval,
coefficients,
deg,
prec+CGAL::max(left.get_precision(),
right.get_precision()),
k,
k);
// Clear variables.
free(coefficients);
mpfr_clear(left.fr());
mpfr_clear(right.fr());
// Copy results back to the Gmpfr endpoints.
mpfr_custom_init_set(left.fr(),
mpfr_custom_get_kind(&interval.left),
mpfr_custom_get_exp(&interval.left),
mpfr_get_prec(&interval.left),
mpfr_custom_get_mantissa(&interval.left));
mpfr_custom_init_set(right.fr(),
mpfr_custom_get_kind(&interval.right),
mpfr_custom_get_exp(&interval.right),
mpfr_get_prec(&interval.right),
mpfr_custom_get_mantissa(&interval.right));
CGAL_postcondition(left<=right);
//std::cout<<"ref root is ["<<left<<","<<right<<"]"<<std::endl;
return;
}
template<>
void
RS3_refiner_1<Polynomial<Gmpq>,Gmpfr>::
operator()
(const Polynomial<Gmpq> &qpol,Gmpfr &left,Gmpfr &right,int prec,int k){
typedef Polynomial<Gmpz> ZPolynomial;
typedef Polynomial_traits_d<ZPolynomial> ZPtraits;
typedef ZPtraits::Degree ZDegree;
CGAL_precondition(left<=right);
#ifndef CGAL_NO_PRECONDITIONS
typedef ZPtraits::Make_square_free ZSfpart;
typedef CGAL::RS_AK1::Signat_1<ZPolynomial,Gmpfr>
Signat;
#endif
//std::cout<<"refining ["<<left<<","<<right<<"]"<<std::endl;
// Construct a Gmpz polynomial from the original Gmpq polynomial.
Polynomial<Gmpz> zpol=CGAL::RS_AK1::Polynomial_converter_1<
CGAL::Polynomial<Gmpq>,
CGAL::Polynomial<Gmpz> >()(qpol);
#ifndef CGAL_NO_PRECONDITIONS
ZPolynomial zsfpp=ZSfpart()(zpol);
Signat signof(zsfpp);
CGAL::Sign sl=signof(left);
CGAL_precondition(sl!=signof(right)||(left==right&&sl==ZERO));
#endif
int deg=ZDegree()(zpol);
mpz_t* coefficients=(mpz_t*)malloc((deg+1)*sizeof(mpz_t));
__mpfi_struct interval;
// Make sure the endpoints do not share references.
CGAL_RS_GMPFR_MAKE_UNIQUE(left,temp_left);
CGAL_RS_GMPFR_MAKE_UNIQUE(right,temp_right);
// Construct the mpfi_t interval which will be refined.
interval.left=*(left.fr());
interval.right=*(right.fr());
// Construct the polynomial which will be refined (copy pointers).
for(int i=0;i<=deg;++i)
coefficients[i][0]=*(zpol[i].mpz());
// Call RS.
RS2::RS2_calls::init_solver();
rs3_refine_u_root(&interval,
coefficients,
deg,
prec+CGAL::max(left.get_precision(),
right.get_precision()),
k,
k);
// Clear variables.
free(coefficients);
mpfr_clear(left.fr());
mpfr_clear(right.fr());
// Copy results back to the Gmpfr endpoints.
mpfr_custom_init_set(left.fr(),
mpfr_custom_get_kind(&interval.left),
mpfr_custom_get_exp(&interval.left),
mpfr_get_prec(&interval.left),
mpfr_custom_get_mantissa(&interval.left));
mpfr_custom_init_set(right.fr(),
mpfr_custom_get_kind(&interval.right),
mpfr_custom_get_exp(&interval.right),
mpfr_get_prec(&interval.right),
mpfr_custom_get_mantissa(&interval.right));
CGAL_postcondition(left<=right);
//std::cout<<"ref root is ["<<left<<","<<right<<"]"<<std::endl;
return;
}
} // namespace RS3
} // namespace CGAL
#endif // CGAL_RS_RS3_REFINER_1_H

View File

@ -1,105 +0,0 @@
// Copyright (c) 2006-2013 INRIA Nancy-Grand Est (France). All rights reserved.
//
// This file is part of CGAL (www.cgal.org)
//
// $URL$
// $Id$
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author: Luis Peñaranda <luis.penaranda@gmx.com>
#ifndef CGAL_RS_SIGNAT_1_H
#define CGAL_RS_SIGNAT_1_H
#include <CGAL/Gmpfi.h>
#include <CGAL/Polynomial_traits_d.h>
#include "exact_signat_1.h"
#include <gmp.h>
namespace CGAL{
namespace RS_AK1{
template <class Polynomial_,class Bound_>
struct Signat_1{
typedef Polynomial_ Polynomial;
typedef Bound_ Bound;
typedef CGAL::Polynomial_traits_d<Polynomial> PT;
typedef typename PT::Degree Degree;
Polynomial pol;
Signat_1(const Polynomial &p):pol(p){};
CGAL::Sign operator()(const Bound&)const;
}; // struct Signat_1
template <class Polynomial_,class Bound_>
inline CGAL::Sign
Signat_1<Polynomial_,Bound_>::operator()(const Bound_ &x)const{
typedef Bound_ Bound;
typedef Real_embeddable_traits<Bound> REtraits;
typedef typename REtraits::Sgn BSign;
//typedef Algebraic_structure_traits<Bound> AStraits;
// This generic signat works only when Bound_ is an exact type. For
// non-exact types, an implementation must be provided.
//static_assert(std::is_same<AStraits::Is_exact,Tag_true>::value);
int d=Degree()(pol);
Bound h(pol[d]);
for(int i=1;i<=d;++i)
h=h*x+pol[d-i];
return BSign()(h);
}
template <>
inline CGAL::Sign
Signat_1<Polynomial<Gmpz>,Gmpfr>::operator()(const Gmpfr &x)const{
// In 32-bit systems, using Gmpfr arithmetic to perform exact
// evaluations can overflow. For that reason, we only use Gmpfr
// arithmetic in 64-bit systems.
#if (GMP_LIMB_BITS==64)
typedef ExactSignat_1<Polynomial,Gmpfr> Exact_sign;
#else
typedef Signat_1<Polynomial,Gmpq> Exact_sign;
#endif
// This seems to work faster for small polynomials:
// return Exact_sign(pol)(x);
int d=Degree()(pol);
if(d==0)
return pol[0].sign();
Gmpfi h(pol[d],x.get_precision()+2*d);
Uncertain<CGAL::Sign> indet=Uncertain<CGAL::Sign>::indeterminate();
if(h.sign().is_same(indet))
return Exact_sign(pol)(x);
for(int i=1;i<=d;++i){
h*=x;
h+=pol[d-i];
if(h.sign().is_same(indet))
return Exact_sign(pol)(x);
}
CGAL_assertion(!h.sign().is_same(indet));
return h.sign();
}
// This is the same code as above.
template <>
inline CGAL::Sign
Signat_1<Polynomial<Gmpq>,Gmpfr>::operator()(const Gmpfr &x)const{
typedef Signat_1<Polynomial,Gmpq> Exact_sign;
int d=Degree()(pol);
if(d==0)
return pol[0].sign();
Gmpfi h(pol[d],x.get_precision()+2*d);
Uncertain<CGAL::Sign> indet=Uncertain<CGAL::Sign>::indeterminate();
if(h.sign().is_same(indet))
return Exact_sign(pol)(x);
for(int i=1;i<=d;++i){
h*=x;
h+=pol[d-i];
if(h.sign().is_same(indet))
return Exact_sign(pol)(x);
}
CGAL_assertion(!h.sign().is_same(indet));
return h.sign();
}
} // namespace RS_AK1
} // namespace CGAL
#endif // CGAL_RS_SIGNAT_1_H

View File

@ -1,142 +0,0 @@
// Copyright (c) 2006-2013 INRIA Nancy-Grand Est (France). All rights reserved.
//
// This file is part of CGAL (www.cgal.org)
//
// $URL$
// $Id$
// SPDX-License-Identifier: LGPL-2.1-only
//
// Author: Luis Peñaranda <luis.penaranda@gmx.com>
#include <CGAL/config.h>
#if defined(CGAL_USE_GMP) && defined(CGAL_USE_MPFI) && defined(CGAL_USE_RS)
#include "include/CGAL/_test_algebraic_kernel_1.h"
#ifdef CGAL_RS_TEST_LOG_TIME
#include <ctime>
#endif
#include <CGAL/Algebraic_kernel_rs_gmpq_d_1.h>
template <class AK_>
int test_ak(){
typedef AK_ AK;
typedef typename AK::Polynomial_1 Polynomial_1;
//typedef typename AK::Coefficient Coefficient;
typedef typename AK::Bound Bound;
typedef typename AK::Algebraic_real_1 Algebraic_real_1;
typedef typename AK::Multiplicity_type Multiplicity_type;
#ifdef CGAL_RS_TEST_LOG_TIME
clock_t start=clock();
#endif
AK ak; // an algebraic kernel object
CGAL::test_algebraic_kernel_1<AK>(ak); // we run standard tests first
typename AK::Solve_1 solve_1 = ak.solve_1_object();
Polynomial_1 x = CGAL::shift(Polynomial_1(1),1);
int returnvalue=0;
// variant using a bool indicating a square free polynomial
// multiplicities are not computed
std::vector<Algebraic_real_1> roots;
solve_1(x*x-2,true, std::back_inserter(roots));
if(roots.size()!=2){
returnvalue-=1;
std::cerr<<"error 1: the number of roots of x^2-2 must be 2"<<
std::endl;
}
if(-1.42>=roots[0] || -1.41<=roots[0] ||
1.41>=roots[1] || 1.42<=roots[1]){
returnvalue-=2;
std::cerr<<"error 2: the roots of x^2-2 are wrong"<<std::endl;
}
roots.clear();
// variant for roots in a given range of a square free polynomial
solve_1((x*x-2)*(x*x-3),true, Bound(0),Bound(10),
std::back_inserter(roots));
if(roots.size()!=2){
returnvalue-=4;
std::cerr<<"error 3: the number of roots of (x^2-2)*(x^2-3)"<<
" between 0 and 10 must be 2"<<std::endl;
}
if(1.41>=roots[0] || 1.42<=roots[0] ||
1.73>=roots[1] || 1.74<=roots[1]){
returnvalue-=8;
std::cerr<<"error 4: the roots of (x^2-2)*(x^2-3)"<<
" between 0 and 10 are wrong"<<std::endl;
}
roots.clear();
// variant computing all roots with multiplicities
std::vector<std::pair<Algebraic_real_1,Multiplicity_type> > mroots;
solve_1((x*x-2), std::back_inserter(mroots));
if(mroots.size()!=2){
returnvalue-=16;
std::cerr<<"error 5: the number of roots of x^2-2 must be 2"<<
std::endl;
}
if(-1.42>=mroots[0].first || -1.41<=mroots[0].first ||
1.41>=mroots[1].first || 1.42<=mroots[1].first){
returnvalue-=32;
std::cerr<<"error 6: the roots of x^2-2 are wrong"<<std::endl;
}
if(mroots[0].second!=1 && mroots[1].second!=1){
returnvalue-=64;
std::cerr<<"error 7: the multiplicities of the"<<
" roots of x^2-2 are wrong"<<std::endl;
}
mroots.clear();
// variant computing roots with multiplicities for a range
solve_1((x*x-2)*(x*x-3),Bound(0),Bound(10),std::back_inserter(mroots));
if(mroots.size()!=2){
returnvalue-=128;
std::cerr<<"error 8: the number of roots of (x^2-2)*(x^2-3)"<<
" between 0 and 10 must be 2"<<std::endl;
}
if(1.41>=mroots[0].first || 1.42<=mroots[0].first ||
1.73>=mroots[1].first || 1.74<=mroots[1].first){
returnvalue-=256;
std::cerr<<"error 9: the roots of (x^2-2)*(x^2-3) are wrong"<<
std::endl;
}
if(mroots[0].second!=1 && mroots[1].second!=1){
returnvalue-=512;
std::cerr<<"error 10: the multiplicities of the roots of"<<
" (x^2-2)*(x^2-3) are wrong"<<std::endl;
}
typename AK::Number_of_solutions_1 nos_1 = ak.number_of_solutions_1_object();
if(nos_1(x*x*x-2)!=1){
returnvalue-=1024;
std::cerr<<"error 11: x^3-2 must have only one root"<<std::endl;
}
#ifdef CGAL_RS_TEST_LOG_TIME
std::cerr<<"*** test time: "<<(double)(clock()-start)/CLOCKS_PER_SEC<<
" seconds"<<std::endl;
#endif
return returnvalue;
}
int main(){
typedef CGAL::Algebraic_kernel_rs_gmpq_d_1 AK_rational;
// test and return the result
long result=0;
std::cerr<<"*** testing rational RS AK_1:";
result+=test_ak<AK_rational>();
std::cerr<<"*** result of the tests (should be 0): "<<result<<std::endl;
return result;
}
#else
int main(){
return 0;
}
#endif

View File

@ -1,189 +0,0 @@
// Copyright (c) 2006-2013 INRIA Nancy-Grand Est (France). All rights reserved.
//
// This file is part of CGAL (www.cgal.org)
//
// $URL$
// $Id$
// SPDX-License-Identifier: LGPL-2.1-only
//
// Author: Luis Peñaranda <luis.penaranda@gmx.com>
#include <CGAL/config.h>
#if defined(CGAL_USE_GMP) && defined(CGAL_USE_MPFI) && defined(CGAL_USE_RS)
#include "include/CGAL/_test_algebraic_kernel_1.h"
#ifdef CGAL_RS_TEST_LOG_TIME
#include <ctime>
#endif
// default RS_AK_1
#include <CGAL/Algebraic_kernel_rs_gmpz_d_1.h>
// different isolators
#include <CGAL/RS/rs2_isolator_1.h>
#ifdef CGAL_USE_RS3
#include <CGAL/RS/rs23_k_isolator_1.h>
#endif
// different refiners
#include <CGAL/RS/bisection_refiner_1.h>
#ifdef CGAL_USE_RS3
#include <CGAL/RS/rs3_refiner_1.h>
#include <CGAL/RS/rs3_k_refiner_1.h>
#endif
template <class AK_>
int test_ak(){
typedef AK_ AK;
typedef typename AK::Polynomial_1 Polynomial_1;
//typedef typename AK::Coefficient Coefficient;
typedef typename AK::Bound Bound;
typedef typename AK::Algebraic_real_1 Algebraic_real_1;
typedef typename AK::Multiplicity_type Multiplicity_type;
#ifdef CGAL_RS_TEST_LOG_TIME
clock_t start=clock();
#endif
AK ak; // an algebraic kernel object
CGAL::test_algebraic_kernel_1<AK>(ak); // we run standard tests first
typename AK::Solve_1 solve_1 = ak.solve_1_object();
Polynomial_1 x = CGAL::shift(Polynomial_1(1),1);
int returnvalue=0;
// variant using a bool indicating a square free polynomial
// multiplicities are not computed
std::vector<Algebraic_real_1> roots;
solve_1(x*x-2,true, std::back_inserter(roots));
if(roots.size()!=2){
returnvalue-=1;
std::cerr<<"error 1: the number of roots of x^2-2 must be 2"<<
std::endl;
}
if(-1.42>=roots[0] || -1.41<=roots[0] ||
1.41>=roots[1] || 1.42<=roots[1]){
returnvalue-=2;
std::cerr<<"error 2: the roots of x^2-2 are wrong"<<std::endl;
}
roots.clear();
// variant for roots in a given range of a square free polynomial
solve_1((x*x-2)*(x*x-3),true, Bound(0),Bound(10),
std::back_inserter(roots));
if(roots.size()!=2){
returnvalue-=4;
std::cerr<<"error 3: the number of roots of (x^2-2)*(x^2-3)"<<
" between 0 and 10 must be 2"<<std::endl;
}
if(1.41>=roots[0] || 1.42<=roots[0] ||
1.73>=roots[1] || 1.74<=roots[1]){
returnvalue-=8;
std::cerr<<"error 4: the roots of (x^2-2)*(x^2-3)"<<
" between 0 and 10 are wrong"<<std::endl;
}
roots.clear();
// variant computing all roots with multiplicities
std::vector<std::pair<Algebraic_real_1,Multiplicity_type> > mroots;
solve_1((x*x-2), std::back_inserter(mroots));
if(mroots.size()!=2){
returnvalue-=16;
std::cerr<<"error 5: the number of roots of x^2-2 must be 2"<<
std::endl;
}
if(-1.42>=mroots[0].first || -1.41<=mroots[0].first ||
1.41>=mroots[1].first || 1.42<=mroots[1].first){
returnvalue-=32;
std::cerr<<"error 6: the roots of x^2-2 are wrong"<<std::endl;
}
if(mroots[0].second!=1 && mroots[1].second!=1){
returnvalue-=64;
std::cerr<<"error 7: the multiplicities of the"<<
" roots of x^2-2 are wrong"<<std::endl;
}
mroots.clear();
// variant computing roots with multiplicities for a range
solve_1((x*x-2)*(x*x-3),Bound(0),Bound(10),std::back_inserter(mroots));
if(mroots.size()!=2){
returnvalue-=128;
std::cerr<<"error 8: the number of roots of (x^2-2)*(x^2-3)"<<
" between 0 and 10 must be 2"<<std::endl;
}
if(1.41>=mroots[0].first || 1.42<=mroots[0].first ||
1.73>=mroots[1].first || 1.74<=mroots[1].first){
returnvalue-=256;
std::cerr<<"error 9: the roots of (x^2-2)*(x^2-3) are wrong"<<
std::endl;
}
if(mroots[0].second!=1 && mroots[1].second!=1){
returnvalue-=512;
std::cerr<<"error 10: the multiplicities of the roots of"<<
" (x^2-2)*(x^2-3) are wrong"<<std::endl;
}
typename AK::Number_of_solutions_1 nos_1 = ak.number_of_solutions_1_object();
if(nos_1(x*x*x-2)!=1){
returnvalue-=1024;
std::cerr<<"error 11: x^3-2 must have only one root"<<std::endl;
}
#ifdef CGAL_RS_TEST_LOG_TIME
std::cerr<<"*** test time: "<<(double)(clock()-start)/CLOCKS_PER_SEC<<
" seconds"<<std::endl;
#endif
return returnvalue;
}
int main(){
// We'll test three different RS-based univariate AK's:
// - the default RS one,
// - one with RS2 functions only, and
// - one with both RS2 and RS3 functions.
// the default RS kernel
typedef CGAL::Algebraic_kernel_rs_gmpz_d_1 AK_default;
typedef CGAL::Polynomial<CGAL::Gmpz> Polynomial;
typedef CGAL::Gmpfr Bound;
// the RS2-only kernel
typedef CGAL::RS2::RS2_isolator_1<Polynomial,Bound> RS2_isolator;
typedef CGAL::Bisection_refiner_1<Polynomial,Bound> B_refiner;
typedef CGAL::RS_AK1::Algebraic_kernel_1<Polynomial,
Bound,
RS2_isolator,
B_refiner> AK_RS2;
#ifdef CGAL_USE_RS3
// the RS2/RS3 kernel
typedef CGAL::RS23_k_isolator_1<Polynomial,Bound> K_isolator;
typedef CGAL::RS3::RS3_k_refiner_1<Polynomial,Bound> RS3_k_refiner;
typedef CGAL::RS_AK1::Algebraic_kernel_1<Polynomial,
Bound,
K_isolator,
RS3_k_refiner> AK_RS2_RS3;
#endif // CGAL_USE_RS3
// test all and return the result
long result=0;
std::cerr<<"*** testing default RS AK_1:";
result+=test_ak<AK_default>();
std::cerr<<"*** testing RS2 AK_1:";
result+=(2048*test_ak<AK_RS2>());
#ifdef CGAL_USE_RS3
std::cerr<<"*** testing RS2/RS3 k_AK_1:";
result+=(4096*test_ak<AK_RS2_RS3>());
#endif // CGAL_USE_RS3
std::cerr<<"*** result of the tests (should be 0): "<<result<<std::endl;
return result;
}
#else
int main(){
return 0;
}
#endif

View File

@ -10,11 +10,6 @@ if(MPFI_FOUND)
include(${MPFI_USE_FILE})
endif()
find_package(RS3 QUIET)
if(RS3_FOUND)
message(STATUS "Found RS3")
include(${RS3_USE_FILE})
endif()
# include for local directory
include_directories(BEFORE include)
@ -40,12 +35,6 @@ if(NOT CGAL_DISABLE_GMP)
create_single_source_cgal_program("Curve_pair_analysis_2.cpp")
create_single_source_cgal_program("Real_embeddable_traits_extension.cpp")
if(RS_FOUND)
create_single_source_cgal_program("Algebraic_kernel_rs_gmpq_d_1.cpp")
create_single_source_cgal_program("Algebraic_kernel_rs_gmpz_d_1.cpp")
else()
message(STATUS "NOTICE: Some tests require the RS library, and will not be compiled.")
endif()
else()
message(STATUS "NOTICE: Some tests require GMP support, and will not be compiled.")
endif()

View File

@ -330,7 +330,7 @@ template<typename Arithmetic_kernel> void test_routine() {
#endif
}
{ // More tests...just analyse some curves and compute their segments
{ // More tests...just analyze some curves and compute their segments
Poly_int2 f = from_string<Poly_int2>("P[8(0,P[8(0,24)(1,-8)(2,-162)(3,204)(4,106)(5,-340)(6,240)(7,-72)(8,8)])(1,P[6(0,-60)(1,8)(2,304)(3,-400)(4,148)(5,8)(6,-8)])(2,P[6(0,18)(1,80)(2,-165)(3,-132)(4,367)(5,-212)(6,38)])(3,P[4(0,-30)(1,-136)(2,264)(3,-72)(4,-26)])(4,P[4(0,-15)(1,36)(2,89)(3,-144)(4,49)])(5,P[2(0,30)(1,-24)(2,-6)])(6,P[2(0,-6)(1,-28)(2,22)])(8,P[0(0,3)])]");
Curve_analysis_2 curve= construct_curve_2(f);
#if CGAL_ACK_DEBUG_FLAG

View File

@ -13,7 +13,7 @@ find_package(Qt6 QUIET COMPONENTS Widgets OpenGL)
if(CGAL_Qt6_FOUND AND Qt6_FOUND)
add_definitions(-DQT_NO_KEYWORDS)
add_compile_definitions(QT_NO_KEYWORDS)
# Instruct CMake to run moc/ui/rcc automatically when needed.
set(CMAKE_AUTOMOC ON)

View File

@ -1638,7 +1638,7 @@ compute_edge_status( const Cell_handle& c,
last=ccirc;
while (is_infinite(ccirc) ) ++ccirc; //skip infinite incident cells
alpha = (*ccirc).get_alpha();
as.set_alpha_mid(alpha); // initialise as.alpha_mid to alpha value of an incident cell
as.set_alpha_mid(alpha); // initialize as.alpha_mid to alpha value of an incident cell
as.set_alpha_max(alpha); // same for as.alpha_max
while (++ccirc != last)
{

View File

@ -218,7 +218,7 @@ test_filtration(AS &A, bool verbose)
typename AS::NT alpha;
if(verbose) {
std::cerr << std::endl;
std::cerr << "Analyse filtration " << std::endl;
std::cerr << "Analyze filtration " << std::endl;
}
for (; filtre_it != filtration.end(); filtre_it++) {
if(assign(vertex, *filtre_it)) {

View File

@ -54,7 +54,7 @@ void validate(std::any & v, const std::vector<std::string> & values,
Option_parser::my_validate<Option_parser::Strategy_id>(v, values);
}
/*! Constructor */
/*! constructs */
Option_parser::Option_parser() :
m_generic_opts("Generic options"),
m_config_opts("Configuration options"),
@ -136,7 +136,7 @@ Option_parser::Option_parser() :
m_positional_opts.add("input-file", -1);
}
/*! Parse the options */
/*! parses the options */
void Option_parser::operator()(int argc, char * argv[])
{
po::store(po::command_line_parser(argc, argv).
@ -225,20 +225,20 @@ void Option_parser::operator()(int argc, char * argv[])
}
}
/*! Obtain the base file-name */
/*! obtains the base file-name */
const std::string & Option_parser::get_file_name(unsigned int i) const
{
return m_variable_map["input-file"].as<Input_path>()[i];
}
/*! Obtain the full file-name */
/*! obtains the full file-name */
const std::string & Option_parser::get_full_name(unsigned int i) const
{ return m_full_names[i]; }
/*! Obtain number of type options */
/*! obtains number of type options */
unsigned int Option_parser::get_number_opts(Type_id &)
{ return sizeof(s_type_opts) / sizeof(char *); }
/*! Obtain number of strategy options */
/*! obtains number of strategy options */
unsigned int Option_parser::get_number_opts(Strategy_id &)
{ return sizeof(s_strategy_opts) / sizeof(char *); }

View File

@ -62,17 +62,17 @@ public:
typedef Vector_strategy_id::iterator Vector_strategy_id_iter;
public:
/*! \brief obtains number of type options */
/*! obtains number of type options */
static unsigned int get_number_opts(Type_id &);
/*! \brief obtains number of strategy options */
/*! obtains number of strategy options */
static unsigned int get_number_opts(Strategy_id &);
/*! Compare the i-th type option to a given option */
/*! compares the i-th type option to a given option */
static bool compare_opt(unsigned int i, const char * opt, Type_id &)
{ return strcmp(s_type_opts[i], opt) == 0; }
/*! Compare the i-th strategy option to a given option */
/*! compares the i-th strategy option to a given option */
static bool compare_opt(unsigned int i, const char * opt, Strategy_id &)
{ return strcmp(s_strategy_opts[i], opt) == 0; }
@ -94,19 +94,19 @@ public:
Input_file_missing_error(std::string & str) : error(str) {}
};
/*! Parse the options */
/*! parses the options */
void operator()(int argc, char * argv[]);
/*! Obtain the verbosity level */
/*! obtains the verbosity level */
unsigned int get_verbose_level() const { return m_verbose_level; }
/*! Obtain the number of input files */
/*! obtains the number of input files */
unsigned int get_number_files() const { return m_number_files; }
/*! \brief obtains the base file-name */
/*! obtains the base file-name */
const std::string & get_file_name(unsigned int i) const;
/*! \brief obtains the full file-name */
/*! obtains the full file-name */
const std::string & get_full_name(unsigned int i) const;
bool get_postscript() const { return m_postscript; }
@ -117,10 +117,10 @@ public:
const char * get_strategy_name(Strategy_code id) const
{ return s_strategy_opts[id]; }
/*! Obtain the window width */
/*! obtains the window width */
unsigned int get_width() const { return m_win_width; }
/*! Obtain the window height */
/*! obtains the window height */
unsigned int get_height() const { return m_win_height; }
template <class MyId>

View File

@ -150,7 +150,7 @@
<benchArrCgalGmpqCartesianSegment print_header="1"/>
<benchArrCgalGmpqCartesianSegment/>
<benchArrCgalGmpqLazyCartesianSegment/>
<benchArrCgalGmpqLazyCartesianSegment/>
<benchArrCgalGmpqLazySimpleCartesianSegment/>
<benchArrCgalGmpqExactSegment/>
<benchArrDoubleCartesianSegment enable="false"/>
<benchArrLazyCgalGmpqCartesianSegment/>

View File

@ -20,7 +20,7 @@ if (CGAL_Qt6_FOUND AND Qt6_FOUND)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Arrangement package includes
add_definitions(-DQT_NO_KEYWORDS)
add_compile_definitions(QT_NO_KEYWORDS)
option(COMPILE_UTILS_INCREMENTALLY
"Compile files in Utils directory incrementally, or compile them all as a unit. \
Incremental compilation will be better for development and consume less \

View File

@ -111,13 +111,10 @@ void CurveInputMethod::beginInput_()
static inline void clearPainterPath(QPainterPath& ppath)
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 13, 0))
ppath.clear();
#else
ppath = {};
#endif
}
void CurveInputMethod::reset()
{
this->resetInput();

View File

@ -67,11 +67,7 @@ void GridGraphicsItem::setSpacing(int spacing_)
static inline qreal
horizontalAdvance(const QFontMetrics& fm, const QString& text)
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
return fm.horizontalAdvance(text);
#else
return fm.boundingRect(text).width();
#endif
}
void GridGraphicsItem::paint(

View File

@ -40,7 +40,7 @@ namespace {
Flag(bool init) : v{ init } {}
};
// EXTENDED AOS for analysing the arrangement
// EXTENDED AOS for analyzing the arrangement
using Ext_dcel = CGAL::Arr_extended_dcel<Geom_traits, Flag, Flag, Flag>;
using Ext_topol_traits =
CGAL::Arr_spherical_topology_traits_2<Geom_traits, Ext_dcel>;

View File

@ -39,7 +39,7 @@ endif()
add_definitions(-DQT_NO_VERSION_TAGGING)
add_compile_definitions(QT_NO_VERSION_TAGGING)
# AOS
file(GLOB source_files_aos Aos.h Aos.cpp Aos_defs.h

View File

@ -168,7 +168,8 @@ Remarks
of segments in all the polylines together. The same holds for the
more general type <em>polycurve</em>, which are piecewise curves
that are not necessarily linear; see Section \ref
arr_sssectr_polycurves. </li>
arr_sssectr_polycurves.
</li>
</ol>
@ -1188,7 +1189,7 @@ functions are of little use. However, you should keep in mind that
there may be extraneous data (probably non-geometric) associated with
the point objects or with the curve objects, as defined by the traits
class. With these two functions you can modify this data; see more
details in Section \ref arr_ssecmeta_tr. In addition, you can use
details in Section \ref arr_sssec_tr_data_decorators. In addition, you can use
these functions to replace a geometric object (a point or a curve)
with an equivalent object that has a more compact representation. For
example, if we use some simple rational-number type to represent the
@ -1435,14 +1436,15 @@ vary according to the user choice.} for answering queries:
points or choosing points on a grid, are also available; see the
Reference Manual for more details.
The landmark strategy requires that the type of the attached
arrangement be an instance of the `Arrangement_2<Traits,Dcel>` class
template, where the `Traits` parameter is substituted by a
geometry-traits class that models the `AosLandmarkTraits_2`
concept, which refines the basic `AosBasicTraits_2` concept;
see Section \ref aos_sssec-tr_landmarks_concept for details. Most
traits classes included in the \ref PkgArrangementOnSurface2 package
are models of this refined concept.
The arrangement attached to the landmark strategy must be either (i)
an instance of the `Arrangement_2<GeomTraits,Dcel>` class template,
where the `GeomTraits` parameter is substituted by a geometry-traits
class that models the `AosLandmarkTraits_2` concept, or (ii) an
instance of the `Arrangement_on_surface_2<GeomTraits,TopolTraits>`
class template, where the `GeomTraits` is similarly substituted;
see Section \ref aos_sssec-tr_landmarks_concept for details about
this concept. Most traits classes included in the \ref
PkgArrangementOnSurface2 package are models of this refined concept.
<LI>`Arr_trapezoid_ric_point_location<Arrangement>` implements an
improved variant of Mulmuley's point-location algorithm
@ -1489,7 +1491,7 @@ educational purposes, and thus we do not elaborate on this strategy.
The data structure needed by the landmark and the trapezoidal map RIC
strategies can be constructed in \cgalBigO{N \log N} time, where \f$N\f$
is the overall number of edges in the arrangement, but the constant
hidden in the \cgalBigO{&nbsp;} notation for the trapezoidal map RIC strategy
hidden in the \cgalBigO{~} notation for the trapezoidal map RIC strategy
is much larger. Thus, construction needed by the landmark algorithm is
in practice significantly faster than the construction needed by the
trapezoidal map RIC strategy. In addition, although both resulting
@ -2035,8 +2037,8 @@ so it must be construct from scratch.
In the first case, we sweep over the input curves, compute their
intersection points, and construct the \dcel that represents their
arrangement. This process is performed in \cgalBigO{left((n + k)\log
n\right} time, where \f$k\f$ is the total number of intersection
arrangement. This process is performed in \cgalBigO{(n + k)\log
n} time, where \f$k\f$ is the total number of intersection
points. The running time is asymptotically better than the time needed
for incremental insertion if the arrangement is relatively sparse
(when \f$k\f$ is \cgalBigO{\frac{n^2}{\log n}}), but it is recommended
@ -3530,6 +3532,10 @@ The concept `AosConstructCurveTraits_2` refines the concept
must support the operation below (in addition to fulfilling the
requirements listed by the `AosBasicTraits_2` concept).
<!-- ----------------------------------------------------------------------- -->
\subsubsection aos_sssec-tr_additional_concepts The Construct Curve Concept
<!-- ----------------------------------------------------------------------- -->
<DL>
<DT>\link AosConstructCurveTraits_2::Construct_curve_2 <B>`Construct_curve_2`</B>\endlink:
<DD> Given two points \f$p_1\f$ and \f$p_2\f$, construct
@ -4398,12 +4404,13 @@ size \f$m\f$ typically take \cgalBigO{\log m} time.
You are free to choose the underlying segment traits class. Your
decision could be based, for example, on the number of expected
intersection points; see Section \ref arr_ssectr_segs. Moreover, it
is possible to substitute the `SubcurveTraits_2` template parameter
with a traits class that handles segments with some additional data
attached to each individual segment; see Section
\ref arr_ssecmeta_tr. This makes it possible to associate different
data objects with the different segments that compose a polyline.
intersection points; see Section \ref arr_ssectr_segs. Moreover, it is
possible to substitute the `SubcurveTraits_2` template parameter with
a traits class that handles segments with some additional data
attached to each individual segment; see Section \ref
arr_sssec_tr_data_decorators. This makes it possible to associate
different data objects with the different segments that compose a
polyline.
<!-- ----------------------------------------------------------------------- -->
\cgalFigureBegin{aos_fig-polylines,polylines.png}
@ -5513,7 +5520,17 @@ with source endpoint and ending at the target endpoint.
<!-- ----------------------------------------------------------------------- -->
<!-- ----------------------------------------------------------------------- -->
\subsection arr_ssecmeta_tr Traits-Class Decorators
\subsection arr_ssec_tr_decorators Traits-Class Decorators
<!-- ----------------------------------------------------------------------- -->
Decorator is a structural pattern that allows adding new behaviors to
objects by placing them inside special wrapper objects, called
decorators. One type of decorators attaches auxiliary data to the
geometric objects handled by the original traits. Another type enables
the retrieval of debugging and informative metadata.
<!-- ----------------------------------------------------------------------- -->
\subsubsection arr_sssec_tr_data_decorators Data Decorators
<!-- ----------------------------------------------------------------------- -->
Geometric traits-class decorators allow you to attach auxiliary data
@ -5687,6 +5704,33 @@ the curve-data traits:
\cgalExample{Arrangement_on_surface_2/dual_with_data.cpp}
<!-- ----------------------------------------------------------------------- -->
\subsubsection arr_sssec_tr_metadata_decorators Metadata Decorators
<!-- ----------------------------------------------------------------------- -->
The package provides two traits-class decorators, namely
`Arr_counting_traits_2<BaseTraits>` and
`Arr_tracing_traits_2<BaseTraits>`, that can be used to insert
debugging and informative metadata to an output stream. The former is
used to count the number of invocations of traits-class functors, and
the latter is used to trace these invocations. Note that the
constructors of each of these class templates apply perfect
forwarding. The counting traits also exports the count of traits-class
objects of specific types constructed during the execution of the
program. The tracing traits supports filtering of traced functors. The
calls `traits.enable_trace(id)` and `traits.disable_trace(id)` enables
and disables the tracing of a functor identified by `id`,
respectively. A functor is identified by an enumeration. For example,
the functor \link AosTraits_2::Make_x_monotone_2
`Make_x_monotone_2`\endlink is identified by the enumeration
`Arr_tracing_traits_2::MAKE_X_MONOTONE_OP`. The calls
`traits.enable_all_traces()` and `traits.disable_all_traces()` enables
and disables the traces of all functors, respectively. The example
program listed below demonstrates the use of both of these metadata
decorators.
\cgalExample{Arrangement_on_surface_2/count_and_trace.cpp}
<!-- ======================================================================= -->
\section aos_sec-topol_traits The Topology Traits
<!-- ======================================================================= -->
@ -5919,7 +5963,7 @@ edges (halfedge pairs) are associated with \link
Arrangement_on_surface_2::X_monotone_curve_2
`X_monotone_curve_2`\endlink objects, both defined by the traits
class. Extending the geometric traits-class types by using a
traits-class decorator, as explained in Section \ref arr_ssecmeta_tr,
traits-class decorator, as explained in Section \ref arr_ssec_tr_decorators,
might be a sufficient solution for some applications. However, the
\dcel faces are not associated with any geometric object, so
traits-class decorators cannot help here. Extending the \dcel face
@ -6136,7 +6180,7 @@ The overlay of two given arrangements, conveniently referred to as the
algorithm employing a dedicated visitor; see Section
\ref arr_ssec_sweep. The \f$x\f$-monotone curve type is extended with
a color attribute (whose value is either blue or red); see Section \ref
arr_ssecmeta_tr. With the help of the extended type unnecessary
arr_ssec_tr_decorators. With the help of the extended type unnecessary
computations are filtered out while the plane is swept, yielding an
efficient process. For example, monochromatic intersections are not
computed.

View File

@ -5,8 +5,8 @@ namespace CGAL {
* The traits class `Arr_algebraic_segment_traits_2` is a model of the
* `AosTraits_2` concept that handles planar algebraic curves of arbitrary
* degree, and \f$x\f$-monotone of such curves. A planar (real) <I>algebraic
* curve</I> is the vanishing set of a polynomial in two variables, that is, the
* curve is defined by the defining equation
* curve</I> is the vanishing set of a polynomial in two variables, that is,
* the curve is defined by the defining equation
* \f[f(x):=\sum_{i+j\leq n} a_{ij} x^i y^j =0, \f] where \f$n\f$ is the
* degree of the curve.
*
@ -20,9 +20,11 @@ namespace CGAL {
*
* \cgalModels{AosTraits_2}
*/
template <typename Coefficient>
class Arr_algebraic_segment_traits_2 {
public:
/// \name Types
/// @{
@ -39,7 +41,8 @@ public:
*/
typedef unspecified_type Polynomial_2;
/// model for the concept `AlgebraicKernel_1`
/*! model for the concept `AlgebraicKernel_1`
*/
typedef unspecified_type Algebraic_kernel_1;
/*! represents coordinates of points.
@ -55,13 +58,16 @@ public:
/// \name Accessing functor objects
/// @{
///
/*!
*/
Construct_curve_2 construct_curve_2_object() const;
///
/*!
*/
Construct_point_2 construct_point_2_object() const;
///
/*!
*/
Construct_x_monotone_segment_2 construct_x_monotone_segment_2_object() const;
/// @}
@ -73,15 +79,15 @@ public:
/// \name Object Creation Functors
/// @{
/*! Returns a `Curve_2` object that represents the curve defined by the
* polynomial `p`.
/*! returns a `Curve_2` object that represents the curve defined by the
* polynomial `p`
*/
Curve_2 operator() (Polynomial_2 p);
/*! Returns a `Curve_2` object specified by `s`. The passed string
* represents the defining polynomial of the curve and must be given in a
* MAPLE-readable format using "x" as first and "y" as second variable,
* e.g., \f$(x^3*y-2*x)*(-6*x-y^3*x^6)\f$ for integer coefficients, and
/*! returns a `Curve_2` object specified by `s`. The passed string represents
* the defining polynomial of the curve and must be given in a MAPLE-readable
* format using "x" as first and "y" as second variable, e.g.,
* \f$(x^3*y-2*x)*(-6*x-y^3*x^6)\f$ for integer coefficients, and
* \f$3/2*x*y^4-5/7*x^2+3/1\f$ for rational coefficients.
*/
Curve_2 operator() (std::string s);
@ -97,36 +103,36 @@ public:
/// \name Object Creation Functors
/// @{
/*! Returns a `Point_2` object that represents the `arcno`-th
/*! returns a `Point_2` object that represents the `arcno`-th
* point in the fiber of `cv` at \f$x\f$-coordinate `x`,
* counted from the bottom, starting with zero.
*
* \pre `cv` must not have a vertical line at `x`,
* \pre (`cv` must not have a vertical line at `x`,
* and \f$0\leq arcno < c\f$, where \f$ c\f$ is the number of points
* in the fiber of `cv` at `x`.
* in the fiber of `cv` at `x`.)
*/
Point_2 operator()(Algebraic_real_1 x, Curve_2 cv, int arcno);
/*! Returns a `Point_2` object that represents the point on
* `xcv` at \f$x\f$-coordinate `x`
/*! returns a `Point_2` object that represents the
* point on `xcv` at \f$x\f$-coordinate `x`
*
* \pre `x` is in the \f$x\f$-range of `xcv`.
* \pre (`x` is in the \f$x\f$-range of `xcv`.)
*/
Point_2 operator()(Algebraic_real_1 x, X_monotone_curve_2 xcv);
/*! Returns a `Point_2` object that represents (x,y)
/*! returns a `Point_2` object that represents (x,y)
*/
Point_2 operator()(Algebraic_real_1 x, Algebraic_real_1 y);
/*! Returns a `Point_2` object that represents (x,y)
/*! returns a `Point_2` object that represents (x,y)
*/
Point_2 operator()(Coefficient x, Coefficient y);
/*! Returns a `Point_2` object that represents (x,y)
/*! returns a `Point_2` object that represents (x,y)
*/
Point_2 operator()(Bound x, Bound y);
/*! Returns a `Point_2` object that represents (x,y)
/*! returns a `Point_2` object that represents (x,y)
*/
Point_2 operator()(int x, int y);
@ -141,10 +147,10 @@ public:
/// \name Object Creation Functors
/// @{
/*! inserts a sequence of `X_monotone_curve_2` objects (terminal segments)
* into an output container given through an output iterator. These terminal
* segments compose an \f$x\f$-monotone (or vertical) segment of a given
* curve that starts in `end_min`, and ends in `end_max`.
/*! inserts a sequence of `X_monotone_curve_2` objects (terminal segments) into
* an output container given through an output iterator. These terminal segments
* compose an \f$x\f$-monotone (or vertical) segment of a given curve that
* starts in `end_min`, and ends in `end_max`.
*
* \param cv The input curve.
* \param end_min The starting point.
@ -152,18 +158,18 @@ public:
* \param oi The output iterator that points at the output container.
* \return The past-the-end iterator of the output container.
*
* \pre `end_min` must have a unique \f$x\f$-monotone segment to its right,
* or `end_max` must have a unique \f$x\f$-monotone segment to its
* \pre `end_min` must have a unique \f$x\f$-monotone segment to its right, or
* `end_max` must have a unique \f$x\f$-monotone segment to its left.
* Furthermore, `end_min` and `end_max` must be connected by an
* left. \f$x\f$-monotone segment of `cv`)
* \f$x\f$-monotone segment of `cv`)
*/
template <typename OutputIterator>
OutputIterator operator()(Curve_2 cv, Point_2 end_min, Point_2 end_max,
OutputIterator oi);
/*! inserts a sequence of `X_monotone_curve_2` objects into an output
* container given through an output iterator. These segments form an
* \f$x\f$-monotone (or vertical) segment of the curve `cv`.
/*! inserts a sequence of `X_monotone_curve_2` objects into an output container
* given through an output iterator. These segments form an \f$x\f$-monotone
* (or vertical) segment of the curve `cv`.
*
* If `site_of_p` == `POINT_IN_INTERIOR`, the maximal segment that contains
* `p` in its interior is returned .
@ -178,12 +184,10 @@ public:
* of an \f$x\f$-monotone or a vertical segment.
*
* \pre If `site_of_p` == `MIN_ENDPOINT`, `p` must either have a unique
* \f$x\f$-monotone segment to the right, or a vertical segment from `p`
* upwards.
* \f$x\f$-monotone segment to the right, or a vertical segment from `p` upwards.
*
* \pre If `site_of_p` == `MAX_ENDPOINT`, `p` must either have a unique
* \f$x\f$-monotone segment to the left, or a vertical segment from `p`
* downwards.
* \f$x\f$-monotone segment to the left, or a vertical segment from `p` downwards.
*/
template <typename OutputIterator>
OutputIterator operator()(Curve_2 cv, Point_2 p, Site_of_point site_of_p,
@ -195,7 +199,7 @@ public:
* share the same \f$x\f$-coordinate, the constructed vertical segment
* consists of only one `X_monotone_curve_2` object and can be computed
* efficiently. In the non-vertical case, the construction is only possible
* if `p` and `q` have both rational x- and y-coordinates.
* if `p` and `q` have both rational \f$x\f$- and \f$y\f$-coordinates.
*
* \pre `p` must not be equal to `q`.
*/
@ -205,7 +209,7 @@ public:
/// @}
}; /* end Arr_algebraic_segment_traits_2::Construct_x_monotone_segment_2 */
/*! Models the `AosTraits_2::Curve_2` concept.
/*! A model of the the `AosTraits_2::Curve_2` concept.
* Represents algebraic curves. Internally, the type stores
* topological-geometric information about the particular curve.
* In order to use internal caching, instances should only be created
@ -213,6 +217,7 @@ public:
*/
class Curve_2 {
public:
/// \name Modifiers
/// @{
@ -221,9 +226,10 @@ public:
Polynomial_2 polynomial() const;
/// @}
}; /* end Arr_algebraic_segment_traits_2::Curve_2 */
/*! Models the `AosBasicTraits_2::Point_2` concept.
/*! A model of the `AosBasicTraits_2::Point_2` concept.
* Represents points in \f$\mathbb{R}^2\f$. Intersection points of algebraic
* curves are in general non-rational, so we need a data structure that is
* capable of representing arbitrary points with algebraic coordinates.
@ -237,8 +243,8 @@ public:
* point when shooting a vertical ray at \f$x\f$, starting from \f$-\infty\f$
* (where counting starts with \f$0\f$).
*
* In addition to the methods listed below, the copy constructor and
* assignment operator for `Point_2` objects are also supported.
* In addition to the methods listed below, the copy constructor and assignment
* operator for `Point_2` objects are also supported.
*
* The functor `Construct_point_2` constructs `Point_2` instances.
*/
@ -275,9 +281,10 @@ public:
std::pair<double,double> to_double() const;
/// @}
}; /* end Arr_algebraic_segment_traits_2::Point_2 */
/*! Models the `AosBasicTraits_2::X_monotone_curve_2` concept.
/*! A model of the `AosBasicTraits_2::X_monotone_curve_2` concept.
* Represents terminal segments of an algebraic curves, that means vertical
* segments or \f$x\f$-monotone segments with no critical \f$x\f$-coordinate
* in the interior of their \f$x\f$-range. Terminal segments might either be
@ -297,6 +304,7 @@ public:
*/
class X_monotone_curve_2 {
public:
/// \name Modifiers
/// @{
@ -312,23 +320,23 @@ public:
*/
bool is_finite(CGAL::Arr_curve_end ce) const;
/*! \pre The corresponding curve end is finite.
/*! \pre (The corresponding curve end is finite)
*/
Point_2 curve_end(CGAL::Arr_curve_end ce) const;
/*! returns the arc number of the segment.
*
* \pre The segment is non-vertical.
* \pre (The segment is non-vertical)
*/
int arcno() const;
/*! returns the \f$x\f$-coordinate of a vertical segment.
*
* \pre The segment is vertical.
* \pre (The segment is vertical)
*/
Algebraic_real_1 x() const;
/// @}
}; /* end Arr_algebraic_segment_traits_2::X_monotone_curve_2 */
}; /* end Arr_algebraic_segment_traits_2 */

View File

@ -49,10 +49,10 @@ public:
/// \name Creation
/// @{
/*! Default constructor. */
/*! constructs default */
Arr_bounded_planar_topology_traits_2();
/*! Constructor from a geometry-traits object.
/*! constructs from a geometry-traits object.
* \param traits the traits.
*/
Arr_bounded_planar_topology_traits_2(const GeometryTraits_2* traits);
@ -62,16 +62,16 @@ public:
/// \name Accessors
/// @{
/*! Obtain the \dcel (const version). */
/*! obtains the \dcel (const version). */
const Dcel& dcel() const;
/*! Obtain the \dcel (non-const version). */
/*! obtains the \dcel (non-const version). */
Dcel& dcel();
/*! Obtain the unbounded face (const version). */
/*! obtains the unbounded face (const version). */
const Face* unbounded_face() const;
/*! Obtain the unbounded face (non-const version). */
/*! obtains the unbounded face (non-const version). */
Face* unbounded_face();
/// @}

View File

@ -184,7 +184,7 @@ public:
/// \name Creation
/// @{
/*! default constructor.
/*! constructs default
*/
Point_2();
@ -315,7 +315,7 @@ public:
/// \name Creation
/// @{
/*! Trims the given x-monotone curve to an from src to tgt.
/*! trims the given x-monotone curve to an from src to tgt.
* \ pre `src` and `tgt` lies on the curve
*/
X_monotone_curve_2(const X_monotone_curve_2& xcv,

View File

@ -254,11 +254,11 @@ public:
/// \name Creation
/// @{
/*! construct a default point.
/*! constructs a default point.
*/
Point_2();
/*! construct a point from an algebraic point.
/*! constructs a point from an algebraic point.
*/
Point_2(const typename Alg_kernel::Point_2& p);
@ -396,7 +396,7 @@ public:
*/
X_monotone_curve_2 operator()(const Curve_2& cv) const;
/*! Constructs an \f$x\f$-monotone curve connecting the two given endpoints.
/*! constructs an \f$x\f$-monotone curve connecting the two given endpoints.
* \param source The first point.
* \param target The second point.
* \pre `source` and `target` must not be the same.
@ -405,7 +405,7 @@ public:
X_monotone_curve_2 operator()(const Point_2& source,
const Point_2& target) const;
/*! Constructs a special segment of a given line connecting to given
/*! constructs a special segment of a given line connecting to given
* endpoints.
* \param a, b, c The coefficients of the supporting line
* (\f$ax + by + c = 0\f$).
@ -425,20 +425,21 @@ public:
*/
class Construct_bbox_2 {
public:
/*! Obtain a bounding box for a conic arc.
/*! obtains a bounding box for a conic arc.
* \param cv The conic arc.
* \return The bounding box.
*/
Bbox_2 operator()(const Curve_2& cv) const { return bbox(cv); }
/*! Obtain a bounding box for an \f$x\f$-monotone conic arc.
/*! obtains a bounding box for an \f$x\f$-monotone conic arc.
* \param xcv The \f$x\f$-monotone conic arc.
* \return The bounding box.
*/
Bbox_2 operator()(const X_monotone_curve_2& xcv) const { return bbox(xcv); }
};
/*! \name Auxiliary Functor definitions.
/*! \name Auxiliary Functor definitions, used for, e.g., the landmarks \
* point-location strategy and the drawing function.
*/
/// @{
typedef double Approximate_number_type;
@ -451,7 +452,7 @@ public:
*/
class Trim_2 {
public:
/*! Trims the given \f$x\f$-monotone arc to new endpoints.
/*! trims the given \f$x\f$-monotone arc to new endpoints.
* \param xcv The \f$x\f$-monotone arc
* \param source The new source point.
* \param target The new target point.
@ -460,22 +461,21 @@ public:
X_monotone_curve_2 operator()(const X_monotone_curve_2& xcv,
const Point_2& source,
const Point_2& target) const;
};
/// \name Accessing Functor Objects
/// @{
/*! Obtain a `Construct_curve_2` functor. */
/*! obtains a `Construct_curve_2` functor. */
Construct_curve_2 construct_curve_2_object() const;
/*! Obtain a `Construct_x_monotone_curve_2` functor. */
/*! obtains a `Construct_x_monotone_curve_2` functor. */
Construct_x_monotone_curve_2 construct_x_monotone_curve_2_object() const;
/*! Obtain a `Bbox_2` functor. */
/*! obtains a `Bbox_2` functor. */
Construct_bbox_2 construct_bbox_2_object() const;
/*! Obtain a `Trim_2` functor. */
/*! obtains a `Trim_2` functor. */
Trim_2 trim_2_object() const;
/// @}

View File

@ -3,11 +3,12 @@ namespace CGAL {
/*! \ingroup PkgArrangementOnSurface2TraitsClasses
*
* The class `Arr_consolidated_curve_data_traits_2` is a model of the concept
* `AosTraits_2`, and serves as a decorator class that enables the extension of
* the curve type defined by the `Traits` parameter. The traits class inherits
* its point type from `Traits::Point_2`, and defines the types `Curve_2` and
* `X_monotone_curve_2` extended with extraneous data fields of type `Data`.
* `AosTraits_2`, and serves as a decorator class that enables the
* extension of the curve type defined by the `Traits` parameter. The traits
* class inherits its point type from `Traits::Point_2`, and defines the types
* `Curve_2` and `X_monotone_curve_2` extended with extraneous data fields of
* type `Data`.
*
* Each `Curve_2` object is associated with a single data field of type `Data`,
* and each `X_monotone_curve_2` object is associated with a set of unique data
* objects. When a curve is subdivided into \f$x\f$-monotone subcurves, all
@ -17,7 +18,7 @@ namespace CGAL {
* resulting subcurves. In case two (or more) \f$x\f$-monotone curves overlap,
* their data sets are consolidated, and are inserted into the set of the
* \f$x\f$-monotone curve that represents the overlap.
*
* \cgalModels{AosTraits_2}
*/
template <typename Traits, typename Data>
@ -28,19 +29,19 @@ public:
/// \name Types
/// @{
/// the base traits-class.
//! the base traits-class.
typedef Traits Base_traits_2;
/// the base curve.
//! the base curve.
typedef typename Base_traits_2::Curve_2 Base_curve_2;
/// the base \f$x\f$-monotone curve curve.
//! the base \f$x\f$-monotone curve curve.
typedef typename Base_traits_2::X_monotone_curve_2 Base_x_monotone_curve_2;
/// a set of data objects that is associated with an \f$x\f$-monotone curve.
//! a set of data objects that is associated with an \f$x\f$-monotone curve.
typedef unspecified_type typedef Data_container;
/// a non-mutable iterator for the data objects in the data container.
//! a non-mutable iterator for the data objects in the data container.
typedef unspecified_type typedef Data_iterator;
/// @}
@ -57,7 +58,7 @@ public:
/// \name Creation
/// @{
/*! default constructor.
/*! constructs default.
*/
Data_container();
@ -83,11 +84,13 @@ public:
Data_iterator end() const;
/*! returns the first data object inserted into the set.
*
* \pre The number of data objects is not \f$0\f$.
*/
const Data& front() const;
/*! returns the last data object inserted into the set.
*
* \pre The number of data objects is not \f$0\f$.
*/
const Data& back() const;
@ -97,12 +100,12 @@ public:
/// \name Predicates
/// @{
/*! check if the two sets contain the same data objects
* (regardless of order).
/*! checks whether the two sets contain the same data objects (regardless of
* order).
*/
bool operator==(const Data_container& other) const;
/*! find the given `data` object in the set and returns an iterator
/*! finds the given `data` object in the set and returns an iterator
* for this object, or `end()` if it is not found.
*/
Data_iterator find(const Data& data);

View File

@ -0,0 +1,145 @@
// Copyright (c) 2005,2007,2009,2010,2011 Tel-Aviv University (Israel).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
//
// $URL$
// $Id$
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
//
// Author(s): Efi Fogel <efif@post.tau.ac.il>
// Eric Berberich <ericb@post.tau.ac.il>
namespace CGAL {
/*! \ingroup PkgArrangementOnSurface2TraitsClasses
*
* A metadata traits-class decorator for the arrangement package. It counts the
* number of invocations of traits-class functors. It is parameterized with
* another traits class and inherits from it. For each traits method it
* maintains a counter that counts the number of invocations into the method.
*
* It models all the concepts that the original traits models.
*/
template <typename BaseTraits>
class Arr_counting_traits_2 : public BaseTraits {
public:
enum Operation_id {
COMPARE_X_2_OP = 0,
COMPARE_XY_2_OP,
CONSTRUCT_MIN_VERTEX_2_OP,
CONSTRUCT_MAX_VERTEX_2_OP,
IS_VERTICAL_2_OP,
COMPARE_Y_AT_X_2_OP,
EQUAL_2_POINTS_OP,
EQUAL_2_CURVES_OP,
COMPARE_Y_AT_X_LEFT_2_OP,
COMPARE_Y_AT_X_RIGHT_2_OP,
MAKE_X_MONOTONE_2_OP,
SPLIT_2_OP,
INTERSECT_2_OP,
ARE_MERGEABLE_2_OP,
MERGE_2_OP,
CONSTRUCT_2_OPPOSITE_2_OP,
COMPARE_ENDPOINTS_XY_2_OP,
APPROXIMATE_2_COORD_OP,
APPROXIMATE_2_POINT_OP,
APPROXIMATE_2_CURVE_OP,
PARAMETER_SPACE_IN_X_2_CURVE_END_OP,
PARAMETER_SPACE_IN_X_2_POINT_OP,
IS_ON_X_IDENTIFICATION_POINT_2_OP,
IS_ON_X_IDENTIFICATION_CURVE_2_OP,
COMPARE_Y_ON_BOUNDARY_2_OP,
COMPARE_Y_NEAR_BOUNDARY_2_OP,
PARAMETER_SPACE_IN_Y_2_CURVE_END_OP,
PARAMETER_SPACE_IN_Y_2_POINT_OP,
IS_ON_Y_IDENTIFICATION_2_POINT_OP,
IS_ON_Y_IDENTIFICATION_2_CURVE_OP,
COMPARE_X_ON_BOUNDARY_2_POINTS_OP,
COMPARE_X_ON_BOUNDARY_2_POINT_CURVE_END_OP,
COMPARE_X_ON_BOUNDARY_2_CURVE_ENDS_OP,
COMPARE_X_NEAR_BOUNDARY_2_OP,
NUMBER_OF_OPERATIONS
};
/// \name Creation
/// @{
/*! constructs default */
template <typename ... Args>
Arr_counting_traits_2(Args ... args) : Base(std::forward<Args>(args)...) {}
/*! disables copy constructor. */
Arr_counting_traits_2(const Arr_counting_traits_2&) = delete;
/// @}
/*! obtains the counter of the given operation */
std::size_t count(Operation_id id) const;
/*! prints the counter associated with an operation. */
template <typename OutStream>
OutStream& print(OutStream& os, Operation_id id) const;
/// \name Types and functors inherited from `BaseTraits`
/// @{
using Has_left_category = typename Base::Has_left_category;
using Has_merge_category = typename Base::Has_merge_category;
using Has_do_intersect_category = typename Base::Has_do_intersect_category;
using Left_side_category =
typename internal::Arr_complete_left_side_category<Base>::Category;
using Bottom_side_category =
typename internal::Arr_complete_bottom_side_category<Base>::Category;
using Top_side_category =
typename internal::Arr_complete_top_side_category<Base>::Category;
using Right_side_category =
typename internal::Arr_complete_right_side_category<Base>::Category;
using Point_2 = typename Base::Point_2;
using X_monotone_curve_2 = typename Base::X_monotone_curve_2;
using Curve_2 = typename Base::Curve_2;
/// @}
/// \name Obtain the appropriate functor
/// @{
Compare_x_2 compare_x_2_object() const;
Compare_xy_2 compare_xy_2_object() const;
Construct_min_vertex_2 construct_min_vertex_2_object() const;
Construct_max_vertex_2 construct_max_vertex_2_object() const;
Is_vertical_2 is_vertical_2_object() const;
Compare_y_at_x_2 compare_y_at_x_2_object() const;
Equal_2 equal_2_object() const;
Compare_y_at_x_left_2 compare_y_at_x_left_2_object() const;
Compare_y_at_x_right_2 compare_y_at_x_right_2_object() const;
Make_x_monotone_2 make_x_monotone_2_object() const;
Split_2 split_2_object() const;
Intersect_2 intersect_2_object() const;
Are_mergeable_2 are_mergeable_2_object() const;
Merge_2 merge_2_object() const;
Construct_opposite_2 construct_opposite_2_object() const;
Compare_endpoints_xy_2 compare_endpoints_xy_2_object() const;
Approximate_2 approximate_2_object() const;
Parameter_space_in_x_2 parameter_space_in_x_2_object() const;
Is_on_x_identification_2 is_on_x_identification_2_object() const;
Compare_y_on_boundary_2 compare_y_on_boundary_2_object() const;
Compare_y_near_boundary_2 compare_y_near_boundary_2_object() const;
Parameter_space_in_y_2 parameter_space_in_y_2_object() const;
Is_on_y_identification_2 is_on_y_identification_2_object() const;
Compare_x_on_boundary_2 compare_x_on_boundary_2_object() const;
Compare_x_near_boundary_2 compare_x_near_boundary_2_object() const;
/// @}
/*! cleans all operation counters */
void clear_counters();
};
template <typename OutStream, class BaseTraits>
inline OutStream& operator<<(OutStream& os,
const Arr_counting_traits_2<BaseTraits>& traits);
} // namespace CGAL

View File

@ -88,8 +88,7 @@ public:
/// \name Creation
/// @{
/*! default constructor.
*/
/*! constructs default */
Curve_2();
/*! constructs curve from the given `base` curve with uninitialized
@ -127,8 +126,7 @@ public:
/// \name Creation
/// @{
/*! default constructor.
*/
/*! constructs default */
X_monotone_curve_2();
/*! constructs an \f$x\f$-monotone curve from the given `base` curve with
@ -136,8 +134,8 @@ public:
*/
X_monotone_curve_2(const Base_x_monotone_curve_2& base);
/*! constructs an \f$x\f$-monotone curve from the given `base` \f$
* x\f$-monotone curve with an attached `data` field.
/*! constructs an \f$x\f$-monotone curve from the given `base`
* \f$x\f$-monotone curve with an attached `data` field.
*/
X_monotone_curve_2(const Base_x_monotone_curve_2& base,
const X_monotone_curve_data& data);

View File

@ -81,7 +81,7 @@ public:
/// \name Creation
/// @{
/*! Constructs a point from a direction and a location.
/*! constructs a point from a direction and a location.
* \param[in] dir the direction.
* \param[in] location indicates the location of the point pre-image
* in the parameter space.
@ -93,13 +93,13 @@ public:
/// \name Operations
/// @{
/*! Set the location of the point pre-image in the parameter space.
/*! sets the location of the point pre-image in the parameter space.
* \param[in] location the updated location of the point pre-image in
* the parameter space.
*/
void set_location(Location_type location);
/*! Obtain the location of the point.
/*! obtains the location of the point.
* \return the location of the point pre-image in the parameter space.
*/
Location_type location() const;
@ -125,7 +125,7 @@ public:
/// \name Creation
/// @{
/*! Constructs an \f$x\f$-monotone geodesic arc.
/*! constructs an \f$x\f$-monotone geodesic arc.
* \param[in] source the source point of the arc.
* \param[in] target the target point of the arc.
* \param[in] normal the normal of the plane that contains the arc.
@ -134,6 +134,7 @@ public:
* \param[in] is_full is the arc a full great circle?
* \param[in] is_degenerate is the arc degenerate (single point)?
* \param[in] is_empty is the arc empty?
*
* \pre Both endpoints lie on the given plane.
*/
X_monotone_curve_2(const Point_2& source,
@ -145,19 +146,21 @@ public:
bool is_degenerate = false,
bool is_empty = false);
/*! Construct an \f$x\f$-monotone geodesic arc.
/*! constructs an \f$x\f$-monotone geodesic arc.
* \param[in] normal the normal of the plane containing the arc.
* \param[in] source the source-point direction.
* \param[in] target the target-point direction.
*
* \pre Both endpoints lie on the given plane.
*/
X_monotone_curve_2(const Point_2& source,
const Point_2& target,
const Direction_3& normal);
/*! Construct a full great-circle.
/*! constructs a full great-circle.
* \param[in] point the endpoint of the full great-circle.
* \param[in] normal the normal of the plane containing the arc.
*
* \pre the point lies on the given plane.
* \pre the point pre-image lies on the identified left and right sides
* of the boundary of the parameter space.
@ -170,66 +173,66 @@ public:
/// \name Operations
/// @{
/*! Sets the source endpoint.
/*! sets the source endpoint.
* \param[in] source the updated source endpoint.
*/
void set_source(const Point_2& source);
/*! Sets the target endpoint.
/*! sets the target endpoint.
* \param[in] target the updated target endpoint.
*/
void set_target(const Point_2& target);
/*! Sets the normal of the underlying plane.
/*! sets the normal of the underlying plane.
* \param[in] normal the updated normal of the underlying plane.
*/
void set_normal(const Direction_3& normal);
/*! Sets the flag that indicates whether the arc is vertical.
/*! sets the flag that indicates whether the arc is vertical.
* \param[in] flag indicates whether the arc pre-image in the parameter
* space is vertical.
*/
void set_is_vertical(bool flag);
/*! Sets the flag that indicates whether the direction of the arc
/*! sets the flag that indicates whether the direction of the arc
* pre-image in the parameter space is from left to right.
* \param flag indicates whether the arc pre-image in the parameter
* space is from left to right.
*/
void set_is_directed_right(bool flag);
/*! Sets the flag that indicates whether the arc is a full great circle.
/*! sets the flag that indicates whether the arc is a full great circle.
* \param[in] flag indicates whether the arc is a full great circle.
*/
void set_is_full(bool flag);
/*! Sets the flag that indicates whether the arc degenerates to a point.
/*! sets the flag that indicates whether the arc degenerates to a point.
* \param[in] flag indicates whether the arc degenerates to a point.
*/
void set_is_degenerate(bool flag);
/*! Sets the flag that indicates whether the arc is empty.
/*! sets the flag that indicates whether the arc is empty.
* \param[in] flag indicates whether the arc is empty.
*/
void set_is_empty(bool flag);
/*! Obtains the source point.
/*! obtains the source point.
*/
const Point_2& source() const;
/*! Obtains the target point.
/*! obtains the target point.
*/
const Point_2& target() const;
/*! Obtains the normal to the containing plane.
/*! obtains the normal to the containing plane.
*/
const Direction_3& normal() const;
/*! Obtains the (lexicographically) left endpoint direction.
/*! obtains the (lexicographically) left endpoint direction.
*/
const Point_2& left() const;
/*! Obtains the (lexicographically) right endpoint.
/*! obtains the (lexicographically) right endpoint.
*/
const Point_2& right() const;
@ -237,23 +240,22 @@ public:
*/
bool is_vertical() const;
/*! Determines whether the arc is directed lexicographically from left to
* right.
/*! determines whether the arc is directed lexicographically from left to right.
*/
bool is_directed_right() const;
/*! Determines whether the arc is a great circle.
/*! determines whether the arc is a great circle.
*/
bool is_full() const;
/*! Determines whether the arc is degenerate.
/*! determines whether the arc is degenerate.
*/
bool is_degenerate() const;
/*! Determines whether the arc is empty. */
/*! determines whether the arc is empty. */
bool is_empty() const;
/*! Determines whether the arc is a meridian.
/*! determines whether the arc is a meridian.
*/
bool is_meridian() const;
@ -296,7 +298,7 @@ public:
/// \name Operations
/// @{
/*! Construct a point on the sphere from three coordinates, which define
/*! constructs a point on the sphere from three coordinates, which define
* a (not necessarily normalized) direction.
* \param[in] x the x coordinate
* \param[in] y the y coordinate
@ -304,7 +306,7 @@ public:
*/
Point_2 operator()(const FT& x, const FT& y, const FT& z);
/*! Construct a point on the sphere from a (not necessarily normalized)
/*! constructs a point on the sphere from a (not necessarily normalized)
* direction.
* \param other the other direction
*/
@ -330,17 +332,17 @@ public:
/// \name Operations
/// @{
/*! Construct the minor geodesic arc from two endpoints. The minor arc
/*! constructs the minor geodesic arc from two endpoints. The minor arc
* is the one with the smaller angle among the two geodesic arcs with
* the given endpoints.
* 1. Find out whether the arc is x-monotone.
* 2. If it is x-monotone,
* 1. Find out whether the arc is \f$x\f$-monotone.
* 2. If it is \f$x\f$-monotone,
* 2.1 Find out whether it is vertical, and
* 2.2 whether the target is larger than the source (directed right).
*
* An arc is vertical, iff
* 1. one of its endpoint direction pierces a pole, or
* 2. the projections of the endpoint directions onto the xy-plane coincide.
* 2. the projections of the endpoint directions onto the \f$xy\f$-plane coincide.
* \param[in] p the first endpoint.
* \param[in] q the second endpoint.
* \pre p and q must not coincide.
@ -350,7 +352,7 @@ public:
*/
X_monotone_curve_2 operator()(const Point_2& p, const Point_2& q);
/*! Construct a full great circle from a normal to a plane.
/*! constructs a full great circle from a normal to a plane.
* Observe that the constructed arc has one endpoint that lies on
* the identification curve. This point is considered both the source and
* target (and also the left and right) point of the arc.
@ -359,7 +361,7 @@ public:
*/
X_monotone_curve_2 operator()(const Direction_3& normal);
/*! Construct a geodesic arc from two endpoints and a normal to the plane
/*! constructs a geodesic arc from two endpoints and a normal to the plane
* containing the arc. The two endpoints determine the plane. The normal
* determines the orientation of the plane and the final arc (whether its
* the minor arc or the major arc). The right-hand rule can be used
@ -394,22 +396,22 @@ public:
/// \name Operations
/// @{
/*! Construct a full great circle from a normal to a plane.
/*! constructs a full great circle from a normal to a plane.
* \param normal the normal to the plane containing the great circle.
*/
X_monotone_curve_2 operator()(const Direction_3& normal);
/*! Construct the minor geodesic arc from two endpoints. The minor arc
/*! constructs the minor geodesic arc from two endpoints. The minor arc
* is the one with the smaller angle among the two geodesic arcs with
* the given endpoints.
* 1. Find out whether the arc is x-monotone.
* 2. If it is x-monotone,
* 1. Find out whether the arc is \f$x\f$-monotone.
* 2. If it is \f$x\f$-monotone,
* 1. Find out whether it is vertical, and
* 2. whether the target is larger than the source (directed right).
*
* An arc is vertical, iff
* 1. one of its endpoint direction pierces a pole, or
* 2. the projections of the endpoint directions onto the xy-plane coincide.
* 2. the projections of the endpoint directions onto the \f$xy\f$-plane coincide.
*
* \param[in] p the first endpoint.
* \param[in] q the second endpoint.
@ -418,7 +420,7 @@ public:
*/
Curve_2 operator()(const Point_2& p, const Point_2& q);
/*! Construct a geodesic arc from two endpoints and a normal to the plane
/*! constructs a geodesic arc from two endpoints and a normal to the plane
* containing the arc. The two endpoints determine the plane. The normal
* determines the orientation of the plane and the final arc (whether its
* the minor arc or the major arc). The right-hand rule can be used
@ -426,6 +428,7 @@ public:
* \param[in] p the first endpoint.
* \param[in] q the second endpoint.
* \param[in] normal the normal to the oriented plane containing the arc.
*
* \pre Both endpoints lie on the given oriented plane.
*/
Curve_2 operator()(const Point_2& p, const Point_2& q,
@ -433,15 +436,15 @@ public:
/// @}
};
/*! Returns an instance of `Construct_point_2`.
/*! returns an instance of `Construct_point_2`.
*/
Construct_point_2 construct_point_2_object() const;
/*! Returns an instance of `Construct_x_monotone_curve_2`.
/*! returns an instance of `Construct_x_monotone_curve_2`.
*/
Construct_x_monotone_curve_2 construct_x_monotone_curve_2_object() const;
/*! Returns an instance of `Construct_curve_2`.
/*! returns an instance of `Construct_curve_2`.
*/
Construct_curve_2 construct_curve_2_object() const;
};

View File

@ -144,7 +144,7 @@ public:
/// \name Creation
/// @{
/*! Trims the given x-monotone curve to an from src to tgt.
/*! trims the given x-monotone curve to an from src to tgt.
* \ pre `src` and `tgt` lies on the curve
*/
X_monotone_curve_2 operator()(const X_monotone_curve_2& xcv,

View File

@ -11,8 +11,8 @@ namespace CGAL {
* or line segments. We call such a compound curve a polycurve. A polycurve
* is a chain of subcurves, where each two neighboring subcurves in the chain
* share a common endpoint; that is, the polycurve is continuous. Furthermore,
* the target of the \f$i\f$th segment of a polycurve has to coincide with
* the source of the \f$i+1\f$st segment; that is, the polycurve has to be
* the target of the \f$i\f$-th segment of a polycurve has to coincide with
* the source of the \f$i+1\f$-st segment; that is, the polycurve has to be
* \a well-oriented. Note that it is possible to construct general polycurves
* that are neither continuous nor well-oriented, as it is impossible to
* enforce this precondition (using the set of predicates required by the
@ -66,7 +66,7 @@ namespace CGAL {
* earlier) any object of the `X_monotone_curve_2` type nested in
* `Arr_polycurve_traits_2` which in that version was called
* `Arr_polyline_tratis_2` maintained a direction invariant; namely, its
* vertices were ordered in an \a ascending lexicographical \f$(xy)\f$-order.
* vertices were ordered in an \a ascending lexicographical \f$xy\f$-order.
* This restriction is no longer imposed and `X_monotone_curve_2` can be now
* directed either from right-to-left \a or left-to-right. If you wish to
* maintain a left-to-right orientations of the \f$x\f$-monotone polycurve,
@ -116,22 +116,21 @@ public:
/// \name Operations
/// @{
/*! Obtain a polycurve that comprises of one given subcurve.
/*! obtains a polycurve that comprises of one given subcurve.
* \param subcurve input subcurve.
*
* \pre `subcurve` is not degenerated (not tested).
* \return A polycurve with one subcurve, namely `subcurve`.
*/
Curve_2 operator()(const Subcurve_2& subcurve) const;
/*! Construct a well-oriented polycurve from a range of either
/*! constructs a well-oriented polycurve from a range of either
* `SubcurveTraits_2::Point_2` or `SubcurveTraits_2::Curve_2`.
*
* \param begin iterator pointing to the first element in the
* range.
* \param end iterator pointing to the past-the-end
* element in the range.
* \pre The given range form a continuous and well-oriented polycurve
* (not tested).
* \param begin iterator pointing to the first element in the range.
* \param end iterator pointing to the past-the-end element in the range.
*
* \pre The given range form a continuous and well-oriented polycurve (not tested).
* \pre Contains no degenerated subcurves (not tested)
* \return A polycurve using the corresponding construction implementation.
*/
@ -166,7 +165,7 @@ public:
/// \name Operations
/// @{
/*! Append a subcurve `subcurve` to an existing polycurve `cv` at the back.
/*! appends a subcurve `subcurve` to an existing polycurve `cv` at the back.
* If `cv` is empty, `subcurve` will be its first subcurve.
* \param cv a polycurve. Note, `cv` is (not necessarily) \f$x\f$-monotone.
* \param subcurve a subcurve (not necessarily \f$x\f$-monotone) to be
@ -174,7 +173,7 @@ public:
*/
void operator()(Curve_2& cv, const Subcurve_2& subcurve) const;
/*! Append a subcurve `subcurve` to an existing \f$x\f$-monotone polycurve
/*! appends a subcurve `subcurve` to an existing \f$x\f$-monotone polycurve
* `xcv` at the back. If `xcv` is empty, `subcurve` will be its first
* subcurve.
* \param xcv existing \f$x\f$-monotone polycurve
@ -182,6 +181,7 @@ public:
* \pre If `xcv` is not empty then `subcurve` extends `xcv` to the right
* if `xcv` is oriented right-to-left. Otherwise, `subcurve` extends
* `xcv` to the left.
*
* \pre `subcurve` is not degenerated.
* \pre `xcv` and `subcurve` should have the same orientation
*/
@ -198,7 +198,7 @@ public:
/// \name Operations
/// @{
/*! Append a subcurve `subcurve` to an existing polycurve `cv` at the
/*! appends a subcurve `subcurve` to an existing polycurve `cv` at the
* front. If `cv` is empty, `subcurve` will be its first subcurve.
* \param cv a polycurve. Note, `cv` is (not necessarily) \f$x\f$-monotone.
* \param subcurve a subcurve (not necessarily \f$x\f$-monotone) to be
@ -206,11 +206,12 @@ public:
*/
void operator()(Curve_2& cv, const Subcurve_2& subcurve) const;
/*! Append a subcurve `subcurve` to an existing \f$x\f$-monotone polycurve
/*! appends a subcurve `subcurve` to an existing \f$x\f$-monotone polycurve
* `xcv` at the front. If `xcv` is empty, `subcurve` will be its first
* subcurve.
* \param xcv existing \f$x\f$-monotone polycurve
* \param subcurve the subcurve to be added
*
* \pre If `xcv` is not empty then `subcurve` extends `xcv` to the left if
* `xcv` is oriented right-to-left. Otherwise, `subcurve` extends
* `xcv` to the right.
@ -225,9 +226,9 @@ public:
class Trim_2 {
public:
/*! Obtain a trimmed version of the polycurve with src and tgt as end
/*! obtains a trimmed version of the polycurve with src and tgt as end
* vertices.
* Src and tgt will be swapped if they do not conform to the direction of
* `src` and `tgt` will be swapped if they do not conform to the direction of
* the polycurve.
*/
X_monotone_curve_2 operator()(const X_monotone_curve_2& xcv,
@ -235,7 +236,7 @@ public:
const Point_2& tgt) const;
};
/*! Subdivide a given subcurve into \f$x\f$-monotone subcurves and
/*! subdivides a given subcurve into \f$x\f$-monotone subcurves and
* isolated points, and insert them into an output container. An object in
* the output container is represented by a discriminated union container
* that holds either a point or an \f$x\f$-monotone curve.
@ -278,17 +279,17 @@ public:
*/
template <typename SubcurveType_2, typename PointType_2>
class Curve_2 {
public:
protected:
/// \name Types
/// @{
/// The container of the subcurves that comprises the polycurve.
/*! The container of the subcurves that comprises the polycurve.
*/
typedef typename std::vector<Subcurve_2> Subcurves_container;
public:
/// The size of the container that comprises the polycurve.
/*! The size of the container that comprises the polycurve.
*/
typedef typename Subcurves_container::size_type Size;
typedef typename Subcurves_container::size_type size_type;
@ -319,15 +320,15 @@ public:
/// \name Creation
/// @{
/*! Default constructor that constructs an empty polycurve.
/*! constructs default; constructs an empty polycurve.
*/
Curve_2();
/*! Construct a polycurve from one subcurve.
/*! constructs a polycurve from one subcurve.
*/
Curve_2(const Subcurve_2 subcurve);
/*! Construct a polycurve defined by the given range of subcurves
/*! constructs a polycurve defined by the given range of subcurves
* `[first, last)` (the value-type of `InputIterator` must be
* `SubcurveTraits_2::Curve_2`. In general, the subcurves might not
* be \f$x\f$-monotone, furthermore, they might not form a
@ -353,7 +354,7 @@ public:
/// @{
/*! \deprecated
* Obtain the number of subcurve end-points that comprise the polycurve.
* obtains the number of subcurve end-points that comprise the polycurve.
* Note that for a bounded polycurve, if there are \f$n\f$ points in the
* polycurve, it comprises \f$(n - 1)\f$ subcurves.
* Currently, only bounded polycurves are supported.
@ -361,60 +362,62 @@ public:
unsigned_int points() const;
/*! \deprecated
* Obtain an iterator pointing at the source point of the polycurve.
* obtains an iterator pointing at the source point of the polycurve.
*/
const_iterator begin() const;
/*! Obtain an iterator pointing at the first subcurve of the polycurve.
/*! obtains an iterator pointing at the first subcurve of the polycurve.
*/
Subcurve_const_iterator begin_subcurves() const;
/*! \deprecated
* Obtain an iterator pointing after the end of the polycurve.
* obtains an iterator pointing after the end of the polycurve.
*/
const_iterator end() const;
/*! Get an iterator pointing at the past-the-end subcurve of the polycurve.
/*! obtains an iterator pointing at the past-the-end subcurve of the
* polycurve.
*/
Subcurve_const_iterator end_subcurves() const;
/*! \deprecated
* Obtain an iterator pointing at the target point of the polycurve.
* obtains an iterator pointing at the target point of the polycurve.
*/
const_iterator rbegin() const;
/*! Obtain an iterator pointing at the last subcurve of the polycurve.
/*! obtains an iterator pointing at the last subcurve of the polycurve.
*/
Subcurve_const_reverse_iterator rbegin_subcurves() const;
/*! \deprecated
* Obtain an iterator pointing before the beginning of the polycurve.
* obtains an iterator pointing before the beginning of the polycurve.
*/
const_iterator rend() const;
/*! Obtain an iterator pointing at the past-the-end subcurve of
/*! obtains an iterator pointing at the past-the-end subcurve of
* the polycurve in reverse order.
*/
Subcurve_const_reverse_iterator rend_subcurves() const;
/*! \deprecated
* Obtain the number of subcurves composing the polycurve
* obtains the number of subcurves composing the polycurve
* (equivalent to `pi.points() - 1`). Was replaced by number_of_subcurves()
*/
size_type size() const;
/*! Obtain the number of subcurves that comprise the polycurve.
/*! obtains the number of subcurves that comprise the polycurve.
*/
size_type number_of_subcurves() const;
/*! Obtain the \f$k\f$th subcurve of the polycurve.
/*! obtains the \f$k\f$-th subcurve of the polycurve.
*
* \pre \f$k\f$ is not greater than or equal to \f$n-1\f$, where
* \f$n\f$ is the number of subcurves.
*/
typename SubcurveTraits_2::X_monotone_curve_2
operator[](std::size_t k) const;
operator[](size_t k) const;
/*! Obtain the bounding box of the polycurve.
/*! obtains the bounding box of the polycurve.
*/
Bbox_2 bbox() const;
@ -423,22 +426,24 @@ public:
/// \name Operations
/// @{
/*! Append a subcurve to the polycurve at the back.
/*! appends a subcurve to the polycurve at the back.
* \a Warning: This function does not perform the precondition test
* that the `Push_back_2` functor does. Thus, it is
* recommended to use the latter.
* \param subcurve The new subcurve to be appended to the polycurve.
*
* \pre If the polycurve is not empty, the source of `subcurve` must
* coincide with the target point of the last subcurve in the
* polycurve.
*/
inline void push_back(const Subcurve_2& subcurve);
/*! Append a subcurve to the polycurve at the front.
/*! appends a subcurve to the polycurve at the front.
* \a Warning: This is a risky function! Don't use it! Prefer the
* corresponding functor which is provided in the traits
* class.
* \param subcurve The new subcurve to be appended to the polycurve.
*
* \pre If the polycurve is not empty, the target of `subcurve` must
* coincide with the source point of the first subcurve in the
* polycurve.
@ -446,30 +451,31 @@ public:
inline void push_front(const Subcurve_2& subcurve);
/*! \deprecated
* Add a new point to the polycurvs, which becomes the new target point
* adds a new point to the polycurvs, which becomes the new target point
* of `pi`.
*/
void push_back(const Point_2 & p);
/*! Reset the polycurve.
/*! resets the polycurve.
*/
void clear();
/// @} /* End of Operations */
}; /* end Arr_polycurve_traits_2::Curve_2 */
/*! The `X_monotone_curve_2` class nested within the polycurve traits is
* used to represent \f$x\f$-monotone piecewise linear subcurves.
*
* It inherits from the `Curve_2` type. `X_monotone_curve_2` can be
* constructed just like `Curve_2`. However, there is precondition (which
* is not tested) that the input defines an \f$x\f$-monotone polycurve.
* Furthermore, in contrast to the general `Curve_2` type, in this case,
* the subcurves that an `X_monotone_curve_2` comprises have to be
* instances of the type `SubcurveTraits_2::X_monotone_curve_2`. Note that
* the \f$x\f$-monotonicity ensures that an \f$x\f$-monotone polycurve is
* not self-intersecting. (A self-intersecting polycurve is subdivided
* into several interior-disjoint \f$x\f$-monotone subcurves).
* constructed just like `Curve_2`. However, there is precondition (which is
* not tested) that the input defines an \f$x\f$-monotone
* polycurve. Furthermore, in contrast to the general `Curve_2` type, in this
* case, the subcurves that an `X_monotone_curve_2` comprises have to be
* instances of the type `SubcurveTraits_2::X_monotone_curve_2`. Note that the
* \f$x\f$-monotonicity ensures that an \f$x\f$-monotone polycurve is not
* self-intersecting. (A self-intersecting polycurve is subdivided into
* several interior-disjoint \f$x\f$-monotone subcurves).
*
* The defined \f$x\f$-monotone polycurve can be directed either from
* right-to-left (and in turn its vertices are stored in an ascending

View File

@ -150,7 +150,7 @@ public:
/// obtains the past-the-end reverse iterator for the polyline points.
Segment_const_reverse_iterator rend_segments() const;
/*! Obtain the number of subcurves that comprise the poyline.
/*! obtains the number of subcurves that comprise the poyline.
* \return The number of subcurves.
*/
Segments_size_type number_of_segments() const;
@ -170,13 +170,13 @@ public:
typedef std::reverse_iterator<Segment_const_iterator>
Segment_const_reverse_iterator;
/*! Construct default. */
/*! constructs default. */
X_monotone_curve_2();
/*! Construct from a subcurve. */
/*! constructs from a subcurve. */
X_monotone_curve_2(X_monotone_segment_2 seg);
/*! Construct from a range. Similar to the constructor of a general
/*! constructs from a range. Similar to the constructor of a general
* polycurve. Like in the case of general polycurve, for the sake of
* backwards compatibility we have to keep an implementation of
* construction from a range of points. DO NOT USE THIS CONSTRUCTION.
@ -184,23 +184,23 @@ public:
template <typename InputIterator>
X_monotone_curve_2(InputIterator begin, InputIterator end);
/*! Obtain the first iterator of the polyline subcurves.
/*! obtains the first iterator of the polyline subcurves.
*/
Segment_const_iterator begin_segments() const;
/*! Obtain the past-the-end iterator of the polyline subcurves.
/*! obtains the past-the-end iterator of the polyline subcurves.
*/
Segment_const_iterator end_segments() const;
/*! Obtain the first reverse iterator of the polyline subcurves.
/*! obtains the first reverse iterator of the polyline subcurves.
*/
Segment_const_reverse_iterator rbegin_segments() const;
/*! Obtain the past-the-end reverse iterator for the polyline points.
/*! obtains the past-the-end reverse iterator for the polyline points.
*/
Segment_const_reverse_iterator rend_segments() const;
/*! Obtain the number of subcurves that comprise the poyline.
/*! obtains the number of subcurves that comprise the poyline.
* \return The number of subcurves.
*/
Segments_size_type number_of_segments() const;
@ -220,7 +220,7 @@ public:
/// \name Operations
/// @{
/*! Obtain a polyline connecting the two given endpoints.
/*! obtains a polyline connecting the two given endpoints.
* \param p The first point.
* \param q The second point.
* \return A segment connecting `p` and `q`.
@ -228,14 +228,14 @@ public:
*/
Curve_2 operator()(const Point_2& p, const Point_2& q) const;
/*! Obtain a polyline that comprises of one given segment.
/*! obtains a polyline that comprises of one given segment.
* \param seg input segment
* \return A polyline with one segment, namely `seg`.
* \pre `seg` is not degenerated (not tested)
*/
Curve_2 operator()(const Segment_2& seg) const;
/*! Construct a well-oriented polyline from a range of either
/*! constructs a well-oriented polyline from a range of either
* `SegmentTraits_2::Point_2` or `SegmentTraits_2::Segment_2`.
*
* \param begin iterator pointing to the first element in the range.
@ -271,7 +271,7 @@ public:
/// \name Operations
/// @{
/*! Append a point `p` to an existing polyline `cv` at the back.
/*! appends a point `p` to an existing polyline `cv` at the back.
* \param cv a polyline. Note, `cv` is not (necessarily)
* \f$x\f$-monotone.
* \param p a point to be appended to `cv` at the back.
@ -279,7 +279,7 @@ public:
*/
void operator()(Curve_2& cv, const Point_2& p) const;
/*! Append a segment `seg` to an existing polyline `cv` at the back.
/*! appends a segment `seg` to an existing polyline `cv` at the back.
* If `cv` is empty, `seg` will be its first segment.
* \param cv a polyline. Note, `cv` is (not necessarily) \f$x\f$-monotone.
* \param seg a segment (not necessarily \f$x\f$-monotone) to be appended
@ -287,7 +287,7 @@ public:
*/
void operator()(Curve_2& cv, const Segment_2& seg) const;
/*! Append a point `p` to an existing \f$x\f$-monotone polyline `xcv` at
/*! appends a point `p` to an existing \f$x\f$-monotone polyline `xcv` at
* the back.
* \param xcv the existing \f$x\f$-monotone polyline
* \param p the point to be pushed back.
@ -298,7 +298,7 @@ public:
*/
void operator()(const X_monotone_curve_2& xcv, Point_2& p) const;
/*! Append a segment `seg` to an existing \f$x\f$-monotone polyline `xcv`
/*! appends a segment `seg` to an existing \f$x\f$-monotone polyline `xcv`
* at the back. If `xcv` is empty, `seg` will be its first segment.
* \param xcv existing \f$x\f$-monotone polyline
* \param seg the segment to be added
@ -321,7 +321,7 @@ public:
/// \name Operations
/// @{
/*! Append a point `p` to an existing polyline `cv` at the front.
/*! appends a point `p` to an existing polyline `cv` at the front.
* \param cv a polyline. Note, `cv` is not (necessarily)
* \f$x\f$-monotone.
* \param p a point to be appended to `cv` at the back.
@ -329,7 +329,7 @@ public:
*/
void operator()(Curve_2& cv, const Point_2& p) const;
/*! Append a segment `seg` to an existing polyline `cv` at the front.
/*! appends a segment `seg` to an existing polyline `cv` at the front.
* If `cv` is empty, `seg` will be its first segment.
* \param cv a polyline. Note, `cv` is (not necessarily) \f$x\f$-monotone.
* \param seg a segment (not necessarily \f$x\f$-monotone) to be appended
@ -337,7 +337,7 @@ public:
*/
void operator()(Curve_2& cv, const Segment_2& seg) const;
/*! Append a point `p` to an existing \f$x\f$-monotone polyline `xcv` at
/*! appends a point `p` to an existing \f$x\f$-monotone polyline `xcv` at
* the front.
* \param xcv the existing \f$x\f$-monotone polyline
* \param p the point to be pushed back.
@ -348,7 +348,7 @@ public:
*/
void operator()(const X_monotone_curve_2& xcv, Point_2& p) const;
/*! Append a segment `seg` to an existing \f$x\f$-monotone polyline `xcv`
/*! appends a segment `seg` to an existing \f$x\f$-monotone polyline `xcv`
* at the front. If `xcv` is empty, `seg` will be its first segment.
* \param xcv existing \f$x\f$-monotone polyline
* \param seg the segment to be added

View File

@ -17,13 +17,12 @@ namespace CGAL {
* interval \f$[x_{\rm min}, x_{\rm max}]\f$ or defined over a ray
* \f$(-\infty,x_{\rm max}]\f$ or over \f$[x_{\rm min}, \infty)\f$. Rational
* functions are represented by the nested type `Curve_2`. Note that a rational
* function may be not continuous since roots of \f$Q\f$ induce vertical
* asymptotes, which would contradict the notion of an \f$x\f$-monotone curve as
* it is introduced by the `AosTraits_2` concept. Thus, continuous
* portions of rational functions are represented by the nested type
* `X_monotone_curve_2`, which is different from `Curve_2`. Constructors for
* both classes are provided by the traits. A `Curve_2` may be split up into
* several `X_monotone_curve_2` using `Make_x_monotone_2`.
* function may be not continuous since roots of \f$Q\f$ induce vertical asymptotes,
* which would contradict the notion of an \f$x\f$-monotone curve as it is introduced
* by the `AosTraits_2` concept. Thus, continuous portions of rational functions are
* represented by the nested type `X_monotone_curve_2`, which is different from
* `Curve_2`. Constructors for both classes are provided by the traits. A `Curve_2`
* may be split up into several `X_monotone_curve_2` using `Make_x_monotone_2`.
*
* The template parameter of the traits must be a model of the concept
* `AlgebraicKernel_d_1`. A rational function is then represented by two
@ -86,19 +85,19 @@ public:
/// \name Operations
/// @{
/*! Returns an instance of `Construct_curve_2`.
/*! returns an instance of `Construct_curve_2`.
*/
Construct_curve_2 construct_curve_2_object() const;
/*! Returns an instance of `Construct_x_monotone_curve_2`.
/*! returns an instance of `Construct_x_monotone_curve_2`.
*/
Construct_x_monotone_curve_2 construct_x_monotone_curve_2_object() const;
/*! Deletes all curves from the cache that exist only there.
/*! deletes all curves from the cache that exist only there.
*/
void cleanup_cache() const;
/*! Returns a pointer to the used algebraic kernel object.
/*! returns a pointer to the used algebraic kernel object.
*/
const Algebraic_kernel_d_1* algebraic_kernel_d_1() const;
@ -138,60 +137,58 @@ public:
/// \name Operations
/// @{
/*! Constructs a curve representing the polynomial function \f$y = P(x)\f$.
/*! constructs a curve representing the polynomial function \f$y = P(x)\f$.
*/
Curve_2 operator()(Polynomial_1 P) const;
/*! Constructs a curve representing the polynomial function \f$y = P(x)\f$.
* The function is defined over the interval \f$[x,+\infty)\f$ if
* \f$right\f$ is true and \f$(-\infty,x]\f$ otherwise.
/*! constructs a curve representing the polynomial function \f$y = P(x)\f$.
* The function is defined over the interval \f$[x,+\infty)\f$ if \f$right\f$
* is true and \f$(-\infty,x]\f$ otherwise.
*/
Curve_2 operator()(Polynomial_1 P, const Algebraic_real_1& x,
bool right) const;
/*! Constructs a curve representing the polynomial function \f$y = P(x)\f$.
/*! constructs a curve representing the polynomial function \f$y = P(x)\f$.
* The function is defined over the interval \f$[lower,upper]\f$.
*/
Curve_2 operator()(Polynomial_1 P, const Algebraic_real_1& lower,
const Algebraic_real_1& upper) const;
/*! Constructs a curve representing the rational function
* \f$y = P(x)/Q(x)\f$.
/*! constructs a curve representing the rational function \f$y = P(x)/Q(x)\f$.
*/
Curve_2 operator()(Polynomial_1 P, Polynomial_1 Q) const;
/*! Constructs a curve representing the rational function
* \f$y = P(x)/Q(x)\f$.
* The function is defined over the interval \f$I=[x,+\infty)\f$ if
* \f$right\f$ is true and \f$I=(-\infty,x]\f$ otherwise.
/*! constructs a curve representing the rational function \f$y = P(x)/Q(x)\f$.
* The function is defined over the interval
* \f$ I=[x,+\infty)\f$ if \f$right\f$ is true and
* \f$ I=(-\infty,x]\f$ otherwise.
*/
Curve_2 operator()(Polynomial_1 P, Polynomial_1 Q,
const Algebraic_real_1& x, bool right) const;
/*! Constructs a curve representing the rational function
* \f$y = P(x)/Q(x)\f$.
/*! constructs a curve representing the rational function \f$y = P(x)/Q(x)\f$.
* The function is defined over the interval \f$I=[lower,upper]\f$.
*/
Curve_2 operator()(Polynomial_1 P, Polynomial_1 Q,
const Algebraic_real_1& lower,
const Algebraic_real_1& upper) const;
/*! Constructs a curve representing the polynomial function \f$y = P(x)\f$,
/*! constructs a curve representing the polynomial function \f$y = P(x)\f$,
* where the coefficients of \f$P\f$ are given in the range `[begin,end)`.
*/
template <typename InputIterator>
Curve_2 operator()(InputIterator begin, InputIterator end) const;
/*! Constructs a curve representing the polynomial function \f$y = P(x)\f$,
* where the coefficients of \f$P\f$ are given in the range
* `[begin,end)`. The function is defined over the interval
/*! constructs a curve representing the polynomial function \f$y = P(x)\f$,
* where the coefficients of \f$P\f$ are given in the range `[begin,end)`.
* The function is defined over the interval
* \f$[x,+\infty)\f$ if \f$right\f$ is true and \f$(-\infty,x]\f$ otherwise.
*/
template <typename InputIterator>
Curve_2 operator()(InputIterator begin, InputIterator end,
const Algebraic_real_1& x, bool right) const;
/*! Constructs a curve representing the polynomial function \f$y = P(x)\f$,
/*! constructs a curve representing the polynomial function \f$y = P(x)\f$,
* where the coefficients of \f$P\f$ are given in the range `[begin,end)`.
* The function is defined over the interval \f$[lower,upper]\f$.
*/
@ -200,32 +197,29 @@ public:
const Algebraic_real_1& lower,
const Algebraic_real_1& upper) const;
/*! Constructs a curve representing the rational function \f$y = P(x)/Q(x)\f$,
/*! constructs a curve representing the rational function \f$y = P(x)/Q(x)\f$,
* where the coefficients of \f$P\f$ and \f$Q\f$ are given in the ranges
* `[begin_numer,end_numer)` and `[begin_denom,end_denom)`,
* respectively.
* `[begin_numer,end_numer)` and `[begin_denom,end_denom)`, respectively.
*/
template <typename InputIterator>
Curve_2 operator()(InputIterator begin_numer, InputIterator end_numer,
InputIterator begin_denom, InputIterator end_denom) const;
/*! Constructs a curve representing the rational function
* \f$y = P(x)/Q(x)\f$, where the coefficients of \f$P\f$ and \f$Q\f$ are
* given in the ranges `[begin_numer,end_numer)` and `[begin_denom,end_denom)`,
* respectively. The function is defined over the interval
* \f$I=[x,+\infty)\f$ if \f$right\f$ is true and \f$I=(-\infty,x]\f$
* otherwise.
/*! constructs a curve representing the rational function \f$y = P(x)/Q(x)\f$,
* where the coefficients of \f$P\f$ and \f$Q\f$ are given in the ranges
* `[begin_numer,end_numer)` and `[begin_denom,end_denom)`, respectively.
* The function is defined over the interval \f$I=[x,+\infty)\f$
* if \f$right\f$ is true and \f$I=(-\infty,x]\f$ otherwise.
*/
template <typename InputIterator>
Curve_2 operator()(InputIterator begin_numer, InputIterator end_numer,
InputIterator begin_denom, InputIterator end_denom,
const Algebraic_real_1& x, bool right) const;
/*! Constructs a curve representing the rational function
* \f$y = P(x)/Q(x)\f$, where the coefficients of \f$P\f$ and \f$Q\f$ are
* given in the ranges `[begin_numer,end_numer)` and `[begin_denom,end_denom)`,
* respectively. The function is defined over the interval
* \f$I=[lower,upper]\f$.
/*! constructs a curve representing the rational function \f$y = P(x)/Q(x)\f$,
* where the coefficients of \f$P\f$ and \f$Q\f$ are given in the ranges
* `[begin_numer,end_numer)` and `[begin_denom,end_denom)`, respectively.
* The function is defined over the interval \f$I=[lower,upper]\f$.
*/
template <typename InputIterator>
Curve_2 operator()(InputIterator begin_numer, InputIterator end_numer,
@ -236,8 +230,8 @@ public:
/// @}
}; /* end Arr_rational_function_traits_2::Construct_curve_2 */
/*! Functor to construct a `X_monotone_curve_2`. To enable caching the class
* is not default constructible and must be obtained via the function
/*! Functor to construct a `X_monotone_curve_2`. To enable caching the class is
* not default constructible and must be obtained via the function
* `construct_x_monotone_curve_2_object()`, which is a member of the traits.
*
* \cgalModels{Assignable,CopyConstructible,AdaptableBinaryFunction,AdaptableUnaryFunction}
@ -270,35 +264,36 @@ public:
/// \name Operations
/// @{
/*! Constructs an \f$x\f$-monotone curve supported by the polynomial
* function \f$y = P(x)\f$.
/*! constructs an \f$x\f$-monotone curve supported by the polynomial function
* \f$y = P(x)\f$.
*/
X_monotone_curve_2 operator()(Polynomial_1 P) const;
/*! Constructs an \f$x\f$-monotone curve supported by the polynomial
* function \f$y = P(x)\f$. The function is defined over the interval
/*! constructs an \f$x\f$-monotone curve supported by the polynomial function
* \f$y = P(x)\f$. The function is defined over the interval
* \f$[x,+\infty)\f$ if \f$right\f$ is true and \f$(-\infty,x]\f$
* otherwise.
*/
X_monotone_curve_2 operator()(Polynomial_1 P, const Algebraic_real_1& x,
X_monotone_curve_2 operator()(Polynomial_1 P,
const Algebraic_real_1& x,
bool right) const;
/*! Constructs an \f$x\f$-monotone curve supported by the polynomial
* function \f$y = P(x)\f$. The function is defined over the interval
/*! constructs an \f$x\f$-monotone curve supported by the polynomial function
* \f$y = P(x)\f$. The function is defined over the interval
* \f$[lower,upper]\f$.
*/
X_monotone_curve_2 operator()(Polynomial_1 P,
const Algebraic_real_1& lower,
const Algebraic_real_1& upper); const
const Algebraic_real_1& upper) const;
/*! Constructs an \f$x\f$-monotone curve supported by the rational function
/*! constructs an \f$x\f$-monotone curve supported by the rational function
* \f$y = P(x)/Q(x)\f$.
*
* \pre \f$Q\f$ has no real roots.
*/
X_monotone_curve_2 operator()(Polynomial_1 P, Polynomial_1 Q); const
X_monotone_curve_2 operator()(Polynomial_1 P, Polynomial_1 Q) const;
/*! Constructs an \f$x\f$-monotone curve supported by the rational function
/*! constructs an \f$x\f$-monotone curve supported by the rational function
* \f$y = P(x)/Q(x)\f$. The function is defined over the interval
* \f$I=[x,+\infty)\f$ if \f$right\f$ is true and \f$I=(-\infty,x]\f$
* otherwise.
@ -307,62 +302,60 @@ public:
*/
X_monotone_curve_2 operator()(Polynomial_1 P, Polynomial_1 Q,
const Algebraic_real_1& x,
bool right); const
bool right) const;
/*! Constructs an \f$x\f$-monotone curve supported by the rational function
/*! constructs an \f$x\f$-monotone curve supported by the rational function
* \f$y = P(x)/Q(x)\f$. The function is defined over the interval
* \f$I=[lower,upper]\f$.
*
* \pre \f$Q\f$ has no real roots in the interior of \f$I\f$.
*/
X_monotone_curve_2 operator()(Polynomial_1 P, Polynomial_1 Q,
const Algebraic_real_1& lower,
const Algebraic_real_1& upper); const
const Algebraic_real_1& upper) const;
/*! Constructs an \f$x\f$-monotone curve supported by the polynomial
* function \f$y = P(x)\f$, where the coefficients of \f$P\f$ are given
* in the range `[begin,end)`.
/*! constructs an \f$x\f$-monotone curve supported by the polynomial function
* \f$y = P(x)\f$, where the coefficients of \f$P\f$ are given in the range
* `[begin,end)`.
*/
template <typename InputIterator>
X_monotone_curve_2 operator()(InputIterator begin, InputIterator end) const;
/*! Constructs an \f$x\f$-monotone curve supported by the polynomial
* function \f$y = P(x)\f$, where the coefficients of \f$P\f$ are given in
* the range `[begin,end)`. The function is defined over the interval
* \f$[x,+\infty)\f$ if \f$right\f$ is true and \f$(-\infty,x]\f$ otherwise.
/*! constructs an \f$x\f$-monotone curve supported by the polynomial function
* \f$y = P(x)\f$, where the coefficients of \f$P\f$ are given in the range
* `[begin,end)`. The function is defined over the interval \f$[x,+\infty)\f$
* if \f$right\f$ is true and \f$(-\infty,x]\f$ otherwise.
*/
template <typename InputIterator>
X_monotone_curve_2 operator()(InputIterator begin, InputIterator end,
const Algebraic_real_1& x, bool right) const;
/*! Constructs an \f$x\f$-monotone curve supported by the polynomial
* function \f$y = P(x)\f$, where the coefficients of \f$P\f$ are given in
* the range `[begin,end)`. The function is defined over the interval
/*! constructs an \f$x\f$-monotone curve supported by the polynomial function
* \f$y = P(x)\f$, where the coefficients of \f$P\f$ are given in the range
* `[begin,end)`. The function is defined over the interval
* \f$[lower,upper]\f$.
*/
template <typename InputIterator>
X_monotone_curve_2 operator()(InputIterator begin, InputIterator end
const Algebraic_real_1& lower,
const Algebraic_real_1& upper); const
const Algebraic_real_1& upper) const;
/*! Constructs an \f$x\f$-monotone curve supported by the rational function
/*! constructs an \f$x\f$-monotone curve supported by the rational function
* \f$y = P(x)/Q(x)\f$, where the coefficients of \f$P\f$ and \f$Q\f$ are
* given in the ranges `[begin_numer,end_numer)` and
* `[begin_denom,end_denom)`, respectively.
*
* \pre \f$Q\f$ has no real roots.
*/
template <typename InputIterator>
X_monotone_curve_2 operator()(InputIterator begin_numer,
InputIterator end_numer,
InputIterator begin_denom,
InputIterator end_denom); const
InputIterator end_denom) const;
/*! Constructs an \f$x\f$-monotone curve supported by the rational function
* \f$y = P(x)/Q(x)\f$, where the coefficients of \f$P\f$ and \f$Q\f$
* are given in the ranges `[begin_numer,end_numer)` and
* `[begin_denom,end_denom)`, respectively. The function is defined over
* the interval \f$I=[x,+\infty)\f$ if \f$right\f$ is true and
/*! constructs an \f$x\f$-monotone curve supported by the rational function
* \f$y = P(x)/Q(x)\f$, where the coefficients of \f$P\f$ and \f$Q\f$ are
* given in the ranges `[begin_numer,end_numer)` and
* `[begin_denom,end_denom)`, respectively. The function is defined over the
* interval \f$I=[x,+\infty)\f$ if \f$right\f$ is true and
* \f$I=(-\infty,x]\f$ otherwise.
*
* \pre \f$Q\f$ has no real roots in the interior of \f$I\f$.
@ -372,14 +365,13 @@ public:
InputIterator end_numer,
InputIterator begin_denom,
InputIterator end_denom,
const Algebraic_real_1& x, bool right); const
const Algebraic_real_1& x, bool right) const;
/*! Constructs an \f$x\f$-monotone curve supported by the rational function
* \f$y = P(x)/Q(x)\f$, where the coefficients of \f$P\f$ and \f$Q\f$
* are given in the ranges `[begin_numer,end_numer)` and
* `[begin_denom,end_denom)`, respectively. The function is defined over
* the interval \f$I=[lower,upper]\f$.
*
/*! constructs an \f$x\f$-monotone curve supported by the rational function
* \f$y = P(x)/Q(x)\f$, where the coefficients of \f$P\f$ and \f$Q\f$ are
* given in the ranges `[begin_numer,end_numer)` and
* `[begin_denom,end_denom)`, respectively. The function is defined over the
* interval \f$I=[lower,upper]\f$.
* \pre \f$Q\f$ has no real roots in the interior of \f$I\f$.
*/
template <typename InputIterator>
@ -388,13 +380,13 @@ public:
InputIterator begin_denom,
InputIterator end_denom,
const Algebraic_real_1& lower,
const Algebraic_real_1& upper); const
const Algebraic_real_1& upper) const;
/// @}
}; /* end Arr_rational_function_traits_2::Construct_x_monotone_curve_2 */
/*! The `Curve_2` class nested within the traits is used to
* represent rational functions which may be restricted to a certain x-range.
/*! The `Curve_2` class nested within the traits is used to represent rational
* functions which may be restricted to a certain \f$x\f$-range.
*
* \cgalModels{ArrTraits::Curve_2}
*/
@ -438,12 +430,14 @@ public:
Arr_parameter_space right_parameter_space_in_x() const;
/*! returns the \f$x\f$-coordinate of the left end.
* \pre left_boundary_in_x()==ARR_INTERIOR
*
* \pre `left_boundary_in_x()` == `ARR_INTERIOR`
*/
Algebraic_real_1 left_x() const;
/*! returns the \f$x\f$-coordinate of the right end.
* \pre right_boundary_in_x()==ARR_INTERIOR
*
* \pre `right_boundary_in_x()` == `ARR_INTERIOR`
*/
Algebraic_real_1 right_x() const;
@ -489,12 +483,12 @@ public:
*/
Algebraic_real_1 x() const;
/*! obtains the y-coordinates of the point. <B>Attention:</B> As described
* above, points are not stored by their y-coordinate in `Algebraic_real_1`
* representation. In fact, this representation must be computed on demand,
* and might become quite costly for points defined by high-degree
* polynomials. Therefore, it is recommended to avoid calls to this
* function as much as possible.
/*! obtains the \f$y\f$-coordinates of the point. <B>Attention:</B> As
* described above, points are not stored by their \f$y\f$-coordinate in
* `Algebraic_real_1` representation. In fact, this representation must be
* computed on demand, and might become quite costly for points defined by
* high-degree polynomials. Therefore, it is recommended to avoid calls to
* this function as much as possible.
*/
Algebraic_real_1 y() const;
@ -522,7 +516,7 @@ public:
*/
std::pair<Bound,Bound> approximate_relative_x(int r) const;
/*! Computes a pair \f$p\f$ approximating the \f$y\f$-coordinate with
/*! computes a pair \f$p\f$ approximating the \f$y\f$-coordinate with
* respect to the given relative precision \f$r\f$.
*
* \post \f$p.first \leq y \leq p.second\f$
@ -534,10 +528,10 @@ public:
}; /* end Arr_rational_function_traits_2::Point_2 */
/*! The `X_monotone_curve_2` class nested within the traits is used
* to represent \f$x\f$-monotone parts of rational functions. In particular,
* such an \f$x\f$-monotone curve may not contain a vertical asymptote in
* its interior \f$x\f$-range.
/*! The `X_monotone_curve_2` class nested within the traits is used to represent
* \f$x\f$-monotone parts of rational functions. In particular, such as
* \f$x\f$-monotone curve may not contain a vertical asymptote in its interior
* \f$x\f$-range.
*
* \cgalModels{ArrTraits::XMonotoneCurve_2}
*/
@ -579,7 +573,6 @@ public:
Arr_parameter_space source_parameter_space_in_y() const;
/*! returns the source point of the arc.
*
* \pre Both the \f$x\f$- and \f$y\f$-coordinates of the source point is
* finite.
*/
@ -602,7 +595,6 @@ public:
Arr_parameter_space target_parameter_space_in_y() const;
/*! returns the target point of the arc.
*
* \pre Both the \f$x\f$- and \f$y\f$-coordinates of the target point is
* finite.
*/
@ -614,20 +606,19 @@ public:
*/
Algebraic_real_1 target_x() const;
/*! returns whether the \f$x\f$-coordinate of the left curve end is finite
* or whether it is \f$\pm\infty\f$.
/*! returns whether the \f$x\f$-coordinate of the left curve end is finite or
* whether it is \f$\pm\infty\f$.
*/
Arr_parameter_space left_parameter_space_in_x() const;
/*! returns whether the \f$y\f$-coordinate of the left curve end is finite
* or whether it is \f$\pm\infty\f$.
/*! returns whether the \f$y\f$-coordinate of the left curve end is finite or
* whether it is \f$\pm\infty\f$.
*/
Arr_parameter_space left_parameter_space_in_y() const;
/*! returns the left point of the arc.
*
* \pre Both the \f$x\f$- and \f$y\f$-coordinates of the left point is
* finite.
* \pre Both the \f$x\f$- and \f$y\f$-coordinates of the left point is finite.
*/
const Point_2& left() const;
@ -637,18 +628,17 @@ public:
*/
Algebraic_real_1 left_x() const;
/*! returns whether the \f$x\f$-coordinate of the right curve end is finite
* or whether it is \f$\pm\infty\f$.
/*! returns whether the \f$x\f$-coordinate of the right curve end is finite or
* whether it is \f$\pm\infty\f$.
*/
Arr_parameter_space right_parameter_space_in_x () const;
/*! returns whether the \f$y\f$-coordinate of the right curve end is finite
* or whether it is \f$\pm\infty\f$.
/*! returns whether the \f$y\f$-coordinate of the right curve end is finite or
* whether it is \f$\pm\infty\f$.
*/
Arr_parameter_space right_parameter_space_in_y () const;
/*! returns the right point of the arc.
*
* \pre Both the \f$x\f$- and \f$y\f$-coordinates of The right point is
* finite.
*/
@ -665,6 +655,7 @@ public:
bool is_left_to_right() const;
/// @}
}; /* end Arr_rational_function_traits_2::X_monotone_curve_2 */
}; /* end Arr_rational_function_traits_2 */

View File

@ -121,6 +121,7 @@ public:
X_monotone_curve_2(const X_monotone_curve_2& xcv,
const Point_2& src, const Point_2& tgt) const;
//! @}
} /* end Arr_segment_traits_2::Trim_2 */
}; /* end Arr_segment_traits_2 */

View File

@ -49,10 +49,10 @@ public:
/// \name Creation
/// @{
/*! Default constructor. */
/*! constructs default */
Arr_spherical_topology_traits_2();
/*! Constructor from a geometry-traits object.
/*! constructs from a geometry-traits object.
* \param traits the traits.
*/
Arr_spherical_topology_traits_2(const GeometryTraits_2* traits);
@ -62,36 +62,36 @@ public:
/// \name Accessors
/// @{
/*! Obtain the \dcel (const version). */
/*! obtains the \dcel (const version). */
const Dcel& dcel() const;
/*! Obtain the \dcel (non-const version). */
/*! obtains the \dcel (non-const version). */
Dcel& dcel();
/*! Obtain the spherical face (const version). */
/*! obtains the spherical face (const version). */
const Face* spherical_face() const;
/*! Obtain the spherical face (non-const version). */
/*! obtains the spherical face (non-const version). */
Face* spherical_face();
/*! Obtain the south pole (const version). */
/*! obtains the south pole (const version). */
const Vertex* south_pole() const;
/*! Obtain the south pole (non-const version). */
/*! obtains the south pole (non-const version). */
Vertex* south_pole();
/*! Obtain the north pole (const version). */
/*! obtains the north pole (const version). */
const Vertex* north_pole() const;
/*! Obtain the north pole (non-const version). */
/*! obtains the north pole (non-const version). */
Vertex* north_pole();
/*! Obtain a vertex on the line of discontinuity that corresponds to
/*! obtains a vertex on the line of discontinuity that corresponds to
* the given point (or return NULL if no such vertex exists).
*/
const Vertex* discontinuity_vertex(const Point_2& pt) const;
/*! Obtain a vertex on the line of discontinuity that corresponds to
/*! obtains a vertex on the line of discontinuity that corresponds to
* the given point (or return NULL if no such vertex exists).
*/
Vertex* discontinuity_vertex(const Point_2& pt);

View File

@ -0,0 +1,145 @@
/// Copyright (c) 2007,2009,2010,2011 Tel-Aviv University (Israel).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
//
// $URL$
// $Id$
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
//
// Author(s): Efi Fogel <efif@post.tau.ac.il>
namespace CGAL {
/*! \ingroup PkgArrangementOnSurface2TraitsClasses
*
* A metadata traits-class decorator for the arrangement package. It traces the
* invocations of traits-class functors. It is parameterized with another traits
* class and inherits from it. For each traits method it prints out its input
* parameters and its output result
*
* It models all the concepts that the original traits models.
*/
template <typename BaseTraits>
class Arr_tracing_traits_2 : public BaseTraits {
public:
enum Operation_id {
COMPARE_X_2_OP = 0,
COMPARE_XY_2_OP,
CONSTRUCT_MIN_VERTEX_2_OP,
CONSTRUCT_MAX_VERTEX_2_OP,
IS_VERTICAL_2_OP,
COMPARE_Y_AT_X_2_OP,
EQUAL_POINTS_2_OP,
EQUAL_CURVES_2_OP,
COMPARE_Y_AT_X_LEFT_2_OP,
COMPARE_Y_AT_X_RIGHT_2_OP,
MAKE_X_MONOTONE_2_OP,
SPLIT_2_OP,
INTERSECT_2_OP,
ARE_MERGEABLE_2_OP,
MERGE_2_OP,
CONSTRUCT_2_OPPOSITE_2_OP,
COMPARE_ENDPOINTS_XY_2_OP,
APPROXIMATE_2_OP,
PARAMETER_SPACE_IN_X_2_OP,
IS_ON_X_IDENTIFICATION_2_OP,
COMPARE_Y_ON_BOUNDARY_2_OP,
COMPARE_Y_NEAR_BOUNDARY_2_OP,
PARAMETER_SPACE_IN_Y_2_OP,
IS_ON_Y_IDENTIFICATION_2_OP,
COMPARE_X_ON_BOUNDARY_2_OP,
COMPARE_X_NEAR_BOUNDARY_2_OP,
NUMBER_OF_OPERATIONS
};
public:
/// \name Creation
/// @{
/*! constructs default */
template<typename ... Args>
Arr_tracing_traits_2(Args ... args) : Base(std::forward<Args>(args)...) {}
/*! disables copy constructor. */
Arr_tracing_traits_2(const Arr_tracing_traits_2&) = delete;
/// @}
/*! enables the trace of a traits operation
* \param id the operation identifier
*/
void enable_trace(Operation_id id);
/*! enables the trace of all traits operations
*/
void enable_all_traces();
/*! disables the trace of a traits operation
* \param id the operation identifier
*/
void disable_trace(Operation_id id);
/*! disables the trace of all traits operations
*/
void disable_all_traces();
/// \name Types and functors inherited from `BaseTraits`
/// @{
using Has_left_category = typename Base::Has_left_category;
using Has_merge_category = typename Base::Has_merge_category;
using Has_do_intersect_category = typename Base::Has_do_intersect_category;
using Left_side_category =
typename internal::Arr_complete_left_side_category< Base >::Category;
using Bottom_side_category =
typename internal::Arr_complete_bottom_side_category< Base >::Category;
using Top_side_category =
typename internal::Arr_complete_top_side_category< Base >::Category;
using Right_side_category =
typename internal::Arr_complete_right_side_category< Base >::Category;
using Point_2 = typename Base::Point_2;
using X_monotone_curve_2 = typename Base::X_monotone_curve_2;
using Curve_2 = typename Base::Curve_2;
using Multiplicity = typename Base::Multiplicity;
/// @}
/// \name Obtain the appropriate functor
/// @{
Compare_x_2 compare_x_2_object() const;
Compare_xy_2 compare_xy_2_object() const;
Construct_min_vertex_2 construct_min_vertex_2_object() const;
Construct_max_vertex_2 construct_max_vertex_2_object() const;
Is_vertical_2 is_vertical_2_object() const;
Compare_y_at_x_2 compare_y_at_x_2_object() const;
Equal_2 equal_2_object() const;
Compare_y_at_x_left_2 compare_y_at_x_left_2_object() const;
Compare_y_at_x_right_2 compare_y_at_x_right_2_object() const;
Make_x_monotone_2 make_x_monotone_2_object() const;
Split_2 split_2_object() const;
Intersect_2 intersect_2_object() const;
Are_mergeable_2 are_mergeable_2_object() const;
Merge_2 merge_2_object() const;
Construct_opposite_2 construct_opposite_2_object() const;
Compare_endpoints_xy_2 compare_endpoints_xy_2_object() const;
Approximate_2 approximate_2_object() const;
Parameter_space_in_x_2 parameter_space_in_x_2_object() const;
Is_on_x_identification_2 is_on_x_identification_2_object() const;
Compare_y_on_boundary_2 compare_y_on_boundary_2_object() const;
Compare_y_near_boundary_2 compare_y_near_boundary_2_object() const;
Parameter_space_in_y_2 parameter_space_in_y_2_object() const;
Is_on_y_identification_2 is_on_y_identification_2_object() const;
Compare_x_on_boundary_2 compare_x_on_boundary_2_object() const;
Compare_x_near_boundary_2 compare_x_near_boundary_2_object() const;
/// @}
};
template <typename OutputStream>
OutputStream& operator<<(OutputStream& os, Comparison_result cr);
} // namespace CGAL

View File

@ -49,10 +49,10 @@ public:
/// \name Creation
/// @{
/*! Default constructor. */
/*! constructs default. */
Arr_unb_planar_topology_traits_2();
/*! Constructor from a geometry-traits object.
/*! constructs from a geometry-traits object.
* \param traits the traits.
*/
Arr_unb_planar_topology_traits_2(const GeometryTraits_2* traits);

View File

@ -363,8 +363,8 @@ remove_edge(Arrangement_2<Traits,Dcel>& arr,
* Attempts to removed a given vertex from a given arrangement. The vertex can
* be removed if it is either an isolated vertex, (and has no incident edge,) or
* if it is a <I>redundant</I> vertex. That is, it has exactly two incident
* edges, whose associated curves can be merged to form a single \f$
* x\f$-monotone curve. The function returns a boolean value that indicates
* edges, whose associated curves can be merged to form a single \f$x\f$-monotone
* curve. The function returns a boolean value that indicates
* whether it succeeded removing the vertex from the arrangement.
*
* \cgalHeading{Requirements}

View File

@ -27,6 +27,7 @@ public:
/// \name Functor Types
/// @{
/// @}
/// \name Accessing Functor Objects
/// @{

View File

@ -31,6 +31,7 @@ public:
/// \name Functor Types
/// @{
/// @}
/// \name Accessing Functor Objects
/// @{

View File

@ -31,6 +31,7 @@ public:
/// \name Functor Types
/// @{
/// @}
/// \name Accessing Functor Objects
/// @{

View File

@ -31,6 +31,7 @@ public:
/// \name Functor Types
/// @{
/// @}
/// \name Accessing Functor Objects
/// @{

View File

@ -31,6 +31,7 @@ public:
/// \name Functor Types
/// @{
/// @}
/// \name Accessing Functor Objects
/// @{

View File

@ -28,6 +28,7 @@ public:
/// \name Functor Types
/// @{
/// @}
/// \name Accessing Functor Objects
/// @{

View File

@ -32,6 +32,7 @@ public:
/// \name Functor Types
/// @{
/// @}
/// \name Accessing Functor Objects
/// @{

View File

@ -32,6 +32,7 @@ public:
/// \name Functor Types
/// @{
/// @}
/// \name Accessing Functor Objects
/// @{

View File

@ -32,6 +32,7 @@ public:
/// \name Functor Types
/// @{
/// @}
/// \name Accessing Functor Objects
/// @{

View File

@ -32,6 +32,7 @@ public:
/// \name Functor Types
/// @{
/// @}
/// \name Accessing Functor Objects
/// @{

View File

@ -27,6 +27,7 @@ public:
/// \name Functor Types
/// @{
/// @}
/// \name Accessing Functor Objects
/// @{

View File

@ -27,6 +27,7 @@ public:
/// \name Functor Types
/// @{
/// @}
/// \name Accessing Functor Objects
/// @{

Some files were not shown because too many files have changed in this diff Show More