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

""" 

Spaces of homomorphisms between modular abelian varieties 

 

EXAMPLES: 

 

First, we consider J0(37). This Jacobian has two simple factors, 

corresponding to distinct newforms. These two intersect 

nontrivially in J0(37). 

 

:: 

 

sage: J = J0(37) 

sage: D = J.decomposition() ; D 

[ 

Simple abelian subvariety 37a(1,37) of dimension 1 of J0(37), 

Simple abelian subvariety 37b(1,37) of dimension 1 of J0(37) 

] 

sage: D[0].intersection(D[1]) 

(Finite subgroup with invariants [2, 2] over QQ of Simple abelian subvariety 37a(1,37) of dimension 1 of J0(37), 

Simple abelian subvariety of dimension 0 of J0(37)) 

 

As an abstract product, since these newforms are distinct, the 

corresponding simple abelian varieties are not isogenous, and so 

there are no maps between them. The endomorphism ring of the 

corresponding product is thus isomorphic to the direct sum of the 

endomorphism rings for each factor. Since the factors correspond to 

abelian varieties of dimension 1, these endomorphism rings are each 

isomorphic to ZZ. 

 

:: 

 

sage: Hom(D[0],D[1]).gens() 

() 

sage: A = D[0] * D[1] ; A 

Abelian subvariety of dimension 2 of J0(37) x J0(37) 

sage: A.endomorphism_ring().gens() 

(Abelian variety endomorphism of Abelian subvariety of dimension 2 of J0(37) x J0(37), 

Abelian variety endomorphism of Abelian subvariety of dimension 2 of J0(37) x J0(37)) 

sage: [ x.matrix() for x in A.endomorphism_ring().gens() ] 

[ 

[1 0 0 0] [0 0 0 0] 

[0 1 0 0] [0 0 0 0] 

[0 0 0 0] [0 0 1 0] 

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

] 

 

However, these two newforms have a congruence between them modulo 

2, which gives rise to interesting endomorphisms of J0(37). 

 

:: 

 

sage: E = J.endomorphism_ring() 

sage: E.gens() 

(Abelian variety endomorphism of Abelian variety J0(37) of dimension 2, 

Abelian variety endomorphism of Abelian variety J0(37) of dimension 2) 

sage: [ x.matrix() for x in E.gens() ] 

[ 

[1 0 0 0] [ 0 1 1 -1] 

[0 1 0 0] [ 1 0 1 0] 

[0 0 1 0] [ 0 0 -1 1] 

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

] 

sage: (-1*E.gens()[0] + E.gens()[1]).matrix() 

[-1 1 1 -1] 

[ 1 -1 1 0] 

[ 0 0 -2 1] 

[ 0 0 0 0] 

 

Of course, these endomorphisms will be reflected in the Hecke 

algebra, which is in fact the full endomorphism ring of J0(37) in 

this case:: 

 

sage: J.hecke_operator(2).matrix() 

[-1 1 1 -1] 

[ 1 -1 1 0] 

[ 0 0 -2 1] 

[ 0 0 0 0] 

sage: T = E.image_of_hecke_algebra() 

sage: T.gens() 

(Abelian variety endomorphism of Abelian variety J0(37) of dimension 2, 

Abelian variety endomorphism of Abelian variety J0(37) of dimension 2) 

sage: [ x.matrix() for x in T.gens() ] 

[ 

[1 0 0 0] [ 0 1 1 -1] 

[0 1 0 0] [ 1 0 1 0] 

[0 0 1 0] [ 0 0 -1 1] 

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

] 

sage: T.index_in(E) 

1 

 

Next, we consider J0(33). In this case, we have both oldforms and 

newforms. There are two copies of J0(11), one for each degeneracy 

map from J0(11) to J0(33). There is also one newform at level 33. 

The images of the two degeneracy maps are, of course, isogenous. 

 

:: 

 

sage: J = J0(33) 

sage: D = J.decomposition() 

sage: D 

[ 

Simple abelian subvariety 11a(1,33) of dimension 1 of J0(33), 

Simple abelian subvariety 11a(3,33) of dimension 1 of J0(33), 

Simple abelian subvariety 33a(1,33) of dimension 1 of J0(33) 

] 

sage: Hom(D[0],D[1]).gens() 

(Abelian variety morphism: 

From: Simple abelian subvariety 11a(1,33) of dimension 1 of J0(33) 

To: Simple abelian subvariety 11a(3,33) of dimension 1 of J0(33),) 

sage: Hom(D[0],D[1]).gens()[0].matrix() 

[ 0 1] 

[-1 0] 

 

Then this gives that the component corresponding to the sum of the 

oldforms will have a rank 4 endomorphism ring. We also have a rank 

one endomorphism ring for the newform 33a (since it is again 

1-dimensional), which gives a rank 5 endomorphism ring for J0(33). 

 

:: 

 

sage: DD = J.decomposition(simple=False) ; DD 

[ 

Abelian subvariety of dimension 2 of J0(33), 

Abelian subvariety of dimension 1 of J0(33) 

] 

sage: A, B = DD 

sage: A == D[0] + D[1] 

True 

sage: A.endomorphism_ring().gens() 

(Abelian variety endomorphism of Abelian subvariety of dimension 2 of J0(33), 

Abelian variety endomorphism of Abelian subvariety of dimension 2 of J0(33), 

Abelian variety endomorphism of Abelian subvariety of dimension 2 of J0(33), 

Abelian variety endomorphism of Abelian subvariety of dimension 2 of J0(33)) 

sage: B.endomorphism_ring().gens() 

(Abelian variety endomorphism of Abelian subvariety of dimension 1 of J0(33),) 

sage: E = J.endomorphism_ring() ; E.gens() # long time (3s on sage.math, 2011) 

(Abelian variety endomorphism of Abelian variety J0(33) of dimension 3, 

Abelian variety endomorphism of Abelian variety J0(33) of dimension 3, 

Abelian variety endomorphism of Abelian variety J0(33) of dimension 3, 

Abelian variety endomorphism of Abelian variety J0(33) of dimension 3, 

Abelian variety endomorphism of Abelian variety J0(33) of dimension 3) 

 

In this case, the image of the Hecke algebra will only have rank 3, 

so that it is of infinite index in the full endomorphism ring. 

However, if we call this image T, we can still ask about the index 

of T in its saturation, which is 1 in this case. 

 

:: 

 

sage: T = E.image_of_hecke_algebra() # long time 

sage: T.gens() # long time 

(Abelian variety endomorphism of Abelian variety J0(33) of dimension 3, 

Abelian variety endomorphism of Abelian variety J0(33) of dimension 3, 

Abelian variety endomorphism of Abelian variety J0(33) of dimension 3) 

sage: T.index_in(E) # long time 

+Infinity 

sage: T.index_in_saturation() # long time 

1 

 

AUTHORS: 

 

- William Stein (2007-03) 

 

- Craig Citro, Robert Bradshaw (2008-03): Rewrote with modabvar overhaul 

""" 

 

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

