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

237

238

239

240

241

242

243

244

245

246

247

248

249

250

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

273

274

275

276

277

278

279

280

281

282

283

284

285

286

287

288

289

290

291

292

293

294

295

296

297

298

299

300

301

302

303

304

305

306

307

308

309

310

311

312

313

314

315

316

317

318

319

320

321

322

323

324

325

326

327

328

329

330

331

332

333

334

335

336

337

338

339

340

341

342

343

344

345

346

347

348

349

350

351

352

353

354

355

356

357

358

359

360

361

362

363

364

365

366

367

368

369

370

371

372

373

374

375

376

377

378

379

380

381

382

383

384

385

386

387

388

389

390

391

392

393

394

395

396

397

398

399

400

401

402

403

404

405

406

407

408

409

410

411

412

413

414

415

416

417

418

419

420

421

422

423

424

425

426

427

428

429

430

431

432

433

434

435

436

437

438

439

440

441

442

443

444

445

446

447

448

449

450

451

452

453

454

455

456

457

458

459

460

461

462

463

464

465

466

467

468

469

470

471

472

473

474

475

476

477

478

479

480

481

482

483

484

485

486

487

488

489

490

491

492

493

494

495

496

497

498

499

500

501

502

503

504

505

506

507

508

509

510

511

512

513

514

515

516

517

518

519

520

521

522

523

524

525

526

527

528

529

530

531

532

533

534

535

536

537

538

539

540

541

542

543

544

545

546

547

548

549

550

551

552

553

554

555

556

557

558

559

560

561

562

563

564

565

566

567

568

569

570

571

572

573

574

575

576

577

578

579

580

581

582

583

584

585

586

587

588

589

590

591

592

593

594

595

596

597

598

599

600

601

602

603

604

605

606

607

608

609

610

611

612

613

614

615

616

617

618

619

620

621

622

623

624

625

626

627

628

629

630

631

632

633

634

635

636

637

638

639

640

641

642

643

644

645

646

647

648

649

650

651

652

653

654

655

656

657

658

659

660

661

662

663

664

665

666

667

668

669

670

671

672

673

674

675

676

677

678

679

680

681

682

683

684

685

686

687

688

689

690

691

692

693

694

695

696

697

698

699

700

701

702

703

704

705

706

707

708

709

710

711

712

713

714

715

716

717

718

719

720

721

722

723

724

725

726

727

728

729

730

731

732

733

734

735

736

737

738

739

740

741

742

743

744

745

746

747

748

749

750

751

752

753

754

755

756

757

758

759

760

761

762

763

764

765

766

767

768

769

770

771

772

773

774

775

776

777

778

779

780

781

782

783

784

785

786

787

788

789

790

791

792

793

794

795

796

797

798

799

800

801

802

803

804

805

806

807

808

809

810

811

812

813

814

815

816

817

818

819

820

821

822

823

824

825

826

827

828

829

830

831

832

833

834

835

836

837

838

839

840

841

842

843

844

845

846

847

848

849

850

851

852

853

854

855

856

857

858

859

860

861

862

863

864

865

866

867

868

869

870

871

872

873

874

875

876

877

878

879

880

881

882

883

884

885

886

887

888

889

890

891

892

893

894

895

896

897

898

899

900

901

902

903

904

905

906

907

908

909

910

911

912

913

914

915

916

917

918

919

920

921

922

923

924

925

926

927

928

929

930

931

932

933

934

935

936

937

938

939

940

941

942

943

944

945

946

947

948

949

950

951

952

953

954

955

956

957

958

959

960

961

962

963

964

965

966

967

968

969

970

971

972

973

974

975

976

977

978

979

980

981

982

983

984

985

986

987

988

989

990

991

992

993

994

995

996

997

998

999

1000

1001

1002

1003

1004

1005

1006

1007

1008

1009

1010

1011

1012

1013

1014

1015

1016

1017

1018

1019

1020

1021

1022

1023

1024

1025

1026

1027

1028

1029

1030

1031

1032

1033

1034

1035

1036

1037

1038

1039

1040

1041

1042

1043

1044

1045

1046

1047

1048

1049

1050

1051

1052

1053

1054

1055

1056

1057

1058

1059

1060

1061

1062

1063

1064

1065

1066

1067

1068

1069

1070

1071

1072

1073

1074

1075

1076

1077

1078

1079

1080

1081

1082

1083

1084

1085

1086

1087

1088

1089

1090

1091

1092

1093

1094

1095

1096

1097

1098

1099

1100

1101

1102

1103

1104

1105

1106

1107

1108

1109

1110

1111

1112

1113

1114

1115

1116

1117

1118

1119

1120

1121

1122

1123

1124

1125

1126

1127

1128

1129

1130

1131

1132

1133

1134

1135

1136

1137

1138

1139

1140

1141

1142

1143

1144

1145

1146

1147

1148

1149

1150

1151

1152

1153

1154

1155

1156

1157

1158

1159

1160

1161

1162

1163

1164

1165

1166

1167

1168

1169

1170

1171

1172

1173

1174

1175

1176

1177

1178

1179

1180

1181

1182

1183

1184

1185

1186

1187

1188

1189

1190

1191

1192

1193

1194

1195

1196

1197

1198

1199

1200

1201

1202

1203

1204

1205

1206

1207

1208

1209

1210

1211

1212

1213

1214

1215

1216

1217

1218

1219

1220

1221

1222

1223

1224

1225

1226

1227

1228

1229

1230

1231

1232

1233

1234

1235

1236

1237

1238

1239

1240

1241

1242

1243

1244

1245

1246

1247

1248

1249

1250

1251

1252

1253

1254

1255

1256

1257

1258

1259

1260

1261

1262

1263

1264

1265

1266

1267

1268

1269

1270

1271

1272

1273

1274

1275

1276

1277

1278

1279

1280

1281

1282

1283

1284

1285

1286

1287

1288

1289

1290

1291

1292

1293

1294

1295

1296

1297

1298

1299

1300

1301

1302

1303

1304

1305

1306

1307

1308

1309

1310

1311

1312

1313

1314

1315

1316

1317

1318

1319

1320

1321

1322

1323

1324

1325

1326

1327

1328

1329

1330

1331

1332

1333

1334

1335

1336

1337

1338

1339

1340

1341

1342

1343

1344

1345

1346

1347

1348

1349

1350

1351

1352

1353

1354

1355

1356

1357

1358

1359

1360

1361

1362

1363

1364

1365

1366

1367

1368

1369

1370

1371

1372

1373

1374

1375

1376

1377

1378

1379

1380

1381

1382

1383

1384

1385

1386

1387

1388

1389

1390

1391

1392

1393

1394

1395

1396

1397

1398

1399

1400

1401

1402

1403

1404

1405

1406

1407

1408

1409

1410

1411

1412

1413

1414

# -*- coding: utf-8 -*- 

