Ejemplo n.º 1
0
SEXP _est_gen_Q_C( SEXP spYdelt,
  		   	SEXP spZ,
  		   	SEXP spX,
  		   	SEXP spMaf,
		   	SEXP spParNull)
{
	// int nUsed0, nTotal0;
	// CFmVector::StatCache( &nTotal0, &nUsed0 );
	// int nUsed1, nTotal1;
	// CFmMatrix::StatCache( &nTotal1, &nUsed1 );
	// Rprintf( "Enter C Range, Vec.count=%d, Mat.count=%d\n", nTotal0, nTotal1);

	CFmMatrix* pFmYDelt = getMatrixData(spYdelt);
	CFmMatrix* pFmZ     = getMatrixData(spZ);
	CFmMatrix* pFmX     = getMatrixData(spX);
	CFmVector* pFmMaf   = getVectorData(spMaf);
	CFmVector* pFmParNull = getVectorData(spParNull);

	SEXP ret;
	try
	{
		ret = Xest_gen_Q_C( pFmYDelt, pFmZ, pFmX, pFmMaf, pFmParNull);
	}
    catch(const char* str)
    {
        _log_error( _HI_, "Exception=%s", str);
        return( R_NilValue );
    }

	destroy( pFmYDelt );
	destroy( pFmZ );
	destroy( pFmX );
	destroy( pFmMaf );
	destroy( pFmParNull );

	// CFmVector::StatCache( &nTotal0, &nUsed0 );
	// CFmMatrix::StatCache( &nTotal1, &nUsed1 );
	// Rprintf( "Leave C Range, Vec.count=%d, Mat.count=%d\n", nTotal0, nTotal1);

	return(ret);
}
Ejemplo n.º 2
0
double searchRadius(double** matrix,int Num,double tau) {
    int nElem=Num*(Num-1)/2;
    vector<double> dist;
    dist.reserve(nElem);
    int cnt=0;
    for(int i=0; i<Num-1; ++i)
        for(int j=i+1; j<Num; ++j)
            dist[cnt++]=getMatrixData(matrix,i,j);
    int pos=int(round(tau*Num));
    nth_element(dist.begin(),dist.begin()+pos-1,dist.end());
    return dist[pos-1];
}
Ejemplo n.º 3
0
void filterHalos(double** matrix,int Num,int nClus,const int* clus, const double* rho,double radius,int* halo) {
	memset(halo,0,sizeof(int)*Num);
	if(nClus<=1)
		return;
	double* boundary_rho=new double[nClus]();
	double dist;
	double avg_rho;
	for(int i=0; i<Num-1; ++i)
		for(int j=i+1; j<Num; ++j) {
			dist=getMatrixData(matrix,i,j);
			if(dist<=radius&&*(clus+i)!=*(clus+j)) {
				avg_rho=(*(rho+i)+*(rho+j))/2.0;
				if(boundary_rho[*(clus+i)]<avg_rho)
					boundary_rho[*(clus+i)]=avg_rho;
				if(boundary_rho[*(clus+j)]<avg_rho)
					boundary_rho[*(clus+j)]=avg_rho;
			}
		}
	for(int i=0; i<Num; ++i) {
		if(*(rho+i)<boundary_rho[*(clus+i)])
			*(halo+i)=1;
	}
	delete[] boundary_rho;
}
Ejemplo n.º 4
0
void GlShaderProgram::setUniformMat4Float(const std::string &variableName, const Matrix<float, 4> &mat4f, const bool transpose) {
  float *matrixData = getMatrixData(mat4f);
  setUniformMat4Float(variableName, matrixData, transpose);
  delete [] matrixData;
}