# Copyright (C) 2007 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 copy import copy 

 

from sage.categories.homset import HomsetWithBase 

from sage.structure.all import parent 

from sage.misc.lazy_attribute import lazy_attribute 

 

 

from . import morphism 

 

import sage.rings.integer_ring 

import sage.rings.all 

 

from sage.rings.ring import Ring 

from sage.matrix.matrix_space import MatrixSpace 

from sage.matrix.constructor import Matrix, identity_matrix 

from sage.structure.element import is_Matrix 

 

ZZ = sage.rings.integer_ring.ZZ 

 

class Homspace(HomsetWithBase): 

""" 

A space of homomorphisms between two modular abelian varieties. 

""" 

Element = morphism.Morphism 

def __init__(self, domain, codomain, cat): 

""" 

Create a homspace. 

 

INPUT: 

 

 

- ``domain, codomain`` - modular abelian varieties 

 

- ``cat`` - category 

 

 

EXAMPLES:: 

 

sage: H = Hom(J0(11), J0(22)); H 

Space of homomorphisms from Abelian variety J0(11) of dimension 1 to Abelian variety J0(22) of dimension 2 

sage: Hom(J0(11), J0(11)) 

Endomorphism ring of Abelian variety J0(11) of dimension 1 

sage: type(H) 

<class 'sage.modular.abvar.homspace.Homspace_with_category'> 

sage: H.homset_category() 

Category of modular abelian varieties over Rational Field 

""" 

from .abvar import is_ModularAbelianVariety 

if not is_ModularAbelianVariety(domain): 

raise TypeError("domain must be a modular abelian variety") 

if not is_ModularAbelianVariety(codomain): 

raise TypeError("codomain must be a modular abelian variety") 

self._gens = None 