r""" 

Space of boundary modular symbols 

 

Used mainly for computing the cuspidal subspace of modular symbols. The space 

of boundary symbols of sign 0 is isomorphic as a Hecke module to the dual of 

the space of Eisenstein series, but this does not give a useful method of 

computing Eisenstein series, since there is no easy way to extract the constant 

terms. 

 

We represent boundary modular symbols as a sum of Manin symbols of the form 

`[P, u/v]`, where `u/v` is a cusp for our group `G`. The group of boundary 

modular symbols naturally embeds into a vector space `B_k(G)` (see Stein, 

section 8.4, or Merel, section 1.4, where this space is called `\CC[\Gamma 

\backslash \QQ]_k`, for a definition), which is a finite dimensional `\QQ` 

vector space of dimension equal to the number of cusps for `G`. The embedding 

takes `[P, u/v]` to `P(u,v)\cdot [(u,v)]`. We represent the basis vectors by 

pairs `[(u,v)]` with u, v coprime. On `B_k(G)`, we have the relations 

 

.. MATH:: 

 

[\gamma \cdot (u,v)] = [(u,v)] 

 

for all `\gamma \in G` and 

 

.. MATH:: 

 

[(\lambda u, \lambda v)] = \operatorname{sign}(\lambda)^k [(u,v)] 

 

 

for all `\lambda \in \QQ^\times`. 

 

It's possible for these relations to kill a class, i.e., for a pair `[(u,v)]` 

to be 0. For example, when `N=4` and `k=3` then `(-1,-2)` is equivalent mod 

`\Gamma_1(4)` to `(1,2)` since `2=-2 \bmod 4` and `1=-1 \bmod 2`. But since `k` 

is odd, `[(-1,-2)]` is also equivalent to `-[(1,2)]`. Thus this symbol is 

equivalent to its negative, hence 0 (notice that this wouldn't be the case in 

characteristic 2). This happens for any irregular cusp when the weight is odd; 

there are no irregular cusps on `\Gamma_1(N)` except when `N = 4`, but there 

can be more on `\Gamma_H` groups. See also prop 2.30 of Stein's Ph.D. thesis. 

 

In addition, in the case that our space is of sign `\sigma = 1` or `-1`, we 

also have the relation `[(-u,v)] = \sigma \cdot [(u,v)]`. This relation can 

also combine with the above to kill a cusp class - for instance, take (u,v) = 

(1,3) for `\Gamma_1(5)`. Then since the cusp `\tfrac{1}{3}` is 

`\Gamma_1(5)`-equivalent to the cusp `-\tfrac{1}{3}`, we have that `[(1,3)] = 

[(-1,3)]`. Now, on the minus subspace, we also have that `[(-1,3)] = -[(1,3)]`, 

which means this class must vanish. Notice that this cannot be used to show 

that `[(1,0)]` or `[(0,1)]` is 0. 

 

.. note:: 

 

Special care must be taken when working with the images of the cusps 0 and 

`\infty` in `B_k(G)`. For all cusps *except* 0 and `\infty`, multiplying the 

cusp by -1 corresponds to taking `[(u,v)]` to `[(-u,v)]` in `B_k(G)`. This 

means that `[(u,v)]` is equivalent to `[(-u,v)]` whenever `\tfrac{u}{v}` is 

equivalent to `-\tfrac{u}{v}`, except in the case of 0 and `\infty`. We 

have the following conditions for `[(1,0)]` and `[(0,1)]`: 

 

- `[(0,1)] = \sigma \cdot [(0,1)]`, so `[(0,1)]` is 0 exactly when `\sigma = 

-1`. 

 

- `[(1,0)] = \sigma \cdot [(-1,0)]` and `[(1,0)] = (-1)^k [(-1,0)]`, so 

`[(1,0)] = 0` whenever `\sigma \ne (-1)^k`. 

 

.. note:: 

 

For all the spaces of boundary symbols below, no work is done to determine 

the cusps for G at creation time. Instead, cusps are added as they are 

discovered in the course of computation. As a result, the rank of a space 

can change as a computation proceeds. 

 

REFERENCES: 

 

- Merel, "Universal Fourier expansions of modular 

forms." Springer LNM 1585 (1994), pg. 59-95. 

 

- Stein, "Modular Forms, a computational approach." AMS (2007). 

""" 

 

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

# Copyright (C) 2005 William Stein <wstein@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 __future__ import absolute_import 

from six.moves import range 

 

from sage.misc.misc import repr_lincomb 

from sage.structure.richcmp import richcmp_method, richcmp 

 

import sage.modules.free_module as free_module 

from sage.modules.free_module_element import is_FreeModuleElement 

 

import sage.modular.arithgroup.all as arithgroup 

import sage.modular.cusps as cusps 

import sage.modular.dirichlet as dirichlet 

import sage.modular.hecke.all as hecke 

from sage.modular.modsym.manin_symbol import ManinSymbol 

 

import sage.rings.all as rings 

import sage.arith.all as arith 

 

 

from . import element 

 

 

class BoundarySpaceElement(hecke.HeckeModuleElement): 

def __init__(self, parent, x): 

""" 

Create a boundary symbol. 

 

INPUT: 

 

 

- ``parent`` - BoundarySpace; a space of boundary 

modular symbols 

 

- ``x`` - a dict with integer keys and values in the 

base field of parent. 

 

 

EXAMPLES:: 

 

sage: B = ModularSymbols(Gamma0(32), sign=-1).boundary_space() 

sage: B(Cusp(1,8)) 

[1/8] 

sage: B.0 

[1/8] 

sage: type(B.0) 

<class 'sage.modular.modsym.boundary.BoundarySpaceElement'> 

""" 

self.__x = x 

self.__vec = parent.free_module()(x) 

hecke.HeckeModuleElement.__init__(self, parent, self.__vec) 

 

def coordinate_vector(self): 

r""" 

Return self as a vector on the QQ-vector space with basis 

self.parent()._known_cusps(). 

 

EXAMPLES:: 

 

sage: B = ModularSymbols(18,4,sign=1).boundary_space() 

sage: x = B(Cusp(1/2)) ; x 

[1/2] 

sage: x.coordinate_vector() 

(1) 

sage: ((18/5)*x).coordinate_vector() 

(18/5) 

sage: B(Cusp(0)) 

[0] 

sage: x.coordinate_vector() 

(1) 

sage: x = B(Cusp(1/2)) ; x 

[1/2] 

sage: x.coordinate_vector() 

(1, 0) 

""" 

return self.__vec 

 

def _repr_(self): 

""" 

Return the string representation of self. 

 

EXAMPLES:: 

 

sage: ModularSymbols(Gamma0(11), 2).boundary_space()(Cusp(0))._repr_() 

'[0]' 

sage: (-6*ModularSymbols(Gamma0(11), 2).boundary_space()(Cusp(0)))._repr_() 

'-6*[0]' 

""" 

g = self.parent()._known_gens_repr 

return repr_lincomb([ (g[i], c) for i,c in self.__x.items() ]) 

 

