-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathDenoisedRates.h
40 lines (32 loc) · 933 Bytes
/
DenoisedRates.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef DENOISED_H
#define DENOISED_H
#include "utils.h"
// [[Rcpp::export(".BASiCS_DenoisedRates")]]
arma::mat BASiCS_DenoisedRates(
NumericMatrix CountsBio,
NumericMatrix Mu,
NumericMatrix TransInvDelta,
NumericMatrix PhiNu,
int N,
int q0,
int n) {
// Transformations to arma objects
arma::mat CountsBio_arma = as_arma(CountsBio);
arma::mat Mu_arma = as_arma(Mu);
arma::mat TransInvDelta_arma = as_arma(TransInvDelta);
arma::mat PhiNu_arma = as_arma(PhiNu);
// Where to store the results
arma::mat Rho = arma::zeros(q0, n);
// Auxiliary matrices
arma::mat m1; arma::mat m2;
for (int i = 0; i<N; i++) {
Rcpp::checkUserInterrupt();
m1 = CountsBio_arma;
m1.each_col() += TransInvDelta_arma.col(i);
m2 = Mu_arma.row(i).t() * PhiNu_arma.row(i);
m2.each_col() += TransInvDelta_arma.col(i);
Rho += m1 / m2;
}
return(Rho / N);
}
#endif