pca Subroutine

private impure subroutine pca(this, matrix, npc, method, coeff, score, latent, explained, matrix_app)

Type Bound

tpca

Arguments

Type IntentOptional Attributes Name
class(tpca), intent(inout) :: this
real(kind=rk), intent(in), dimension(:,:) :: matrix
integer, intent(in), optional :: npc
character(len=*), intent(in), optional :: method
real(kind=rk), intent(out), dimension(:,:), allocatable :: coeff
real(kind=rk), intent(out), optional, dimension(:,:), allocatable :: score
real(kind=rk), intent(out), optional, dimension(:), allocatable :: latent
real(kind=rk), intent(out), optional, dimension(:), allocatable :: explained
real(kind=rk), intent(out), optional, dimension(:,:), allocatable :: matrix_app

Calls

proc~~pca~~CallsGraph proc~pca forpca::tpca%pca proc~cmp_explained_variance forpca::tpca%cmp_explained_variance proc~pca->proc~cmp_explained_variance proc~compute_coeff forpca::tpca%compute_coeff proc~pca->proc~compute_coeff proc~compute_score forpca::tpca%compute_score proc~pca->proc~compute_score proc~initialize forpca::tpca%initialize proc~pca->proc~initialize proc~reconstruct_data forpca::tpca%reconstruct_data proc~pca->proc~reconstruct_data eig eig proc~compute_coeff->eig mask mask proc~compute_coeff->mask order order proc~compute_coeff->order svd svd proc~compute_coeff->svd

Called by

proc~~pca~~CalledByGraph proc~pca forpca::tpca%pca program~benchmark benchmark program~benchmark->proc~pca program~test1 test1 program~test1->proc~pca

Source Code

   impure subroutine pca(this, matrix, npc, method, coeff, score, latent, explained, matrix_app)
#else
   pure subroutine pca(this, matrix, npc, method, coeff, score, latent, explained, matrix_app)
#endif
      class(tpca),                           intent(inout)         :: this
      real(rk), dimension(:,:),              intent(in)            :: matrix
      integer,                               intent(in),  optional :: npc
      character(*),                          intent(in),  optional :: method
      real(rk), dimension(:,:), allocatable, intent(out)           :: coeff
      real(rk), dimension(:,:), allocatable, intent(out), optional :: score
      real(rk), dimension(:),   allocatable, intent(out), optional :: latent
      real(rk), dimension(:),   allocatable, intent(out), optional :: explained
      real(rk), dimension(:,:), allocatable, intent(out), optional :: matrix_app

      call this%initialize(matrix, npc, method)

      call this%compute_coeff()
      coeff = this%coeff

      if(present(score)) then
         call this%compute_score()
         score = this%score
      end if

      if(present(latent)) then
         latent = this%latent
      end if

      if(present(explained)) then
         call this%cmp_explained_variance()
         explained = this%explained_variance*100.0_rk
      end if


      if(present(matrix_app)) then
         call this%reconstruct_data()
         matrix_app = this%matrix_app
      end if

   end subroutine pca