bool gcta::comput_inverse_logdet_LDLT(eigenMatrix &Vi, eigenVector &prev_varcmp, double &logdet) { int i=0, n=Vi.cols(); LDLT<eigenMatrix> ldlt(Vi); eigenVector d=ldlt.vectorD(); if(d.minCoeff()<0){ if(prev_varcmp.minCoeff()>0) return false; else throw("Error: the matrix V becomes negative-definite because of one of the variance component is negative.\nPlease re-run the analysis without the --reml-no-constrain option."); } logdet=0.0; for(i=0; i<n; i++) logdet+=log(d[i]); Vi.setIdentity(); ldlt.solveInPlace(Vi); return true; }
bool gcta::bending_eigenval(eigenVector &eval) { int j=0; double eval_m=eval.mean(); if(eval.minCoeff()>0.0) return false; double S=0.0, P=0.0; for(j=0; j<eval.size(); j++){ if(eval[j]>=0) continue; S+=eval[j]; P=-eval[j]; } double W=S*S*100.0+1; for(j=0; j<eval.size(); j++){ if(eval[j]>=0) continue; eval[j]=P*(S-eval[j])*(S-eval[j])/W; } eval*=eval_m/eval.mean(); return true; }