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

""" 

Generic dual bases symmetric functions 

""" 

from __future__ import absolute_import 

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

# Copyright (C) 2007 Mike Hansen <mhansen@gmail.com> 

# 2012 Mike Zabrocki <mike.zabrocki@gmail.com> 

# 

# Distributed under the terms of the GNU General Public License (GPL) 

# 

# This code is distributed in the hope that it will be useful, 

# but WITHOUT ANY WARRANTY; without even the implied warranty of 

# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 

# General Public License for more details. 

# 

# The full text of the GPL is available at: 

# 

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

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

from sage.categories.morphism import SetMorphism 

from sage.categories.homset import Hom 

from sage.matrix.all import matrix 

import sage.combinat.partition 

import sage.data_structures.blas_dict as blas 

from . import classical 

 

class SymmetricFunctionAlgebra_dual(classical.SymmetricFunctionAlgebra_classical): 

def __init__(self, dual_basis, scalar, scalar_name="", basis_name=None, prefix=None): 

r""" 

Generic dual basis of a basis of symmetric functions. 

 

INPUT: 

 

- ``dual_basis`` -- a basis of the ring of symmetric functions 

 

- ``scalar`` -- A function `z` on partitions which determines the 

scalar product on the power sum basis by 

`\langle p_{\mu}, p_{\mu} \rangle = z(\mu)`. (Independently on the 

function chosen, the power sum basis will always be orthogonal; the 

function ``scalar`` only determines the norms of the basis elements.) 

This defaults to the function ``zee`` defined in 

``sage.combinat.sf.sfa``, that is, the function is defined by: 

 

.. MATH:: 

 

\lambda \mapsto \prod_{i = 1}^\infty m_i(\lambda)! 

i^{m_i(\lambda)}`, 

 

where `m_i(\lambda)` means the number of times `i` appears in 

`\lambda`. This default function gives the standard Hall scalar 

product on the ring of symmetric functions. 

 

- ``scalar_name`` -- (default: the empty string) a string giving a 

description of the scalar product specified by the parameter 

``scalar`` 

 

- ``basis_name`` -- (optional) a string to serve as name for the basis 

to be generated (such as "forgotten" in "the forgotten basis"); don't 

set it to any of the already existing basis names (such as 

``homogeneous``, ``monomial``, ``forgotten``, etc.). 

 

- ``prefix`` -- (default: ``'d'`` and the prefix for ``dual_basis``) 

a string to use as the symbol for the basis 

 

OUTPUT: 

 

The basis of the ring of symmetric functions dual to the basis 

``dual_basis`` with respect to the scalar product determined 

by ``scalar``. 

 

EXAMPLES:: 

 

sage: e = SymmetricFunctions(QQ).e() 

sage: f = e.dual_basis(prefix = "m", basis_name="Forgotten symmetric functions"); f 

Symmetric Functions over Rational Field in the Forgotten symmetric functions basis 

sage: TestSuite(f).run(elements = [f[1,1]+2*f[2], f[1]+3*f[1,1]]) 

sage: TestSuite(f).run() # long time (11s on sage.math, 2011) 

 

This class defines canonical coercions between ``self`` and 

``self^*``, as follow: 

 

Lookup for the canonical isomorphism from ``self`` to `P` 

(=powersum), and build the adjoint isomorphism from `P^*` to 

``self^*``. Since `P` is self-adjoint for this scalar product, 

derive an isomorphism from `P` to ``self^*``, and by composition 

with the above get an isomorphism from ``self`` to ``self^*`` (and 

similarly for the isomorphism ``self^*`` to ``self``). 

 

This should be striped down to just (auto?) defining canonical 

isomorphism by adjunction (as in MuPAD-Combinat), and let 

the coercion handle the rest. 

 

Inversions may not be possible if the base ring is not a field:: 

 

sage: m = SymmetricFunctions(ZZ).m() 

sage: h = m.dual_basis(lambda x: 1) 

sage: h[2,1] 

Traceback (most recent call last): 

... 

TypeError: no conversion of this rational to integer 

 

By transitivity, this defines indirect coercions to and from all other bases:: 

 

sage: s = SymmetricFunctions(QQ['t'].fraction_field()).s() 

sage: t = QQ['t'].fraction_field().gen() 

sage: zee_hl = lambda x: x.centralizer_size(t=t) 

sage: S = s.dual_basis(zee_hl) 

sage: S(s([2,1])) 

(-t/(t^5-2*t^4+t^3-t^2+2*t-1))*d_s[1, 1, 1] + ((-t^2-1)/(t^5-2*t^4+t^3-t^2+2*t-1))*d_s[2, 1] + (-t/(t^5-2*t^4+t^3-t^2+2*t-1))*d_s[3] 

 

TESTS: 

 

Regression test for :trac:`12489`. This ticket improving 

equality test revealed that the conversion back from the dual 

basis did not strip cancelled terms from the dictionary:: 

 

sage: y = e[1, 1, 1, 1] - 2*e[2, 1, 1] + e[2, 2] 

sage: sorted(f.element_class(f, dual = y)) 

[([1, 1, 1, 1], 6), ([2, 1, 1], 2), ([2, 2], 1)] 

 

""" 

self._dual_basis = dual_basis 

self._scalar = scalar 

self._scalar_name = scalar_name 

 

# Set up the cache 

 

# cache for the coordinates of the elements 

# of ``dual_basis`` with respect to ``self`` 

self._to_self_cache = {} 

# cache for the coordinates of the elements 

# of ``self`` with respect to ``dual_basis`` 

self._from_self_cache = {} 

# cache for transition matrices which contain the coordinates of 

# the elements of ``dual_basis`` with respect to ``self`` 

self._transition_matrices = {} 

# cache for transition matrices which contain the coordinates of 

# the elements of ``self`` with respect to ``dual_basis`` 

self._inverse_transition_matrices = {} 

 

scalar_target = scalar(sage.combinat.partition.Partition([1])).parent() 

scalar_target = (scalar_target.one()*dual_basis.base_ring().one()).parent() 

 

self._sym = sage.combinat.sf.sf.SymmetricFunctions(scalar_target) 

self._p = self._sym.power() 

 

if prefix is None: 

prefix = 'd_'+dual_basis.prefix() 

 

classical.SymmetricFunctionAlgebra_classical.__init__(self, self._sym, 

basis_name = basis_name, 

prefix = prefix) 

 

# temporary until Hom(GradedHopfAlgebrasWithBasis work better) 

category = sage.categories.all.ModulesWithBasis(self.base_ring()) 

self .register_coercion(SetMorphism(Hom(self._dual_basis, self, category), self._dual_to_self)) 

self._dual_basis.register_coercion(SetMorphism(Hom(self, self._dual_basis, category), self._self_to_dual)) 

 

 

def _dual_to_self(self, x): 

""" 

Coerce an element of the dual of ``self`` canonically into ``self``. 

 

INPUT: 

 

- ``x`` -- an element in the dual basis of ``self`` 

 

OUTPUT: 

 

- returns ``x`` expressed in the basis ``self`` 

 

EXAMPLES:: 

 

sage: m = SymmetricFunctions(QQ).monomial() 

sage: zee = sage.combinat.sf.sfa.zee 

sage: h = m.dual_basis(scalar=zee) 

sage: h._dual_to_self(m([2,1]) + 3*m[1,1,1]) 

d_m[1, 1, 1] - d_m[2, 1] 

sage: hh = m.realization_of().h() 

sage: h._dual_to_self(m(hh([2,2,2]))) 

d_m[2, 2, 2] 

 

:: Note that the result is not correct if ``x`` is not an element of the 

dual basis of ``self`` 

 

sage: h._dual_to_self(m([2,1])) 

-2*d_m[1, 1, 1] + 5*d_m[2, 1] - 3*d_m[3] 

sage: h._dual_to_self(hh([2,1])) 

-2*d_m[1, 1, 1] + 5*d_m[2, 1] - 3*d_m[3] 

 

This is for internal use only. Please use instead:: 

 

sage: h(m([2,1]) + 3*m[1,1,1]) 

d_m[1, 1, 1] - d_m[2, 1] 

""" 

