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

r""" 

Rigged Partitions 

  

Class and methods of the rigged partition which are used by the rigged 

configuration class. This is an internal class used by the rigged 

configurations and KR tableaux during the bijection, and is not to be used by 

the end-user. 

  

We hold the partitions as an 1-dim array of positive integers where each 

value corresponds to the length of the row. This is the shape of the 

partition which can be accessed by the regular index. 

  

The data for the vacancy number is also stored in a 1-dim array which each 

entry corresponds to the row of the tableau, and similarly for the 

partition values. 

  

AUTHORS: 

  

- Travis Scrimshaw (2010-09-26): Initial version 

  

.. TODO:: 

  

Convert this to using multiplicities `m_i` (perhaps with a dictionary?)? 

""" 

  

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

# Copyright (C) 2010-2012 Travis Scrimshaw <tscrim@ucdavis.edu> 

# 

# 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.misc.latex import latex 

from sage.structure.richcmp cimport richcmp 

  

cdef class RiggedPartition(SageObject): 

r""" 

The RiggedPartition class which is the data structure of a rigged (i.e. 

marked or decorated) Young diagram of a partition. 

  

Note that this class as a stand-alone object does not make sense since the 

vacancy numbers are calculated using the entire rigged configuration. For 

more, see :class:`RiggedConfigurations`. 

  

EXAMPLES:: 

  

sage: RC = RiggedConfigurations(['A', 4, 1], [[2, 2]]) 

sage: RP = RC(partition_list=[[2],[2,2],[2,1],[2]])[2] 

sage: RP 

0[ ][ ]0 

-1[ ]-1 

<BLANKLINE> 

""" 

  

def __init__(self, shape=None, rigging_list=None, vacancy_nums=None): 

r""" 

Initialize by the rigged partition. 

  

Note that this only performs checks to see that the sizes match up. 

  

INPUT: 

  

- ``shape`` -- (default: ``None``) the shape 

- ``rigging_list`` -- (default: ``None``) the riggings 

- ``vacancy_nums`` -- (default: ``None``) the vacancy numbers 

  

TESTS:: 

  

sage: from sage.combinat.rigged_configurations.rigged_partition import RiggedPartition 

sage: RiggedPartition() 

(/) 

<BLANKLINE> 

sage: RP = RiggedPartition([2,1], [0,0], [1, 0]) 

sage: RP 

1[ ][ ]0 

0[ ]0 

<BLANKLINE> 

sage: TestSuite(RP).run() 

""" 

self._hash = 0 

  

if shape is None: 

self._list = [] 

self.vacancy_numbers = [] 

self.rigging = [] 

return 

  

self._list = list(shape) 

  

if vacancy_nums is not None: 

if len(shape) != len(vacancy_nums): 

raise ValueError("mismatch between shape and vacancy numbers") 

  

self.vacancy_numbers = list(vacancy_nums) 

else: 

self.vacancy_numbers = [None] * len(shape) 

  

if rigging_list is not None: 

  

if len(shape) != len(rigging_list): 

raise ValueError("mismatch between shape and rigging list") 

  

self.rigging = list(rigging_list) 

else: 

self.rigging = [None] * len(shape) 

  

def _repr_(self): 

""" 

Return a string representation of ``self``. 

  

EXAMPLES:: 

  

sage: RC = RiggedConfigurations(['A', 4, 1], [[2, 2]]) 

sage: elt = RC(partition_list=[[2],[2,2],[2,1],[2]])[2] 

sage: elt 

0[ ][ ]0 

-1[ ]-1 

<BLANKLINE> 

sage: Partitions.options.convention="french" 

sage: elt 

-1[ ]-1 

0[ ][ ]0 

<BLANKLINE> 

sage: Partitions.options._reset() 

""" 

# If it is empty, return saying so 

if not self._list: 

return("(/)\n") 

  

from sage.combinat.partition import Partitions 

if Partitions.options.convention == "French": 

itr = reversed(list(enumerate(self._list))) 

else: 

itr = enumerate(self._list) 

ret_str = "" 

vac_num_width = max(len(str(vac_num)) for vac_num in self.vacancy_numbers) 

for i, val in itr: 

ret_str += ("{:>" + str(vac_num_width) + "}").format(self.vacancy_numbers[i]) 

ret_str += "[ ]"*val 

ret_str += str(self.rigging[i]) 

ret_str += "\n" 

return(ret_str) 

  

def _latex_(self): 

r""" 

Returns LaTeX representation of ``self``. 

  

EXAMPLES:: 

  

sage: RC = RiggedConfigurations(['A', 4, 1], [[2, 2]]) 

sage: latex(RC(partition_list=[[2],[2,2],[2,1],[2]])[2]) 

{ 

\begin{array}[t]{r|c|c|l} 

\cline{2-3} 0 &\phantom{|}&\phantom{|}& 0 \\ 

\cline{2-3} -1 &\phantom{|}& \multicolumn{2 }{l}{ -1 } \\ 

\cline{2-2}  

\end{array} 

} 

  

TESTS: 

  

Check that this prints using the French convention:: 

  

sage: RC = RiggedConfigurations(['D',5,1], [[2,1], [1,2]]) 

sage: RiggedConfigurations.options.convention='French' 

sage: latex(RC(partition_list=[[3],[3,1],[1,1],[1],[1]])[1]) 

{ 

\begin{array}[t]{r|c|c|c|l} 

\cline{2-2} 0 &\phantom{|}& \multicolumn{3 }{l}{ 0 } \\ 

\cline{2-4} -2 &\phantom{|}&\phantom{|}&\phantom{|}& -2 \\ 

\cline{2-4} 

\end{array} 

} 

sage: RiggedConfigurations.options._reset() 

""" 

num_rows = len(self._list) 

if num_rows == 0: 

return "{\\emptyset}" 

  

num_cols = self._list[0] 

ret_string = "{\n\\begin{array}[t]{r|" + "c|"*num_cols + "l}\n" 

  

from sage.combinat.rigged_configurations.rigged_configurations import RiggedConfigurations 

if RiggedConfigurations.options.convention == 'English': 

ret_string += "\\cline{2-%s} "%(1+num_cols) + latex(self.vacancy_numbers[0]) 

for i, row_len in enumerate(self._list): 

  

ret_string += " &" + "\\phantom{|}&"*row_len 

  

if num_cols == row_len: 

ret_string += " " + latex(self.rigging[i]) 

else: 

ret_string += " \\multicolumn{" + repr(num_cols - row_len + 1) 

ret_string += "}{l}{" + latex(self.rigging[i]) + "}" 

  

ret_string += " \\\\\n" 

  

ret_string += "\\cline{2-" + repr(1 + row_len) + "} " 

if i != num_rows - 1 and row_len != self._list[i + 1]: 

ret_string += latex(self.vacancy_numbers[i + 1]) 

ret_string += "\n\\end{array}\n}" 

else: 

for i, row_len in enumerate(reversed(self._list)): 

ret_string += "\\cline{2-%s} "%(1 + row_len) + latex(self.vacancy_numbers[-i-1]) 

ret_string += " &" + "\\phantom{|}&"*row_len 

  

if num_cols == row_len: 

ret_string += " " + latex(self.rigging[-i-1]) 

else: 

ret_string += " \\multicolumn{" + repr(num_cols - row_len + 1) 

ret_string += "}{l}{" + latex(self.rigging[-i-1]) + "}" 

  

ret_string += " \\\\\n" 

ret_string += "\\cline{2-%s}\n\\end{array}\n}"%(1 + num_cols) 

  

return ret_string 

  

def _clone(self): 

r""" 

Makes a (deep) copy of this rigged partition. 

  

TESTS:: 

  

sage: RC = RiggedConfigurations(['A', 4, 1], [[2, 2]]) 

sage: RP = RC(partition_list=[[2],[2,2],[2,1],[2]])[2]; RP 

0[ ][ ]0 

-1[ ]-1 

<BLANKLINE> 

sage: RP2 = RP._clone(); RP2 

0[ ][ ]0 

-1[ ]-1 

<BLANKLINE> 

sage: RP == RP2 

True 

sage: RP is RP2 

False 

""" 

# TODO: Perhaps we can be better by not copying data as much and do it 

# more on-demand 

cdef RiggedPartition res 

cdef type t = type(self) 

res = t.__new__(t) 

res._list = self._list[:] 

res.rigging = self.rigging[:] 

res.vacancy_numbers = self.vacancy_numbers[:] 

res._hash = self._hash 

return res 

  

def __richcmp__(self, other, int op): 

r""" 

Return true if ``self`` equals ``rhs``. 

  

TESTS:: 

  

sage: RC = RiggedConfigurations(['A',2,1], [[1,1],[1,1],[1,1]]) 

sage: x = RC(partition_list=[[1], []], rigging_list=[[0], []]) 

sage: y = RC(partition_list=[[1], []], rigging_list=[[1], []]) 

sage: x == y 

False 

""" 

if not (isinstance(self, RiggedPartition) and isinstance(other, RiggedPartition)): 

return False 

  

cdef left = <RiggedPartition> self 

cdef right = <RiggedPartition> other 

return richcmp((left._list, left.rigging), (right._list, right.rigging), op) 

  

# TODO: Cythonize CombinatorialObject? 

  

def __hash__(self): 

""" 

TESTS:: 

  

sage: from sage.combinat.rigged_configurations.rigged_partition import RiggedPartition 

sage: nu = RiggedPartition() 

sage: h = hash(nu) 

sage: _ = nu.insert_cell(2) 

sage: h == hash(nu) 

False 

""" 

if self._hash == 0: 

self._hash = hash(tuple(self._list)) 

return self._hash 

  

def __nonzero__(self): 

""" 

TESTS:: 

  

sage: from sage.combinat.rigged_configurations.rigged_partition import RiggedPartition 

sage: nu = RiggedPartition() 

sage: bool(nu) 

False 

sage: nu = RiggedPartition([1]) 

sage: bool(nu) 

True 

""" 

return bool(self._list) 

  

def __len__(self): 

""" 

TESTS:: 

  

sage: from sage.combinat.rigged_configurations.rigged_partition import RiggedPartition 

sage: nu = RiggedPartition() 

sage: len(nu) 

0 

sage: nu = RiggedPartition([3,2,2,1]) 

sage: len(nu) 

4 

""" 

return len(self._list) 

  

def __getitem__(self, key): 

""" 

TESTS:: 

  

sage: from sage.combinat.rigged_configurations.rigged_partition import RiggedPartition 

sage: nu = RiggedPartition([3,2,1]) 

sage: nu[2] 

1 

""" 

return self._list[key] 

  

def __iter__(self): 

""" 

TESTS:: 

  

sage: from sage.combinat.rigged_configurations.rigged_partition import RiggedPartition 

sage: nu = RiggedPartition([3,2,1]) 

sage: list(nu) 

[3, 2, 1] 

""" 

return iter(self._list) 

  

def __reduce__(self): 

""" 

TESTS:: 

  

sage: from sage.combinat.rigged_configurations.rigged_partition import RiggedPartition 

sage: nu = RiggedPartition([3,2,1]) 

sage: loads(dumps(nu)) == nu 

True 

""" 

return type(self), (self._list, self.rigging, self.vacancy_numbers) 

  

# Should we move these functions to the CP -> RC bijections? 

  

cpdef get_num_cells_to_column(self, int end_column, t=1): 

r""" 

Get the number of cells in all columns before the ``end_column``. 

  

INPUT: 

  

- ``end_column`` -- The index of the column to end at 

  

- ``t`` -- The scaling factor 

  

OUTPUT: 

  

- The number of cells 

  

EXAMPLES:: 

  

sage: RC = RiggedConfigurations(['A', 4, 1], [[2, 2]]) 

sage: RP = RC(partition_list=[[2],[2,2],[2,1],[2]])[2] 

sage: RP.get_num_cells_to_column(1) 

2 

sage: RP.get_num_cells_to_column(2) 

3 

sage: RP.get_num_cells_to_column(3) 

3 

sage: RP.get_num_cells_to_column(3, 2) 

5 

""" 

cdef Py_ssize_t sum_cells = 0 

# Sum up from the reverse (the smallest row sizes) 

cdef Py_ssize_t i = len(self._list) - 1 

while i >= 0 and self._list[i]*t < end_column: 

sum_cells += self._list[i]*t 

i -= 1 

  

# Add the remaining cells 

if i > -1: 

sum_cells += end_column * (i + 1) 

  

return sum_cells 

  

cpdef insert_cell(self, int max_width): 

r""" 

Insert a cell given at a singular value as long as its less than the 

specified width. 

  

Note that :meth:`insert_cell` does not update riggings or vacancy 

numbers, but it does prepare the space for them. Returns the width of 

the row we inserted at. 

  

INPUT: 

  

- ``max_width`` -- The maximum width (i.e. row length) that we can 

insert the cell at 

  

OUTPUT: 

  

- The width of the row we inserted at. 

  

EXAMPLES:: 

  

sage: RC = RiggedConfigurations(['A', 4, 1], [[2, 2]]) 

sage: RP = RC(partition_list=[[2],[2,2],[2,1],[2]])[2] 

sage: RP.insert_cell(2) 

2 

sage: RP 

0[ ][ ][ ]None 

-1[ ]-1 

<BLANKLINE> 

""" 

cdef Py_ssize_t max_pos = -1 

cdef Py_ssize_t i 

self._hash = 0 # Reset the cached hash value 

if max_width > 0: 

for i, vac_num in enumerate(self.vacancy_numbers): 

if self._list[i] <= max_width and vac_num == self.rigging[i]: 

max_pos = i 

break 

  

if max_pos == -1: # No singular values, then add a new row 

self._list.append(1) 

self.vacancy_numbers.append(None) 

# Go through our partition until we find a length of greater than 1 

i = len(self._list) - 1 

while i >= 0 and self._list[i] == 1: 

i -= 1 

self.rigging.insert(i + 1, None) 

return 0 

  

self._list[max_pos] += 1 

self.rigging[max_pos] = None # State that we've changed this row 

return self._list[max_pos] - 1 

  

cpdef remove_cell(self, row, int num_cells=1): 

r""" 

Removes a cell at the specified ``row``. 

  

Note that :meth:`remove_cell` does not set/update the vacancy numbers 

or the riggings, but guarantees that the location has been allocated 

in the returned index. 

  

INPUT: 

  

- ``row`` -- the row to remove the cell from 

  

- ``num_cells`` -- (default: 1) the number of cells to remove 

  

OUTPUT: 

  

- The location of the newly constructed row or ``None`` if unable to 

remove row or if deleted a row. 

  

EXAMPLES:: 

  

sage: RC = RiggedConfigurations(['A', 4, 1], [[2, 2]]) 

sage: RP = RC(partition_list=[[2],[2,2],[2,1],[2]])[2] 

sage: RP.remove_cell(0) 

0 

sage: RP 

None[ ]None 

-1[ ]-1 

<BLANKLINE> 

""" 

self._hash = 0 # Reset the cached hash value 

if row is None: 

return None 

  

cdef Py_ssize_t r = row 

if self._list[r] <= num_cells: 

self._list.pop(r) 

self.vacancy_numbers.pop(r) 

self.rigging.pop(r) 

return None 

  

# Find the beginning of the next block we want 

cdef Py_ssize_t block_len = self._list[r] - num_cells # The length of the desired block 

if row + 1 == len(self._list): 

# If we are at the end, just do a simple remove 

self._list[r] = block_len 

self.vacancy_numbers[r] = None 

self.rigging[r] = None 

return r 

  

cdef Py_ssize_t i 

for i in range(r + 1, len(self._list)): 

if self._list[i] <= block_len: 

if i == r + 1: 

# If the next row is a block change, just reduce by num_cells 

self._list[r] = block_len 

self.vacancy_numbers[r] = None 

self.rigging[r] = None 

return row 

  

# Otherwise we need to "move" the row 

self._list.insert(i, block_len) 

# These should be updated (so there should be no need to carry them over) 

self.vacancy_numbers.insert(i, None) 

self.rigging.insert(i, None) 

  

self._list.pop(r) 

self.vacancy_numbers.pop(r) 

self.rigging.pop(r) 

return i - 1 

  

# We need to "move" the row to the end of the partition 

self._list.pop(r) 

self.vacancy_numbers.pop(r) 

self.rigging.pop(r) 

  

self._list.append(block_len) 

# Placeholders as above 

self.vacancy_numbers.append(None) 

self.rigging.append(None) 

return len(self._list) - 1 

  

cdef class RiggedPartitionTypeB(RiggedPartition): 

r""" 

Rigged partitions for type `B_n^{(1)}` which has special printing rules 

which comes from the fact that the `n`-th partition can have columns of 

width `\frac{1}{2}`. 

""" 

def __init__(self, arg0, arg1=None, arg2=None): 

""" 

Initialize ``self``. 

  

EXAMPLES:: 

  

sage: RP = sage.combinat.rigged_configurations.rigged_partition.RiggedPartition([2,1], [0,0], [1, 0]) 

sage: B = sage.combinat.rigged_configurations.rigged_partition.RiggedPartitionTypeB(RP); B 

1[][]0 

0[]0 

<BLANKLINE> 

sage: TestSuite(B).run() 

""" 

if arg1 is not None: 

RiggedPartition.__init__(self, arg0, arg1, arg2) 

return 

  

RiggedPartition.__init__(self, 

arg0._list, 

arg0.rigging, 

arg0.vacancy_numbers) 

  

def _repr_(self): 

