G.2.6 Get Value ELL_Matrix Functions

The main documentation of the Get Value ELL_Matrix Functions contains additional explanation of this code listing.

  define([REAL_ACCESS_ROUTINE],[
    pushdef([VALUE], [$1])
    pushdef([Get_REAL_VALUE_ELLM], expand(Get_VALUE_ELLM))
    ifelse(
      VALUE, [Two_Norm_Estimate],
        [pushdef([VALUE_is_Updated], Two_Norm_is_Updated)],
      VALUE, [Two_Norm_Range],
        [pushdef([VALUE_is_Updated], Two_Norm_is_Updated)],
      [pushdef([VALUE_is_Updated], expand(VALUE_is_Updated))])

    function Get_REAL_VALUE_ELLM (ELLM) result(VALUE)

      ! Use association information.

      ifelse(VALUE, [Two_Norm_Estimate], [
        use Caesar_Numbers_Module, only: half
      ])

      ! Input/Output variables.

      ! ELL_Matrix object.
      type(ELL_Matrix_type), intent(inout) :: ELLM 

      ! Output variables.

      ifelse(
        VALUE, [Two_Norm_Range],
          [type(real), dimension(2) :: VALUE ! ELL_Matrix value to be output.],
        [type(real) :: VALUE                 ! ELL_Matrix value to be output.])

      ! Internal variables.
  
      ifelse(
        VALUE, [One_Norm],
          [type(real,1) :: Column_Sums          ! Column sum temporary.    ],
        VALUE, [Two_Norm_Estimate],
          [type(real), dimension(2) :: TNRange  ! Two Norm temporary.      ],
        VALUE, [Two_Norm_Range],
          [type(real) :: N                      ! Matrix row dimension.     
           type(real) :: M                      ! Matrix column dimension. ],
        [])

      !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  
      ! Verify requirements.
  
      VERIFY(Valid_State(ELLM),5)       ! ELL_Matrix is valid.

      ! Set value.

      if (ELLM%VALUE_is_Updated) then
        VALUE = ELLM%VALUE
      else
        ifelse(
          VALUE, [Average],
            [VALUE = Global_Sum(ELLM%Values) / &
                     Length_Total(ELLM%Row_Structure) / &
                     Length_Total(ELLM%Column_Structure) ],
          VALUE, [Frobenius_Norm],
            [VALUE = SQRT(Global_Sum(ELLM%Values**2))],
          VALUE, [Infinity_Norm],
            [VALUE = Global_MaxVal(SUM(ABS(ELLM%Values),2))],
          VALUE, [Maximum],
            [VALUE = Global_MaxVal(ELLM%Values)],
          VALUE, [Minimum],
            [VALUE = Global_MinVal(ELLM%Values)],
          VALUE, [One_Norm],
            [call Initialize (Column_Sums, Length_PE(ELLM%Column_Structure))
             call Scatter_SUM (Column_Sums, ABS(ELLM%Values), ELLM%Columns)
             VALUE = Global_MaxVal(Column_Sums)
             call Finalize (Column_Sums)],
          VALUE, [Two_Norm_Estimate],
            [TNRange = Two_Norm_Range(ELLM)
             VALUE = half * (TNRange(1) + TNRange(2))],
          VALUE, [Two_Norm_Range],
            [N = changetype(real, Length_Total(ELLM%Row_Structure))
             M = changetype(real, Length_Total(ELLM%Column_Structure))
             VALUE[](1) = MAX(Frobenius_Norm(ELLM)/SQRT(N), &
                              Maximum(ELLM),                &
                              Infinity_Norm(ELLM)/SQRT(N),  &
                              One_Norm(ELLM)/SQRT(M))
             VALUE[](2) = MIN(Frobenius_Norm(ELLM),         &
                              SQRT(M*N)*Maximum(ELLM),      &
                              SQRT(M)*Infinity_Norm(ELLM),  &
                              SQRT(N)*One_Norm(ELLM),       &
                              SQRT(One_Norm(ELLM)*Infinity_Norm(ELLM)))],
          VALUE, [Sum],
            [VALUE = Global_Sum(ELLM%Values)],
          [])
        ELLM%VALUE_is_Updated = .true.
        ELLM%VALUE = VALUE
      end if

      ! Verify guarantees - none.
  
      return
    end function Get_REAL_VALUE_ELLM

    popdef([VALUE])
    popdef([Get_REAL_VALUE_ELLM])
    popdef([VALUE_is_Updated])
  ])

  fortext([Value],
          [Average Frobenius_Norm Infinity_Norm Maximum Minimum One_Norm Sum 
           Two_Norm_Estimate Two_Norm_Range],[
    REAL_ACCESS_ROUTINE(Value)
  ])

  define([INTEGER_ACCESS_ROUTINE],[
    pushdef([VALUE], [$1])
    pushdef([VALUE_Result], expand(VALUE_Result))
    pushdef([Get_INTEGER_VALUE_ELLM], expand(Get_VALUE_ELLM))

    function Get_INTEGER_VALUE_ELLM (ELLM) result(VALUE_Result)

      ! Input/Output variables.

      ! ELL_Matrix object.
      type(ELL_Matrix_type), intent(in) :: ELLM 

      ! Output variables.

      type(integer) :: VALUE_Result     ! ELL_Matrix value to be output.

      !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  
      ! Verify requirements.
  
      VERIFY(Valid_State(ELLM),5)       ! ELL_Matrix is valid.

      ! Set value.

      ifelse(
        VALUE, [First_Row_PE],
          [VALUE_Result = First_PE(ELLM%Row_Structure)],
        VALUE, [Last_Row_PE],
          [VALUE_Result = Last_PE(ELLM%Row_Structure)],
        VALUE, [Max_Nonzeros],
          [VALUE_Result = ELLM%Max_Nonzeros],
        VALUE, [NColumns],
          [VALUE_Result = Length_Total(ELLM%Column_Structure)],
        VALUE, [NRows_PE],
          [VALUE_Result = Length_PE(ELLM%Row_Structure)],
        VALUE, [NRows_Total],
          [VALUE_Result = Length_Total(ELLM%Row_Structure)],
        [])

      ! Verify guarantees - none.
  
      return
    end function Get_INTEGER_VALUE_ELLM

    popdef([VALUE])
    popdef([VALUE_Result])
    popdef([Get_INTEGER_VALUE_ELLM])
  ])

  fortext([Value],
          [First_Row_PE Last_Row_PE Max_Nonzeros NColumns NRows_PE 
           NRows_Total],[
    INTEGER_ACCESS_ROUTINE(Value)
  ])

  function Get_Name_ELLM (ELLM) result(Name)
  
    ! Input variables.

    ! ELL_Matrix object.
    type(ELL_Matrix_type), intent(in) :: ELLM 
  
    ! Output variables.
  
    type(character,80) :: Name      ! ELL_Matrix value to be output.
  
    !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  
    ! Verify requirements.
  
    VERIFY(Valid_State(ELLM),5)       ! ELL_Matrix is valid.
  
    ! Set value.
  
    Name = ELLM%Name

    ! Verify guarantees - none.
  
    return
  end function Get_Name_ELLM



Michael L. Hall