public Tuple <EdgeValueType[], EdgeValueType> CreateAlphaPartitionTreeElementArray <ElementValueType, EdgeValueType>( IAlgebraReal <EdgeValueType> algebra, IFunctionDissimilarity <ElementValueType, EdgeValueType> edge_function, ElementValueType [] element_values) { int element_count = this.ElementCount; EdgeValueType[] element_and_edge_values = new EdgeValueType[element_count]; EdgeValueType max_value = algebra.MinValue; // do x edges for (int element_index = x_edge_offset; element_index < y_edge_offset; element_index++) { if (element_index % raster_size[0] != raster_size[0] - 1) { element_and_edge_values[element_index] = edge_function.Compute( element_values[element_index - x_edge_offset], element_values[element_index - x_edge_offset + 1]); max_value = algebra.Max(max_value, element_and_edge_values[element_index]); } } // do y edges for (int element_index = y_edge_offset; element_index < z_edge_offset; element_index++) { if ((element_index % size_xy) / raster_size[0] != raster_size[1] - 1) { element_and_edge_values[element_index] = edge_function.Compute( element_values[element_index - y_edge_offset], element_values[element_index - y_edge_offset + this.size_x]); max_value = algebra.Max(max_value, element_and_edge_values[element_index]); } } // do z edges for (int element_index = z_edge_offset; element_index < (element_and_edge_values.Length - size_xy); element_index++) { element_and_edge_values[element_index] = edge_function.Compute( element_values[element_index - z_edge_offset], element_values[element_index - z_edge_offset + this.size_xy]); max_value = algebra.Max(max_value, element_and_edge_values[element_index]); } // set real node values to max value for (int element_index = 0; element_index < x_edge_offset; element_index++) { element_and_edge_values[element_index] = max_value; } // flip all edges for (int element_index = x_edge_offset; element_index < element_count; element_index++) { element_and_edge_values[element_index] = algebra.Subtract(max_value, element_and_edge_values[element_index]); } return(new Tuple <EdgeValueType[], EdgeValueType>(element_and_edge_values, max_value)); }
public Tuple <EdgeValueType[], EdgeValueType> CreateAlphaPartitionTreeElementArray <ElementValueType, EdgeValueType>( IAlgebraReal <EdgeValueType> algebra, IFunctionDissimilarity <ElementValueType, EdgeValueType> edge_function, ElementValueType[] element_values) { int element_count = this.ElementCount; EdgeValueType [] new_image = new EdgeValueType [element_count]; EdgeValueType max_value = algebra.MinValue; // do x edges for (int element_index = x_edge_offset; element_index < element_count; element_index++) { new_image[element_index] = edge_function.Compute( element_values[element_index - x_edge_offset], element_values[element_index - x_edge_offset + 1]); max_value = algebra.Max(max_value, new_image[element_index]); } // set node values for (int element_index = 0; element_index < x_edge_offset; element_index++) { new_image[element_index] = max_value; } // flip x edges for (int element_index = x_edge_offset; element_index < element_count; element_index++) { new_image[element_index] = algebra.Subtract(max_value, new_image[element_index]); } return(new Tuple <EdgeValueType[], EdgeValueType>(new_image, max_value)); }