return self._element_class(self, dual = x) 

 

def _self_to_dual(self, x): 

""" 

Coerce an element of ``self`` canonically into the dual. 

 

INPUT: 

 

- ``x`` -- an element of ``self`` 

 

OUTPUT: 

 

- returns ``x`` expressed in the dual basis 

 

EXAMPLES:: 

 

sage: m = SymmetricFunctions(QQ).monomial() 

sage: zee = sage.combinat.sf.sfa.zee 

sage: h = m.dual_basis(scalar=zee) 

sage: h._self_to_dual(h([2,1]) + 3*h[1,1,1]) 

21*m[1, 1, 1] + 11*m[2, 1] + 4*m[3] 

 

This is for internal use only. Please use instead: 

 

sage: m(h([2,1]) + 3*h[1,1,1]) 

21*m[1, 1, 1] + 11*m[2, 1] + 4*m[3] 

 

or:: 

 

sage: (h([2,1]) + 3*h[1,1,1]).dual() 

21*m[1, 1, 1] + 11*m[2, 1] + 4*m[3] 

""" 

return x.dual() 

 

def _dual_basis_default(self): 

""" 

Returns the default value for ``self.dual_basis()`` 

 

This returns the basis ``self`` has been built from by 

duality. 

 

.. WARNING:: 

 

This is not necessarily the dual basis for the standard 

(Hall) scalar product! 

 

EXAMPLES:: 

 

sage: m = SymmetricFunctions(QQ).monomial() 

sage: zee = sage.combinat.sf.sfa.zee 

sage: h = m.dual_basis(scalar=zee) 

sage: h.dual_basis() 

Symmetric Functions over Rational Field in the monomial basis 

sage: m2 = h.dual_basis(zee, prefix='m2') 

sage: m([2])^2 

2*m[2, 2] + m[4] 

sage: m2([2])^2 

2*m2[2, 2] + m2[4] 

 

TESTS:: 

 

sage: h.dual_basis() is h._dual_basis_default() 

True 

""" 

return self._dual_basis 

 

def _repr_(self): 

""" 

Representation of ``self``. 

 

OUTPUT: 

 

- a string description of ``self`` 

 

EXAMPLES:: 

 

sage: m = SymmetricFunctions(QQ).monomial() 

sage: zee = sage.combinat.sf.sfa.zee 

sage: h = m.dual_basis(scalar=zee); h #indirect doctests 

Dual basis to Symmetric Functions over Rational Field in the monomial basis 

sage: h = m.dual_basis(scalar=zee, scalar_name='Hall scalar product'); h #indirect doctest 

Dual basis to Symmetric Functions over Rational Field in the monomial basis with respect to the Hall scalar product 

""" 

if hasattr(self, "_basis"): 

return super(SymmetricFunctionAlgebra_dual, self)._repr_() 

if self._scalar_name: 

return "Dual basis to %s"%self._dual_basis + " with respect to the " + self._scalar_name 

else: 

return "Dual basis to %s"%self._dual_basis 

 

def _precompute(self, n): 

""" 

Compute the transition matrices between ``self`` and its dual basis for 

the homogeneous component of size `n`. The result is not returned, 

but stored in the cache. 

 

INPUT: 

 

- ``n`` -- nonnegative integer 

 

EXAMPLES:: 

 

sage: e = SymmetricFunctions(QQ['t']).elementary() 

sage: f = e.dual_basis() 

sage: f._precompute(0) 

sage: f._precompute(1) 

sage: f._precompute(2) 

sage: l = lambda c: [ (i[0],[j for j in sorted(i[1].items())]) for i in sorted(c.items())] 

sage: l(f._to_self_cache) # note: this may depend on possible previous computations! 

[([], [([], 1)]), ([1], [([1], 1)]), ([1, 1], [([1, 1], 2), ([2], 1)]), ([2], [([1, 1], 1), ([2], 1)])] 

sage: l(f._from_self_cache) 

[([], [([], 1)]), ([1], [([1], 1)]), ([1, 1], [([1, 1], 1), ([2], -1)]), ([2], [([1, 1], -1), ([2], 2)])] 

sage: f._transition_matrices[2] 

[1 1] 

[1 2] 

sage: f._inverse_transition_matrices[2] 

[ 2 -1] 

[-1 1] 

""" 

