#include
#include
#include
using namespace Rcpp;
using namespace std;
//' Compute the Delta of the dynamic programming
//'
//' Compute the Delta of the dynamic programming in \code{\link{Rcpp}}
//'
//' @param x the matrix of rank
//' @export Compute_Cn1n2
//' @rdname Compute_Cn1n2
// [[Rcpp::export]]
NumericMatrix Compute_Cn1n2(NumericMatrix x) {
int n = x.nrow();
NumericMatrix mat(x.nrow(),x.ncol());
NumericVector vect(x.ncol());
NumericVector vect_bis(x.ncol());
NumericVector vect_suite(x.ncol());
// calcul du vecteur des sommes de colonnes dans le cas de la diagonale
for(int ii=0;iin1) {
double res = 0;
for(int i=0;i< n;i++)
{
double sum2 = 0;
for(int j=n1;j<=n2;j++){
sum2 = sum2 + x(i,j);
}
vect_bis(i) = sum2;
vect_suite(i) = std::pow(vect_bis(i)/((n2+1)-n1)-(n+1)/2.0,2);
res=res + vect_suite(i)*((n2+1)-n1);
}
mat(n1,n2) = res;
}
// reste de la matrice remplie de zero
else {
mat(n1,n2)=0;
}
Rcpp::checkUserInterrupt();
}
}
return mat;
}