%global __brp_check_rpaths %{nil}
%global packname  fastmit
%global packver   0.1.1
%global rlibdir   /usr/local/lib/R/library

Name:             R-CRAN-%{packname}
Version:          0.1.1
Release:          3%{?dist}%{?buildtag}
Summary:          Fast Mutual Information Based Independence Test

License:          GPL (>= 2)
URL:              https://cran.r-project.org/package=%{packname}
Source0:          %{url}&version=%{packver}#/%{packname}_%{packver}.tar.gz


BuildRequires:    R-devel
Requires:         R-core
BuildRequires:    R-CRAN-Rcpp 
BuildRequires:    R-stats 
BuildRequires:    R-CRAN-RcppArmadillo 
Requires:         R-CRAN-Rcpp 
Requires:         R-stats 

%description
A mutual information estimator based on k-nearest neighbor method proposed
by A. Kraskov, et al. (2004) <doi:10.1103/PhysRevE.69.066138> to measure
general dependence and the time complexity for our estimator is only
squared to the sample size, which is faster than other statistics.
Besides, an implementation of mutual information based independence test
is provided for analyzing multivariate data in Euclidean space (T B.
Berrett, et al. (2019) <doi:10.1093/biomet/asz024>); furthermore, we
extend it to tackle datasets in metric spaces.

%prep
%setup -q -c -n %{packname}


%build

%install

mkdir -p %{buildroot}%{rlibdir}
%{_bindir}/R CMD INSTALL -l %{buildroot}%{rlibdir} %{packname}

test -d %{packname}/src && (cd %{packname}/src; rm -f *.o *.so)
rm -f %{buildroot}%{rlibdir}/R.css

%files
%{rlibdir}/%{packname}