// Compute mean Gamma Rate (Yang) std::vector<double> computeGammaRate(size_t N_GAMMA, double alpha) { std::vector<double> gammaRates(N_GAMMA); double beta = alpha; boost::math::chi_squared_distribution<double> chi2Dist(2.*alpha); // Compute cutting point (Eq. 9) (could use gamma QUANTILE instead) std::vector<double> cPoints(1, 0.); for(size_t iG=1; iG<N_GAMMA; ++iG) { double cPoint = boost::math::quantile(chi2Dist, (double)iG/(double)N_GAMMA) / (2.*beta); cPoints.push_back(cPoint); } // Compute all lower incomplete gamma functions required in Eq. 10 double alphaP1 = alpha + 1; std::vector<double> lowerIncGamma(1, 0.); for(size_t iL=1; iL<cPoints.size(); ++iL) { double liGamma = boost::math::gamma_p(alphaP1, cPoints[iL]*beta); lowerIncGamma.push_back(liGamma); } lowerIncGamma.push_back(1.); // Equation 10. for(size_t iG=0; iG<N_GAMMA; ++iG) { // alpha = beta, thus alpha/beta = 1.0 || k=iG gammaRates[iG] = ((double)N_GAMMA)*(lowerIncGamma[iG+1]-lowerIncGamma[iG]); } return gammaRates; }
void SetupAxis(int nm, GLuint &vao, GLuint &vbo, GLuint &ibo) { std::vector<gmtl::Point3f>start; std::vector<gmtl::Point3f> verts; std::vector<unsigned int> indices; std::vector<gmtl::Point3f> color; std::vector<gmtl::Point2f> uvs; std::vector<gmtl::Point3f> normals; int np = 5; gmtl::Point3f p0(.0f, .0f, .0f); gmtl::Point3f p1(.025f, .0f, .0f); gmtl::Point3f p2(.025f, .85f, .0f); gmtl::Point3f p3(.055f, .85f, .0f); gmtl::Point3f p4(.0f, 1.0f, .0f); start.push_back(p0); start.push_back(p1); start.push_back(p2); start.push_back(p3); start.push_back(p4); verts = rPoints(start, nm, np, 'y'); color = cPoints(verts, 'o'); normals = nPoints(verts, 'a'); uvs = uvPoints(nm, np); GenerateIndices(nm, np, indices); axisIndexSize = indices.size(); int vertOffset = verts.size() * sizeof(gmtl::Point3f); int uvOffset = uvs.size() * sizeof(gmtl::Point2f); int colorOffset = color.size() * sizeof(gmtl::Point3f); int indexOffset = indices.size() * sizeof(GLuint); int normalOffset = normals.size() * sizeof(gmtl::Point3f); glGenVertexArrays(1, &vao); glBindVertexArray(vao); glGenBuffers(1, &ibo); //Setup 1 buffer name and store the generated buffer object name their glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo); //bind the buffer name to the target glBufferData(GL_ELEMENT_ARRAY_BUFFER, //target buffer object indexOffset, //size of buffer object &indices[0], //pointer to the data GL_STATIC_DRAW); glGenBuffers(1, &vbo); glBindBuffer(GL_ARRAY_BUFFER, vbo); //Set the size and data of the Vertex Buffer Object and set it to STATIC_DRAW glBufferData(GL_ARRAY_BUFFER, //this is the target we are buffering to vertOffset + colorOffset + normalOffset + uvOffset, //this is the total size of the buffer NULL, //address of the content to be updated nothing because we are setting it in the subData buffers GL_STATIC_DRAW);//+ uvOffset + normalOffset glBufferSubData(GL_ARRAY_BUFFER, 0, //offset where data replacement will begin vertOffset, //size &verts[0]);//address of the content to be updated glBufferSubData(GL_ARRAY_BUFFER, vertOffset, //offset where data replacement will begin colorOffset, //size &color[0]);//data glBufferSubData(GL_ARRAY_BUFFER, vertOffset + colorOffset, normalOffset, &normals[0]); glBufferSubData(GL_ARRAY_BUFFER, vertOffset + colorOffset + normalOffset, uvOffset, &uvs[0]); //verts|uv|color|normals //layout(location = 0) in vec4 VertexPosition; //layout(location = 1) in vec4 VertexColor; //layout(location = 2) in vec3 VertexNormal; //layout(location = 3) in vec2 VertexUV; //This is the layout in the shader for the attribute variables //that will be binded to the different geometry buffers glEnableVertexAttribArray(0); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, (void*)(0)); glEnableVertexAttribArray(1); glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, (void*)(vertOffset)); // vertex buffer object glEnableVertexAttribArray(2); glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, 0, (void*)(vertOffset + colorOffset)); // vertex buffer object glEnableVertexAttribArray(3); glVertexAttribPointer(3, 2, GL_FLOAT, GL_FALSE, 0, (void*)(vertOffset + colorOffset + normalOffset)); glBindVertexArray(0); //Bind the index buffer for the object glBindBuffer(GL_ARRAY_BUFFER, 0); // Bind the index buffer for the object glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); }