# can't inherit arithmetic operations from HeckeModule, because basis 

# dimension might change! 

 

def _add_(self, other): 

""" 

Return self + other. Assumes that other is a BoundarySpaceElement. 

 

EXAMPLES:: 

 

sage: B = ModularSymbols(Gamma1(16), 4).boundary_space() 

sage: x = B(Cusp(2/7)) ; y = B(Cusp(13/16)) 

sage: x + y # indirect doctest 

[2/7] + [13/16] 

sage: x + x # indirect doctest 

2*[2/7] 

""" 

z = dict(other.__x) 

for i, c in self.__x.items(): 

if i in z: 

z[i] += c 

else: 

z[i] = c 

return BoundarySpaceElement(self.parent(), z) 

 

def _sub_(self, other): 

""" 

Return self - other. Assumes that other is a BoundarySpaceElement. 

 

EXAMPLES:: 

 

sage: B = ModularSymbols(Gamma1(16), 4).boundary_space() 

sage: x = B(Cusp(2/7)) ; y = B(Cusp(13/16)) 

sage: x - y # indirect doctest 

[2/7] - [13/16] 

sage: x - x # indirect doctest 

0 

""" 

z = dict(self.__x) 

for i, c in other.__x.items(): 

if i in z: 

z[i] -= c 

else: 

z[i] = -c 

return BoundarySpaceElement(self.parent(), z) 

 

def _rmul_(self, other): 

""" 

Return self \* other. Assumes that other can be coerced into 

self.parent().base_ring(). 

 

EXAMPLES:: 

 

sage: B = ModularSymbols(Gamma1(16), 4).boundary_space() 

sage: x = B(Cusp(2/7)) 

sage: x*5 # indirect doctest 

5*[2/7] 

sage: x*-3/5 # indirect doctest 

-3/5*[2/7] 

""" 

x = {} 

for i, c in self.__x.items(): 

x[i] = c*other 

return BoundarySpaceElement(self.parent(), x) 

 

def _lmul_(self, other): 

""" 

Return other \* self. Assumes that other can be coerced into 

self.parent().base_ring(). 

 

EXAMPLES:: 

 

sage: B = ModularSymbols(Gamma1(16), 4).boundary_space() 

sage: x = B(Cusp(13/16)) 

sage: 11*x # indirect doctest 

11*[13/16] 

sage: 1/3*x # indirect doctest 

1/3*[13/16] 

""" 

x = {} 

for i, c in self.__x.items(): 

x[i] = other*c 

return BoundarySpaceElement(self.parent(), x) 

 

def __neg__(self): 

""" 

Return -self. 

 

EXAMPLES:: 

 

sage: B = ModularSymbols(Gamma1(16), 4).boundary_space() 

sage: x = B(Cusp(2/7)) 

sage: -x # indirect doctest 

-[2/7] 

sage: -x + x # indirect doctest 

0 

""" 

return self*(-1) 

 

 

@richcmp_method 

class BoundarySpace(hecke.HeckeModule_generic): 

def __init__(self, 

group = arithgroup.Gamma0(1), 

weight = 2, 

sign = 0, 

base_ring = rings.QQ, 

character = None): 

""" 

Space of boundary symbols for a congruence subgroup of SL_2(Z). 

 

This class is an abstract base class, so only derived classes 

should be instantiated. 

 

INPUT: 

 

 

- ``weight`` - int, the weight 

 

- ``group`` - arithgroup.congroup_generic.CongruenceSubgroup, a congruence 

subgroup. 

 

- ``sign`` - int, either -1, 0, or 1 

 

- ``base_ring`` - rings.Ring (defaults to the 

rational numbers) 

 

 

EXAMPLES:: 

 

sage: B = ModularSymbols(Gamma0(11),2).boundary_space() 

sage: isinstance(B, sage.modular.modsym.boundary.BoundarySpace) 

True 

sage: B == loads(dumps(B)) 

True 

""" 

weight = int(weight) 

if weight <= 1: 

raise ArithmeticError("weight must be at least 2") 

if not arithgroup.is_CongruenceSubgroup(group): 

raise TypeError("group must be a congruence subgroup") 

sign = int(sign) 

if not isinstance(base_ring, rings.Ring) and rings.is_CommutativeRing(base_ring): 

raise TypeError("base_ring must be a commutative ring") 

if character is None and arithgroup.is_Gamma0(group): 

character = dirichlet.TrivialCharacter(group.level(), base_ring) 

(self.__group, self.__weight, self.__character, 

self.__sign, self.__base_ring) = (group, weight, 

character, sign, base_ring) 

self._known_gens = [] 

self._known_gens_repr = [] 

self._is_zero = [] 

hecke.HeckeModule_generic.__init__(self, base_ring, group.level()) 

 

def __richcmp__(self, other, op): 

""" 

EXAMPLES:: 

 

sage: B2 = ModularSymbols(11, 2).boundary_space() 

sage: B4 = ModularSymbols(11, 4).boundary_space() 

sage: B2 == B4 

False 

sage: B2 == ModularSymbols(17, 2).boundary_space() 

False 

""" 

if type(self) is not type(other): 

return NotImplemented 

 

return richcmp((self.group(), self.weight(), self.character()), 

(other.group(), other.weight(), other.character()), 

op) 

 

def _known_cusps(self): 

""" 

Return the list of cusps found so far. 

 

EXAMPLES:: 

 

sage: B = ModularSymbols(Gamma1(12), 4).boundary_space() 

sage: B._known_cusps() 

[] 

sage: ls = [ B(Cusp(i,10)) for i in range(10) ] 

sage: B._known_cusps() 

[0, 1/10, 1/5] 

""" 

return list(self._known_gens) 

 

def is_ambient(self): 

""" 

Return True if self is a space of boundary symbols associated to an 

ambient space of modular symbols. 

 

EXAMPLES:: 

 

sage: M = ModularSymbols(Gamma1(6), 4) 

sage: M.is_ambient() 

True 

sage: M.boundary_space().is_ambient() 

True 

""" 

return True 

 

def group(self): 

""" 

Return the congruence subgroup associated to this space of boundary 

modular symbols. 

 

EXAMPLES:: 

 

sage: ModularSymbols(GammaH(14,[9]), 2).boundary_space().group() 

Congruence Subgroup Gamma_H(14) with H generated by [9] 

""" 

return self.__group 

 

def weight(self): 

""" 

Return the weight of this space of boundary modular symbols. 

 

EXAMPLES:: 

 

sage: ModularSymbols(Gamma1(9), 5).boundary_space().weight() 

5 

""" 

return self.__weight 

 

def character(self): 

""" 

Return the Dirichlet character associated to this space of boundary 

modular symbols. 

 

EXAMPLES:: 

 

sage: ModularSymbols(DirichletGroup(7).0, 6).boundary_space().character() 

Dirichlet character modulo 7 of conductor 7 mapping 3 |--> zeta6 

""" 