HomsetWithBase.__init__(self, domain, codomain, category=cat) 

 

def identity(self): 

""" 

Return the identity endomorphism. 

 

EXAMPLES:: 

 

sage: E = End(J0(11)) 

sage: E.identity() 

Abelian variety endomorphism of Abelian variety J0(11) of dimension 1 

sage: E.one() 

Abelian variety endomorphism of Abelian variety J0(11) of dimension 1 

 

sage: H = Hom(J0(11), J0(22)) 

sage: H.identity() 

Traceback (most recent call last): 

... 

TypeError: the identity map is only defined for endomorphisms 

""" 

if self.domain() is not self.codomain(): 

raise TypeError("the identity map is only defined for endomorphisms") 

M = self.matrix_space().one() 

return self.element_class(self, M) 

 

@lazy_attribute 

def _matrix_space(self): 

""" 

Return the matrix space of ``self``. 

 

.. WARNING:: 

 

During unpickling, the domain and codomain may be unable to 

provide the necessary information. This is why this is a lazy 

attribute. See :trac:`14793`. 

 

EXAMPLES:: 

 

sage: Hom(J0(11), J0(22))._matrix_space 

Full MatrixSpace of 2 by 4 dense matrices over Integer Ring 

""" 

return MatrixSpace(ZZ,2*self.domain().dimension(), 2*self.codomain().dimension()) 

 

def _element_constructor_from_element_class(self, *args, **keywords): 

""" 

Used in the coercion framework. Unfortunately, the default method 

would get the order of parent and data different from what is expected 

in ``MatrixMorphism.__init__``. 

 

EXAMPLES:: 

 

sage: H = Hom(J0(11), J0(22)) 

sage: phi = H(matrix(ZZ,2,4,[5..12])); phi # indirect doctest 

Abelian variety morphism: 

From: Abelian variety J0(11) of dimension 1 

To: Abelian variety J0(22) of dimension 2 

""" 

return self.element_class(self, *args, **keywords) 

 

def __call__(self, M): 

r""" 

Create a homomorphism in this space from M. M can be any of the 

following: 

 

- a Morphism of abelian varieties 

 

- a matrix of the appropriate size 

(i.e. 2\*self.domain().dimension() x 

2\*self.codomain().dimension()) whose entries are coercible 

into self.base_ring() 

 

- anything that can be coerced into self.matrix_space() 

 

EXAMPLES:: 

 

sage: H = Hom(J0(11), J0(22)) 

sage: phi = H(matrix(ZZ,2,4,[5..12])) ; phi 

Abelian variety morphism: 

From: Abelian variety J0(11) of dimension 1 

To: Abelian variety J0(22) of dimension 2 

sage: phi.matrix() 

[ 5 6 7 8] 

[ 9 10 11 12] 

sage: phi.matrix().parent() 

Full MatrixSpace of 2 by 4 dense matrices over Integer Ring 

 

:: 

 

sage: H = J0(22).Hom(J0(11)*J0(11)) 

sage: m1 = J0(22).degeneracy_map(11,1).matrix() ; m1 

[ 0 1] 

[-1 1] 

[-1 0] 

[ 0 -1] 

sage: m2 = J0(22).degeneracy_map(11,2).matrix() ; m2 

[ 1 -2] 

[ 0 -2] 

[ 1 -1] 

[ 0 -1] 

sage: m = m1.transpose().stack(m2.transpose()).transpose() ; m 

[ 0 1 1 -2] 

[-1 1 0 -2] 

[-1 0 1 -1] 

[ 0 -1 0 -1] 

sage: phi = H(m) ; phi 

Abelian variety morphism: 

From: Abelian variety J0(22) of dimension 2 

To: Abelian variety J0(11) x J0(11) of dimension 2 

sage: phi.matrix() 

[ 0 1 1 -2] 

[-1 1 0 -2] 

[-1 0 1 -1] 

[ 0 -1 0 -1] 

""" 

if isinstance(M, morphism.Morphism): 

if M.parent() is self: 

return M 

elif M.domain() == self.domain() and M.codomain() == self.codomain(): 

M = M.matrix() 

else: 

raise ValueError("cannot convert %s into %s" % (M, self)) 

elif is_Matrix(M): 

if M.base_ring() != ZZ: 

M = M.change_ring(ZZ) 

if M.nrows() != 2*self.domain().dimension() or M.ncols() != 2*self.codomain().dimension(): 

raise TypeError("matrix has wrong dimension") 

