.TH "libhmsbeagle/beagle.h" 3 "Wed Nov 2 2016" "Version 2.1.2" "BEAGLE" \" -*- nroff -*- .ad l .nh .SH NAME libhmsbeagle/beagle.h \- This file documents the API as well as header for the Broad-platform Evolutionary Analysis General Likelihood Evaluator\&. .SH SYNOPSIS .br .PP \fC#include 'libhmsbeagle/platform\&.h'\fP .br .SS "Classes" .in +1c .ti -1c .RI "struct \fBBeagleInstanceDetails\fP" .br .RI "Information about a specific instance\&. " .ti -1c .RI "struct \fBBeagleResource\fP" .br .RI "Description of a hardware resource\&. " .ti -1c .RI "struct \fBBeagleResourceList\fP" .br .RI "List of hardware resources\&. " .ti -1c .RI "struct \fBBeagleOperation\fP" .br .RI "A list of integer indices which specify a partial likelihoods operation\&. " .in -1c .SS "Enumerations" .in +1c .ti -1c .RI "enum \fBBeagleReturnCodes\fP { \fBBEAGLE_SUCCESS\fP = 0, \fBBEAGLE_ERROR_GENERAL\fP = -1, \fBBEAGLE_ERROR_OUT_OF_MEMORY\fP = -2, \fBBEAGLE_ERROR_UNIDENTIFIED_EXCEPTION\fP = -3, \fBBEAGLE_ERROR_UNINITIALIZED_INSTANCE\fP = -4, \fBBEAGLE_ERROR_OUT_OF_RANGE\fP = -5, \fBBEAGLE_ERROR_NO_RESOURCE\fP = -6, \fBBEAGLE_ERROR_NO_IMPLEMENTATION\fP = -7, \fBBEAGLE_ERROR_FLOATING_POINT\fP = -8 } .RI "Error return codes\&. "" .br .ti -1c .RI "enum \fBBeagleFlags\fP { \fBBEAGLE_FLAG_PRECISION_SINGLE\fP = 1 << 0, \fBBEAGLE_FLAG_PRECISION_DOUBLE\fP = 1 << 1, \fBBEAGLE_FLAG_COMPUTATION_SYNCH\fP = 1 << 2, \fBBEAGLE_FLAG_COMPUTATION_ASYNCH\fP = 1 << 3, \fBBEAGLE_FLAG_EIGEN_REAL\fP = 1 << 4, \fBBEAGLE_FLAG_EIGEN_COMPLEX\fP = 1 << 5, \fBBEAGLE_FLAG_SCALING_MANUAL\fP = 1 << 6, \fBBEAGLE_FLAG_SCALING_AUTO\fP = 1 << 7, \fBBEAGLE_FLAG_SCALING_ALWAYS\fP = 1 << 8, \fBBEAGLE_FLAG_SCALING_DYNAMIC\fP = 1 << 25, \fBBEAGLE_FLAG_SCALERS_RAW\fP = 1 << 9, \fBBEAGLE_FLAG_SCALERS_LOG\fP = 1 << 10, \fBBEAGLE_FLAG_INVEVEC_STANDARD\fP = 1 << 20, \fBBEAGLE_FLAG_INVEVEC_TRANSPOSED\fP = 1 << 21, \fBBEAGLE_FLAG_VECTOR_SSE\fP = 1 << 11, \fBBEAGLE_FLAG_VECTOR_AVX\fP = 1 << 24, \fBBEAGLE_FLAG_VECTOR_NONE\fP = 1 << 12, \fBBEAGLE_FLAG_THREADING_OPENMP\fP = 1 << 13, \fBBEAGLE_FLAG_THREADING_NONE\fP = 1 << 14, \fBBEAGLE_FLAG_PROCESSOR_CPU\fP = 1 << 15, \fBBEAGLE_FLAG_PROCESSOR_GPU\fP = 1 << 16, \fBBEAGLE_FLAG_PROCESSOR_FPGA\fP = 1 << 17, \fBBEAGLE_FLAG_PROCESSOR_CELL\fP = 1 << 18, \fBBEAGLE_FLAG_PROCESSOR_PHI\fP = 1 << 19, \fBBEAGLE_FLAG_PROCESSOR_OTHER\fP = 1 << 26, \fBBEAGLE_FLAG_FRAMEWORK_CUDA\fP = 1 << 22, \fBBEAGLE_FLAG_FRAMEWORK_OPENCL\fP = 1 << 23, \fBBEAGLE_FLAG_FRAMEWORK_CPU\fP = 1 << 27 } .RI "Hardware and implementation capability flags\&. "" .br .ti -1c .RI "enum \fBBeagleOpCodes\fP { \fBBEAGLE_OP_COUNT\fP = 7, \fBBEAGLE_OP_NONE\fP = -1 } .RI "Operation codes\&. "" .br .in -1c .SS "Functions" .in +1c .ti -1c .RI "BEAGLE_DLLEXPORT const char * \fBbeagleGetVersion\fP (void)" .br .RI "Get version\&. " .ti -1c .RI "BEAGLE_DLLEXPORT const char * \fBbeagleGetCitation\fP (void)" .br .RI "Get citation\&. " .ti -1c .RI "BEAGLE_DLLEXPORT \fBBeagleResourceList\fP * \fBbeagleGetResourceList\fP (void)" .br .RI "Get list of hardware resources\&. " .ti -1c .RI "BEAGLE_DLLEXPORT int \fBbeagleCreateInstance\fP (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, \fBBeagleInstanceDetails\fP *returnInfo)" .br .RI "Create a single instance\&. " .ti -1c .RI "BEAGLE_DLLEXPORT int \fBbeagleFinalizeInstance\fP (int instance)" .br .RI "Finalize this instance\&. " .ti -1c .RI "BEAGLE_DLLEXPORT int \fBbeagleFinalize\fP (void)" .br .RI "Finalize the library\&. " .ti -1c .RI "BEAGLE_DLLEXPORT int \fBbeagleSetTipStates\fP (int instance, int tipIndex, const int *inStates)" .br .RI "Set the compact state representation for tip node\&. " .ti -1c .RI "BEAGLE_DLLEXPORT int \fBbeagleSetTipPartials\fP (int instance, int tipIndex, const double *inPartials)" .br .RI "Set an instance partials buffer for tip node\&. " .ti -1c .RI "BEAGLE_DLLEXPORT int \fBbeagleSetPartials\fP (int instance, int bufferIndex, const double *inPartials)" .br .RI "Set an instance partials buffer\&. " .ti -1c .RI "BEAGLE_DLLEXPORT int \fBbeagleGetPartials\fP (int instance, int bufferIndex, int scaleIndex, double *outPartials)" .br .RI "Get partials from an instance buffer\&. " .ti -1c .RI "BEAGLE_DLLEXPORT int \fBbeagleSetEigenDecomposition\fP (int instance, int eigenIndex, const double *inEigenVectors, const double *inInverseEigenVectors, const double *inEigenValues)" .br .RI "Set an eigen-decomposition buffer\&. " .ti -1c .RI "BEAGLE_DLLEXPORT int \fBbeagleSetStateFrequencies\fP (int instance, int stateFrequenciesIndex, const double *inStateFrequencies)" .br .RI "Set a state frequency buffer\&. " .ti -1c .RI "BEAGLE_DLLEXPORT int \fBbeagleSetCategoryWeights\fP (int instance, int categoryWeightsIndex, const double *inCategoryWeights)" .br .RI "Set a category weights buffer\&. " .ti -1c .RI "BEAGLE_DLLEXPORT int \fBbeagleSetCategoryRates\fP (int instance, const double *inCategoryRates)" .br .RI "Set category rates\&. " .ti -1c .RI "BEAGLE_DLLEXPORT int \fBbeagleSetPatternWeights\fP (int instance, const double *inPatternWeights)" .br .RI "Set pattern weights\&. " .ti -1c .RI "BEAGLE_DLLEXPORT int \fBbeagleConvolveTransitionMatrices\fP (int instance, const int *firstIndices, const int *secondIndices, const int *resultIndices, int matrixCount)" .br .RI "Convolve lists of transition probability matrices\&. " .ti -1c .RI "BEAGLE_DLLEXPORT int \fBbeagleUpdateTransitionMatrices\fP (int instance, int eigenIndex, const int *probabilityIndices, const int *firstDerivativeIndices, const int *secondDerivativeIndices, const double *edgeLengths, int count)" .br .RI "Calculate a list of transition probability matrices\&. " .ti -1c .RI "BEAGLE_DLLEXPORT int \fBbeagleSetTransitionMatrix\fP (int instance, int matrixIndex, const double *inMatrix, double paddedValue)" .br .RI "Set a finite-time transition probability matrix\&. " .ti -1c .RI "BEAGLE_DLLEXPORT int \fBbeagleGetTransitionMatrix\fP (int instance, int matrixIndex, double *outMatrix)" .br .RI "Get a finite-time transition probability matrix\&. " .ti -1c .RI "BEAGLE_DLLEXPORT int \fBbeagleSetTransitionMatrices\fP (int instance, const int *matrixIndices, const double *inMatrices, const double *paddedValues, int count)" .br .RI "Set multiple transition matrices\&. " .ti -1c .RI "BEAGLE_DLLEXPORT int \fBbeagleUpdatePartials\fP (const int instance, const \fBBeagleOperation\fP *operations, int operationCount, int cumulativeScaleIndex)" .br .RI "Calculate or queue for calculation partials using a list of operations\&. " .ti -1c .RI "BEAGLE_DLLEXPORT int \fBbeagleWaitForPartials\fP (const int instance, const int *destinationPartials, int destinationPartialsCount)" .br .RI "Block until all calculations that write to the specified partials have completed\&. " .ti -1c .RI "BEAGLE_DLLEXPORT int \fBbeagleAccumulateScaleFactors\fP (int instance, const int *scaleIndices, int count, int cumulativeScaleIndex)" .br .RI "Accumulate scale factors\&. " .ti -1c .RI "BEAGLE_DLLEXPORT int \fBbeagleRemoveScaleFactors\fP (int instance, const int *scaleIndices, int count, int cumulativeScaleIndex)" .br .RI "Remove scale factors\&. " .ti -1c .RI "BEAGLE_DLLEXPORT int \fBbeagleResetScaleFactors\fP (int instance, int cumulativeScaleIndex)" .br .RI "Reset scalefactors\&. " .ti -1c .RI "BEAGLE_DLLEXPORT int \fBbeagleCopyScaleFactors\fP (int instance, int destScalingIndex, int srcScalingIndex)" .br .RI "Copy scale factors\&. " .ti -1c .RI "BEAGLE_DLLEXPORT int \fBbeagleGetScaleFactors\fP (int instance, int srcScalingIndex, double *outScaleFactors)" .br .RI "Get scale factors\&. " .ti -1c .RI "BEAGLE_DLLEXPORT int \fBbeagleCalculateRootLogLikelihoods\fP (int instance, const int *bufferIndices, const int *categoryWeightsIndices, const int *stateFrequenciesIndices, const int *cumulativeScaleIndices, int count, double *outSumLogLikelihood)" .br .RI "Calculate site log likelihoods at a root node\&. " .ti -1c .RI "BEAGLE_DLLEXPORT int \fBbeagleCalculateEdgeLogLikelihoods\fP (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)" .br .RI "Calculate site log likelihoods and derivatives along an edge\&. " .ti -1c .RI "BEAGLE_DLLEXPORT int \fBbeagleGetSiteLogLikelihoods\fP (int instance, double *outLogLikelihoods)" .br .RI "Get site log likelihoods for last beagleCalculateRootLogLikelihoods or beagleCalculateEdgeLogLikelihoods call\&. " .ti -1c .RI "BEAGLE_DLLEXPORT int \fBbeagleGetSiteDerivatives\fP (int instance, double *outFirstDerivatives, double *outSecondDerivatives)" .br .RI "Get site derivatives for last beagleCalculateEdgeLogLikelihoods call\&. " .in -1c .SH "Detailed Description" .PP This file documents the API as well as header for the Broad-platform Evolutionary Analysis General Likelihood Evaluator\&. Copyright 2009-2013 Phylogenetic Likelihood Working Group .PP This file is part of BEAGLE\&. .PP 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\&. .PP 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\&. .PP You should have received a copy of the GNU Lesser General Public License along with BEAGLE\&. If not, see http://www.gnu.org/licenses/\&. .PP KEY CONCEPTS .PP The key to BEAGLE performance lies in delivering fine-scale parallelization while minimizing data transfer and memory copy overhead\&. To accomplish this, the library lacks the concept of data structure for a tree, in spite of the intended use for phylogenetic analysis\&. Instead, BEAGLE acts directly on flexibly indexed data storage (called buffers) for observed character states and partial likelihoods\&. The client program can set the input buffers to reflect the data and can calculate the likelihood of a particular phylogeny by invoking likelihood calculations on the appropriate input and output buffers in the correct order\&. Because of this design simplicity, the library can support many different tree inference algorithms and likelihood calculation on a variety of models\&. Arbitrary numbers of states can be used, as can nonreversible substitution matrices via complex eigen decompositions, and mixture models with multiple rate categories and/or multiple eigen decompositions\&. Finally, BEAGLE application programming interface (API) calls can be asynchronous, allowing the calling program to implement other coarse-scale parallelization schemes such as evaluating independent genes or running concurrent Markov chains\&. .PP USAGE .PP To use the library, a client program first creates an instance of BEAGLE by calling beagleCreateInstance; multiple instances per client are possible and encouraged\&. All additional functions are called with a reference to this instance\&. The client program can optionally request that an instance run on certain hardware (e\&.g\&., a GPU) or have particular features (e\&.g\&., double-precision math)\&. Next, the client program must specify the data dimensions and specify key aspects of the phylogenetic model\&. Character state data are then loaded and can be in the form of discrete observed states or partial likelihoods for ambiguous characters\&. The observed data are usually unchanging and loaded only once at the start to minimize memory copy overhead\&. The character data can be compressed into unique “site patterns” and associated weights for each\&. The parameters of the substitution process can then be 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\&. .PP In order 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 considering a nondiagonalizable model or calculated in parallel from the eigen decomposition and edge lengths specified\&. This is performed within BEAGLE’s memory space to minimize data transfers\&. A single function call will then request 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 needs only specify nodes for which the partial likelihoods need updating, but it is up to the calling software to keep track of these dependencies\&. The final step in evaluating the phylogenetic model is done using an API call that yields a single log likelihood for the model given the data\&. .PP 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\&. .PP \fBAuthor:\fP .RS 4 Likelihood API Working Group .PP Daniel Ayres .PP Peter Beerli .PP Michael Cummings .PP Aaron Darling .PP Mark Holder .PP John Huelsenbeck .PP Paul Lewis .PP Michael Ott .PP Andrew Rambaut .PP Fredrik Ronquist .PP Marc Suchard .PP David Swofford .PP Derrick Zwickl .RE .PP .SH "Enumeration Type Documentation" .PP .SS "enum \fBBeagleFlags\fP" .PP Hardware and implementation capability flags\&. This enumerates all possible hardware and implementation capability flags\&. Each capability is a bit in a 'long' .PP \fBEnumerator\fP .in +1c .TP \fB\fIBEAGLE_FLAG_PRECISION_SINGLE \fP\fP Single precision computation .TP \fB\fIBEAGLE_FLAG_PRECISION_DOUBLE \fP\fP Double precision computation .TP \fB\fIBEAGLE_FLAG_COMPUTATION_SYNCH \fP\fP Synchronous computation (blocking) .TP \fB\fIBEAGLE_FLAG_COMPUTATION_ASYNCH \fP\fP Asynchronous computation (non-blocking) .TP \fB\fIBEAGLE_FLAG_EIGEN_REAL \fP\fP Real eigenvalue computation .TP \fB\fIBEAGLE_FLAG_EIGEN_COMPLEX \fP\fP Complex eigenvalue computation .TP \fB\fIBEAGLE_FLAG_SCALING_MANUAL \fP\fP Manual scaling .TP \fB\fIBEAGLE_FLAG_SCALING_AUTO \fP\fP Auto-scaling on (deprecated, may not work correctly) .TP \fB\fIBEAGLE_FLAG_SCALING_ALWAYS \fP\fP Scale at every updatePartials (deprecated, may not work correctly) .TP \fB\fIBEAGLE_FLAG_SCALING_DYNAMIC \fP\fP Manual scaling with dynamic checking (deprecated, may not work correctly) .TP \fB\fIBEAGLE_FLAG_SCALERS_RAW \fP\fP Save raw scalers .TP \fB\fIBEAGLE_FLAG_SCALERS_LOG \fP\fP Save log scalers .TP \fB\fIBEAGLE_FLAG_INVEVEC_STANDARD \fP\fP Inverse eigen vectors passed to BEAGLE have not been transposed .TP \fB\fIBEAGLE_FLAG_INVEVEC_TRANSPOSED \fP\fP Inverse eigen vectors passed to BEAGLE have been transposed .TP \fB\fIBEAGLE_FLAG_VECTOR_SSE \fP\fP SSE computation .TP \fB\fIBEAGLE_FLAG_VECTOR_AVX \fP\fP AVX computation .TP \fB\fIBEAGLE_FLAG_VECTOR_NONE \fP\fP No vector computation .TP \fB\fIBEAGLE_FLAG_THREADING_OPENMP \fP\fP OpenMP threading .TP \fB\fIBEAGLE_FLAG_THREADING_NONE \fP\fP No threading .TP \fB\fIBEAGLE_FLAG_PROCESSOR_CPU \fP\fP Use CPU as main processor .TP \fB\fIBEAGLE_FLAG_PROCESSOR_GPU \fP\fP Use GPU as main processor .TP \fB\fIBEAGLE_FLAG_PROCESSOR_FPGA \fP\fP Use FPGA as main processor .TP \fB\fIBEAGLE_FLAG_PROCESSOR_CELL \fP\fP Use Cell as main processor .TP \fB\fIBEAGLE_FLAG_PROCESSOR_PHI \fP\fP Use Intel Phi as main processor .TP \fB\fIBEAGLE_FLAG_PROCESSOR_OTHER \fP\fP Use other type of processor .TP \fB\fIBEAGLE_FLAG_FRAMEWORK_CUDA \fP\fP Use CUDA implementation with GPU resources .TP \fB\fIBEAGLE_FLAG_FRAMEWORK_OPENCL \fP\fP Use OpenCL implementation with GPU resources .TP \fB\fIBEAGLE_FLAG_FRAMEWORK_CPU \fP\fP Use CPU implementation .SS "enum \fBBeagleOpCodes\fP" .PP Operation codes\&. This enumerates all possible BEAGLE operation codes\&. .PP \fBEnumerator\fP .in +1c .TP \fB\fIBEAGLE_OP_COUNT \fP\fP Total number of integers per beagleUpdatePartials operation .TP \fB\fIBEAGLE_OP_NONE \fP\fP Specify no use for indexed buffer .SS "enum \fBBeagleReturnCodes\fP" .PP Error return codes\&. This enumerates all possible BEAGLE return codes\&. Error codes are always negative\&. .PP \fBEnumerator\fP .in +1c .TP \fB\fIBEAGLE_SUCCESS \fP\fP Success .TP \fB\fIBEAGLE_ERROR_GENERAL \fP\fP Unspecified error .TP \fB\fIBEAGLE_ERROR_OUT_OF_MEMORY \fP\fP Not enough memory could be allocated .TP \fB\fIBEAGLE_ERROR_UNIDENTIFIED_EXCEPTION \fP\fP Unspecified exception .TP \fB\fIBEAGLE_ERROR_UNINITIALIZED_INSTANCE \fP\fP The instance index is out of range, or the instance has not been created .TP \fB\fIBEAGLE_ERROR_OUT_OF_RANGE \fP\fP One of the indices specified exceeded the range of the array .TP \fB\fIBEAGLE_ERROR_NO_RESOURCE \fP\fP No resource matches requirements .TP \fB\fIBEAGLE_ERROR_NO_IMPLEMENTATION \fP\fP No implementation matches requirements .TP \fB\fIBEAGLE_ERROR_FLOATING_POINT \fP\fP Floating-point range exceeded .SH "Function Documentation" .PP .SS "BEAGLE_DLLEXPORT int beagleAccumulateScaleFactors (int instance, const int * scaleIndices, int count, int cumulativeScaleIndex)" .PP Accumulate scale factors\&. This function adds (log) scale factors from a list of scaleBuffers to a cumulative scale buffer\&. It is used to calculate the marginal scaling at a specific node for each site\&. .PP \fBParameters:\fP .RS 4 \fIinstance\fP Instance number (input) .br \fIscaleIndices\fP List of scaleBuffers to add (input) .br \fIcount\fP Number of scaleBuffers in list (input) .br \fIcumulativeScaleIndex\fP Index number of scaleBuffer to accumulate factors into (input) .RE .PP .SS "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)" .PP Calculate site log likelihoods and derivatives along an edge\&. This function integrates a list of partials at a parent and child node with respect to a set of partials-weights and state frequencies to return the log likelihood and first and second derivative sums .PP \fBParameters:\fP .RS 4 \fIinstance\fP Instance number (input) .br \fIparentBufferIndices\fP List of indices of parent partialsBuffers (input) .br \fIchildBufferIndices\fP List of indices of child partialsBuffers (input) .br \fIprobabilityIndices\fP List indices of transition probability matrices for this edge (input) .br \fIfirstDerivativeIndices\fP List indices of first derivative matrices (input) .br \fIsecondDerivativeIndices\fP List indices of second derivative matrices (input) .br \fIcategoryWeightsIndices\fP List of weights to apply to each partialsBuffer (input) .br \fIstateFrequenciesIndices\fP List of state frequencies for each partialsBuffer (input)\&. There should be one set for each of parentBufferIndices .br \fIcumulativeScaleIndices\fP List of scaleBuffers containing accumulated factors to apply to each partialsBuffer (input)\&. There should be one index for each of parentBufferIndices .br \fIcount\fP Number of partialsBuffers (input) .br \fIoutSumLogLikelihood\fP Pointer to destination for resulting log likelihood (output) .br \fIoutSumFirstDerivative\fP Pointer to destination for resulting first derivative (output) .br \fIoutSumSecondDerivative\fP Pointer to destination for resulting second derivative (output) .RE .PP \fBReturns:\fP .RS 4 error code .RE .PP .SS "BEAGLE_DLLEXPORT int beagleCalculateRootLogLikelihoods (int instance, const int * bufferIndices, const int * categoryWeightsIndices, const int * stateFrequenciesIndices, const int * cumulativeScaleIndices, int count, double * outSumLogLikelihood)" .PP Calculate site log likelihoods at a root node\&. This function integrates a list of partials at a node with respect to a set of partials-weights and state frequencies to return the log likelihood sum .PP \fBParameters:\fP .RS 4 \fIinstance\fP Instance number (input) .br \fIbufferIndices\fP List of partialsBuffer indices to integrate (input) .br \fIcategoryWeightsIndices\fP List of weights to apply to each partialsBuffer (input)\&. There should be one categoryCount sized set for each of parentBufferIndices .br \fIstateFrequenciesIndices\fP List of state frequencies for each partialsBuffer (input)\&. There should be one set for each of parentBufferIndices .br \fIcumulativeScaleIndices\fP List of scaleBuffers containing accumulated factors to apply to each partialsBuffer (input)\&. There should be one index for each of parentBufferIndices .br \fIcount\fP Number of partialsBuffer to integrate (input) .br \fIoutSumLogLikelihood\fP Pointer to destination for resulting log likelihood (output) .RE .PP \fBReturns:\fP .RS 4 error code .RE .PP .SS "BEAGLE_DLLEXPORT int beagleConvolveTransitionMatrices (int instance, const int * firstIndices, const int * secondIndices, const int * resultIndices, int matrixCount)" .PP Convolve lists of transition probability matrices\&. This function convolves two lists of transition probability matrices\&. .PP \fBParameters:\fP .RS 4 \fIinstance\fP Instance number (input) .br \fIfirstIndices\fP List of indices of the first transition probability matrices to convolve (input) .br \fIsecondIndices\fP List of indices of the second transition probability matrices to convolve (input) .br \fIresultIndices\fP List of indices of resulting transition probability matrices (input) .br \fImatrixCount\fP Length of lists .RE .PP .SS "BEAGLE_DLLEXPORT int beagleCopyScaleFactors (int instance, int destScalingIndex, int srcScalingIndex)" .PP Copy scale factors\&. This function copies scale factors from one buffer to another\&. .PP \fBParameters:\fP .RS 4 \fIinstance\fP Instance number (input) .br \fIdestScalingIndex\fP Destination scaleBuffer (input) .br \fIsrcScalingIndex\fP Source scaleBuffer (input) .RE .PP .SS "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, \fBBeagleInstanceDetails\fP * returnInfo)" .PP Create a single instance\&. This function creates a single instance of the BEAGLE library and can be called multiple times to create multiple data partition instances each returning a unique identifier\&. .PP \fBParameters:\fP .RS 4 \fItipCount\fP Number of tip data elements (input) .br \fIpartialsBufferCount\fP Number of partials buffers to create (input) .br \fIcompactBufferCount\fP Number of compact state representation buffers to create (input) .br \fIstateCount\fP Number of states in the continuous-time Markov chain (input) .br \fIpatternCount\fP Number of site patterns to be handled by the instance (input) .br \fIeigenBufferCount\fP Number of rate matrix eigen-decomposition, category weight, and state frequency buffers to allocate (input) .br \fImatrixBufferCount\fP Number of transition probability matrix buffers (input) .br \fIcategoryCount\fP Number of rate categories (input) .br \fIscaleBufferCount\fP Number of scale buffers to create, ignored for auto scale or always scale (input) .br \fIresourceList\fP List of potential resources on which this instance is allowed (input, NULL implies no restriction) .br \fIresourceCount\fP Length of resourceList list (input) .br \fIpreferenceFlags\fP Bit-flags indicating preferred implementation characteristics, see BeagleFlags (input) .br \fIrequirementFlags\fP Bit-flags indicating required implementation characteristics, see BeagleFlags (input) .br \fIreturnInfo\fP Pointer to return implementation and resource details .RE .PP \fBReturns:\fP .RS 4 the unique instance identifier (<0 if failed, see \fBBeagleReturnCodes\fP) .RE .PP .SS "BEAGLE_DLLEXPORT int beagleFinalize (void)" .PP Finalize the library\&. This function finalizes the library and releases all allocated memory\&. This function is automatically called under GNU C via \fBattribute\fP ((destructor))\&. .PP \fBReturns:\fP .RS 4 error code .RE .PP .SS "BEAGLE_DLLEXPORT int beagleFinalizeInstance (int instance)" .PP Finalize this instance\&. This function finalizes the instance by releasing allocated memory .PP \fBParameters:\fP .RS 4 \fIinstance\fP Instance number .RE .PP \fBReturns:\fP .RS 4 error code .RE .PP .SS "BEAGLE_DLLEXPORT const char* beagleGetCitation (void)" .PP Get citation\&. This function returns a pointer to a string describing the version of the library and how to cite it\&. .PP \fBReturns:\fP .RS 4 A string describing the version of the library and how to cite it .RE .PP .SS "BEAGLE_DLLEXPORT int beagleGetPartials (int instance, int bufferIndex, int scaleIndex, double * outPartials)" .PP 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\&. .PP \fBParameters:\fP .RS 4 \fIinstance\fP Instance number from which to get partialsBuffer (input) .br \fIbufferIndex\fP Index of source partialsBuffer (input) .br \fIscaleIndex\fP Index of scaleBuffer to apply to partialsBuffer (input) .br \fIoutPartials\fP Pointer to which to receive partialsBuffer (output) .RE .PP \fBReturns:\fP .RS 4 error code .RE .PP .SS "BEAGLE_DLLEXPORT \fBBeagleResourceList\fP* beagleGetResourceList (void)" .PP Get list of hardware resources\&. This function returns a pointer to a \fBBeagleResourceList\fP struct, which includes a \fBBeagleResource\fP array describing the available hardware resources\&. .PP \fBReturns:\fP .RS 4 A list of hardware resources available to the library as a \fBBeagleResourceList\fP .RE .PP .SS "BEAGLE_DLLEXPORT int beagleGetScaleFactors (int instance, int srcScalingIndex, double * outScaleFactors)" .PP Get scale factors\&. This function retrieves a buffer of scale factors\&. .PP \fBParameters:\fP .RS 4 \fIinstance\fP Instance number (input) .br \fIsrcScalingIndex\fP Source scaleBuffer (input) .br \fIoutScaleFactors\fP Pointer to which to receive scaleFactors (output) .RE .PP .SS "BEAGLE_DLLEXPORT int beagleGetSiteDerivatives (int instance, double * outFirstDerivatives, double * outSecondDerivatives)" .PP Get site derivatives for last beagleCalculateEdgeLogLikelihoods call\&. This function returns the derivatives for each site .PP \fBParameters:\fP .RS 4 \fIinstance\fP Instance number (input) .br \fIoutFirstDerivatives\fP Pointer to destination for resulting first derivatives (output) .br \fIoutSecondDerivatives\fP Pointer to destination for resulting second derivatives (output) .RE .PP \fBReturns:\fP .RS 4 error code .RE .PP .SS "BEAGLE_DLLEXPORT int beagleGetSiteLogLikelihoods (int instance, double * outLogLikelihoods)" .PP Get site log likelihoods for last beagleCalculateRootLogLikelihoods or beagleCalculateEdgeLogLikelihoods call\&. This function returns the log likelihoods for each site .PP \fBParameters:\fP .RS 4 \fIinstance\fP Instance number (input) .br \fIoutLogLikelihoods\fP Pointer to destination for resulting log likelihoods (output) .RE .PP \fBReturns:\fP .RS 4 error code .RE .PP .SS "BEAGLE_DLLEXPORT int beagleGetTransitionMatrix (int instance, int matrixIndex, double * outMatrix)" .PP 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\&. .PP \fBParameters:\fP .RS 4 \fIinstance\fP Instance number (input) .br \fImatrixIndex\fP Index of matrix buffer (input) .br \fIoutMatrix\fP Pointer to destination transition probability matrix (output) .RE .PP \fBReturns:\fP .RS 4 error code .RE .PP .SS "BEAGLE_DLLEXPORT const char* beagleGetVersion (void)" .PP Get version\&. This function returns a pointer to a string with the library version number\&. .PP \fBReturns:\fP .RS 4 A string with the version number .RE .PP .SS "BEAGLE_DLLEXPORT int beagleRemoveScaleFactors (int instance, const int * scaleIndices, int count, int cumulativeScaleIndex)" .PP 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\&. .PP \fBParameters:\fP .RS 4 \fIinstance\fP Instance number (input) .br \fIscaleIndices\fP List of scaleBuffers to remove (input) .br \fIcount\fP Number of scaleBuffers in list (input) .br \fIcumulativeScaleIndex\fP Index number of scaleBuffer containing accumulated factors (input) .RE .PP .SS "BEAGLE_DLLEXPORT int beagleResetScaleFactors (int instance, int cumulativeScaleIndex)" .PP Reset scalefactors\&. This function resets a cumulative scale buffer\&. .PP \fBParameters:\fP .RS 4 \fIinstance\fP Instance number (input) .br \fIcumulativeScaleIndex\fP Index number of cumulative scaleBuffer (input) .RE .PP .SS "BEAGLE_DLLEXPORT int beagleSetCategoryRates (int instance, const double * inCategoryRates)" .PP Set category rates\&. This function sets the vector of category rates for an instance\&. .PP \fBParameters:\fP .RS 4 \fIinstance\fP Instance number (input) .br \fIinCategoryRates\fP Array containing categoryCount rate scalers (input) .RE .PP \fBReturns:\fP .RS 4 error code .RE .PP .SS "BEAGLE_DLLEXPORT int beagleSetCategoryWeights (int instance, int categoryWeightsIndex, const double * inCategoryWeights)" .PP Set a category weights buffer\&. This function copies a category weights array into an instance buffer\&. .PP \fBParameters:\fP .RS 4 \fIinstance\fP Instance number (input) .br \fIcategoryWeightsIndex\fP Index of category weights buffer (input) .br \fIinCategoryWeights\fP Category weights array (categoryCount) (input) .RE .PP \fBReturns:\fP .RS 4 error code .RE .PP .SS "BEAGLE_DLLEXPORT int beagleSetEigenDecomposition (int instance, int eigenIndex, const double * inEigenVectors, const double * inInverseEigenVectors, const double * inEigenValues)" .PP Set an eigen-decomposition buffer\&. This function copies an eigen-decomposition into an instance buffer\&. .PP \fBParameters:\fP .RS 4 \fIinstance\fP Instance number (input) .br \fIeigenIndex\fP Index of eigen-decomposition buffer (input) .br \fIinEigenVectors\fP Flattened matrix (stateCount x stateCount) of eigen-vectors (input) .br \fIinInverseEigenVectors\fP Flattened matrix (stateCount x stateCount) of inverse-eigen- vectors (input) .br \fIinEigenValues\fP Vector of eigenvalues .RE .PP \fBReturns:\fP .RS 4 error code .RE .PP .SS "BEAGLE_DLLEXPORT int beagleSetPartials (int instance, int bufferIndex, const double * inPartials)" .PP Set an instance partials buffer\&. This function copies an array of partials into an instance buffer\&. The inPartials array should be stateCount * patternCount * categoryCount in length\&. .PP \fBParameters:\fP .RS 4 \fIinstance\fP Instance number in which to set a partialsBuffer (input) .br \fIbufferIndex\fP Index of destination partialsBuffer (input) .br \fIinPartials\fP Pointer to partials values to set (input) .RE .PP \fBReturns:\fP .RS 4 error code .RE .PP .SS "BEAGLE_DLLEXPORT int beagleSetPatternWeights (int instance, const double * inPatternWeights)" .PP Set pattern weights\&. This function sets the vector of pattern weights for an instance\&. .PP \fBParameters:\fP .RS 4 \fIinstance\fP Instance number (input) .br \fIinPatternWeights\fP Array containing patternCount weights (input) .RE .PP \fBReturns:\fP .RS 4 error code .RE .PP .SS "BEAGLE_DLLEXPORT int beagleSetStateFrequencies (int instance, int stateFrequenciesIndex, const double * inStateFrequencies)" .PP Set a state frequency buffer\&. This function copies a state frequency array into an instance buffer\&. .PP \fBParameters:\fP .RS 4 \fIinstance\fP Instance number (input) .br \fIstateFrequenciesIndex\fP Index of state frequencies buffer (input) .br \fIinStateFrequencies\fP State frequencies array (stateCount) (input) .RE .PP \fBReturns:\fP .RS 4 error code .RE .PP .SS "BEAGLE_DLLEXPORT int beagleSetTipPartials (int instance, int tipIndex, const double * inPartials)" .PP Set an instance partials buffer for tip node\&. This function copies an array of partials into an instance buffer\&. The inPartials array should be stateCount * patternCount in length\&. For most applications this will be used to set the partial likelihoods for the observed states\&. Internally, the partials will be copied categoryCount times\&. .PP \fBParameters:\fP .RS 4 \fIinstance\fP Instance number in which to set a partialsBuffer (input) .br \fItipIndex\fP Index of destination partialsBuffer (input) .br \fIinPartials\fP Pointer to partials values to set (input) .RE .PP \fBReturns:\fP .RS 4 error code .RE .PP .SS "BEAGLE_DLLEXPORT int beagleSetTipStates (int instance, int tipIndex, const int * inStates)" .PP Set the compact state representation for tip node\&. This function copies a compact state representation into an instance buffer\&. Compact state representation is an array of states: 0 to stateCount - 1 (missing = stateCount)\&. The inStates array should be patternCount in length (replication across categoryCount is not required)\&. .PP \fBParameters:\fP .RS 4 \fIinstance\fP Instance number (input) .br \fItipIndex\fP Index of destination compactBuffer (input) .br \fIinStates\fP Pointer to compact states (input) .RE .PP \fBReturns:\fP .RS 4 error code .RE .PP .SS "BEAGLE_DLLEXPORT int beagleSetTransitionMatrices (int instance, const int * matrixIndices, const double * inMatrices, const double * paddedValues, int count)" .PP Set multiple transition matrices\&. This function copies multiple transition matrices into matrix buffers\&. This function is used when the application wishes to explicitly set the transition matrices rather than using the beagleSetEigenDecomposition and beagleUpdateTransitionMatrices functions\&. The inMatrices array should be of size stateCount * stateCount * categoryCount * count\&. .PP \fBParameters:\fP .RS 4 \fIinstance\fP Instance number (input) .br \fImatrixIndices\fP Indices of matrix buffers (input) .br \fIinMatrices\fP Pointer to source transition matrices (input) .br \fIpaddedValues\fP Values to be used for padding for ambiguous states (e\&.g\&. 1 for probability matrices, 0 for derivative matrices) (input) .br \fIcount\fP Number of transition matrices (input) .RE .PP \fBReturns:\fP .RS 4 error code .RE .PP .SS "BEAGLE_DLLEXPORT int beagleSetTransitionMatrix (int instance, int matrixIndex, const double * inMatrix, double paddedValue)" .PP Set a finite-time transition probability matrix\&. This function copies a finite-time transition probability matrix into a matrix buffer\&. This function is used when the application wishes to explicitly set the transition probability matrix rather than using the beagleSetEigenDecomposition and beagleUpdateTransitionMatrices functions\&. The inMatrix array should be of size stateCount * stateCount * categoryCount and will contain one matrix for each rate category\&. .PP \fBParameters:\fP .RS 4 \fIinstance\fP Instance number (input) .br \fImatrixIndex\fP Index of matrix buffer (input) .br \fIinMatrix\fP Pointer to source transition probability matrix (input) .br \fIpaddedValue\fP Value to be used for padding for ambiguous states (e\&.g\&. 1 for probability matrices, 0 for derivative matrices) (input) .RE .PP \fBReturns:\fP .RS 4 error code .RE .PP .SS "BEAGLE_DLLEXPORT int beagleUpdatePartials (const int instance, const \fBBeagleOperation\fP * operations, int operationCount, int cumulativeScaleIndex)" .PP Calculate or queue for calculation partials using a list of operations\&. This function either calculates or queues for calculation a list partials\&. Implementations supporting ASYNCH may queue these calculations while other implementations perform these operations immediately and in order\&. .PP \fBParameters:\fP .RS 4 \fIinstance\fP Instance number (input) .br \fIoperations\fP \fBBeagleOperation\fP list specifying operations (input) .br \fIoperationCount\fP Number of operations (input) .br \fIcumulativeScaleIndex\fP Index number of scaleBuffer to store accumulated factors (input) .RE .PP \fBReturns:\fP .RS 4 error code .RE .PP .SS "BEAGLE_DLLEXPORT int beagleUpdateTransitionMatrices (int instance, int eigenIndex, const int * probabilityIndices, const int * firstDerivativeIndices, const int * secondDerivativeIndices, const double * edgeLengths, int count)" .PP Calculate a list of transition probability matrices\&. This function calculates a list of transition probabilities matrices and their first and second derivatives (if requested)\&. .PP \fBParameters:\fP .RS 4 \fIinstance\fP Instance number (input) .br \fIeigenIndex\fP Index of eigen-decomposition buffer (input) .br \fIprobabilityIndices\fP List of indices of transition probability matrices to update (input) .br \fIfirstDerivativeIndices\fP List of indices of first derivative matrices to update (input, NULL implies no calculation) .br \fIsecondDerivativeIndices\fP List of indices of second derivative matrices to update (input, NULL implies no calculation) .br \fIedgeLengths\fP List of edge lengths with which to perform calculations (input) .br \fIcount\fP Length of lists .RE .PP \fBReturns:\fP .RS 4 error code .RE .PP .SS "BEAGLE_DLLEXPORT int beagleWaitForPartials (const int instance, const int * destinationPartials, int destinationPartialsCount)" .PP Block until all calculations that write to the specified partials have completed\&. This function is optional and only has to be called by clients that 'recycle' partials\&. .PP If used, this function must be called after an beagleUpdatePartials call and must refer to indices of 'destinationPartials' that were used in a previous beagleUpdatePartials call\&. The library will block until those partials have been calculated\&. .PP \fBParameters:\fP .RS 4 \fIinstance\fP Instance number (input) .br \fIdestinationPartials\fP List of the indices of destinationPartials that must be calculated before the function returns .br \fIdestinationPartialsCount\fP Number of destinationPartials (input) .RE .PP \fBReturns:\fP .RS 4 error code .RE .PP .SH "Author" .PP Generated automatically by Doxygen for BEAGLE from the source code\&.