return self.__character 

 

def sign(self): 

""" 

Return the sign of the complex conjugation involution on this space 

of boundary modular symbols. 

 

EXAMPLES:: 

 

sage: ModularSymbols(13,2,sign=-1).boundary_space().sign() 

-1 

""" 

return self.__sign 

 

def gen(self, i=0): 

""" 

Return the i-th generator of this space. 

 

EXAMPLES:: 

 

sage: B = ModularSymbols(Gamma0(24), 4).boundary_space() 

sage: B.gen(0) 

Traceback (most recent call last): 

... 

ValueError: only 0 generators known for Space of Boundary Modular Symbols for Congruence Subgroup Gamma0(24) of weight 4 and over Rational Field 

sage: B(Cusp(1/3)) 

[1/3] 

sage: B.gen(0) 

[1/3] 

""" 

if i >= len(self._known_gens) or i < 0: 

raise ValueError("only %s generators known for %s"%(len(self._known_gens), self)) 

return BoundarySpaceElement(self, {i:1}) 

 

def __len__(self): 

""" 

Return the length of self, i.e. the dimension of the underlying 

vector space. 

 

EXAMPLES:: 

 

sage: B = ModularSymbols(Gamma0(36),4,sign=1).boundary_space() 

sage: B.__len__() 

0 

sage: len(B) 

0 

sage: x = B(Cusp(0)) ; y = B(Cusp(oo)) ; len(B) 

2 

""" 

return len(self._known_gens) 

 

def free_module(self): 

""" 

Return the underlying free module for self. 

 

EXAMPLES:: 

 

sage: B = ModularSymbols(Gamma1(7), 5, sign=-1).boundary_space() 

sage: B.free_module() 

Sparse vector space of dimension 0 over Rational Field 

sage: x = B(Cusp(0)) ; y = B(Cusp(1/7)) ; B.free_module() 

Sparse vector space of dimension 2 over Rational Field 

""" 

return free_module.FreeModule(self.__base_ring, len(self._known_gens), sparse=True) 

 

def rank(self): 

""" 

The rank of the space generated by boundary symbols that have been 

found so far in the course of computing the boundary map. 

 

.. warning:: 

 

This number may change as more elements are coerced into 

this space!! (This is an implementation detail that will 

likely change.) 

 

EXAMPLES:: 

 

sage: M = ModularSymbols(Gamma0(72), 2) ; B = M.boundary_space() 

sage: B.rank() 

0 

sage: _ = [ B(x) for x in M.basis() ] 

sage: B.rank() 

16 

""" 

return len(self._known_gens) 

 

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

# Coercion 

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

 

def _coerce_in_manin_symbol(self, x): 

""" 

Coerce the Manin symbol x into self. (That is, return the image of 

x under the boundary map.) 

 

Assumes that x is associated to the same space of modular symbols 

as self. 

 

EXAMPLES:: 

 

sage: M = ModularSymbols(Gamma1(5), 4) ; B = M.boundary_space() 

sage: [ B(x) for x in M.basis() ] 

[-[2/5], -[-1/5], -[1/2], -[1/2], -[1/4], -[1/4]] 

sage: [ B._coerce_in_manin_symbol(x) for x in M.manin_symbols_basis() ] 

[-[2/5], -[-1/5], -[1/2], -[1/2], -[1/4], -[1/4]] 

""" 

i = x.i 

alpha, beta = x.endpoints(self.level()) 

if self.weight() == 2: 

return self(alpha) - self(beta) 

if i == 0: 

return self(alpha) 

elif i == self.weight() - 2: 

return -self(beta) 

else: 

return self(0) 

 

def __call__(self, x): 

""" 

Coerce x into a boundary symbol space. 

 

If x is a modular symbol (with the same group, weight, character, 

sign, and base field), this returns the image of that modular 

symbol under the boundary map. 

 

EXAMPLES:: 

 

sage: M = ModularSymbols(Gamma0(15), 2) ; B = M.boundary_space() 

sage: B(M.0) 

[Infinity] - [0] 

sage: B(Cusp(1)) 

[0] 

sage: B(Cusp(oo)) 

[Infinity] 

sage: B(7) 

Traceback (most recent call last): 

... 

TypeError: Coercion of 7 (of type <type 'sage.rings.integer.Integer'>) into Space of Boundary Modular Symbols for Congruence Subgroup Gamma0(15) of weight 2 and over Rational Field not (yet) defined. 

""" 

from .ambient import ModularSymbolsAmbient 

if isinstance(x, int) and x == 0: 

return BoundarySpaceElement(self, {}) 

 

elif isinstance(x, cusps.Cusp): 

return self._coerce_cusp(x) 

 

elif isinstance(x, ManinSymbol): 

return self._coerce_in_manin_symbol(x) 

 

elif element.is_ModularSymbolsElement(x): 

M = x.parent() 

if not isinstance(M, ModularSymbolsAmbient): 

raise TypeError("x (=%s) must be an element of a space of modular symbols of type ModularSymbolsAmbient"%x) 

if M.level() != self.level(): 

raise TypeError("x (=%s) must have level %s but has level %s"%( 

x, self.level(), M.level())) 

S = x.manin_symbol_rep() 

if len(S) == 0: 

return self(0) 

return sum([c*self._coerce_in_manin_symbol(v) for c, v in S]) 

 

elif is_FreeModuleElement(x): 

y = dict([(i,x[i]) for i in range(len(x))]) 

return BoundarySpaceElement(self, y) 

 

raise TypeError("Coercion of %s (of type %s) into %s not (yet) defined."%(x, type(x), self)) 

 

def _repr_(self): 

""" 

Return the string representation of self. 

 

EXAMPLES:: 

 

sage: sage.modular.modsym.boundary.BoundarySpace(Gamma0(3), 2)._repr_() 

'Space of Boundary Modular Symbols of weight 2 for Congruence Subgroup Gamma0(3) with sign 0 and character [1] over Rational Field' 

""" 

return ("Space of Boundary Modular Symbols of weight %s for" + \ 

" %s with sign %s and character %s over %s")%( 

self.weight(), self.group(), self.sign(), 

self.character()._repr_short_(), self.base_ring()) 

 

def _cusp_index(self, cusp): 

""" 

Return the index of the first cusp in self._known_cusps() 

equivalent to cusp, or -1 if cusp is not equivalent to any cusp 

found so far. 

 

EXAMPLES:: 

 

sage: B = ModularSymbols(Gamma0(21), 4).boundary_space() 

sage: B._cusp_index(Cusp(0)) 

-1 

sage: _ = B(Cusp(oo)) 

sage: _ = B(Cusp(0)) 

sage: B._cusp_index(Cusp(0)) 

1 

""" 

g = self._known_gens 

N = self.level() 

for i in range(len(g)): 

if self._is_equiv(cusp, g[i]): 

return i 

return -1 

 

class BoundarySpace_wtk_g0(BoundarySpace): 

