1
+ //
2
+ // Copyright (C) 2014 Aleksandar Zlateski <[email protected] >
3
+ // ----------------------------------------------------------
4
+ //
5
+ // This program is free software: you can redistribute it and/or modify
6
+ // it under the terms of the GNU General Public License as published by
7
+ // the Free Software Foundation, either version 3 of the License, or
8
+ // (at your option) any later version.
9
+ //
10
+ // This program is distributed in the hope that it will be useful,
11
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ // GNU General Public License for more details.
14
+ //
15
+ // You should have received a copy of the GNU General Public License
16
+ // along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ //
18
+
1
19
#ifndef ZNN_BF_CONV_HPP_INCLUDED
2
20
#define ZNN_BF_CONV_HPP_INCLUDED
3
21
@@ -186,9 +204,9 @@ inline double3d_ptr bf_conv_constant(const double3d_ptr& ap,
186
204
inline double bf_conv_flipped_constant (const double3d_ptr& ap,
187
205
const double3d_ptr& bp)
188
206
{
189
- ZI_ASSERT ( volume_size (ap)== volume_size (bp) );
207
+ ASSERT_SAME_SIZE (ap,bp );
190
208
191
- std::size_t n = volume_elements (ap );
209
+ std::size_t n = ap-> num_elements ( );
192
210
193
211
double r = 0 ;
194
212
@@ -215,7 +233,7 @@ inline double3d_ptr bf_conv_inverse_constant(const double3d_ptr& ap,
215
233
double3d_ptr rp = volume_pool.get_double3d (ax,ay,az);
216
234
double3d& r = *rp;
217
235
218
- std::size_t n = volume_elements (ap );
236
+ std::size_t n = ap-> num_elements ( );
219
237
220
238
for ( std::size_t i = 0 ; i < n; ++i )
221
239
{
@@ -253,8 +271,7 @@ inline double3d_ptr bf_conv_sparse(const double3d_ptr& ap,
253
271
for ( std::size_t z = 0 ; z < rz; ++z )
254
272
{
255
273
r[x][y][z] = 0 ;
256
-
257
- // [02/28/2014 kisuklee]
274
+
258
275
for ( std::size_t dx = x, wx = bx-1 ; dx < bx + x; dx += s[0 ], wx -= s[0 ] )
259
276
for ( std::size_t dy = y, wy = by-1 ; dy < by + y; dy += s[1 ], wy -= s[1 ] )
260
277
for ( std::size_t dz = z, wz = bz-1 ; dz < bz + z; dz += s[2 ], wz -= s[2 ] )
@@ -263,17 +280,6 @@ inline double3d_ptr bf_conv_sparse(const double3d_ptr& ap,
263
280
a[dx][dy][dz] *
264
281
b[wx][wy][wz];
265
282
}
266
- //
267
- // original code was buggy
268
- //
269
- // for ( std::size_t dx = x, wx = (bx-1)*s[0]; dx < bx + x; dx += s[0], wx -= s[0] )
270
- // for ( std::size_t dy = y, wy = (by-1)*s[1]; dy < by + y; dy += s[1], wy -= s[1] )
271
- // for ( std::size_t dz = z, wz = (bz-1)*s[2]; dz < bz + z; dz += s[2], wz -= s[2] )
272
- // {
273
- // r[x][y][z] +=
274
- // a[dx][dy][dz] *
275
- // b[wx][wy][wz];
276
- // }
277
283
}
278
284
279
285
return rp;
0 commit comments