elif self.matrix_space().has_coerce_map_from(parent(M)): 

M = self.matrix_space()(M) 

else: 

raise TypeError("can only coerce in matrices or morphisms") 

return self.element_class(self, M) 

 

def _coerce_impl(self, x): 

""" 

Coerce x into self, if possible. 

 

EXAMPLES:: 

 

sage: J = J0(37) ; J.Hom(J)._coerce_impl(matrix(ZZ,4,[5..20])) 

Abelian variety endomorphism of Abelian variety J0(37) of dimension 2 

sage: K = J0(11) * J0(11) ; J.Hom(K)._coerce_impl(matrix(ZZ,4,[5..20])) 

Abelian variety morphism: 

From: Abelian variety J0(37) of dimension 2 

To: Abelian variety J0(11) x J0(11) of dimension 2 

""" 

if self.matrix_space().has_coerce_map_from(parent(x)): 

return self(x) 

else: 

return HomsetWithBase._coerce_impl(self, x) 

 

def _repr_(self): 

""" 

String representation of a modular abelian variety homspace. 

 

EXAMPLES:: 

 

sage: J = J0(11) 

sage: End(J)._repr_() 

'Endomorphism ring of Abelian variety J0(11) of dimension 1' 

""" 

return "Space of homomorphisms from %s to %s"%\ 

(self.domain(), self.codomain()) 

 

def _get_matrix(self, g): 

""" 

Given an object g, try to return a matrix corresponding to g with 

dimensions the same as those of self.matrix_space(). 

 

INPUT: 

 

 

- ``g`` - a matrix or morphism or object with a list 

method 

 

 

OUTPUT: a matrix 

 

EXAMPLES:: 

 

sage: E = End(J0(11)) 

sage: E._get_matrix(matrix(QQ,2,[1,2,3,4])) 

[1 2] 

[3 4] 

sage: E._get_matrix(J0(11).hecke_operator(2)) 

[-2 0] 

[ 0 -2] 

 

:: 

 

sage: H = Hom(J0(11) * J0(17), J0(22)) 

sage: H._get_matrix(tuple([8..23])) 

[ 8 9 10 11] 

[12 13 14 15] 

[16 17 18 19] 

[20 21 22 23] 

sage: H._get_matrix(tuple([8..23])) 

[ 8 9 10 11] 

[12 13 14 15] 

[16 17 18 19] 

[20 21 22 23] 

sage: H._get_matrix([8..23]) 

[ 8 9 10 11] 

[12 13 14 15] 

[16 17 18 19] 

[20 21 22 23] 

""" 

try: 

if g.parent() is self.matrix_space(): 

return g 

except AttributeError: 

pass 

 

if isinstance(g, morphism.Morphism): 

return g.matrix() 

elif hasattr(g, 'list'): 

return self.matrix_space()(g.list()) 

else: 

return self.matrix_space()(g) 

 

def free_module(self): 

r""" 

Return this endomorphism ring as a free submodule of a big 

`\ZZ^{4nm}`, where `n` is the dimension of 

the domain abelian variety and `m` the dimension of the 

codomain. 

 

OUTPUT: free module 

 

EXAMPLES:: 

 

sage: E = Hom(J0(11), J0(22)) 

sage: E.free_module() 

Free module of degree 8 and rank 2 over Integer Ring 

Echelon basis matrix: 

[ 1 0 -3 1 1 1 -1 -1] 

[ 0 1 -3 1 1 1 -1 0] 

""" 

self.calculate_generators() 

V = ZZ**(4*self.domain().dimension() * self.codomain().dimension()) 

return V.submodule([ V(m.matrix().list()) for m in self.gens() ]) 

 

def gen(self, i=0): 

""" 

Return i-th generator of self. 

 

INPUT: 

 

 

- ``i`` - an integer 

 

 

OUTPUT: a morphism 

 

EXAMPLES:: 

 

sage: E = End(J0(22)) 

sage: E.gen(0).matrix() 

[1 0 0 0] 

[0 1 0 0] 

[0 0 1 0] 

[0 0 0 1] 

""" 

self.calculate_generators() 

if i > self.ngens(): 

raise ValueError("self only has %s generators"%self.ngens()) 

return self.element_class(self, self._gens[i]) 

 

def ngens(self): 

""" 

Return number of generators of self. 

 

OUTPUT: integer 

 

EXAMPLES:: 

 

sage: E = End(J0(22)) 

sage: E.ngens() 

4 

""" 

