vectorized_process_distance_matrix | R Documentation |
Efficiently processes elements of the dissimilarity matrix for calculating convergence error using pre-processed numeric representations of thresholds. This optimized version eliminates expensive string operations during optimization.
vectorized_process_distance_matrix(
distances_numeric,
threshold_mask,
p_dist_mat
)
distances_numeric |
Numeric matrix. The numeric dissimilarity values (without threshold indicators) |
threshold_mask |
Integer matrix. Codes representing threshold types: 1 for "greater than" (>), -1 for "less than" (<), or 0 for exact values |
p_dist_mat |
Numeric matrix. The calculated distance matrix to compare against |
This function handles threshold logic for convergence error calculation by using pre-processed numeric matrices:
For "greater than" thresholds (threshold_mask = 1): Returns the numeric value if the calculated distance is less than the threshold, otherwise returns NA
For "less than" thresholds (threshold_mask = -1): Returns the numeric value if the calculated distance is greater than the threshold, otherwise returns NA
For regular values (threshold_mask = 0): Returns the numeric value
This function operates on entire matrices at once using vectorized operations, which is significantly faster than processing each element individually.
Numeric matrix with processed distance values. Elements where threshold conditions are not satisfied will contain NA.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.