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

from __future__ import absolute_import 

  

from cysignals.memory cimport sig_malloc, sig_free 

from cysignals.signals cimport sig_on, sig_off 

  

from sage.libs.gmp.mpz cimport mpz_init, mpz_clear, mpz_pow_ui 

from sage.libs.flint.padic cimport * 

from sage.libs.flint.fmpz_poly cimport * 

from sage.libs.flint.nmod_vec cimport * 

from sage.libs.flint.fmpz_vec cimport * 

from sage.libs.flint.fmpz cimport fmpz_init, fmpz_one, fmpz_mul, fmpz_set, fmpz_get_mpz, fmpz_clear, fmpz_pow_ui, fmpz_set_mpz, fmpz_fdiv_q_2exp 

  

from cpython.object cimport Py_EQ, Py_NE 

from sage.structure.richcmp cimport richcmp_not_equal 

from sage.rings.integer cimport Integer 

from sage.rings.all import ZZ 

from sage.rings.polynomial.polynomial_integer_dense_flint cimport Polynomial_integer_dense_flint 

  

  

cdef class PowComputer_flint(PowComputer_class): 

""" 

A PowComputer for use in `p`-adics implemented via FLINT. 

  

For a description of inputs see :func:`PowComputer_flint_maker`. 

  

EXAMPLES:: 

  

sage: from sage.rings.padics.pow_computer_flint import PowComputer_flint 

sage: PowComputer_flint(5, 20, 20, 20, False) 

FLINT PowComputer for 5 

""" 

def __cinit__(self, Integer prime, long cache_limit, long prec_cap, long ram_prec_cap, bint in_field, poly=None, shift_seed = None): 

""" 

Memory initialization. 

  

TESTS:: 

  

sage: from sage.rings.padics.pow_computer_flint import PowComputer_flint 

sage: type(PowComputer_flint(5, 20, 20, 20, False)) 

<type 'sage.rings.padics.pow_computer_flint.PowComputer_flint'> 

  

""" 

# fmpz_init does not allocate memory 

fmpz_init(self.fprime) 

fmpz_init(self.half_prime) 

fmpz_set_mpz(self.fprime, prime.value) 

fmpz_init(self._fpow_variable) 

fmpz_fdiv_q_2exp(self.half_prime, self.fprime, 1) 

fmpz_init(self.tfmpz) 

  

sig_on() 

try: 

mpz_init(self.top_power) 

padic_ctx_init(self.ctx, self.fprime, 0, prec_cap, PADIC_SERIES) 

finally: 

sig_off() 

  

self.__allocated = 4 

  

def __init__(self, Integer prime, long cache_limit, long prec_cap, long ram_prec_cap, bint in_field, poly=None, shift_seed=None): 

""" 

Initialization. 

  

TESTS:: 

  

sage: from sage.rings.padics.pow_computer_flint import PowComputer_flint_maker 

sage: R.<x> = ZZ[]; f = x^3 - 8*x - 2 

sage: A = PowComputer_flint_maker(5, 20, 20, 20, False, f, 'capped-rel') # indirect doctest 

sage: TestSuite(A).run() 

  

""" 

PowComputer_class.__init__(self, prime, cache_limit, prec_cap, ram_prec_cap, in_field, poly, shift_seed) 

  

mpz_pow_ui(self.top_power, prime.value, prec_cap) 

  

def __dealloc__(self): 

""" 

Deallocation. 

  

TESTS:: 

  

sage: from sage.rings.padics.pow_computer_flint import PowComputer_flint 

sage: A = PowComputer_flint(5, 20, 20, 20, False) 

sage: del A 

""" 

if self.__allocated >= 4: 

fmpz_clear(self.fprime) 

fmpz_clear(self.half_prime) 

fmpz_clear(self._fpow_variable) 

fmpz_clear(self.tfmpz) 

mpz_clear(self.top_power) 

padic_ctx_clear(self.ctx) 

  

def __reduce__(self): 

""" 

Pickling. 

  

TESTS:: 

  

sage: from sage.rings.padics.pow_computer_flint import PowComputer_flint_maker 

sage: R.<x> = ZZ[]; f = x^3 - 8*x - 2 

sage: A = PowComputer_flint_maker(5, 20, 20, 20, False, f, 'capped-rel') # indirect doctest 

sage: A._test_pickling() # indirect doctest 

  

""" 

return PowComputer_flint_maker, (self.prime, self.cache_limit, self.prec_cap, self.ram_prec_cap, self.in_field, self.polynomial(), self._prec_type) 

  

def _repr_(self): 

""" 

String representation of this powcomputer. 

  

EXAMPLES:: 

  

sage: from sage.rings.padics.pow_computer_flint import PowComputer_flint 

sage: A = PowComputer_flint(5, 20, 20, 20, False); A 

FLINT PowComputer for 5 

""" 

return "FLINT PowComputer for %s" % self.prime 

  

cdef fmpz_t* pow_fmpz_t_tmp(self, unsigned long n) except NULL: 

""" 

Returns a pointer to a FLINT ``fmpz_t`` holding `p^n`. 

  

Analogous to 

:meth:`sage.rings.padics.pow_computer.PowComputer_class.pow_mpz_t_tmp` 

but with FLINT ``fmpz_t`` rather than GMP ``mpz_t``. The same 

important warnings apply. 

""" 

cdef padic_ctx_struct ctx = (<padic_ctx_struct*>self.ctx)[0] 

if ctx.min <= n and n < ctx.max: 

self._fpow_array[0] = (ctx.pow + (n - ctx.min))[0] 

return &self._fpow_array 

else: 

fmpz_pow_ui(self._fpow_variable, self.fprime, n) 

return &self._fpow_variable 

  

cdef mpz_srcptr pow_mpz_t_tmp(self, long n) except NULL: 

""" 

Returns a pointer to an ``mpz_t`` holding `p^n`. 

  

See 

:meth:`sage.rings.padics.pow_computer.PowComputer_class.pow_mpz_t_tmp` 

for important warnings. 

""" 

fmpz_get_mpz(self.temp_m, self.pow_fmpz_t_tmp(n)[0]) 

return self.temp_m 

  

cdef mpz_srcptr pow_mpz_t_top(self): 

""" 

Returns a pointer to an ``mpz_t`` holding `p^N`, where `N` is 

the precision cap. 

""" 

return self.top_power 

  

cdef unsigned long capdiv(self, unsigned long n): 

""" 

Returns ceil(n / e). 

""" 

if self.e == 1: return n 

if n == 0: return 0 

return (n-1) / self.e + 1 

  

def polynomial(self, n=None, var='x'): 

""" 

Returns ``None``. 

  

For consistency with subclasses. 

  

EXAMPLES:: 

  

sage: from sage.rings.padics.pow_computer_flint import PowComputer_flint 

sage: A = PowComputer_flint(5, 20, 20, 20, False, None) 

sage: A.polynomial() is None 

True 

  

""" 

return None 

  

cdef class PowComputer_flint_1step(PowComputer_flint): 

""" 

A PowComputer for a `p`-adic extension defined by a single polynomial. 

  

For a description of inputs see :func:`PowComputer_flint_maker`. 

  

EXAMPLES:: 

  

sage: from sage.rings.padics.pow_computer_flint import PowComputer_flint_1step 

sage: R.<x> = ZZ[]; f = x^3 - 8*x - 2 

sage: A = PowComputer_flint_1step(5, 20, 20, 20, False, f); A 

FLINT PowComputer for 5 with polynomial x^3 - 8*x - 2 

  

""" 

def __cinit__(self, Integer prime, long cache_limit, long prec_cap, long ram_prec_cap, bint in_field, _poly): 

""" 

Memory initialization. 

  

TESTS:: 

  

sage: from sage.rings.padics.pow_computer_flint import PowComputer_flint_1step 

sage: R.<x> = ZZ[]; f = x^3 - 8*x - 2 

sage: A = PowComputer_flint_1step(5, 20, 20, 20, False, f) 

sage: type(A) 

<type 'sage.rings.padics.pow_computer_flint.PowComputer_flint_1step'> 

  

""" 

cdef Polynomial_integer_dense_flint poly = _poly 

cdef long length = fmpz_poly_length(poly.__poly) 

  

cdef Py_ssize_t i 

  

# fmpz_init does not allocate memory 

fmpz_init(self.q) 

  

sig_on() 

try: 

self._moduli = <fmpz_poly_t*>sig_malloc(sizeof(fmpz_poly_t) * (cache_limit + 2)) 