self.calculate_generators() 

return len(self._gens) 

 

def gens(self): 

""" 

Return tuple of generators for this endomorphism ring. 

 

EXAMPLES:: 

 

sage: E = End(J0(22)) 

sage: E.gens() 

(Abelian variety endomorphism of Abelian variety J0(22) of dimension 2, 

Abelian variety endomorphism of Abelian variety J0(22) of dimension 2, 

Abelian variety endomorphism of Abelian variety J0(22) of dimension 2, 

Abelian variety endomorphism of Abelian variety J0(22) of dimension 2) 

""" 

try: 

return self._gen_morphisms 

except AttributeError: 

self.calculate_generators() 

self._gen_morphisms = tuple([self.gen(i) for i in range(self.ngens())]) 

return self._gen_morphisms 

 

def matrix_space(self): 

""" 

Return the underlying matrix space that we view this endomorphism 

ring as being embedded into. 

 

EXAMPLES:: 

 

sage: E = End(J0(22)) 

sage: E.matrix_space() 

Full MatrixSpace of 4 by 4 dense matrices over Integer Ring 

""" 

return self._matrix_space 

 

def calculate_generators(self): 

""" 

If generators haven't already been computed, calculate generators 

for this homspace. If they have been computed, do nothing. 

 

EXAMPLES:: 

 

sage: E = End(J0(11)) 

sage: E.calculate_generators() 

""" 

 

if self._gens is not None: 

return 

 

if (self.domain() == self.codomain()) and (self.domain().dimension() == 1): 

self._gens = tuple([ identity_matrix(ZZ,2) ]) 

return 

 

phi = self.domain()._isogeny_to_product_of_powers() 

psi = self.codomain()._isogeny_to_product_of_powers() 

 

H_simple = phi.codomain().Hom(psi.codomain()) 

im_gens = H_simple._calculate_product_gens() 

 

M = phi.matrix() 

Mt = psi.complementary_isogeny().matrix() 

 

R = ZZ**(4*self.domain().dimension()*self.codomain().dimension()) 

gens = R.submodule([ (M*self._get_matrix(g)*Mt).list() 

for g in im_gens ]).saturation().basis() 

self._gens = tuple([ self._get_matrix(g) for g in gens ]) 

 

def _calculate_product_gens(self): 

""" 

For internal use. 

 

Calculate generators for self, assuming that self is a product of 

simple factors. 

 

EXAMPLES:: 

 

sage: E = End(J0(37)) 

sage: E.gens() 

(Abelian variety endomorphism of Abelian variety J0(37) of dimension 2, 

Abelian variety endomorphism of Abelian variety J0(37) of dimension 2) 

sage: [ x.matrix() for x in E.gens() ] 

[ 

[1 0 0 0] [ 0 1 1 -1] 

[0 1 0 0] [ 1 0 1 0] 

[0 0 1 0] [ 0 0 -1 1] 

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

] 

sage: E._calculate_product_gens() 

[ 

[1 0 0 0] [0 0 0 0] 

[0 1 0 0] [0 0 0 0] 

[0 0 0 0] [0 0 1 0] 

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

] 

""" 

Afactors = self.domain().decomposition(simple=False) 

Bfactors = self.codomain().decomposition(simple=False) 

if len(Afactors) == 1 and len(Bfactors) == 1: 

Asimples = Afactors[0].decomposition() 

Bsimples = Bfactors[0].decomposition() 

if len(Asimples) == 1 and len(Bsimples) == 1: 

# Handle the base case of A, B simple 

gens = self._calculate_simple_gens() 

 

else: 

# Handle the case of A, B simple powers 

gens = [] 

phi_matrix = Afactors[0]._isogeny_to_product_of_simples().matrix() 

psi_t_matrix = Bfactors[0]._isogeny_to_product_of_simples().complementary_isogeny().matrix() 

for i in range(len(Asimples)): 

for j in range(len(Bsimples)): 

hom_gens = Asimples[i].Hom(Bsimples[j]).gens() 

for sub_gen in hom_gens: 

sub_mat = sub_gen.matrix() 

M = copy(self.matrix_space().zero_matrix()) 

M.set_block(sub_mat.nrows()*i, sub_mat.ncols()*j, sub_mat) 

gens.append(phi_matrix * M * psi_t_matrix) 

 

else: 

# Handle the case of A, B generic 