def __init__(self, level, weight, sign, F): 

""" 

Initialize a space of boundary symbols of weight k for Gamma_0(N) 

over base field F. 

 

INPUT: 

 

 

- ``level`` - int, the level 

 

- ``weight`` - integer weight = 2. 

 

- ``sign`` - int, either -1, 0, or 1 

 

- ``F`` - field 

 

 

EXAMPLES:: 

 

sage: B = ModularSymbols(Gamma0(2), 5).boundary_space() 

sage: type(B) 

<class 'sage.modular.modsym.boundary.BoundarySpace_wtk_g0_with_category'> 

sage: B == loads(dumps(B)) 

True 

""" 

level = int(level) 

sign = int(sign) 

weight = int(weight) 

if not sign in [-1,0,1]: 

raise ArithmeticError("sign must be an int in [-1,0,1]") 

if level <= 0: 

raise ArithmeticError("level must be positive") 

BoundarySpace.__init__(self, 

weight = weight, 

group = arithgroup.Gamma0(level), 

sign = sign, 

base_ring = F) 

 

def _repr_(self): 

""" 

Return the string representation of self. 

 

EXAMPLES:: 

 

sage: B = ModularSymbols(Gamma0(97), 3).boundary_space() 

sage: B._repr_() 

'Space of Boundary Modular Symbols for Congruence Subgroup Gamma0(97) of weight 3 and over Rational Field' 

""" 

return ("Space of Boundary Modular Symbols for %s of weight %s " + \ 

"and over %s")%(self.group(), self.weight(), self.base_ring()) 

 

def _coerce_cusp(self, c): 

""" 

Coerce the cusp c into this boundary symbol space. 

 

EXAMPLES:: 

 

sage: B = ModularSymbols(Gamma0(17), 6).boundary_space() 

sage: B._coerce_cusp(Cusp(0)) 

[0] 

sage: B = ModularSymbols(Gamma0(17), 6, sign=-1).boundary_space() 

sage: B._coerce_cusp(Cusp(0)) 

0 

sage: B = ModularSymbols(Gamma0(16), 4).boundary_space() 

sage: [ B(Cusp(i,4)) for i in range(4) ] 

[[0], [1/4], [1/2], [3/4]] 

sage: B = ModularSymbols(Gamma0(16), 4, sign=1).boundary_space() 

sage: [ B(Cusp(i,4)) for i in range(4) ] 

[[0], [1/4], [1/2], [1/4]] 

sage: B = ModularSymbols(Gamma0(16), 4, sign=-1).boundary_space() 

sage: [ B(Cusp(i,4)) for i in range(4) ] 

[0, [1/4], 0, -[1/4]] 

""" 

if self.weight()%2 != 0: 

return self(0) 

N = self.level() 

 

# see if we've already found this cusp 

i = self._cusp_index(c) 

if i != -1: 

if i in self._is_zero: 

return self(0) 

return BoundarySpaceElement(self, {i:1}) 

 

# see if we've already found -c 

sign = self.sign() 

if sign != 0: 

i2 = self._cusp_index(-c) 

if i2 != -1: 

if i2 in self._is_zero: 

return self(0) 

return BoundarySpaceElement(self, {i2:sign}) 

 

# found a new cusp class 

g = self._known_gens 

g.append(c) 

self._known_gens_repr.append("[%s]"%c) 

 

# See if the new cusp is killed by sign relations. The 

# relevant relations (for cusps other than 0 and Infinity) 

# are: 

# 

# [(u,v)] = (-1)^k [(-u,-v)] 

# [(u,v)] = [gamma * (u,v)] 

# [(-u,v)] = sign * [(u,v)] 

# 

# So since k is always even on Gamma0, we have that [(u,v)] = 

# 0 from the above relations exactly when (u,v) = gamma*(-u,v) 

# and the sign is -1. 

if sign == -1: 

# NOTE: this code looks wrong. One should do the 

# following: 

# 

# - if c is 0, if the sign is -1, append & return 0 

# - if c is Infinity, then if the sign 

# is not equal to (-1)**self.weight(), then 

# append & return 0 

# - otherwise, if the sign is -1, and c is 

# equivalent to -c, append & return 0. 

# 

# Interestingly, the code below does precisely that. 

# (It's important to recall that for Gamma0, odd weight 

# spaces are 0.) 

if self._is_equiv(c, -c): 

self._is_zero.append(len(g)-1) 

return self(0) 

 

return BoundarySpaceElement(self, {(len(g)-1):1}) 

 

def _is_equiv(self, c1, c2): 

""" 

Determine whether or not c1 and c2 are equivalent for self. 

 

EXAMPLES:: 

 

sage: B = ModularSymbols(Gamma0(24), 6).boundary_space() 

sage: B._is_equiv(Cusp(0), Cusp(oo)) 

False 

sage: B._is_equiv(Cusp(0), Cusp(1)) 

True 

""" 

return c1.is_gamma0_equiv(c2, self.level()) 

 

 

class BoundarySpace_wtk_g1(BoundarySpace): 

def __init__(self, level, weight, sign, F): 

""" 

Initialize a space of boundary modular symbols for Gamma1(N). 

 

INPUT: 

 

 

- ``level`` - int, the level 

 

- ``weight`` - int, the weight = 2 

 

- ``sign`` - int, either -1, 0, or 1 

 

- ``F`` - base ring 

 

 

EXAMPLES:: 

 

sage: from sage.modular.modsym.boundary import BoundarySpace_wtk_g1 

sage: B = BoundarySpace_wtk_g1(17, 2, 0, QQ) ; B 

Boundary Modular Symbols space for Gamma_1(17) of weight 2 over Rational Field 

sage: B == loads(dumps(B)) 

True 

""" 

level = int(level) 

sign = int(sign) 

if not sign in [-1,0,1]: 

raise ArithmeticError("sign must be an int in [-1,0,1]") 

if level <= 0: 

raise ArithmeticError("level must be positive") 

 

BoundarySpace.__init__(self, 

weight = weight, 

group = arithgroup.Gamma1(level), 

sign = sign, 

base_ring = F) 

 

def _repr_(self): 

""" 

Return the string representation of self. 

 

EXAMPLES:: 

 

sage: ModularSymbols(Gamma1(5), 3, sign=1).boundary_space()._repr_() 

'Boundary Modular Symbols space for Gamma_1(5) of weight 3 over Rational Field' 

""" 

return ("Boundary Modular Symbols space for Gamma_1(%s) of weight %s " + \ 

"over %s")%(self.level(),self.weight(), self.base_ring()) 

 

 

def _is_equiv(self, c1, c2): 

""" 

Return True if c1 and c2 are equivalent cusps for self, and False 

otherwise. 

 

EXAMPLES:: 

 

sage: B = ModularSymbols(Gamma1(10), 4).boundary_space() 

sage: B._is_equiv(Cusp(0), Cusp(1/5)) 

(False, 0) 

sage: B._is_equiv(Cusp(4/5), Cusp(1/5)) 

(True, -1) 

sage: B._is_equiv(Cusp(-4/5), Cusp(1/5)) 

(True, 1) 

""" 

