scale_real_real Function

private pure function scale_real_real(real_array, a, b) result(real_scaled_array)

Normalize the input real array to the range [0, 1]

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in), dimension(:) :: real_array
real(kind=wp), intent(in) :: a
real(kind=wp), intent(in) :: b

Return Value real(kind=wp), dimension(size(real_array))


Called by

proc~~scale_real_real~~CalledByGraph proc~scale_real_real scale_real_real proc~scale_real_int scale_real_int proc~scale_real_int->proc~scale_real_real proc~extract Colormap%extract proc~extract->proc~scale_real_int program~extract extract program~extract->proc~extract

Source Code

    pure function scale_real_real(real_array,a,b) result(real_scaled_array)
        real(wp), dimension(:), intent(in) :: real_array
        real(wp), intent(in) :: a, b
        real(wp), dimension(size(real_array)) :: real_scaled_array
        real(wp) :: minValue, maxValue
        real(wp), parameter :: tolerance = 1.0e-12_wp

        ! Find minimum and maximum values in the input real array
        minValue = minval(real_array)
        maxValue = maxval(real_array)

        if (abs(maxValue-minValue) < tolerance) then
            real_scaled_array = b
        else
            real_scaled_array = a + (b - a) * (real_array - minValue) / (maxValue - minValue)
        end if
    end function scale_real_real