schochastics / signnet
1
// [[Rcpp::depends(RcppArmadillo)]]
2
#include <RcppArmadillo.h>
3

4
// [[Rcpp::export]]
5 1
arma::cx_mat cxmatmul(arma::cx_mat A,arma::cx_mat B) {
6 1
  int n=A.n_rows;
7 1
  arma::cx_mat C(n,n);
8 1
  arma::cx_vec tmp(n);
9 1
  arma::vec Repart(n);
10 1
  arma::vec Impart(n);
11

12 1
  for(int i=0;i<n;++i){
13 1
    for(int j=0;j<n;++j){
14 1
      for(int k=0;k<n;++k){
15 1
        tmp[k] = A(i,k)*B(k,j);
16
      }
17 1
      Repart = abs(real(tmp));
18 1
      Impart = abs(imag(tmp));
19 1
      tmp = arma::cx_vec(Repart,Impart);
20 1
      C(i,j) = sum(tmp);
21
    }
22
  }
23 1
  return C;
24
}
25

Read our documentation on viewing source code .

Loading