@@ -11,7 +11,7 @@ template <typename T, int dim>
1111struct BarrierEnergy <T, dim>::Impl
1212{
1313 DeviceBuffer<T> device_x;
14- DeviceBuffer<T> device_contact_area, device_n,device_n_ceil, device_o;
14+ DeviceBuffer<T> device_contact_area, device_n, device_n_ceil, device_o;
1515 int N;
1616 DeviceBuffer<T> device_grad;
1717 DeviceTripletMatrix<T, 1 > device_hess;
@@ -39,11 +39,11 @@ BarrierEnergy<T, dim>::BarrierEnergy(const std::vector<T> &x, const std::vector<
3939 pimpl_->device_x .copy_from (x);
4040 pimpl_->device_contact_area .copy_from (contact_area);
4141 std::vector<T> n_ceil (dim);
42- n_ceil[1 ]= -1 ;
42+ n_ceil[1 ] = -1 ;
4343 pimpl_->device_n_ceil .copy_from (n_ceil);
4444 pimpl_->device_n .copy_from (n);
4545 pimpl_->device_o .copy_from (o);
46- pimpl_->device_hess .resize_triplets ((pimpl_->N *2 - 1 ) * dim * dim);
46+ pimpl_->device_hess .resize_triplets ((pimpl_->N * 2 - 1 ) * dim * dim);
4747 pimpl_->device_hess .reshape (x.size (), x.size ());
4848 pimpl_->device_grad .resize (pimpl_->N * dim);
4949}
@@ -75,7 +75,7 @@ T BarrierEnergy<T, dim>::val()
7575 device_val1 (i)= kappa * device_contact_area (i) * dhat/2 *(s-1 )*log (s);
7676 } })
7777 .wait ();
78- ParallelFor (256 ).apply (N- 1 , [device_val2 = device_val2.viewer (), device_x = device_x.cviewer (), device_contact_area = device_contact_area.cviewer (), device_n_ceil = device_n_ceil.cviewer (), device_o = device_o.cviewer (),N] __device__ (int i) mutable
78+ ParallelFor (256 ).apply (N - 1 , [device_val2 = device_val2.viewer (), device_x = device_x.cviewer (), device_contact_area = device_contact_area.cviewer (), device_n_ceil = device_n_ceil.cviewer (), device_o = device_o.cviewer (), N] __device__ (int i) mutable
7979 { T d = 0 ;
8080 for (int j=0 ;j<dim;j++){
8181 d += device_n_ceil (j)*(device_x (i*dim+j)-device_x ((N-1 )*dim+j));
@@ -85,7 +85,7 @@ T BarrierEnergy<T, dim>::val()
8585 device_val2 (i)= kappa * device_contact_area (i) * dhat/2 *(s-1 )*log (s);
8686 } })
8787 .wait ();
88- return devicesum (device_val1)+ devicesum (device_val2);
88+ return devicesum (device_val1) + devicesum (device_val2);
8989} // Calculate the energy
9090
9191template <typename T, int dim>
@@ -115,7 +115,7 @@ const DeviceBuffer<T> &BarrierEnergy<T, dim>::grad()
115115 }
116116 } })
117117 .wait ();
118- ParallelFor (256 ).apply (N- 1 , [device_x = device_x.cviewer (), device_contact_area = device_contact_area.cviewer (), device_grad = device_grad.viewer (), device_n_ceil = device_n_ceil.cviewer (), device_o = device_o.cviewer (),N] __device__ (int i) mutable
118+ ParallelFor (256 ).apply (N - 1 , [device_x = device_x.cviewer (), device_contact_area = device_contact_area.cviewer (), device_grad = device_grad.viewer (), device_n_ceil = device_n_ceil.cviewer (), device_o = device_o.cviewer (), N] __device__ (int i) mutable
119119
120120 {
121121 T d = 0 ;
@@ -131,7 +131,8 @@ const DeviceBuffer<T> &BarrierEnergy<T, dim>::grad()
131131 device_grad (i * dim + j) += grad;
132132 device_grad ((N-1 ) * dim + j) -= grad;
133133 }
134- } }).wait ();
134+ } })
135+ .wait ();
135136 return device_grad;
136137}
137138
@@ -178,7 +179,7 @@ const DeviceTripletMatrix<T, 1> &BarrierEnergy<T, dim>::hess()
178179 }
179180 } })
180181 .wait ();
181- ParallelFor (256 ).apply (N- 1 , [device_x = device_x.cviewer (), device_contact_area = device_contact_area.cviewer (), device_hess_val = device_hess_val.viewer (), device_hess_row_idx = device_hess_row_idx.viewer (), device_hess_col_idx = device_hess_col_idx.viewer (), N, device_n_ceil = device_n_ceil.cviewer (), device_o = device_o.cviewer ()] __device__ (int i) mutable
182+ ParallelFor (256 ).apply (N - 1 , [device_x = device_x.cviewer (), device_contact_area = device_contact_area.cviewer (), device_hess_val = device_hess_val.viewer (), device_hess_row_idx = device_hess_row_idx.viewer (), device_hess_col_idx = device_hess_col_idx.viewer (), N, device_n_ceil = device_n_ceil.cviewer (), device_o = device_o.cviewer ()] __device__ (int i) mutable
182183 {
183184 T d = 0 ;
184185 for (int j = 0 ; j < dim; j++)
@@ -206,7 +207,8 @@ const DeviceTripletMatrix<T, 1> &BarrierEnergy<T, dim>::hess()
206207 device_hess_col_idx (idx) = (N-1 ) * dim + k;
207208 device_hess_val (idx) = 0 ;
208209 }
209- } }).wait ();
210+ } })
211+ .wait ();
210212 return device_hess;
211213
212214} // Calculate the Hessian of the energy
@@ -240,9 +242,9 @@ T BarrierEnergy<T, dim>::init_step_size(const DeviceBuffer<T> &p)
240242 device_alpha (i) = min (device_alpha (i), 0.9 * alpha / -p_n);
241243 } })
242244 .wait ();
243-
245+
244246 ParallelFor (256 )
245- .apply (N- 1 , [device_x = device_x.cviewer (), p = p.cviewer (), device_alpha = device_alpha.viewer (), device_n_ceil = device_n_ceil.cviewer (), device_o = device_o.cviewer (),N] __device__ (int i) mutable
247+ .apply (N - 1 , [device_x = device_x.cviewer (), p = p.cviewer (), device_alpha = device_alpha.viewer (), device_n_ceil = device_n_ceil.cviewer (), device_o = device_o.cviewer (), N] __device__ (int i) mutable
246248
247249 {
248250 T p_n = 0 ;
0 commit comments