gens = [] 

cur_row = 0 

for Afactor in Afactors: 

cur_row += Afactor.dimension() * 2 

cur_col = 0 

for Bfactor in Bfactors: 

cur_col += Bfactor.dimension() * 2 

Asimple = Afactor[0] 

Bsimple = Bfactor[0] 

if Asimple.newform_label() == Bsimple.newform_label(): 

for sub_gen in Afactor.Hom(Bfactor).gens(): 

sub_mat = sub_gen.matrix() 

M = copy(self.matrix_space().zero_matrix()) 

M.set_block(cur_row - sub_mat.nrows(), 

cur_col - sub_mat.ncols(), 

sub_mat) 

gens.append(M) 

 

return gens 

 

def _calculate_simple_gens(self): 

""" 

Calculate generators for self, where both the domain and codomain 

for self are assumed to be simple abelian varieties. The saturation 

of the span of these generators in self will be the full space of 

homomorphisms from the domain of self to its codomain. 

 

EXAMPLES:: 

 

sage: H = Hom(J0(11), J0(22)[0]) 

sage: H._calculate_simple_gens() 

[ 

[1 0] 

[1 1] 

] 

sage: J = J0(11) * J0(33) ; J.decomposition() 

[ 

Simple abelian subvariety 11a(1,11) of dimension 1 of J0(11) x J0(33), 

Simple abelian subvariety 11a(1,33) of dimension 1 of J0(11) x J0(33), 

Simple abelian subvariety 11a(3,33) of dimension 1 of J0(11) x J0(33), 

Simple abelian subvariety 33a(1,33) of dimension 1 of J0(11) x J0(33) 

] 

sage: J[0].Hom(J[1])._calculate_simple_gens() 

[ 

[ 0 -1] 

[ 1 -1] 

] 

sage: J[0].Hom(J[2])._calculate_simple_gens() 

[ 

[-1 0] 

[-1 -1] 

] 

sage: J[0].Hom(J[0])._calculate_simple_gens() 

[ 

[1 0] 

[0 1] 

] 

sage: J[1].Hom(J[2])._calculate_simple_gens() 

[ 

[ 0 -4] 

[ 4 0] 

] 

 

:: 

 

sage: J = J0(23) ; J.decomposition() 

[ 

Simple abelian variety J0(23) of dimension 2 

] 

sage: J[0].Hom(J[0])._calculate_simple_gens() 

[ 

[1 0 0 0] [ 0 1 -1 0] 

[0 1 0 0] [ 0 1 -1 1] 

[0 0 1 0] [-1 2 -2 1] 

[0 0 0 1], [-1 1 0 -1] 

] 

sage: J.hecke_operator(2).matrix() 

[ 0 1 -1 0] 

[ 0 1 -1 1] 

[-1 2 -2 1] 

[-1 1 0 -1] 

 

:: 

 

sage: H = Hom(J0(11), J0(22)[0]) 

sage: H._calculate_simple_gens() 

[ 

[1 0] 

[1 1] 

] 

""" 

A = self.domain() 

B = self.codomain() 

 

if A.newform_label() != B.newform_label(): 

return [] 

 

f = A._isogeny_to_newform_abelian_variety() 

g = B._isogeny_to_newform_abelian_variety().complementary_isogeny() 

 

Af = f.codomain() 

ls = Af._calculate_endomorphism_generators() 

 

Mf = f.matrix() 

Mg = g.matrix() 

 

return [ Mf * self._get_matrix(e) * Mg for e in ls ] 

 

# NOTE/WARNING/TODO: Below in the __init__, etc. we do *not* check 

# that the input gens are give something that spans a sub*ring*, as apposed 

# to just a subgroup. 

class EndomorphismSubring(Homspace, Ring): 

 

def __init__(self, A, gens=None, category=None): 