base_ring = self.base_ring() 

zero = base_ring.zero() 

 

# Handle the n == 0 and n == 1 cases separately 

if n == 0 or n == 1: 

part = sage.combinat.partition.Partition([1]*n) 

self._to_self_cache[ part ] = { part: base_ring.one() } 

self._from_self_cache[ part ] = { part: base_ring.one() } 

self._transition_matrices[n] = matrix(base_ring, [[1]]) 

self._inverse_transition_matrices[n] = matrix(base_ring, [[1]]) 

return 

 

partitions_n = sage.combinat.partition.Partitions_n(n).list() 

 

# We now get separated into two cases, depending on whether we can 

# use the power-sum basis to compute the matrix, or we have to use 

# the Schur basis. 

 

from sage.rings.rational_field import RationalField 

if (not base_ring.has_coerce_map_from(RationalField())) and self._scalar == sage.combinat.sf.sfa.zee: 

# This is the case when (due to the base ring not being a 

# \mathbb{Q}-algebra) we cannot use the power-sum basis, 

# but (due to zee being the standard zee function) we can 

# use the Schur basis. 

 

schur = self._sym.schur() 

 

# Get all the basis elements of the n^th homogeneous component 

# of the dual basis and express them in the Schur basis 

d = {} 

for part in partitions_n: 

d[part] = schur(self._dual_basis(part))._monomial_coefficients 

 

# This contains the data for the transition matrix from the 

# dual basis to self. 

transition_matrix_n = matrix(base_ring, len(partitions_n), len(partitions_n)) 

 

# This first section calculates how the basis elements of the 

# dual basis are expressed in terms of self's basis. 

 

# For every partition p of size n, compute self(p) in 

# terms of the dual basis using the scalar product. 

i = 0 

for s_part in partitions_n: 

# s_part corresponds to self(dual_basis(part)) 

# s_mcs corresponds to self(dual_basis(part))._monomial_coefficients 

s_mcs = {} 

 

# We need to compute the scalar product of d[s_part] and 

# all of the d[p_part]'s 

j = 0 

for p_part in partitions_n: 

# Compute the scalar product of d[s_part] and d[p_part] 

sp = zero 

for ds_part in d[s_part]: 

if ds_part in d[p_part]: 

sp += d[s_part][ds_part]*d[p_part][ds_part] 

if sp != zero: 

s_mcs[p_part] = sp 

transition_matrix_n[i,j] = sp 

 

j += 1 

 

self._to_self_cache[ s_part ] = s_mcs 

i += 1 

 

else: 

# Now the other case. Note that just being in this case doesn't 

# guarantee that we can use the power-sum basis, but we can at 

# least try. 

 

# Get all the basis elements of the n^th homogeneous component 

# of the dual basis and express them in the power-sum basis 

d = {} 

for part in partitions_n: 

d[part] = self._p(self._dual_basis(part))._monomial_coefficients 

 

# This contains the data for the transition matrix from the 

# dual basis to self. 

transition_matrix_n = matrix(base_ring, len(partitions_n), len(partitions_n)) 

 

# This first section calculates how the basis elements of the 

# dual basis are expressed in terms of self's basis. 

 

# For every partition p of size n, compute self(p) in 

# terms of the dual basis using the scalar product. 

i = 0 

for s_part in partitions_n: 

# s_part corresponds to self(dual_basis(part)) 

# s_mcs corresponds to self(dual_basis(part))._monomial_coefficients 

s_mcs = {} 

 

# We need to compute the scalar product of d[s_part] and 

# all of the d[p_part]'s 

j = 0 

for p_part in partitions_n: 

# Compute the scalar product of d[s_part] and d[p_part] 

sp = zero 

for ds_part in d[s_part]: 

if ds_part in d[p_part]: 

sp += d[s_part][ds_part]*d[p_part][ds_part]*self._scalar(ds_part) 

