ʻOhana
Population structure, admixture history, and selection using learning methods.
Public Types | Static Public Member Functions
jade::basic_cov2nwk< TValue > Class Template Reference

A template for a class that approximates covariance matrices as Newick-formatted trees. More...

#include <jade.cov2nwk.hpp>

+ Collaboration diagram for jade::basic_cov2nwk< TValue >:

Public Types

typedef TValue value_type
 The value type. More...
 

Static Public Member Functions

static void execute (std::istream &in, std::ostream &out)
 Executes the program through the specified streams. More...
 

Detailed Description

template<typename TValue>
class jade::basic_cov2nwk< TValue >

A template for a class that approximates covariance matrices as Newick-formatted trees.

Definition at line 20 of file jade.cov2nwk.hpp.

Member Typedef Documentation

◆ value_type

template<typename TValue >
typedef TValue jade::basic_cov2nwk< TValue >::value_type

The value type.

Definition at line 24 of file jade.cov2nwk.hpp.

Member Function Documentation

◆ execute()

template<typename TValue >
static void jade::basic_cov2nwk< TValue >::execute ( std::istream &  in,
std::ostream &  out 
)
inlinestatic

Executes the program through the specified streams.

Parameters
inThe input stream.
outThe output stream.

Definition at line 29 of file jade.cov2nwk.hpp.

32  {
33  typedef basic_matrix<value_type> matrix_type;
34  const matrix_type c (in);
35 
36  typedef basic_verification<value_type> verification_type;
37  verification_type::validate_c(c);
38 
39  const auto rk = c.get_height();
40  const auto k = rk + 1;
41 
42  matrix_type padded_c (k, k);
43  for (size_t i = 0; i < rk; i++)
44  for (size_t j = 0; j < rk; j++)
45  padded_c(i + 1, j + 1) = c(i, j);
46 
47  matrix_type distances (k, k);
48  for (size_t i = 0; i < k; i++)
49  {
50  const auto c_ii = padded_c(i, i);
51  for (size_t j = 0; j < k; j++)
52  {
53  const auto c_jj = padded_c(j, j);
54  const auto c_ij = padded_c(i, j);
55  distances(i, j) = c_ii + c_jj - c_ij - c_ij;
56  }
57  }
58 
59  typedef basic_neighbor_joining<value_type> algorithm_type;
60  const algorithm_type algorithm (distances);
61 
62  algorithm.write(out);
63  out << std::endl;
64  }

The documentation for this class was generated from the following file: