本文整理汇总了C++中arma::mat::at方法的典型用法代码示例。如果您正苦于以下问题:C++ mat::at方法的具体用法?C++ mat::at怎么用?C++ mat::at使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类arma::mat
的用法示例。
在下文中一共展示了mat::at方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tp5
// Gompertz model
void tp5(arma::mat& g3, int lk, double gam, double om) {
while(om==1) {
om = 0.999 + rand() * 0.002 / RAND_MAX;
}
for(int n2=0; n2<lk; n2++) {
g3.at(0, n2) = Rf_dpois(n2, 0, false);
}
for(int n1=1; n1<lk; n1++) {
for(int n2=0; n2<lk; n2++) {
g3.at(n1, n2) = Rf_dpois(n2, n1*exp(gam * (1 - log(n1)/log(om))), false);
}
}
}
示例2: tp3
// trend model
void tp3(arma::mat& g3, int lk, double gam) {
for(int n1=0; n1<lk; n1++) {
for(int n2=0; n2<lk; n2++) {
g3.at(n1, n2) = Rf_dpois(n2, gam*n1, false);
}
}
}
示例3: tp4
// Ricker model
void tp4(arma::mat& g3, int lk, double gam, double om) {
for(int n1=0; n1<lk; n1++) {
for(int n2=0; n2<lk; n2++) {
g3.at(n1, n2) = Rf_dpois(n2, n1*exp(gam*(1-n1/om)), false);
}
}
}
示例4: tp5
// Gompertz + immigration model
void tp5(arma::mat& g3, int lk, double gam, double om, double imm) {
for(int n1=0; n1<lk; n1++) {
for(int n2=0; n2<lk; n2++) {
g3.at(n1, n2) = Rf_dpois(n2, n1*exp(gam * (1 - log(double (n1) + 1)/log(om + 1))) + imm, false);
}
}
}
示例5:
/*!
* \brief LAArmadillo::arma2OiMat
* \param result
* \param m
*/
void LAArmadillo::arma2OiMat(OiMat &result, const arma::mat &m){
for(int i = 0; i < m.n_rows; i++){
for(int j = 0; j < m.n_cols; j++){
result.setAt(i, j, m.at(i, j));
}
}
}
示例6: toAffinity
/*******************************************************************
* 函数功能:几何校正需要调用的函数
*
*
*/
arma::mat toAffinity(arma::mat &f){
arma::mat A;
arma::mat v;
v << 0 << 0 << 1 << arma::endr;
int flag = f.n_rows;
switch(flag){
case 6:{ // oriented ellipses
arma::mat T = f.rows(0, 1);
arma::mat tmp = join_horiz(f.rows(2, 3), f.rows(4, 5));
arma::mat tmp1 = join_horiz(tmp, T);
A = join_vert(tmp1, v);
break;}
case 4:{ // oriented discs
arma::mat T = f.rows(0, 1);
double s = f.at(2,0);
double th = f.at(3,0);
arma::mat S = arma::randu<arma::mat>(2,2);
/*S.at(0, 0) = s*cos(th);
S.at(0, 1) = -s*sin(th);
S.at(1, 0) = s*sin(th);
S.at(1, 1) = s*cos(th);*/
S << s*cos(th) << -s*sin(th) << arma::endr
<< s*sin(th) << s*cos(th) << arma::endr;
arma::mat tmp1 = join_horiz(S, T);
A = join_vert(tmp1, v);
//A.print("A =");
break;}
/*case 3:{ // discs
mat T = f.rows(0, 1);
mat s = f.row(2);
int th = 0 ;
A = [s*[cos(th) -sin(th) ; sin(th) cos(th)], T ; 0 0 1] ;
}
case 5:{ // ellipses
mat T = f.rows(0, 1);
A = [mapFromS(f(3:5)), T ; 0 0 1] ;
}*/
default:
std::cout << "出错啦!" << std::endl;
break;
}
return A;
}
示例7: tp1
// constant model
void tp1(arma::mat& g3, int lk, double gam, double om) {
int Nmin=0;
for(int n1=0; n1<lk; n1++) {
for(int n2=0; n2<lk; n2++) {
Nmin = std::min(n1, n2);
for(int c=0; c<=Nmin; c++) {
g3.at(n1, n2) += exp(Rf_dbinom(c, n1, om, true) +
Rf_dpois(n2-c, gam, true));
}
}
}
}
示例8: compute_dct
arma::mat compute_dct(arma::mat& inp) {
arma::mat out(8,8);
for(int v = 0; v < 8; v++) {
for(int u = 0; u < 8; u++) {
double Cu, Cv, z = 0.0;
COEFFS(Cu,Cv,u,v);
for(int y = 0; y < 8; y++) {
for(int x = 0; x < 8; x++) {
double s, q;
s = inp.at(x,y);
q = s * cos((double)(2*x+1) * (double)u * M_PI/16.0) *
cos((double)(2*y+1) * (double)v * M_PI/16.0);
z += q;
}}
out.at(u,v) = 0.25 * Cu * Cv * z;
}}
return out;
}
示例9: confROH
Rcpp::NumericMatrix rcpp_segIBDandNVersion2(std::string pathThisBreed, int NFileC, int NC, const arma::ivec& ArmaIndexC, const arma::mat& ArmaNat, int minSNP, double minL, const arma::vec& ArmaPos, const arma::vec& Armakb, double a, std::string stdsymB, int skip, int cskip) {
int m, m2, i, j, r, rK, endoffile, gleich;
double L, w, lSEG ;
char str1[100];
char symB = stdsymB.at(0);
FILE *fC;
Rcpp::NumericMatrix confROH(NC, NC);
int K = (minSNP<=60)?(minSNP/2):(30);
int M = Armakb.n_elem - 1;
size_t bufsize = 2*NFileC;
char* Line = (char*)malloc(bufsize*sizeof(char));
if(Line == NULL){error_return("Memory allocation failed.");};
int** Nat = (int**)calloc(NC,sizeof(int*));
double** fROH = (double**)calloc(NC,sizeof(double*));
int** thisROH = (int**)calloc(NC,sizeof(int*));
int* currAllelesC = (int*)calloc(NC,sizeof(int));
int* prevAllelesC = (int*)calloc(NC,sizeof(int));
int* indexC = (int*)calloc(NC,sizeof(int));
double* Pos = (double*)calloc(ArmaPos.n_elem, sizeof(double));
double* kb = (double*)calloc(Armakb.n_elem, sizeof(double));
if(Nat == NULL){error_return("Memory allocation failed.");};
if(fROH == NULL){error_return("Memory allocation failed.");};
if(thisROH == NULL){error_return("Memory allocation failed.");};
if(currAllelesC == NULL){error_return("Memory allocation failed.");};
if(prevAllelesC == NULL){error_return("Memory allocation failed.");};
if(indexC == NULL){error_return("Memory allocation failed.");};
if(Pos == NULL){error_return("Memory allocation failed.");};
if(kb == NULL){error_return("Memory allocation failed.");};
for(m=0;m<M+1;m++){
Pos[m] = ArmaPos.at(m);
kb[m] = Armakb.at(m);
}
for(i=0; i<NC;i++){
indexC[i] = ArmaIndexC.at(i);
fROH[i] = (double*)calloc(i+1, sizeof(double));
thisROH[i]= (int*)calloc(i+1, sizeof(int));
Nat[i] = (int*)calloc(M, sizeof(int));
if(fROH[i] == NULL){error_return("Memory allocation failed.");};
if(thisROH[i] == NULL){error_return("Memory allocation failed.");};
if(Nat[i] == NULL){error_return("Memory allocation failed.");};
for(m=0; m<M;m++){
Nat[i][m] = ArmaNat.at(m,i);
}
}
fC = fopen(pathThisBreed.c_str(),"r");
if(fC == NULL){error_return("File opening failed.");};
for(i=0;i<skip+1;i++){
while(fgetc(fC)!='\n'){}
}
endoffile=0;
m=0;
while(!endoffile){
for(i=0; i<NC;i++){
prevAllelesC[i] = currAllelesC[i];
currAllelesC[i] = 0;
}
rK=0;
while(rK<K){
for(i=0; i<cskip; i++){
endoffile = fscanf(fC, "%s ", str1)<1;
if(endoffile){break;}
}
if(endoffile){break;}
endoffile = fgets(Line,2*NFileC,fC)==NULL;
if(endoffile){break;}
for(i=0; i<NC;i++){
if(Line[2*indexC[i]]==symB){currAllelesC[i]= currAllelesC[i] | (1u<<rK);}
}
rK++;
}
if(endoffile){Rprintf("M=%d\n",m+rK);}
if(rK==0){break;}
for(i=0; i<NC;i++){
for(j=0; j<i+1; j++){
if(currAllelesC[i]==currAllelesC[j]){
if(prevAllelesC[i]==prevAllelesC[j] && m>0){ /* ROH verlängern */
thisROH[i][j] += rK;
}else{ /* neuer ROH */
thisROH[i][j] = rK;
if(m>0){
gleich = ~(prevAllelesC[i] ^ prevAllelesC[j]);
r = K-1;
while(r>=0 && ((gleich>>r)&1u)){
thisROH[i][j] += 1;
r--;
}
}
}
}else{
if(prevAllelesC[i]==prevAllelesC[j] && m>0){ /* ROH beenden */
gleich = ~(currAllelesC[i] ^ currAllelesC[j]);
//.........这里部分代码省略.........