|
Bsoft
2.1.0
Bernard's software package
|
Utility functions for matrices. More...
Go to the source code of this file.
Functions | |
| int | matrix_normalize (Matrix &m) |
| Normalizes a matrix. More... | |
| double | matrix_find_cutoff_for_number (Matrix m, int n) |
| Calculates a cutoff to ensure that the given number of elements fall below it. More... | |
| int | matrix_log_1_R (Matrix matrix) |
| Calculates the logarithmic derivative of an R-factor in a matrix. More... | |
| int * | matrix_find_linear_sequence (Matrix, int window) |
| Finds a linear sequence of elements based on a pairwise matrix. More... | |
| int | matrix_permute (int i, int j, Matrix, int *order, double *best_R, int *best_order) |
| Permutes the order of a pairwise matrix and calculate a distance criterion. More... | |
| double | matrix_calc_dist_fit (Matrix, int *order) |
| Calculates an R-factor for a specific order of elements in a pairwise matrix. More... | |
Utility functions for matrices.
Definition in file matrix_util.h.
| double matrix_calc_dist_fit | ( | Matrix | matrix, |
| int * | order | ||
| ) |
Calculates an R-factor for a specific order of elements in a pairwise matrix.
| matrix | pairwise square matrix. |
| *order | n-value array holding the order. |
A new matrix is composed with the lower triangle taken from the input
matrix in the given order, and the upper triangle calculated as the
sum of the diagonal elements between the indices of the element.
I.e, if i and j are the indices of an upper triangle element, then
it is the sum of all the diagonal elements from i to j:
up(i,j) = sum(mat(k,k+1)) for i<=k<j
The difference between the lower and upper triangles is then calculated
as:
1 up(i,j) - upmin lo(j,i) - lomin
R = sum(----- * (--------------- - ---------------) )
i - j upmax - upmin lomax - lomin
where upmin, upmax, lomin, and lomax are the extremes in each triangle.
Definition at line 232 of file matrix_util.cpp.
| double matrix_find_cutoff_for_number | ( | Matrix | m, |
| int | n | ||
| ) |
Calculates a cutoff to ensure that the given number of elements fall below it.
| m | pairwise square matrix. |
| n | number of elements below cutoff. |
Each column is scanned and the cutoff adjusted so that at least the given number of elements will fall below it.
Definition at line 78 of file matrix_util.cpp.
| int* matrix_find_linear_sequence | ( | Matrix | matrix, |
| int | window | ||
| ) |
Finds a linear sequence of elements based on a pairwise matrix.
| matrix | pairwise square matrix. |
| window | range of elements to permute. |
Definition at line 129 of file matrix_util.cpp.
| int matrix_log_1_R | ( | Matrix | matrix | ) |
Calculates the logarithmic derivative of an R-factor in a matrix.
| matrix | pairwise square matrix. |
Definition at line 107 of file matrix_util.cpp.
| int matrix_normalize | ( | Matrix & | m | ) |
Normalizes a matrix.
| &m | matrix. |
The rows and columns are alternatively iteratively normalized until the error is small enough.
Definition at line 27 of file matrix_util.cpp.
| int matrix_permute | ( | int | i, |
| int | j, | ||
| Matrix | matrix, | ||
| int * | order, | ||
| double * | best_R, | ||
| int * | best_order | ||
| ) |
Permutes the order of a pairwise matrix and calculate a distance criterion.
| i | start of window within the order array. |
| j | end of window within the order array. |
| matrix | pairwise square matrix. |
| *order | n-value array holding the current order. |
| *best_R | R-factor for the best order. |
| *best_order | n-value array holding the best order. |
A recursive function to pass through all possible permutations within a given window.
Definition at line 182 of file matrix_util.cpp.