libhmsbeagle/beagle.h(3)

πŸ“¦
version 3.1.2 Β· 3 versions
, in ubuntu jammy

✨ 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 scaling
  • BEAGLE_BENCHFLAG_SCALING_ALWAYS β€” scale at every iteration
  • BEAGLE_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 computation
  • BEAGLE_FLAG_PRECISION_DOUBLE β€” double precision computation
  • BEAGLE_FLAG_COMPUTATION_SYNCH β€” synchronous computation (blocking)
  • BEAGLE_FLAG_COMPUTATION_ASYNCH β€” asynchronous computation (non-blocking)
  • BEAGLE_FLAG_EIGEN_REAL β€” real eigenvalue computation
  • BEAGLE_FLAG_EIGEN_COMPLEX β€” complex eigenvalue computation
  • BEAGLE_FLAG_SCALING_MANUAL β€” manual scaling
  • BEAGLE_FLAG_SCALING_AUTO β€” auto-scaling on (deprecated, may not work correctly)
  • BEAGLE_FLAG_SCALING_ALWAYS β€” scale at every updatePartials (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 scalers
  • BEAGLE_FLAG_SCALERS_LOG β€” save log scalers
  • BEAGLE_FLAG_INVEVEC_STANDARD β€” inverse eigen vectors passed to BEAGLE have not been transposed
  • BEAGLE_FLAG_INVEVEC_TRANSPOSED β€” inverse eigen vectors passed to BEAGLE have been transposed
  • BEAGLE_FLAG_VECTOR_SSE β€” SSE computation
  • BEAGLE_FLAG_VECTOR_AVX β€” AVX computation
  • BEAGLE_FLAG_VECTOR_NONE β€” no vector computation
  • BEAGLE_FLAG_THREADING_CPP β€” C++11 threading
  • BEAGLE_FLAG_THREADING_OPENMP β€” OpenMP threading
  • BEAGLE_FLAG_THREADING_NONE β€” no threading (default)
  • BEAGLE_FLAG_PROCESSOR_CPU β€” use CPU as main processor
  • BEAGLE_FLAG_PROCESSOR_GPU β€” use GPU as main processor
  • BEAGLE_FLAG_PROCESSOR_FPGA β€” use FPGA as main processor
  • BEAGLE_FLAG_PROCESSOR_CELL β€” use Cell as main processor
  • BEAGLE_FLAG_PROCESSOR_PHI β€” use Intel Phi as main processor
  • BEAGLE_FLAG_PROCESSOR_OTHER β€” use other type of processor
  • BEAGLE_FLAG_FRAMEWORK_CUDA β€” use CUDA implementation with GPU resources
  • BEAGLE_FLAG_FRAMEWORK_OPENCL β€” use OpenCL implementation with GPU resources
  • BEAGLE_FLAG_FRAMEWORK_CPU β€” use CPU implementation
  • BEAGLE_FLAG_PARALLELOPS_STREAMS β€” operations in updatePartials may be assigned to separate device streams
  • BEAGLE_FLAG_PARALLELOPS_GRID β€” operations in updatePartials may 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 per beagleUpdatePartials operation
  • BEAGLE_PARTITION_OP_COUNT β€” total number of integers per beagleUpdatePartialsByPartition operation
  • BEAGLE_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 error
  • BEAGLE_ERROR_OUT_OF_MEMORY β€” not enough memory could be allocated
  • BEAGLE_ERROR_UNIDENTIFIED_EXCEPTION β€” unspecified exception
  • BEAGLE_ERROR_UNINITIALIZED_INSTANCE β€” the instance index is out of range, or the instance has not been created
  • BEAGLE_ERROR_OUT_OF_RANGE β€” one of the indices specified exceeded the range of the array
  • BEAGLE_ERROR_NO_RESOURCE β€” no resource matches requirements
  • BEAGLE_ERROR_NO_IMPLEMENTATION β€” no implementation matches requirements
  • BEAGLE_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 of scaleBuffers to add (input)
  • count β€” number of scaleBuffers in list (input)
  • cumulativeScaleIndex β€” index number of scaleBuffer to 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 of scaleBuffers to add (input)
  • count β€” Number of scaleBuffers in list (input)
  • cumulativeScaleIndex β€” Index number of scaleBuffer to 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 parent partialsBuffers (input)
  • childBufferIndices β€” List of indices of child partialsBuffers (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 each partialsBuffer (input)
  • stateFrequenciesIndices β€” List of state frequencies for each partialsBuffer (input). There should be one set for each of parentBufferIndices
  • cumulativeScaleIndices β€” List of scaleBuffers containing accumulated factors to apply to each partialsBuffer (input). There should be one index for each of parentBufferIndices
  • count β€” Number of partialsBuffers (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 parent partialsBuffers (input)
  • childBufferIndices β€” List of indices of child partialsBuffers (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 each partialsBuffer (input)
  • stateFrequenciesIndices β€” List of state frequencies for each partialsBuffer (input). There should be one set for each of parentBufferIndices
  • cumulativeScaleIndices β€” List of scaleBuffers containing accumulated factors to apply to each partialsBuffer (input). There should be one index for each of parentBufferIndices
  • partitionIndices β€” List of partition indices indicating which sites in each partialsBuffer should be used (input). There should be one index for each of parentBufferIndices
  • partitionCount β€” Number of distinct partitionIndices (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 of partialsBuffer indices to integrate (input)
  • categoryWeightsIndices β€” List of weights to apply to each partialsBuffer (input). There should be one categoryCount sized set for each of parentBufferIndices
  • stateFrequenciesIndices β€” List of state frequencies for each partialsBuffer (input). There should be one set for each of parentBufferIndices
  • cumulativeScaleIndices β€” List of scaleBuffers containing accumulated factors to apply to each partialsBuffer (input). There should be one index for each of parentBufferIndices
  • count β€” Number of partialsBuffer to 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 of partialsBuffer indices to integrate (input)
  • categoryWeightsIndices β€” List of weights to apply to each partialsBuffer (input). There should be one categoryCount sized set for each of bufferIndices
  • stateFrequenciesIndices β€” List of state frequencies for each partialsBuffer (input). There should be one set for each of bufferIndices
  • cumulativeScaleIndices β€” List of scaleBuffers containing accumulated factors to apply to each partialsBuffer (input). There should be one index for each of bufferIndices
  • partitionIndices β€” List of partition indices indicating which sites in each partialsBuffer should be used (input). There should be one index for each of bufferIndices
  • partitionCount β€” Number of distinct partitionIndices (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 β€” partitionCount arrays, each containing patternCount pattern 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 β€” Destination scaleBuffer (input)
  • srcScalingIndex β€” Source scaleBuffer (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, NULL implies no restriction) πŸ’€
  • resourceCount β€” Length of resourceList list (input) πŸ“
  • preferenceFlags β€” Bit-flags indicating preferred implementation characteristics, see BeagleFlags (input) 🧚
  • requirementFlags β€” Bit-flags indicating required implementation characteristics, see BeagleFlags (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, NULL implies no restriction (input)
  • resourceCount β€” Length of resourceList list (input)
  • preferenceFlags β€” Bit-flags indicating preferred implementation characteristics, see BeagleFlags (input)
  • requirementFlags β€” Bit-flags indicating required implementation characteristics, see BeagleFlags (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 get partialsBuffer (input)
  • bufferIndex β€” Index of source partialsBuffer (input)
  • scaleIndex β€” Index of scaleBuffer to apply to partialsBuffer (input)
  • outPartials β€” Pointer to which to receive partialsBuffer (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 β€” Source scaleBuffer (input)
  • outScaleFactors β€” Pointer to which to receive scaleFactors (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 of scaleBuffers to remove (input)
  • count β€” Number of scaleBuffers in list (input)
  • cumulativeScaleIndex β€” Index number of scaleBuffer containing 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 of scaleBuffers to remove (input)
  • count β€” Number of scaleBuffers in list (input)
  • cumulativeScaleIndex β€” Index number of scaleBuffer containing 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 cumulative scaleBuffer (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 cumulative scaleBuffer (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 input
  • inCategoryRates β€” array holding categoryCount rate 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 containing categoryCount rate 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, sized categoryCount (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_CPP flag to be set
  • it has no effect on GPU-based implementations, periodt
  • it also has no effect with the default BEAGLE_FLAG_THREADING_NONE setting
  • if BEAGLE_FLAG_THREADING_CPP is 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 a partialsBuffer (input)
  • bufferIndex β€” index of destination partialsBuffer (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 containing partitionCount partition 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 containing patternCount weights (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, sized stateCount (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 a partialsBuffer (input)
  • tipIndex β€” index of destination partialsBuffer (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 destination compactBuffer (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. 1 for probability matrices, 0 for 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. 1 for probability matrices, 0 for 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 β€” BeagleOperation list specifying operations (input)
  • operationCount β€” number of operations (input)
  • cumulativeScaleIndex β€” index number of scaleBuffer to 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 β€” BeagleOperation list 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, NULL implies no calculation)
  • secondDerivativeIndices β€” list of indices of second derivative matrices to update (input, NULL implies 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, NULL implies no calculation)
  • secondDerivativeIndices β€” List of indices of second derivative matrices to update (input, NULL implies 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 beagleUpdatePartials call.
  • It must refer to indices of 'destinationPartials' that were used in a previous beagleUpdatePartials call.

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 of destinationPartials that must be calculated before the function returns
  • destinationPartialsCount β€” Number of destinationPartials (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