if sp != zero: 

s_mcs[p_part] = sp 

transition_matrix_n[i,j] = sp 

 

j += 1 

 

self._to_self_cache[ s_part ] = s_mcs 

i += 1 

 

# Save the transition matrix 

self._transition_matrices[n] = transition_matrix_n 

 

# This second section calculates how the basis elements of 

# self expand in terms of the dual basis. We do this by 

# computing the inverse of the matrix obtained above. 

inverse_transition = ~transition_matrix_n 

 

for i in range(len(partitions_n)): 

d_mcs = {} 

for j in range(len(partitions_n)): 

if inverse_transition[i,j] != zero: 

d_mcs[ partitions_n[j] ] = inverse_transition[i,j] 

 

self._from_self_cache[ partitions_n[i] ] = d_mcs 

 

self._inverse_transition_matrices[n] = inverse_transition 

 

def transition_matrix(self, basis, n): 

r""" 

Returns the transition matrix between the `n^{th}` homogeneous components 

of ``self`` and ``basis``. 

 

INPUT: 

 

- ``basis`` -- a target basis of the ring of symmetric functions 

- ``n`` -- nonnegative integer 

 

OUTPUT: 

 

- A transition matrix from ``self`` to ``basis`` for the elements 

of degree ``n``. The indexing order of the rows and 

columns is the order of ``Partitions(n)``. 

 

EXAMPLES:: 

 

sage: Sym = SymmetricFunctions(QQ) 

sage: s = Sym.schur() 

sage: e = Sym.elementary() 

sage: f = e.dual_basis() 

sage: f.transition_matrix(s, 5) 

[ 1 -1 0 1 0 -1 1] 

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

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

[ 3 -1 -1 1 0 0 0] 

[ 3 -2 1 0 0 0 0] 

[-4 1 0 0 0 0 0] 

[ 1 0 0 0 0 0 0] 

sage: Partitions(5).list() 

[[5], [4, 1], [3, 2], [3, 1, 1], [2, 2, 1], [2, 1, 1, 1], [1, 1, 1, 1, 1]] 

sage: s(f[2,2,1]) 

s[3, 2] - 2*s[4, 1] + 3*s[5] 

sage: e.transition_matrix(s, 5).inverse().transpose() 

[ 1 -1 0 1 0 -1 1] 

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

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

[ 3 -1 -1 1 0 0 0] 

[ 3 -2 1 0 0 0 0] 

[-4 1 0 0 0 0 0] 

[ 1 0 0 0 0 0 0] 

""" 

if n not in self._transition_matrices: 

self._precompute(n) 

 

if basis is self._dual_basis: 

return self._inverse_transition_matrices[n] 

else: 

return self._inverse_transition_matrices[n]*self._dual_basis.transition_matrix(basis, n) 

 

 

def _multiply(self, left, right): 

""" 

Return product of ``left`` and ``right``. 

 

Multiplication is done by performing the multiplication in the dual 

basis of ``self`` and then converting back to ``self``. 

 

INPUT: 

 

- ``left``, ``right`` -- elements of ``self`` 

 

OUTPUT: 

 

- the product of ``left`` and ``right`` in the basis ``self`` 

 

EXAMPLES:: 

 

sage: m = SymmetricFunctions(QQ).monomial() 

sage: zee = sage.combinat.sf.sfa.zee 

sage: h = m.dual_basis(scalar=zee) 

sage: a = h([2]) 

sage: b = a*a; b # indirect doctest 

d_m[2, 2] 

sage: b.dual() 

6*m[1, 1, 1, 1] + 4*m[2, 1, 1] + 3*m[2, 2] + 2*m[3, 1] + m[4] 

""" 

 

#Do the multiplication in the dual basis 

#and then convert back to self. 

eclass = left.__class__ 

d_product = left.dual()*right.dual() 

 

return eclass(self, dual=d_product) 

 

class Element(classical.SymmetricFunctionAlgebra_classical.Element): 

""" 

An element in the dual basis. 

 

INPUT: 

 

At least one of the following must be specified. The one (if 

any) which is not provided will be computed. 

 

- ``dictionary`` -- an internal dictionary for the 

monomials and coefficients of ``self`` 

 

- ``dual`` -- self as an element of the dual basis. 

""" 

def __init__(self, A, dictionary=None, dual=None): 

""" 

Create an element of a dual basis. 

 

TESTS:: 

 

sage: m = SymmetricFunctions(QQ).monomial() 

sage: zee = sage.combinat.sf.sfa.zee 

sage: h = m.dual_basis(scalar=zee, prefix='h') 

sage: a = h([2]) 

sage: ec = h._element_class 

sage: ec(h, dual=m([2])) 

-h[1, 1] + 2*h[2] 

sage: h(m([2])) 

-h[1, 1] + 2*h[2] 

sage: h([2]) 

h[2] 

sage: h([2])._dual 

m[1, 1] + m[2] 

sage: m(h([2])) 

m[1, 1] + m[2] 

""" 

if dictionary is None and dual is None: 

raise ValueError("you must specify either x or dual") 

 

parent = A 

base_ring = parent.base_ring() 

zero = base_ring.zero() 

 

if dual is None: 

# We need to compute the dual 

dual_dict = {} 

from_self_cache = parent._from_self_cache 

 

# Get the underlying dictionary for self 

s_mcs = dictionary 

 

# Make sure all the conversions from self to 

# to the dual basis have been precomputed 

for part in s_mcs: 

if part not in from_self_cache: 

parent._precompute(sum(part)) 

 

# Create the monomial coefficient dictionary from the 

# the monomial coefficient dictionary of dual 

for s_part in s_mcs: 

from_dictionary = from_self_cache[s_part] 

for part in from_dictionary: 

dual_dict[ part ] = dual_dict.get(part, zero) + base_ring(s_mcs[s_part]*from_dictionary[part]) 

 

dual = parent._dual_basis._from_dict(dual_dict) 

 

 

if dictionary is None: 

# We need to compute the monomial coefficients dictionary 

dictionary = {} 

to_self_cache = parent._to_self_cache 

 

# Get the underlying dictionary for the dual 

d_mcs = dual._monomial_coefficients 

 

# Make sure all the conversions from the dual basis 

# to self have been precomputed 

for part in d_mcs: 

if part not in to_self_cache: 

parent._precompute(sum(part)) 

 

# Create the monomial coefficient dictionary from the 

# the monomial coefficient dictionary of dual 

dictionary = blas.linear_combination( (to_self_cache[d_part], d_mcs[d_part]) for d_part in d_mcs) 

 

# Initialize self 

self._dual = dual 

classical.SymmetricFunctionAlgebra_classical.Element.__init__(self, A, dictionary) 

 

 

def dual(self): 

""" 

Return ``self`` in the dual basis. 

 

OUTPUT: 

 

- the element ``self`` expanded in the dual basis to ``self.parent()`` 

 

EXAMPLES:: 

 

sage: m = SymmetricFunctions(QQ).monomial() 

sage: zee = sage.combinat.sf.sfa.zee 

sage: h = m.dual_basis(scalar=zee) 

sage: a = h([2,1]) 

sage: a.parent() 

Dual basis to Symmetric Functions over Rational Field in the monomial basis 

sage: a.dual() 

3*m[1, 1, 1] + 2*m[2, 1] + m[3] 

""" 

return self._dual 

 

def omega(self): 