if self._moduli == NULL: 

raise MemoryError 

try: 

fmpz_poly_init2(self.modulus, length) 

try: 

for i in range(1,cache_limit+2): 

try: 

fmpz_poly_init2(self._moduli[i], length) 

except BaseException: 

i-=1 

while i: 

fmpz_poly_clear(self._moduli[i]) 

i-=1 

raise 

except BaseException: 

fmpz_poly_clear(self.modulus) 

raise 

except BaseException: 

sig_free(self._moduli) 

raise 

finally: 

sig_off() 

  

self.__allocated = 8 

  

def __init__(self, Integer prime, long cache_limit, long prec_cap, long ram_prec_cap, bint in_field, _poly, shift_seed=None): 

""" 

Initialization. 

  

TESTS:: 

  

sage: from sage.rings.padics.pow_computer_flint import PowComputer_flint_maker 

sage: R.<x> = ZZ[]; f = x^3 - 8*x - 2 

sage: A = PowComputer_flint_maker(5, 20, 20, 20, False, f, 'capped-rel') 

sage: TestSuite(A).run() 

  

""" 

PowComputer_flint.__init__(self, prime, cache_limit, prec_cap, ram_prec_cap, in_field, _poly, shift_seed) 

  

cdef Polynomial_integer_dense_flint poly = _poly 

cdef long length = fmpz_poly_length(poly.__poly) 

self.deg = length - 1 

  

fmpz_poly_set(self.modulus, poly.__poly) 

  

cdef Py_ssize_t i 

cdef fmpz* coeffs = self.modulus.coeffs 

fmpz_one(self.tfmpz) 

for i in range(1,cache_limit+1): 

fmpz_mul(self.tfmpz, self.tfmpz, self.fprime) 

_fmpz_vec_scalar_mod_fmpz((<fmpz_poly_struct*>self._moduli[i])[0].coeffs, coeffs, length, self.tfmpz) 

_fmpz_poly_set_length(self._moduli[i], length) 

  

_fmpz_poly_set_length(self._moduli[cache_limit+1], length) 

  

def __dealloc__(self): 

""" 

Deallocation. 

  

TESTS:: 

  

sage: from sage.rings.padics.pow_computer_flint import PowComputer_flint_1step 

sage: R.<x> = ZZ[]; f = x^3 - 8*x - 2 

sage: A = PowComputer_flint_1step(5, 20, 20, 20, False, f) 

sage: del A 

""" 

cdef Py_ssize_t i 

  

if self.__allocated >= 8: 

fmpz_clear(self.q) 

fmpz_poly_clear(self.modulus) 

for i in range(1, self.cache_limit + 1): 

fmpz_poly_clear(self._moduli[i]) 

sig_free(self._moduli) 

  

def _repr_(self): 

""" 

String representation of this powcomputer. 

  

EXAMPLES:: 

  

sage: from sage.rings.padics.pow_computer_flint import PowComputer_flint_1step 

sage: R.<x> = ZZ[]; f = x^3 - 8*x - 2 

sage: A = PowComputer_flint_1step(5, 20, 20, 20, False, f); A 

FLINT PowComputer for 5 with polynomial x^3 - 8*x - 2 

""" 

return "FLINT PowComputer for %s with polynomial %s" % (self.prime, self.polynomial()) 

  

def __richcmp__(self, other, int op): 

""" 

Comparison. 

  

Lexicographic on class, prime, precision cap, cache_limit and polynomial. 

  

EXAMPLES:: 

  

sage: from sage.rings.padics.pow_computer_flint import PowComputer_flint_1step 

sage: R.<x> = ZZ[]; f = x^3 - 8*x - 2; g = x^3 - (8 + 5^22)*x - 2 

sage: A = PowComputer_flint_1step(5, 20, 20, 20, False, f) 

sage: B = PowComputer_flint_1step(5, 20, 20, 20, False, g) 

sage: A == B 

False 

""" 

if not isinstance(other, PowComputer_flint_1step): 

if op in [Py_EQ, Py_NE]: 

return (op == Py_NE) 

return NotImplemented 

  

cdef PowComputer_flint_1step s = self 

cdef PowComputer_flint_1step o = other 

  

lx = s.prime 

rx = o.prime 

if lx != rx: 