return c1.is_gamma1_equiv(c2, self.level()) 

 

def _cusp_index(self, cusp): 

""" 

Returns a pair (i, t), where i is the index of the first cusp in 

self._known_cusps() which is equivalent to cusp, and t is 1 or -1 

as cusp is Gamma1-equivalent to plus or minus 

self._known_cusps()[i]. If cusp is not equivalent to any known 

cusp, return (-1, 0). 

 

EXAMPLES:: 

 

sage: B = ModularSymbols(Gamma1(11),2).boundary_space() 

sage: B._cusp_index(Cusp(1/11)) 

(-1, 0) 

sage: B._cusp_index(Cusp(10/11)) 

(-1, 0) 

sage: B._coerce_cusp(Cusp(1/11)) 

[1/11] 

sage: B._cusp_index(Cusp(1/11)) 

(0, 1) 

sage: B._cusp_index(Cusp(10/11)) 

(0, -1) 

""" 

g = self._known_gens 

N = self.level() 

for i in range(len(g)): 

t, eps = self._is_equiv(cusp, g[i]) 

if t: 

return i, eps 

return -1, 0 

 

def _coerce_cusp(self, c): 

""" 

Coerce a cusp into this boundary symbol space. 

 

EXAMPLES:: 

 

sage: B = ModularSymbols(Gamma1(4), 4).boundary_space() 

sage: B._coerce_cusp(Cusp(1/2)) 

[1/2] 

sage: B._coerce_cusp(Cusp(1/4)) 

[1/4] 

sage: B._coerce_cusp(Cusp(3/4)) 

[1/4] 

sage: B = ModularSymbols(Gamma1(5), 3, sign=-1).boundary_space() 

sage: B._coerce_cusp(Cusp(0)) 

0 

sage: B._coerce_cusp(Cusp(oo)) 

[Infinity] 

sage: B = ModularSymbols(Gamma1(2), 3, sign=-1).boundary_space() 

sage: B._coerce_cusp(Cusp(0)) 

0 

sage: B._coerce_cusp(Cusp(oo)) 

0 

sage: B = ModularSymbols(Gamma1(7), 3).boundary_space() 

sage: [ B(Cusp(i,7)) for i in range(7) ] 

[[0], [1/7], [2/7], [3/7], -[3/7], -[2/7], -[1/7]] 

sage: B._is_equiv(Cusp(1,6), Cusp(5,6)) 

(True, 1) 

sage: B._is_equiv(Cusp(1,6), Cusp(0)) 

(True, -1) 

sage: B(Cusp(0)) 

[0] 

sage: B = ModularSymbols(Gamma1(7), 3, sign=1).boundary_space() 

sage: [ B(Cusp(i,7)) for i in range(7) ] 

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

sage: B = ModularSymbols(Gamma1(7), 3, sign=-1).boundary_space() 

sage: [ B(Cusp(i,7)) for i in range(7) ] 

[0, [1/7], [2/7], [3/7], -[3/7], -[2/7], -[1/7]] 

""" 

N = self.level() 

k = self.weight() 

sign = self.sign() 

i, eps = self._cusp_index(c) 

if i != -1: 

if i in self._is_zero: 

return self(0) 

return BoundarySpaceElement(self, {i : eps**k}) 

 

if sign != 0: 

i2, eps = self._cusp_index(-c) 

if i2 != -1: 

if i2 in self._is_zero: 

return self(0) 

else: 

return BoundarySpaceElement(self, {i2:sign*(eps**k)}) 

 

# found a new cusp class 

g = self._known_gens 

g.append(c) 

self._known_gens_repr.append("[%s]"%c) 

 

# Does cusp class vanish because of - relations? (See note at top 

# of file.) 

if k % 2 != 0: 

(u, v) = (c.numerator(), c.denominator()) 

if (2*v) % N == 0: 

if (2*u) % v.gcd(N) == 0: 

self._is_zero.append(len(g)-1) 

return self(0) 

 

# Does class vanish because of sign relations? The relevant 

# relations are 

# 

# [(u,v)] = (-1)^k [(-u,-v)] 

# [(u,v)] = sign * [(-u,v)] 

# [(u,v)] = eps * (-1)^k [(-u,v)] 

# 

# where, in the last line, (u,v) is Gamma1-equivalent to 

# (-u,v) or (u,-v) as eps is 1 or -1. 

# 

# Thus (other than for 0 and Infinity), we have that [(u,v)] 

# can only be killed by sign relations when: 

# 

# - (u,v) is Gamma1-equivalent to (-u,v) or (u,-v), and 

# - eps is 1 and sign is -1, or eps is -1 and sign is not 

# (-1)^k. 

# 

if sign: 

if c.is_infinity(): 

if sign != (-1)**self.weight(): 

self._is_zero.append(len(g)-1) 

return self(0) 

elif c.is_zero(): 

if (sign == -1): 

self._is_zero.append(len(g)-1) 

return self(0) 

else: 

t, eps = self._is_equiv(c, -c) 

if t and ((eps == 1 and sign == -1) or \ 

(eps == -1 and sign != (-1)**self.weight())): 

self._is_zero.append(len(g)-1) 

return self(0) 

 

return BoundarySpaceElement(self, {(len(g)-1):1}) 

 

class BoundarySpace_wtk_gamma_h(BoundarySpace): 

def __init__(self, group, weight, sign, F): 

""" 

Initialize a space of boundary modular symbols for GammaH(N). 

 

INPUT: 

 

 

- ``group`` - congruence subgroup Gamma_H(N). 

 

- ``weight`` - int, the weight = 2 

 

- ``sign`` - int, either -1, 0, or 1 

 

- ``F`` - base ring 

 

 

EXAMPLES:: 

 

sage: from sage.modular.modsym.boundary import BoundarySpace_wtk_gamma_h 

sage: B = BoundarySpace_wtk_gamma_h(GammaH(13,[3]), 2, 0, QQ) ; B 

Boundary Modular Symbols space for Congruence Subgroup Gamma_H(13) with H generated by [3] of weight 2 over Rational Field 

sage: B == loads(dumps(B)) 

True 

""" 

sign = int(sign) 

if not sign in [-1,0,1]: 

raise ArithmeticError("sign must be an int in [-1,0,1]") 

 

BoundarySpace.__init__(self, 

weight = weight, 

group = group, 

sign = sign, 

base_ring = F) 

 

def _repr_(self): 

""" 

Return the string representation of self. 

 

EXAMPLES:: 

 

sage: ModularSymbols(GammaH(7,[2]), 4).boundary_space()._repr_() 

'Boundary Modular Symbols space for Congruence Subgroup Gamma_H(7) with H generated by [2] of weight 4 over Rational Field' 

""" 

