1/* $Id$ 2 3 Part of CLP(R) (Constraint Logic Programming over Reals) 4 5 Author: Leslie De Koninck 6 E-mail: Leslie.DeKoninck@cs.kuleuven.be 7 WWW: http://www.swi-prolog.org 8 http://www.ai.univie.ac.at/cgi-bin/tr-online?number+95-09 9 Copyright (C): 2004, K.U. Leuven and 10 1992-1995, Austrian Research Institute for 11 Artificial Intelligence (OFAI), 12 Vienna, Austria 13 14 This software is part of Leslie De Koninck's master thesis, supervised 15 by Bart Demoen and daily advisor Tom Schrijvers. It is based on CLP(Q,R) 16 by Christian Holzbaur for SICStus Prolog and distributed under the 17 license details below with permission from all mentioned authors. 18 19 This program is free software; you can redistribute it and/or 20 modify it under the terms of the GNU General Public License 21 as published by the Free Software Foundation; either version 2 22 of the License, or (at your option) any later version. 23 24 This program is distributed in the hope that it will be useful, 25 but WITHOUT ANY WARRANTY; without even the implied warranty of 26 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 GNU General Public License for more details. 28 29 You should have received a copy of the GNU Lesser General Public 30 License along with this library; if not, write to the Free Software 31 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 32 33 As a special exception, if you link this library with other files, 34 compiled with a Free Software compiler, to produce an executable, this 35 library does not by itself cause the resulting executable to be covered 36 by the GNU General Public License. This exception does not however 37 invalidate any other reasons why the executable file might be covered by 38 the GNU General Public License. 39*/ 40 41:- module(cdr, []). 42 43:- license(gpl_swipl, 'CLP(CDR)'). 44:- use_module(library(near_utils)). 45:- use_module(library(cdqr), []). 46:- reexport(library(clpcd)). 47 48clpcd_domain_opsclpcd_module(cdr, cdr). 49 50:- initialization(set_clpcd(cdr)). 51 52clpcd_domain_opscompare_d(cdr, Op, A, B) :- 53 near_compare(Op, A, B). 54 55clpcd_domain_opsdiv_d(cdr, A, B, C) :- C is A/B. 56 57clpcd_domain_opscast_d(cdr, A, B) :- 58 ( rational(A), 59 \+ integer(A) 60 ->B is float(A) 61 ; number(A) 62 ->B = A 63 ). 64 65clpcd_domain_opsfloor_d(cdr, A, B) :- 66 repsilon(abs(A), E), 67 B is floor(A+E). 68 69clpcd_domain_opsceiling_d(cdr, A, B) :- 70 repsilon(abs(A), E), 71 B is ceiling(A-E). 72 73clpcd_domain_opsintegerp(cdr, X, I) :- 74 I is round(X), 75 near_compare(=, X, I)