arithmetic.hh
Go to the documentation of this file.
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
* Main authors:
* Christian Schulte <schulte@gecode.org>
* Guido Tack <tack@gecode.org>
* Vincent Barichard <Vincent.Barichard@univ-angers.fr>
*
* Copyright:
* Christian Schulte, 2002
* Guido Tack, 2004
* Vincent Barichard, 2012
*
* This file is part of Gecode, the generic constraint
* development environment:
* http://www.gecode.org
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#ifndef __GECODE_FLOAT_ARITHMETIC_HH__
#define __GECODE_FLOAT_ARITHMETIC_HH__
#include <gecode/int.hh>
#include <gecode/float.hh>
#include <gecode/float/rel.hh>
namespace Gecode { namespace Float { namespace Arithmetic {
template<class VA, class VB>
class SqrPlus : public MixBinaryPropagator<VA,PC_FLOAT_BND,VB,PC_FLOAT_BND> {
protected:
using MixBinaryPropagator<VA,PC_FLOAT_BND,VB,PC_FLOAT_BND>::x0;
using MixBinaryPropagator<VA,PC_FLOAT_BND,VB,PC_FLOAT_BND>::x1;
SqrPlus(Home home, VA x0, VB x1);
SqrPlus(Space& home, SqrPlus<VA,VB>& p);
public:
static ExecStatus post(Home home, VA x0, VB x1);
virtual Actor* copy(Space& home);
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
};
template<class View>
class Sqr : public BinaryPropagator<View,PC_FLOAT_BND> {
protected:
using BinaryPropagator<View,PC_FLOAT_BND>::x0;
using BinaryPropagator<View,PC_FLOAT_BND>::x1;
Sqr(Space& home, Sqr& p);
Sqr(Home home, View x0, View x1);
public:
virtual Actor* copy(Space& home);
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
static ExecStatus post(Home home, View x0, View x1);
};
template<class A, class B>
class Sqrt : public MixBinaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND> {
protected:
using MixBinaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND>::x0;
using MixBinaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND>::x1;
Sqrt(Space& home, Sqrt& p);
Sqrt(Home home, A x0, B x1);
public:
virtual Actor* copy(Space& home);
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
static ExecStatus post(Home home, A x0, B x1);
};
template<class A, class B>
class Abs : public MixBinaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND> {
protected:
using MixBinaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND>::x0;
using MixBinaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND>::x1;
Abs(Space& home, Abs& p);
Abs(Home home, A x0, B x1);
public:
Abs(Space& home, Propagator& p, A x0, B x1);
virtual Actor* copy(Space& home);
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
static ExecStatus post(Home home, A x0, B x1);
};
template<class A, class B>
class Pow : public MixBinaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND> {
protected:
using MixBinaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND>::x0;
using MixBinaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND>::x1;
int m_n;
Pow(Space& home, Pow& p);
Pow(Home home, A x0, B x1, int n);
public:
virtual Actor* copy(Space& home);
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
static ExecStatus post(Home home, A x0, B x1, int n);
};
template<class A, class B>
class NthRoot : public MixBinaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND> {
protected:
using MixBinaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND>::x0;
using MixBinaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND>::x1;
int m_n;
NthRoot(Space& home, NthRoot& p);
NthRoot(Home home, A x0, B x1, int n);
public:
virtual Actor* copy(Space& home);
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
static ExecStatus post(Home home, A x0, B x1, int n);
};
template<class View>
class MultZeroOne : public BinaryPropagator<View,PC_FLOAT_BND> {
protected:
using BinaryPropagator<View,PC_FLOAT_BND>::x0;
using BinaryPropagator<View,PC_FLOAT_BND>::x1;
MultZeroOne(Space& home, MultZeroOne<View>& p);
MultZeroOne(Home home, View x0, View x1);
public:
virtual Actor* copy(Space& home);
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
static ExecStatus post(Home home, View x0, View x1);
};
template<class VA, class VB, class VC>
class MultPlus :
public MixTernaryPropagator<VA,PC_FLOAT_BND,VB,PC_FLOAT_BND,VC,PC_FLOAT_BND> {
protected:
using MixTernaryPropagator<VA,PC_FLOAT_BND,VB,PC_FLOAT_BND,VC,PC_FLOAT_BND>::x0;
using MixTernaryPropagator<VA,PC_FLOAT_BND,VB,PC_FLOAT_BND,VC,PC_FLOAT_BND>::x1;
using MixTernaryPropagator<VA,PC_FLOAT_BND,VB,PC_FLOAT_BND,VC,PC_FLOAT_BND>::x2;
public:
MultPlus(Home home, VA x0, VB x1, VC x2);
MultPlus(Space& home, MultPlus<VA,VB,VC>& p);
static ExecStatus post(Home home, VA x0, VB x1, VC x2);
virtual Actor* copy(Space& home);
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
};
template<class View>
class Mult : public TernaryPropagator<View,PC_FLOAT_BND> {
protected:
using TernaryPropagator<View,PC_FLOAT_BND>::x0;
using TernaryPropagator<View,PC_FLOAT_BND>::x1;
using TernaryPropagator<View,PC_FLOAT_BND>::x2;
Mult(Space& home, Mult<View>& p);
public:
Mult(Home home, View x0, View x1, View x2);
static ExecStatus post(Home home, View x0, View x1, View x2);
virtual Actor* copy(Space& home);
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
};
template<class A, class B, class C>
class Div : public MixTernaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND,C,PC_FLOAT_BND> {
protected:
using MixTernaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND,C,PC_FLOAT_BND>::x0;
using MixTernaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND,C,PC_FLOAT_BND>::x1;
using MixTernaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND,C,PC_FLOAT_BND>::x2;
Div(Space& home, Div& p);
Div(Home home, A x0, B x1, C x2);
public:
virtual Actor* copy(Space& home);
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
static ExecStatus post(Home home, A x0, B x1, C x2);
};
template<class A, class B, class C>
class Min : public MixTernaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND,C,PC_FLOAT_BND> {
protected:
using MixTernaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND,C,PC_FLOAT_BND>::x0;
using MixTernaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND,C,PC_FLOAT_BND>::x1;
using MixTernaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND,C,PC_FLOAT_BND>::x2;
Min(Space& home, Min& p);
Min(Home home, A x0, B x1, C x2);
public:
Min(Space& home, Propagator& p, A x0, B x1, C x2);
virtual Actor* copy(Space& home);
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
static ExecStatus post(Home home, A x0, B x1, C x2);
};
template<class A, class B, class C>
class Max : public MixTernaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND,C,PC_FLOAT_BND> {
protected:
using MixTernaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND,C,PC_FLOAT_BND>::x0;
using MixTernaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND,C,PC_FLOAT_BND>::x1;
using MixTernaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND,C,PC_FLOAT_BND>::x2;
Max(Space& home, Max& p);
Max(Home home, A x0, B x1, C x2);
public:
Max(Space& home, Propagator& p, A x0, B x1, C x2);
virtual Actor* copy(Space& home);
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
static ExecStatus post(Home home, A x0, B x1, C x2);
};
template<class View>
class NaryMax : public NaryOnePropagator<View,PC_FLOAT_BND> {
protected:
using NaryOnePropagator<View,PC_FLOAT_BND>::x;
using NaryOnePropagator<View,PC_FLOAT_BND>::y;
NaryMax(Space& home, NaryMax& p);
NaryMax(Home home, ViewArray<View>& x, View y);
public:
virtual Actor* copy(Space& home);
virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
static ExecStatus post(Home home, ViewArray<View>& x, View y);
};
}}}
#include <gecode/float/arithmetic/sqr-sqrt.hpp>
#include <gecode/float/arithmetic/abs.hpp>
#include <gecode/float/arithmetic/pow-nroot.hpp>
#include <gecode/float/arithmetic/mult.hpp>
#include <gecode/float/arithmetic/div.hpp>
#include <gecode/float/arithmetic/min-max.hpp>
#endif
// STATISTICS: float-prop
Gecode::ActorLink::Actor
friend class Actor
Definition core.hpp:590
Gecode::BinaryPropagator< View, PC_FLOAT_BND >::x0
View x0
Definition pattern.hpp:87
Gecode::BinaryPropagator< View, PC_FLOAT_BND >::BinaryPropagator
BinaryPropagator(Space &home, BinaryPropagator &p)
Gecode::BinaryPropagator< View, PC_FLOAT_BND >::x1
View x1
Definition pattern.hpp:87
Gecode::Float::Arithmetic::Abs::Abs
Abs(Space &home, Abs &p)
Constructor for cloning p.
Definition abs.hpp:61
Gecode::Float::Arithmetic::Abs::post
static ExecStatus post(Home home, A x0, B x1)
Post propagator for .
Definition abs.hpp:47
Gecode::Float::Arithmetic::Abs::propagate
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition abs.hpp:72
Gecode::Float::Arithmetic::Abs::Abs
Abs(Space &home, Propagator &p, A x0, B x1)
Constructor for rewriting p during cloning.
Gecode::Float::Arithmetic::Abs::copy
virtual Actor * copy(Space &home)
Create copy during cloning.
Definition abs.hpp:66
Gecode::Float::Arithmetic::Div::copy
virtual Actor * copy(Space &home)
Create copy during cloning.
Definition div.hpp:54
Gecode::Float::Arithmetic::Div::Div
Div(Space &home, Div &p)
Constructor for cloning p.
Definition div.hpp:49
Gecode::Float::Arithmetic::Div::propagate
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition div.hpp:69
Gecode::Float::Arithmetic::Div::post
static ExecStatus post(Home home, A x0, B x1, C x2)
Post propagator for .
Definition div.hpp:60
Gecode::Float::Arithmetic::Max::post
static ExecStatus post(Home home, A x0, B x1, C x2)
Post propagator for .
Definition min-max.hpp:120
Gecode::Float::Arithmetic::Max::copy
virtual Actor * copy(Space &home)
Create copy during cloning.
Definition min-max.hpp:114
Gecode::Float::Arithmetic::Max::propagate
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition min-max.hpp:130
Gecode::Float::Arithmetic::Max::Max
Max(Space &home, Max &p)
Constructor for cloning p.
Definition min-max.hpp:103
Gecode::Float::Arithmetic::Min::Min
Min(Space &home, Min &p)
Constructor for cloning p.
Definition min-max.hpp:51
Gecode::Float::Arithmetic::Min::post
static ExecStatus post(Home home, A x0, B x1, C x2)
Post propagator for .
Definition min-max.hpp:68
Gecode::Float::Arithmetic::Min::copy
virtual Actor * copy(Space &home)
Create copy during cloning.
Definition min-max.hpp:62
Gecode::Float::Arithmetic::Min::propagate
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition min-max.hpp:78
Gecode::Float::Arithmetic::MultPlus::post
static ExecStatus post(Home home, VA x0, VB x1, VC x2)
Post propagator .
Definition mult.hpp:169
Gecode::Float::Arithmetic::MultPlus::copy
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition mult.hpp:150
Gecode::Float::Arithmetic::MultPlus::propagate
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition mult.hpp:156
Gecode::Float::Arithmetic::MultPlus::MultPlus
MultPlus(Home home, VA x0, VB x1, VC x2)
Constructor for posting.
Definition mult.hpp:138
Gecode::Float::Arithmetic::MultZeroOne::post
static ExecStatus post(Home home, View x0, View x1)
Post propagator .
Definition mult.hpp:69
Gecode::Float::Arithmetic::MultZeroOne::propagate
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition mult.hpp:107
Gecode::Float::Arithmetic::MultZeroOne::copy
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition mult.hpp:101
Gecode::Float::Arithmetic::MultZeroOne::MultZeroOne
MultZeroOne(Space &home, MultZeroOne< View > &p)
Constructor for cloning p.
Definition mult.hpp:96
Gecode::Float::Arithmetic::Mult::post
static ExecStatus post(Home home, View x0, View x1, View x2)
Post propagator .
Definition mult.hpp:314
Gecode::Float::Arithmetic::Mult::copy
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition mult.hpp:195
Gecode::Float::Arithmetic::Mult::propagate
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition mult.hpp:201
Gecode::Float::Arithmetic::Mult::Mult
Mult(Space &home, Mult< View > &p)
Constructor for cloning p.
Definition mult.hpp:190
Gecode::Float::Arithmetic::NaryMax::copy
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition min-max.hpp:187
Gecode::Float::Arithmetic::NaryMax::post
static ExecStatus post(Home home, ViewArray< View > &x, View y)
Post propagator .
Definition min-max.hpp:155
Gecode::Float::Arithmetic::NaryMax::propagate
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition min-max.hpp:242
Gecode::Float::Arithmetic::NaryMax::NaryMax
NaryMax(Space &home, NaryMax &p)
Constructor for cloning p.
Gecode::Float::Arithmetic::NthRoot::NthRoot
NthRoot(Space &home, NthRoot &p)
Constructor for cloning p.
Definition pow-nroot.hpp:145
Gecode::Float::Arithmetic::NthRoot::propagate
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition pow-nroot.hpp:156
Gecode::Float::Arithmetic::NthRoot::m_n
int m_n
Definition arithmetic.hh:197
Gecode::Float::Arithmetic::NthRoot::copy
virtual Actor * copy(Space &home)
Create copy during cloning.
Definition pow-nroot.hpp:150
Gecode::Float::Arithmetic::NthRoot::post
static ExecStatus post(Home home, A x0, B x1, int n)
Post propagator for .
Definition pow-nroot.hpp:134
Gecode::Float::Arithmetic::Pow::m_n
int m_n
Definition arithmetic.hh:169
Gecode::Float::Arithmetic::Pow::post
static ExecStatus post(Home home, A x0, B x1, int n)
Post propagator for .
Definition pow-nroot.hpp:49
Gecode::Float::Arithmetic::Pow::propagate
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition pow-nroot.hpp:95
Gecode::Float::Arithmetic::Pow::copy
virtual Actor * copy(Space &home)
Create copy during cloning.
Definition pow-nroot.hpp:89
Gecode::Float::Arithmetic::Pow::Pow
Pow(Space &home, Pow &p)
Constructor for cloning p.
Definition pow-nroot.hpp:84
Gecode::Float::Arithmetic::SqrPlus::propagate
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition sqr-sqrt.hpp:77
Gecode::Float::Arithmetic::SqrPlus::copy
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition sqr-sqrt.hpp:71
Gecode::Float::Arithmetic::SqrPlus::SqrPlus
SqrPlus(Home home, VA x0, VB x1)
Constructor for posting.
Definition sqr-sqrt.hpp:46
Gecode::Float::Arithmetic::SqrPlus::post
static ExecStatus post(Home home, VA x0, VB x1)
Post propagator .
Definition sqr-sqrt.hpp:51
Gecode::Float::Arithmetic::Sqr::copy
virtual Actor * copy(Space &home)
Create copy during cloning.
Definition sqr-sqrt.hpp:130
Gecode::Float::Arithmetic::Sqr::post
static ExecStatus post(Home home, View x0, View x1)
Post propagator for .
Definition sqr-sqrt.hpp:105
Gecode::Float::Arithmetic::Sqr::Sqr
Sqr(Space &home, Sqr &p)
Constructor for cloning p.
Gecode::Float::Arithmetic::Sqr::propagate
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition sqr-sqrt.hpp:136
Gecode::Float::Arithmetic::Sqrt::Sqrt
Sqrt(Space &home, Sqrt &p)
Constructor for cloning p.
Definition sqr-sqrt.hpp:186
Gecode::Float::Arithmetic::Sqrt::propagate
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition sqr-sqrt.hpp:197
Gecode::Float::Arithmetic::Sqrt::post
static ExecStatus post(Home home, A x0, B x1)
Post propagator for .
Definition sqr-sqrt.hpp:170
Gecode::Float::Arithmetic::Sqrt::copy
virtual Actor * copy(Space &home)
Create copy during cloning.
Definition sqr-sqrt.hpp:191
Gecode::Home
Home class for posting propagators
Definition core.hpp:856
Gecode::MixBinaryPropagator< VA, PC_FLOAT_BND, VB, PC_FLOAT_BND >::x1
VB x1
Definition pattern.hpp:209
Gecode::MixBinaryPropagator< VA, PC_FLOAT_BND, VB, PC_FLOAT_BND >::MixBinaryPropagator
MixBinaryPropagator(Space &home, MixBinaryPropagator &p)
Definition pattern.hpp:597
Gecode::MixBinaryPropagator< VA, PC_FLOAT_BND, VB, PC_FLOAT_BND >::x0
VA x0
Definition pattern.hpp:207
Gecode::MixTernaryPropagator< VA, PC_FLOAT_BND, VB, PC_FLOAT_BND, VC, PC_FLOAT_BND >::x0
VA x0
Definition pattern.hpp:240
Gecode::MixTernaryPropagator< VA, PC_FLOAT_BND, VB, PC_FLOAT_BND, VC, PC_FLOAT_BND >::x1
VB x1
Definition pattern.hpp:242
Gecode::MixTernaryPropagator< VA, PC_FLOAT_BND, VB, PC_FLOAT_BND, VC, PC_FLOAT_BND >::x2
VC x2
Definition pattern.hpp:244
Gecode::MixTernaryPropagator< VA, PC_FLOAT_BND, VB, PC_FLOAT_BND, VC, PC_FLOAT_BND >::MixTernaryPropagator
MixTernaryPropagator(Space &home, MixTernaryPropagator &p)
Definition pattern.hpp:661
Gecode::NaryOnePropagator< View, PC_FLOAT_BND >::x
ViewArray< View > x
Definition pattern.hpp:175
Gecode::NaryOnePropagator< View, PC_FLOAT_BND >::NaryOnePropagator
NaryOnePropagator(Space &home, NaryOnePropagator &p)
Gecode::NaryOnePropagator< View, PC_FLOAT_BND >::y
View y
Definition pattern.hpp:177
Gecode::Propagator::Space
friend class Space
Definition core.hpp:1066
Gecode::Propagator::med
ModEventDelta med
A set of modification events (used during propagation).
Definition core.hpp:1075
Gecode::Propagator::Propagator
Propagator(Home home)
Constructor for posting.
Definition core.hpp:3498
Gecode::TernaryPropagator< View, PC_FLOAT_BND >::x2
View x2
Definition pattern.hpp:116
Gecode::TernaryPropagator< View, PC_FLOAT_BND >::x1
View x1
Definition pattern.hpp:116
Gecode::TernaryPropagator< View, PC_FLOAT_BND >::x0
View x0
Definition pattern.hpp:116
Gecode::TernaryPropagator< View, PC_FLOAT_BND >::TernaryPropagator
TernaryPropagator(Space &home, TernaryPropagator &p)
Gecode::View
Gecode::ViewArray
View arrays.
Definition array.hpp:253
abs.hpp
div.hpp
mult.hpp
rel.hh
float.hh
int.hh
Gecode::ModEventDelta
int ModEventDelta
Modification event deltas.
Definition core.hpp:89
min-max.hpp
Gecode::Float::Arithmetic
Arithmetic propagators
Gecode::Float
Floating point numbers.
Gecode::Float::PC_FLOAT_BND
const Gecode::PropCond PC_FLOAT_BND
Propagate when minimum or maximum of a view changes.
Definition var-type.hpp:292
Gecode
Gecode toplevel namespace
Gecode::ExecStatus
ExecStatus
Definition core.hpp:472
pow-nroot.hpp
sqr-sqrt.hpp