return ("Boundary Modular Symbols space for %s of weight %s " + \ 

"over %s")%(self.group(),self.weight(), self.base_ring()) 

 

 

def _is_equiv(self, c1, c2): 

""" 

Return a pair of the form (b, t), where b is True if c1 and c2 are 

equivalent cusps for self, and False otherwise, and t gives extra 

information about the equivalence between c1 and c2. 

 

EXAMPLES:: 

 

sage: B = ModularSymbols(GammaH(7,[2]), 4).boundary_space() 

sage: B._is_equiv(Cusp(0), Cusp(1/7)) 

(False, 0) 

sage: B._is_equiv(Cusp(2/7), Cusp(1/7)) 

(True, 1) 

sage: B._is_equiv(Cusp(3/7), Cusp(1/7)) 

(True, -1) 

""" 

return c1.is_gamma_h_equiv(c2, self.group()) 

 

def _cusp_index(self, cusp): 

""" 

Returns a pair (i, t), where i is the index of the first cusp in 

self._known_cusps() which is equivalent to cusp, and t is 1 or -1 

as cusp is GammaH-equivalent to plus or minus 

self._known_cusps()[i]. If cusp is not equivalent to any known 

cusp, return (-1, 0). 

 

EXAMPLES:: 

 

sage: M = ModularSymbols(GammaH(9,[4]), 3) 

sage: B = M.boundary_space() 

sage: B._cusp_index(Cusp(0)) 

(-1, 0) 

sage: _ = [ B(x) for x in M.basis() ] 

sage: B._cusp_index(Cusp(0)) 

(1, -1) 

sage: B._cusp_index(Cusp(5/6)) 

(3, 1) 

""" 

g = self._known_gens 

N = self.level() 

for i in range(len(g)): 

t, eps = self._is_equiv(cusp, g[i]) 

if t: 

return i, eps 

return -1, 0 

 

def _coerce_cusp(self, c): 

""" 

Coerce the cusp c into self. 

 

EXAMPLES:: 

 

sage: B = ModularSymbols(GammaH(10,[9]), 2).boundary_space() 

sage: B(Cusp(0)) 

[0] 

sage: B(Cusp(1/3)) 

[1/3] 

sage: B(Cusp(1/13)) 

[1/3] 

sage: B = ModularSymbols(GammaH(25, [6]), 2).boundary_space() 

sage: B._coerce_cusp(Cusp(0)) 

[0] 

 

:: 

 

sage: B = ModularSymbols(GammaH(11,[3]), 3).boundary_space() 

sage: [ B(Cusp(i,11)) for i in range(11) ] 

[[0], 

[1/11], 

-[1/11], 

[1/11], 

[1/11], 

[1/11], 

-[1/11], 

-[1/11], 

-[1/11], 

[1/11], 

-[1/11]] 

sage: B._is_equiv(Cusp(0), Cusp(1,11)) 

(False, 0) 

sage: B._is_equiv(Cusp(oo), Cusp(1,11)) 

(True, 1) 

sage: B = ModularSymbols(GammaH(11,[3]), 3, sign=1).boundary_space() 

sage: [ B(Cusp(i,11)) for i in range(11) ] 

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

sage: B = ModularSymbols(GammaH(11,[3]), 3, sign=-1).boundary_space() 

sage: [ B(Cusp(i,11)) for i in range(11) ] 

[0, 

[1/11], 

-[1/11], 

[1/11], 

[1/11], 

[1/11], 

-[1/11], 

-[1/11], 

-[1/11], 

[1/11], 

-[1/11]] 

""" 

N = self.level() 

k = self.weight() 

sign = self.sign() 

i, eps = self._cusp_index(c) 

if i != -1: 

if i in self._is_zero: 

return self(0) 

return BoundarySpaceElement(self, {i : eps**k}) 

 

if sign != 0: 

i2, eps = self._cusp_index(-c) 

if i2 != -1: 

if i2 in self._is_zero: 

return self(0) 

return BoundarySpaceElement(self, {i2:sign*(eps**k)}) 

 

# found a new cusp class 

g = self._known_gens 

g.append(c) 

self._known_gens_repr.append("[%s]"%c) 

 

# Does cusp class vanish because of - relations? (See note at top 

# of file.) 

if k % 2 != 0: 

(u, v) = (c.numerator(), c.denominator()) 

if (2*v) % N == 0: 

if (2*u) % v.gcd(N) == 0: 

self._is_zero.append(len(g)-1) 

return self(0) 

 

# Does class vanish because of sign relations? The relevant 

# relations are 

# 

# [(u,v)] = (-1)^k [(-u,-v)] 

# [(u,v)] = sign * [(-u,v)] 

# [(u,v)] = eps * (-1)^k [(-u,v)] 

# 

# where, in the last line, (u,v) is GammaH-equivalent to 

# (-u,v) or (u,-v) as eps is 1 or -1. 

# 

# Thus (other than for 0 and Infinity), we have that [(u,v)] 

# can only be killed by sign relations when: 

# 

# - (u,v) is GammaH-equivalent to (-u,v) or (u,-v), and 

# - eps is 1 and sign is -1, or eps is -1 and sign is not 

# (-1)^k. 

# 

# (Notice that while this description looks identical to that 

# of Gamma1, it differs in that the condition of being GammaH 

# equivalent is weaker than that of being Gamma1 equivalent 

# when H is larger than {1}.) 

# 

if sign: 

if c.is_infinity(): 

if sign != (-1)**self.weight(): 

self._is_zero.append(len(g)-1) 

return self(0) 

elif c.is_zero(): 

if (sign == -1): 

self._is_zero.append(len(g)-1) 

return self(0) 

else: 

t, eps = self._is_equiv(c, -c) 

if t and ((eps == 1 and sign == -1) or \ 

(eps == -1 and sign != (-1)**self.weight())): 

self._is_zero.append(len(g)-1) 

return self(0) 

 

return BoundarySpaceElement(self, {(len(g)-1):1}) 

 

 

class BoundarySpace_wtk_eps(BoundarySpace): 

def __init__(self, eps, weight, sign=0): 

""" 

Space of boundary modular symbols with given weight, character, and 

sign. 

 

INPUT: 

 

 

- ``eps`` - dirichlet.DirichletCharacter, the 

"Nebentypus" character. 

 

- ``weight`` - int, the weight = 2 

 

- ``sign`` - int, either -1, 0, or 1 

 

 

EXAMPLES:: 

 

sage: B = ModularSymbols(DirichletGroup(6).0, 4).boundary_space() ; B 

Boundary Modular Symbols space of level 6, weight 4, character [-1] and dimension 0 over Rational Field 

sage: type(B) 

<class 'sage.modular.modsym.boundary.BoundarySpace_wtk_eps_with_category'> 

sage: B == loads(dumps(B)) 

True 

""" 

level = eps.modulus() 

sign = int(sign) 

self.__eps = eps 

if not sign in [-1,0,1]: 

