File: NxsDiscreteMatrix.html

package info (click to toggle)
libncl 2.1.18%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 8,344 kB
  • ctags: 3,526
  • sloc: xml: 43,716; cpp: 30,400; sh: 10,658; python: 231; makefile: 190
file content (659 lines) | stat: -rw-r--r-- 34,761 bytes parent folder | download | duplicates (5)
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
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head><title>NEXUS CLASS LIBRARY: NxsDiscreteMatrix Class</title>

<style type="text/css">
<!--
@import url(ncl.css);
.quickref {font-family: Arial, sans-serif}
.public {font-weight: bold; color: black; background: white;}
.protected {font-weight: bold; color: teal; background: white;}
.private {font-weight: bold; color: red; background: white;}
.groupheading {font-size: large; font-weight: bold;}
.classy {font-family: Arial, sans-serif; color: navy;}
.variablename {font-weight: bold; color: maroon;}
-->
</style>
</head>
<body>

<table border="1" width="100%">
<tr><td>
<table border="0" width="100%">
<tr>
<td align="left"><span class="classy">NEXUS CLASS LIBRARY</span></td>
<td align="right"><span class="classy"><a href="v2.0index.html">home</a> | <a href="classes.html">classes</a> | <a href="functions.html">functions</a></span></td>
</tr>
</table>
</td></tr>
</table>

<h1>Class NxsDiscreteMatrix</h1>

<h2>Friends</h2>
class <a href="NxsAllelesBlock.html"><span class="quickref">NxsAllelesBlock</span></a>, class <a href="NxsCharactersBlock.html"><span class="quickref">NxsCharactersBlock</span></a>
<h2>Data Members</h2>
<a href="#data"><span class="quickref">data</span></a>, <a href="#ncols"><span class="quickref">ncols</span></a>, <a href="#nrows"><span class="quickref">nrows</span></a>
<h2>Member Functions</h2>
<a href="#AddRows55"><span class="quickref">AddRows</span></a><a href="#AddState90"><span class="quickref">, AddState</span></a><a href="#AddState113"><span class="quickref">, AddState</span></a><a href="#CopyStatesFromFirstTaxon165"><span class="quickref">, CopyStatesFromFirstTaxon</span></a><a href="#DebugSaveMatrix182"><span class="quickref">, DebugSaveMatrix</span></a><a href="#DuplicateRow214"><span class="quickref">, DuplicateRow</span></a><a href="#Flush251"><span class="quickref">, Flush</span></a><a href="#GetDiscreteDatum269"><span class="quickref">, GetDiscreteDatum</span></a><a href="#GetNumStates287"><span class="quickref">, GetNumStates</span></a><a href="#GetNumStates303"><span class="quickref">, GetNumStates</span></a><a href="#GetObsNumStates320"><span class="quickref">, GetObsNumStates</span></a><a href="#GetState351"><span class="quickref">, GetState</span></a><a href="#GetState370"><span class="quickref">, GetState</span></a><a href="#IsGap386"><span class="quickref">, IsGap</span></a><a href="#IsGap403"><span class="quickref">, IsGap</span></a><a href="#IsMissing416"><span class="quickref">, IsMissing</span></a><a href="#IsMissing433"><span class="quickref">, IsMissing</span></a><a href="#IsPolymorphic446"><span class="quickref">, IsPolymorphic</span></a><a href="#IsPolymorphic463"><span class="quickref">, IsPolymorphic</span></a><a href="#NxsDiscreteMatrix26"><span class="quickref">, NxsDiscreteMatrix</span></a><a href="#NxsDiscreteMatrix41"><span class="quickref">, ~NxsDiscreteMatrix</span></a><a href="#Reset478"><span class="quickref">, Reset</span></a><a href="#SetGap509"><span class="quickref">, SetGap</span></a><a href="#SetGap526"><span class="quickref">, SetGap</span></a><a href="#SetMissing539"><span class="quickref">, SetMissing</span></a><a href="#SetMissing556"><span class="quickref">, SetMissing</span></a><a href="#SetPolymorphic570"><span class="quickref">, SetPolymorphic</span></a><a href="#SetPolymorphic589"><span class="quickref">, SetPolymorphic</span></a><a href="#SetState607"><span class="quickref">, SetState</span></a><a href="#SetState627"><span class="quickref">, SetState</span></a>
<h2>Class Description</h2>

<p>
Class providing storage for the discrete data types (dna, rna, nucleotide, standard, and protein) inside a DATA or  CHARACTERS block. This class is also used to store the data for an ALLELES block. Maintains a matrix in which each  cell is an object of the class  <a href="NxsDiscreteDatum.html">NxsDiscreteDatum</a> .  <a href="NxsDiscreteDatum.html">NxsDiscreteDatum</a>  stores the state for a particular combination of  taxon and character as an integer. Ordinarily, there will be a single state recorded for each taxon-character  combination, but exceptions exist if there is polymorphism for a taxon-character combination, or if there is  uncertainty about the state (e.g., in dna data, the data file might have contained an R or Y entry). Please consult  the documentation for the  <a href="NxsDiscreteDatum.html">NxsDiscreteDatum</a>  class for the details about how states are stored. For data stored in an  ALLELES block, rows of the matrix correspond to individuals and columns to loci. Each  <a href="NxsDiscreteDatum.html">NxsDiscreteDatum</a>  must  therefore store information about both genes at a single locus for a single individual in the case of diploid data. To do this, two macros HIWORD and LOWORD are used to divide up the unsigned value into two words. A maximum of 255  distinct allelic forms can be accommodated by this scheme, assuming at minimum a 32-bit architecture. Because it is not known in advance how many rows are going to be necessary, The NxsDiscreteMatrix class provides the AddRows  method, which expands the number of rows allocated for the matrix while preserving data already stored.


<h3>Key to symbols and colors</h3>

