compute_linear_map Subroutine

public subroutine compute_linear_map(src, dst, matrix, rc)

Arguments

Type IntentOptional Attributes Name
real(kind=REAL32), intent(in) :: src(:)
real(kind=REAL32), intent(in) :: dst(:)
type(CSR_SparseMatrix_sp), intent(out) :: matrix
integer, intent(out), optional :: rc

Calls

proc~~compute_linear_map~~CallsGraph proc~compute_linear_map compute_linear_map add_row add_row proc~compute_linear_map->add_row interface~mapl_assert MAPL_Assert proc~compute_linear_map->interface~mapl_assert proc~mapl_return MAPL_Return proc~compute_linear_map->proc~mapl_return at at proc~mapl_return->at insert insert proc~mapl_return->insert proc~mapl_throw_exception MAPL_throw_exception proc~mapl_return->proc~mapl_throw_exception

Called by

proc~~compute_linear_map~~CalledByGraph proc~compute_linear_map compute_linear_map proc~test_compute_linear_map test_compute_linear_map proc~test_compute_linear_map->proc~compute_linear_map

Source Code

   subroutine compute_linear_map(src, dst, matrix, rc)
      real(REAL32), intent(in) :: src(:)
      real(REAL32), intent(in) :: dst(:)
      type(SparseMatrix_sp), intent(out) :: matrix
      ! real(REAL32), allocatable, intent(out) :: matrix(:, :)
      integer, optional, intent(out) :: rc

      real(REAL32) :: val, weight(2)
      integer :: ndx, status
      type(IndexValuePair) :: pair(2)

#ifndef NDEBUG
      _ASSERT(maxval(dst) <= maxval(src), "maxval(dst) > maxval(src)")
      _ASSERT(minval(dst) >= minval(src), "minval(dst) < minval(src)")
      _ASSERT(is_decreasing(src), "src array is not decreasing")
#endif

      ! allocate(matrix(size(dst), size(src)), source=0., _STAT)
      ! Expected 2 non zero entries in each row
      matrix = SparseMatrix_sp(size(dst), size(src), 2*size(dst))
      do ndx = 1, size(dst)
         val = dst(ndx)
         call find_bracket_(val, src, pair)
         call compute_weights_(val, pair%value_, weight)
         if (pair(1) == pair(2)) then
            ! matrix(ndx, pair(1)%index) = weight(1)
            call add_row(matrix, ndx, pair(1)%index, [weight(1)])
         else
            ! matrix(ndx, pair(1)%index) = weight(1)
            ! matrix(ndx, pair(2)%index) = weight(2)
            call add_row(matrix, ndx, pair(1)%index, [weight(1), weight(2)])
         end if
      end do

      _RETURN(_SUCCESS)
   end subroutine compute_linear_map