vectorized_process_distance_matrix: TopoLow Core Functions Vectorized Processing of Dissimilarity...

View source: R/core.R

vectorized_process_distance_matrixR Documentation

TopoLow Core Functions Vectorized Processing of Dissimilarity Matrix for Convergence Error Calculations

Description

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.

Usage

vectorized_process_distance_matrix(
  distances_numeric,
  threshold_mask,
  p_dist_mat
)

Arguments

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

Details

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.

Value

Numeric matrix with processed distance values. Elements where threshold conditions are not satisfied will contain NA.


topolow documentation built on Aug. 31, 2025, 1:07 a.m.