Commit ed7cb02c authored by karius's avatar karius

quadrature seems to work

parent 93570620
......@@ -397,6 +397,18 @@ void TransformationGrid::d_transformation_to_memory(const uint& linear_index, fl
translation->w = 0;
}
__host__
void TransformationGrid::print_quadrature_nodes(void){
uint t = 0;
float4 translation[1];
float4 rotation[1];
while(t < h_num_transformations[0]){
h_transformation_to_memory(t,&rotation[0],&translation[0]);
printf("%u - %f | %f | %f\n",t,translation[0].x,translation[0].y,translation[0].z);
t++;
}
}
__host__
void TransformationGrid::print_quadrature_weights(void){
int t = 0;
......@@ -415,6 +427,7 @@ void TransformationGrid::print_quadrature_weights(void){
printf("Total sum of weights: %e\n",sum/8);
}
template <uint blockSize>
__global__
void translation_quadrature(TransformationGrid grid, float * d_tmp_quadrature){
......@@ -437,8 +450,7 @@ void translation_quadrature(TransformationGrid grid, float * d_tmp_quadrature){
weight = grid.d_chebychev_weights[transformation_index.x];
weight *= grid.d_chebychev_weights[grid.d_translation_refinement_dim[0] + transformation_index.y];
weight *= grid.d_chebychev_weights[grid.d_translation_refinement_dim[0] + grid.d_translation_refinement_dim[1] + transformation_index.z];
// reduce[threadIdx.x] += weight*d_scores[t];
reduce[threadIdx.x] += weight;
reduce[threadIdx.x] += weight*d_scores[t];
t += grid_dim;
}
__syncthreads();
......@@ -472,7 +484,6 @@ void TransformationGrid::quadrature(float* const &result){
cudaMemcpy(h_tmp_quadrature,d_tmp_quadrature,grid_dim*sizeof(*h_tmp_quadrature),cudaMemcpyDeviceToHost);
result[0] = 0.0;
for (int i=0;i<grid_dim;i++)result[0] += h_tmp_quadrature[i];
result[0] /=8;
}
__host__
......@@ -484,7 +495,8 @@ void TransformationGrid::gaussian(void){
float N = 1.0/(powf(sigma,3.0)*powf(2*M_PI,1.5));
for (uint i = 0; i < h_num_transformations[0];i++){
h_transformation_to_memory(i,rotation,translation);
h_scores[i] = N*expf(-powf(translation->x-mu,2.0)/powf(sigma,2.0)-powf(translation->y-mu,2.0)/powf(sigma,2.0)-powf(translation->z-mu,2.0)/powf(sigma,2.0));
// h_scores[i] = N*expf(-powf(translation->x-mu,2.0)/powf(sigma,2.0)-powf(translation->y-mu,2.0)/powf(sigma,2.0)-powf(translation->z-mu,2.0)/powf(sigma,2.0));
h_scores[i] = powf(translation->x,2.0) + powf(translation->y,2.0) + powf(translation->z,2.0);
}
cudaMemcpy(d_scores,h_scores,h_num_transformations[0]*sizeof(*d_scores),cudaMemcpyHostToDevice);
CudaCheckError();
......
......@@ -94,6 +94,7 @@ public:
__host__ void gaussian(void);
__host__ void quadrature(float* const &result);
__host__ void print_quadrature_weights(void);
__host__ void print_quadrature_nodes(void);
// static __host__ void evaluate(const char * file_name);
__host__ static thrust::device_vector<thrust::tuple<float4,float3,float>> n_best_from_file(const char * file_name, uint n);
__host__ static float3 transform(const float4& t);
......
No preview for this file type
......@@ -630,15 +630,15 @@ BOOST_AUTO_TEST_CASE(translational_quadrature)
printf(" ============================= ++++++++++++++++++++++++++++++++ ===========================\n");
std::pair<float3,float3> effective_translational_shift;
effective_translational_shift.first = {0,0,0};
effective_translational_shift.second = {100,100,100};
float trans_offset[3] = {50,50,50};
float tau = 3;
effective_translational_shift.second = {2,2,2};
float trans_offset[3] = {1,1,1};
float tau = 0.5;
float * quadrature_result = (float *) malloc(sizeof(*quadrature_result));
TransformationGrid transformation_grid(effective_translational_shift,tau,&trans_offset[0]);
transformation_grid.gaussian();
transformation_grid.quadrature(quadrature_result);
CudaCheckError();
// transformation_grid.print_quadrature_weights();
transformation_grid.print_quadrature_nodes();
printf("Transformation num: %u\n",transformation_grid.h_num_transformations[0]);
printf("Translation num: %u\n",transformation_grid.h_num_translations[0]);
printf("Rotation num: %u\n",transformation_grid.h_num_rotations[0]);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment