Legofit
infers population history from nucleotide site patterns.
Data Structures | Functions | Variables
idset.c File Reference

A set of tipID_t values. More...

#include "idset.h"
#include "misc.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

Data Structures

struct  IdSet
 

Functions

static void merge (int nz, tipId_t *z, int nx, tipId_t *x, int ny, tipId_t *y)
 
static void merge3 (int nw, tipId_t *w, int nz, tipId_t *z, int nx, tipId_t *x, int ny, tipId_t *y)
 
static IdSetIdSet_new_noEventLst (int nIds, const tipId_t *tid)
 Allocate a new IdSet object with given values of nIds and tid. More...
 
void IdSet_sanityCheck (IdSet *self, const char *file, int lineno)
 
void IdSet_print (IdSet *self, FILE *fp)
 
IdSetIdSet_new (int nIds, const tipId_t *tid, EventLst *evlst)
 Allocate a new IdSet object with given values of nIds, tid, and evlst.
 
IdSetIdSet_dup (const IdSet *old)
 
void IdSet_copyEventLst (IdSet *self, const IdSet *old)
 
IdSetIdSet_join (IdSet *left, IdSet *right, int nsamples, tipId_t *samples)
 Join two IdSet objects, left and right, along with all the tipId_t values in the "samples" array. More...
 
void IdSet_addEvent (IdSet *self, unsigned event, unsigned outcome, long double pr)
 
IdSetIdSet_addSamples (IdSet *old, int nsamples, tipId_t *samples)
 Return pointer to new IdSet and free old one.
 
IdSetIdSet_newTip (tipId_t tid)
 Allocate a new IdSet with a single tipId_t value and probability 1.
 
int IdSet_cmp (const IdSet *left, const IdSet *right)
 
uint32_t IdSet_hash (const IdSet *self)
 
void IdSet_free (IdSet *self)
 
long double IdSet_prob (IdSet *self)
 
int IdSet_nIds (IdSet *self)
 
tipId_t IdSet_union (IdSet *self, int n, int *ndx)
 Return a tipId_t value representing the union of the values within this IdSet object whose indices are given in ndx, an array of length n.
 
void IdSet_partition (IdSet *self, unsigned k, tipId_t part[k], unsigned n, unsigned a[n])
 On entry, k is the number of parts into which this IdSet will be subdivided, n must equal self->nIds, and a[j] is the index of the part into which the j'th tipId_t value will be assigned. More...
 
EventLstIdSet_dupEventLst (const IdSet *self)
 Return a duplicate of the EventLst of this IdSet.
 
IdSetIdSet_subset (const IdSet *self, int n, int *ndx)
 Return a pointer to an IdSet representing a subset of "self". More...
 
int IdSet_get (const IdSet *self, int i)
 Return i'th tipId_t value.
 

Variables

long double improbable = 0.0L
 
long double pr_ignored = 0.0L
 

Detailed Description

A set of tipID_t values.

Author
Alan R. Rogers

Function Documentation

◆ IdSet_join()

IdSet * IdSet_join ( IdSet left,
IdSet right,
int  nsamples,
tipId_t *  samples 
)

Join two IdSet objects, left and right, along with all the tipId_t values in the "samples" array.

On success, function returns a pointer to the new IdSet object. If "left" and "right" represent mutually exclusive events, they cannot be joined, and the function returns NULL.

◆ IdSet_new_noEventLst()

static IdSet * IdSet_new_noEventLst ( int  nIds,
const tipId_t *  tid 
)
static

Allocate a new IdSet object with given values of nIds and tid.

Leave evlst and pr unset. This function is used only within the current file, and in each case, pr and evlst are then set by the calling function.

Referenced by IdSet_new().

◆ IdSet_partition()

void IdSet_partition ( IdSet self,
unsigned  k,
tipId_t  part[k],
unsigned  n,
unsigned  a[n] 
)

On entry, k is the number of parts into which this IdSet will be subdivided, n must equal self->nIds, and a[j] is the index of the part into which the j'th tipId_t value will be assigned.

On return, partition[i] is the union of the tipId_t values in self which belong to the i'th part.

◆ IdSet_subset()

IdSet * IdSet_subset ( const IdSet self,
int  n,
int *  ndx 
)

Return a pointer to an IdSet representing a subset of "self".

The tipId_t values of the subset are defined by "ndx", an array of n non-negative integers, which index values in the original IdSet.