""" 

Return a string representation of ``self``. 

  

INPUT: 

  

- ``half_width_boxes`` -- (Default: ``True``) Display the partition 

using half width boxes 

  

EXAMPLES:: 

  

sage: RC = RiggedConfigurations(['B', 2, 1], [[2, 2]]) 

sage: elt = RC(partition_list=[[2],[2,1]])[1] 

sage: elt 

-2[][]-2 

-2[]-2 

<BLANKLINE> 

sage: RiggedConfigurations.options.half_width_boxes_type_B=False 

sage: elt 

-2[ ][ ]-2 

-2[ ]-2 

<BLANKLINE> 

sage: RiggedConfigurations.options._reset() 

""" 

# If it is empty, return saying so 

if len(self._list) == 0: 

return("(/)\n") 

  

from sage.combinat.partition import Partitions 

if Partitions.options.convention == "french": 

itr = reversed(list(enumerate(self._list))) 

else: 

itr = enumerate(self._list) 

ret_str = "" 

  

from sage.combinat.rigged_configurations.rigged_configurations import RiggedConfigurations 

if RiggedConfigurations.options.half_width_boxes_type_B: 

box_str = "[]" 

else: 

box_str = "[ ]" 

  

vac_num_width = max(len(str(vac_num)) for vac_num in self.vacancy_numbers) 

for i, val in itr: 

ret_str += ("{:>" + str(vac_num_width) + "}").format(self.vacancy_numbers[i]) 

ret_str += box_str*val 

ret_str += str(self.rigging[i]) 

ret_str += "\n" 

return(ret_str) 

  

def _latex_(self): 

r""" 

Returns LaTeX representation of ``self``. 

  

INPUT: 

  

- ``half_width_boxes`` -- (Default: ``True``) Display the partition 

using half width boxes 

  

EXAMPLES:: 

  

sage: RC = RiggedConfigurations(['B', 2, 1], [[1, 1]]) 

sage: RP = RC(partition_list=[[],[2]])[1] 

sage: latex(RP) 

{ 

\begin{array}[t]{r|c|c|l} 

\cline{2-3} -4 &\phantom{a}&\phantom{a}& -4 \\ 

\cline{2-3}  

\end{array} 

} 

sage: RiggedConfigurations.options.half_width_boxes_type_B=False 

sage: latex(RP) 

{ 

\begin{array}[t]{r|c|c|l} 

\cline{2-3} -4 &\phantom{X|}&\phantom{X|}& -4 \\ 

\cline{2-3}  

\end{array} 

} 

sage: RiggedConfigurations.options._reset() 

""" 

num_rows = len(self._list) 

if num_rows == 0: 

return "{\\emptyset}" 

 

from sage.combinat.rigged_configurations.rigged_configurations import RiggedConfigurations 

if RiggedConfigurations.options.half_width_boxes_type_B: 

box_str = "\\phantom{a}&" 

else: 

box_str = "\\phantom{X|}&" 

  

num_cols = self._list[0] 

ret_string = "{\n\\begin{array}[t]{r|" + "c|"*num_cols + "l}\n" 

  

if RiggedConfigurations.options.convention == 'English': 

ret_string += "\\cline{2-%s} "%(1+num_cols) + latex(self.vacancy_numbers[0]) 

for i, row_len in enumerate(self._list): 

ret_string += " &" + box_str*row_len 

  

if num_cols == row_len: 

ret_string += " " + latex(self.rigging[i]) 

else: 

ret_string += " \\multicolumn{" + repr(num_cols - row_len + 1) 

ret_string += "}{l}{" + latex(self.rigging[i]) + "}" 

  

ret_string += " \\\\\n" 

  

ret_string += "\\cline{2-" + repr(1 + row_len) + "} " 

if i != num_rows - 1 and row_len != self._list[i + 1]: 

ret_string += latex(self.vacancy_numbers[i + 1]) 

ret_string += "\n\\end{array}\n}" 

else: 

for i, row_len in enumerate(reversed(self._list)): 

ret_string += "\\cline{2-%s} "%(1 + row_len) 

ret_string += latex(self.vacancy_numbers[-i-1]) 

ret_string += " &" + box_str*row_len 

  

if num_cols == row_len: 

ret_string += " " + latex(self.rigging[-i-1]) 

else: 

ret_string += " \\multicolumn{" + repr(num_cols - row_len + 1) 

ret_string += "}{l}{" + latex(self.rigging[-i-1]) + "}" 

  

ret_string += " \\\\\n" 

ret_string += "\\cline{2-%s}\n\\end{array}\n}"%(1 + num_cols) 

  

return ret_string