[arrayfire] 80/248: Merge branch 'devel' into stats_tests

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Tue Nov 17 15:54:06 UTC 2015


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch dfsg-clean
in repository arrayfire.

commit 4b478af874609fbd67425101773d83dbb20b3f24
Merge: f26cc0d 31d2475
Author: pradeep <pradeep at arrayfire.com>
Date:   Mon Sep 28 12:24:21 2015 -0400

    Merge branch 'devel' into stats_tests

 ArrayFireConfig.cmake.in                           |  14 +-
 CMakeModules/Version.cmake                         |   4 +-
 CMakeModules/build_forge.cmake                     |   2 +-
 CMakeModules/osx_install/cpu_scripts/postinstall   |   6 +-
 CMakeModules/osx_install/cuda_scripts/postinstall  |   4 +-
 .../osx_install/opencl_scripts/postinstall         |   4 +-
 docs/CMakeLists.txt                                |   2 +-
 docs/details/array.dox                             |  13 +-
 docs/details/backend.dox                           |  32 ++++
 docs/layout.xml                                    |   1 +
 docs/pages/README.md                               |  32 ++--
 docs/pages/getting_started.md                      |   2 +
 docs/pages/release_notes.md                        |  24 +++
 docs/pages/unified_backend.md                      | 182 +++++++++++++++++++++
 docs/pages/using_on_linux.md                       |  25 +--
 docs/pages/using_on_osx.md                         |  25 +--
 docs/pages/using_on_windows.md                     |   8 +-
 examples/unified/basic.cpp                         |  46 +++---
 include/af/array.h                                 |  44 ++++-
 include/af/backend.h                               |  16 +-
 include/af/defines.h                               |  14 +-
 include/af/dim4.hpp                                |   6 +-
 include/af/macros.h                                |  24 +++
 include/af/traits.hpp                              |  20 +++
 include/af/util.h                                  |   4 +-
 include/arrayfire.h                                |  65 +++++---
 src/api/c/assign.cpp                               |   8 +-
 src/api/c/bilateral.cpp                            |   2 +
 src/api/c/binary.cpp                               |   8 +
 src/api/c/cast.cpp                                 |   2 +
 src/api/c/convolve.cpp                             |  48 +++---
 src/api/c/corrcoef.cpp                             |   2 +
 src/api/c/covariance.cpp                           |   2 +
 src/api/c/data.cpp                                 |  40 ++++-
 src/api/c/device.cpp                               |   8 +
 src/api/c/diff.cpp                                 |   4 +
 src/api/c/dog.cpp                                  |  12 +-
 src/api/c/fast.cpp                                 |   2 +
 src/api/c/fftconvolve.cpp                          |   2 +
 src/api/c/filters.cpp                              |   2 +
 src/api/c/flip.cpp                                 |   2 +
 src/api/c/handle.hpp                               |   3 +
 src/api/c/histeq.cpp                               |   2 +
 src/api/c/histogram.cpp                            |  22 ++-
 src/api/c/imageio.cpp                              |   2 -
 src/api/c/implicit.cpp                             |   6 +
 src/api/c/index.cpp                                |  10 +-
 src/api/c/join.cpp                                 |   4 +
 src/api/c/match_template.cpp                       |   2 +
 src/api/c/mean.cpp                                 |  28 ++--
 src/api/c/meanshift.cpp                            |   2 +
 src/api/c/median.cpp                               |   4 +
 src/api/c/moddims.cpp                              |   2 +
 src/api/c/morph.cpp                                |   4 +
 src/api/c/nearest_neighbour.cpp                    |  13 +-
 src/api/c/print.cpp                                |   6 +
 src/api/c/reduce.cpp                               |  16 ++
 src/api/c/regions.cpp                              |   2 +
 src/api/c/reorder.cpp                              |   2 +
 src/api/c/replace.cpp                              |   4 +
 src/api/c/resize.cpp                               |   2 +
 src/api/c/rgb_gray.cpp                             |   2 +
 src/api/c/rotate.cpp                               |   2 +
 src/api/c/sat.cpp                                  |   2 +
 src/api/c/scan.cpp                                 |   2 +
 src/api/c/select.cpp                               |   6 +
 src/api/c/set.cpp                                  |   6 +
 src/api/c/shift.cpp                                |   2 +
 src/api/c/sobel.cpp                                |   2 +
 src/api/c/sort.cpp                                 |   8 +
 src/api/c/stdev.cpp                                |   4 +
 src/api/c/stream.cpp                               |   4 +
 src/api/c/susan.cpp                                |   2 +
 src/api/c/tile.cpp                                 |   2 +
 src/api/c/transform.cpp                            |   2 +
 src/api/c/transpose.cpp                            |   4 +
 src/api/c/type_util.cpp                            |  10 +-
 src/api/c/unwrap.cpp                               |   2 +
 src/api/c/var.cpp                                  |   8 +
 src/api/c/where.cpp                                |   2 +
 src/api/c/wrap.cpp                                 |   2 +
 src/api/cpp/array.cpp                              |  24 ++-
 src/api/cpp/corrcoef.cpp                           |   4 +
 src/api/cpp/data.cpp                               |   2 +
 src/api/cpp/device.cpp                             |   8 +-
 src/api/cpp/mean.cpp                               |   2 +
 src/api/cpp/median.cpp                             |   4 +
 src/api/cpp/reduce.cpp                             |   6 +
 src/api/cpp/stdev.cpp                              |   4 +
 src/api/cpp/var.cpp                                |   2 +
 src/api/unified/symbol_manager.cpp                 |  15 +-
 src/backend/ArrayInfo.cpp                          |   2 +
 src/backend/cpu/Array.cpp                          |   2 +
 src/backend/cpu/approx.cpp                         |   8 +-
 src/backend/cpu/assign.cpp                         |   2 +
 src/backend/cpu/bilateral.cpp                      |   2 +
 src/backend/cpu/convolve.cpp                       |   2 +
 src/backend/cpu/copy.cpp                           |  54 +++---
 src/backend/cpu/diagonal.cpp                       |   2 +
 src/backend/cpu/diff.cpp                           |   2 +
 src/backend/cpu/fast.cpp                           |   2 +
 src/backend/cpu/fftconvolve.cpp                    |   4 +
 src/backend/cpu/hist_graphics.cpp                  |   2 +
 src/backend/cpu/histogram.cpp                      |  10 +-
 src/backend/cpu/histogram.hpp                      |   2 +-
 src/backend/cpu/identity.cpp                       |   4 +-
 src/backend/cpu/image.cpp                          |   2 +
 src/backend/cpu/index.cpp                          |   2 +
 src/backend/cpu/iota.cpp                           |   2 +
 src/backend/cpu/ireduce.cpp                        |   4 +
 src/backend/cpu/join.cpp                           |   4 +
 src/backend/cpu/lookup.cpp                         |   4 +
 src/backend/cpu/match_template.cpp                 |   2 +
 src/backend/cpu/meanshift.cpp                      |   2 +
 src/backend/cpu/medfilt.cpp                        |   2 +
 src/backend/cpu/memory.cpp                         |   2 +
 src/backend/cpu/morph.cpp                          |   2 +
 src/backend/cpu/nearest_neighbour.cpp              |  13 +-
 src/backend/cpu/platform.cpp                       |   4 +-
 src/backend/cpu/plot.cpp                           |   2 +
 src/backend/cpu/random.cpp                         |   2 +
 src/backend/cpu/range.cpp                          |   2 +
 src/backend/cpu/reduce.cpp                         |  16 +-
 src/backend/cpu/regions.cpp                        |   2 +
 src/backend/cpu/reorder.cpp                        |   2 +
 src/backend/cpu/resize.cpp                         |   2 +
 src/backend/cpu/rotate.cpp                         |   2 +
 src/backend/cpu/scan.cpp                           |   2 +
 src/backend/cpu/select.cpp                         |   2 +
 src/backend/cpu/set.cpp                            |   2 +
 src/backend/cpu/shift.cpp                          |   2 +
 src/backend/cpu/sobel.cpp                          |   2 +
 src/backend/cpu/sort.cpp                           |   2 +
 src/backend/cpu/sort_by_key.cpp                    |   5 +
 src/backend/cpu/sort_index.cpp                     |   2 +
 src/backend/cpu/susan.cpp                          |   2 +
 src/backend/cpu/tile.cpp                           |   2 +
 src/backend/cpu/transform.cpp                      |   2 +
 src/backend/cpu/transpose.cpp                      |   2 +
 src/backend/cpu/triangle.cpp                       |   2 +
 src/backend/cpu/types.hpp                          |   1 +
 src/backend/cpu/unwrap.cpp                         |   2 +
 src/backend/cpu/where.cpp                          |   2 +
 src/backend/cpu/wrap.cpp                           |   2 +
 src/backend/cuda/Array.cpp                         |   2 +
 src/backend/cuda/JIT/arith.cu                      |   2 +
 src/backend/cuda/JIT/cast.cu                       |  20 ++-
 src/backend/cuda/JIT/exp.cu                        |   4 +
 src/backend/cuda/JIT/hyper.cu                      |   2 +
 src/backend/cuda/JIT/logic.cu                      |   8 +
 src/backend/cuda/JIT/numeric.cu                    |  42 +++--
 src/backend/cuda/JIT/trig.cu                       |   4 +
 src/backend/cuda/JIT/types.h                       |   1 +
 src/backend/cuda/all.cu                            |   2 +
 src/backend/cuda/any.cu                            |   2 +
 src/backend/cuda/assign.cu                         |   8 +-
 src/backend/cuda/bilateral.cu                      |   2 +
 src/backend/cuda/convolve.cpp                      |   2 +
 src/backend/cuda/copy.cu                           |  38 +++--
 src/backend/cuda/count.cu                          |   2 +
 src/backend/cuda/diagonal.cu                       |   2 +
 src/backend/cuda/diff.cu                           |   2 +
 src/backend/cuda/dilate.cu                         |   2 +
 src/backend/cuda/dilate3d.cu                       |   2 +
 src/backend/cuda/erode.cu                          |   2 +
 src/backend/cuda/erode3d.cu                        |   2 +
 src/backend/cuda/fast.cu                           |   2 +
 src/backend/cuda/fast_pyramid.cu                   |   2 +
 src/backend/cuda/fftconvolve.cu                    |   2 +
 src/backend/cuda/histogram.cu                      |  21 +--
 src/backend/cuda/histogram.hpp                     |   2 +-
 src/backend/cuda/identity.cu                       |   2 +
 src/backend/cuda/index.cu                          |   6 +-
 src/backend/cuda/iota.cu                           |   2 +
 src/backend/cuda/ireduce.cu                        |   4 +
 src/backend/cuda/jit.cpp                           |   2 +
 src/backend/cuda/join.cu                           |  22 ++-
 src/backend/cuda/kernel/convolve.cu                |  14 +-
 src/backend/cuda/kernel/convolve_separable.cu      |  10 +-
 src/backend/cuda/kernel/fast.hpp                   |  20 +++
 src/backend/cuda/kernel/histogram.hpp              |  33 ++--
 src/backend/cuda/kernel/ireduce.hpp                |  11 ++
 src/backend/cuda/kernel/memcopy.hpp                |   2 +
 src/backend/cuda/kernel/nearest_neighbour.hpp      |   9 +
 src/backend/cuda/kernel/reduce.hpp                 |  11 +-
 src/backend/cuda/kernel/shared.hpp                 |   2 +
 src/backend/cuda/lookup.cu                         |   4 +
 src/backend/cuda/match_template.cu                 |   2 +
 src/backend/cuda/math.hpp                          |   7 +
 src/backend/cuda/max.cu                            |   2 +
 src/backend/cuda/meanshift.cu                      |   2 +
 src/backend/cuda/medfilt.cu                        |   2 +
 src/backend/cuda/memory.cpp                        |   2 +
 src/backend/cuda/min.cu                            |   2 +
 src/backend/cuda/nearest_neighbour.cu              |   2 +
 src/backend/cuda/platform.cpp                      |   4 +
 src/backend/cuda/product.cu                        |   4 +-
 src/backend/cuda/random.cu                         |   2 +
 src/backend/cuda/range.cu                          |   2 +
 src/backend/cuda/regions.cu                        |   2 +
 src/backend/cuda/reorder.cu                        |   2 +
 src/backend/cuda/resize.cu                         |   2 +
 src/backend/cuda/rotate.cu                         |   2 +
 src/backend/cuda/scan.cu                           |   2 +
 src/backend/cuda/select.cu                         |   2 +
 src/backend/cuda/set.cu                            |   2 +
 src/backend/cuda/shift.cu                          |   2 +
 src/backend/cuda/sobel.cu                          |   2 +
 src/backend/cuda/sort.cu                           |   2 +
 .../cuda/{dilate.cu => sort_by_key/ascd_s16.cu}    |  11 +-
 .../cuda/{dilate.cu => sort_by_key/ascd_u16.cu}    |  11 +-
 .../cuda/{dilate.cu => sort_by_key/desc_s16.cu}    |  11 +-
 .../cuda/{dilate.cu => sort_by_key/desc_u16.cu}    |  11 +-
 src/backend/cuda/sort_by_key_impl.hpp              |   2 +
 src/backend/cuda/sort_index.cu                     |   2 +
 src/backend/cuda/sum.cu                            |   2 +
 src/backend/cuda/susan.cu                          |   2 +
 src/backend/cuda/tile.cu                           |   2 +
 src/backend/cuda/transform.cu                      |   2 +
 src/backend/cuda/transpose.cu                      |   2 +
 src/backend/cuda/transpose_inplace.cu              |   2 +
 src/backend/cuda/triangle.cu                       |   2 +
 src/backend/cuda/types.cpp                         |   8 +
 src/backend/cuda/types.hpp                         |   3 +-
 src/backend/cuda/unwrap.cu                         |   2 +
 src/backend/cuda/where.cu                          |   2 +
 src/backend/cuda/wrap.cu                           |   2 +
 src/backend/defines.hpp                            |   4 +
 src/backend/opencl/Array.cpp                       |   2 +
 src/backend/opencl/all.cpp                         |   2 +
 src/backend/opencl/any.cpp                         |   2 +
 src/backend/opencl/assign.cpp                      |   6 +-
 src/backend/opencl/bilateral.cpp                   |   2 +
 src/backend/opencl/convolve.cpp                    |   2 +
 src/backend/opencl/convolve_separable.cpp          |   2 +
 src/backend/opencl/copy.cpp                        |  24 ++-
 src/backend/opencl/count.cpp                       |   2 +
 src/backend/opencl/diagonal.cpp                    |   2 +
 src/backend/opencl/diff.cpp                        |   2 +
 src/backend/opencl/dilate.cpp                      |   2 +
 src/backend/opencl/dilate3d.cpp                    |   2 +
 src/backend/opencl/erode.cpp                       |   2 +
 src/backend/opencl/erode3d.cpp                     |   2 +
 src/backend/opencl/fast.cpp                        |   2 +
 src/backend/opencl/fftconvolve.cpp                 |   2 +
 src/backend/opencl/histogram.cpp                   |  21 +--
 src/backend/opencl/histogram.hpp                   |   2 +-
 src/backend/opencl/identity.cpp                    |   2 +
 src/backend/opencl/index.cpp                       |   6 +-
 src/backend/opencl/iota.cpp                        |   2 +
 src/backend/opencl/ireduce.cpp                     |   4 +
 src/backend/opencl/join.cpp                        |   4 +
 src/backend/opencl/kernel/convolve/conv1.cpp       |   2 +
 .../{dilate.cpp => kernel/convolve/conv2_s16.cpp}  |  15 +-
 .../{dilate.cpp => kernel/convolve/conv2_u16.cpp}  |  15 +-
 src/backend/opencl/kernel/convolve/conv3.cpp       |   2 +
 src/backend/opencl/kernel/convolve_separable.cpp   |   2 +
 src/backend/opencl/kernel/fast.hpp                 |   2 +-
 src/backend/opencl/kernel/histogram.cl             |  24 ++-
 src/backend/opencl/kernel/histogram.hpp            |  15 +-
 src/backend/opencl/kernel/iops.cl                  |  24 ++-
 src/backend/opencl/kernel/ireduce.hpp              |  15 +-
 src/backend/opencl/kernel/reduce.hpp               |  12 +-
 src/backend/opencl/lookup.cpp                      |   4 +
 src/backend/opencl/match_template.cpp              |   2 +
 src/backend/opencl/max.cpp                         |   2 +
 src/backend/opencl/meanshift.cpp                   |   2 +
 src/backend/opencl/medfilt.cpp                     |   2 +
 src/backend/opencl/memory.cpp                      |   2 +
 src/backend/opencl/min.cpp                         |   2 +
 src/backend/opencl/nearest_neighbour.cpp           |   2 +
 src/backend/opencl/product.cpp                     |   2 +
 src/backend/opencl/random.cpp                      |   2 +
 src/backend/opencl/range.cpp                       |   2 +
 src/backend/opencl/regions.cpp                     |   2 +
 src/backend/opencl/reorder.cpp                     |   2 +
 src/backend/opencl/resize.cpp                      |   2 +
 src/backend/opencl/rotate.cpp                      |   2 +
 src/backend/opencl/scan.cpp                        |   2 +
 src/backend/opencl/select.cpp                      |   2 +
 src/backend/opencl/set.cpp                         |   2 +
 src/backend/opencl/shift.cpp                       |   2 +
 src/backend/opencl/sobel.cpp                       |   2 +
 src/backend/opencl/sort.cpp                        |   2 +
 src/backend/opencl/sort_by_key/impl.hpp            |   2 +
 .../opencl/{dilate.cpp => sort_by_key/s16.cpp}     |  12 +-
 .../opencl/{dilate.cpp => sort_by_key/u16.cpp}     |  12 +-
 src/backend/opencl/sort_index.cpp                  |   2 +
 src/backend/opencl/sum.cpp                         |   2 +
 src/backend/opencl/susan.cpp                       |   2 +
 src/backend/opencl/tile.cpp                        |   2 +
 src/backend/opencl/transform.cpp                   |   2 +
 src/backend/opencl/transpose.cpp                   |   2 +
 src/backend/opencl/transpose_inplace.cpp           |   2 +
 src/backend/opencl/triangle.cpp                    |   2 +
 src/backend/opencl/types.cpp                       |   2 +
 src/backend/opencl/types.hpp                       |   1 +
 src/backend/opencl/unwrap.cpp                      |   2 +
 src/backend/opencl/where.cpp                       |   2 +
 src/backend/opencl/wrap.cpp                        |   2 +
 test/approx1.cpp                                   |  14 +-
 test/approx2.cpp                                   |  16 +-
 test/array.cpp                                     |  22 ++-
 test/assign.cpp                                    |   2 +-
 test/bilateral.cpp                                 |   2 +-
 test/blas.cpp                                      |  37 +++--
 test/constant.cpp                                  |   2 +-
 test/convolve.cpp                                  |   2 +-
 test/diff1.cpp                                     |   2 +-
 test/diff2.cpp                                     |   2 +-
 test/dog.cpp                                       |   6 +-
 test/fast.cpp                                      |   2 +-
 test/hamming.cpp                                   |   4 +-
 test/histogram.cpp                                 |  21 ++-
 test/index.cpp                                     |   4 +-
 test/info.cpp                                      |  36 ++--
 test/iota.cpp                                      |   2 +-
 test/ireduce.cpp                                   |  22 +++
 test/join.cpp                                      |   2 +-
 test/match_template.cpp                            |   2 +-
 test/mean.cpp                                      |  46 ++++--
 test/meanshift.cpp                                 |   2 +-
 test/medfilt.cpp                                   |   2 +-
 test/median.cpp                                    |  27 ++-
 test/moddims.cpp                                   |   2 +-
 test/morph.cpp                                     |   2 +-
 test/nearest_neighbour.cpp                         |  14 +-
 test/random.cpp                                    |   2 +-
 test/range.cpp                                     |   2 +-
 test/reduce.cpp                                    |  39 ++++-
 test/regions.cpp                                   |   2 +-
 test/reorder.cpp                                   |   2 +-
 test/replace.cpp                                   |   2 +-
 test/resize.cpp                                    |   2 +-
 test/rotate.cpp                                    |   2 +-
 test/rotate_linear.cpp                             |   2 +-
 test/sat.cpp                                       |   2 +-
 test/scan.cpp                                      |   4 +-
 test/select.cpp                                    |   2 +-
 test/shift.cpp                                     |   2 +-
 test/sobel.cpp                                     |   2 +-
 test/sort.cpp                                      |   2 +-
 test/sort_by_key.cpp                               |   2 +-
 test/sort_index.cpp                                |   2 +-
 test/susan.cpp                                     |   2 +-
 test/testHelpers.hpp                               |  41 +----
 test/tile.cpp                                      |   2 +-
 test/translate.cpp                                 |   2 +-
 test/transpose.cpp                                 |   2 +-
 test/transpose_inplace.cpp                         |   2 +-
 test/triangle.cpp                                  |   2 +-
 test/unwrap.cpp                                    |   2 +-
 test/var.cpp                                       |  16 +-
 test/where.cpp                                     |   2 +-
 test/wrap.cpp                                      |   2 +-
 test/write.cpp                                     |   2 +-
 356 files changed, 1884 insertions(+), 614 deletions(-)

diff --cc src/api/c/mean.cpp
index 38401be,76d2e6e..09844ef
--- a/src/api/c/mean.cpp
+++ b/src/api/c/mean.cpp
@@@ -60,16 -73,18 +60,18 @@@ af_err af_mean(af_array *out, const af_
          ArrayInfo info = getInfo(in);
          af_dtype type = info.getType();
          switch(type) {
 -            case f64: output = mean<double,  double>(in, dim); break;
 -            case f32: output = mean<float ,  float >(in, dim); break;
 -            case s32: output = mean<int   ,  float >(in, dim); break;
 -            case u32: output = mean<uint  ,  float >(in, dim); break;
 -            case s64: output = mean<intl  ,  double>(in, dim); break;
 -            case u64: output = mean<uintl ,  double>(in, dim); break;
 -            case s16: output = mean<short ,  float >(in, dim); break;
 -            case u16: output = mean<ushort,  float >(in, dim); break;
 -            case  u8: output = mean<uchar ,  float >(in, dim); break;
 -            case  b8: output = mean<char  ,  float >(in, dim); break;
 -            case c32: output = mean<cfloat,  cfloat>(in, dim); break;
 -            case c64: output = mean<cdouble,cdouble>(in, dim); break;
 +            case f64: output = mean< double>(in, dim); break;
-             case f32: output = mean<  float>(in, dim); break;
-             case s32: output = mean<  float>(in, dim); break;
-             case u32: output = mean<  float>(in, dim); break;
++            case f32: output = mean< float >(in, dim); break;
++            case s32: output = mean< float >(in, dim); break;
++            case u32: output = mean< float >(in, dim); break;
 +            case s64: output = mean< double>(in, dim); break;
 +            case u64: output = mean< double>(in, dim); break;
-             case  u8: output = mean<  float>(in, dim); break;
-             case  b8: output = mean<  float>(in, dim); break;
++            case s16: output = mean< float >(in, dim); break;
++            case u16: output = mean< float >(in, dim); break;
++            case  u8: output = mean< float >(in, dim); break;
++            case  b8: output = mean< float >(in, dim); break;
 +            case c32: output = mean< cfloat>(in, dim); break;
 +            case c64: output = mean<cdouble>(in, dim); break;
              default : TYPE_ERROR(1, type);
          }
          std::swap(*out, output);
@@@ -92,16 -107,18 +94,18 @@@ af_err af_mean_weighted(af_array *out, 
          ARG_ASSERT(2, (wType==f32 || wType==f64)); /* verify that weights are non-complex real numbers */
  
          switch(iType) {
 -            case f64: output = mean<double,  double>(in, weights, dim); break;
 -            case f32: output = mean<float ,  float >(in, weights, dim); break;
 -            case s32: output = mean<int   ,  float >(in, weights, dim); break;
 -            case u32: output = mean<uint  ,  float >(in, weights, dim); break;
 -            case s64: output = mean<intl  ,  double>(in, weights, dim); break;
 -            case u64: output = mean<uintl ,  double>(in, weights, dim); break;
 -            case s16: output = mean<short ,  float >(in, weights, dim); break;
 -            case u16: output = mean<ushort,  float >(in, weights, dim); break;
 -            case  u8: output = mean<uchar ,  float >(in, weights, dim); break;
 -            case  b8: output = mean<char  ,  float >(in, weights, dim); break;
 -            case c32: output = mean<cfloat,  cfloat>(in, weights, dim); break;
 -            case c64: output = mean<cdouble,cdouble>(in, weights, dim); break;
 +            case f64: output = mean< double>(in, weights, dim); break;
-             case f32: output = mean<  float>(in, weights, dim); break;
-             case s32: output = mean<  float>(in, weights, dim); break;
-             case u32: output = mean<  float>(in, weights, dim); break;
++            case f32: output = mean< float >(in, weights, dim); break;
++            case s32: output = mean< float >(in, weights, dim); break;
++            case u32: output = mean< float >(in, weights, dim); break;
 +            case s64: output = mean< double>(in, weights, dim); break;
 +            case u64: output = mean< double>(in, weights, dim); break;
-             case  u8: output = mean<  float>(in, weights, dim); break;
-             case  b8: output = mean<  float>(in, weights, dim); break;
++            case s16: output = mean< float >(in, weights, dim); break;
++            case u16: output = mean< float >(in, weights, dim); break;
++            case  u8: output = mean< float >(in, weights, dim); break;
++            case  b8: output = mean< float >(in, weights, dim); break;
 +            case c32: output = mean< cfloat>(in, weights, dim); break;
 +            case c64: output = mean<cdouble>(in, weights, dim); break;
              default : TYPE_ERROR(1, iType);
          }
          std::swap(*out, output);
@@@ -116,16 -133,18 +120,18 @@@ af_err af_mean_all(double *realVal, dou
          ArrayInfo info = getInfo(in);
          af_dtype type = info.getType();
          switch(type) {
 -            case f64: *realVal = mean<double, double>(in); break;
 -            case f32: *realVal = mean<float ,  float>(in); break;
 -            case s32: *realVal = mean<int   ,  float>(in); break;
 -            case u32: *realVal = mean<uint  ,  float>(in); break;
 -            case s64: *realVal = mean<intl  , double>(in); break;
 -            case u64: *realVal = mean<uintl , double>(in); break;
 -            case s16: *realVal = mean<short ,  float>(in); break;
 -            case u16: *realVal = mean<ushort,  float>(in); break;
 -            case  u8: *realVal = mean<uchar ,  float>(in); break;
 -            case  b8: *realVal = mean<char  ,  float>(in); break;
 +            case f64: *realVal = mean<double>(in); break;
 +            case f32: *realVal = mean< float>(in); break;
 +            case s32: *realVal = mean< float>(in); break;
 +            case u32: *realVal = mean< float>(in); break;
 +            case s64: *realVal = mean<double>(in); break;
 +            case u64: *realVal = mean<double>(in); break;
++            case s16: *realVal = mean< float>(in); break;
++            case u16: *realVal = mean< float>(in); break;
 +            case  u8: *realVal = mean< float>(in); break;
 +            case  b8: *realVal = mean< float>(in); break;
              case c32: {
 -                cfloat tmp = mean<cfloat,cfloat>(in);
 +                cfloat tmp = mean<cfloat>(in);
                  *realVal = real(tmp);
                  *imagVal = imag(tmp);
                  } break;
@@@ -152,16 -171,18 +158,18 @@@ af_err af_mean_all_weighted(double *rea
          ARG_ASSERT(3, (wType==f32 || wType==f64)); /* verify that weights are non-complex real numbers */
  
          switch(iType) {
 -            case f64: *realVal = mean<double, double>(in, weights); break;
 -            case f32: *realVal = mean<float ,  float>(in, weights); break;
 -            case s32: *realVal = mean<int   ,  float>(in, weights); break;
 -            case u32: *realVal = mean<uint  ,  float>(in, weights); break;
 -            case s64: *realVal = mean<intl  , double>(in, weights); break;
 -            case u64: *realVal = mean<uintl , double>(in, weights); break;
 -            case s16: *realVal = mean<short ,  float>(in, weights); break;
 -            case u16: *realVal = mean<ushort,  float>(in, weights); break;
 -            case  u8: *realVal = mean<uchar ,  float>(in, weights); break;
 -            case  b8: *realVal = mean<char  ,  float>(in, weights); break;
 +            case f64: *realVal = mean<double>(in, weights); break;
 +            case f32: *realVal = mean< float>(in, weights); break;
 +            case s32: *realVal = mean< float>(in, weights); break;
 +            case u32: *realVal = mean< float>(in, weights); break;
 +            case s64: *realVal = mean<double>(in, weights); break;
 +            case u64: *realVal = mean<double>(in, weights); break;
++            case s16: *realVal = mean< float>(in, weights); break;
++            case u16: *realVal = mean< float>(in, weights); break;
 +            case  u8: *realVal = mean< float>(in, weights); break;
 +            case  b8: *realVal = mean< float>(in, weights); break;
              case c32: {
 -                cfloat tmp = mean<cfloat,cfloat>(in);
 +                cfloat tmp = mean<cfloat>(in, weights);
                  *realVal = real(tmp);
                  *imagVal = imag(tmp);
                  } break;
diff --cc test/mean.cpp
index fed7c96,1559c78..a39f540
--- a/test/mean.cpp
+++ b/test/mean.cpp
@@@ -132,22 -111,12 +134,12 @@@ void meanDimTest(string pFileName, dim_
  
  TYPED_TEST(Mean, Dim0Matrix)
  {
 -    meanDimTest<TypeParam>(string(TEST_DIR"/mean/mean_dim0_matrix.test"), 0);
 +    meanDimTest<TypeParam>(string(TEST_DIR "/mean/mean_dim0_matrix.test"), 0);
  }
  
- TYPED_TEST(Mean, Wtd_Dim0Matrix)
- {
-     meanDimTest<TypeParam>(string(TEST_DIR "/mean/wtd_mean_dim0_mat.test"), 0, true);
- }
- 
- TYPED_TEST(Mean, Wtd_Dim1Matrix)
- {
-     meanDimTest<TypeParam>(string(TEST_DIR "/mean/wtd_mean_dim1_mat.test"), 1, true);
- }
- 
  TYPED_TEST(Mean, Dim1Cube)
  {
 -    meanDimTest<TypeParam>(string(TEST_DIR"/mean/mean_dim1_cube.test"), 1);
 +    meanDimTest<TypeParam>(string(TEST_DIR "/mean/mean_dim1_cube.test"), 1);
  }
  
  TYPED_TEST(Mean, Dim0HyperCube)
@@@ -167,11 -136,16 +159,21 @@@ TYPED_TEST(Mean, Dim2Cube
  
  TYPED_TEST(Mean, Dim2HyperCube)
  {
 -    meanDimTest<TypeParam>(string(TEST_DIR"/mean/mean_dim2_hypercube.test"), 2);
 +    meanDimTest<TypeParam>(string(TEST_DIR "/mean/mean_dim2_hypercube.test"), 2);
  }
  
 -//////////////////////////////// CPP ////////////////////////////////////
 -// test mean_all interface using cpp api
++TYPED_TEST(Mean, Wtd_Dim0Matrix)
++{
++    meanDimTest<TypeParam>(string(TEST_DIR "/mean/wtd_mean_dim0_mat.test"), 0, true);
++}
+ 
 -#include <iostream>
++TYPED_TEST(Mean, Wtd_Dim1Matrix)
++{
++    meanDimTest<TypeParam>(string(TEST_DIR "/mean/wtd_mean_dim1_mat.test"), 1, true);
++}
+ 
  template<typename T>
 -void testCPPMean(T const_value, af::dim4 dims)
 +void meanAllTest(T const_value, af::dim4 dims)
  {
      typedef typename meanOutType<T>::type outType;
      if (noDoubleTests<T>()) return;
@@@ -196,102 -170,52 +198,112 @@@
      ASSERT_NEAR(::imag(output), ::imag(gold), 1.0e-3);
  }
  
 -TEST(Mean, CPP_f64)
 +TEST(MeanAll, f64)
 +{
 +    meanAllTest<double>(2.1, af::dim4(10, 10, 1, 1));
 +}
 +
 +TEST(MeanAll, f32)
  {
 -    testCPPMean<double>(2.1, af::dim4(10, 10, 1, 1));
 +    meanAllTest<float>(2.1f, af::dim4(10, 5, 2, 1));
  }
  
 -TEST(Mean, CPP_f32)
 +TEST(MeanAll, s32)
  {
 -    testCPPMean<float>(2.1f, af::dim4(10, 5, 2, 1));
 +    meanAllTest<int>(2, af::dim4(5, 5, 2, 2));
  }
  
 -TEST(Mean, CPP_s32)
 +TEST(MeanAll, u32)
  {
 -    testCPPMean<int>(2, af::dim4(5, 5, 2, 2));
 +    meanAllTest<unsigned>(2, af::dim4(100, 1, 1, 1));
  }
  
 -TEST(Mean, CPP_u32)
 +TEST(MeanAll, s8)
  {
 -    testCPPMean<unsigned>(2, af::dim4(100, 1, 1, 1));
 +    meanAllTest<char>(2, af::dim4(5, 5, 2, 2));
  }
  
 -TEST(Mean, CPP_s8)
 +TEST(MeanAll, u8)
  {
 -    testCPPMean<char>(2, af::dim4(5, 5, 2, 2));
 +    meanAllTest<uchar>(2, af::dim4(100, 1, 1, 1));
  }
  
 -TEST(Mean, CPP_u8)
 +TEST(MeanAll, c32)
  {
 -    testCPPMean<uchar>(2, af::dim4(100, 1, 1, 1));
 +    meanAllTest<cfloat>(cfloat(2.1f), af::dim4(10, 5, 2, 1));
  }
  
 -TEST(Mean, CPP_s16)
++TEST(MeanAll, s16)
+ {
 -    testCPPMean<short>(2, af::dim4(5, 5, 2, 2));
++    meanAllTest<short>(2, af::dim4(5, 5, 2, 2));
+ }
+ 
 -TEST(Mean, CPP_u16)
++TEST(MeanAll, u16)
+ {
 -    testCPPMean<ushort>(2, af::dim4(100, 1, 1, 1));
++    meanAllTest<ushort>(2, af::dim4(100, 1, 1, 1));
+ }
+ 
 -TEST(Mean, CPP_cfloat)
 +TEST(MeanAll, c64)
  {
 -    testCPPMean<cfloat>(cfloat(2.1f), af::dim4(10, 5, 2, 1));
 +    meanAllTest<cdouble>(cdouble(2.1), af::dim4(10, 10, 1, 1));
 +}
 +
 +
 +template<typename T>
 +T random() { return T(std::rand()%10); }
 +
 +template<> cfloat random<cfloat>() { return cfloat(float(std::rand()%10), float(std::rand()%10)); }
 +
 +template<> cdouble random<cdouble>() { return cdouble(double(std::rand()%10), double(std::rand()%10)); }
 +
 +template<typename T>
 +class WeightedMean : public ::testing::Test
 +{
 +    public:
 +        virtual void SetUp() {}
 +};
 +
 +// register the type list
 +TYPED_TEST_CASE(WeightedMean, TestTypes);
 +
 +template<typename T, typename wtsType>
 +void weightedMeanAllTest(af::dim4 dims)
 +{
 +    typedef typename meanOutType<T>::type outType;
 +
 +    if (noDoubleTests<T>()) return;
 +    if (noDoubleTests<outType>()) return;
 +    if (noDoubleTests<wtsType>()) return;
 +
 +    using af::array;
 +    using af::mean;
 +
 +    std::srand(std::time(0));
 +
 +    vector<T> data(dims.elements());
 +    vector<wtsType> wts(dims.elements());
 +    std::generate(data.begin(), data.end(), random<T>);
 +    std::generate(wts.begin(), wts.end(), random<wtsType>);
 +
 +    outType wtdSum = outType(0);
 +    wtsType wtsSum = wtsType(0);
 +
 +    for(int i = 0; i < (int)data.size(); i++) {
 +        wtdSum = wtdSum + data[i]*wts[i];
 +        wtsSum = wtsSum + wts[i];
 +    }
 +
 +    outType gold = wtdSum / wtsSum;
 +
 +    array a(dims, &(data.front()));
 +    array w(dims, &(wts.front()));
 +    outType output = mean<outType>(a, w);
 +
 +    ASSERT_NEAR(::real(output), ::real(gold), 1.0e-2);
 +    ASSERT_NEAR(::imag(output), ::imag(gold), 1.0e-2);
  }
  
 -TEST(Mean, CPP_cdouble)
 +TYPED_TEST(WeightedMean, Basic)
  {
 -    testCPPMean<cdouble>(cdouble(2.1), af::dim4(10, 10, 1, 1));
 +    weightedMeanAllTest<TypeParam, float>(af::dim4(66, 66, 31, 17));
  }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/arrayfire.git



More information about the debian-science-commits mailing list