A toolkit for working with phylogenetic data.
v0.19.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
tree/mass_tree/functions.hpp
Go to the documentation of this file.
1 #ifndef GENESIS_TREE_MASS_TREE_FUNCTIONS_H_
2 #define GENESIS_TREE_MASS_TREE_FUNCTIONS_H_
3 
4 /*
5  Genesis - A toolkit for working with phylogenetic data.
6  Copyright (C) 2014-2017 Lucas Czech
7 
8  This program is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 3 of the License, or
11  (at your option) any later version.
12 
13  This program is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program. If not, see <http://www.gnu.org/licenses/>.
20 
21  Contact:
22  Lucas Czech <lucas.czech@h-its.org>
23  Exelixis Lab, Heidelberg Institute for Theoretical Studies
24  Schloss-Wolfsbrunnenweg 35, D-69118 Heidelberg, Germany
25 */
26 
34 #include <cstddef>
35 #include <utility>
36 #include <vector>
37 
38 namespace genesis {
39 
40 // =================================================================================================
41 // Forward Declarations
42 // =================================================================================================
43 
44 namespace utils {
45 
46  template<typename T>
47  class Matrix;
48 
49 }
50 
51 namespace tree {
52 
53  class Tree;
54  class TreeNode;
55  class TreeEdge;
56 
57  using MassTree = Tree;
58 
59 }
60 
61 namespace tree {
62 
63 // =================================================================================================
64 // Manipulate Masses
65 // =================================================================================================
66 
77  MassTree const& lhs,
78  MassTree const& rhs,
79  double const scaler_lhs = 1.0,
80  double const scaler_rhs = 1.0
81 );
82 
94  MassTree& lhs,
95  MassTree const& rhs,
96  double const scaler_lhs = 1.0,
97  double const scaler_rhs = 1.0
98 );
99 
103 void mass_tree_clear_masses( MassTree& tree );
104 
108 void mass_tree_reverse_signs( MassTree& tree );
109 
113 void mass_tree_scale_masses( MassTree& tree, double factor );
114 
119 
125 
135 
146 
169 double mass_tree_binify_masses( MassTree& tree, size_t number_of_bins );
170 
171 // =================================================================================================
172 // Others
173 // =================================================================================================
174 
181 std::vector<double> mass_tree_mass_per_edge( MassTree const& tree );
182 
193 double mass_tree_sum_of_masses( MassTree const& tree );
194 
216 bool mass_tree_validate( MassTree const& tree, double valid_total_mass_difference = -1.0);
217 
218 } // namespace tree
219 } // namespace genesis
220 
221 #endif // include guard
void mass_tree_merge_trees_inplace(MassTree &lhs, MassTree const &rhs, double const scaler_lhs, double const scaler_rhs)
Merge all masses of two MassTrees by adding them to the first MassTree.
void mass_tree_reverse_signs(MassTree &tree)
Reverse the sign of each mass point on a MassTree.
double mass_tree_sum_of_masses(MassTree const &tree)
Return the total sum of all masses on the MassTree.
double mass_tree_center_masses_on_branches_averaged(MassTree &tree)
Accumulate all masses of a MassTree at the average mass position per edge.
std::vector< double > mass_tree_mass_per_edge(MassTree const &tree)
Return a std::vector that contains the total Mass for each edge of the given MassTree.
void mass_tree_transform_to_unit_branch_lengths(MassTree &tree)
Set all branch lengths of a MassTree to 1.0, while keeping the relative position of all masses on the...
Tree MassTree
Alias for a Tree that stores masses on its TreeEdges.
MassTree mass_tree_merge_trees(MassTree const &lhs, MassTree const &rhs, double const scaler_lhs, double const scaler_rhs)
Merge all masses of two MassTrees into one and return it.
void mass_tree_clear_masses(MassTree &tree)
Clear all masses of a MassTree, while keeping its topology.
void mass_tree_scale_masses(MassTree &tree, double factor)
Scale all masses of a MassTree with the multiplicative factor factor.
void mass_tree_normalize_masses(MassTree &tree)
Scale all masses of a MassTree so that they sum up to 1.0.
double mass_tree_center_masses_on_branches(MassTree &tree)
Accumulate all masses of a MassTree on the centers of their edges.
double mass_tree_binify_masses(MassTree &tree, size_t number_of_bins)
Accumulate all masses of a MassTree into bins on each branch.
bool mass_tree_validate(MassTree const &tree, double valid_total_mass_difference)
Validate the data on a MassTree.