lowrank Subroutine

private pure subroutine lowrank(this, matrix, rank, method)

Type Bound

tsvd

Arguments

Type IntentOptional Attributes Name
class(tsvd), intent(inout) :: this
real(kind=rk), intent(in), dimension(:, :) :: matrix
integer, intent(in) :: rank
character(len=*), intent(in), optional :: method

Calls

proc~~lowrank~~CallsGraph proc~lowrank forsvd::tsvd%lowrank interface~svd forsvd::svd proc~lowrank->interface~svd proc~svd_rel forsvd::svd_rel interface~svd->proc~svd_rel proc~gesdd_rel forsvd::gesdd_rel proc~svd_rel->proc~gesdd_rel proc~gesvd_rel forsvd::gesvd_rel proc~svd_rel->proc~gesvd_rel

Called by

proc~~lowrank~~CalledByGraph proc~lowrank forsvd::tsvd%lowrank proc~compress_pixels forsvd::pixel%compress_pixels proc~compress_pixels->proc~lowrank program~test4 test4 program~test4->proc~lowrank program~test5 test5 program~test5->proc~compress_pixels

Source Code

   pure subroutine lowrank(this, matrix, rank, method)
      class(tsvd),  intent(inout)            :: this
      real(rk), dimension(:, :), intent(in)  :: matrix
      integer,      intent(in)               :: rank
      character(*), intent(in), optional     :: method
      real(rk), dimension(:, :), allocatable :: U, VT
      real(rk), dimension(:),    allocatable :: S
      integer                                :: i, j, irank

      this%matrix = matrix
      this%nrow   = size(matrix,1)
      this%ncol   = size(matrix,2)
      this%rank   = rank

      allocate(U(this%nrow,this%nrow), S(min(this%nrow,this%ncol)), VT(this%ncol,this%ncol))

      call svd(this%matrix, U,S,VT, method)

      allocate(this%matrix_app(this%nrow,this%ncol))
      this%matrix_app = 0.0_rk
      do irank = 1, rank
         do j = 1,this%ncol
            do i = 1,this%nrow
               this%matrix_app(i,j) = this%matrix_app(i,j) + U(i, irank)*S(irank)*VT(irank, j)
            end do
         end do
      end do

   end subroutine lowrank