49 #include <unordered_map> 50 #include <unordered_set> 68 for(
auto const& name : pqry.
names() ) {
69 mult += name.multiplicity;
77 for(
auto const& pqry : sample.
pqueries() ) {
89 auto result = std::vector<double>( sample.
tree().
edge_count(), 0.0 );
91 for(
auto const& pqry : sample.
pqueries() ) {
93 for(
auto const& place : pqry.placements() ) {
94 result[ place.edge().index() ] += place.like_weight_ratio * mult;
106 if( sample_set.
size() == 0 ) {
111 auto const set_size = sample_set.
size();
115 if( result.rows() == 0 || result.cols() == 0 ) {
120 #pragma omp parallel for schedule(dynamic) 121 for(
size_t i = 0; i < set_size; ++i ) {
122 auto const& smp = sample_set[ i ];
124 if( smp.tree().edge_count() != result.cols() ) {
125 throw std::runtime_error(
126 "Cannot calculate placement weights per edge matrix " 127 "for Samples with Trees of different size." 131 for(
auto const& pqry : smp.pqueries() ) {
133 for(
auto const& place : pqry.placements() ) {
134 result( i, place.edge().index() ) += place.like_weight_ratio * mult;
145 for(
const auto& pqry : smp.
pqueries() ) {
147 for(
auto const& name : pqry.names() ) {
148 mult += name.multiplicity;
151 double lwr_sum = 0.0;
152 for(
auto const& place : pqry.placements() ) {
153 lwr_sum += place.like_weight_ratio;
155 sum += lwr_sum * mult;
166 auto result = std::vector<double>( sample.
tree().
edge_count(), 0.0 );
168 for(
auto const& pqry : sample.
pqueries() ) {
169 for(
auto const& place : pqry.placements() ) {
170 result[ place.edge().index() ] += place.like_weight_ratio;
182 if( sample_set.
size() == 0 ) {
187 auto const set_size = sample_set.
size();
191 if( result.rows() == 0 || result.cols() == 0 ) {
196 #pragma omp parallel for schedule(dynamic) 197 for(
size_t i = 0; i < set_size; ++i ) {
198 auto const& smp = sample_set[ i ];
200 if( smp.tree().edge_count() != result.cols() ) {
201 throw std::runtime_error(
202 "Cannot calculate placement weights per edge matrix " 203 "for Samples with Trees of different size." 207 for(
auto const& pqry : smp.pqueries() ) {
208 for(
auto const& place : pqry.placements() ) {
209 result( i, place.edge().index() ) += place.like_weight_ratio;
220 for(
const auto& pqry : smp.
pqueries() ) {
221 for(
auto& place : pqry.placements() ) {
222 sum += place.like_weight_ratio;
std::vector< double > placement_mass_per_edge_without_multiplicities(Sample const &sample)
Return a vector that contains the sum of the masses of the PqueryPlacements per edge of the tree of t...
size_t size() const
Return the size of the SampleSet, i.e., the number of Samples.
std::vector< double > placement_mass_per_edges_with_multiplicities(Sample const &sample)
Return a vector that contains the sum of the masses of the PqueryPlacements per edge of the tree of t...
Provides some valuable algorithms that are not part of the C++ 11 STL.
PlacementTree & tree()
Get the PlacementTree of this Sample.
Header of CommonTree distance methods.
A pquery holds a set of PqueryPlacements and a set of PqueryNames.
double total_placement_mass_without_multiplicities(Sample const &smp)
Get the summed mass of all PqueryPlacements in all Pqueries of the given Sample, where mass is measu...
size_t edge_count() const
Return the number of TreeEdges of the Tree.
double sum(const Histogram &h)
Container namespace for all symbols of genesis in order to keep them separate when used as a library...
Provides some valuable additions to STD.
utils::Range< iterator_pqueries > pqueries()
Return a Range iterator to the Pqueries .
Store a set of Samples with associated names.
double total_multiplicity(Pquery const &pqry)
Return the sum of all multiplicities of the Pquery.
double total_placement_mass_with_multiplicities(Sample const &smp)
Get the mass of all PqueryPlacements of the Sample, using the multiplicities as factors.
Manage a set of Pqueries along with the PlacementTree where the PqueryPlacements are placed on...
utils::Range< iterator_names > names()
Return a Range iterator to the PqueryNames.
Header of Tree distance methods.