mirror of https://github.com/CGAL/cgal
Merge branch 'master' into Aos_2-traits_concept-efif
This commit is contained in:
commit
669d83b469
|
|
@ -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
|
||||||
|
|
@ -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))
|
||||||
|
|
@ -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
|
||||||
|
|
@ -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"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
@ -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
|
||||||
|
|
@ -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 text eol=lf
|
||||||
Scripts/developer_scripts/create_cgal_test_with_cmake 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_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/create_new_release text eol=lf
|
||||||
Scripts/developer_scripts/detect_files_with_mixed_eol_styles text eol=lf
|
Scripts/developer_scripts/detect_files_with_mixed_eol_styles text eol=lf
|
||||||
Scripts/developer_scripts/detect_packages_licenses text eol=lf
|
Scripts/developer_scripts/detect_packages_licenses text eol=lf
|
||||||
|
|
|
||||||
|
|
@ -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._
|
_Please use the following template to help us solving your issue._
|
||||||
|
|
||||||
## Issue Details
|
## Issue Details
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
blank_issues_enabled: false
|
||||||
|
|
@ -1,56 +1,115 @@
|
||||||
name: Documentation
|
name: Build Documentation
|
||||||
|
|
||||||
on:
|
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:
|
issue_comment:
|
||||||
types: [created]
|
types: [created]
|
||||||
|
|
||||||
|
env:
|
||||||
|
author_association: ${{ github.event.comment.author_association }}
|
||||||
|
comment_body: ${{ github.event.comment.body }}
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read # to fetch code (actions/checkout)
|
contents: read # to fetch code (actions/checkout)
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
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:
|
||||||
|
- 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: |
|
||||||
|
if ( context.payload.input && context.payload.inputs.doc_version ) {
|
||||||
|
return context.payload.inputs.doc_version
|
||||||
|
}
|
||||||
|
const body = context.payload.comment.body
|
||||||
|
const re = /\/(force-)?build:(\w+)\s*/;
|
||||||
|
if(re.test(body)) {
|
||||||
|
const res = re.exec(body)
|
||||||
|
return res[2]
|
||||||
|
}
|
||||||
|
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:
|
permissions:
|
||||||
contents: read # to fetch code (actions/checkout)
|
contents: read # to fetch code (actions/checkout)
|
||||||
pull-requests: write # to create comment
|
pull-requests: write # to create comment
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
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:
|
steps:
|
||||||
- uses: actions/github-script@v7
|
|
||||||
id: get_round
|
|
||||||
with:
|
|
||||||
result-encoding: string
|
|
||||||
script: |
|
|
||||||
const asso = context.payload.comment.author_association
|
|
||||||
if(asso == 'OWNER' || asso == 'MEMBER') {
|
|
||||||
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"
|
|
||||||
}
|
|
||||||
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
|
|
||||||
|
|
||||||
- name: Emoji-comment
|
- name: Emoji-comment
|
||||||
|
if: github.event_name == 'issue_comment'
|
||||||
|
continue-on-error: true
|
||||||
uses: actions/github-script@v7
|
uses: actions/github-script@v7
|
||||||
if: steps.get_round.outputs.result != 'stop'
|
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
github.rest.reactions.createForIssueComment({
|
github.rest.reactions.createForIssueComment({
|
||||||
|
|
@ -62,17 +121,23 @@ jobs:
|
||||||
|
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
name: "checkout branch"
|
name: "checkout branch"
|
||||||
if: steps.get_round.outputs.result != 'stop'
|
|
||||||
with:
|
with:
|
||||||
repository: ${{ github.repository }}
|
repository: ${{ github.repository }}
|
||||||
ref: refs/pull/${{ steps.get_pr_number.outputs.result }}/merge
|
ref: refs/pull/${{ env.pr_number }}/head
|
||||||
fetch-depth: 2
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: install dependencies
|
- name: Install dependencies
|
||||||
if: steps.get_round.outputs.result != 'stop'
|
|
||||||
run: |
|
run: |
|
||||||
set -x
|
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 lxml
|
||||||
sudo pip install pyquery
|
sudo pip install pyquery
|
||||||
wget --no-verbose -O doxygen_exe https://cgal.geometryfactory.com/~cgaltest/doxygen_1_9_6_patched/doxygen
|
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.email "cgal@geometryfactory.com"
|
||||||
git config --global user.name "cgaltest"
|
git config --global user.name "cgaltest"
|
||||||
|
|
||||||
- name: configure all
|
- name: CMake configuration of Documentation/doc
|
||||||
if: steps.get_round.outputs.result != 'stop'
|
|
||||||
run: |
|
run: |
|
||||||
set -ex
|
set -ex
|
||||||
mkdir -p build_doc && cd build_doc && cmake ../Documentation/doc
|
mkdir -p build_doc && cd build_doc && cmake ../Documentation/doc
|
||||||
|
|
||||||
- name: Build and Upload Doc
|
- name: Build and upload Doc
|
||||||
id: build_and_run
|
id: build_and_run
|
||||||
if: steps.get_round.outputs.result != 'stop'
|
env:
|
||||||
|
GH_TOKEN: ${{ github.token }}
|
||||||
run: |
|
run: |
|
||||||
set -ex
|
set -ex
|
||||||
PR_NUMBER=${{ steps.get_pr_number.outputs.result }}
|
PR_NUMBER=$pr_number
|
||||||
TMP_ROUND=${{ steps.get_round.outputs.result }}
|
ROUND=$doc_version
|
||||||
ROUND=$(echo $TMP_ROUND | cut -d ":" -f 1)
|
force=$force_build
|
||||||
force=$(echo $TMP_ROUND | cut -d ":" -f 2)
|
wget --no-verbose cgal.github.io -O index.html
|
||||||
wget --no-verbose cgal.github.io -O tmp.html
|
if ! egrep -qF "/$PR_NUMBER/$ROUND" index.html || [ "$force" = "yes" ]; then
|
||||||
if ! egrep -q "\/$PR_NUMBER\/$ROUND" tmp.html || [ "$force" = "yes" ]; then
|
|
||||||
#list impacted packages
|
#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
|
if [ "$LIST_OF_PKGS" = "" ]; then
|
||||||
echo "DoxygenError=No package affected." >> $GITHUB_OUTPUT
|
echo "DoxygenError=No package affected." >> $GITHUB_OUTPUT
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
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
|
cd build_doc && make -j$(nproc) doc
|
||||||
make -j$(nproc) doc_with_postprocessing 2>tmp.log
|
make -j$(nproc) doc_with_postprocessing 2>build.log
|
||||||
if [ -s tmp.log ]; then
|
if [ -s build.log ]; then
|
||||||
content=`cat ./tmp.log`
|
|
||||||
delimiter="$(openssl rand -hex 8)"
|
delimiter="$(openssl rand -hex 8)"
|
||||||
echo "DoxygenError<<${delimiter}" >> "${GITHUB_OUTPUT}"
|
echo "DoxygenError<<${delimiter}" >> "${GITHUB_OUTPUT}"
|
||||||
cat tmp.log >> "${GITHUB_OUTPUT}"
|
cat build.log >> "${GITHUB_OUTPUT}"
|
||||||
echo "${delimiter}" >> "${GITHUB_OUTPUT}"
|
echo "${delimiter}" >> "${GITHUB_OUTPUT}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
@ -118,18 +187,16 @@ jobs:
|
||||||
git clone https://CGAL:${{ secrets.PUSH_TO_CGAL_GITHUB_IO_TOKEN }}@github.com/CGAL/cgal.github.io.git
|
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
|
mkdir -p cgal.github.io/${PR_NUMBER}/$ROUND
|
||||||
rm cgal.github.io/${PR_NUMBER}/$ROUND/* -rf
|
rm cgal.github.io/${PR_NUMBER}/$ROUND/* -rf
|
||||||
for f in $LIST_OF_PKGS
|
for f in $LIST_OF_PKGS Manual
|
||||||
do
|
do
|
||||||
if [ -d ./build_doc/doc_output/$f ]; then
|
if [ -d ./build_doc/doc_output/$f ]; then
|
||||||
cp -r ./build_doc/doc_output/$f ./cgal.github.io/${PR_NUMBER}/$ROUND
|
cp -r ./build_doc/doc_output/$f ./cgal.github.io/${PR_NUMBER}/$ROUND
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
cp -r ./build_doc/doc_output/Manual ./cgal.github.io/${PR_NUMBER}/$ROUND
|
|
||||||
cd ./cgal.github.io
|
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>" >> ./index.html
|
||||||
echo "<li><a href=https://cgal.github.io/${PR_NUMBER}/$ROUND/Manual/index.html>Manual for PR ${PR_NUMBER} ($ROUND).</a></li>" >> ./tmp.html
|
./cleanup.bash
|
||||||
mv tmp.html index.html
|
git add ${PR_NUMBER}/$ROUND index.html && git commit -q --amend -m "sole commit" && git push -q -f -u origin master
|
||||||
git add ${PR_NUMBER}/$ROUND index.html && git commit -q --amend -m "base commit" && git push -q -f -u origin master
|
|
||||||
else
|
else
|
||||||
echo "DoxygenError=This round already exists. Overwrite it with /force-build." >> $GITHUB_OUTPUT
|
echo "DoxygenError=This round already exists. Overwrite it with /force-build." >> $GITHUB_OUTPUT
|
||||||
exit 1
|
exit 1
|
||||||
|
|
@ -137,13 +204,11 @@ jobs:
|
||||||
|
|
||||||
- name: Post address
|
- name: Post address
|
||||||
uses: actions/github-script@v7
|
uses: actions/github-script@v7
|
||||||
if: ${{ success() && steps.get_round.outputs.result != 'stop' }}
|
if: ${{ success() }}
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
const tmp_round = "${{ steps.get_round.outputs.result }}";
|
const round = "${{ env.doc_version }}"
|
||||||
const id = tmp_round.indexOf(":");
|
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"
|
||||||
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"
|
|
||||||
github.rest.issues.createComment({
|
github.rest.issues.createComment({
|
||||||
owner: "CGAL",
|
owner: "CGAL",
|
||||||
repo: "cgal",
|
repo: "cgal",
|
||||||
|
|
@ -155,7 +220,7 @@ jobs:
|
||||||
env:
|
env:
|
||||||
ERRORMSG: ${{steps.build_and_run.outputs.DoxygenError}}
|
ERRORMSG: ${{steps.build_and_run.outputs.DoxygenError}}
|
||||||
uses: actions/github-script@v7
|
uses: actions/github-script@v7
|
||||||
if: ${{ failure() && steps.get_round.outputs.result != 'stop' }}
|
if: ${{ failure() }}
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
const error = process.env.ERRORMSG
|
const error = process.env.ERRORMSG
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,8 @@ permissions:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
if: github.repository == 'CGAL/cgal' || github.event_name != 'push'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: install dependencies
|
- name: install dependencies
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,8 @@ permissions:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
cmake-testsuite:
|
cmake-testsuite:
|
||||||
|
if: github.repository == 'CGAL/cgal' || github.event_name != 'push'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: install dependencies
|
- name: install dependencies
|
||||||
|
|
@ -21,9 +20,8 @@ jobs:
|
||||||
ctest -L Installation -j $(getconf _NPROCESSORS_ONLN)
|
ctest -L Installation -j $(getconf _NPROCESSORS_ONLN)
|
||||||
|
|
||||||
cmake-testsuite-with-qt:
|
cmake-testsuite-with-qt:
|
||||||
|
if: github.repository == 'CGAL/cgal' || github.event_name != 'push'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: install dependencies
|
- name: install dependencies
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,33 @@
|
||||||
name: Documentation Removal
|
name: Documentation Removal
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
PR_NUMBER:
|
||||||
|
description: 'Pull request number for which the documentation should be removed'
|
||||||
|
type: number
|
||||||
|
required: true
|
||||||
pull_request_target:
|
pull_request_target:
|
||||||
types: [closed, removed, workflow_dispatch]
|
types: [closed]
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
delete_doc:
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write # for Git to git push
|
contents: write # for Git to git push
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- 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: |
|
run: |
|
||||||
set -x
|
set -x
|
||||||
git config --global user.email "cgal@geometryfactory.com"
|
git config --global user.email "cgal@geometryfactory.com"
|
||||||
git config --global user.name "cgaltest"
|
git config --global user.name "cgaltest"
|
||||||
git clone https://CGAL:${{ secrets.PUSH_TO_CGAL_GITHUB_IO_TOKEN }}@github.com/CGAL/cgal.github.io.git
|
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/
|
cd cgal.github.io/
|
||||||
egrep -v " ${PR_NUMBER}\." index.html > tmp.html || true
|
egrep -v " ${PR_NUMBER}\." index.html > tmp.html || true
|
||||||
if [ -n "$(diff -q ./index.html ./tmp.html)" ]; then
|
if [ -n "$(diff -q ./index.html ./tmp.html)" ]; then
|
||||||
|
|
|
||||||
|
|
@ -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
|
|
||||||
});
|
|
||||||
|
|
@ -10,17 +10,18 @@ jobs:
|
||||||
reuse:
|
reuse:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- name: Checkout
|
||||||
- name: REUSE version
|
uses: actions/checkout@v4
|
||||||
uses: fsfe/reuse-action@v4
|
- name: Display reuse-tool version
|
||||||
|
uses: fsfe/reuse-action@v5
|
||||||
with:
|
with:
|
||||||
args: --version
|
args: --version
|
||||||
- name: REUSE lint
|
- name: REUSE Compliance Check
|
||||||
uses: fsfe/reuse-action@v4
|
uses: fsfe/reuse-action@v5
|
||||||
with:
|
with:
|
||||||
args: --include-submodules lint
|
args: --include-submodules lint
|
||||||
- name: REUSE SPDX SBOM
|
- name: REUSE SPDX SBOM
|
||||||
uses: fsfe/reuse-action@v4
|
uses: fsfe/reuse-action@v5
|
||||||
with:
|
with:
|
||||||
args: spdx
|
args: spdx
|
||||||
- name: install dependencies
|
- name: install dependencies
|
||||||
|
|
@ -29,7 +30,7 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
mkdir -p ./release
|
mkdir -p ./release
|
||||||
cmake -DDESTINATION=./release -DCGAL_VERSION=9.9 -P ./Scripts/developer_scripts/cgal_create_release_with_cmake.cmake
|
cmake -DDESTINATION=./release -DCGAL_VERSION=9.9 -P ./Scripts/developer_scripts/cgal_create_release_with_cmake.cmake
|
||||||
- name: REUSE lint release tarball
|
- name: REUSE Compliance Check of release tarball
|
||||||
uses: fsfe/reuse-action@v4
|
uses: fsfe/reuse-action@v5
|
||||||
with:
|
with:
|
||||||
args: --root ./release/CGAL-9.9 --include-submodules lint
|
args: --root ./release/CGAL-9.9 --include-submodules lint
|
||||||
|
|
|
||||||
|
|
@ -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
|
.DS_Store
|
||||||
|
|
||||||
# Binaries:
|
# Binaries:
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"default": true,
|
||||||
|
"line-length": false,
|
||||||
|
"no-duplicate-heading": {
|
||||||
|
"siblings_only": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -14,7 +14,7 @@ find_package(Qt6 QUIET COMPONENTS Gui OpenGL)
|
||||||
|
|
||||||
if(CGAL_Qt6_FOUND AND Qt6_FOUND)
|
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.
|
# Instruct CMake to run moc/ui/rcc automatically when needed.
|
||||||
set(CMAKE_AUTOMOC ON)
|
set(CMAKE_AUTOMOC ON)
|
||||||
|
|
|
||||||
|
|
@ -551,7 +551,7 @@ public:
|
||||||
traits.intersection(query, singleton_data());
|
traits.intersection(query, singleton_data());
|
||||||
break;
|
break;
|
||||||
default: // if(size() >= 2)
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* @brief General traversal query
|
* @brief General traversal query
|
||||||
* @param query the 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
|
* @param nb_primitives the number of primitive
|
||||||
*
|
*
|
||||||
* General traversal query. The traits class allows using it for the various
|
* General traversal query. The traits class allows using it for the various
|
||||||
|
|
|
||||||
|
|
@ -426,7 +426,7 @@ void test_algebraic_structure_intern(
|
||||||
//commutative
|
//commutative
|
||||||
assert(a+b+c==c+b+a);
|
assert(a+b+c==c+b+a);
|
||||||
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);
|
||||||
assert((a+b)*c==a*c+b*c);
|
assert((a+b)*c==a*c+b*c);
|
||||||
//binom
|
//binom
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ namespace CGAL {
|
||||||
\section Algebraic_kernel_dIntroduction Introduction
|
\section Algebraic_kernel_dIntroduction Introduction
|
||||||
|
|
||||||
Real solving of polynomials is a fundamental problem with a wide application range.
|
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
|
algorithms to determine, compare, and approximate real roots of univariate polynomials
|
||||||
and bivariate polynomial systems. Such a black-box is called an *Algebraic Kernel*.
|
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
|
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
|
Querying such a representation by calling `Compute_y_2` is a
|
||||||
time-consuming step, and should be avoided for efficiency reasons if possible.
|
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
|
\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,
|
contribution of all authors of the \exacus project,
|
||||||
particularly the contribution of Arno Eigenwillig, Sebastian Limbach and Pavel Emeliyanenko.
|
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
|
In 2010, two univariate kernels that interface the library RS \cgalCite{cgal:r-rs} were
|
||||||
written by Luis Peñaranda and Sylvain Lazard.
|
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.
|
Both models interface the library RS \cgalCite{cgal:r-rs} by Fabrice Rouillier.
|
||||||
The authors want to thank Fabrice Rouillier and Elias Tsigaridas for
|
The authors want to thank Fabrice Rouillier and Elias Tsigaridas for
|
||||||
strong support and many useful discussions that lead to the integration of RS.
|
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 */
|
} /* namespace CGAL */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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 */
|
|
||||||
|
|
@ -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 */
|
|
||||||
|
|
@ -9,8 +9,7 @@ algebraic functionalities on univariate polynomials of general degree \f$ d\f$.
|
||||||
\cgalRefines{CopyConstructible,Assignable}
|
\cgalRefines{CopyConstructible,Assignable}
|
||||||
|
|
||||||
\cgalHasModelsBegin
|
\cgalHasModelsBegin
|
||||||
\cgalHasModels{CGAL::Algebraic_kernel_rs_gmpz_d_1}
|
\cgalHasModels{CGAL::Algebraic_kernel_d_1}
|
||||||
\cgalHasModels{CGAL::Algebraic_kernel_rs_gmpq_d_1}
|
|
||||||
\cgalHasModelsEnd
|
\cgalHasModelsEnd
|
||||||
|
|
||||||
\sa `AlgebraicKernel_d_2`
|
\sa `AlgebraicKernel_d_2`
|
||||||
|
|
@ -172,4 +171,3 @@ AlgebraicKernel_d_1::Bound_between_1 bound_between_1_object() const;
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
}; /* end AlgebraicKernel_d_1 */
|
}; /* end AlgebraicKernel_d_1 */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,11 @@ for solving and handling bivariate polynomial systems of general degree \f$ d\f$
|
||||||
|
|
||||||
\cgalRefines{AlgebraicKernel_d_1,CopyConstructible,Assignable}
|
\cgalRefines{AlgebraicKernel_d_1,CopyConstructible,Assignable}
|
||||||
|
|
||||||
|
|
||||||
|
\cgalHasModelsBegin
|
||||||
|
\cgalHasModels{CGAL::Algebraic_kernel_d_2}
|
||||||
|
\cgalHasModelsEnd
|
||||||
|
|
||||||
\sa `AlgebraicKernel_d_1`
|
\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 */
|
}; /* end AlgebraicKernel_d_2 */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,12 +21,11 @@
|
||||||
\cgalPkgPicture{Algebraic_kernel_d.png}
|
\cgalPkgPicture{Algebraic_kernel_d.png}
|
||||||
\cgalPkgSummaryBegin
|
\cgalPkgSummaryBegin
|
||||||
\cgalPkgAuthors{Eric Berberich, Michael Hemmer, Michael Kerber, Sylvain Lazard, Luis Peñaranda, and Monique Teillaud}
|
\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}
|
\cgalPkgManuals{Chapter_Algebraic_Kernel,PkgAlgebraicKernelDRef}
|
||||||
\cgalPkgSummaryEnd
|
\cgalPkgSummaryEnd
|
||||||
\cgalPkgShortInfoBegin
|
\cgalPkgShortInfoBegin
|
||||||
\cgalPkgSince{3.6}
|
\cgalPkgSince{3.6}
|
||||||
\cgalPkgDependsOn{Some models depend on \ref thirdpartyRS3.}
|
|
||||||
\cgalPkgBib{cgal:bht-ak}
|
\cgalPkgBib{cgal:bht-ak}
|
||||||
\cgalPkgLicense{\ref licensesLGPL "LGPL"}
|
\cgalPkgLicense{\ref licensesLGPL "LGPL"}
|
||||||
\cgalPkgShortInfoEnd
|
\cgalPkgShortInfoEnd
|
||||||
|
|
@ -100,8 +99,4 @@
|
||||||
- `CGAL::Algebraic_kernel_d_1<Coeff>`
|
- `CGAL::Algebraic_kernel_d_1<Coeff>`
|
||||||
- `CGAL::Algebraic_kernel_d_2<Coeff>`
|
- `CGAL::Algebraic_kernel_d_2<Coeff>`
|
||||||
|
|
||||||
- `CGAL::Algebraic_kernel_rs_gmpz_d_1`
|
|
||||||
- `CGAL::Algebraic_kernel_rs_gmpq_d_1`
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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 {};
|
class Virtual_method_exception {};
|
||||||
|
|
||||||
|
|
@ -128,7 +128,7 @@ public:
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Constructor computing an interval containing all real roots of \c f,
|
* 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,
|
Generic_descartes_rep(Bitstream_descartes_type type,
|
||||||
Polynomial f,
|
Polynomial f,
|
||||||
|
|
@ -170,7 +170,7 @@ public:
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Constructor that copies the Bitstream tree given from outside
|
* 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
|
* The tree must "fit" to the polynomial
|
||||||
*/
|
*/
|
||||||
Generic_descartes_rep(Bitstream_descartes_type type,
|
Generic_descartes_rep(Bitstream_descartes_type type,
|
||||||
|
|
@ -367,7 +367,7 @@ public:
|
||||||
/*!
|
/*!
|
||||||
* \brief When does the isolation algorithm terminate?
|
* \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() {
|
virtual bool termination_condition() {
|
||||||
throw Virtual_method_exception();
|
throw Virtual_method_exception();
|
||||||
|
|
@ -378,7 +378,7 @@ public:
|
||||||
* \brief gives an opportunity to process the nodes after
|
* \brief gives an opportunity to process the nodes after
|
||||||
* the subdivision steps are finished
|
* 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.
|
* remain empty in many cases.
|
||||||
*/
|
*/
|
||||||
virtual void process_nodes() {
|
virtual void process_nodes() {
|
||||||
|
|
@ -389,7 +389,7 @@ public:
|
||||||
/*! \brief returns whether the \c i th root is definitely a simple root
|
/*! \brief returns whether the \c i th root is definitely a simple root
|
||||||
* of the isolated polynomial
|
* of the isolated polynomial
|
||||||
*
|
*
|
||||||
* Must be specialised by derived class
|
* Must be specialized by derived class
|
||||||
*/
|
*/
|
||||||
virtual bool is_certainly_simple_root(int) const {
|
virtual bool is_certainly_simple_root(int) const {
|
||||||
throw Virtual_method_exception();
|
throw Virtual_method_exception();
|
||||||
|
|
@ -399,7 +399,7 @@ public:
|
||||||
/*! \brief returns whether the \c i th root is definitely a multiple root
|
/*! \brief returns whether the \c i th root is definitely a multiple root
|
||||||
* of the isolated polynomial
|
* of the isolated polynomial
|
||||||
*
|
*
|
||||||
* Must be specialised by derived class
|
* Must be specialized by derived class
|
||||||
*/
|
*/
|
||||||
virtual bool is_certainly_multiple_root(int) const {
|
virtual bool is_certainly_multiple_root(int) const {
|
||||||
throw Virtual_method_exception();
|
throw Virtual_method_exception();
|
||||||
|
|
@ -1082,7 +1082,7 @@ protected:
|
||||||
* variant of the Bitstream Descartes method: The Square_free_descartes_tag
|
* variant of the Bitstream Descartes method: The Square_free_descartes_tag
|
||||||
* starts the usual Bitstream method for square free integer polynomials.
|
* 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
|
* 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
|
* even more complicated polynomials, if the multiple roots with even
|
||||||
* multiplicity can be refined from outside. See the corresponding
|
* multiplicity can be refined from outside. See the corresponding
|
||||||
* constructors for more information.
|
* constructors for more information.
|
||||||
|
|
|
||||||
|
|
@ -865,7 +865,7 @@ public:
|
||||||
by trying randomly and checking. This randomization means
|
by trying randomly and checking. This randomization means
|
||||||
the same polynomial and same initial interval may give rise
|
the same polynomial and same initial interval may give rise
|
||||||
to different intervals each time this class is used.
|
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
|
with a small denominator. Hence we first try denominator
|
||||||
2 (subdivision at midpoint), then denominator 16, and
|
2 (subdivision at midpoint), then denominator 16, and
|
||||||
only then the "proper" denominator prescribed by theory.
|
only then the "proper" denominator prescribed by theory.
|
||||||
|
|
|
||||||
|
|
@ -469,7 +469,7 @@ public:
|
||||||
* (\c SHEAR_ONLY_AT_IRRATIONAL_STRATEGY)
|
* (\c SHEAR_ONLY_AT_IRRATIONAL_STRATEGY)
|
||||||
* is to \c shear the curve
|
* is to \c shear the curve
|
||||||
* if a degenerate situation is detected during the analysis,
|
* 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
|
* more directly. The analysis
|
||||||
* is then performed in the sheared system, and finally translated back
|
* is then performed in the sheared system, and finally translated back
|
||||||
* into the original system.
|
* into the original system.
|
||||||
|
|
@ -520,7 +520,7 @@ private:
|
||||||
void set_event_lines(InputIterator1 event_begin,
|
void set_event_lines(InputIterator1 event_begin,
|
||||||
InputIterator1 event_end,
|
InputIterator1 event_end,
|
||||||
InputIterator2 intermediate_begin,
|
InputIterator2 intermediate_begin,
|
||||||
InputIterator2 CGAL_precondition_code(intermediate_end)) const {
|
InputIterator2 CGAL_assertion_code(intermediate_end)) const {
|
||||||
|
|
||||||
if(! this->ptr()->event_coordinates) {
|
if(! this->ptr()->event_coordinates) {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -875,7 +875,7 @@ private:
|
||||||
* Checks intersection with symbolic methods
|
* Checks intersection with symbolic methods
|
||||||
*/
|
*/
|
||||||
bool check_candidate_symbolically(Status_line_CA_1& e1,size_type ,
|
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 {
|
size_type k) const {
|
||||||
Polynomial_1 p = -coprincipal_subresultants(k-1);
|
Polynomial_1 p = -coprincipal_subresultants(k-1);
|
||||||
Polynomial_1 q = principal_subresultants(k)*Coefficient(k);
|
Polynomial_1 q = principal_subresultants(k)*Coefficient(k);
|
||||||
|
|
@ -1173,7 +1173,7 @@ private:
|
||||||
/*
|
/*
|
||||||
* \brief reduces the number of possible intersections
|
* \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
|
* 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
|
* until there are only \c n possible intersection points. The method can
|
||||||
* be interrupted if all possible intersection points are known to have
|
* be interrupted if all possible intersection points are known to have
|
||||||
|
|
|
||||||
|
|
@ -140,7 +140,7 @@ public:
|
||||||
virtual ~LRU_hashed_map()
|
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
|
* If the object is not in the map, it is constructed using \c Creator
|
||||||
* and added to the map
|
* and added to the map
|
||||||
|
|
@ -312,7 +312,7 @@ public:
|
||||||
~LRU_hashed_map_with_kernel()
|
~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
|
* If the object is not in the map, it is constructed using \c Creator
|
||||||
* and added to the map
|
* and added to the map
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ template < class PolynomialIterator,
|
||||||
int gen_agebraic_reals_with_mults( PolynomialIterator fac,
|
int gen_agebraic_reals_with_mults( PolynomialIterator fac,
|
||||||
PolynomialIterator fac_end,
|
PolynomialIterator fac_end,
|
||||||
IntIterator mul,
|
IntIterator mul,
|
||||||
IntIterator CGAL_precondition_code(mul_end),
|
IntIterator CGAL_assertion_code(mul_end),
|
||||||
AlgebraicRealOutputIterator oi_root,
|
AlgebraicRealOutputIterator oi_root,
|
||||||
IntOutputIterator oi_mult){
|
IntOutputIterator oi_mult){
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -331,7 +331,7 @@ public:
|
||||||
const typename Curve_pair_analysis_2
|
const typename Curve_pair_analysis_2
|
||||||
::Curve_analysis_2& c1,
|
::Curve_analysis_2& c1,
|
||||||
const typename Curve_pair_analysis_2
|
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());
|
CGAL_precondition(0 <= j && j < number_of_events());
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ namespace CGAL {
|
||||||
/*!
|
/*!
|
||||||
* \brief Exception class for not sufficiently generic positions.
|
* \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".
|
* is not "good enough".
|
||||||
*/
|
*/
|
||||||
class Non_generic_position_exception {
|
class Non_generic_position_exception {
|
||||||
|
|
@ -40,7 +40,7 @@ namespace CGAL {
|
||||||
/*!
|
/*!
|
||||||
* \brief Exception class for not sufficiently generic positions.
|
* \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".
|
* is not "good enough".
|
||||||
*/
|
*/
|
||||||
template<typename Polynomial>
|
template<typename Polynomial>
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If set, the curve and curve pair analysis are using specialized code
|
* 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
|
#ifndef CGAL_ACK_USE_SPECIAL_TREATMENT_FOR_CONIX
|
||||||
#define CGAL_ACK_USE_SPECIAL_TREATMENT_FOR_CONIX 0
|
#define CGAL_ACK_USE_SPECIAL_TREATMENT_FOR_CONIX 0
|
||||||
|
|
|
||||||
|
|
@ -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
|
|
||||||
|
|
@ -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
|
|
||||||
|
|
@ -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
|
|
||||||
|
|
@ -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
|
|
||||||
|
|
@ -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
|
|
||||||
|
|
@ -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
|
|
||||||
|
|
@ -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
|
|
||||||
|
|
@ -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
|
|
||||||
|
|
@ -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
|
|
||||||
|
|
@ -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
|
|
||||||
|
|
@ -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
|
|
||||||
|
|
@ -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
|
|
||||||
|
|
@ -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
|
|
||||||
|
|
@ -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
|
|
||||||
|
|
@ -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
|
|
||||||
|
|
@ -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
|
|
||||||
|
|
@ -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
|
|
||||||
|
|
@ -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
|
|
||||||
|
|
@ -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
|
|
||||||
|
|
@ -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
|
|
||||||
|
|
@ -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
|
|
||||||
|
|
@ -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
|
|
||||||
|
|
@ -10,11 +10,6 @@ if(MPFI_FOUND)
|
||||||
include(${MPFI_USE_FILE})
|
include(${MPFI_USE_FILE})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
find_package(RS3 QUIET)
|
|
||||||
if(RS3_FOUND)
|
|
||||||
message(STATUS "Found RS3")
|
|
||||||
include(${RS3_USE_FILE})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# include for local directory
|
# include for local directory
|
||||||
include_directories(BEFORE include)
|
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("Curve_pair_analysis_2.cpp")
|
||||||
create_single_source_cgal_program("Real_embeddable_traits_extension.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()
|
else()
|
||||||
message(STATUS "NOTICE: Some tests require GMP support, and will not be compiled.")
|
message(STATUS "NOTICE: Some tests require GMP support, and will not be compiled.")
|
||||||
endif()
|
endif()
|
||||||
|
|
|
||||||
|
|
@ -330,7 +330,7 @@ template<typename Arithmetic_kernel> void test_routine() {
|
||||||
#endif
|
#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)])]");
|
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);
|
Curve_analysis_2 curve= construct_curve_2(f);
|
||||||
#if CGAL_ACK_DEBUG_FLAG
|
#if CGAL_ACK_DEBUG_FLAG
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ find_package(Qt6 QUIET COMPONENTS Widgets OpenGL)
|
||||||
|
|
||||||
if(CGAL_Qt6_FOUND AND Qt6_FOUND)
|
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.
|
# Instruct CMake to run moc/ui/rcc automatically when needed.
|
||||||
set(CMAKE_AUTOMOC ON)
|
set(CMAKE_AUTOMOC ON)
|
||||||
|
|
|
||||||
|
|
@ -1638,7 +1638,7 @@ compute_edge_status( const Cell_handle& c,
|
||||||
last=ccirc;
|
last=ccirc;
|
||||||
while (is_infinite(ccirc) ) ++ccirc; //skip infinite incident cells
|
while (is_infinite(ccirc) ) ++ccirc; //skip infinite incident cells
|
||||||
alpha = (*ccirc).get_alpha();
|
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
|
as.set_alpha_max(alpha); // same for as.alpha_max
|
||||||
while (++ccirc != last)
|
while (++ccirc != last)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -218,7 +218,7 @@ test_filtration(AS &A, bool verbose)
|
||||||
typename AS::NT alpha;
|
typename AS::NT alpha;
|
||||||
if(verbose) {
|
if(verbose) {
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
std::cerr << "Analyse filtration " << std::endl;
|
std::cerr << "Analyze filtration " << std::endl;
|
||||||
}
|
}
|
||||||
for (; filtre_it != filtration.end(); filtre_it++) {
|
for (; filtre_it != filtration.end(); filtre_it++) {
|
||||||
if(assign(vertex, *filtre_it)) {
|
if(assign(vertex, *filtre_it)) {
|
||||||
|
|
|
||||||
|
|
@ -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);
|
Option_parser::my_validate<Option_parser::Strategy_id>(v, values);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Constructor */
|
/*! constructs */
|
||||||
Option_parser::Option_parser() :
|
Option_parser::Option_parser() :
|
||||||
m_generic_opts("Generic options"),
|
m_generic_opts("Generic options"),
|
||||||
m_config_opts("Configuration options"),
|
m_config_opts("Configuration options"),
|
||||||
|
|
@ -136,7 +136,7 @@ Option_parser::Option_parser() :
|
||||||
m_positional_opts.add("input-file", -1);
|
m_positional_opts.add("input-file", -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Parse the options */
|
/*! parses the options */
|
||||||
void Option_parser::operator()(int argc, char * argv[])
|
void Option_parser::operator()(int argc, char * argv[])
|
||||||
{
|
{
|
||||||
po::store(po::command_line_parser(argc, 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
|
const std::string & Option_parser::get_file_name(unsigned int i) const
|
||||||
{
|
{
|
||||||
return m_variable_map["input-file"].as<Input_path>()[i];
|
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
|
const std::string & Option_parser::get_full_name(unsigned int i) const
|
||||||
{ return m_full_names[i]; }
|
{ return m_full_names[i]; }
|
||||||
|
|
||||||
/*! Obtain number of type options */
|
/*! obtains number of type options */
|
||||||
unsigned int Option_parser::get_number_opts(Type_id &)
|
unsigned int Option_parser::get_number_opts(Type_id &)
|
||||||
{ return sizeof(s_type_opts) / sizeof(char *); }
|
{ 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 &)
|
unsigned int Option_parser::get_number_opts(Strategy_id &)
|
||||||
{ return sizeof(s_strategy_opts) / sizeof(char *); }
|
{ return sizeof(s_strategy_opts) / sizeof(char *); }
|
||||||
|
|
|
||||||
|
|
@ -62,17 +62,17 @@ public:
|
||||||
typedef Vector_strategy_id::iterator Vector_strategy_id_iter;
|
typedef Vector_strategy_id::iterator Vector_strategy_id_iter;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/*! \brief obtains number of type options */
|
/*! obtains number of type options */
|
||||||
static unsigned int get_number_opts(Type_id &);
|
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 &);
|
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 &)
|
static bool compare_opt(unsigned int i, const char * opt, Type_id &)
|
||||||
{ return strcmp(s_type_opts[i], opt) == 0; }
|
{ 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 &)
|
static bool compare_opt(unsigned int i, const char * opt, Strategy_id &)
|
||||||
{ return strcmp(s_strategy_opts[i], opt) == 0; }
|
{ return strcmp(s_strategy_opts[i], opt) == 0; }
|
||||||
|
|
||||||
|
|
@ -94,19 +94,19 @@ public:
|
||||||
Input_file_missing_error(std::string & str) : error(str) {}
|
Input_file_missing_error(std::string & str) : error(str) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
/*! Parse the options */
|
/*! parses the options */
|
||||||
void operator()(int argc, char * argv[]);
|
void operator()(int argc, char * argv[]);
|
||||||
|
|
||||||
/*! Obtain the verbosity level */
|
/*! obtains the verbosity level */
|
||||||
unsigned int get_verbose_level() const { return m_verbose_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; }
|
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;
|
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;
|
const std::string & get_full_name(unsigned int i) const;
|
||||||
|
|
||||||
bool get_postscript() const { return m_postscript; }
|
bool get_postscript() const { return m_postscript; }
|
||||||
|
|
@ -117,10 +117,10 @@ public:
|
||||||
const char * get_strategy_name(Strategy_code id) const
|
const char * get_strategy_name(Strategy_code id) const
|
||||||
{ return s_strategy_opts[id]; }
|
{ return s_strategy_opts[id]; }
|
||||||
|
|
||||||
/*! Obtain the window width */
|
/*! obtains the window width */
|
||||||
unsigned int get_width() const { return m_win_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; }
|
unsigned int get_height() const { return m_win_height; }
|
||||||
|
|
||||||
template <class MyId>
|
template <class MyId>
|
||||||
|
|
|
||||||
|
|
@ -150,7 +150,7 @@
|
||||||
<benchArrCgalGmpqCartesianSegment print_header="1"/>
|
<benchArrCgalGmpqCartesianSegment print_header="1"/>
|
||||||
<benchArrCgalGmpqCartesianSegment/>
|
<benchArrCgalGmpqCartesianSegment/>
|
||||||
<benchArrCgalGmpqLazyCartesianSegment/>
|
<benchArrCgalGmpqLazyCartesianSegment/>
|
||||||
<benchArrCgalGmpqLazyCartesianSegment/>
|
<benchArrCgalGmpqLazySimpleCartesianSegment/>
|
||||||
<benchArrCgalGmpqExactSegment/>
|
<benchArrCgalGmpqExactSegment/>
|
||||||
<benchArrDoubleCartesianSegment enable="false"/>
|
<benchArrDoubleCartesianSegment enable="false"/>
|
||||||
<benchArrLazyCgalGmpqCartesianSegment/>
|
<benchArrLazyCgalGmpqCartesianSegment/>
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ if (CGAL_Qt6_FOUND AND Qt6_FOUND)
|
||||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||||
|
|
||||||
# Arrangement package includes
|
# Arrangement package includes
|
||||||
add_definitions(-DQT_NO_KEYWORDS)
|
add_compile_definitions(QT_NO_KEYWORDS)
|
||||||
option(COMPILE_UTILS_INCREMENTALLY
|
option(COMPILE_UTILS_INCREMENTALLY
|
||||||
"Compile files in Utils directory incrementally, or compile them all as a unit. \
|
"Compile files in Utils directory incrementally, or compile them all as a unit. \
|
||||||
Incremental compilation will be better for development and consume less \
|
Incremental compilation will be better for development and consume less \
|
||||||
|
|
|
||||||
|
|
@ -111,13 +111,10 @@ void CurveInputMethod::beginInput_()
|
||||||
|
|
||||||
static inline void clearPainterPath(QPainterPath& ppath)
|
static inline void clearPainterPath(QPainterPath& ppath)
|
||||||
{
|
{
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 13, 0))
|
|
||||||
ppath.clear();
|
ppath.clear();
|
||||||
#else
|
|
||||||
ppath = {};
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CurveInputMethod::reset()
|
void CurveInputMethod::reset()
|
||||||
{
|
{
|
||||||
this->resetInput();
|
this->resetInput();
|
||||||
|
|
|
||||||
|
|
@ -67,11 +67,7 @@ void GridGraphicsItem::setSpacing(int spacing_)
|
||||||
static inline qreal
|
static inline qreal
|
||||||
horizontalAdvance(const QFontMetrics& fm, const QString& text)
|
horizontalAdvance(const QFontMetrics& fm, const QString& text)
|
||||||
{
|
{
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
|
|
||||||
return fm.horizontalAdvance(text);
|
return fm.horizontalAdvance(text);
|
||||||
#else
|
|
||||||
return fm.boundingRect(text).width();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GridGraphicsItem::paint(
|
void GridGraphicsItem::paint(
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright(c) 2023, 2024 Tel-Aviv University (Israel).
|
// Copyright (c) 2023, 2024 Tel-Aviv University (Israel).
|
||||||
// All rights reserved.
|
// All rights reserved.
|
||||||
//
|
//
|
||||||
// This file is part of CGAL (www.cgal.org).
|
// This file is part of CGAL (www.cgal.org).
|
||||||
|
|
@ -40,7 +40,7 @@ namespace {
|
||||||
Flag(bool init) : v{ init } {}
|
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_dcel = CGAL::Arr_extended_dcel<Geom_traits, Flag, Flag, Flag>;
|
||||||
using Ext_topol_traits =
|
using Ext_topol_traits =
|
||||||
CGAL::Arr_spherical_topology_traits_2<Geom_traits, Ext_dcel>;
|
CGAL::Arr_spherical_topology_traits_2<Geom_traits, Ext_dcel>;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright(c) 2023, 2024 Tel-Aviv University (Israel).
|
// Copyright (c) 2023, 2024 Tel-Aviv University (Israel).
|
||||||
// All rights reserved.
|
// All rights reserved.
|
||||||
//
|
//
|
||||||
// This file is part of CGAL (www.cgal.org).
|
// This file is part of CGAL (www.cgal.org).
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright(c) 2023, 2024 Tel-Aviv University (Israel).
|
// Copyright (c) 2023, 2024 Tel-Aviv University (Israel).
|
||||||
// All rights reserved.
|
// All rights reserved.
|
||||||
//
|
//
|
||||||
// This file is part of CGAL (www.cgal.org).
|
// This file is part of CGAL (www.cgal.org).
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright(c) 2023, 2024 Tel-Aviv University (Israel).
|
// Copyright (c) 2023, 2024 Tel-Aviv University (Israel).
|
||||||
// All rights reserved.
|
// All rights reserved.
|
||||||
//
|
//
|
||||||
// This file is part of CGAL (www.cgal.org).
|
// This file is part of CGAL (www.cgal.org).
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright(c) 2023, 2024 Tel-Aviv University (Israel).
|
// Copyright (c) 2023, 2024 Tel-Aviv University (Israel).
|
||||||
// All rights reserved.
|
// All rights reserved.
|
||||||
//
|
//
|
||||||
// This file is part of CGAL (www.cgal.org).
|
// This file is part of CGAL (www.cgal.org).
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ endif()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
add_definitions(-DQT_NO_VERSION_TAGGING)
|
add_compile_definitions(QT_NO_VERSION_TAGGING)
|
||||||
|
|
||||||
# AOS
|
# AOS
|
||||||
file(GLOB source_files_aos Aos.h Aos.cpp Aos_defs.h
|
file(GLOB source_files_aos Aos.h Aos.cpp Aos_defs.h
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright(c) 2023, 2024 Tel-Aviv University (Israel).
|
// Copyright (c) 2023, 2024 Tel-Aviv University (Israel).
|
||||||
// All rights reserved.
|
// All rights reserved.
|
||||||
//
|
//
|
||||||
// This file is part of CGAL (www.cgal.org).
|
// This file is part of CGAL (www.cgal.org).
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright(c) 2023, 2024 Tel-Aviv University (Israel).
|
// Copyright (c) 2023, 2024 Tel-Aviv University (Israel).
|
||||||
// All rights reserved.
|
// All rights reserved.
|
||||||
//
|
//
|
||||||
// This file is part of CGAL (www.cgal.org).
|
// This file is part of CGAL (www.cgal.org).
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright(c) 2023, 2024 Tel-Aviv University(Israel).
|
// Copyright (c) 2023, 2024 Tel-Aviv University(Israel).
|
||||||
// All rights reserved.
|
// All rights reserved.
|
||||||
//
|
//
|
||||||
// This file is part of CGAL (www.cgal.org).
|
// This file is part of CGAL (www.cgal.org).
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright(c) 2023, 2024 Tel-Aviv University (Israel).
|
// Copyright (c) 2023, 2024 Tel-Aviv University (Israel).
|
||||||
// All rights reserved.
|
// All rights reserved.
|
||||||
//
|
//
|
||||||
// This file is part of CGAL (www.cgal.org).
|
// This file is part of CGAL (www.cgal.org).
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright(c) 2023, 2024 Tel-Aviv University (Israel).
|
// Copyright (c) 2023, 2024 Tel-Aviv University (Israel).
|
||||||
// All rights reserved.
|
// All rights reserved.
|
||||||
//
|
//
|
||||||
// This file is part of CGAL (www.cgal.org).
|
// This file is part of CGAL (www.cgal.org).
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright(c) 2023, 2024 Tel-Aviv University (Israel).
|
// Copyright (c) 2023, 2024 Tel-Aviv University (Israel).
|
||||||
// All rights reserved.
|
// All rights reserved.
|
||||||
//
|
//
|
||||||
// This file is part of CGAL (www.cgal.org).
|
// This file is part of CGAL (www.cgal.org).
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright(c) 2023, 2024 Tel-Aviv University (Israel).
|
// Copyright (c) 2023, 2024 Tel-Aviv University (Israel).
|
||||||
// All rights reserved.
|
// All rights reserved.
|
||||||
//
|
//
|
||||||
// This file is part of CGAL (www.cgal.org).
|
// This file is part of CGAL (www.cgal.org).
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright(c) 2023, 2024 Tel-Aviv University (Israel).
|
// Copyright (c) 2023, 2024 Tel-Aviv University (Israel).
|
||||||
// All rights reserved.
|
// All rights reserved.
|
||||||
//
|
//
|
||||||
// This file is part of CGAL (www.cgal.org).
|
// This file is part of CGAL (www.cgal.org).
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright(c) 2023, 2024 Tel-Aviv University (Israel).
|
// Copyright (c) 2023, 2024 Tel-Aviv University (Israel).
|
||||||
// All rights reserved.
|
// All rights reserved.
|
||||||
//
|
//
|
||||||
// This file is part of CGAL (www.cgal.org).
|
// This file is part of CGAL (www.cgal.org).
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright(c) 2023, 2024 Tel-Aviv University (Israel).
|
// Copyright (c) 2023, 2024 Tel-Aviv University (Israel).
|
||||||
// All rights reserved.
|
// All rights reserved.
|
||||||
//
|
//
|
||||||
// This file is part of CGAL (www.cgal.org).
|
// This file is part of CGAL (www.cgal.org).
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright(c) 2023, 2024 Tel-Aviv University (Israel).
|
// Copyright (c) 2023, 2024 Tel-Aviv University (Israel).
|
||||||
// All rights reserved.
|
// All rights reserved.
|
||||||
//
|
//
|
||||||
// This file is part of CGAL (www.cgal.org).
|
// This file is part of CGAL (www.cgal.org).
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright(c) 2023, 2024 Tel-Aviv University (Israel).
|
// Copyright (c) 2023, 2024 Tel-Aviv University (Israel).
|
||||||
// All rights reserved.
|
// All rights reserved.
|
||||||
//
|
//
|
||||||
// This file is part of CGAL (www.cgal.org).
|
// This file is part of CGAL (www.cgal.org).
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright(c) 2023, 2024 Tel-Aviv University (Israel).
|
// Copyright (c) 2023, 2024 Tel-Aviv University (Israel).
|
||||||
// All rights reserved.
|
// All rights reserved.
|
||||||
//
|
//
|
||||||
// This file is part of CGAL (www.cgal.org).
|
// This file is part of CGAL (www.cgal.org).
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright(c) 2023, 2024 Tel-Aviv University (Israel).
|
// Copyright (c) 2023, 2024 Tel-Aviv University (Israel).
|
||||||
// All rights reserved.
|
// All rights reserved.
|
||||||
//
|
//
|
||||||
// This file is part of CGAL (www.cgal.org).
|
// This file is part of CGAL (www.cgal.org).
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright(c) 2023, 2024 Tel-Aviv University (Israel).
|
// Copyright (c) 2023, 2024 Tel-Aviv University (Israel).
|
||||||
// All rights reserved.
|
// All rights reserved.
|
||||||
//
|
//
|
||||||
// This file is part of CGAL (www.cgal.org).
|
// This file is part of CGAL (www.cgal.org).
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright(c) 2023, 2024 Tel-Aviv University (Israel).
|
// Copyright (c) 2023, 2024 Tel-Aviv University (Israel).
|
||||||
// All rights reserved.
|
// All rights reserved.
|
||||||
//
|
//
|
||||||
// This file is part of CGAL (www.cgal.org).
|
// This file is part of CGAL (www.cgal.org).
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright(c) 2023, 2024 Tel-Aviv University (Israel).
|
// Copyright (c) 2023, 2024 Tel-Aviv University (Israel).
|
||||||
// All rights reserved.
|
// All rights reserved.
|
||||||
//
|
//
|
||||||
// This file is part of CGAL (www.cgal.org).
|
// This file is part of CGAL (www.cgal.org).
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright(c) 2023, 2024 Tel-Aviv University (Israel).
|
// Copyright (c) 2023, 2024 Tel-Aviv University (Israel).
|
||||||
// All rights reserved.
|
// All rights reserved.
|
||||||
//
|
//
|
||||||
// This file is part of CGAL (www.cgal.org).
|
// This file is part of CGAL (www.cgal.org).
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright(c) 2023, 2024 Tel-Aviv University (Israel).
|
// Copyright (c) 2023, 2024 Tel-Aviv University (Israel).
|
||||||
// All rights reserved.
|
// All rights reserved.
|
||||||
//
|
//
|
||||||
// This file is part of CGAL (www.cgal.org).
|
// This file is part of CGAL (www.cgal.org).
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright(c) 2023, 2024 Tel-Aviv University (Israel).
|
// Copyright (c) 2023, 2024 Tel-Aviv University (Israel).
|
||||||
// All rights reserved.
|
// All rights reserved.
|
||||||
//
|
//
|
||||||
// This file is part of CGAL (www.cgal.org).
|
// This file is part of CGAL (www.cgal.org).
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright(c) 2023, 2024 Tel-Aviv University (Israel).
|
// Copyright (c) 2023, 2024 Tel-Aviv University (Israel).
|
||||||
// All rights reserved.
|
// All rights reserved.
|
||||||
//
|
//
|
||||||
// This file is part of CGAL (www.cgal.org).
|
// This file is part of CGAL (www.cgal.org).
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright(c) 2023, 2024 Tel-Aviv University (Israel).
|
// Copyright (c) 2023, 2024 Tel-Aviv University (Israel).
|
||||||
// All rights reserved.
|
// All rights reserved.
|
||||||
//
|
//
|
||||||
// This file is part of CGAL (www.cgal.org).
|
// This file is part of CGAL (www.cgal.org).
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright(c) 2023, 2024 Tel-Aviv University (Israel).
|
// Copyright (c) 2023, 2024 Tel-Aviv University (Israel).
|
||||||
// All rights reserved.
|
// All rights reserved.
|
||||||
//
|
//
|
||||||
// This file is part of CGAL (www.cgal.org).
|
// This file is part of CGAL (www.cgal.org).
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright(c) 2023, 2024 Tel-Aviv University (Israel).
|
// Copyright (c) 2023, 2024 Tel-Aviv University (Israel).
|
||||||
// All rights reserved.
|
// All rights reserved.
|
||||||
//
|
//
|
||||||
// This file is part of CGAL (www.cgal.org).
|
// This file is part of CGAL (www.cgal.org).
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright(c) 2023, 2024 Tel-Aviv University (Israel).
|
// Copyright (c) 2023, 2024 Tel-Aviv University (Israel).
|
||||||
// All rights reserved.
|
// All rights reserved.
|
||||||
//
|
//
|
||||||
// This file is part of CGAL (www.cgal.org).
|
// This file is part of CGAL (www.cgal.org).
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright(c) 2023, 2024 Tel-Aviv University (Israel).
|
// Copyright (c) 2023, 2024 Tel-Aviv University (Israel).
|
||||||
// All rights reserved.
|
// All rights reserved.
|
||||||
//
|
//
|
||||||
// This file is part of CGAL (www.cgal.org).
|
// This file is part of CGAL (www.cgal.org).
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue