2 ase-metric.h -- Metrical Spaces and Distances
3 Copyright (C) 2006, 2007, 2008 Sebastian Freundt
5 Author: Sebastian Freundt <hroptatyr@sxemacs.org>
7 * This file is part of SXEmacs.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
20 * 3. Neither the name of the author nor the names of any contributors
21 * may be used to endorse or promote products derived from this
22 * software without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
25 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
31 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
32 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
33 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
34 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 /* Synched up with: Not in FSF. */
39 #ifndef INCLUDED_ase_metric_h_
40 #define INCLUDED_ase_metric_h_ 1
44 typedef struct ase_metric_s *ase_metric_t;
45 typedef struct ase_pmetric_data_s *ase_pmetric_data_t;
46 typedef Lisp_Object(*ase_distance_f)(void*, Lisp_Object, Lisp_Object);
48 #define EMOD_ASE_DEBUG_METR(args...) EMOD_ASE_DEBUG("[METR]: " args)
50 extern Lisp_Object Qase_metric, Qase_metricp;
51 extern Lisp_Object Qase_euclidean_metric, Qase_supremum_metric;
53 extern void LTX_PUBINIT(ase_metric)(void);
54 extern void LTX_PUBREINIT(ase_metric)(void);
55 extern void LTX_PUBDEINIT(ase_metric)(void);
62 /* helper data (e.g. for p-metrics) */
66 struct ase_pmetric_data_s {
78 #define ASE_METRICP(_i) \
79 (DYNACATP(_i) && EQ(XDYNACAT_TYPE(_i), Qase_metric))
80 #define CHECK_ASE_METRIC(x) \
82 if (!ASE_METRICP(x)) \
83 dead_wrong_type_argument(Qase_metricp, x); \
85 #define CONCHECK_ASE_METRIC(x) \
87 if (!ASE_METRICP(x)) \
88 x = wrong_type_argument(Qase_metricp, x); \
90 extern Lisp_Object _ase_wrap_metric(ase_metric_t);
91 #define XSETASE_METRIC(_res, _int) (_res) = _ase_wrap_metric((_int))
92 #define XASE_METRIC(_x) ((ase_metric_t)get_dynacat(_x))
94 #define ase_metric_dist(_m) ((_m)->dist)
95 #define XASE_METRIC_DIST(_m) (ase_metric_dist(XASE_METRIC(_m)))
96 #define ase_metric_ldist(_m) ((_m)->ldist)
97 #define XASE_METRIC_LDIST(_m) (ase_metric_ldist(XASE_METRIC(_m)))
98 #define ase_metric_data(_m) ((_m)->data)
99 #define XASE_METRIC_DATA(_m) (ase_metric_data(XASE_METRIC(_m)))
101 /* stuff we provide */
103 ase_make_metric(ase_distance_f fn, void *data, Lisp_Object lambda);
105 #endif /* INCLUDED_ase_metric_h_ */