""" 

A subring of the endomorphism ring. 

 

INPUT: 

 

 

- ``A`` - an abelian variety 

 

- ``gens`` - (default: None); optional; if given 

should be a tuple of the generators as matrices 

 

 

EXAMPLES:: 

 

sage: J0(23).endomorphism_ring() 

Endomorphism ring of Abelian variety J0(23) of dimension 2 

sage: sage.modular.abvar.homspace.EndomorphismSubring(J0(25)) 

Endomorphism ring of Abelian variety J0(25) of dimension 0 

sage: E = J0(11).endomorphism_ring() 

sage: type(E) 

<class 'sage.modular.abvar.homspace.EndomorphismSubring_with_category'> 

sage: E.homset_category() 

Category of modular abelian varieties over Rational Field 

sage: E.category() 

Category of endsets of modular abelian varieties over Rational Field 

sage: E in Rings() 

True 

sage: TestSuite(E).run(skip=["_test_prod"]) 

 

TESTS: 

 

The following tests against a problem on 32 bit machines that 

occured while working on :trac:`9944`:: 

 

sage: sage.modular.abvar.homspace.EndomorphismSubring(J1(12345)) 

Endomorphism ring of Abelian variety J1(12345) of dimension 5405473 

 

:trac:`16275` removed the custom ``__reduce__`` method, since 

:meth:`Homset.__reduce__` already implements appropriate 

unpickling by construction:: 

 

sage: E.__reduce__.__module__ 

'sage.categories.homset' 

sage: E.__reduce__() 

(<function Hom at ...>, 

(Abelian variety J0(11) of dimension 1, 

Abelian variety J0(11) of dimension 1, 

Category of modular abelian varieties over Rational Field, 

False)) 

""" 

self._J = A.ambient_variety() 

self._A = A 

 

# Initialise self with the correct category. 

# We need to initialise it as a ring first 

if category is None: 

homset_cat = A.category() 

else: 

homset_cat = category 

# Remark: Ring.__init__ will automatically form the join 

# of the category of rings and of homset_cat 

Ring.__init__(self, A.base_ring(), category=homset_cat.Endsets()) 

Homspace.__init__(self, A, A, cat=homset_cat) 

if gens is None: 

self._gens = None 

else: 

self._gens = tuple([ self._get_matrix(g) for g in gens ]) 

self._is_full_ring = gens is None 

 

def _repr_(self): 

""" 

Return the string representation of self. 

 

EXAMPLES:: 

 

sage: J0(31).endomorphism_ring()._repr_() 

'Endomorphism ring of Abelian variety J0(31) of dimension 2' 

sage: J0(31).endomorphism_ring().image_of_hecke_algebra()._repr_() 

'Subring of endomorphism ring of Abelian variety J0(31) of dimension 2' 

""" 

if self._is_full_ring: 

return "Endomorphism ring of %s" % self._A 

else: 

return "Subring of endomorphism ring of %s" % self._A 

 

def abelian_variety(self): 

""" 

Return the abelian variety that this endomorphism ring is attached 

to. 

 

EXAMPLES:: 

 

sage: J0(11).endomorphism_ring().abelian_variety() 

Abelian variety J0(11) of dimension 1 

""" 

return self._A 

 

def index_in(self, other, check=True): 

""" 

Return the index of self in other. 

 

INPUT: 

 

 

- ``other`` - another endomorphism subring of the 

same abelian variety 

 

- ``check`` - bool (default: True); whether to do some 

type and other consistency checks 

 

 

EXAMPLES:: 

 

sage: R = J0(33).endomorphism_ring() 

sage: R.index_in(R) 

1 

sage: J = J0(37) ; E = J.endomorphism_ring() ; T = E.image_of_hecke_algebra() 

sage: T.index_in(E) 

1 

sage: J = J0(22) ; E = J.endomorphism_ring() ; T = E.image_of_hecke_algebra() 

sage: T.index_in(E) 

+Infinity 

""" 

if check: 

if not isinstance(other, EndomorphismSubring): 

raise ValueError("other must be a subring of an endomorphism ring of an abelian variety.") 

if not (self.abelian_variety() == other.abelian_variety()): 

raise ValueError("self and other must be endomorphisms of the same abelian variety") 

 

M = self.free_module() 

N = other.free_module() 

if M.rank() < N.rank(): 

return sage.rings.all.Infinity 

return M.index_in(N) 

 

def index_in_saturation(self): 

""" 

Given a Hecke algebra T, compute its index in its saturation. 

 

EXAMPLES:: 

 

sage: End(J0(23)).image_of_hecke_algebra().index_in_saturation() 

1 

sage: End(J0(44)).image_of_hecke_algebra().index_in_saturation() 

2 

""" 

A = self.abelian_variety() 

d = A.dimension() 

M = ZZ**(4*d**2) 

gens = [ x.matrix().list() for x in self.gens() ] 

R = M.submodule(gens) 

return R.index_in_saturation() 

 

def discriminant(self): 

""" 

Return the discriminant of this ring, which is the discriminant of 

the trace pairing. 

 

.. note:: 

 

One knows that for modular abelian varieties, the 

endomorphism ring should be isomorphic to an order in a 

number field. However, the discriminant returned by this 

function will be `2^n` ( `n =` 

self.dimension()) times the discriminant of that order, 

since the elements are represented as 2d x 2d 

matrices. Notice, for example, that the case of a one 

dimensional abelian variety, whose endomorphism ring must 

be ZZ, has discriminant 2, as in the example below. 

 

EXAMPLES:: 

 

sage: J0(33).endomorphism_ring().discriminant() 

-64800 

sage: J0(46).endomorphism_ring().discriminant() # long time (6s on sage.math, 2011) 

24200000000 

sage: J0(11).endomorphism_ring().discriminant() 

2 

""" 

g = self.gens() 

M = Matrix(ZZ,len(g), [ (g[i]*g[j]).trace() 

for i in range(len(g)) for j in range(len(g)) ]) 

return M.determinant() 

 

def image_of_hecke_algebra(self, check_every=1): 

""" 

Compute the image of the Hecke algebra inside this endomorphism 

subring. 

 

We simply calculate Hecke operators up to the Sturm bound, and look 

at the submodule spanned by them. While computing, we can check to 

see if the submodule spanned so far is saturated and of maximal 

dimension, in which case we may be done. The optional argument 

check_every determines how many Hecke operators we add in before 

checking to see if this condition is met. 

 

INPUT: 

 

- ``check_every`` -- integer (default: 1) If this integer is positive, 

this integer determines how many Hecke operators we add in before 

checking to see if the submodule spanned so far is maximal and 

saturated. 

 

OUTPUT: 

 

- The image of the Hecke algebra as an subring of ``self``. 

 

EXAMPLES:: 

 

sage: E = J0(33).endomorphism_ring() 

sage: E.image_of_hecke_algebra() 

Subring of endomorphism ring of Abelian variety J0(33) of dimension 3 

sage: E.image_of_hecke_algebra().gens() 

(Abelian variety endomorphism of Abelian variety J0(33) of dimension 3, 

Abelian variety endomorphism of Abelian variety J0(33) of dimension 3, 

Abelian variety endomorphism of Abelian variety J0(33) of dimension 3) 

sage: [ x.matrix() for x in E.image_of_hecke_algebra().gens() ] 

[ 

[1 0 0 0 0 0] [ 0 2 0 -1 1 -1] [ 0 0 1 -1 1 -1] 

[0 1 0 0 0 0] [-1 -2 2 -1 2 -1] [ 0 -1 1 0 1 -1] 

[0 0 1 0 0 0] [ 0 0 1 -1 3 -1] [ 0 0 1 0 2 -2] 

[0 0 0 1 0 0] [-2 2 0 1 1 -1] [-2 0 1 1 1 -1] 

[0 0 0 0 1 0] [-1 1 0 2 0 -3] [-1 0 1 1 0 -1] 

[0 0 0 0 0 1], [-1 1 -1 1 1 -2], [-1 0 0 1 0 -1] 

] 

sage: J0(33).hecke_operator(2).matrix() 

[-1 0 1 -1 1 -1] 

[ 0 -2 1 0 1 -1] 

[ 0 0 0 0 2 -2] 

[-2 0 1 0 1 -1] 

[-1 0 1 1 -1 -1] 

[-1 0 0 1 0 -2] 

""" 

try: 

return self.__hecke_algebra_image 

except AttributeError: 

pass 

 

A = self.abelian_variety() 

if not A.is_hecke_stable(): 

raise ValueError("ambient variety is not Hecke stable") 

 

M = A.modular_symbols() 

 

d = A.dimension() 

EndVecZ = ZZ**(4*d**2) 

 

if d == 1: 

self.__hecke_algebra_image = EndomorphismSubring(A, [[1,0,0,1]]) 

return self.__hecke_algebra_image 

 

V = EndVecZ.submodule([A.hecke_operator(1).matrix().list()]) 

 

for n in range(2,M.sturm_bound()+1): 

if (check_every > 0 and 

n % check_every == 0 and 

V.dimension() == d and 

V.index_in_saturation() == 1): 

break 

V += EndVecZ.submodule([ A.hecke_operator(n).matrix().list() ]) 

 

self.__hecke_algebra_image = EndomorphismSubring(A, V.basis()) 

return self.__hecke_algebra_image