Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

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

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

""" 

Counting Congruence Solutions 

 

This file provides more user-friendly Python front-ends to the Cython code in 

:mod:`sage.quadratic_forms.count_local`. 

""" 

################################################################## 

## Methods for counting/computing the number of representations ## 

## of a number by a quadratic form in Z/(p^k)Z of various types ## 

################################################################## 

 

 

from sage.quadratic_forms.count_local_2 import CountAllLocalTypesNaive 

 

 

 

def count_congruence_solutions_as_vector(self, p, k, m, zvec, nzvec): 

""" 

Gives the number of integer solution vectors `x` satisfying the 

congruence Q(`x`) `= m (mod p^k)` of each solution type (i.e. All, 

Good, Zero, Bad, BadI, BadII) which satisfy the additional 

congruence conditions of having certain coefficients = 0 (mod `p`) 

and certain collections of coefficients not congruent to the zero 

vector (mod `p`). 

 

A solution vector `x` satisfies the additional congruence conditions 

specified by zvec and nzvec (and therefore is counted) iff both of 

the following conditions hold: 

 

1) `x[i] == 0 (mod p)` for all `i` in zvec 

 

2) `x[i] != 0 (mod p) for all i` in nzvec 

 

 

REFERENCES: 

 

See Hanke's (????) paper "Local Densities and explicit bounds...", p??? for 

the definitions of the solution types and congruence conditions. 

 

INPUT: 

 

- `p` -- prime number > 0 

- `k` -- an integer > 0 

- `m` -- an integer (depending only on mod `p^k`) 

- zvec, nzvec -- a list of integers in range(self.dim()), or None 

 

OUTPUT: 

 

a list of six integers >= 0 representing the solution types: 

[All, Good, Zero, Bad, BadI, BadII] 

 

 

EXAMPLES:: 

 

sage: Q = DiagonalQuadraticForm(ZZ, [1,2,3]) 

sage: Q.count_congruence_solutions_as_vector(3, 1, 1, [], []) 

[0, 0, 0, 0, 0, 0] 

sage: Q.count_congruence_solutions_as_vector(3, 1, 1, None, []) 

[0, 0, 0, 0, 0, 0] 

sage: Q.count_congruence_solutions_as_vector(3, 1, 1, [], None) 

[6, 6, 0, 0, 0, 0] 

sage: Q.count_congruence_solutions_as_vector(3, 1, 1, None, None) 

[6, 6, 0, 0, 0, 0] 

sage: Q.count_congruence_solutions_as_vector(3, 1, 2, None, None) 

[6, 6, 0, 0, 0, 0] 

sage: Q.count_congruence_solutions_as_vector(3, 1, 0, None, None) 

[15, 12, 1, 2, 0, 2] 

 

""" 

return CountAllLocalTypesNaive(self, p, k, m, zvec, nzvec) 

 

 

 

 

 

 

##/////////////////////////////////////////// 

##/// Front-ends for our counting routines // 

##/////////////////////////////////////////// 

 

def count_congruence_solutions(self, p, k, m, zvec, nzvec): 

""" 

Counts all solutions of Q(`x`) `= m (mod p^k)` satisfying the 

additional congruence conditions described in 

QuadraticForm.count_congruence_solutions_as_vector(). 

 

INPUT: 

 

`p` -- prime number > 0 

 

`k` -- an integer > 0 

 

`m` -- an integer (depending only on mod `p^k`) 

 

zvec, nzvec -- a list of integers in range(self.dim()), or None 

 

EXAMPLES:: 

 

sage: Q = DiagonalQuadraticForm(ZZ, [1,2,3]) 

sage: Q.count_congruence_solutions(3, 1, 0, None, None) 

15 

 

""" 

return CountAllLocalTypesNaive(self, p, k, m, zvec, nzvec)[0] 

 

 

 

def count_congruence_solutions__good_type(self, p, k, m, zvec, nzvec): 