r""" 

Return the image of ``self`` under the omega automorphism. 

 

The *omega automorphism* is defined to be the unique algebra 

endomorphism `\omega` of the ring of symmetric functions that 

satisfies `\omega(e_k) = h_k` for all positive integers `k` 

(where `e_k` stands for the `k`-th elementary symmetric 

function, and `h_k` stands for the `k`-th complete homogeneous 

symmetric function). It furthermore is a Hopf algebra 

endomorphism and an involution, and it is also known as the 

*omega involution*. It sends the power-sum symmetric function 

`p_k` to `(-1)^{k-1} p_k` for every positive integer `k`. 

 

The images of some bases under the omega automorphism are given by 

 

.. MATH:: 

 

\omega(e_{\lambda}) = h_{\lambda}, \qquad 

\omega(h_{\lambda}) = e_{\lambda}, \qquad 

\omega(p_{\lambda}) = (-1)^{|\lambda| - \ell(\lambda)} 

p_{\lambda}, \qquad 

\omega(s_{\lambda}) = s_{\lambda^{\prime}}, 

 

where `\lambda` is any partition, where `\ell(\lambda)` denotes 

the length (:meth:`~sage.combinat.partition.Partition.length`) 

of the partition `\lambda`, where `\lambda^{\prime}` denotes the 

conjugate partition 

(:meth:`~sage.combinat.partition.Partition.conjugate`) of 

`\lambda`, and where the usual notations for bases are used 

(`e` = elementary, `h` = complete homogeneous, `p` = powersum, 

`s` = Schur). 

 

:meth:`omega_involution` is a synonym for the :meth:`omega` 

method. 

 

OUTPUT: 

 

- the result of applying omega to ``self`` 

 

EXAMPLES:: 

 

sage: m = SymmetricFunctions(QQ).monomial() 

sage: zee = sage.combinat.sf.sfa.zee 

sage: h = m.dual_basis(zee) 

sage: hh = SymmetricFunctions(QQ).homogeneous() 

sage: hh([2,1]).omega() 

h[1, 1, 1] - h[2, 1] 

sage: h([2,1]).omega() 

d_m[1, 1, 1] - d_m[2, 1] 

""" 

eclass = self.__class__ 

return eclass(self.parent(), dual=self._dual.omega() ) 

 

omega_involution = omega 

 

def scalar(self, x): 

""" 

Return the standard scalar product of ``self`` and ``x``. 

 

INPUT: 

 

- ``x`` -- element of the symmetric functions 

 

OUTPUT: 

 

- the scalar product between ``x`` and ``self`` 

 

EXAMPLES:: 

 

sage: m = SymmetricFunctions(QQ).monomial() 

sage: zee = sage.combinat.sf.sfa.zee 

sage: h = m.dual_basis(scalar=zee) 

sage: a = h([2,1]) 

sage: a.scalar(a) 

2 

""" 

return self._dual.scalar(x) 

 

def scalar_hl(self, x): 

""" 

Return the Hall-Littlewood scalar product of ``self`` and ``x``. 

 

INPUT: 

 

- ``x`` -- element of the same dual basis as ``self`` 

 

OUTPUT: 

 

- the Hall-Littlewood scalar product between ``x`` and ``self`` 

 

EXAMPLES:: 

 

sage: m = SymmetricFunctions(QQ).monomial() 

sage: zee = sage.combinat.sf.sfa.zee 

sage: h = m.dual_basis(scalar=zee) 

sage: a = h([2,1]) 

sage: a.scalar_hl(a) 

(t + 2)/(-t^4 + 2*t^3 - 2*t + 1) 

""" 

return self._dual.scalar_hl(x) 

 

def _add_(self, y): 

""" 

Add two elements in the dual basis. 

 

INPUT: 

 

- ``y`` -- element of the same dual basis as ``self`` 

 

OUTPUT: 

 

- the sum of ``self`` and ``y`` 

 

EXAMPLES:: 

 

sage: m = SymmetricFunctions(QQ).monomial() 

sage: zee = sage.combinat.sf.sfa.zee 

sage: h = m.dual_basis(zee) 

sage: a = h([2,1])+h([3]); a # indirect doctest 

d_m[2, 1] + d_m[3] 

sage: h[2,1]._add_(h[3]) 

d_m[2, 1] + d_m[3] 

sage: a.dual() 

4*m[1, 1, 1] + 3*m[2, 1] + 2*m[3] 

""" 

eclass = self.__class__ 

return eclass(self.parent(), dual=(self.dual()+y.dual())) 

 

def _neg_(self): 

""" 

Return the negative of ``self``. 

 

EXAMPLES:: 

 

sage: m = SymmetricFunctions(QQ).monomial() 

sage: zee = sage.combinat.sf.sfa.zee 

sage: h = m.dual_basis(zee) 

sage: -h([2,1]) # indirect doctest 

-d_m[2, 1] 

""" 