return richcmp_not_equal(lx, rx, op) 

  

lx = s.prec_cap 

rx = o.prec_cap 

if lx != rx: 

return richcmp_not_equal(lx, rx, op) 

  

lx = s.cache_limit 

rx = o.cache_limit 

if lx != rx: 

return richcmp_not_equal(lx, rx, op) 

  

lx = s.in_field 

rx = o.in_field 

if lx != rx: 

return richcmp_not_equal(lx, rx, op) 

  

if fmpz_poly_equal(s.modulus, o.modulus): 

return (op == Py_EQ) 

if op != Py_NE: 

return NotImplemented 

# return cmp(self.polynomial(), other.polynomial()) 

return False 

  

cdef fmpz_poly_t* get_modulus(self, unsigned long k): 

""" 

Returns the defining polynomial reduced modulo `p^k`. 

  

The same warnings apply as for 

:meth:`sage.rings.padics.pow_computer.PowComputer_class.pow_mpz_t_tmp`. 

""" 

cdef long c 

if k <= self.cache_limit: 

return &(self._moduli[k]) 

else: 

c = self.cache_limit+1 

_fmpz_vec_scalar_mod_fmpz((<fmpz_poly_struct*>self._moduli[c])[0].coeffs, 

(<fmpz_poly_struct*>self.modulus)[0].coeffs, 

self.deg + 1, 

self.pow_fmpz_t_tmp(k)[0]) 

return &(self._moduli[c]) 

  

cdef fmpz_poly_t* get_modulus_capdiv(self, unsigned long k): 

""" 

Returns the defining polynomial reduced modulo `p^a`, where 

`a` is the ceiling of `k/e`. 

  

The same warnings apply as for 

:meth:`sage.rings.padics.pow_computer.PowComputer_class.pow_mpz_t_tmp`. 

""" 

return self.get_modulus(self.capdiv(k)) 

  

def polynomial(self, _n=None, var='x'): 

""" 

Returns the polynomial attached to this ``PowComputer``, possibly reduced modulo a power of `p`. 

  

INPUT: 

  

- ``_n`` -- (default ``None``) an integer, the power of `p` 

modulo which to reduce. 

  

- ``var`` -- (default ``'x'``) the variable for the returned polynomial 

  

.. NOTE:: 

  

From Cython you should use :meth:`get_modulus` instead for 

speed. 

  

EXAMPLES:: 

  

sage: from sage.rings.padics.pow_computer_flint import PowComputer_flint_1step 

sage: R.<y> = ZZ[]; f = y^3 - 8*y - 2 

sage: A = PowComputer_flint_1step(5, 20, 20, 20, False, f) 

sage: A.polynomial() 

x^3 - 8*x - 2 

sage: A.polynomial(var='y') 

y^3 - 8*y - 2 

sage: A.polynomial(2) 

x^3 + 17*x + 23 

""" 

R = ZZ[var] 

x = R.gen() 

cdef Polynomial_integer_dense_flint ans = (<Polynomial_integer_dense_flint?>x)._new() 

if _n is None: 

fmpz_poly_set(ans.__poly, self.modulus) 

else: 

fmpz_poly_set(ans.__poly, self.get_modulus(_n)[0]) 

return ans 

  

cdef _new_fmpz_poly(self, fmpz_poly_t value, var='x'): 

""" 

Returns a polynomial with the value stored in ``value`` and 

variable name ``var``. 

""" 

R = ZZ[var] 

x = R.gen() 

cdef Polynomial_integer_dense_flint ans = (<Polynomial_integer_dense_flint?>x)._new() 

fmpz_poly_set(ans.__poly, value) 

return ans 

  

cdef class PowComputer_flint_unram(PowComputer_flint_1step): 

""" 

A PowComputer for a `p`-adic extension defined by an unramified polynomial. 

  

For a description of inputs see :func:`PowComputer_flint_maker`. 

  

EXAMPLES:: 

  

sage: from sage.rings.padics.pow_computer_flint import PowComputer_flint_unram 

sage: R.<x> = ZZ[]; f = x^3 - 8*x - 2 

sage: A = PowComputer_flint_unram(5, 20, 20, 20, False, f); A 

FLINT PowComputer for 5 with polynomial x^3 - 8*x - 2 

  

""" 

