libhmsbeagle/beagle.h(3)
β¨ okay bestie, buckle up β¨ this is the libhmsbeagle/beagle.h(3) page from the BEAGLE manual. It's giving header energy, it's giving API docs, and it's literally the Broad-platform Evolutionary Analysis General Likelihood Evaluator. No cap, this file is the main character of the library. π
π NAME π
libhmsbeagle/beagle.h β this file documents the API as well as the header for the Broad-platform Evolutionary Analysis General Likelihood Evaluator. It's the blueprint, the vibe, the whole package. π«Ά
β¨ SYNOPSIS β¨
First thing you do, bestie, is include the platform header. Like this, exactly:
#include 'libhmsbeagle/platform.h'
yes, it's single quotes in the manpage. I am not changing it. periodt. π
π Classes π
These are the structs chillin' in this header. Each one is a little data moment with its own job. Obsessed.
struct BeagleInstanceDetailsβ information about a specific instance. It's giving "tell me about this one instance" energy. πstruct BeagleResourceβ a description of a hardware resource. Hardware lore, but make it a struct. β¨struct BeagleResourceListβ a list of hardware resources. Simple, effective, slay. πstruct BeagleBenchmarkedResourceβ a description of a benchmarked hardware resource. It went through the benchmark vibe check. π¦struct BeagleBenchmarkedResourceListβ an ordered list of benchmarked hardware resources, from fastest to slowest. Speed ranking, periodt. πstruct BeagleOperationβ a list of integer indices which specify a partial likelihoods operation. Math girlies, rise. π₯struct BeagleOperationByPartitionβ a list of integer indices which specify a partial likelihoods operation for a partitioned analysis. Same energy, but partitioned. π
πΈ Enumerations πΈ
Enums, bestie. Named constants, but make it fashion. π
enum BeagleReturnCodes
Error return codes. When something goes sideways, one of these babies comes back to tell you what's up. π
enum BeagleReturnCodes { BEAGLE_SUCCESS = 0, BEAGLE_ERROR_GENERAL = -1,
BEAGLE_ERROR_OUT_OF_MEMORY = -2, BEAGLE_ERROR_UNIDENTIFIED_EXCEPTION
= -3, BEAGLE_ERROR_UNINITIALIZED_INSTANCE = -4,
BEAGLE_ERROR_OUT_OF_RANGE = -5, BEAGLE_ERROR_NO_RESOURCE = -6,
BEAGLE_ERROR_NO_IMPLEMENTATION = -7, BEAGLE_ERROR_FLOATING_POINT =
-8 }
enum BeagleFlags
Hardware and implementation capability flags. This is the big one, bestie. It's giving "what can this machine even do?" energy. π¦
enum BeagleFlags { BEAGLE_FLAG_PRECISION_SINGLE = 1 << 0,
BEAGLE_FLAG_PRECISION_DOUBLE = 1 << 1, BEAGLE_FLAG_COMPUTATION_SYNCH
= 1 << 2, BEAGLE_FLAG_COMPUTATION_ASYNCH = 1 << 3,
BEAGLE_FLAG_EIGEN_REAL = 1 << 4, BEAGLE_FLAG_EIGEN_COMPLEX = 1 << 5,
BEAGLE_FLAG_SCALING_MANUAL = 1 << 6, BEAGLE_FLAG_SCALING_AUTO = 1 <<
7, BEAGLE_FLAG_SCALING_ALWAYS = 1 << 8, BEAGLE_FLAG_SCALING_DYNAMIC
= 1 << 25, BEAGLE_FLAG_SCALERS_RAW = 1 << 9, BEAGLE_FLAG_SCALERS_LOG
= 1 << 10, BEAGLE_FLAG_INVEVEC_STANDARD = 1 << 20,
BEAGLE_FLAG_INVEVEC_TRANSPOSED = 1 << 21, BEAGLE_FLAG_VECTOR_SSE = 1
<< 11, BEAGLE_FLAG_VECTOR_AVX = 1 << 24, BEAGLE_FLAG_VECTOR_NONE = 1
<< 12, BEAGLE_FLAG_THREADING_CPP = 1 << 30,
BEAGLE_FLAG_THREADING_OPENMP = 1 << 13, BEAGLE_FLAG_THREADING_NONE =
1 << 14, BEAGLE_FLAG_PROCESSOR_CPU = 1 << 15,
BEAGLE_FLAG_PROCESSOR_GPU = 1 << 16, BEAGLE_FLAG_PROCESSOR_FPGA = 1
<< 17, BEAGLE_FLAG_PROCESSOR_CELL = 1 << 18,
BEAGLE_FLAG_PROCESSOR_PHI = 1 << 19, BEAGLE_FLAG_PROCESSOR_OTHER = 1
<< 26, BEAGLE_FLAG_FRAMEWORK_CUDA = 1 << 22,
BEAGLE_FLAG_FRAMEWORK_OPENCL = 1 << 23, BEAGLE_FLAG_FRAMEWORK_CPU =
1 << 27, BEAGLE_FLAG_PARALLELOPS_STREAMS = 1 << 28,
BEAGLE_FLAG_PARALLELOPS_GRID = 1 << 29 }
enum BeagleBenchmarkFlags
Benchmarking mode flags for resource performance evaluation with beagleGetOrderedResourceList. Basically: how hard do we want to vibe-check the hardware? π
enum BeagleBenchmarkFlags { BEAGLE_BENCHFLAG_SCALING_NONE = 1 << 0,
BEAGLE_BENCHFLAG_SCALING_ALWAYS = 1 << 1,
BEAGLE_BENCHFLAG_SCALING_DYNAMIC = 1 << 2 }
enum BeagleOpCodes
Operation codes. Short, sweet, and they keep the partial likelihoods ops in check. β¨
enum BeagleOpCodes { BEAGLE_OP_COUNT = 7, BEAGLE_PARTITION_OP_COUNT = 9,
BEAGLE_OP_NONE = -1 }
β¨ FUNCTIONS β¨
okay bestie, here's the whole function lineup π every signature is copied exactly, no cap, and every description is giving the same facts with extra sparkle. periodt.
beagleGetVersionβ Get version. Like, literally grab the version info, bestie. π
BEAGLE_DLLEXPORT const char * beagleGetVersion (void)
beagleGetCitationβ Get citation. The citation, bestie, so you can cite it correctly. β¨
BEAGLE_DLLEXPORT const char * beagleGetCitation (void)
beagleGetResourceListβ Get list of hardware resources. It's giving inventory energy, fr fr. π₯οΈβ¨
BEAGLE_DLLEXPORT BeagleResourceList * beagleGetResourceList (void)
beagleGetBenchmarkedResourceListβ Get a benchmarked list of hardware resources for the given analysis parameters. So many params, bestie, but it's all there. π₯
BEAGLE_DLLEXPORT BeagleBenchmarkedResourceList *
beagleGetBenchmarkedResourceList (int tipCount, int
compactBufferCount, int stateCount, int patternCount, int
categoryCount, int *resourceList, int resourceCount, long
preferenceFlags, long requirementFlags, int eigenModelCount, int
partitionCount, int calculateDerivatives, long benchmarkFlags)
beagleCreateInstanceβ Create a single instance. One instance, coming right up. π
BEAGLE_DLLEXPORT int beagleCreateInstance (int tipCount, int
partialsBufferCount, int compactBufferCount, int stateCount, int
patternCount, int eigenBufferCount, int matrixBufferCount, int
categoryCount, int scaleBufferCount, int *resourceList, int
resourceCount, long preferenceFlags, long requirementFlags,
BeagleInstanceDetails *returnInfo)
beagleFinalizeInstanceβ Finalize this instance. Wrap it up, bestie. π
BEAGLE_DLLEXPORT int beagleFinalizeInstance (int instance)
beagleFinalizeβ Finalize the library. Whole library, done. π
BEAGLE_DLLEXPORT int beagleFinalize (void)
beagleSetCPUThreadCountβ Set number of threads for native CPU implementation. Thread count go brrr. π§΅β¨
BEAGLE_DLLEXPORT int beagleSetCPUThreadCount (int instance, int
threadCount)
beagleSetTipStatesβ Set the compact state representation for tip node. Tip node states, compact style. π¦
BEAGLE_DLLEXPORT int beagleSetTipStates (int instance, int tipIndex,
const int *inStates)
beagleSetTipPartialsβ Set an instance partials buffer for tip node. Partials for the tip node, got it. πΈ
BEAGLE_DLLEXPORT int beagleSetTipPartials (int instance, int tipIndex,
const double *inPartials)
beagleSetPartialsβ Set an instance partials buffer. Just a regular partials buffer, bestie. β¨
BEAGLE_DLLEXPORT int beagleSetPartials (int instance, int bufferIndex,
const double *inPartials)
beagleGetPartialsβ Get partials from an instance buffer. Retrieve those partials. π
BEAGLE_DLLEXPORT int beagleGetPartials (int instance, int bufferIndex,
int scaleIndex, double *outPartials)
beagleSetEigenDecompositionβ Set an eigen-decomposition buffer. Eigen-decomp, set. π§
BEAGLE_DLLEXPORT int beagleSetEigenDecomposition (int instance, int
eigenIndex, const double *inEigenVectors, const double
*inInverseEigenVectors, const double *inEigenValues)
beagleSetStateFrequenciesβ Set a state frequency buffer. Frequencies, set. π
BEAGLE_DLLEXPORT int beagleSetStateFrequencies (int instance, int
stateFrequenciesIndex, const double *inStateFrequencies)
beagleSetCategoryWeightsβ Set a category weights buffer. Weights, set. π
BEAGLE_DLLEXPORT int beagleSetCategoryWeights (int instance, int
categoryWeightsIndex, const double *inCategoryWeights)
beagleSetCategoryRatesβ Set the default category rates buffer. Default rates, set. β¨
BEAGLE_DLLEXPORT int beagleSetCategoryRates (int instance, const double
*inCategoryRates)
beagleSetCategoryRatesWithIndexβ Set a category rates buffer. Rates, set. π₯
BEAGLE_DLLEXPORT int beagleSetCategoryRatesWithIndex (int instance, int
categoryRatesIndex, const double *inCategoryRates)
beagleSetPatternWeightsβ Set pattern weights. Weights for patterns, periodt. π
BEAGLE_DLLEXPORT int beagleSetPatternWeights (int instance, const double
*inPatternWeights)
beagleSetPatternPartitionsβ Set pattern partition assignments. Assign those partitions, bestie. π¦
BEAGLE_DLLEXPORT int beagleSetPatternPartitions (int instance, int
partitionCount, const int *inPatternPartitions)
beagleConvolveTransitionMatricesβ Set partitions by pattern weight. Yes, that's what it says, bestie. π
BEAGLE_DLLEXPORT int beagleConvolveTransitionMatrices (int instance,
const int *firstIndices, const int *secondIndices, const int
*resultIndices, int matrixCount)
beagleUpdateTransitionMatricesβ Calculate a list of transition probability matrices. Matrices, calculated. π₯
BEAGLE_DLLEXPORT int beagleUpdateTransitionMatrices (int instance, int
eigenIndex, const int *probabilityIndices, const int
*firstDerivativeIndices, const int *secondDerivativeIndices, const
double *edgeLengths, int count)
beagleUpdateTransitionMatricesWithMultipleModelsβ Calculate a list of transition probability matrices with multiple models. Multiple models, multiple matrices. π
BEAGLE_DLLEXPORT int beagleUpdateTransitionMatricesWithMultipleModels
(int instance, const int *eigenIndices, const int
*categoryRateIndices, const int *probabilityIndices, const int
*firstDerivativeIndices, const int *secondDerivativeIndices, const
double *edgeLengths, int count)
beagleSetTransitionMatrixβ Set a finite-time transition probability matrix. One matrix, set. π
BEAGLE_DLLEXPORT int beagleSetTransitionMatrix (int instance, int
matrixIndex, const double *inMatrix, double paddedValue)
beagleGetTransitionMatrixβ Get a finite-time transition probability matrix. One matrix, got it. β¨
BEAGLE_DLLEXPORT int beagleGetTransitionMatrix (int instance, int
matrixIndex, double *outMatrix)
beagleSetTransitionMatricesβ Set multiple transition matrices. Many matrices, set. π
BEAGLE_DLLEXPORT int beagleSetTransitionMatrices (int instance, const
int *matrixIndices, const double *inMatrices, const double
*paddedValues, int count)
beagleUpdatePartialsβ Calculate or queue for calculation partials using a list of operations. Queue it up or calculate it, your call. π§
BEAGLE_DLLEXPORT int beagleUpdatePartials (const int instance, const
BeagleOperation *operations, int operationCount, int
cumulativeScaleIndex)
beagleUpdatePartialsByPartitionβ Calculate or queue for calculation partials using a list of partition operations. Partition operations, same energy. π
BEAGLE_DLLEXPORT int beagleUpdatePartialsByPartition (const int
instance, const BeagleOperationByPartition *operations, int
operationCount)
beagleWaitForPartialsβ Block until all calculations that write to the specified partials have completed. Blocking, bestie, like waiting for your boba order. π§
BEAGLE_DLLEXPORT int beagleWaitForPartials (const int instance, const
int *destinationPartials, int destinationPartialsCount)
beagleAccumulateScaleFactorsβ Accumulate scale factors. Stack 'em up. π
BEAGLE_DLLEXPORT int beagleAccumulateScaleFactors (int instance, const
int *scaleIndices, int count, int cumulativeScaleIndex)
beagleAccumulateScaleFactorsByPartitionβ Accumulate scale factors by partition. Per partition, stack 'em. ποΈ
BEAGLE_DLLEXPORT int beagleAccumulateScaleFactorsByPartition (int
instance, const int *scaleIndices, int count, int
cumulativeScaleIndex, int partitionIndex)
beagleRemoveScaleFactorsβ Remove scale factors. Yeet those scale factors. π
BEAGLE_DLLEXPORT int beagleRemoveScaleFactors (int instance, const int
*scaleIndices, int count, int cumulativeScaleIndex)
beagleRemoveScaleFactorsByPartitionβ Remove scale factors by partition. Per partition, yeet. π
BEAGLE_DLLEXPORT int beagleRemoveScaleFactorsByPartition (int instance,
const int *scaleIndices, int count, int cumulativeScaleIndex, int
partitionIndex)
beagleResetScaleFactorsβ Reset scalefactors. Reset, no cap. π
BEAGLE_DLLEXPORT int beagleResetScaleFactors (int instance, int
cumulativeScaleIndex)
beagleResetScaleFactorsByPartitionβ Reset scalefactors by partition. Per partition reset. π
BEAGLE_DLLEXPORT int beagleResetScaleFactorsByPartition (int instance,
int cumulativeScaleIndex, int partitionIndex)
beagleCopyScaleFactorsβ Copy scale factors. Copy-paste energy. π
BEAGLE_DLLEXPORT int beagleCopyScaleFactors (int instance, int
destScalingIndex, int srcScalingIndex)
beagleGetScaleFactorsβ Get scale factors. Retrieve those scale factors. π
BEAGLE_DLLEXPORT int beagleGetScaleFactors (int instance, int
srcScalingIndex, double *outScaleFactors)
beagleCalculateRootLogLikelihoodsβ Calculate site log likelihoods at a root node. Root node log likelihoods, calculated. π³
BEAGLE_DLLEXPORT int beagleCalculateRootLogLikelihoods (int instance,
const int *bufferIndices, const int *categoryWeightsIndices, const
int *stateFrequenciesIndices, const int *cumulativeScaleIndices, int
count, double *outSumLogLikelihood)
beagleCalculateRootLogLikelihoodsByPartitionβ Calculate site log likelihoods at a root node with per partition buffers. Per partition buffers, root node. ποΈ
BEAGLE_DLLEXPORT int beagleCalculateRootLogLikelihoodsByPartition (int
instance, const int *bufferIndices, const int
*categoryWeightsIndices, const int *stateFrequenciesIndices, const
int *cumulativeScaleIndices, const int *partitionIndices, int
partitionCount, int count, double *outSumLogLikelihoodByPartition,
double *outSumLogLikelihood)
beagleCalculateEdgeLogLikelihoodsβ Calculate site log likelihoods and derivatives along an edge. Edge likelihoods and derivatives, slay. π₯
BEAGLE_DLLEXPORT int beagleCalculateEdgeLogLikelihoods (int instance,
const int *parentBufferIndices, const int *childBufferIndices, const
int *probabilityIndices, const int *firstDerivativeIndices, const
int *secondDerivativeIndices, const int *categoryWeightsIndices,
const int *stateFrequenciesIndices, const int
*cumulativeScaleIndices, int count, double *outSumLogLikelihood,
double *outSumFirstDerivative, double *outSumSecondDerivative)
beagleCalculateEdgeLogLikelihoodsByPartitionβ Calculate multiple site log likelihoods and derivatives along an edge with per partition buffers. Multiple sites, per partition buffers. π
BEAGLE_DLLEXPORT int beagleCalculateEdgeLogLikelihoodsByPartition (int
instance, const int *parentBufferIndices, const int
*childBufferIndices, const int *probabilityIndices, const int
*firstDerivativeIndices, const int *secondDerivativeIndices, const
int *categoryWeightsIndices, const int *stateFrequenciesIndices,
const int *cumulativeScaleIndices, const int *partitionIndices, int
partitionCount, int count, double *outSumLogLikelihoodByPartition,
double *outSumLogLikelihood, double
*outSumFirstDerivativeByPartition, double *outSumFirstDerivative,
double *outSumSecondDerivativeByPartition, double
*outSumSecondDerivative)
beagleGetLogLikelihoodβ Returns log likelihood sum and subsequent to an asynchronous integration call. Async call, then get the sum. β³
BEAGLE_DLLEXPORT int beagleGetLogLikelihood (int instance, double
*outSumLogLikelihood)
beagleGetDerivativesβ Returns derivative sums subsequent to an asynchronous integration call. Async call, then derivative sums. π
BEAGLE_DLLEXPORT int beagleGetDerivatives (int instance, double
*outSumFirstDerivative, double *outSumSecondDerivative)
beagleGetSiteLogLikelihoodsβ Get site log likelihoods for last beagleCalculateRootLogLikelihoods or beagleCalculateEdgeLogLikelihoods call. For the last call, get site log likelihoods. π
BEAGLE_DLLEXPORT int beagleGetSiteLogLikelihoods (int instance, double
*outLogLikelihoods)
beagleGetSiteDerivativesβ Get site derivatives for last beagleCalculateEdgeLogLikelihoods call. For the last edge call, get site derivatives. β¨
BEAGLE_DLLEXPORT int beagleGetSiteDerivatives (int instance, double
*outFirstDerivatives, double *outSecondDerivatives)
Detailed Description π
okay so this file is the documentation for the API and the header of the Broad-platform Evolutionary Analysis General Likelihood Evaluator. iconic behavior honestly.
Copyright 2009-2013 Phylogenetic Likelihood Working Group
This file is part of BEAGLE.
BEAGLE is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
BEAGLE 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with BEAGLE. If not, see <http://www.gnu.org/licenses/>.
π KEY CONCEPTS π
bestie, the whole point of BEAGLE's speed is fine-scale parallelization while keeping data transfer and memory copy overhead as tiny as possible. and the way they do that?? the library literally has no concept of a data structure for a tree, even though phylogenetics is literally the whole reason it exists. wild, right? π
instead, BEAGLE acts directly on flexibly indexed data storage β called buffers β for observed character states and partial likelihoods. your client program sets up the input buffers to reflect the data, then calculates the likelihood of a particular phylogeny by invoking likelihood calculations on the appropriate input and output buffers in the correct order. no cap.
and because of that design simplicity, the library can support so many different tree inference algorithms and likelihood calculation on a whole variety of models. like:
- arbitrary numbers of states can be used
- nonreversible substitution matrices via complex eigen decompositions
- mixture models with multiple rate categories and/or multiple eigen decompositions
finally β and this is the slay part β BEAGLE application programming interface (API) calls can be asynchronous, which lets the calling program implement other coarse-scale parallelization schemes, like evaluating independent genes or running concurrent Markov chains. main character energy fr fr. π
π οΈ USAGE π οΈ
okay so to actually use this thing, a client program first creates an instance of BEAGLE by calling beagleCreateInstance. and listen β multiple instances per client are possible and encouraged. yes bestie, go off. all the other functions get called with a reference to this instance.
the client program can optionally request that an instance run on certain hardware (like a GPU π) or have particular features (like double-precision math β¨).
next up, the client program must specify the data dimensions and specify key aspects of the phylogenetic model. then character state data get loaded, and they can be either discrete observed states or partial likelihoods for ambiguous characters. the observed data are usually unchanging and loaded only once at the start β that's to minimize memory copy overhead, iykyk. the character data can be compressed into unique "site patterns" plus associated weights for each one.
then the parameters of the substitution process get specified, including:
- the equilibrium state frequencies
- the rates for one or more substitution rate categories, and their weights
- and finally, the eigen decomposition for the substitution process
so to calculate the likelihood of a particular tree, the client program then specifies a series of integration operations that correspond to steps in Felsenstein's algorithm. π¦
finite-time transition probabilities for each edge are loaded directly if you're considering a nondiagonalizable model, or else calculated in parallel from the eigen decomposition and the edge lengths specified. all of this happens inside BEAGLE's memory space, to keep data transfers minimal. periodt.
then a single function call requests one or more integration operations to calculate partial likelihoods over some or all nodes. the operations are performed in the order they are provided, typically dictated by a postorder traversal of the tree topology. the client only needs to specify nodes for which the partial likelihoods need updating β but tracking those dependencies?? that's on the calling software, bestie. π
the final step in evaluating the phylogenetic model is done with an API call that yields a single log likelihood for the model given the data. chef's kiss. π
aspects of the BEAGLE API design support both maximum likelihood (ML) and Bayesian phylogenetic tree inference. for ML inference, API calls can calculate first and second derivatives of the likelihood with respect to the lengths of edges (branches). in both cases, BEAGLE provides the ability to cache and reuse previously computed partial likelihood results, which can yield a tremendous speedup over recomputing the entire likelihood every time a new phylogenetic model is evaluated. obsessed.
Author π
Likelihood API Working Group
- Daniel Ayres
- Peter Beerli
- Michael Cummings
- Aaron Darling
- Mark Holder
- John Huelsenbeck
- Paul Lewis
- Michael Ott
- Andrew Rambaut
- Fredrik Ronquist
- Marc Suchard
- David Swofford
- Derrick Zwickl
π Enumeration Type Documentation π
enum BeagleBenchmarkFlags
Benchmarking mode flags for resource performance evaluation with beagleGetOrderedResourceList.
this one enumerates all possible benchmarking mode flags. each mode is a bit in a long. π«
Enumerator
BEAGLE_BENCHFLAG_SCALING_NONEβ no scalingBEAGLE_BENCHFLAG_SCALING_ALWAYSβ scale at every iterationBEAGLE_BENCHFLAG_SCALING_DYNAMICβ scale every fixed number of iterations, or when a numerical error occurs, and re-use scale factors for subsequent iterations
enum BeagleFlags
Hardware and implementation capability flags.
this one enumerates all possible hardware and implementation capability flags. each capability is a bit in a long. β
Enumerator
BEAGLE_FLAG_PRECISION_SINGLEβ single precision computationBEAGLE_FLAG_PRECISION_DOUBLEβ double precision computationBEAGLE_FLAG_COMPUTATION_SYNCHβ synchronous computation (blocking)BEAGLE_FLAG_COMPUTATION_ASYNCHβ asynchronous computation (non-blocking)BEAGLE_FLAG_EIGEN_REALβ real eigenvalue computationBEAGLE_FLAG_EIGEN_COMPLEXβ complex eigenvalue computationBEAGLE_FLAG_SCALING_MANUALβ manual scalingBEAGLE_FLAG_SCALING_AUTOβ auto-scaling on (deprecated, may not work correctly)BEAGLE_FLAG_SCALING_ALWAYSβ scale at everyupdatePartials(deprecated, may not work correctly)BEAGLE_FLAG_SCALING_DYNAMICβ manual scaling with dynamic checking (deprecated, may not work correctly)BEAGLE_FLAG_SCALERS_RAWβ save raw scalersBEAGLE_FLAG_SCALERS_LOGβ save log scalersBEAGLE_FLAG_INVEVEC_STANDARDβ inverse eigen vectors passed to BEAGLE have not been transposedBEAGLE_FLAG_INVEVEC_TRANSPOSEDβ inverse eigen vectors passed to BEAGLE have been transposedBEAGLE_FLAG_VECTOR_SSEβ SSE computationBEAGLE_FLAG_VECTOR_AVXβ AVX computationBEAGLE_FLAG_VECTOR_NONEβ no vector computationBEAGLE_FLAG_THREADING_CPPβ C++11 threadingBEAGLE_FLAG_THREADING_OPENMPβ OpenMP threadingBEAGLE_FLAG_THREADING_NONEβ no threading (default)BEAGLE_FLAG_PROCESSOR_CPUβ use CPU as main processorBEAGLE_FLAG_PROCESSOR_GPUβ use GPU as main processorBEAGLE_FLAG_PROCESSOR_FPGAβ use FPGA as main processorBEAGLE_FLAG_PROCESSOR_CELLβ use Cell as main processorBEAGLE_FLAG_PROCESSOR_PHIβ use Intel Phi as main processorBEAGLE_FLAG_PROCESSOR_OTHERβ use other type of processorBEAGLE_FLAG_FRAMEWORK_CUDAβ use CUDA implementation with GPU resourcesBEAGLE_FLAG_FRAMEWORK_OPENCLβ use OpenCL implementation with GPU resourcesBEAGLE_FLAG_FRAMEWORK_CPUβ use CPU implementationBEAGLE_FLAG_PARALLELOPS_STREAMSβ operations inupdatePartialsmay be assigned to separate device streamsBEAGLE_FLAG_PARALLELOPS_GRIDβ operations inupdatePartialsmay be folded into a single kernel launch (necessary for partitions; typically performs better for problems with fewer pattern sites)
enum BeagleOpCodes
Operation codes.
this one enumerates all possible BEAGLE operation codes. π
Enumerator
BEAGLE_OP_COUNTβ total number of integers perbeagleUpdatePartialsoperationBEAGLE_PARTITION_OP_COUNTβ total number of integers perbeagleUpdatePartialsByPartitionoperationBEAGLE_OP_NONEβ specify no use for indexed buffer
enum BeagleReturnCodes
Error return codes.
this one enumerates all possible BEAGLE return codes. and heads up bestie: error codes are always negative. π
Enumerator
BEAGLE_SUCCESSβ success πBEAGLE_ERROR_GENERALβ unspecified errorBEAGLE_ERROR_OUT_OF_MEMORYβ not enough memory could be allocatedBEAGLE_ERROR_UNIDENTIFIED_EXCEPTIONβ unspecified exceptionBEAGLE_ERROR_UNINITIALIZED_INSTANCEβ the instance index is out of range, or the instance has not been createdBEAGLE_ERROR_OUT_OF_RANGEβ one of the indices specified exceeded the range of the arrayBEAGLE_ERROR_NO_RESOURCEβ no resource matches requirementsBEAGLE_ERROR_NO_IMPLEMENTATIONβ no implementation matches requirementsBEAGLE_ERROR_FLOATING_POINTβ floating-point error (e.g.,NaN)
π§ Function Documentation π§
BEAGLE_DLLEXPORT int beagleAccumulateScaleFactors (int instance, const int * scaleIndices, int count, int cumulativeScaleIndex)
Accumulate scale factors. π«
this function adds (log) scale factors from a list of scaleBuffers to a cumulative scale buffer. it's used to calculate the marginal scaling at a specific node for each site.
Parameters
instanceβ instance number (input)scaleIndicesβ list ofscaleBuffersto add (input)countβ number ofscaleBuffersin list (input)cumulativeScaleIndexβ index number ofscaleBufferto accumulate factors into (input)
BEAGLE_DLLEXPORT int beagleAccumulateScaleFactorsByPartition (int instance, const int * scaleIndices, int count, int cumulativeScaleIndex, int partitionIndex)
Accumulate scale factors by partition. πΈ
this function adds (log) scale factors from a list of scaleBuffers to a cumulative scale buffer. it's used to calculate the marginal scaling at a specific node for each site.
Parameters
okay so real quick, here's the parameter rundown for the function we were just talking about:
instanceβ Instance number (input)scaleIndicesβ List ofscaleBuffersto add (input)countβ Number ofscaleBuffersin list (input)cumulativeScaleIndexβ Index number ofscaleBufferto accumulate factors into (input)partitionIndexβ Index of partition to accumulate into (input)
beagleCalculateEdgeLogLikelihoods π
BEAGLE_DLLEXPORT int beagleCalculateEdgeLogLikelihoods (int instance, const int * parentBufferIndices, const int * childBufferIndices, const int * probabilityIndices, const int * firstDerivativeIndices, const int * secondDerivativeIndices, const int * categoryWeightsIndices, const int * stateFrequenciesIndices, const int * cumulativeScaleIndices, int count, double * outSumLogLikelihood, double * outSumFirstDerivative, double * outSumSecondDerivative)
Calculate site log likelihoods and derivatives along an edge. Bestie, this one integrates a list of partials at a parent and child node with respect to a set of partials-weights and state frequencies, and hands you back the log likelihood plus the first and second derivative sums. it's giving math girlboss energy ngl β¨
Parameters
instanceβ Instance number (input)parentBufferIndicesβ List of indices of parentpartialsBuffers(input)childBufferIndicesβ List of indices of childpartialsBuffers(input)probabilityIndicesβ List indices of transition probability matrices for this edge (input)firstDerivativeIndicesβ List indices of first derivative matrices (input)secondDerivativeIndicesβ List indices of second derivative matrices (input)categoryWeightsIndicesβ List of weights to apply to eachpartialsBuffer(input)stateFrequenciesIndicesβ List of state frequencies for eachpartialsBuffer(input). There should be one set for each ofparentBufferIndicescumulativeScaleIndicesβ List ofscaleBufferscontaining accumulated factors to apply to eachpartialsBuffer(input). There should be one index for each ofparentBufferIndicescountβ Number ofpartialsBuffers(input)outSumLogLikelihoodβ Pointer to destination for resulting log likelihood (output)outSumFirstDerivativeβ Pointer to destination for resulting first derivative (output)outSumSecondDerivativeβ Pointer to destination for resulting second derivative (output)
Returns
error code π
beagleCalculateEdgeLogLikelihoodsByPartition π¦
BEAGLE_DLLEXPORT int beagleCalculateEdgeLogLikelihoodsByPartition (int instance, const int * parentBufferIndices, const int * childBufferIndices, const int * probabilityIndices, const int * firstDerivativeIndices, const int * secondDerivativeIndices, const int * categoryWeightsIndices, const int * stateFrequenciesIndices, const int * cumulativeScaleIndices, const int * partitionIndices, int partitionCount, int count, double * outSumLogLikelihoodByPartition, double * outSumLogLikelihood, double * outSumFirstDerivativeByPartition, double * outSumFirstDerivative, double * outSumSecondDerivativeByPartition, double * outSumSecondDerivative)
Calculate multiple site log likelihoods and derivatives along an edge with per partition buffers. same vibe as the last one, except it integrates lists of partials at a parent and child node w.r.t. a set of partials-weights and state frequencies, and returns the log likelihood and first and second derivative sums β but now with partition flavor πΈ
Parameters
instanceβ Instance number (input)parentBufferIndicesβ List of indices of parentpartialsBuffers(input)childBufferIndicesβ List of indices of childpartialsBuffers(input)probabilityIndicesβ List indices of transition probability matrices for this edge (input)firstDerivativeIndicesβ List indices of first derivative matrices (input)secondDerivativeIndicesβ List indices of second derivative matrices (input)categoryWeightsIndicesβ List of weights to apply to eachpartialsBuffer(input)stateFrequenciesIndicesβ List of state frequencies for eachpartialsBuffer(input). There should be one set for each ofparentBufferIndicescumulativeScaleIndicesβ List ofscaleBufferscontaining accumulated factors to apply to eachpartialsBuffer(input). There should be one index for each ofparentBufferIndicespartitionIndicesβ List of partition indices indicating which sites in eachpartialsBuffershould be used (input). There should be one index for each ofparentBufferIndicespartitionCountβ Number of distinctpartitionIndices(input)countβ Number of sets of partitions to integrate across (input)outSumLogLikelihoodByPartitionβ Pointer to destination for resulting log likelihoods for each partition (output)outSumLogLikelihoodβ Pointer to destination for resulting log likelihood (output)outSumFirstDerivativeByPartitionβ Pointer to destination for resulting first derivative for each partition (output)outSumFirstDerivativeβ Pointer to destination for resulting first derivative (output)outSumSecondDerivativeByPartitionβ Pointer to destination for resulting second derivative for each partition (output)outSumSecondDerivativeβ Pointer to destination for resulting second derivative (output)
Returns
error code π
beagleCalculateRootLogLikelihoods πΏ
BEAGLE_DLLEXPORT int beagleCalculateRootLogLikelihoods (int instance, const int * bufferIndices, const int * categoryWeightsIndices, const int * stateFrequenciesIndices, const int * cumulativeScaleIndices, int count, double * outSumLogLikelihood)
Calculate site log likelihoods at a root node. this one integrates a list of partials at a node with respect to a set of partials-weights and state frequencies, and gives you the log likelihood sum. root node said main character fr fr π
Parameters
instanceβ Instance number (input)bufferIndicesβ List ofpartialsBufferindices to integrate (input)categoryWeightsIndicesβ List of weights to apply to eachpartialsBuffer(input). There should be onecategoryCountsized set for each ofparentBufferIndicesstateFrequenciesIndicesβ List of state frequencies for eachpartialsBuffer(input). There should be one set for each ofparentBufferIndicescumulativeScaleIndicesβ List ofscaleBufferscontaining accumulated factors to apply to eachpartialsBuffer(input). There should be one index for each ofparentBufferIndicescountβ Number ofpartialsBufferto integrate (input)outSumLogLikelihoodβ Pointer to destination for resulting log likelihood (output)
Returns
error code π
beagleCalculateRootLogLikelihoodsByPartition π«Ά
BEAGLE_DLLEXPORT int beagleCalculateRootLogLikelihoodsByPartition (int instance, const int * bufferIndices, const int * categoryWeightsIndices, const int * stateFrequenciesIndices, const int * cumulativeScaleIndices, const int * partitionIndices, int partitionCount, int count, double * outSumLogLikelihoodByPartition, double * outSumLogLikelihood)
Calculate site log likelihoods at a root node with per partition buffers. integrates lists of partials at a node w.r.t. a set of partials-weights and state frequencies, and returns the log likelihood sums β partitions edition π
Parameters
instanceβ Instance number (input)bufferIndicesβ List ofpartialsBufferindices to integrate (input)categoryWeightsIndicesβ List of weights to apply to eachpartialsBuffer(input). There should be onecategoryCountsized set for each ofbufferIndicesstateFrequenciesIndicesβ List of state frequencies for eachpartialsBuffer(input). There should be one set for each ofbufferIndicescumulativeScaleIndicesβ List ofscaleBufferscontaining accumulated factors to apply to eachpartialsBuffer(input). There should be one index for each ofbufferIndicespartitionIndicesβ List of partition indices indicating which sites in eachpartialsBuffershould be used (input). There should be one index for each ofbufferIndicespartitionCountβ Number of distinctpartitionIndices(input)countβ Number of sets of partitions to integrate across (input)outSumLogLikelihoodByPartitionβ Pointer to destination for resulting log likelihoods for each partition (output)outSumLogLikelihoodβ Pointer to destination for resulting log likelihood (output)
Returns
error code π
beagleConvolveTransitionMatrices β
BEAGLE_DLLEXPORT int beagleConvolveTransitionMatrices (int instance, const int * firstIndices, const int * secondIndices, const int * resultIndices, int matrixCount)
Set partitions by pattern weight. okay so this function defines partitions by setting their vectors of pattern-weights for an instance. heads up bestie: it should be called after beagleSetTipPartials or beagleSetTipStates. don't skip that step, it's giving order matters π
Parameters
instanceβ Instance number (input)inPartitionPatternWeightsβpartitionCountarrays, each containingpatternCountpattern weights (input)partitionCountβ Number of partitions (input)
Returns
error code π
Convolve lists of transition probability matrices
This function convolves two lists of transition probability matrices. (yes, the description above is doing its own thing, we don't question the manpage, we just report it π)
Parameters
instanceβ Instance number (input)firstIndicesβ List of indices of the first transition probability matrices to convolve (input)secondIndicesβ List of indices of the second transition probability matrices to convolve (input)resultIndicesβ List of indices of resulting transition probability matrices (input)matrixCountβ Length of lists
beagleCopyScaleFactors π
BEAGLE_DLLEXPORT int beagleCopyScaleFactors (int instance, int destScalingIndex, int srcScalingIndex)
Copy scale factors. literally just copies scale factors from one buffer to another. no thoughts, just vibes β¨
Parameters
instanceβ Instance number (input)destScalingIndexβ DestinationscaleBuffer(input)srcScalingIndexβ SourcescaleBuffer(input)
beagleCreateInstance π
BEAGLE_DLLEXPORT int beagleCreateInstance (int tipCount, int partialsBufferCount, int compactBufferCount, int stateCount, int patternCount, int eigenBufferCount, int matrixBufferCount, int categoryCount, int scaleBufferCount, int * resourceList, int resourceCount, long preferenceFlags, long requirementFlags, BeagleInstanceDetails * returnInfo)
Create a single instance. this function creates a single instance of the BEAGLE library, and bestie you can call it multiple times to create multiple data partition instances β each one returning a unique identifier π
okay bestie, so the function that hands you back the unique instance id β here's the full tea on what you pass in: β¨
tipCountβ Number of tip data elements (input) π¦partialsBufferCountβ Number of partials buffers to create (input) πcompactBufferCountβ Number of compact state representation buffers to create (input) πstateCountβ Number of states in the continuous-time Markov chain (input) πΈpatternCountβ Number of site patterns to be handled by the instance (input) πeigenBufferCountβ Number of rate matrix eigen-decomposition, category weight, category rates, and state frequency buffers to allocate (input) πmatrixBufferCountβ Number of transition probability matrix buffers (input) π₯categoryCountβ Number of rate categories (input) πscaleBufferCountβ Number of scale buffers to create, ignored for auto scale or always scale (input) βresourceListβ List of potential resources on which this instance is allowed (input,NULLimplies no restriction) πresourceCountβ Length ofresourceListlist (input) πpreferenceFlagsβ Bit-flags indicating preferred implementation characteristics, seeBeagleFlags(input) π§requirementFlagsβ Bit-flags indicating required implementation characteristics, seeBeagleFlags(input) πreturnInfoβ Pointer to return implementation and resource details π«Ά
Returns: the unique instance identifier (<0 if failed, see BeagleReturnCodes) π
beagleFinalize β the big goodbye π
BEAGLE_DLLEXPORT int beagleFinalize (void)
Finalize the library. This function finalizes the library and releases all allocated memory. This function is automatically called under GNU C via attribute ((destructor)).
Returns: error code
beagleFinalizeInstance β one instance, peace out βοΈ
BEAGLE_DLLEXPORT int beagleFinalizeInstance (int instance)
Finalize this instance. This function finalizes the instance by releasing allocated memory
Parameters:
instanceβ Instance number
Returns: error code
beagleGetBenchmarkedResourceList β the hardware speed dating π
BEAGLE_DLLEXPORT BeagleBenchmarkedResourceList*
beagleGetBenchmarkedResourceList (int tipCount, int compactBufferCount,
int stateCount, int patternCount, int categoryCount, int * resourceList,
int resourceCount, long preferenceFlags, long requirementFlags, int
eigenModelCount, int partitionCount, int calculateDerivatives, long
benchmarkFlags)
Get a benchmarked list of hardware resources for the given analysis parameters. This function returns a pointer to a BeagleBenchmarkedResourceList struct, which includes a BeagleBenchmarkedResource array describing the available hardware resources with benchmark times and CPU performance ratios for each resource. Resources are benchmarked with the given analysis parameters and the array is ordered from fastest to slowest. If there is an error the function returns NULL.
Parameters:
tipCountβ Number of tip data elements (input)compactBufferCountβ Number of compact state representation tips (input)stateCountβ Number of states in the continuous-time Markov chain (input)patternCountβ Number of site patterns (input)categoryCountβ Number of rate categories (input)resourceListβ List of resources to be benchmarked,NULLimplies no restriction (input)resourceCountβ Length ofresourceListlist (input)preferenceFlagsβ Bit-flags indicating preferred implementation characteristics, seeBeagleFlags(input)requirementFlagsβ Bit-flags indicating required implementation characteristics, seeBeagleFlags(input)eigenModelCountβ Number of full-alignment rate matrix eigen-decomposition models (input)partitionCountβ Number of partitions (input)calculateDerivativesβ Indicates if calculation of derivatives are required (input)benchmarkFlagsβ Bit-flags indicating benchmarking preferences (input)
Returns: An ordered (fastest to slowest) list of hardware resources available to the library as a BeagleBenchmarkedResourceList for the specified analysis parameters
beagleGetCitation β cite your faves π
BEAGLE_DLLEXPORT const char* beagleGetCitation (void)
Get citation. This function returns a pointer to a string describing the version of the library and how to cite it.
Returns: A string describing the version of the library and how to cite it
beagleGetDerivatives β async girlies only π
BEAGLE_DLLEXPORT int beagleGetDerivatives (int instance, double *
outSumFirstDerivative, double * outSumSecondDerivative)
Returns derivative sums subsequent to an asynchronous integration call. This function is optional and only has to be called by clients that use the non-blocking asynchronous computation mode (BEAGLE_FLAG_COMPUTATION_ASYNCH).
If used, this function must be called after a beagleCalculateEdgeLogLikelihoods call. The library will block until the derivatives have been calculated.
Parameters:
instanceβ Instance number (input)outSumFirstDerivativeβ Pointer to destination for resulting first derivative (output)outSumSecondDerivativeβ Pointer to destination for resulting second derivative (output)
Returns: error code
beagleGetLogLikelihood β the likelihood tea β
BEAGLE_DLLEXPORT int beagleGetLogLikelihood (int instance, double *
outSumLogLikelihood)
Returns log likelihood sum and subsequent to an asynchronous integration call. This function is optional and only has to be called by clients that use the non-blocking asynchronous computation mode (BEAGLE_FLAG_COMPUTATION_ASYNCH).
If used, this function must be called after a beagleCalculateRootLogLikelihoods or beagleCalculateEdgeLogLikelihoods call. The library will block until the likelihood has been calculated.
Parameters:
instanceβ Instance number (input)outSumLogLikelihoodβ Pointer to destination for resulting log likelihood (output)
Returns: error code
beagleGetPartials β grab those partials π«Ά
BEAGLE_DLLEXPORT int beagleGetPartials (int instance, int bufferIndex, int
scaleIndex, double * outPartials)
Get partials from an instance buffer. This function copies an instance buffer into the array outPartials. The outPartials array should be stateCount * patternCount * categoryCount in length.
Parameters:
instanceβ Instance number from which to getpartialsBuffer(input)bufferIndexβ Index of sourcepartialsBuffer(input)scaleIndexβ Index ofscaleBufferto apply topartialsBuffer(input)outPartialsβ Pointer to which to receivepartialsBuffer(output)
Returns: error code
beagleGetResourceList β hardware menu π
BEAGLE_DLLEXPORT BeagleResourceList* beagleGetResourceList (void)
Get list of hardware resources. This function returns a pointer to a BeagleResourceList struct, which includes a BeagleResource array describing the available hardware resources.
Returns: A list of hardware resources available to the library as a BeagleResourceList
beagleGetScaleFactors β scale factor vibes β
BEAGLE_DLLEXPORT int beagleGetScaleFactors (int instance, int
srcScalingIndex, double * outScaleFactors)
Get scale factors. This function retrieves a buffer of scale factors.
Parameters:
instanceβ Instance number (input)srcScalingIndexβ SourcescaleBuffer(input)outScaleFactorsβ Pointer to which to receivescaleFactors(output)
beagleGetSiteDerivatives β per-site derivatives, periodt π
BEAGLE_DLLEXPORT int beagleGetSiteDerivatives (int instance, double *
outFirstDerivatives, double * outSecondDerivatives)
Get site derivatives for last beagleCalculateEdgeLogLikelihoods call. This function returns the derivatives for each site
Parameters:
instanceβ Instance number (input)outFirstDerivativesβ Pointer to destination for resulting first derivatives (output)outSecondDerivativesβ Pointer to destination for resulting second derivatives (output)
Returns: error code
beagleGetSiteLogLikelihoods β per-site log-likelihoods πΈ
BEAGLE_DLLEXPORT int beagleGetSiteLogLikelihoods (int instance, double *
outLogLikelihoods)
Get site log likelihoods for last beagleCalculateRootLogLikelihoods or beagleCalculateEdgeLogLikelihoods call. This function returns the log likelihoods for each site
Parameters:
instanceβ Instance number (input)outLogLikelihoodsβ Pointer to destination for resulting log likelihoods (output)
Returns: error code
beagleGetTransitionMatrix β matrix moment π
BEAGLE_DLLEXPORT int beagleGetTransitionMatrix (int instance, int
matrixIndex, double * outMatrix)
Get a finite-time transition probability matrix. This function copies a finite-time transition matrix buffer into the array outMatrix. The outMatrix array should be of size stateCount * stateCount * categoryCount and will be filled with one matrix for each rate category.
Parameters:
instanceβ Instance number (input)matrixIndexβ Index of matrix buffer (input)outMatrixβ Pointer to destination transition probability matrix (output)
Returns: error code
beagleGetVersion β what's the version, bestie? π¦
BEAGLE_DLLEXPORT const char* beagleGetVersion (void)
Get version. This function returns a pointer to a string with the library version number.
Returns: A string with the version number
beagleRemoveScaleFactors β bye-bye scale factors π
BEAGLE_DLLEXPORT int beagleRemoveScaleFactors (int instance, const int *
scaleIndices, int count, int cumulativeScaleIndex)
Remove scale factors. This function removes (log) scale factors from a cumulative scale buffer. The scale factors to be removed are indicated in a list of scaleBuffers.
Parameters:
instanceβ Instance number (input)scaleIndicesβ List ofscaleBuffersto remove (input)countβ Number ofscaleBuffersin list (input)cumulativeScaleIndexβ Index number ofscaleBuffercontaining accumulated factors (input)
beagleRemoveScaleFactorsByPartition β partition-specific removal π
BEAGLE_DLLEXPORT int beagleRemoveScaleFactorsByPartition (int instance,
const int * scaleIndices, int count, int cumulativeScaleIndex, int
partitionIndex)
Remove scale factors by partition. This function removes (log) scale factors from a cumulative scale buffer. The scale factors to be removed are indicated in a list of scaleBuffers.
Parameters:
instanceβ Instance number (input)scaleIndicesβ List ofscaleBuffersto remove (input)countβ Number ofscaleBuffersin list (input)cumulativeScaleIndexβ Index number ofscaleBuffercontaining accumulated factors (input)partitionIndexβ Index of partition to remove from (input)
beagleResetScaleFactors β reset the scale factors π
BEAGLE_DLLEXPORT int beagleResetScaleFactors (int instance, int
cumulativeScaleIndex)
Reset scalefactors. This function resets a cumulative scale buffer.
Parameters:
instanceβ Instance number (input)cumulativeScaleIndexβ Index number of cumulativescaleBuffer(input)
beagleResetScaleFactorsByPartition β reset by partition, slay β¨
BEAGLE_DLLEXPORT int beagleResetScaleFactorsByPartition (int instance, int
cumulativeScaleIndex, int partitionIndex)
Reset scalefactors by partition. This function resets a cumulative scale buffer.
Parameters:
instanceβ Instance number (input)cumulativeScaleIndexβ Index number of cumulativescaleBuffer(input)partitionIndexβ Index of partition to reset (input)
beagleSetCategoryRates β set those rates π
BEAGLE_DLLEXPORT int beagleSetCategoryRates (int instance, const double *
inCategoryRates)
Set the default category rates buffer. This function sets the default vector of category rates for an instance.
okay so finishing up the deets on the function from before π (the one whose heading already went by, you know the vibe):
Parameters
instanceβ the instance number, and yeah it's an inputinCategoryRatesβ array holdingcategoryCountrate scalers, also input
Returns
- error code, bestie
πΈ beagleSetCategoryRatesWithIndex πΈ
BEAGLE_DLLEXPORT int beagleSetCategoryRatesWithIndex (int instance, int categoryRatesIndex, const double * inCategoryRates)
okay so this one sets a category rates buffer β like, it takes the vector of category rates and drops it into a specific buffer inside an instance. not all buffers, that buffer. iykyk β¨
Parameters
instanceβ instance number (input)categoryRatesIndexβ the index of the category rates buffer you're targeting (input)inCategoryRatesβ array containingcategoryCountrate scalers (input)
Returns
- error code π«Ά
π beagleSetCategoryWeights π
BEAGLE_DLLEXPORT int beagleSetCategoryWeights (int instance, int categoryWeightsIndex, const double * inCategoryWeights)
set a category weights buffer!! it literally just copies a category weights array into an instance buffer. no drama, no plot twist, just copying β¨
Parameters
instanceβ instance number (input)categoryWeightsIndexβ index of the category weights buffer (input)inCategoryWeightsβ the category weights array, sizedcategoryCount(input)
Returns
- error code π
π¦ beagleSetCPUThreadCount π¦
BEAGLE_DLLEXPORT int beagleSetCPUThreadCount (int instance, int threadCount)
so this sets how many threads the native CPU implementation gets to use β like, the max number of worker threads. the lore:
- it should only be called after
beagleCreateInstanceβ οΈ - it requires the
BEAGLE_FLAG_THREADING_CPPflag to be set - it has no effect on GPU-based implementations, periodt
- it also has no effect with the default
BEAGLE_FLAG_THREADING_NONEsetting - if
BEAGLE_FLAG_THREADING_CPPis set and you never call this function, BEAGLE will use a heuristic to pick an appropriate number of threads for you. main character energy fr fr π§
Parameters
instanceβ instance number (input)threadCountβ number of threads (input)
Returns
- error code π
β¨ beagleSetEigenDecomposition β¨
BEAGLE_DLLEXPORT int beagleSetEigenDecomposition (int instance, int eigenIndex, const double * inEigenVectors, const double * inInverseEigenVectors, const double * inEigenValues)
sets an eigen-decomposition buffer β it copies an eigen-decomposition straight into an instance buffer. iconic math moment tbh π
Parameters
instanceβ instance number (input)eigenIndexβ index of the eigen-decomposition buffer (input)inEigenVectorsβ flattened matrix (stateCount x stateCount) of eigenvectors (input)inInverseEigenVectorsβ flattened matrix (stateCount x stateCount) of inverse-eigenvectors (input)inEigenValuesβ vector of eigenvalues
Returns
- error code β
π
beagleSetPartials π
BEAGLE_DLLEXPORT int beagleSetPartials (int instance, int bufferIndex, const double * inPartials)
sets an instance partials buffer β it copies an array of partials into an instance buffer. heads up bestie: the inPartials array should be stateCount * patternCount * categoryCount in length. that's the whole size, no shortcuts π₯
Parameters
instanceβ instance number in which to set apartialsBuffer(input)bufferIndexβ index of destinationpartialsBuffer(input)inPartialsβ pointer to partials values to set (input)
Returns
- error code π
πΈ beagleSetPatternPartitions πΈ
BEAGLE_DLLEXPORT int beagleSetPatternPartitions (int instance, int partitionCount, const int * inPatternPartitions)
sets the pattern partition assignments β it sets the vector of pattern partition indices for an instance. and listen, the order matters: it should only be called after beagleSetTipPartials and beagleSetPatternWeights. not before. do not be chaotic about this π
Parameters
instanceβ instance number (input)partitionCountβ number of partitions (input)inPatternPartitionsβ array containingpartitionCountpartition indices (input)
Returns
- error code π
π¦ beagleSetPatternWeights π¦
BEAGLE_DLLEXPORT int beagleSetPatternWeights (int instance, const double * inPatternWeights)
sets the pattern weights β it sets the vector of pattern weights for an instance. simple, clean, slay β¨
Parameters
instanceβ instance number (input)inPatternWeightsβ array containingpatternCountweights (input)
Returns
- error code π
π beagleSetStateFrequencies π
BEAGLE_DLLEXPORT int beagleSetStateFrequencies (int instance, int stateFrequenciesIndex, const double * inStateFrequencies)
sets a state frequency buffer β copies a state frequency array into an instance buffer. that's it, that's the function π
Parameters
instanceβ instance number (input)stateFrequenciesIndexβ index of the state frequencies buffer (input)inStateFrequenciesβ state frequencies array, sizedstateCount(input)
Returns
- error code π«Ά
π beagleSetTipPartials π
BEAGLE_DLLEXPORT int beagleSetTipPartials (int instance, int tipIndex, const double * inPartials)
sets an instance partials buffer for a tip node β it copies an array of partials into an instance buffer. the inPartials array should be stateCount * patternCount in length. for most applications this is what you'll use to set the partial likelihoods for the observed states. and internally? the partials get copied categoryCount times. no cap π₯
Parameters
instanceβ instance number in which to set apartialsBuffer(input)tipIndexβ index of destinationpartialsBuffer(input)inPartialsβ pointer to partials values to set (input)
Returns
- error code π
β beagleSetTipStates β
BEAGLE_DLLEXPORT int beagleSetTipStates (int instance, int tipIndex, const int * inStates)
sets the compact state representation for a tip node β it copies a compact state representation into an instance buffer. compact state representation is literally an array of states: 0 to stateCount - 1, and missing = stateCount. the inStates array should be patternCount in length, and nope, replication across categoryCount is not required here π§
Parameters
instanceβ instance number (input)tipIndexβ index of destinationcompactBuffer(input)inStatesβ pointer to compact states (input)
Returns
- error code β¨
π
beagleSetTransitionMatrices π
BEAGLE_DLLEXPORT int beagleSetTransitionMatrices (int instance, const int * matrixIndices, const double * inMatrices, const double * paddedValues, int count)
sets multiple transition matrices at once β it copies multiple transition matrices into matrix buffers. you'd use this when your app wants to explicitly set the transition matrices itself instead of going through beagleSetEigenDecomposition and beagleUpdateTransitionMatrices. the inMatrices array should be size stateCount * stateCount * categoryCount * count. yes, that's a lot of multiplying, it's giving "dimensionality" π
Parameters
instanceβ instance number (input)matrixIndicesβ indices of matrix buffers (input)inMatricesβ pointer to source transition matrices (input)paddedValuesβ values to be used for padding for ambiguous states, e.g.1for probability matrices,0for derivative matrices (input)countβ number of transition matrices (input)
Returns
- error code π
π¦ beagleSetTransitionMatrix π¦
BEAGLE_DLLEXPORT int beagleSetTransitionMatrix (int instance, int matrixIndex, const double * inMatrix, double paddedValue)
sets a finite-time transition probability matrix β copies one into a matrix buffer. again, this is the "i'll set it myself" route instead of using beagleSetEigenDecomposition and beagleUpdateTransitionMatrices. the inMatrix array should be size stateCount * stateCount * categoryCount and will contain one matrix for each rate category. one matrix per category, we love an organized queen π
Parameters
instanceβ instance number (input)matrixIndexβ index of matrix buffer (input)inMatrixβ pointer to source transition probability matrix (input)paddedValueβ value to be used for padding for ambiguous states, e.g.1for probability matrices,0for derivative matrices (input)
Returns
- error code π
π₯ beagleUpdatePartials π₯
BEAGLE_DLLEXPORT int beagleUpdatePartials (const int instance, const BeagleOperation * operations, int operationCount, int cumulativeScaleIndex)
calculates β or queues for calculation β partials using a list of operations. so here's the tea: implementations supporting ASYNCH may queue these calculations, while other implementations perform these operations immediately and in order. two very different vibes, same function π
Parameters
instanceβ instance number (input)operationsβBeagleOperationlist specifying operations (input)operationCountβ number of operations (input)cumulativeScaleIndexβ index number ofscaleBufferto store accumulated factors (input)
Returns
- error code π
β¨ beagleUpdatePartialsByPartition β¨
BEAGLE_DLLEXPORT int beagleUpdatePartialsByPartition (const int instance, const BeagleOperationByPartition * operations, int operationCount)
same energy as the last one but partitioned: calculates or queues for calculation a list of partitioned partials, using a list of partition operations. and yeah, ASYNCH-supporting implementations may queue these while others do them immediately and in order π
Parameters
instanceβ instance number (input)operationsβBeagleOperationlist specifying operations (input)operationCountβ number of operations (input)
Returns
- error code β
πΈ beagleUpdateTransitionMatrices πΈ
BEAGLE_DLLEXPORT int beagleUpdateTransitionMatrices (int instance, int eigenIndex, const int * probabilityIndices, const int * firstDerivativeIndices, const int * secondDerivativeIndices, const double * edgeLengths, int count)
calculates a list of transition probability matrices β and their first and second derivatives, but only if you asked for them. no free derivatives, bestie π«Ά
Parameters
instanceβ instance number (input)eigenIndexβ index of eigen-decomposition buffer (input)probabilityIndicesβ list of indices of transition probability matrices to update (input)firstDerivativeIndicesβ list of indices of first derivative matrices to update (input,NULLimplies no calculation)secondDerivativeIndicesβ list of indices of second derivative matrices to update (input,NULLimplies no calculation)edgeLengthsβ list of edge lengths with which to perform calculations (input)countβ length of lists
Returns
- error code π
π§ beagleUpdateTransitionMatricesWithMultipleModels π§
BEAGLE_DLLEXPORT int beagleUpdateTransitionMatricesWithMultipleModels (int instance, const int * eigenIndices, const int * categoryRateIndices, const int * probabilityIndices, const int * firstDerivativeIndices, const int * secondDerivativeIndices, const double * edgeLengths, int count)
calculates a list of transition probability matrices with multiple models β this function calculates a list of transition probabilities matrices and their first and second derivatives (if requested).
Parameters π«Ά
okay so here's the tea on what you gotta hand over π
instanceβ Instance number (input)eigenIndicesβ List of indices of eigen-decomposition buffers to use for updates (input)categoryRateIndicesβ List of indices of category-rate buffers to use for updates (input)probabilityIndicesβ List of indices of transition probability matrices to update (input)firstDerivativeIndicesβ List of indices of first derivative matrices to update (input,NULLimplies no calculation)secondDerivativeIndicesβ List of indices of second derivative matrices to update (input,NULLimplies no calculation)edgeLengthsβ List of edge lengths with which to perform calculations (input)countβ Length of lists
Returns β¨
error code π (yes bestie, that's the whole vibe, it just hands you back an error code)
πΈ beagleWaitForPartials πΈ
BEAGLE_DLLEXPORT int beagleWaitForPartials (const int instance, const int *destinationPartials, int destinationPartialsCount)
Block until all calculations that write to the specified partials have completed. Okay so this one is optional, like genuinely optional β you only ever call it if you're a client that 'recycles' partials. Reusing partials? Iconic. But then you gotta wait for them, no cutting the line π«Ά
If you do use it, here's the rules, bestie, listen up:
- It must be called after a
beagleUpdatePartialscall. - It must refer to indices of
'destinationPartials'that were used in a previousbeagleUpdatePartialscall.
The library will just sit there and block until those partials have been calculated. That's it. That's the whole job. It's giving bouncer at the club door, checking that everybody's inside before it lets you through π
Parameters π
instanceβ Instance number (input)destinationPartialsβ List of the indices ofdestinationPartialsthat must be calculated before the function returnsdestinationPartialsCountβ Number ofdestinationPartials(input)
Returns π
error code β
π Author
Generated automatically by Doxygen for BEAGLE from the source code. (no human wrote this by hand, the robots did it, and honestly? slay π€β¨)
aaaand that's a wrap on the whole page, bestie!! π This was Version 3.1.2, dated Tue Oct 19 2021, and it's all about libhmsbeagle/beagle.h(3) β go forth and phylogenetically compute, you main character π¦π
π¦ where this page comes from
- ubuntu jammy: libhmsbeagle-dev 3.1.2+dfsg-12ubuntu1 Β· LGPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms