![]() |
Bsoft 2.1.4
Bernard's software package
|
Utility functions for matrices. More...
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.
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.
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.
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. |
int matrix_log_1_R | ( | Matrix | matrix | ) |
Calculates the logarithmic derivative of an R-factor in a matrix.
matrix | pairwise square matrix. |
int matrix_normalize | ( | Matrix & | m | ) |
Normalizes a matrix.
&m | matrix. |
The rows and columns are alternatively iteratively normalized until the error is small enough.
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.