1
#include <Rcpp.h>
2
using namespace Rcpp;
3

4
// [[Rcpp::export]]
5 2
NumericMatrix transreduct(NumericMatrix M) {
6 2
  NumericMatrix R(clone(M));
7 2
  int n = R.rows();
8 2
  for(int j=0;j<n;++j){
9 2
    for(int i=0;i<n;++i){
10 2
      if(R(i,j)==1){
11 2
        for (int k=0; k<n;++k){
12 2
          if (R(j,k)==1){
13 2
            R(i,k)=0;
14
          } 
15
        }
16
      }
17
    }
18
  }
19 2
  return R;
20
}

Read our documentation on viewing source code .

Loading