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

""" 

Structure maps for finite fields 

 

This module provides classes for isomorphisms between finite fields and vector spaces. 

 

AUTHORS: 

 

- Kwankyu Lee (2017-11-07): initial version 

 

""" 

 

#***************************************************************************** 

# Copyright (C) 2017 Kwankyu <ekwankyu@gmail.com> 

# 

# This program is free software: you can redistribute it and/or modify 

# it under the terms of the GNU General Public License as published by 

# the Free Software Foundation, either version 2 of the License, or 

# (at your option) any later version. 

# http://www.gnu.org/licenses/ 

#***************************************************************************** 

 

from sage.categories.morphism import Morphism 

 

class FiniteFieldVectorSpaceIsomorphism(Morphism): 

""" 

Base class of the vector space isomorphism between a finite field 

and a vector space over a subfield of the finite field. 

""" 

def _repr_(self): 

""" 

Return the string representation of this isomorphism 

between a finite field and a vector space. 

 

EXAMPLES:: 

 

sage: E = GF(16) 

sage: F = GF(4) 

sage: V, phi, psi = E.vector_space(E, map=True) 

sage: phi 

Isomorphism: 

From: Vector space of dimension 1 over Finite Field in z4 of size 2^4 

To: Finite Field in z4 of size 2^4 

 

""" 

s = "Isomorphism:" 

s += "\n From: {}".format(self.domain()) 

s += "\n To: {}".format(self.codomain()) 

return s 

 

def is_injective(self): 

""" 

EXAMPLES:: 

 

sage: E = GF(9) 

sage: F = GF(3) 

sage: V, phi, psi = E.vector_space(E, map=True) 

sage: phi.is_injective() 

True 

""" 

return True 

 

def is_surjective(self): 

""" 

EXAMPLES:: 

 

sage: E = GF(9) 

sage: F = GF(3) 

sage: V, phi, psi = E.vector_space(E, map=True) 

sage: phi.is_surjective() 

True 

""" 

return True 

 

class MorphismVectorSpaceToFiniteField(FiniteFieldVectorSpaceIsomorphism): 

""" 

Isomorphisms from vector spaces to finite fields. 

""" 

def __init__(self, V, K, C): 

""" 

Initialize. 

 

INPUT: 

 

- ``V`` -- vector space 

 

- ``K`` -- finite field 

 

- ``C`` -- matrix 

 

EXAMPLES:: 

 

sage: E = GF(16) 

sage: F = GF(4) 

sage: V, phi, psi = E.vector_space(E, map=True) 

sage: phi 

Isomorphism: 

From: Vector space of dimension 1 over Finite Field in z4 of size 2^4 

To: Finite Field in z4 of size 2^4 

""" 

if C.is_mutable(): 

C = C.__copy__() 

C.set_immutable() 

self._C = C 

FiniteFieldVectorSpaceIsomorphism.__init__(self, V, K) 

 

def _call_(self, v): 

r""" 

TESTS:: 

 

sage: E = GF(64) 

sage: F = GF(4) 

sage: V, phi, psi = E.vector_space(F, map=True) 

sage: phi(V.zero()) 

0 

sage: [phi(v) for v in V.basis()] 

[1, z6, z6^2] 

""" 

E = self.codomain() # = GF((p^n)^m) 

V = self.domain() # = GF(p^n)^m 

m = V.dimension() 

F = V.base_ring() # = GF(p^n) 

n = F.degree() 

 

if m == n == 1: 

# 1x1 matrix 

return self._C[0][0] * v[0] 

else: 

# expand v as a vector over GF(p) 

w = self._C._row_ambient_module()() 

for i in range(m): 

w[i*n:(i+1)*n] = v[i]._vector_() 

return E(w * self._C) 

 

class MorphismFiniteFieldToVectorSpace(FiniteFieldVectorSpaceIsomorphism): 

""" 

Isomorphisms from finite fields to vector spaces 

""" 

def __init__(self, K, V, C): 

""" 

Initialize. 

 

INPUT: 

 

- ``K`` -- finite field GF((p^m)^n) 

 

- ``V`` -- vector space of rank n over GF(p^m) 

 

- ``C`` -- matrix 

 

EXAMPLES:: 

 

sage: E = GF(16) 

sage: F = GF(4) 

sage: V, phi, psi = E.vector_space(E, map=True) 

sage: psi 

Isomorphism: 

From: Finite Field in z4 of size 2^4 

To: Vector space of dimension 1 over Finite Field in z4 of size 2^4 

""" 

if C.is_mutable(): 

C = C.__copy__() 

C.set_immutable() 

self._C = C 

FiniteFieldVectorSpaceIsomorphism.__init__(self, K, V) 

 

def _call_(self, e): 

r""" 

TESTS:: 

 

sage: E = GF(64) 

sage: F = GF(4) 

sage: V, phi, psi = E.vector_space(F, map=True) 

sage: psi(E.zero()) 

(0, 0, 0) 

sage: psi(E.one()) 

(1, 0, 0) 

sage: psi(E.gen()) 

(0, 1, 0) 

""" 

V = self.codomain() # = GF(p^n)^m 

m = V.dimension() 

F = V.base_ring() # = GF(p^n) 

n = F.degree() 

w = e._vector_() * self._C 

if F.degree() > 1: 

return V([F(w[i*n:(i+1)*n]) for i in range(m)]) 

else: 

return w