File: Dehn_coefficients.c

package info (click to toggle)
snappea 3.0d3-20.1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 5,896 kB
  • ctags: 3,582
  • sloc: ansic: 33,469; sh: 8,293; python: 7,623; makefile: 240
file content (116 lines) | stat: -rw-r--r-- 2,143 bytes parent folder | download | duplicates (12)
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
 *	This file contains the functions
 *
 *		Boolean	all_Dehn_coefficients_are_integers(Triangulation *manifold);
 *		Boolean		Dehn_coefficients_are_integers(Cusp *cusp);
 *
 *		Boolean	all_Dehn_coefficients_are_relatively_prime_integers(Triangulation *manifold);
 *		Boolean		Dehn_coefficients_are_relatively_prime_integers(Cusp *cusp);
 *
 *		Boolean	all_cusps_are_complete(Triangulation *manifold);
 *		Boolean	all_cusps_are_filled(Triangulation *manifold);
 *
 *	which are used within the kernel to test whether Dehn filling coefficients
 *	are (relatively prime) integers.
 */

#include "kernel.h"


Boolean all_Dehn_coefficients_are_integers(
	Triangulation	*manifold)
{
	Cusp	*cusp;

	for (cusp = manifold->cusp_list_begin.next;
		 cusp != &manifold->cusp_list_end;
		 cusp = cusp->next)

		if (Dehn_coefficients_are_integers(cusp) == FALSE)

			return FALSE;

	return TRUE;
}


Boolean all_Dehn_coefficients_are_relatively_prime_integers(
	Triangulation	*manifold)
{
	Cusp	*cusp;

	for (cusp = manifold->cusp_list_begin.next;
		 cusp != &manifold->cusp_list_end;
		 cusp = cusp->next)

		if (Dehn_coefficients_are_relatively_prime_integers(cusp) == FALSE)

			return FALSE;

	return TRUE;
}


Boolean Dehn_coefficients_are_integers(
	Cusp	*cusp)
{
	return
	(
		cusp->is_complete == TRUE
	 ||
		(
			cusp->m == (double)(int)cusp->m
		 && cusp->l == (double)(int)cusp->l
		)
	);
}


Boolean Dehn_coefficients_are_relatively_prime_integers(
	Cusp	*cusp)
{
	return
	(
		cusp->is_complete == TRUE
	 ||
		(
			cusp->m == (double)(int)cusp->m
		 && cusp->l == (double)(int)cusp->l
		 && gcd((long int)cusp->m, (long int)cusp->l) == 1
		)
	);
}


Boolean all_cusps_are_complete(
	Triangulation	*manifold)
{
	Cusp	*cusp;

	for (cusp = manifold->cusp_list_begin.next;
		 cusp != &manifold->cusp_list_end;
		 cusp = cusp->next)

		if (cusp->is_complete == FALSE)

			return FALSE;

	return TRUE;
}


Boolean all_cusps_are_filled(
	Triangulation	*manifold)
{
	Cusp	*cusp;

	for (cusp = manifold->cusp_list_begin.next;
		 cusp != &manifold->cusp_list_end;
		 cusp = cusp->next)

		if (cusp->is_complete == TRUE)

			return FALSE;

	return TRUE;
}