set_sparsity_mode Subroutine

private subroutine set_sparsity_mode(me, sparsity_mode, xlow_for_sparsity, xhigh_for_sparsity)

Set sparsity mode.

Type Bound

numdiff_type

Arguments

Type IntentOptional Attributes Name
class(numdiff_type), intent(inout) :: me
integer, intent(in) :: sparsity_mode

the sparsity computation method: 1 - assume dense, 2 - three-point simple method, 3 - will be specified by the user in a subsequent call to set_sparsity_pattern. 4 - computes a two-point jacobian at num_sparsity_points points.

real(kind=wp), intent(in), optional, dimension(:) :: xlow_for_sparsity

lower bounds on x used for sparsity computation (when sparsity_mode is 2). If not present, then xlow is used.

real(kind=wp), intent(in), optional, dimension(:) :: xhigh_for_sparsity

upper bounds on x used for sparsity computation (when sparsity_mode is 2). If not present, then xhigh is used.


Calls

proc~~set_sparsity_mode~~CallsGraph proc~set_sparsity_mode numerical_differentiation_module::numdiff_type%set_sparsity_mode proc~raise_exception numerical_differentiation_module::numdiff_type%raise_exception proc~set_sparsity_mode->proc~raise_exception proc~set_numdiff_sparsity_bounds numerical_differentiation_module::numdiff_type%set_numdiff_sparsity_bounds proc~set_sparsity_mode->proc~set_numdiff_sparsity_bounds proc~set_numdiff_sparsity_bounds->proc~raise_exception

Called by

proc~~set_sparsity_mode~~CalledByGraph proc~set_sparsity_mode numerical_differentiation_module::numdiff_type%set_sparsity_mode proc~initialize_numdiff numerical_differentiation_module::numdiff_type%initialize_numdiff proc~initialize_numdiff->proc~set_sparsity_mode proc~initialize_numdiff_for_diff numerical_differentiation_module::numdiff_type%initialize_numdiff_for_diff proc~initialize_numdiff_for_diff->proc~set_sparsity_mode

Source Code

    subroutine set_sparsity_mode(me,sparsity_mode,xlow_for_sparsity,xhigh_for_sparsity)

    implicit none

    class(numdiff_type),intent(inout) :: me
    integer,intent(in) :: sparsity_mode !! the sparsity computation method:
                                        !! **1** - assume dense,
                                        !! **2** - three-point simple method,
                                        !! **3** - will be specified by the user in
                                        !! a subsequent call to [[set_sparsity_pattern]].
                                        !! **4** - computes a two-point jacobian
                                        !! at `num_sparsity_points` points.
    real(wp),dimension(:),intent(in),optional :: xlow_for_sparsity   !! lower bounds on `x` used for
                                                                     !! sparsity computation (when
                                                                     !! `sparsity_mode` is 2). If not
                                                                     !! present, then `xlow` is used.
    real(wp),dimension(:),intent(in),optional :: xhigh_for_sparsity  !! upper bounds on `x` used for
                                                                     !! sparsity computation (when
                                                                     !! `sparsity_mode` is 2). If not
                                                                     !! present, then `xhigh` is used.

    if (me%exception_raised) return ! check for exceptions

    ! set the sparsity function
    select case (sparsity_mode)
    case(1)  ! dense
        me%compute_sparsity => compute_sparsity_dense
    case(3)  ! user defined
        me%compute_sparsity => null()
    case(2)  ! three-point simple method
        me%compute_sparsity => compute_sparsity_random
        ! in this case, we have the option of specifying
        ! separate bounds for computing the sparsity:
        call me%set_numdiff_sparsity_bounds(xlow_for_sparsity,xhigh_for_sparsity)
    case(4)  ! compute 2-point jacobian in specified number of points
        me%compute_sparsity => compute_sparsity_random_2
        ! in this case, we have the option of specifying
        ! separate bounds for computing the sparsity:
        call me%set_numdiff_sparsity_bounds(xlow_for_sparsity,xhigh_for_sparsity)
    case default
        call me%raise_exception(5,'set_sparsity_mode',&
                                  'sparsity_mode must be 1, 2, 3, or 4.')
        return
    end select

    end subroutine set_sparsity_mode