File: pl-mp.h

package info (click to toggle)
swi-prolog-packages 5.0.1-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 50,688 kB
  • ctags: 25,904
  • sloc: ansic: 195,096; perl: 91,425; cpp: 7,660; sh: 3,046; makefile: 2,750; yacc: 843; awk: 14; sed: 12
file content (38 lines) | stat: -rw-r--r-- 829 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "gmp.h"
#include <SWI-Prolog.h>

/* if GMP multiplication proves to be more expensive than addition,
   it is wise to enable FAST_COMPLEX_MUL */
#define FAST_COMPLEX_MUL

#define max(n, m) (n >= m ? n : m)
#define abs(n) (n >= 0 ? n : -n)

#define MPE (0)	/* error: not an MP type */
#define MPZ (1)	/* MP integer */
#define MPQ (2)	/* MP rational */
#define MPF (3)	/* MP float */
#define MPC (4)	/* MP complex */
#define MP0 (5)	/* MP division by zero */

typedef int mp_tp;	/* MP types as defined above */

typedef struct {
	mpf_t r;
	mpf_t i;
} mpc_t;		/* MP complex number */

typedef struct {
	mp_tp t;
	union {
		mpz_t z;	/* GMP integer */
		mpq_t q;	/* GMP rational */
		mpf_t f;	/* GMP float */
		mpc_t c;	/* complex */
	} n;
} mp_t;			/* MP number */

void mp_install();

extern PL_extension mp_predicates[];