eclass = self.__class__ 

return eclass(self.parent(), dual=self.dual()._neg_()) 

 

def _sub_(self, y): 

""" 

Subtract two elements in the dual basis. 

 

INPUT: 

 

- ``y`` -- element of the same dual basis as ``self`` 

 

OUTPUT: 

 

- the difference of ``self`` and ``y`` 

 

EXAMPLES:: 

 

sage: m = SymmetricFunctions(QQ).monomial() 

sage: zee = sage.combinat.sf.sfa.zee 

sage: h = m.dual_basis(zee) 

sage: h([2,1])-h([3]) # indirect doctest 

d_m[2, 1] - d_m[3] 

sage: h[2,1]._sub_(h[3]) 

d_m[2, 1] - d_m[3] 

""" 

eclass = self.__class__ 

return eclass(self.parent(), dual=(self.dual()-y.dual())) 

 

def _div_(self, y): 

""" 

Divide an element ``self`` of the dual basis by ``y``. 

 

INPUT: 

 

- ``y`` -- element of base field 

 

OUTPUT: 

 

- the element ``self`` divided by ``y`` 

 

EXAMPLES:: 

 

sage: m = SymmetricFunctions(QQ).monomial() 

sage: zee = sage.combinat.sf.sfa.zee 

sage: h = m.dual_basis(zee) 

sage: a = h([2,1])+h([3]) 

sage: a/2 # indirect doctest 

1/2*d_m[2, 1] + 1/2*d_m[3] 

""" 

return self*(~y) 

 

def __invert__(self): 

""" 

Invert ``self`` (only possible if ``self`` is a scalar 

multiple of `1` and we are working over a field). 

 

OUTPUT: 

 

- multiplicative inverse of ``self`` if possible 

 

EXAMPLES:: 

 

sage: m = SymmetricFunctions(QQ).monomial() 

sage: zee = sage.combinat.sf.sfa.zee 

sage: h = m.dual_basis(zee) 

sage: a = h(2); a 

2*d_m[] 

sage: ~a 

1/2*d_m[] 

sage: a = 3*h[1] 

sage: a.__invert__() 

Traceback (most recent call last): 

... 

ValueError: cannot invert self (= 3*m[1]) 

""" 

eclass = self.__class__ 

return eclass(self.parent(), dual=~self.dual()) 

 

def expand(self, n, alphabet='x'): 

""" 

Expand the symmetric function ``self`` as a symmetric polynomial 

in ``n`` variables. 

 

INPUT: 

 

- ``n`` -- a nonnegative integer 

 

- ``alphabet`` -- (default: ``'x'``) a variable for the expansion 

 

OUTPUT: 

 

A monomial expansion of ``self`` in the `n` variables 

labelled by ``alphabet``. 

 

EXAMPLES:: 

 

sage: m = SymmetricFunctions(QQ).monomial() 

sage: zee = sage.combinat.sf.sfa.zee 

sage: h = m.dual_basis(zee) 

sage: a = h([2,1])+h([3]) 

sage: a.expand(2) 

2*x0^3 + 3*x0^2*x1 + 3*x0*x1^2 + 2*x1^3 

sage: a.dual().expand(2) 

2*x0^3 + 3*x0^2*x1 + 3*x0*x1^2 + 2*x1^3 

sage: a.expand(2,alphabet='y') 

2*y0^3 + 3*y0^2*y1 + 3*y0*y1^2 + 2*y1^3 

sage: a.expand(2,alphabet='x,y') 

2*x^3 + 3*x^2*y + 3*x*y^2 + 2*y^3 

sage: h([1]).expand(0) 

0 

sage: (3*h([])).expand(0) 

3 

""" 

return self._dual.expand(n, alphabet) 

 

# Backward compatibility for unpickling 

from sage.structure.sage_object import register_unpickle_override 

register_unpickle_override('sage.combinat.sf.dual', 'SymmetricFunctionAlgebraElement_dual', SymmetricFunctionAlgebra_dual.Element)