""" 

Counts the good-type solutions of Q(x) = m (mod p^k) satisfying the 

additional congruence conditions described in 

QuadraticForm.count_congruence_solutions_as_vector(). 

 

INPUT: 

 

`p` -- prime number > 0 

 

`k` -- an integer > 0 

 

`m` -- an integer (depending only on mod `p^k`) 

 

zvec, nzvec -- a list of integers up to dim(Q) 

 

EXAMPLES:: 

 

sage: Q = DiagonalQuadraticForm(ZZ, [1,2,3]) 

sage: Q.count_congruence_solutions__good_type(3, 1, 0, None, None) 

12 

 

""" 

return CountAllLocalTypesNaive(self, p, k, m, zvec, nzvec)[1] 

 

 

 

def count_congruence_solutions__zero_type(self, p, k, m, zvec, nzvec): 

""" 

Counts the zero-type solutions of Q(`x`) = `m (mod p^k)` satisfying the 

additional congruence conditions described in 

QuadraticForm.count_congruence_solutions_as_vector(). 

 

INPUT: 

 

`p` -- prime number > 0 

 

`k` -- an integer > 0 

 

`m` -- an integer (depending only on mod `p^k`) 

 

zvec, nzvec -- a list of integers up to dim(Q) 

 

EXAMPLES:: 

 

sage: Q = DiagonalQuadraticForm(ZZ, [1,2,3]) 

sage: Q.count_congruence_solutions__zero_type(3, 1, 0, None, None) 

1 

 

""" 

return CountAllLocalTypesNaive(self, p, k, m, zvec, nzvec)[2] 

 

 

def count_congruence_solutions__bad_type(self, p, k, m, zvec, nzvec): 

""" 

Counts the bad-type solutions of Q(`x`) `= m (mod p^k)` satisfying the 

additional congruence conditions described in 

QuadraticForm.count_congruence_solutions_as_vector(). 

 

INPUT: 

 

`p` -- prime number > 0 

 

`k` -- an integer > 0 

 

`m` -- an integer (depending only on mod `p^k`) 

 

zvec, nzvec -- a list of integers up to dim(Q) 

 

EXAMPLES:: 

 

sage: Q = DiagonalQuadraticForm(ZZ, [1,2,3]) 

sage: Q.count_congruence_solutions__bad_type(3, 1, 0, None, None) 

2 

 

""" 

return CountAllLocalTypesNaive(self, p, k, m, zvec, nzvec)[3] 

 

 

def count_congruence_solutions__bad_type_I(self, p, k, m, zvec, nzvec): 

""" 

Counts the bad-typeI solutions of Q(`x`) = `m (mod p^k)` satisfying 

the additional congruence conditions described in 

QuadraticForm.count_congruence_solutions_as_vector(). 

 

INPUT: 

 

`p` -- prime number > 0 

 

`k` -- an integer > 0 

 

`m` -- an integer (depending only on mod `p^k`) 

 

zvec, nzvec -- a list of integers up to dim(Q) 

 

EXAMPLES:: 

 

sage: Q = DiagonalQuadraticForm(ZZ, [1,2,3]) 

sage: Q.count_congruence_solutions__bad_type_I(3, 1, 0, None, None) 

0 

 

""" 

return CountAllLocalTypesNaive(self, p, k, m, zvec, nzvec)[4] 

 

 

def count_congruence_solutions__bad_type_II(self, p, k, m, zvec, nzvec): 

""" 

Counts the bad-typeII solutions of Q(`x`) `= m (mod p^k)` satisfying 

the additional congruence conditions described in 

QuadraticForm.count_congruence_solutions_as_vector(). 

 

INPUT: 

 

`p` -- prime number > 0 

 

`k` -- an integer > 0 

 

`m` -- an integer (depending only on mod `p^k`) 

 

zvec, nzvec -- a list of integers up to dim(Q) 

 

EXAMPLES:: 

 

sage: Q = DiagonalQuadraticForm(ZZ, [1,2,3]) 

sage: Q.count_congruence_solutions__bad_type_II(3, 1, 0, None, None) 

2 

 

""" 

return CountAllLocalTypesNaive(self, p, k, m, zvec, nzvec)[5]