biomcmc-lib  0.1
low level library for phylogenetic analysis
distance_generator.h
Go to the documentation of this file.
1 /*
2  * This file is part of biomcmc-lib, , a low-level library for phylogenomic analysis.
3  * Copyright (C) 2019-today Leonardo de Oliveira Martins [ leomrtns at gmail.com; http://www.leomartins.org ]
4  * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
5  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
6  * details (file "COPYING" or http://www.gnu.org/copyleft/gpl.html).
7  */
8 
13 #ifndef _biomcmc_distance_generator_h_
14 #define _biomcmc_distance_generator_h_
15 
16 #include "distance_matrix.h" // idea is to replace/extend distance_matrix
17 // TODO: how to extend to subsamples s.t. calling function doenst know but whole matrix is updated
19 
21 {
22  int n_samples, n_distances; // how many elements (samples) in matrix, and how many distances the function calculates at once
23  int which_distance; // which of the n_distances is being currently used
24  double **dist; // distance, allowing for negative values
25  bool *cached; // if pair has been calculated or not (we assume all distances for this pair are calculated together)
26  void *data; // extra data (original features, sequences, etc. used by the distance_function() )
27  void (*distance_function) (void*, int, int, double*); // defined elsewhere, receives data, i, and j, returns double[]
28  int ref_counter;
29 };
30 
31 distance_generator new_distance_generator (int n_samples, int n_distances);
32 void del_distance_generator (distance_generator d);
33 double distance_generator_get_at_distance (distance_generator d, int i, int j, int which_distance);
34 double distance_generator_get (distance_generator d, int i, int j);
37 void distance_generator_set_function_data (distance_generator d, void (*lowlevel_dist_funct)(void*, int, int, double*), void *extra_data);
40 void distance_generator_set_which_distance (distance_generator d, int which_distance);
41 void distance_generator_reset (distance_generator d);
42 
43 #endif
void distance_generator_set_function_data(distance_generator d, void(*lowlevel_dist_funct)(void *, int, int, double *), void *extra_data)
defines distance calculation function wrapper, and all extra data needed by wrapper; no check is done...
Definition: distance_generator.c:69
distance matrix, that can be used in alignments and trees, and patristic-distance based species dista...
Definition: distance_generator.h:20
void distance_generator_set_which_distance(distance_generator d, int which_distance)
distance wrapper may return several distances, but only one is returned by get(); this sets which one...
Definition: distance_generator.c:76