def __cinit__(self, Integer prime, long cache_limit, long prec_cap, long ram_prec_cap, bint in_field, _poly, shift_seed=None): 

""" 

Memory initialization. 

  

TESTS:: 

  

sage: from sage.rings.padics.pow_computer_flint import PowComputer_flint_unram 

sage: R.<x> = ZZ[]; f = x^3 - 8*x - 2 

sage: A = PowComputer_flint_unram(5, 20, 20, 20, False, f) 

sage: type(A) 

<type 'sage.rings.padics.pow_computer_flint.PowComputer_flint_unram'> 

  

""" 

# fmpz_init does not allocate memory 

fmpz_init(self.fmpz_ccmp) 

fmpz_init(self.fmpz_cval) 

fmpz_init(self.fmpz_cinv) 

fmpz_init(self.fmpz_cinv2) 

fmpz_init(self.fmpz_cexp) 

fmpz_init(self.fmpz_ctm) 

fmpz_init(self.fmpz_cconv) 

  

# While the following allocations have the potential to leak 

# small amounts of memory when interrupted or when one of the 

# init methods raises a MemoryError, the only leak-free 

# solution we could devise used 11-nested try blocks. We 

# choose readable code in this case. 

sig_on() 

fmpz_poly_init(self.poly_cconv) 

fmpz_poly_init(self.poly_ctm) 

fmpz_poly_init(self.poly_ccmp) 

fmpz_poly_init(self.poly_cinv) 

fmpz_poly_init(self.poly_cisunit) 

fmpz_poly_init(self.poly_cinv2) 

fmpz_poly_init(self.poly_flint_rep) 

fmpz_poly_init(self.poly_matmod) 

mpz_init(self.mpz_cpow) 

mpz_init(self.mpz_ctm) 

mpz_init(self.mpz_cconv) 

mpz_init(self.mpz_matmod) 

sig_off() 

  

self.__allocated = 16 

  

def __dealloc__(self): 

""" 

Deallocation. 

  

TESTS:: 

  

sage: from sage.rings.padics.pow_computer_flint import PowComputer_flint_unram 

sage: R.<x> = ZZ[]; f = x^3 - 8*x - 2 

sage: A = PowComputer_flint_unram(5, 20, 20, 20, False, f) 

sage: del A 

  

""" 

if self.__allocated >= 16: 

fmpz_clear(self.fmpz_ccmp) 

fmpz_clear(self.fmpz_cval) 

fmpz_clear(self.fmpz_cinv) 

fmpz_clear(self.fmpz_cinv2) 

fmpz_clear(self.fmpz_cexp) 

fmpz_clear(self.fmpz_ctm) 

fmpz_clear(self.fmpz_cconv) 

mpz_clear(self.mpz_cconv) 

mpz_clear(self.mpz_ctm) 

mpz_clear(self.mpz_cpow) 

mpz_clear(self.mpz_matmod) 

fmpz_poly_clear(self.poly_cconv) 

fmpz_poly_clear(self.poly_ctm) 

fmpz_poly_clear(self.poly_ccmp) 

fmpz_poly_clear(self.poly_cinv) 

fmpz_poly_clear(self.poly_cisunit) 

fmpz_poly_clear(self.poly_cinv2) 

fmpz_poly_clear(self.poly_flint_rep) 

fmpz_poly_clear(self.poly_matmod) 

  

def __init__(self, Integer prime, long cache_limit, long prec_cap, long ram_prec_cap, bint in_field, poly=None): 

""" 

Initialization. 

  

TESTS:: 

  

sage: from sage.rings.padics.pow_computer_flint import PowComputer_flint_maker 

sage: R.<x> = ZZ[]; f = x^3 - 8*x - 2 

sage: A = PowComputer_flint_maker(5, 20, 20, 20, False, f, 'capped-rel') 

sage: TestSuite(A).run() 

  

""" 

PowComputer_flint_1step.__init__(self, prime, cache_limit, prec_cap, ram_prec_cap, in_field, poly) 

  

self.e = 1 

self.f = fmpz_poly_degree(self.modulus) 

fmpz_pow_ui(self.q, self.fprime, self.f) 

  

cdef class PowComputer_flint_eis(PowComputer_flint_1step): 