<p><span class="public">public</span>, <span class="protected">protected</span>, <span class="private">private</span>, <code>A</code> = abstract, <code>C</code> = constructor, <code>D</code> = destructor, <code>I</code> = inline, <code>S</code> = static, <code>V</code> = virtual, <code>F</code> = friend</p>
<p>&nbsp;</p>
<center>
<table border="5" cellpadding="1" cellspacing="0" width="95%">
<tr bgcolor="#CCCCFF">
<td><span class="groupheading">Data Members</span></td>
</table>
<table border="1" cellpadding="3" cellspacing="0" width="95%">
<tr><td>
<table  width="100%" border="0" cellpadding="1">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code>&nbsp;<a href="NxsDiscreteDatum.html">NxsDiscreteDatum</a></code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="private"><a name="data">**data</a></code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>storage for the data</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table  width="100%" border="0" cellpadding="1">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code>&nbsp;unsigned</code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="private"><a name="ncols">ncols</a></code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>number of columns (characters) in the data matrix</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table  width="100%" border="0" cellpadding="1">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code>&nbsp;unsigned</code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="private"><a name="nrows">nrows</a></code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>number of rows (taxa) in the data matrix</dd></td>
</tr>
</table>
</td></tr>
</table>
</center>
<p>&nbsp;</p>
<center>
<table border="5" cellpadding="1" cellspacing="0" width="95%">
<tr bgcolor="#CCCCFF">
<td><span class="groupheading">Member Functions</span></td>
</table>
<table border="1" cellpadding="3" cellspacing="0" width="95%">
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code>void</code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="public"><a name="AddRows55">AddRows</a></code><code>(unsigned nAddRows)</code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>Allocates memory for <span class="variablename">nAddRows</span> additional rows and updates the variable nrows. Data already stored in <span class="variablename">data</span> is not destroyed; the newly-allocated rows are added at the bottom of the existing matrix.</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code>void</code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="public"><a name="AddState90">AddState</a></code><code>(unsigned i, unsigned j, unsigned value)</code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>Adds state directly to the <a href="NxsDiscreteDatum.html">NxsDiscreteDatum</a> object at data[i][j]. Assumes <span class="variablename">data</span> is non-NULL, <span class="variablename">i</span> is in the range  [0..nrows), and <span class="variablename">j</span> is in the range [0..ncols). The <span class="variablename">value</span> argument is assumed to be either zero or a positive  integer. Calls private member function AddState to do the real work; look at the documentation for that function  for additional details.</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code>void</code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="public"><a name="AddState113">AddState</a></code><code>(NxsDiscreteDatum &d, unsigned value)</code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>Adds an additional state to the array states of <span class="variablename">d</span>. If <span class="variablename">states</span> is NULL, allocates memory for two integers and  assigns 1 to the first and <span class="variablename">value</span> to the second. If <span class="variablename">states</span> is non-NULL, allocates a new int array long enough to  hold states already present plus the new one being added here, then deletes the old <span class="variablename">states</span> array. Assumes that we  are not trying to set either the missing state or the gap state here; the functions SetMissing or SetGap,  respectively, should be used for those purposes. Also assumes that we do not want to overwrite the state. This  function always adds states to those already present; use SetState to overwrite the state.</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code>void</code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="public"><a name="CopyStatesFromFirstTaxon165">CopyStatesFromFirstTaxon</a></code><code>(unsigned i, unsigned j)</code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>Sets state of taxon <span class="variablename">i</span> and character <span class="variablename">j</span> to state of first taxon for character <span class="variablename">j</span>. Assumes <span class="variablename">i</span> is in the range  [0..nrows) and <span class="variablename">j</span> is in the range [0..ncols). Also assumes <span class="variablename">data</span> is non-NULL. Calls private function CopyFrom to do the actual work.</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code>void</code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="public"><a name="DebugSaveMatrix182">DebugSaveMatrix</a></code><code>(ostream &out, unsigned colwidth)</code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>Performs a dump of the current contents of the data matrix stored in the variable <span class="variablename">data</span>. Translates missing data elements to the '?' character and gap states to '-', otherwise, calls GetState to provide the representation.</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code>unsigned</code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="public"><a name="DuplicateRow214">DuplicateRow</a></code><code>(unsigned row, unsigned count, unsigned startCol, unsigned endCol)</code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>Duplicates columns <span class="variablename">startCol</span> to <span class="variablename">endCol</span> in row <span class="variablename">row</span> of the matrix. If additional storage is needed to accommodate the duplication, this is done automatically through the use of the AddRows method. Note that <span class="variablename">count</span> includes the  row already present, so if <span class="variablename">count</span> is 10, then 9 more rows will actually be added to the matrix to make a total of  10 identical rows. The parameters <span class="variablename">startCol</span> and <span class="variablename">endCol</span> default to 0 and <span class="variablename">ncols</span>, so if duplication of the entire row is needed, these need not be explicitly specified in the call to DuplicateRow. Return value is number of  additional rows allocated to matrix (0 if no rows needed to be allocated). Assumes <span class="variablename">data</span> is non-NULL, <span class="variablename">row</span> is in the range [[0..<span class="variablename">nrows</span>), <span class="variablename">startCol</span> is in the range [0..<span class="variablename">ncols</span>), and <span class="variablename">endCol</span> is either UINT_MAX, in which case it is reset to <span class="variablename">ncols</span> - 1, or is in the range (<span class="variablename">startCol</span>..<span class="variablename">ncols</span>).</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code>void</code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="public"><a name="Flush251">Flush</a></code><code>()</code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>Deletes all cells of <span class="variablename">data</span>, setting <span class="variablename">data</span> to NULL, and resets <span class="variablename">nrows</span> and <span class="variablename">ncols</span> to 0.</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code><a href="NxsDiscreteDatum.html">NxsDiscreteDatum</a></code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="public"><a name="GetDiscreteDatum269">&GetDiscreteDatum</a></code><code>(unsigned i, unsigned j)</code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>Assumes that <span class="variablename">data</span> is non-NULL, <span class="variablename">i</span> is in the range [0..<span class="variablename">nrows</span>) and <span class="variablename">j</span> is in the range [0..<span class="variablename">ncols</span>). Returns  reference to the <a href="NxsDiscreteDatum.html">NxsDiscreteDatum</a> object at row <span class="variablename">i</span>, column <span class="variablename">j</span> of matrix.</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code>unsigned</code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="public"><a name="GetNumStates287">GetNumStates</a></code><code>(unsigned i, unsigned j)</code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>Returns number of states for taxon <span class="variablename">i</span> and character <span class="variablename">j</span>. Assumes <span class="variablename">data</span> is non-NULL, <span class="variablename">i</span> is in the range  [0..<span class="variablename">nrows</span>), and <span class="variablename">j</span> is in the range [0..<span class="variablename">ncols</span>). Calls private member function GetNumStates to do the actual work.</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code>unsigned</code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="public"><a name="GetNumStates303">GetNumStates</a></code><code>(NxsDiscreteDatum &d)</code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>Returns total number of states assigned to <span class="variablename">d</span>. Returns 0 for both gap and missing states.</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code>unsigned</code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="public"><a name="GetObsNumStates320">GetObsNumStates</a></code><code>(unsigned j)</code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>Returns number of states for character <span class="variablename">j</span> over all taxa. Note: this function is rather slow, as it must walk  through each taxon for the specified character, adding the states encountered to a set, then finally returning the size of the set. Thus, if this function is called often, it would be advisable to initialize an array using this  function, then refer to the array subsequently. Assumes <span class="variablename">j</span> is in the range [0..<span class="variablename">ncols</span>) and <span class="variablename">data</span> is non-NULL. Includes all taxa (i.e. there is no mechanism here for treating some taxa as deleted for a particular analysis). Missing and gap states are ignored.</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code>unsigned</code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="public"><a name="GetState351">GetState</a></code><code>(unsigned i, unsigned j, unsigned k)</code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>Returns the <span class="variablename">k</span>th state possessed by taxon <span class="variablename">i</span> and character <span class="variablename">j</span>. This taxon-character combination will have more  than one state if there is ambiguity or polymorphism. Assumes that <span class="variablename">i</span> is in the range [0..<span class="variablename">nrows</span>) and <span class="variablename">j</span> is in  the range [0..<span class="variablename">ncols</span>). Also assumes that at least one state is present (i.e., not the gap or missing state). Use  the function GetNumStates to determine the  number of states present. Assumes <span class="variablename">k</span> is in the range [0..ns), where ns is the value returned by GetNumStates.</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code>unsigned</code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="public"><a name="GetState370">GetState</a></code><code>(NxsDiscreteDatum &d, unsigned k)</code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>Returns the internal unsigned representation of the state stored in <span class="variablename">d</span> at position <span class="variablename">k</span> of the array <span class="variablename">d.states</span>.  Assumes that the state is not the missing or gap state. Use IsMissing and IsGap prior to calling this function to  ensure this function will succeed. Assumes that <span class="variablename">k</span> is in the range [ 0 .. <span class="variablename">d.states</span>[0]).</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code>bool</code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="public"><a name="IsGap386">IsGap</a></code><code>(unsigned i, unsigned j)</code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>Returns 1 if the state for taxon <span class="variablename">i</span>, character <span class="variablename">j</span>, is set to the gap symbol, 0 otherwise. Assumes <span class="variablename">data</span> is  non-NULL, <span class="variablename">i</span> is in the range [0..<span class="variablename">nrows</span>) and <span class="variablename">j</span> is in the range [0..<span class="variablename">ncols</span>).</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code>bool</code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="public"><a name="IsGap403">IsGap</a></code><code>(NxsDiscreteDatum &d)</code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>Returns true if the gap state is stored, otherwise returns false. Note: returns false if this datum represents  missing data (often the gap state is equated with missing data, but the distinction is made here).</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code>bool</code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="public"><a name="IsMissing416">IsMissing</a></code><code>(unsigned i, unsigned j)</code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>Returns 1 if the state for taxon <span class="variablename">i</span>, character <span class="variablename">j</span>, is set to the missing data symbol, 0 otherwise. Assumes <span class="variablename">i</span> is  in the range [0..<span class="variablename">nrows</span>) and <span class="variablename">j</span> is in the range [0..<span class="variablename">ncols</span>).</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code>bool</code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="public"><a name="IsMissing433">IsMissing</a></code><code>(NxsDiscreteDatum &d)</code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>Returns true if the missing state is stored, false otherwise. Note that this function returns false if the gap state is stored (often the gap state is equated with missing data, but the distinction is maintained here).</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code>bool</code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="public"><a name="IsPolymorphic446">IsPolymorphic</a></code><code>(unsigned i, unsigned j)</code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>Returns 1 if character <span class="variablename">j</span> is polymorphic in taxon <span class="variablename">i</span>, 0 otherwise. Assumes <span class="variablename">data</span> is non-NULL, <span class="variablename">i</span> is in the  range [0..<span class="variablename">nrows</span>) and <span class="variablename">j</span> is in the range [0..<span class="variablename">ncols</span>).</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code>bool</code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="public"><a name="IsPolymorphic463">IsPolymorphic</a></code><code>(NxsDiscreteDatum &d)</code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>Returns true if the number of states is greater than 1 and polymorphism has been specified. Returns false if the  state stored is the missing state, the gap state, or if the number of states is 1.</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td>C</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code></code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="public"><a name="NxsDiscreteMatrix26">NxsDiscreteMatrix</a></code><code>(unsigned rows, unsigned cols)</code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>Initializes <span class="variablename">nrows</span> to <span class="variablename">rows</span> and <span class="variablename">ncols</span> to <span class="variablename">cols</span>. In addition, memory is allocated for <span class="variablename">data</span> (each element of  the matrix <span class="variablename">data</span> is a <a href="NxsDiscreteDatum.html">NxsDiscreteDatum</a> object, which can do its own initialization).</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td>D</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code></code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="public"><a name="NxsDiscreteMatrix41">~NxsDiscreteMatrix</a></code><code>()</code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>Deletes memory allocated in the constructor for data member <span class="variablename">data</span>.</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code>void</code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="public"><a name="Reset478">Reset</a></code><code>(unsigned rows, unsigned cols)</code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>Deletes all cells of <span class="variablename">data</span> and reallocates memory to create a new matrix object with <span class="variablename">nrows</span> = <span class="variablename">rows</span> and <span class="variablename">ncols</span>  = <span class="variablename">cols</span>. Assumes <span class="variablename">rows</span> and <span class="variablename">cols</span> are both greater than 0.</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code>void</code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="public"><a name="SetGap509">SetGap</a></code><code>(unsigned i, unsigned j)</code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>Sets state stored at `data[i][j]' to the gap state. Assumes <span class="variablename">i</span> is in the range [0..<span class="variablename">nrows</span>) and <span class="variablename">j</span> is in the  range [0..<span class="variablename">ncols</span>). Calls the private SetGap member function to do the actual work.</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code>void</code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="public"><a name="SetGap526">SetGap</a></code><code>(NxsDiscreteDatum &d)</code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>Assigns the gap state to <span class="variablename">d</span>, erasing any previously stored information. The gap state is designated internally as  a states array one element long, with the single element set to the value 0.</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code>void</code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="public"><a name="SetMissing539">SetMissing</a></code><code>(unsigned i, unsigned j)</code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>Sets state stored at `data[i][j]' to the missing state. Assumes <span class="variablename">data</span> is non-NULL, <span class="variablename">i</span> is in the range [0..<span class="variablename">nrows</span>) and <span class="variablename">j</span> is in the range [0..<span class="variablename">ncols</span>). Calls the private member function SetMissing to do the actual work.</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code>void</code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="public"><a name="SetMissing556">SetMissing</a></code><code>(NxsDiscreteDatum &d)</code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>Assigns the missing state to <span class="variablename">d</span>, erasing any previously stored information. The missing state is stored internally as a NULL value for the states array.</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code>void</code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="public"><a name="SetPolymorphic570">SetPolymorphic</a></code><code>(unsigned i, unsigned j, unsigned value)</code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>Specify 1 for <span class="variablename">value</span> if taxon at row <span class="variablename">i</span> is polymorphic at character in column <span class="variablename">j</span>, 0 for <span class="variablename">value</span> if uncertain  which state applies. Sets polymorphism state of taxon <span class="variablename">i</span> and character <span class="variablename">j</span> to <span class="variablename">value</span>. Assumes <span class="variablename">data</span> is non-NULL, <span class="variablename">i</span> is in the range [0..<span class="variablename">nrows</span>) and <span class="variablename">j</span> is in the range [0..<span class="variablename">ncols</span>). Also assumes that the number of states  stored is greater than 1. Calls private member function SetPolymorphic to do the actual work.</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code>void</code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="public"><a name="SetPolymorphic589">SetPolymorphic</a></code><code>(NxsDiscreteDatum &d, unsigned value)</code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>Sets the polymorphism cell (last cell in <span class="variablename">d.states</span>) to <span class="variablename">value</span>. Warning: has no effect if there are fewer than 2  states stored!</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code>void</code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="public"><a name="SetState607">SetState</a></code><code>(unsigned i, unsigned j, unsigned value)</code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>Sets state of taxon <span class="variablename">i</span> and character <span class="variablename">j</span> to <span class="variablename">value</span>. Assumes <span class="variablename">data</span> is non-NULL, <span class="variablename">i</span> is in the range [0..<span class="variablename">nrows</span>)  and <span class="variablename">j</span> is in the range [0..<span class="variablename">ncols</span>). Assumes that this function will not be called if there is missing data or the  state is the gap state, in which case the functions SetMissing or SetGap, respectively, should be called instead. Calls the private member function SetState to do the actual work.</dd></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="1">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td align="right" valign="top" width="15%"><code>void</code></td>
<td>&nbsp;</td>
<td align="left" valign="top" width="82%"><code class="public"><a name="SetState627">SetState</a></code><code>(NxsDiscreteDatum &d, unsigned value)</code></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><dd>Assigns <span class="variablename">value</span> to the 2nd cell in <span class="variablename">d.states</span> (1st cell in <span class="variablename">d.states</span> array is set to 1 to indicate that there is  only one state). Warning: if already one or more states (including the gap state) are assigned to <span class="variablename">d</span>, they will  be forgotten. Use the function AddState if you want to preserve states already stored in <span class="variablename">d</span>. Assumes state being  set is not the missing state nor the gap state; use SetMissing or SetGap, respectively, for that.</dd></td>
</tr>
</table>
</td></tr>
</table>
</center>