raise ArithmeticError("sign must be an int in [-1,0,1]") 

if level <= 0: 

raise ArithmeticError("level must be positive") 

BoundarySpace.__init__(self, 

weight = weight, 

group = arithgroup.Gamma1(level), 

sign = sign, 

base_ring = eps.base_ring(), 

character = eps) 

 

def _repr_(self): 

""" 

Return the string representation of self. 

 

EXAMPLES:: 

 

sage: ModularSymbols(DirichletGroup(6).0, 4).boundary_space()._repr_() 

'Boundary Modular Symbols space of level 6, weight 4, character [-1] and dimension 0 over Rational Field' 

""" 

return ("Boundary Modular Symbols space of level %s, weight %s, character %s " + \ 

"and dimension %s over %s")%(self.level(), self.weight(), 

self.character()._repr_short_(), self.rank(), self.base_ring()) 

 

 

def _is_equiv(self, c1, c2): 

""" 

Return a pair (b, t), where b is True if c1 and c2 are equivalent 

cusps for self, and False otherwise, and t gives extra information 

about the equivalence of c1 and c2. 

 

EXAMPLES:: 

 

sage: B = ModularSymbols(DirichletGroup(12).1, 3).boundary_space() 

sage: B._is_equiv(Cusp(0), Cusp(1/3)) 

(False, None) 

sage: B._is_equiv(Cusp(2/3), Cusp(1/3)) 

(True, 5) 

sage: B._is_equiv(Cusp(3/4), Cusp(1/4)) 

(True, 7) 

""" 

return c1.is_gamma0_equiv(c2, self.level(), transformation=True) 

 

def _cusp_index(self, cusp): 

""" 

Returns a pair (i, s), where i is the index of the first cusp in 

self._known_cusps() which is equivalent to cusp, and such that 

cusp is Gamma0-equivalent to self.character()(s) times 

self._known_cusps()[i]. If cusp is not equivalent to any known 

cusp, return (-1, 0). 

 

EXAMPLES:: 

 

sage: B = ModularSymbols(DirichletGroup(11).0**3, 5).boundary_space() 

sage: B._cusp_index(Cusp(0)) 

(-1, 0) 

sage: B._coerce_cusp(Cusp(0)) 

[0] 

sage: B._cusp_index(Cusp(0)) 

(0, 1) 

sage: B._coerce_cusp(Cusp(1,11)) 

[1/11] 

sage: B._cusp_index(Cusp(2,11)) 

(1, -zeta10^2) 

""" 

g = self._known_gens 

N = self.level() 

for i in range(len(g)): 

t, s = self._is_equiv(cusp, g[i]) 

if t: 

return i, self.__eps(s) 

return -1, 0 

 

def _coerce_cusp(self, c): 

""" 

Coerce the cusp c into self. 

 

EXAMPLES:: 

 

sage: B = ModularSymbols(DirichletGroup(13).0**3, 5, sign=0).boundary_space() 

sage: [ B(Cusp(i,13)) for i in range(13) ] 

[[0], 

[1/13], 

-zeta4*[1/13], 

[1/13], 

-[1/13], 

-zeta4*[1/13], 

-zeta4*[1/13], 

zeta4*[1/13], 

zeta4*[1/13], 

[1/13], 

-[1/13], 

zeta4*[1/13], 

-[1/13]] 

sage: B._is_equiv(Cusp(oo), Cusp(1,13)) 

(True, 1) 

sage: B._is_equiv(Cusp(0), Cusp(1,13)) 

(False, None) 

sage: B = ModularSymbols(DirichletGroup(13).0**3, 5, sign=1).boundary_space() 

sage: [ B(Cusp(i,13)) for i in range(13) ] 

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

sage: B._coerce_cusp(Cusp(oo)) 

0 

sage: B = ModularSymbols(DirichletGroup(13).0**3, 5, sign=-1).boundary_space() 

sage: [ B(Cusp(i,13)) for i in range(13) ] 

[0, 

[1/13], 

-zeta4*[1/13], 

[1/13], 

-[1/13], 

-zeta4*[1/13], 

-zeta4*[1/13], 

zeta4*[1/13], 

zeta4*[1/13], 

[1/13], 

-[1/13], 

zeta4*[1/13], 

-[1/13]] 

sage: B = ModularSymbols(DirichletGroup(13).0**4, 5, sign=1).boundary_space() 

sage: B._coerce_cusp(Cusp(0)) 

[0] 

sage: B = ModularSymbols(DirichletGroup(13).0**4, 5, sign=-1).boundary_space() 

sage: B._coerce_cusp(Cusp(0)) 

0 

""" 

N = self.level() 

k = self.weight() 

sign = self.sign() 

i, eps = self._cusp_index(c) 

if i != -1: 

if i in self._is_zero: 

return self(0) 

return BoundarySpaceElement(self, {i : eps}) 

 

if sign != 0: 

i2, eps = self._cusp_index(-c) 

if i2 != -1: 

if i2 in self._is_zero: 

return self(0) 

return BoundarySpaceElement(self, {i2:sign*eps}) 

 

# found a new cusp class 

g = self._known_gens 

g.append(c) 

self._known_gens_repr.append("[%s]"%c) 

 

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

# TODO?: This is a very dumb way to check for solutions to an 

# equation (see Prop 2.30 of Stein's Ph.D. thesis for which 

# equation); however, computing the cusp equivalence for the 

# boundary map takes much less time than computing the kernel 

# of the boundary map, so it's not worth optimizing this now. 

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

 

(u, v) = (c.numerator(), c.denominator()) 

gcd = arith.gcd 

d = gcd(v,N) 

x = N//d 

 

for j in range(d): 

alpha = 1 - j*x 

if gcd(alpha, N) == 1: 

if (v*(1-alpha))%N == 0 and (u*(1-alpha))%d == 0: 

if self.__eps(alpha) != 1: 

self._is_zero.append(len(g)-1) 

return self(0) 

 

# Does class vanish because of sign relations? The relevant 

# relations are 

# 

# [(u,v)] = (-1)^k [(-u,-v)] 

# [(u,v)] = sign * [(-u,v)] 

# [(u,v)] = eps(d) * [(-u,v)] 

# 

# where, in the last line, eps is the character defining 

# our space, and [a,b;c,d] takes (u,v) to (-u,v). 

# 

# Thus (other than for 0 and Infinity), we have that [(u,v)] 

# can only be killed by sign relations when the sign is not 

# equal to eps(d). 

# 

if sign: 

if c.is_zero(): 

if sign == -1: 

self._is_zero.append(len(g)-1) 

return self(0) 

elif c.is_infinity(): 

if sign != (-1)**self.weight(): 

self._is_zero.append(len(g)-1) 

return self(0) 

else: 

t, s = self._is_equiv(c, -c) 

if t: 

if sign != self.__eps(s): 

self._is_zero.append(len(g)-1) 

return self(0) 

 

return BoundarySpaceElement(self, {(len(g)-1):1})