""" 

A PowComputer for a `p`-adic extension defined by an Eisenstein polynomial. 

  

For a description of inputs see :func:`PowComputer_flint_maker`. 

  

EXAMPLES:: 

  

sage: from sage.rings.padics.pow_computer_flint import PowComputer_flint_eis 

sage: R.<x> = ZZ[]; f = x^3 - 25*x + 5 

sage: A = PowComputer_flint_eis(5, 20, 20, 60, False, f); A 

FLINT PowComputer for 5 with polynomial x^3 - 25*x + 5 

""" 

def __init__(self, Integer prime, long cache_limit, long prec_cap, long ram_prec_cap, bint in_field, poly=None): 

""" 

Initialization. 

  

TESTS:: 

  

sage: from sage.rings.padics.pow_computer_flint import PowComputer_flint_eis 

sage: R.<x> = ZZ[]; f = x^3 - 25*x + 5 

sage: A = PowComputer_flint_eis(5, 20, 20, 60, False, f) 

sage: type(A) 

<type 'sage.rings.padics.pow_computer_flint.PowComputer_flint_eis'> 

  

""" 

PowComputer_flint_1step.__init__(self, prime, cache_limit, prec_cap, ram_prec_cap, in_field, poly) 

  

self.e = fmpz_poly_degree(self.modulus) 

self.f = 1 

fmpz_set(self.q, self.fprime) 

  

def PowComputer_flint_maker(prime, cache_limit, prec_cap, ram_prec_cap, in_field, poly, prec_type): 

""" 

Return an appropriate FLINT PowComputer for the given input. 

  

INPUT: 

  

- ``prime`` -- an integral prime 

  

- ``cache_limit`` -- a non-negative integer, controlling the 

caching. Powers of ``prime``, reductions of ``poly`` modulo 

different powers of ``prime`` and inverses of the leading 

coefficient modulo different powers of ``prime`` are cached. 

Additional data is cached for ramified extensions. 

  

- ``prec_cap`` -- the power of `p` modulo which elements of 

largest precision are defined. 

  

- ``ram_prec_cap`` -- Approximately ``e*prec_cap``, where ``e`` is 

the ramification degree of the extension. For a ramified 

extension this is what Sage calls the precision cap of the ring. 

In fact, it's possible to have rings with precision cap not a 

multiple of `e`, in which case the actual relationship between 

``ram_prec_cap`` and ``prec_cap`` is that 

``prec_cap = ceil(n/e)`` 

  

- ``in_field`` -- (boolean) whether the associated ring is 

actually a field. 

  

- ``poly`` -- the polynomial defining the extension. 

  

- `prec_type`` -- one of ``"capped-rel"``, ``"capped-abs"`` or 

``"fixed-mod"``, the precision type of the ring. 

  

.. NOTE:: 

  

Because of the way templates work, this function imports the 

class of its return value from the appropriate element files. 

This means that the returned PowComputer will have the 

appropriate compile-time-type for Cython. 

  

EXAMPLES:: 

  

sage: from sage.rings.padics.pow_computer_flint import PowComputer_flint_maker 

sage: R.<x> = ZZ[] 

sage: A = PowComputer_flint_maker(3, 20, 20, 20, False, x^3 + 2*x + 1, 'capped-rel'); type(A) 

<type 'sage.rings.padics.qadic_flint_CR.PowComputer_'> 

sage: A = PowComputer_flint_maker(3, 20, 20, 20, False, x^3 + 2*x + 1, 'capped-abs'); type(A) 

<type 'sage.rings.padics.qadic_flint_CA.PowComputer_'> 

sage: A = PowComputer_flint_maker(3, 20, 20, 20, False, x^3 + 2*x + 1, 'fixed-mod'); type(A) 

<type 'sage.rings.padics.qadic_flint_FM.PowComputer_'> 

  

""" 

if prec_type == 'capped-rel': 

from .qadic_flint_CR import PowComputer_ 

elif prec_type == 'capped-abs': 

from .qadic_flint_CA import PowComputer_ 

elif prec_type == 'fixed-mod': 

from .qadic_flint_FM import PowComputer_ 

elif prec_type == 'floating-point': 

from .qadic_flint_FP import PowComputer_ 

else: 

raise ValueError("unknown prec_type `%s`" % prec_type) 

return PowComputer_(prime, cache_limit, prec_cap, ram_prec_cap, in_field, poly)