[nfft] 01/01: New upstream version 3.4.0~rc1

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Wed Sep 20 17:53:14 UTC 2017


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

ghisvail-guest pushed a commit to branch upstream/latest
in repository nfft.

commit 602289f8c7b00cb2551af6eb072126f6b099d1e8
Author: Ghislain Antony Vaillant <ghisvail at gmail.com>
Date:   Tue Sep 19 17:43:32 2017 +0200

    New upstream version 3.4.0~rc1
---
 .gitignore                                         |  12 +
 3rdparty/cstripack/cstripack.c                     |   2 +-
 3rdparty/cstripack/cstripack.h                     |   2 +-
 ChangeLog                                          |  17 +
 Makefile.am                                        |   6 +-
 README.md                                          |   5 +-
 applications/doxygen.c                             |   2 +-
 applications/fastgauss/fastgauss.c.in              |   2 +-
 applications/fastgauss/levelplots.m                |   2 +-
 applications/fastgauss/output_error.m              |   2 +-
 applications/fastgauss/output_error_p.m            |   2 +-
 applications/fastgauss/show_results.m              |   2 +-
 applications/fastsum/Makefile.am                   |   4 +
 applications/fastsum/fastsum.c                     | 388 ++++++++-----
 applications/fastsum/fastsum.h                     |  82 ++-
 applications/fastsum/fastsum.m                     |   4 +-
 applications/fastsum/fastsum_benchomp.c            |   2 +-
 .../fastsum/fastsum_benchomp_createdataset.c       |   2 +-
 applications/fastsum/fastsum_benchomp_detail.c     |   6 +-
 applications/fastsum/fastsum_matlab.c              |   6 +-
 applications/fastsum/fastsum_test.c                |   6 +-
 applications/fastsum/fastsum_test.m                |   2 +-
 applications/fastsum/kernels.c                     |  18 +-
 applications/fastsum/kernels.h                     |  29 +-
 applications/fastsumS2/doxygen.h                   |   2 +-
 applications/fastsumS2/fastsumS2.c                 |   2 +-
 applications/fastsumS2/fastsumS2.m                 |   4 +-
 applications/fastsumS2/readTestcase.m              |   2 +-
 applications/fastsumS2/writeTestcase.m             |   2 +-
 applications/iterS2/doxygen.h                      |   2 +-
 applications/iterS2/iterS2.c                       |   2 +-
 applications/iterS2/writeImageTestcase.m           |   4 +-
 applications/iterS2/writeTestcase.m                |   4 +-
 applications/mri/doxygen.c                         |   2 +-
 applications/mri/mri2d/construct_data_2d.c         |   2 +-
 applications/mri/mri2d/construct_data_inh_2d1d.c   |   2 +-
 applications/mri/mri2d/construct_data_inh_3d.c     |   2 +-
 applications/mri/mri2d/construct_inh.m             |   2 +-
 applications/mri/mri2d/construct_knots_linogram.m  |   2 +-
 applications/mri/mri2d/construct_knots_radial.m    |   2 +-
 applications/mri/mri2d/construct_knots_rose.m      |   2 +-
 applications/mri/mri2d/construct_knots_spiral.m    |   2 +-
 applications/mri/mri2d/construct_readout_time.m    |   2 +-
 applications/mri/mri2d/doxygen.h                   |   2 +-
 applications/mri/mri2d/mri.m                       |   2 +-
 applications/mri/mri2d/mri_inh.m                   |   2 +-
 applications/mri/mri2d/phantom.m                   |   2 +-
 applications/mri/mri2d/precompute_weights.m        |   2 +-
 applications/mri/mri2d/reconstruct_data_2d.c       |   2 +-
 applications/mri/mri2d/reconstruct_data_gridding.c |   2 +-
 applications/mri/mri2d/reconstruct_data_inh_2d1d.c |   2 +-
 applications/mri/mri2d/reconstruct_data_inh_3d.c   |   2 +-
 .../mri/mri2d/reconstruct_data_inh_nnfft.c         |   2 +-
 applications/mri/mri2d/rms.m                       |   2 +-
 applications/mri/mri2d/verschiebung.m              |   2 +-
 applications/mri/mri2d/visualize_data.m            |   2 +-
 applications/mri/mri3d/construct_data_2d1d.c       |   2 +-
 applications/mri/mri3d/construct_data_3d.c         |   2 +-
 applications/mri/mri3d/construct_knots_linogram.m  |   2 +-
 applications/mri/mri3d/construct_knots_radial.m    |   2 +-
 applications/mri/mri3d/construct_knots_radial_3d.m |   2 +-
 applications/mri/mri3d/construct_knots_rose.m      |   2 +-
 applications/mri/mri3d/construct_knots_spiral.m    |   2 +-
 applications/mri/mri3d/construct_phantom.m         |   2 +-
 applications/mri/mri3d/doxygen.h                   |   2 +-
 applications/mri/mri3d/mri.m                       |   2 +-
 applications/mri/mri3d/precompute_weights_2d.m     |   2 +-
 applications/mri/mri3d/reconstruct_data_2d1d.c     |   2 +-
 applications/mri/mri3d/reconstruct_data_3d.c       |   2 +-
 applications/mri/mri3d/reconstruct_data_gridding.c |   2 +-
 applications/mri/mri3d/rms.m                       |   2 +-
 applications/mri/mri3d/visualize_data.m            |   2 +-
 applications/polarFFT/doxygen.h                    |   2 +-
 applications/polarFFT/fft_test.m                   |   2 +-
 applications/polarFFT/linogram_fft_test.c.in       |   2 +-
 applications/polarFFT/mpolar_fft_test.c.in         |   2 +-
 applications/polarFFT/phantom.m                    |   2 +-
 applications/polarFFT/polar_fft_test.c.in          |   2 +-
 applications/quadratureS2/doxygen.h                |   2 +-
 applications/quadratureS2/lgwt.m                   |   2 +-
 applications/quadratureS2/plotGrid.m               |   4 +-
 applications/quadratureS2/quadratureS2.c           |   2 +-
 applications/quadratureS2/quadratureS2.m           |   4 +-
 applications/quadratureS2/readTestcase.m           |   4 +-
 applications/quadratureS2/writeTestcase.m          |   4 +-
 applications/quadratureS2/writeWeights.m           |   4 +-
 applications/radon/inverse_radon.c.in              |   2 +-
 applications/radon/phantom.m                       |   2 +-
 applications/radon/radon.c.in                      |   2 +-
 applications/radon/radon.m                         |   2 +-
 applications/radon/ridgelet.m                      |   2 +-
 configure.ac                                       |  45 +-
 doc/assets/sphere.pdf                              | Bin 0 -> 55197 bytes
 doc/assets/sphere.png                              | Bin 0 -> 10243 bytes
 doxygen.dox                                        |  16 +-
 doxygen/doxygen.Doxyfile.in                        |  51 +-
 examples/doxygen.c                                 |   2 +-
 examples/fpt/simple_test.c                         |   2 +-
 examples/nfct/simple_test.c.in                     |   2 +-
 examples/nfft/flags.c                              |   2 +-
 examples/nfft/flags.m                              |   2 +-
 examples/nfft/ndft_fast.c                          |   2 +-
 examples/nfft/ndft_fast.m                          |   2 +-
 examples/nfft/nfft_benchomp.c                      |   2 +-
 examples/nfft/nfft_benchomp_createdataset.c        |   2 +-
 examples/nfft/nfft_benchomp_detail.c               |   2 +-
 examples/nfft/nfft_times.c                         |   2 +-
 examples/nfft/simple_test.c.in                     |   2 +-
 examples/nfft/simple_test_threads.c.in             |   2 +-
 examples/nfft/taylor_nfft.c                        |   2 +-
 examples/nfft/taylor_nfft.m                        |   2 +-
 examples/nfsft/nfsft_benchomp.c                    |   2 +-
 examples/nfsft/nfsft_benchomp_createdataset.c      |   2 +-
 examples/nfsft/nfsft_benchomp_detail.c             |   2 +-
 examples/nfsft/simple_test.c                       |   2 +-
 examples/nfsft/simple_test_threads.c               |   2 +-
 examples/nfsoft/simple_test.c                      |   2 +-
 examples/nfst/simple_test.c.in                     |   2 +-
 examples/nnfft/accuracy.c                          |   2 +-
 examples/nnfft/accuracy.m                          |   2 +-
 examples/nnfft/simple_test.c                       |   2 +-
 examples/nsfft/nsfft_test.c                        |   2 +-
 examples/nsfft/simple_test.c                       |   2 +-
 examples/solver/doxygen.h                          |   2 +-
 examples/solver/glacier.c.in                       |   2 +-
 examples/solver/glacier.m                          |   2 +-
 examples/solver/glacier_cv.m                       |   2 +-
 examples/solver/simple_test.c.in                   |   2 +-
 include/api.h                                      |   2 +-
 include/infft.h                                    |   9 +-
 include/nfft3.h                                    |  16 +-
 include/nfft3mp.h                                  |   2 +-
 include/solver_adjoint.h                           |   2 +-
 include/ticks.h.in                                 |   2 +-
 kernel/fpt/fpt.c                                   |   2 +-
 kernel/fpt/fpt.h                                   |   2 +-
 kernel/mri/mri.c                                   |   2 +-
 kernel/nfct/nfct.c                                 |   4 +-
 kernel/nfft/nfft.c                                 |  66 ++-
 kernel/nfsft/api.h                                 |   2 +-
 kernel/nfsft/legendre.c                            |   2 +-
 kernel/nfsft/legendre.h                            |   2 +-
 kernel/nfsft/nfsft.c                               |   2 +-
 kernel/nfsoft/nfsoft.c                             |  49 +-
 kernel/nfsoft/wigner.c                             |   2 +-
 kernel/nfsoft/wigner.h                             |   2 +-
 kernel/nfst/nfst.c                                 |   4 +-
 kernel/nnfft/nnfft.c                               |   2 +-
 kernel/nsfft/nsfft.c                               |   2 +-
 kernel/solver/solver.c                             |   2 +-
 kernel/util/assert.c                               |   2 +-
 kernel/util/bessel_i0.c                            |   2 +-
 kernel/util/bspline.c                              |   2 +-
 kernel/util/damp.c                                 |   2 +-
 kernel/util/error.c                                |   2 +-
 kernel/util/float.c                                |   8 +-
 kernel/util/int.c                                  | 132 +++--
 kernel/util/lambda.c                               |   2 +-
 kernel/util/malloc.c                               |   2 +-
 kernel/util/print.c                                |   2 +-
 kernel/util/rand.c                                 |   2 +-
 kernel/util/sinc.c                                 |   4 +-
 kernel/util/sort.c                                 |   2 +-
 kernel/util/thread.c                               |   2 +-
 kernel/util/time.c                                 |   2 +-
 kernel/util/vector1.c                              |   2 +-
 kernel/util/vector2.c                              |   2 +-
 kernel/util/vector3.c                              |   2 +-
 kernel/util/version.c                              |   2 +-
 kernel/util/voronoi.c                              |   2 +-
 kernel/util/window.c                               |  10 +-
 m4/ax_eps_calc.m4                                  |  71 +++
 m4/ax_eps_def.m4                                   |  56 ++
 m4/ax_lib_fftw3.m4                                 |  25 +-
 m4/ax_prog_matlab.m4                               |   2 +-
 matlab/Makefile.am                                 |  20 +-
 matlab/args.c                                      |   2 +-
 matlab/fastsum/Contents.m                          |   0
 .../nnfftmex.m => fastsum/EXACT_NEARFIELD.m}       |  11 +-
 matlab/fastsum/Makefile.am                         |  38 ++
 .../nnfftmex.m => fastsum/NEARFIELD_BOXES.m}       |   9 +-
 matlab/fastsum/fastsum.m                           | 355 ++++++++++++
 .../{nfft/nfftmex.m => fastsum/fastsum_finalize.m} |  10 +-
 .../nfft_adjoint.m => fastsum/fastsum_get_f.m}     |  11 +-
 .../fastsum_get_num_threads.m}                     |  12 +-
 .../FFT_OUT_OF_PLACE.m => fastsum/fastsum_init.m}  |  12 +-
 .../nfftmex.m => fastsum/fastsum_set_alpha.m}      |  10 +-
 matlab/{nfft/nfftmex.m => fastsum/fastsum_set_x.m} |  10 +-
 matlab/{nfft/nfftmex.m => fastsum/fastsum_set_y.m} |  10 +-
 matlab/fastsum/fastsum_simple.m                    |  86 +++
 matlab/{nfft/nfftmex.m => fastsum/fastsum_trafo.m} |  10 +-
 .../nfftmex.m => fastsum/fastsum_trafo_direct.m}   |  10 +-
 matlab/fastsum/fastsummex.c                        | 619 +++++++++++++++++++++
 matlab/fastsum/test_fastsum.m                      |  94 ++++
 matlab/imex.h                                      |   6 +-
 matlab/infft_1D/README                             |  55 ++
 matlab/infft_1D/infft.m                            | 355 ++++++++++++
 matlab/infft_1D/simple_test.m                      |  40 ++
 matlab/malloc.c                                    |   5 +-
 matlab/nfct/Contents.m                             |  30 +
 matlab/{nfft => nfct}/FFTW_ESTIMATE.m              |   4 +-
 matlab/{nfft => nfct}/FFTW_MEASURE.m               |   4 +-
 matlab/{nfft => nfct}/FFT_OUT_OF_PLACE.m           |   4 +-
 matlab/{nfft => nfct}/FG_PSI.m                     |   4 +-
 matlab/nfct/Makefile.am                            |  44 ++
 matlab/{nfft => nfct}/PRE_FG_PSI.m                 |   4 +-
 matlab/{nfft => nfct}/PRE_FULL_PSI.m               |   4 +-
 matlab/{nnfft => nfct}/PRE_LIN_PSI.m               |   4 +-
 matlab/{nfft => nfct}/PRE_PHI_HUT.m                |   4 +-
 matlab/{nnfft => nfct}/PRE_PSI.m                   |   4 +-
 matlab/{nfft/ndft_trafo.m => nfct/ndct_adjoint.m}  |  10 +-
 matlab/{nfft/nfft_adjoint.m => nfct/ndct_trafo.m}  |  10 +-
 matlab/{nfft/nfft.m => nfct/nfct.m}                | 163 +++---
 matlab/{nfft/nfft_get_f.m => nfct/nfct_adjoint.m}  |  10 +-
 matlab/{nfft/nfft_set_x.m => nfct/nfct_finalize.m} |  10 +-
 matlab/{nfft/nfft_get_f.m => nfct/nfct_get_f.m}    |  10 +-
 .../{nfft/nfft_adjoint.m => nfct/nfct_get_f_hat.m} |  10 +-
 .../nfct_get_num_threads.m}                        |  10 +-
 matlab/{nfft/nfft_set_x.m => nfct/nfct_get_x.m}    |  10 +-
 .../{nfft/nfft_init_1d.m => nfct/nfct_init_1d.m}   |  10 +-
 matlab/{nfft/nfft_get_f.m => nfct/nfct_init_2d.m}  |  10 +-
 matlab/{nfft/nfft_get_f.m => nfct/nfct_init_3d.m}  |  10 +-
 .../nfft_init_guru.m => nfct/nfct_init_guru.m}     |  12 +-
 matlab/{nfft/nfft_set_f.m => nfct/nfct_set_f.m}    |  10 +-
 .../nfft_set_f_hat.m => nfct/nfct_set_f_hat.m}     |   8 +-
 matlab/{nfft/nfft_set_x.m => nfct/nfct_set_x.m}    |  10 +-
 matlab/{nfft/nfft_init_1d.m => nfct/nfct_trafo.m}  |  10 +-
 matlab/{nfft/nfftmex.c => nfct/nfctmex.c}          | 203 +++----
 matlab/{nnfft => nfct}/simple_test.m               |  66 +--
 matlab/{nfft/test_nfft1d.m => nfct/test_nfct1d.m}  |  31 +-
 matlab/{nfft/test_nfft2d.m => nfct/test_nfct2d.m}  |  32 +-
 matlab/{nfft/test_nfft3d.m => nfct/test_nfct3d.m}  |  34 +-
 matlab/nfft/FFTW_ESTIMATE.m                        |   4 +-
 matlab/nfft/FFTW_MEASURE.m                         |   4 +-
 matlab/nfft/FFT_OUT_OF_PLACE.m                     |   4 +-
 matlab/nfft/FG_PSI.m                               |   4 +-
 matlab/nfft/NFFT_OMP_BLOCKWISE_ADJOINT.m           |   4 +-
 matlab/nfft/PRE_FG_PSI.m                           |   4 +-
 matlab/nfft/PRE_FULL_PSI.m                         |   4 +-
 matlab/nfft/PRE_LIN_PSI.m                          |   4 +-
 matlab/nfft/PRE_PHI_HUT.m                          |   4 +-
 matlab/nfft/PRE_PSI.m                              |   4 +-
 matlab/nfft/ndft_adjoint.m                         |   4 +-
 matlab/nfft/ndft_trafo.m                           |   4 +-
 matlab/nfft/nfft.m                                 |   5 +-
 matlab/nfft/nfft_adjoint.m                         |   4 +-
 matlab/nfft/nfft_finalize.m                        |   4 +-
 matlab/nfft/nfft_get_f.m                           |   4 +-
 matlab/nfft/nfft_get_f_hat.m                       |   4 +-
 matlab/nfft/nfft_get_num_threads.m                 |   4 +-
 matlab/nfft/nfft_get_x.m                           |   4 +-
 matlab/nfft/nfft_init_1d.m                         |   4 +-
 matlab/nfft/nfft_init_2d.m                         |   4 +-
 matlab/nfft/nfft_init_3d.m                         |   4 +-
 matlab/nfft/nfft_init_guru.m                       |   4 +-
 matlab/nfft/nfft_precompute_psi.m                  |   4 +-
 matlab/nfft/nfft_set_f.m                           |   4 +-
 matlab/nfft/nfft_set_f_hat.m                       |   4 +-
 matlab/nfft/nfft_set_x.m                           |   4 +-
 matlab/nfft/nfft_trafo.m                           |   4 +-
 matlab/nfft/nfftmex.c                              |  58 +-
 matlab/nfft/nfftmex.m                              |   4 +-
 matlab/nfft/simple_test.m                          |  28 +-
 matlab/nfft/test_nfft1d.m                          |   2 +-
 matlab/nfft/test_nfft2d.m                          |   2 +-
 matlab/nfft/test_nfft3d.m                          |   2 +-
 matlab/nfsft/@f_hat/char.m                         |   4 +-
 matlab/nfsft/@f_hat/display.m                      |   4 +-
 matlab/nfsft/@f_hat/double.m                       |   4 +-
 matlab/nfsft/@f_hat/f_hat.m                        |   4 +-
 matlab/nfsft/@f_hat/get.m                          |   4 +-
 matlab/nfsft/@f_hat/minus.m                        |   4 +-
 matlab/nfsft/@f_hat/mtimes.m                       |   4 +-
 matlab/nfsft/@f_hat/mtimesr.m                      |   4 +-
 matlab/nfsft/@f_hat/norm.m                         |   4 +-
 matlab/nfsft/@f_hat/plus.m                         |   4 +-
 matlab/nfsft/@f_hat/subsasgn.m                     |   4 +-
 matlab/nfsft/@f_hat/subsref.m                      |   4 +-
 matlab/nfsft/NFSFT_NORMALIZED.m                    |   4 +-
 matlab/nfsft/NFSFT_NO_DIRECT_ALGORITHM.m           |   4 +-
 matlab/nfsft/NFSFT_NO_FAST_ALGORITHM.m             |   4 +-
 matlab/nfsft/NFSFT_PRESERVE_F_HAT.m                |   4 +-
 matlab/nfsft/NFSFT_USE_DPT.m                       |   4 +-
 matlab/nfsft/NFSFT_USE_NDFT.m                      |   4 +-
 matlab/nfsft/cc.m                                  |   4 +-
 matlab/nfsft/f_hat_index.m                         |   4 +-
 matlab/nfsft/gl.m                                  |   4 +-
 matlab/nfsft/ndsft_adjoint.m                       |   4 +-
 matlab/nfsft/ndsft_trafo.m                         |   4 +-
 matlab/nfsft/nfsft_adjoint.m                       |   4 +-
 matlab/nfsft/nfsft_finalize.m                      |   4 +-
 matlab/nfsft/nfsft_forget.m                        |   4 +-
 matlab/nfsft/nfsft_get_f.m                         |   4 +-
 matlab/nfsft/nfsft_get_f_hat.m                     |   4 +-
 matlab/nfsft/nfsft_get_f_hat_linear.m              |   4 +-
 matlab/nfsft/nfsft_get_num_threads.m               |   4 +-
 matlab/nfsft/nfsft_get_x.m                         |   4 +-
 matlab/nfsft/nfsft_init.m                          |   4 +-
 matlab/nfsft/nfsft_init_advanced.m                 |   4 +-
 matlab/nfsft/nfsft_init_guru.m                     |   4 +-
 matlab/nfsft/nfsft_precompute.m                    |   4 +-
 matlab/nfsft/nfsft_precompute_x.m                  |   4 +-
 matlab/nfsft/nfsft_set_f.m                         |   4 +-
 matlab/nfsft/nfsft_set_f_hat.m                     |   4 +-
 matlab/nfsft/nfsft_set_f_hat_linear.m              |   4 +-
 matlab/nfsft/nfsft_set_x.m                         |   4 +-
 matlab/nfsft/nfsft_trafo.m                         |   4 +-
 matlab/nfsft/nfsftmex.c                            |  71 ++-
 matlab/nfsft/nfsftmex.m                            |   6 +-
 matlab/nfsft/projection.m                          |   4 +-
 matlab/nfsft/simple_test.m                         |   4 +-
 matlab/nfsoft/Makefile.am                          |   3 +-
 matlab/nfsoft/NFSOFT_NORMALIZED.m                  |   2 +
 matlab/nfsoft/NFSOFT_REPRESENT.m                   |   4 +
 matlab/nfsoft/NFSOFT_USE_DPT.m                     |   3 +
 matlab/nfsoft/NFSOFT_USE_NDFT.m                    |   3 +
 matlab/nfsoft/nfsoft_adjoint.m                     |   3 +
 matlab/nfsoft/nfsoft_f_hat_size.m                  |   4 +
 matlab/nfsoft/nfsoft_finalize.m                    |   3 +
 matlab/nfsoft/nfsoft_get_f.m                       |   3 +
 matlab/nfsoft/nfsoft_get_f_hat.m                   |   3 +
 matlab/nfsoft/nfsoft_get_num_threads.m             |   2 +-
 matlab/nfsoft/nfsoft_index.m                       |   3 +
 matlab/nfsoft/nfsoft_init.m                        |  29 +
 matlab/nfsoft/nfsoft_precompute.m                  |   3 +
 matlab/nfsoft/nfsoft_set_f.m                       |   3 +
 matlab/nfsoft/nfsoft_set_f_hat.m                   |   3 +
 matlab/nfsoft/nfsoft_set_x.m                       |   6 +
 matlab/nfsoft/nfsoft_trafo.m                       |   3 +
 matlab/nfsoft/nfsoftmex.c                          | 279 ++++++++--
 matlab/nfsoft/test_nfsoft.m                        |  28 +
 matlab/nfst/Contents.m                             |  30 +
 matlab/{nfft => nfst}/FFTW_ESTIMATE.m              |   4 +-
 matlab/{nfft => nfst}/FFTW_MEASURE.m               |   4 +-
 matlab/{nfft => nfst}/FFT_OUT_OF_PLACE.m           |   4 +-
 matlab/{nfft => nfst}/FG_PSI.m                     |   4 +-
 matlab/nfst/Makefile.am                            |  44 ++
 matlab/{nfft => nfst}/PRE_FG_PSI.m                 |   4 +-
 matlab/{nfft => nfst}/PRE_FULL_PSI.m               |   4 +-
 matlab/{nnfft => nfst}/PRE_LIN_PSI.m               |   4 +-
 matlab/{nfft => nfst}/PRE_PHI_HUT.m                |   4 +-
 matlab/{nnfft => nfst}/PRE_PSI.m                   |   4 +-
 matlab/{nfft/ndft_trafo.m => nfst/ndst_adjoint.m}  |  10 +-
 matlab/{nfft/nfft_adjoint.m => nfst/ndst_trafo.m}  |  10 +-
 matlab/{nfft/nfft.m => nfst/nfst.m}                | 177 +++---
 matlab/{nfft/nfft_get_f.m => nfst/nfst_adjoint.m}  |  10 +-
 matlab/{nfft/nfft_set_x.m => nfst/nfst_finalize.m} |  10 +-
 matlab/{nfft/nfft_get_f.m => nfst/nfst_get_f.m}    |  10 +-
 .../{nfft/nfft_adjoint.m => nfst/nfst_get_f_hat.m} |  10 +-
 .../nfst_get_num_threads.m}                        |  10 +-
 matlab/{nfft/nfft_set_x.m => nfst/nfst_get_x.m}    |  10 +-
 .../{nfft/nfft_init_1d.m => nfst/nfst_init_1d.m}   |  10 +-
 matlab/{nfft/nfft_get_f.m => nfst/nfst_init_2d.m}  |  10 +-
 matlab/{nfft/nfft_get_f.m => nfst/nfst_init_3d.m}  |  10 +-
 .../nfft_init_guru.m => nfst/nfst_init_guru.m}     |  12 +-
 matlab/{nfft/nfft_set_f.m => nfst/nfst_set_f.m}    |  10 +-
 .../{nfft/nfft_adjoint.m => nfst/nfst_set_f_hat.m} |  10 +-
 matlab/{nfft/nfft_set_x.m => nfst/nfst_set_x.m}    |  10 +-
 matlab/{nfft/nfft_set_f.m => nfst/nfst_trafo.m}    |  10 +-
 matlab/{nfft/nfftmex.c => nfst/nfstmex.c}          | 201 +++----
 matlab/{nnfft => nfst}/simple_test.m               |  66 +--
 matlab/{nfft/test_nfft1d.m => nfst/test_nfst1d.m}  |  37 +-
 matlab/{nfft/test_nfft2d.m => nfst/test_nfst2d.m}  |  38 +-
 matlab/{nfft/test_nfft3d.m => nfst/test_nfst3d.m}  |  40 +-
 matlab/nnfft/PRE_FULL_PSI.m                        |   4 +-
 matlab/nnfft/PRE_LIN_PSI.m                         |   4 +-
 matlab/nnfft/PRE_PHI_HUT.m                         |   4 +-
 matlab/nnfft/PRE_PSI.m                             |   4 +-
 matlab/nnfft/nnfft.m                               |   4 +-
 matlab/nnfft/nnfft_display.m                       |   4 +-
 matlab/nnfft/nnfft_finalize.m                      |   4 +-
 matlab/nnfft/nnfft_get_f.m                         |   4 +-
 matlab/nnfft/nnfft_get_f_hat.m                     |   4 +-
 matlab/nnfft/nnfft_get_num_threads.m               |   4 +-
 matlab/nnfft/nnfft_get_x.m                         |   4 +-
 matlab/nnfft/nnfft_init.m                          |   4 +-
 matlab/nnfft/nnfft_init_1d.m                       |   4 +-
 matlab/nnfft/nnfft_init_2d.m                       |   4 +-
 matlab/nnfft/nnfft_init_3d.m                       |   4 +-
 matlab/nnfft/nnfft_init_guru.m                     |   4 +-
 matlab/nnfft/nnfft_precompute_psi.m                |   4 +-
 matlab/nnfft/nnfft_set_f.m                         |   4 +-
 matlab/nnfft/nnfft_set_f_hat.m                     |   4 +-
 matlab/nnfft/nnfft_set_v.m                         |   4 +-
 matlab/nnfft/nnfft_set_x.m                         |   4 +-
 matlab/nnfft/nnfft_trafo.m                         |   4 +-
 matlab/nnfft/nnfft_trafo_direct.m                  |   4 +-
 matlab/nnfft/nnfftmex.c                            |  56 +-
 matlab/nnfft/nnfftmex.m                            |   4 +-
 matlab/nnfft/simple_test.m                         |   4 +-
 matlab/nnfft/test_nnfft1d.m                        |   2 +-
 matlab/nnfft/test_nnfft2d.m                        |   2 +-
 matlab/nnfft/test_nnfft2d_N215.m                   |   2 +-
 support/Portfile                                   |   6 +-
 support/copyright.txt                              |   2 +-
 support/copyright_m4.txt                           |   2 +-
 support/copyright_matlab.txt                       |   2 +-
 support/copyright_matlab_single_line.txt           |   2 +-
 support/fpt.dox                                    |  12 +-
 support/mri.dox                                    |   2 +-
 support/nfct.dox                                   |   2 +-
 support/nfft.dox                                   |  14 +-
 support/nfsft.dox                                  |   6 +-
 support/nfsoft.dox                                 |   6 +-
 support/nfst.dox                                   |   2 +-
 support/nnfft.dox                                  |   2 +-
 support/nsfft.dox                                  |  10 +-
 support/solver.dox                                 |   2 +-
 tests/Makefile.am                                  |   2 +-
 tests/bessel.c                                     |   8 +-
 tests/bessel.h                                     |   2 +-
 tests/bspline.c                                    |   8 +-
 tests/bspline.h                                    |   2 +-
 tests/check.c                                      |  21 +-
 tests/check_nfsft.c                                |   2 +-
 tests/nfct.c                                       |   6 +-
 tests/nfct.h                                       |   2 +-
 tests/nfft.c                                       |   8 +-
 tests/nfft.h                                       |   2 +-
 tests/nfst.c                                       |   6 +-
 tests/nfst.h                                       |   2 +-
 tests/{version.c => reflect.c}                     |  15 +-
 tests/{bessel.h => reflect.h}                      |   5 +-
 tests/util.c                                       | 153 +++++
 tests/{version.h => util.h}                        |   5 +-
 425 files changed, 4573 insertions(+), 1631 deletions(-)

diff --git a/.gitignore b/.gitignore
index 511b63b..34c7f52 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,6 +19,8 @@
 *.so
 *.so.*
 *.dylib
+*.mex
+*.mexw64
 
 # Executables
 *.exe
@@ -34,6 +36,9 @@
 # Log files
 *.log
 
+# Autosave files
+*.asv
+
 # Other
 .cproject
 .project
@@ -49,6 +54,7 @@ m4/lt~obsolete.m4
 autom4te.cache/*
 config/*
 include/config.h.in
+include/config.h.in~
 configure
 **/.deps/*
 Makefile
@@ -113,6 +119,12 @@ examples/nsfft/nsfft_test
 examples/nsfft/simple_test
 examples/solver/glacier
 examples/solver/simple_test
+doc/html
+doc/latex
+doc/doxygen_sqlite3.db
+doc/nfft.pdf
+doc/nfft.tag
 tests/checkall
 *.trs
 CUnitAutomated-Results.xml
+CUnitAutomated_threads-Results.xml
diff --git a/3rdparty/cstripack/cstripack.c b/3rdparty/cstripack/cstripack.c
index 9b234c3..b940900 100644
--- a/3rdparty/cstripack/cstripack.c
+++ b/3rdparty/cstripack/cstripack.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/3rdparty/cstripack/cstripack.h b/3rdparty/cstripack/cstripack.h
index 9c2fdd5..d0a50bc 100644
--- a/3rdparty/cstripack/cstripack.h
+++ b/3rdparty/cstripack/cstripack.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/ChangeLog b/ChangeLog
index edaf744..d82f6fb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,22 @@
 This file contains the version history for NFFT 3.x.x. 
 
+Changes in version 3.4.0:
+
+    Bugfixes
+    - Use nfft_free in nfsoft.c.
+    - Replace %td in format strings with macro __D__ for Windows compatibility.
+    - Support fftw3 compatible libraries that do not require -l linker flags, 
+        e.g. Intel MKL.
+
+    Enhancements
+    - #29 Calculate machine epsilon in configure and prefer over definition in 
+        float.h.
+    - #30 Support cross-compiling (thanks GitHub user xantares).
+    - #35 Add API to query window function name.
+    - Use more efficient method to find log base 2 of an integer.
+    - #39 Add Matlab mex interface for fastsum application.
+    - #40 Add Matlab mex interface for NFCT and NFST modules.
+
 Changes in version 3.3.2:
 
     Bugfixes
diff --git a/Makefile.am b/Makefile.am
index 893659c..bb66d5d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -84,7 +84,11 @@ uninstall-hook:
 	rm -Rf $(DESTDIR)$(docdir)
 
 clean-local:
+	rm -f $(abs_top_builddir)/doc/doxygen_sqlite3.db
+	rm -f $(abs_top_builddir)/doc/nfft.pdf
+	rm -f $(abs_top_builddir)/doc/nfft.tag
 	rm -Rf $(abs_top_builddir)/doc/html
+	rm -Rf $(abs_top_builddir)/doc/latex
 
 dist-hook: doc
 	rm -f @DX_DOCDIR@/@PACKAGE at .tag
@@ -98,4 +102,4 @@ doc: doxygen-doc
 # Flags to be passed to aclocal.
 ACLOCAL_AMFLAGS = -I m4
 
-AM_DISTCHECK_CONFIGURE_FLAGS = --enable-all
\ No newline at end of file
+AM_DISTCHECK_CONFIGURE_FLAGS = --enable-all
diff --git a/README.md b/README.md
index 37327cf..3193ebb 100644
--- a/README.md
+++ b/README.md
@@ -94,7 +94,7 @@ you are using NFFT for!
 
 Legal Information & Credits
 ---------------------------
-Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
 This software was written by Jens Keiner, Stefan Kunis and Daniel Potts.
 It was developed at the Mathematical Institute, University of
@@ -145,6 +145,7 @@ Makefile.in        | Makefile template generated from Makefile.am, processed by
 matlab (dir)       | Matlab MEX interfaces for nfft, nfsft, nfsoft, nfft
 missing            | Used by configure script
 NEWS               | New and noteworthy
-README             | This file
+README             | This file.
+README.md          | This file
 tests (dir)        | CUnit tests
 TODO               | Work to be done
diff --git a/applications/doxygen.c b/applications/doxygen.c
index 066a664..5eae18a 100644
--- a/applications/doxygen.c
+++ b/applications/doxygen.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/fastgauss/fastgauss.c.in b/applications/fastgauss/fastgauss.c.in
index 1ccdca8..bf1237d 100644
--- a/applications/fastgauss/fastgauss.c.in
+++ b/applications/fastgauss/fastgauss.c.in
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/fastgauss/levelplots.m b/applications/fastgauss/levelplots.m
index 294a0b1..f5412be 100644
--- a/applications/fastgauss/levelplots.m
+++ b/applications/fastgauss/levelplots.m
@@ -1,4 +1,4 @@
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/fastgauss/output_error.m b/applications/fastgauss/output_error.m
index c2f0ac4..41025fb 100644
--- a/applications/fastgauss/output_error.m
+++ b/applications/fastgauss/output_error.m
@@ -1,4 +1,4 @@
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/fastgauss/output_error_p.m b/applications/fastgauss/output_error_p.m
index e59b887..8fa9830 100644
--- a/applications/fastgauss/output_error_p.m
+++ b/applications/fastgauss/output_error_p.m
@@ -1,4 +1,4 @@
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/fastgauss/show_results.m b/applications/fastgauss/show_results.m
index 9471034..e994c31 100644
--- a/applications/fastgauss/show_results.m
+++ b/applications/fastgauss/show_results.m
@@ -1,4 +1,4 @@
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/fastsum/Makefile.am b/applications/fastsum/Makefile.am
index b8b009b..51c1cb9 100644
--- a/applications/fastsum/Makefile.am
+++ b/applications/fastsum/Makefile.am
@@ -40,7 +40,11 @@ fastsum_test_SOURCES = fastsum_test.c
 fastsum_test_LDADD = libfastsum.la libkernels.la $(top_builddir)/libnfft3 at PREC_SUFFIX@.la
 
 fastsum_matlab_SOURCES = fastsum_matlab.c
+if HAVE_THREADS
+fastsum_matlab_LDADD = libfastsum_threads.la libkernels.la $(top_builddir)/libnfft3 at PREC_SUFFIX@_threads.la
+else
 fastsum_matlab_LDADD = libfastsum.la libkernels.la $(top_builddir)/libnfft3 at PREC_SUFFIX@.la
+endif
 
 if HAVE_THREADS
   fastsum_test_threads_SOURCES = fastsum_test.c
diff --git a/applications/fastsum/fastsum.c b/applications/fastsum/fastsum.c
index dbd23d1..7a993a7 100644
--- a/applications/fastsum/fastsum.c
+++ b/applications/fastsum/fastsum.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
@@ -378,7 +378,7 @@ static C kubintkern1(const R x, const C *Add, const int Ad, const R a)
 }
 
 /** quicksort algorithm for source knots and associated coefficients */
-static void quicksort(int d, int t, R *x, C *alpha, int N)
+static void quicksort(int d, int t, R *x, C *alpha, int *permutation_x_alpha, int N)
 {
   int lpos = 0;
   int rpos = N - 1;
@@ -388,6 +388,7 @@ static void quicksort(int d, int t, R *x, C *alpha, int N)
   int k;
   R temp1;
   C temp2;
+  int temp_int;
 
   while (lpos <= rpos)
   {
@@ -406,15 +407,22 @@ static void quicksort(int d, int t, R *x, C *alpha, int N)
       temp2 = alpha[lpos];
       alpha[lpos] = alpha[rpos];
       alpha[rpos] = temp2;
-
+      
+      if (permutation_x_alpha)   /** store the permutation of x */
+      {
+        temp_int = permutation_x_alpha[lpos];
+        permutation_x_alpha[lpos] = permutation_x_alpha[rpos];
+        permutation_x_alpha[rpos] = temp_int;      
+      }
+      
       lpos++;
       rpos--;
     }
   }
   if (0 < rpos)
-    quicksort(d, t, x, alpha, rpos + 1);
+    quicksort(d, t, x, alpha, permutation_x_alpha, rpos + 1);
   if (lpos < N - 1)
-    quicksort(d, t, x + lpos * d, alpha + lpos, N - lpos);
+    quicksort(d, t, x + lpos * d, alpha + lpos, permutation_x_alpha ? permutation_x_alpha + lpos : NULL, N - lpos);
 }
 
 /** initialize box-based search data structures */
@@ -582,22 +590,22 @@ static C SearchBox(R *y, fastsum_plan *ths)
   }
   else
   {
-    exit(EXIT_FAILURE);
+    return 0.0/0.0; //exit(EXIT_FAILURE);
   }
   return val;
 }
 
 /** recursive sort of source knots dimension by dimension to get tree structure */
-static void BuildTree(int d, int t, R *x, C *alpha, int N)
+static void BuildTree(int d, int t, R *x, C *alpha, int *permutation_x_alpha, int N)
 {
   if (N > 1)
   {
     int m = N / 2;
 
-    quicksort(d, t, x, alpha, N);
+    quicksort(d, t, x, alpha, permutation_x_alpha, N);
 
-    BuildTree(d, (t + 1) % d, x, alpha, m);
-    BuildTree(d, (t + 1) % d, x + (m + 1) * d, alpha + (m + 1), N - m - 1);
+    BuildTree(d, (t + 1) % d, x, alpha, permutation_x_alpha, m);
+    BuildTree(d, (t + 1) % d, x + (m + 1) * d, alpha + (m + 1), permutation_x_alpha ? permutation_x_alpha + (m + 1) : NULL, N - m - 1);
   }
 }
 
@@ -679,47 +687,106 @@ static C SearchTree(const int d, const int t, const R *x, const C *alpha,
               }
           }
           result += SearchTree(d, (t + 1) % d, x + (m + 1) * d, alpha + (m + 1), xmin,
-                  xmax, N - m - 1, k, param, Ad, Add, p, flags)
-                + SearchTree(d, (t + 1) % d, x, alpha, xmin, xmax, m, k, param, Ad, Add,
+                  xmax, N - m - 1, k, param, Ad, Add, p, flags);
+          result += SearchTree(d, (t + 1) % d, x, alpha, xmin, xmax, m, k, param, Ad, Add,
                         p, flags);
           return result;
       }
   }
 }
 
-/** initialization of fastsum plan */
-void fastsum_init_guru(fastsum_plan *ths, int d, int N_total, int M_total,
-    kernel k, R *param, unsigned flags, int nn, int m, int p, R eps_I, R eps_B)
+static void fastsum_precompute_kernel(fastsum_plan *ths)
 {
-  int t;
-  int N[d], n[d];
+  int j, k, t;
+  INT N[ths->d];
   int n_total;
-  unsigned sort_flags_trafo = 0U;
-  unsigned sort_flags_adjoint = 0U;
-#ifdef _OPENMP
-  int nthreads = NFFT(get_num_threads)();
+#ifdef MEASURE_TIME
+  ticks t0, t1;
 #endif
 
-  if (d > 1)
+  ths->MEASURE_TIME_t[0] = K(0.0);
+
+#ifdef MEASURE_TIME
+  t0 = getticks();
+#endif
+  /** precompute spline values for near field*/
+  if (!(ths->flags & EXACT_NEARFIELD))
   {
-    sort_flags_trafo = NFFT_SORT_NODES;
+    if (ths->d == 1)
 #ifdef _OPENMP
-    sort_flags_adjoint = NFFT_SORT_NODES | NFFT_OMP_BLOCKWISE_ADJOINT;
-#else
-    sort_flags_adjoint = NFFT_SORT_NODES;
+      #pragma omp parallel for default(shared) private(k)
 #endif
+      for (k = -ths->Ad / 2 - 2; k <= ths->Ad / 2 + 2; k++)
+        ths->Add[k + ths->Ad / 2 + 2] = regkern1(ths->k,
+            ths->eps_I * (R) k / (R)(ths->Ad) * K(2.0), ths->p, ths->kernel_param,
+            ths->eps_I, ths->eps_B);
+    else
+#ifdef _OPENMP
+      #pragma omp parallel for default(shared) private(k)
+#endif
+      for (k = 0; k <= ths->Ad + 2; k++)
+        ths->Add[k] = regkern3(ths->k, ths->eps_I * (R) k / (R)(ths->Ad), ths->p,
+            ths->kernel_param, ths->eps_I, ths->eps_B);
   }
+#ifdef MEASURE_TIME
+  t1 = getticks();
+  ths->MEASURE_TIME_t[0] += NFFT(elapsed_seconds)(t1,t0);
+#endif
 
-  ths->d = d;
+#ifdef MEASURE_TIME
+  t0 = getticks();
+#endif
+  /** precompute Fourier coefficients of regularised kernel*/
+  n_total = 1;
+  for (t = 0; t < ths->d; t++)
+    n_total *= ths->n;
 
-  ths->N_total = N_total;
-  ths->M_total = M_total;
+#ifdef _OPENMP
+  #pragma omp parallel for default(shared) private(j,k,t)
+#endif
+  for (j = 0; j < n_total; j++)
+  {
+    if (ths->d == 1)
+      ths->b[j] = regkern1(ths->k, (R) - (j / (R)(ths->n) - K(0.5)), ths->p,
+          ths->kernel_param, ths->eps_I, ths->eps_B) / (R)(n_total);
+    else
+    {
+      k = j;
+      ths->b[j] = K(0.0);
+      for (t = 0; t < ths->d; t++)
+      {
+        ths->b[j] += ((R) (k % (ths->n)) / (R)(ths->n) - K(0.5))
+            * ((R) (k % (ths->n)) / (R)(ths->n) - K(0.5));
+        k = k / (ths->n);
+      }
+      ths->b[j] = regkern3(ths->k, SQRT(CREAL(ths->b[j])), ths->p, ths->kernel_param,
+          ths->eps_I, ths->eps_B) / (R)(n_total);
+    }
+  }
 
-  ths->x = (R *) NFFT(malloc)((size_t)(d * N_total) * (sizeof(R)));
-  ths->alpha = (C *) NFFT(malloc)((size_t)(N_total) * (sizeof(C)));
+  for (t = 0; t < ths->d; t++)
+    N[t] = ths->n;
 
-  ths->y = (R *) NFFT(malloc)((size_t)(d * M_total) * (sizeof(R)));
-  ths->f = (C *) NFFT(malloc)((size_t)(M_total) * (sizeof(C)));
+  NFFT(fftshift_complex)(ths->b, (int)(ths->d), N);
+  FFTW(execute)(ths->fft_plan);
+  NFFT(fftshift_complex)(ths->b, (int)(ths->d), N);
+#ifdef MEASURE_TIME
+  t1 = getticks();
+  ths->MEASURE_TIME_t[0] += nfft_elapsed_seconds(t1,t0);
+#endif
+}
+
+void fastsum_init_guru_kernel(fastsum_plan *ths, int d, kernel k, R *param,
+    unsigned flags, int nn, int p, R eps_I, R eps_B)
+{
+  int t;
+  int N[d];
+  int n_total;
+#ifdef _OPENMP
+  int nthreads = NFFT(get_num_threads)();
+#endif
+
+  ths->d = d;
 
   ths->k = k;
   ths->kernel_param = param;
@@ -788,23 +855,11 @@ void fastsum_init_guru(fastsum_plan *ths, int d, int N_total, int M_total,
     }
   }
 
-  /** init d-dimensional NFFT plan */
   ths->n = nn;
   for (t = 0; t < d; t++)
   {
     N[t] = nn;
-    n[t] = 2 * nn;
   }
-  NFFT(init_guru)(&(ths->mv1), d, N, N_total, n, m,
-      sort_flags_adjoint |
-      PRE_PHI_HUT | PRE_PSI | MALLOC_X | MALLOC_F_HAT | MALLOC_F | FFTW_INIT
-          | FFT_OUT_OF_PLACE,
-      FFTW_MEASURE | FFTW_DESTROY_INPUT);
-  NFFT(init_guru)(&(ths->mv2), d, N, M_total, n, m,
-      sort_flags_trafo |
-      PRE_PHI_HUT | PRE_PSI | MALLOC_X | MALLOC_F_HAT | MALLOC_F | FFTW_INIT
-          | FFT_OUT_OF_PLACE,
-      FFTW_MEASURE | FFTW_DESTROY_INPUT);
 
   /** init d-dimensional FFTW plan */
   n_total = 1;
@@ -812,6 +867,7 @@ void fastsum_init_guru(fastsum_plan *ths, int d, int N_total, int M_total,
     n_total *= nn;
 
   ths->b = (C*) NFFT(malloc)((size_t)(n_total) * sizeof(C));
+  ths->f_hat = (C*) NFFT(malloc)((size_t)(n_total) * sizeof(C));
 #ifdef _OPENMP
   #pragma omp critical (nfft_omp_critical_fftw_plan)
   {
@@ -825,6 +881,47 @@ void fastsum_init_guru(fastsum_plan *ths, int d, int N_total, int M_total,
 }
 #endif
 
+  fastsum_precompute_kernel(ths);
+}
+
+void fastsum_init_guru_source_nodes(fastsum_plan *ths, int N_total, int nn_oversampled, int m)
+{
+  int t;
+  int N[ths->d], n[ths->d];
+  unsigned sort_flags_adjoint = 0U;
+
+  if (ths->d > 1)
+  {
+#ifdef _OPENMP
+    sort_flags_adjoint = NFFT_SORT_NODES | NFFT_OMP_BLOCKWISE_ADJOINT;
+#else
+    sort_flags_adjoint = NFFT_SORT_NODES;
+#endif
+  }
+
+  ths->N_total = N_total;
+
+  ths->x = (R *) NFFT(malloc)((size_t)(ths->d * N_total) * (sizeof(R)));
+  ths->alpha = (C *) NFFT(malloc)((size_t)(N_total) * (sizeof(C)));
+
+  /** init d-dimensional NFFT plan */
+  for (t = 0; t < ths->d; t++)
+  {
+    N[t] = ths->n;
+    n[t] = nn_oversampled;
+  }
+
+  NFFT(init_guru)(&(ths->mv1), ths->d, N, N_total, n, m,
+      sort_flags_adjoint |
+      PRE_PHI_HUT | PRE_PSI | /*MALLOC_X | MALLOC_F_HAT | MALLOC_F |*/ FFTW_INIT
+          | FFT_OUT_OF_PLACE,
+      FFTW_ESTIMATE | FFTW_DESTROY_INPUT);
+  ths->mv1.x = ths->x;
+  ths->mv1.f = ths->alpha;
+  ths->mv1.f_hat = ths->f_hat;
+  
+  ths->permutation_x_alpha = NULL;
+
   if (ths->flags & NEARFIELD_BOXES)
   {
     ths->box_count_per_dim = (int)(LRINT(FLOOR((K(0.5) - ths->eps_B) / ths->eps_I))) + 1;
@@ -838,22 +935,93 @@ void fastsum_init_guru(fastsum_plan *ths, int d, int N_total, int M_total,
 
     ths->box_x = (R *) NFFT(malloc)((size_t)(ths->d * ths->N_total) * sizeof(R));
   }
+  else
+  {
+    if (ths->flags & STORE_PERMUTATION_X_ALPHA)
+    {
+      ths->permutation_x_alpha = (int *) NFFT(malloc)((size_t)(ths->N_total) * (sizeof(int)));
+      for (int i=0; i<ths->N_total; i++)
+        ths->permutation_x_alpha[i] = i;
+    }
+  }
+}
+
+void fastsum_init_guru_target_nodes(fastsum_plan *ths, int M_total, int nn_oversampled, int m)
+{
+  int t;
+  int N[ths->d], n[ths->d];
+  unsigned sort_flags_trafo = 0U;
+
+  if (ths->d > 1)
+    sort_flags_trafo = NFFT_SORT_NODES;
+
+  ths->M_total = M_total;
+
+  ths->y = (R *) NFFT(malloc)((size_t)(ths->d * M_total) * (sizeof(R)));
+  ths->f = (C *) NFFT(malloc)((size_t)(M_total) * (sizeof(C)));
+
+  /** init d-dimensional NFFT plan */
+  for (t = 0; t < ths->d; t++)
+  {
+    N[t] = ths->n;
+    n[t] = nn_oversampled;
+  }
+
+  NFFT(init_guru)(&(ths->mv2), ths->d, N, M_total, n, m,
+      sort_flags_trafo |
+      PRE_PHI_HUT | PRE_PSI | /*MALLOC_X | MALLOC_F_HAT | MALLOC_F |*/ FFTW_INIT
+          | FFT_OUT_OF_PLACE,
+      FFTW_ESTIMATE | FFTW_DESTROY_INPUT);
+  ths->mv2.x = ths->y;
+  ths->mv2.f = ths->f;
+  ths->mv2.f_hat = ths->f_hat;
+}
+
+/** initialization of fastsum plan */
+void fastsum_init_guru(fastsum_plan *ths, int d, int N_total, int M_total,
+    kernel k, R *param, unsigned flags, int nn, int m, int p, R eps_I, R eps_B)
+{
+  fastsum_init_guru_kernel(ths, d, k, param, flags, nn, p, eps_I, eps_B);
+  fastsum_init_guru_source_nodes(ths, N_total, 2*nn, m);
+  fastsum_init_guru_target_nodes(ths, M_total, 2*nn, m);
 }
 
 /** finalization of fastsum plan */
-void fastsum_finalize(fastsum_plan *ths)
+void fastsum_finalize_source_nodes(fastsum_plan *ths)
 {
   NFFT(free)(ths->x);
   NFFT(free)(ths->alpha);
+
+  NFFT(finalize)(&(ths->mv1));
+
+  if (ths->flags & NEARFIELD_BOXES)
+  {
+    NFFT(free)(ths->box_offset);
+    NFFT(free)(ths->box_alpha);
+    NFFT(free)(ths->box_x);
+  }
+  else
+  {
+    if (ths->flags & STORE_PERMUTATION_X_ALPHA)
+      NFFT(free)(ths->permutation_x_alpha);
+  }
+}
+
+/** finalization of fastsum plan */
+void fastsum_finalize_target_nodes(fastsum_plan *ths)
+{
   NFFT(free)(ths->y);
   NFFT(free)(ths->f);
 
+  NFFT(finalize)(&(ths->mv2));
+}
+
+/** finalization of fastsum plan */
+void fastsum_finalize_kernel(fastsum_plan *ths)
+{
   if (!(ths->flags & EXACT_NEARFIELD))
     NFFT(free)(ths->Add);
 
-  NFFT(finalize)(&(ths->mv1));
-  NFFT(finalize)(&(ths->mv2));
-
 #ifdef _OPENMP
   #pragma omp critical (nfft_omp_critical_fftw_plan)
   {
@@ -864,13 +1032,15 @@ void fastsum_finalize(fastsum_plan *ths)
 #endif
 
   NFFT(free)(ths->b);
+  NFFT(free)(ths->f_hat);
+}
 
-  if (ths->flags & NEARFIELD_BOXES)
-  {
-    NFFT(free)(ths->box_offset);
-    NFFT(free)(ths->box_alpha);
-    NFFT(free)(ths->box_x);
-  }
+/** finalization of fastsum plan */
+void fastsum_finalize(fastsum_plan *ths)
+{
+  fastsum_finalize_target_nodes(ths);
+  fastsum_finalize_source_nodes(ths);
+  fastsum_finalize_kernel(ths);
 }
 
 /** direct computation of sums */
@@ -904,17 +1074,13 @@ void fastsum_exact(fastsum_plan *ths)
 }
 
 /** precomputation for fastsum */
-void fastsum_precompute(fastsum_plan *ths)
+void fastsum_precompute_source_nodes(fastsum_plan *ths)
 {
-  int j, k, t;
-  int n_total;
 #ifdef MEASURE_TIME
   ticks t0, t1;
 #endif
 
-  ths->MEASURE_TIME_t[0] = K(0.0);
   ths->MEASURE_TIME_t[1] = K(0.0);
-  ths->MEASURE_TIME_t[2] = K(0.0);
   ths->MEASURE_TIME_t[3] = K(0.0);
 
 #ifdef MEASURE_TIME
@@ -928,7 +1094,8 @@ void fastsum_precompute(fastsum_plan *ths)
   else
   {
     /** sort source knots */
-    BuildTree(ths->d, 0, ths->x, ths->alpha, ths->N_total);
+	
+    BuildTree(ths->d, 0, ths->x, ths->alpha, ths->permutation_x_alpha, ths->N_total);
   }
 
 #ifdef MEASURE_TIME
@@ -939,37 +1106,10 @@ void fastsum_precompute(fastsum_plan *ths)
 #ifdef MEASURE_TIME
   t0 = getticks();
 #endif
-  /** precompute spline values for near field*/
-  if (!(ths->flags & EXACT_NEARFIELD))
-  {
-    if (ths->d == 1)
-#ifdef _OPENMP
-      #pragma omp parallel for default(shared) private(k)
-#endif
-      for (k = -ths->Ad / 2 - 2; k <= ths->Ad / 2 + 2; k++)
-        ths->Add[k + ths->Ad / 2 + 2] = regkern1(ths->k,
-            ths->eps_I * (R) k / (R)(ths->Ad) * K(2.0), ths->p, ths->kernel_param,
-            ths->eps_I, ths->eps_B);
-    else
-#ifdef _OPENMP
-      #pragma omp parallel for default(shared) private(k)
-#endif
-      for (k = 0; k <= ths->Ad + 2; k++)
-        ths->Add[k] = regkern3(ths->k, ths->eps_I * (R) k / (R)(ths->Ad), ths->p,
-            ths->kernel_param, ths->eps_I, ths->eps_B);
-  }
-#ifdef MEASURE_TIME
-  t1 = getticks();
-  ths->MEASURE_TIME_t[0] += NFFT(elapsed_seconds)(t1,t0);
-#endif
-
-#ifdef MEASURE_TIME
-  t0 = getticks();
-#endif
   /** init NFFT plan for transposed transform in first step*/
-  for (k = 0; k < ths->mv1.M_total; k++)
-    for (t = 0; t < ths->mv1.d; t++)
-      ths->mv1.x[ths->mv1.d * k + t] = -ths->x[ths->mv1.d * k + t]; /* note the factor -1 for transposed transform instead of adjoint*/
+//  for (k = 0; k < ths->mv1.M_total; k++)
+//    for (t = 0; t < ths->mv1.d; t++)
+//      ths->mv1.x[ths->mv1.d * k + t] = -ths->x[ths->mv1.d * k + t]; /* note the factor -1 for transposed transform instead of adjoint*/
 
   /** precompute psi, the entries of the matrix B */
   if (ths->mv1.flags & PRE_LIN_PSI)
@@ -985,17 +1125,27 @@ void fastsum_precompute(fastsum_plan *ths)
   ths->MEASURE_TIME_t[1] += nfft_elapsed_seconds(t1,t0);
 #endif
 
-  /** init Fourier coefficients */
-  for (k = 0; k < ths->mv1.M_total; k++)
-    ths->mv1.f[k] = ths->alpha[k];
+//  /** init Fourier coefficients */
+//  for (k = 0; k < ths->mv1.M_total; k++)
+//    ths->mv1.f[k] = ths->alpha[k];
+}
+
+/** precomputation for fastsum */
+void fastsum_precompute_target_nodes(fastsum_plan *ths)
+{
+#ifdef MEASURE_TIME
+  ticks t0, t1;
+#endif
+
+  ths->MEASURE_TIME_t[2] = K(0.0);
 
 #ifdef MEASURE_TIME
   t0 = getticks();
 #endif
   /** init NFFT plan for transform in third step*/
-  for (j = 0; j < ths->mv2.M_total; j++)
-    for (t = 0; t < ths->mv2.d; t++)
-      ths->mv2.x[ths->mv2.d * j + t] = -ths->y[ths->mv2.d * j + t]; /* note the factor -1 for conjugated transform instead of standard*/
+//  for (j = 0; j < ths->mv2.M_total; j++)
+//    for (t = 0; t < ths->mv2.d; t++)
+//      ths->mv2.x[ths->mv2.d * j + t] = -ths->y[ths->mv2.d * j + t]; /* note the factor -1 for conjugated transform instead of standard*/
 
   /** precompute psi, the entries of the matrix B */
   if (ths->mv2.flags & PRE_LIN_PSI)
@@ -1010,45 +1160,13 @@ void fastsum_precompute(fastsum_plan *ths)
   t1 = getticks();
   ths->MEASURE_TIME_t[2] += NFFT(elapsed_seconds)(t1,t0);
 #endif
+}
 
-#ifdef MEASURE_TIME
-  t0 = getticks();
-#endif
-  /** precompute Fourier coefficients of regularised kernel*/
-  n_total = 1;
-  for (t = 0; t < ths->d; t++)
-    n_total *= ths->n;
-
-#ifdef _OPENMP
-  #pragma omp parallel for default(shared) private(j,k,t)
-#endif
-  for (j = 0; j < n_total; j++)
-  {
-    if (ths->d == 1)
-      ths->b[j] = regkern1(ths->k, (R) j / (R)(ths->n) - K(0.5), ths->p,
-          ths->kernel_param, ths->eps_I, ths->eps_B) / (R)(n_total);
-    else
-    {
-      k = j;
-      ths->b[j] = K(0.0);
-      for (t = 0; t < ths->d; t++)
-      {
-        ths->b[j] += ((R) (k % (ths->n)) / (R)(ths->n) - K(0.5))
-            * ((R) (k % (ths->n)) / (R)(ths->n) - K(0.5));
-        k = k / (ths->n);
-      }
-      ths->b[j] = regkern3(ths->k, SQRT(CREAL(ths->b[j])), ths->p, ths->kernel_param,
-          ths->eps_I, ths->eps_B) / (R)(n_total);
-    }
-  }
-
-  NFFT(fftshift_complex)(ths->b, (int)(ths->mv1.d), ths->mv1.N);
-  FFTW(execute)(ths->fft_plan);
-  NFFT(fftshift_complex)(ths->b, (int)(ths->mv1.d), ths->mv1.N);
-#ifdef MEASURE_TIME
-  t1 = getticks();
-  ths->MEASURE_TIME_t[0] += nfft_elapsed_seconds(t1,t0);
-#endif
+/** precomputation for fastsum */
+void fastsum_precompute(fastsum_plan *ths)
+{
+  fastsum_precompute_source_nodes(ths);
+  fastsum_precompute_target_nodes(ths);
 }
 
 /** fast NFFT-based summation */
diff --git a/applications/fastsum/fastsum.h b/applications/fastsum/fastsum.h
index 1b9d3c0..5d1cea6 100644
--- a/applications/fastsum/fastsum.h
+++ b/applications/fastsum/fastsum.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
@@ -31,6 +31,12 @@
  * \defgroup applications_fastsum Fast summation
  * \ingroup applications
  * \{
+ * Direct and fast summation (convolution)
+ * 
+ * Computes the sums
+ * \f[
+ *   f(y_j) = \sum_{k=1}^N \alpha_k K(x_k-y_j),\quad   j=1\dots M.
+ * \f]
  */
 
 #ifndef fastsum_h_inc
@@ -68,6 +74,8 @@ typedef C (*kernel)(R , int , const R *);
 
 #define NEARFIELD_BOXES (1U<< 1)
 
+#define STORE_PERMUTATION_X_ALPHA (1U<< 2)
+
 /** plan for fast summation algorithm */
 typedef struct fastsum_plan_
 {
@@ -97,6 +105,7 @@ typedef struct fastsum_plan_
   /** FS__ - fast summation */
   int n;                                /**< expansion degree                */
   C *b;                      /**< expansion coefficients          */
+  C *f_hat;  /**< Fourier coefficients of nfft plans */
 
   int p;                                /**< degree of smoothness of regularization */
   R eps_I;                         /**< inner boundary                  */  /* fixed to p/n so far  */
@@ -117,8 +126,11 @@ typedef struct fastsum_plan_
   int *box_offset;
   R *box_x;
   C *box_alpha;
+  
+  int *permutation_x_alpha;    /**< permutation vector of source nodes if STORE_PERMUTATION_X_ALPHA is set */
 
   R MEASURE_TIME_t[8]; /**< Measured time for each step if MEASURE_TIME is set */
+
 } fastsum_plan;
 
 /** initialize fast summation plan
@@ -139,19 +151,85 @@ typedef struct fastsum_plan_
  */
 void fastsum_init_guru(fastsum_plan *ths, int d, int N_total, int M_total, kernel k, R *param, unsigned flags, int nn, int m, int p, R eps_I, R eps_B);
 
+/** initialize node independent part of fast summation plan
+ *
+ * \param ths The pointer to a fastsum plan.
+ * \param d The dimension of the problem.
+ * \param kernel The kernel function.
+ * \param param The parameters for the kernel function.
+ * \param flags Fastsum flags.
+ * \param nn The expansion degree.
+ * \param p The degree of smoothness.
+ * \param eps_I The inner boundary.
+ * \param eps_B the outer boundary.
+ *
+ */
+void fastsum_init_guru_kernel(fastsum_plan *ths, int d, kernel k, R *param,
+    unsigned flags, int nn, int p, R eps_I, R eps_B);
+
+/** initialize source nodes dependent part of fast summation plan
+ *
+ * \param ths The pointer to a fastsum plan.
+ * \param N_total The number of source knots x.
+ * \param nn_oversampled The oversampled expansion degree for nfft.
+ * \param m The cut-off parameter for the NFFT.
+ *
+ */
+void fastsum_init_guru_source_nodes(fastsum_plan *ths, int N_total, int nn_oversampled, int m);
+
+/** initialize target nodes dependent part of fast summation plan
+ *
+ * \param ths The pointer to a fastsum plan.
+ * \param M_total The number of target knots y.
+ * \param nn_oversampled The oversampled expansion degree for nfft.
+ * \param m The cut-off parameter for the NFFT.
+ *
+ */
+void fastsum_init_guru_target_nodes(fastsum_plan *ths, int M_total, int nn_oversampled, int m);
+
 /** finalize plan
  *
  * \param ths The pointer to a fastsum plan.
  */
 void fastsum_finalize(fastsum_plan *ths);
 
+/** finalize source nodes dependent part of plan
+ *
+ * \param ths The pointer to a fastsum plan.
+ */
+void fastsum_finalize_source_nodes(fastsum_plan *ths);
+
+/** finalize target nodes dependent part of plan
+ *
+ * \param ths The pointer to a fastsum plan.
+ */
+void fastsum_finalize_target_nodes(fastsum_plan *ths);
+
+/** finalize node independent part of plan
+ *
+ * \param ths The pointer to a fastsum plan.
+ */
+void fastsum_finalize_kernel(fastsum_plan *ths);
+
 /** direct summation
  *
  * \param ths The pointer to a fastsum plan.
  */
 void fastsum_exact(fastsum_plan *ths);
 
-/** sort source nodes, precompute Fourier coefficients, etc.
+/** sort source nodes, precompute nfft source plan.
+ *
+ * \param ths The pointer to a fastsum plan.
+ */
+void fastsum_precompute_source_nodes(fastsum_plan *ths);
+
+/** precompute nfft target plan.
+ *
+ * \param ths The pointer to a fastsum plan.
+ */
+void fastsum_precompute_target_nodes(fastsum_plan *ths);
+
+/** sort source nodes, precompute nfft plans etc.
  *
  * \param ths The pointer to a fastsum plan.
  */
diff --git a/applications/fastsum/fastsum.m b/applications/fastsum/fastsum.m
index b764b42..afdf697 100644
--- a/applications/fastsum/fastsum.m
+++ b/applications/fastsum/fastsum.m
@@ -1,4 +1,4 @@
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -65,7 +65,7 @@ if ispc
 else 
     cmd='./fastsum_matlab';
 end
-system(sprintf('%s %d %d %d %d %d %d %s %e %e %e',cmd,d,N,M,n,m,p,kernel,c,eps_I,eps_B));
+system(sprintf('%s %d %d %d %d %d %d %s %.16g %.16g %.16g',cmd,d,N,M,n,m,p,kernel,c,eps_I,eps_B));
 
 %read result from file
 f2=load('f.dat');
diff --git a/applications/fastsum/fastsum_benchomp.c b/applications/fastsum/fastsum_benchomp.c
index e37a9a4..b404cf7 100644
--- a/applications/fastsum/fastsum_benchomp.c
+++ b/applications/fastsum/fastsum_benchomp.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/fastsum/fastsum_benchomp_createdataset.c b/applications/fastsum/fastsum_benchomp_createdataset.c
index e62cb25..d0d605e 100644
--- a/applications/fastsum/fastsum_benchomp_createdataset.c
+++ b/applications/fastsum/fastsum_benchomp_createdataset.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/fastsum/fastsum_benchomp_detail.c b/applications/fastsum/fastsum_benchomp_detail.c
index df47f8d..5566a10 100644
--- a/applications/fastsum/fastsum_benchomp_detail.c
+++ b/applications/fastsum/fastsum_benchomp_detail.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
@@ -194,6 +194,10 @@ int main(int argc, char **argv)
     kernel = cosc;
   else if (strcmp(s, "cot") == 0)
     kernel = kcot;
+  else if (strcmp(s, "one_over_cube") == 0)
+      kernel = one_over_cube;
+  else if (strcmp(s, "log_sin") == 0)
+    kernel = log_sin;
   else
   {
     s = "multiquadric";
diff --git a/applications/fastsum/fastsum_matlab.c b/applications/fastsum/fastsum_matlab.c
index f8fc1bb..775a86f 100644
--- a/applications/fastsum/fastsum_matlab.c
+++ b/applications/fastsum/fastsum_matlab.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
@@ -116,6 +116,10 @@ int main(int argc, char **argv)
       kernel = cosc;
     else if (strcmp(s, "cot") == 0)
       kernel = kcot;
+    else if (strcmp(s, "one_over_cube") == 0)
+      kernel = one_over_cube;
+    else if (strcmp(s, "log_sin") == 0)
+      kernel = log_sin;
     else
     {
       s = "multiquadric";
diff --git a/applications/fastsum/fastsum_test.c b/applications/fastsum/fastsum_test.c
index cc6e84d..34ba1c9 100644
--- a/applications/fastsum/fastsum_test.c
+++ b/applications/fastsum/fastsum_test.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
@@ -118,6 +118,10 @@ int main(int argc, char **argv)
       kernel = cosc;
     else if (strcmp(s, "cot") == 0)
       kernel = kcot;
+    else if (strcmp(s, "one_over_cube") == 0)
+      kernel = one_over_cube;
+    else if (strcmp(s, "log_sin") == 0)
+      kernel = log_sin;
     else
     {
       s = "multiquadric";
diff --git a/applications/fastsum/fastsum_test.m b/applications/fastsum/fastsum_test.m
index fb46793..e76dfd3 100644
--- a/applications/fastsum/fastsum_test.m
+++ b/applications/fastsum/fastsum_test.m
@@ -1,4 +1,4 @@
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/fastsum/kernels.c b/applications/fastsum/kernels.c
index e802a03..a8fd3e6 100644
--- a/applications/fastsum/kernels.c
+++ b/applications/fastsum/kernels.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
@@ -399,6 +399,22 @@ C one_over_cube(R x, int der, const R *param)
 }
 
 
+C log_sin(R x, int der, const R *param)   /* K(x) = log(|sin(cx)|) */
+{
+  R c=param[0];
+  R value=K(0.0);
+
+  if (FABS(x)<DBL_EPSILON) value=K(0.0);
+  else
+  {
+      if (der == 0) value = LOG(FABS(SIN(c * x)));
+      else value = c * kcot(x, der-1, param);
+  }
+  
+  return value;
+}
+
+
 /* \} */
 
 /* kernels.c */
diff --git a/applications/fastsum/kernels.h b/applications/fastsum/kernels.h
index fcd091a..13f0d70 100644
--- a/applications/fastsum/kernels.h
+++ b/applications/fastsum/kernels.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
@@ -41,19 +41,20 @@ extern "C"
  * \{
  */
 
-C gaussian(R x, int der, const R *param);              /* K(x)=exp(-x^2/c^2) */
-C multiquadric(R x, int der, const R *param);          /* K(x)=sqrt(x^2+c^2) */
-C inverse_multiquadric(R x, int der, const R *param);  /* K(x)=1/sqrt(x^2+c^2) */
-C logarithm(R x, int der, const R *param);             /* K(x)=log |x| */
-C thinplate_spline(R x, int der, const R *param);      /* K(x) = x^2 log |x| */
-C one_over_square(R x, int der, const R *param);       /* K(x) = 1/x^2 */
-C one_over_modulus(R x, int der, const R *param);      /* K(x) = 1/|x| */
-C one_over_x(R x, int der, const R *param);            /* K(x) = 1/x */
-C inverse_multiquadric3(R x, int der, const R *param); /* K(x) = 1/sqrt(x^2+c^2)^3 */
-C sinc_kernel(R x, int der, const R *param);           /* K(x) = sin(cx)/x */
-C cosc(R x, int der, const R *param);                  /* K(x) = cos(cx)/x */
-C kcot(R x, int der, const R *param);                   /* K(x) = cot(cx) */
-C one_over_cube(R x, int der, const R *param);                /* K(x) = 1/x^3 */
+C gaussian(R x, int der, const R *param);              /**< K(x)=exp(-x^2/c^2) */
+C multiquadric(R x, int der, const R *param);          /**< K(x)=sqrt(x^2+c^2) */
+C inverse_multiquadric(R x, int der, const R *param);  /**< K(x)=1/sqrt(x^2+c^2) */
+C logarithm(R x, int der, const R *param);             /**< K(x)=log |x| */
+C thinplate_spline(R x, int der, const R *param);      /**< K(x) = x^2 log |x| */
+C one_over_square(R x, int der, const R *param);       /**< K(x) = 1/x^2 */
+C one_over_modulus(R x, int der, const R *param);      /**< K(x) = 1/|x| */
+C one_over_x(R x, int der, const R *param);            /**< K(x) = 1/x */
+C inverse_multiquadric3(R x, int der, const R *param); /**< K(x) = 1/sqrt(x^2+c^2)^3 */
+C sinc_kernel(R x, int der, const R *param);           /**< K(x) = sin(cx)/x */
+C cosc(R x, int der, const R *param);                  /**< K(x) = cos(cx)/x */
+C kcot(R x, int der, const R *param);                  /**< K(x) = cot(cx) */
+C one_over_cube(R x, int der, const R *param);         /**< K(x) = 1/x^3 */
+C log_sin(R x, int der, const R *param);               /**< K(x) = log(|sin(cx)|) */
 /* \} */
 
 #ifdef __cplusplus
diff --git a/applications/fastsumS2/doxygen.h b/applications/fastsumS2/doxygen.h
index a14e471..d4ce5f6 100644
--- a/applications/fastsumS2/doxygen.h
+++ b/applications/fastsumS2/doxygen.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/fastsumS2/fastsumS2.c b/applications/fastsumS2/fastsumS2.c
index 2730925..4ca4fa5 100644
--- a/applications/fastsumS2/fastsumS2.c
+++ b/applications/fastsumS2/fastsumS2.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/fastsumS2/fastsumS2.m b/applications/fastsumS2/fastsumS2.m
index f30bfcf..c38d86c 100644
--- a/applications/fastsumS2/fastsumS2.m
+++ b/applications/fastsumS2/fastsumS2.m
@@ -1,9 +1,9 @@
 function fastsumS2()
 %FASTSUMS2
 %
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/fastsumS2/readTestcase.m b/applications/fastsumS2/readTestcase.m
index ca809ae..991df92 100644
--- a/applications/fastsumS2/readTestcase.m
+++ b/applications/fastsumS2/readTestcase.m
@@ -48,7 +48,7 @@ function T = readTestcase(file)
 %     - in the sixth column the error E_infty for the fast summation algorithm
 %       using the NFSFT algorithm.
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/fastsumS2/writeTestcase.m b/applications/fastsumS2/writeTestcase.m
index d8aec02..ae9b17e 100644
--- a/applications/fastsumS2/writeTestcase.m
+++ b/applications/fastsumS2/writeTestcase.m
@@ -36,7 +36,7 @@ function writeTestcase(file,usenfsft,usenfft,cutoff,usefpt,threshold,kernel,...
 %     - in the fifth column the error E_infty (undefined if direct sum
 %       evaluation has not been used).
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/iterS2/doxygen.h b/applications/iterS2/doxygen.h
index fa01b5e..70fd0f3 100644
--- a/applications/iterS2/doxygen.h
+++ b/applications/iterS2/doxygen.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/iterS2/iterS2.c b/applications/iterS2/iterS2.c
index bc4c593..74508d5 100644
--- a/applications/iterS2/iterS2.c
+++ b/applications/iterS2/iterS2.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/iterS2/writeImageTestcase.m b/applications/iterS2/writeImageTestcase.m
index c9d3b8c..ca60f4e 100644
--- a/applications/iterS2/writeImageTestcase.m
+++ b/applications/iterS2/writeImageTestcase.m
@@ -4,9 +4,9 @@ function writeTestcase(file,usenfsft,usenfft,cutoff,usefpt,threshold,...
 %    WRITETESTCASE(FILE, USENFSFT, USENFFT, CUTOFF, USEFPT, THRESHOLD,
 %    BANDWIDTH, THETA, PHI, F)
 %
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/iterS2/writeTestcase.m b/applications/iterS2/writeTestcase.m
index 5d66d2a..027293f 100644
--- a/applications/iterS2/writeTestcase.m
+++ b/applications/iterS2/writeTestcase.m
@@ -4,9 +4,9 @@ function writeTestcase(file,usenfsft,usenfft,cutoff,usefpt,threshold,...
 %   WRITETESTCASE(FILE, USENFSFT, USENFFT, CUTOFF, USEFPT, THRESHOLD,
 %   BANDWIDTH, THETA, PHI, F)
 %
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/mri/doxygen.c b/applications/mri/doxygen.c
index bad2f22..b0cf07d 100644
--- a/applications/mri/doxygen.c
+++ b/applications/mri/doxygen.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/mri/mri2d/construct_data_2d.c b/applications/mri/mri2d/construct_data_2d.c
index 72c5094..6e3e4c0 100644
--- a/applications/mri/mri2d/construct_data_2d.c
+++ b/applications/mri/mri2d/construct_data_2d.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/mri/mri2d/construct_data_inh_2d1d.c b/applications/mri/mri2d/construct_data_inh_2d1d.c
index 490c914..6e837fc 100644
--- a/applications/mri/mri2d/construct_data_inh_2d1d.c
+++ b/applications/mri/mri2d/construct_data_inh_2d1d.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/mri/mri2d/construct_data_inh_3d.c b/applications/mri/mri2d/construct_data_inh_3d.c
index 934c177..f4ecf51 100644
--- a/applications/mri/mri2d/construct_data_inh_3d.c
+++ b/applications/mri/mri2d/construct_data_inh_3d.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/mri/mri2d/construct_inh.m b/applications/mri/mri2d/construct_inh.m
index e89f5f7..fb1983d 100644
--- a/applications/mri/mri2d/construct_inh.m
+++ b/applications/mri/mri2d/construct_inh.m
@@ -1,4 +1,4 @@
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/mri/mri2d/construct_knots_linogram.m b/applications/mri/mri2d/construct_knots_linogram.m
index 78cd147..5e8371f 100644
--- a/applications/mri/mri2d/construct_knots_linogram.m
+++ b/applications/mri/mri2d/construct_knots_linogram.m
@@ -1,4 +1,4 @@
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/mri/mri2d/construct_knots_radial.m b/applications/mri/mri2d/construct_knots_radial.m
index 7cc1a1e..dab5c2a 100644
--- a/applications/mri/mri2d/construct_knots_radial.m
+++ b/applications/mri/mri2d/construct_knots_radial.m
@@ -1,4 +1,4 @@
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/mri/mri2d/construct_knots_rose.m b/applications/mri/mri2d/construct_knots_rose.m
index 7fa2607..20a45f7 100644
--- a/applications/mri/mri2d/construct_knots_rose.m
+++ b/applications/mri/mri2d/construct_knots_rose.m
@@ -1,4 +1,4 @@
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/mri/mri2d/construct_knots_spiral.m b/applications/mri/mri2d/construct_knots_spiral.m
index fbc971b..f05b4d2 100644
--- a/applications/mri/mri2d/construct_knots_spiral.m
+++ b/applications/mri/mri2d/construct_knots_spiral.m
@@ -1,4 +1,4 @@
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/mri/mri2d/construct_readout_time.m b/applications/mri/mri2d/construct_readout_time.m
index 9192b50..b2752c9 100644
--- a/applications/mri/mri2d/construct_readout_time.m
+++ b/applications/mri/mri2d/construct_readout_time.m
@@ -1,4 +1,4 @@
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/mri/mri2d/doxygen.h b/applications/mri/mri2d/doxygen.h
index 7656647..47f6447 100644
--- a/applications/mri/mri2d/doxygen.h
+++ b/applications/mri/mri2d/doxygen.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/mri/mri2d/mri.m b/applications/mri/mri2d/mri.m
index 45a61a9..f4474ed 100644
--- a/applications/mri/mri2d/mri.m
+++ b/applications/mri/mri2d/mri.m
@@ -1,4 +1,4 @@
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/mri/mri2d/mri_inh.m b/applications/mri/mri2d/mri_inh.m
index b287849..036be86 100644
--- a/applications/mri/mri2d/mri_inh.m
+++ b/applications/mri/mri2d/mri_inh.m
@@ -1,4 +1,4 @@
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/mri/mri2d/phantom.m b/applications/mri/mri2d/phantom.m
index 2be6d45..21fd57c 100644
--- a/applications/mri/mri2d/phantom.m
+++ b/applications/mri/mri2d/phantom.m
@@ -1,4 +1,4 @@
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/mri/mri2d/precompute_weights.m b/applications/mri/mri2d/precompute_weights.m
index 448713f..ca4e6f1 100644
--- a/applications/mri/mri2d/precompute_weights.m
+++ b/applications/mri/mri2d/precompute_weights.m
@@ -1,4 +1,4 @@
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/mri/mri2d/reconstruct_data_2d.c b/applications/mri/mri2d/reconstruct_data_2d.c
index 341c67a..ff7cbcb 100644
--- a/applications/mri/mri2d/reconstruct_data_2d.c
+++ b/applications/mri/mri2d/reconstruct_data_2d.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/mri/mri2d/reconstruct_data_gridding.c b/applications/mri/mri2d/reconstruct_data_gridding.c
index 4968533..09456b4 100644
--- a/applications/mri/mri2d/reconstruct_data_gridding.c
+++ b/applications/mri/mri2d/reconstruct_data_gridding.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/mri/mri2d/reconstruct_data_inh_2d1d.c b/applications/mri/mri2d/reconstruct_data_inh_2d1d.c
index cff061b..6b59033 100644
--- a/applications/mri/mri2d/reconstruct_data_inh_2d1d.c
+++ b/applications/mri/mri2d/reconstruct_data_inh_2d1d.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/mri/mri2d/reconstruct_data_inh_3d.c b/applications/mri/mri2d/reconstruct_data_inh_3d.c
index 4fa5957..5b5fb3b 100644
--- a/applications/mri/mri2d/reconstruct_data_inh_3d.c
+++ b/applications/mri/mri2d/reconstruct_data_inh_3d.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/mri/mri2d/reconstruct_data_inh_nnfft.c b/applications/mri/mri2d/reconstruct_data_inh_nnfft.c
index bec81f5..82f0c56 100644
--- a/applications/mri/mri2d/reconstruct_data_inh_nnfft.c
+++ b/applications/mri/mri2d/reconstruct_data_inh_nnfft.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/mri/mri2d/rms.m b/applications/mri/mri2d/rms.m
index 79b444b..88f7f79 100644
--- a/applications/mri/mri2d/rms.m
+++ b/applications/mri/mri2d/rms.m
@@ -1,4 +1,4 @@
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/mri/mri2d/verschiebung.m b/applications/mri/mri2d/verschiebung.m
index abe9521..80494d0 100644
--- a/applications/mri/mri2d/verschiebung.m
+++ b/applications/mri/mri2d/verschiebung.m
@@ -1,4 +1,4 @@
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/mri/mri2d/visualize_data.m b/applications/mri/mri2d/visualize_data.m
index 92e0ca4..4ec7549 100644
--- a/applications/mri/mri2d/visualize_data.m
+++ b/applications/mri/mri2d/visualize_data.m
@@ -1,4 +1,4 @@
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/mri/mri3d/construct_data_2d1d.c b/applications/mri/mri3d/construct_data_2d1d.c
index dc3335d..9bd623e 100644
--- a/applications/mri/mri3d/construct_data_2d1d.c
+++ b/applications/mri/mri3d/construct_data_2d1d.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/mri/mri3d/construct_data_3d.c b/applications/mri/mri3d/construct_data_3d.c
index 5f39c95..74db2dd 100644
--- a/applications/mri/mri3d/construct_data_3d.c
+++ b/applications/mri/mri3d/construct_data_3d.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/mri/mri3d/construct_knots_linogram.m b/applications/mri/mri3d/construct_knots_linogram.m
index 161de34..acd8c75 100644
--- a/applications/mri/mri3d/construct_knots_linogram.m
+++ b/applications/mri/mri3d/construct_knots_linogram.m
@@ -1,4 +1,4 @@
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/mri/mri3d/construct_knots_radial.m b/applications/mri/mri3d/construct_knots_radial.m
index 284c6a0..97d2656 100644
--- a/applications/mri/mri3d/construct_knots_radial.m
+++ b/applications/mri/mri3d/construct_knots_radial.m
@@ -1,4 +1,4 @@
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/mri/mri3d/construct_knots_radial_3d.m b/applications/mri/mri3d/construct_knots_radial_3d.m
index fc12456..b1839f7 100644
--- a/applications/mri/mri3d/construct_knots_radial_3d.m
+++ b/applications/mri/mri3d/construct_knots_radial_3d.m
@@ -1,4 +1,4 @@
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/mri/mri3d/construct_knots_rose.m b/applications/mri/mri3d/construct_knots_rose.m
index 7b31dc0..0d601b3 100644
--- a/applications/mri/mri3d/construct_knots_rose.m
+++ b/applications/mri/mri3d/construct_knots_rose.m
@@ -1,4 +1,4 @@
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/mri/mri3d/construct_knots_spiral.m b/applications/mri/mri3d/construct_knots_spiral.m
index acafbc7..e10da2f 100644
--- a/applications/mri/mri3d/construct_knots_spiral.m
+++ b/applications/mri/mri3d/construct_knots_spiral.m
@@ -1,4 +1,4 @@
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/mri/mri3d/construct_phantom.m b/applications/mri/mri3d/construct_phantom.m
index 77a211b..703679a 100644
--- a/applications/mri/mri3d/construct_phantom.m
+++ b/applications/mri/mri3d/construct_phantom.m
@@ -1,4 +1,4 @@
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/mri/mri3d/doxygen.h b/applications/mri/mri3d/doxygen.h
index 2be6495..f26b58d 100644
--- a/applications/mri/mri3d/doxygen.h
+++ b/applications/mri/mri3d/doxygen.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/mri/mri3d/mri.m b/applications/mri/mri3d/mri.m
index d7b0604..aef692e 100644
--- a/applications/mri/mri3d/mri.m
+++ b/applications/mri/mri3d/mri.m
@@ -1,4 +1,4 @@
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/mri/mri3d/precompute_weights_2d.m b/applications/mri/mri3d/precompute_weights_2d.m
index 5aa4bc2..aa2e42c 100644
--- a/applications/mri/mri3d/precompute_weights_2d.m
+++ b/applications/mri/mri3d/precompute_weights_2d.m
@@ -1,4 +1,4 @@
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/mri/mri3d/reconstruct_data_2d1d.c b/applications/mri/mri3d/reconstruct_data_2d1d.c
index f64e9e1..c1b6a37 100644
--- a/applications/mri/mri3d/reconstruct_data_2d1d.c
+++ b/applications/mri/mri3d/reconstruct_data_2d1d.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/mri/mri3d/reconstruct_data_3d.c b/applications/mri/mri3d/reconstruct_data_3d.c
index cf78b23..e0072d0 100644
--- a/applications/mri/mri3d/reconstruct_data_3d.c
+++ b/applications/mri/mri3d/reconstruct_data_3d.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/mri/mri3d/reconstruct_data_gridding.c b/applications/mri/mri3d/reconstruct_data_gridding.c
index 16f5550..71a7e8c 100644
--- a/applications/mri/mri3d/reconstruct_data_gridding.c
+++ b/applications/mri/mri3d/reconstruct_data_gridding.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/mri/mri3d/rms.m b/applications/mri/mri3d/rms.m
index 79b444b..88f7f79 100644
--- a/applications/mri/mri3d/rms.m
+++ b/applications/mri/mri3d/rms.m
@@ -1,4 +1,4 @@
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/mri/mri3d/visualize_data.m b/applications/mri/mri3d/visualize_data.m
index 77bd07f..c11be8d 100644
--- a/applications/mri/mri3d/visualize_data.m
+++ b/applications/mri/mri3d/visualize_data.m
@@ -1,4 +1,4 @@
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/polarFFT/doxygen.h b/applications/polarFFT/doxygen.h
index 727bf6a..3608ccd 100644
--- a/applications/polarFFT/doxygen.h
+++ b/applications/polarFFT/doxygen.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/polarFFT/fft_test.m b/applications/polarFFT/fft_test.m
index 673400d..fd7fa34 100644
--- a/applications/polarFFT/fft_test.m
+++ b/applications/polarFFT/fft_test.m
@@ -1,4 +1,4 @@
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/polarFFT/linogram_fft_test.c.in b/applications/polarFFT/linogram_fft_test.c.in
index 42183b9..e1d2357 100644
--- a/applications/polarFFT/linogram_fft_test.c.in
+++ b/applications/polarFFT/linogram_fft_test.c.in
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/polarFFT/mpolar_fft_test.c.in b/applications/polarFFT/mpolar_fft_test.c.in
index 7011aba..fa011b3 100644
--- a/applications/polarFFT/mpolar_fft_test.c.in
+++ b/applications/polarFFT/mpolar_fft_test.c.in
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/polarFFT/phantom.m b/applications/polarFFT/phantom.m
index 2be6d45..21fd57c 100644
--- a/applications/polarFFT/phantom.m
+++ b/applications/polarFFT/phantom.m
@@ -1,4 +1,4 @@
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/polarFFT/polar_fft_test.c.in b/applications/polarFFT/polar_fft_test.c.in
index 15217a3..a5d14d7 100644
--- a/applications/polarFFT/polar_fft_test.c.in
+++ b/applications/polarFFT/polar_fft_test.c.in
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/quadratureS2/doxygen.h b/applications/quadratureS2/doxygen.h
index 538a0fe..aa319d1 100644
--- a/applications/quadratureS2/doxygen.h
+++ b/applications/quadratureS2/doxygen.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/quadratureS2/lgwt.m b/applications/quadratureS2/lgwt.m
index ed441ff..bce18ed 100644
--- a/applications/quadratureS2/lgwt.m
+++ b/applications/quadratureS2/lgwt.m
@@ -12,7 +12,7 @@ function [x,w]=lgwt(N,a,b)
 %
 %   Written by Greg von Winckel - 02/25/2004
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/quadratureS2/plotGrid.m b/applications/quadratureS2/plotGrid.m
index f174705..a8affe7 100644
--- a/applications/quadratureS2/plotGrid.m
+++ b/applications/quadratureS2/plotGrid.m
@@ -8,9 +8,9 @@ function plotGrid(gridType,p)
 %   2: HEALPix point set,
 %   3: Equidistribution point set.
 %
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/quadratureS2/quadratureS2.c b/applications/quadratureS2/quadratureS2.c
index 18853d1..1810e7b 100644
--- a/applications/quadratureS2/quadratureS2.c
+++ b/applications/quadratureS2/quadratureS2.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/quadratureS2/quadratureS2.m b/applications/quadratureS2/quadratureS2.m
index c44ad57..65570da 100644
--- a/applications/quadratureS2/quadratureS2.m
+++ b/applications/quadratureS2/quadratureS2.m
@@ -1,9 +1,9 @@
 function quadratureS2()
 %QUADRATURES2
 %
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/quadratureS2/readTestcase.m b/applications/quadratureS2/readTestcase.m
index d843d8d..7573451 100644
--- a/applications/quadratureS2/readTestcase.m
+++ b/applications/quadratureS2/readTestcase.m
@@ -1,9 +1,9 @@
 function T = readTestcase(file)
 %READTESTCASE - Read quadratureS2.c testcase results from file
 %
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/quadratureS2/writeTestcase.m b/applications/quadratureS2/writeTestcase.m
index e46ade9..709f122 100644
--- a/applications/quadratureS2/writeTestcase.m
+++ b/applications/quadratureS2/writeTestcase.m
@@ -2,9 +2,9 @@ function writeTestcase(file,usenfsft,usenfft,cutoff,usefpt,threshold,...
   testmode,gridtype,testfunction,repetitions,mode,bandwidths)
 %WRITETESTCASE - Write qudratureS2 testcases
 %
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/quadratureS2/writeWeights.m b/applications/quadratureS2/writeWeights.m
index 40dc8ee..05e06da 100644
--- a/applications/quadratureS2/writeWeights.m
+++ b/applications/quadratureS2/writeWeights.m
@@ -1,9 +1,9 @@
 function writeWeights(file,m)
 %WRITEWEIGHTS
 %
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/radon/inverse_radon.c.in b/applications/radon/inverse_radon.c.in
index 3c8dcb8..6ca3c09 100644
--- a/applications/radon/inverse_radon.c.in
+++ b/applications/radon/inverse_radon.c.in
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/radon/phantom.m b/applications/radon/phantom.m
index 2be6d45..21fd57c 100644
--- a/applications/radon/phantom.m
+++ b/applications/radon/phantom.m
@@ -1,4 +1,4 @@
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/radon/radon.c.in b/applications/radon/radon.c.in
index 0de98ac..d76047a 100644
--- a/applications/radon/radon.c.in
+++ b/applications/radon/radon.c.in
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/radon/radon.m b/applications/radon/radon.m
index ff485f5..37e7c1f 100644
--- a/applications/radon/radon.m
+++ b/applications/radon/radon.m
@@ -1,4 +1,4 @@
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/applications/radon/ridgelet.m b/applications/radon/ridgelet.m
index 6e78726..6b3dbee 100644
--- a/applications/radon/ridgelet.m
+++ b/applications/radon/ridgelet.m
@@ -1,4 +1,4 @@
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/configure.ac b/configure.ac
index 7ac848f..f2e4b07 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
-# Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+# Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 #
 # This program is free software; you can redistribute it and/or modify it under
 # the terms of the GNU General Public License as published by the Free Software
@@ -19,8 +19,8 @@
 ################################################################################
 
 m4_define([nfft_version_major], [3])
-m4_define([nfft_version_minor], [3])
-m4_define([nfft_version_patch], [2])
+m4_define([nfft_version_minor], [4])
+m4_define([nfft_version_patch], [0])
 m4_define([nfft_version_type], [alpha])
 m4_append([NFFT_VERSION], m4_expand([nfft_version_major.nfft_version_minor.nfft_version_patch]))
 m4_append([NFFT_VERSION], m4_expand([nfft_version_type]))
@@ -29,7 +29,7 @@ m4_append([NFFT_VERSION], m4_expand([nfft_version_type]))
 AC_INIT([NFFT],[NFFT_VERSION],[mail at nfft.org])
 
 # copyright notice
-AC_COPYRIGHT([2003, 2015, Jens Keiner, Stefan Kunis, Daniel Potts])
+AC_COPYRIGHT([2003, 2017, Jens Keiner, Stefan Kunis, Daniel Potts])
 
 AC_DEFINE_UNQUOTED([NFFT_VERSION_MAJOR], [nfft_version_major], [Major version number.])
 AC_DEFINE_UNQUOTED([NFFT_VERSION_MINOR], [nfft_version_minor], [Minor version number.])
@@ -77,7 +77,7 @@ LT_INIT([win32-dll])
 AC_SUBST([LIBTOOL_DEPS])
 
 # version information for shared library
-SHARED_VERSION_INFO="2:0:0"
+SHARED_VERSION_INFO="3:0:1"
 
 # substitute SHARED_VERSION_INFO in generated Makefiles
 AC_SUBST(SHARED_VERSION_INFO)
@@ -241,6 +241,7 @@ case "$window" in
     AC_MSG_ERROR([Unknown window function "$window".]);;
 esac
 AC_MSG_RESULT([$window])
+AC_DEFINE_UNQUOTED(WINDOW_NAME,$window,[The name of the window function.])
 
 AC_ARG_ENABLE(exhaustive-unit-tests, [AS_HELP_STRING([--enable-exhaustive-unit-tests],[enable exhaustive unit tests])], ok=$enableval, ok=no)
 if test "$ok" = "yes"; then
@@ -373,6 +374,11 @@ fi
 # option to accept C99
 CFLAGS="$CFLAGS $ac_cv_prog_cc_c99"
 
+# use MinGW implementation of printf
+if test "x${host_os}" = "xmingw32" -o "x${host_os}" = "xmingw64"; then
+  CFLAGS="$CFLAGS -D__USE_MINGW_ANSI_STDIO=1"
+fi  
+
 CPPFLAGS="$CPPFLAGS $fftw3_CPPFLAGS"
 
 # add Matlab CFLAGS
@@ -507,7 +513,7 @@ SLEEP;{
   FILE *f = fopen("ticks.tmp","w");
   fprintf(f,"%.1f\n",tps);
   fclose(f);}
-return 0;}],[read TICKS_PER_SECOND < ticks.tmp],[],[])
+return 0;}],[read TICKS_PER_SECOND < ticks.tmp],[],[TICKS_PER_SECOND=1])
     rm -f ticks.tmp
   if test "$TICKS_PER_SECOND" = "1"; then
     echo "***************************************************************"
@@ -542,6 +548,30 @@ AC_CHECK_DECLS([copysignf, nextafterf, nanf, ceilf, floorf, nearbyintf, rintf, r
 #include <complex.h>])
 fi
 
+# Calculate machine epsilon for selected precision.
+AX_EPS_CALC([$PRECISION])
+
+# Get machine epsilon as per float.h.
+AX_EPS_DEF([$PRECISION])
+
+if test "$ax_cv_eps_calc" = "unknown"; then  
+  if test "$ax_cv_eps_def" = "unknown"; then
+    # Calculation has failed and unable to get from float.h.
+    AC_MSG_ERROR([Unable to determine floating-point epsilon.])
+  else
+    # Unable to calculate but have value in float.h.
+    AC_MSG_WARN([Unable to calculate floating-point epsilon. Using pre-defined value from macro.])
+    AC_DEFINE_UNQUOTED([NFFT_EPSILON], [$ax_cv_eps_def], [Floating-point epsilon.])
+  fi
+else
+  if test "$ax_cv_eps_calc" != "$ax_cv_eps_def"; then
+    # Calculated epsilon different from float.h.
+    AC_MSG_WARN([Calculated epsilon "$ax_cv_eps_calc" and epsilon from macro "$ax_cv_eps_def" differ. Using calculated value.])
+  fi
+    # Calculated and pre-defined values identical.
+    AC_DEFINE_UNQUOTED([NFFT_EPSILON], [$ax_cv_eps_calc], [Floating-point epsilon.])
+fi
+
 # CUnit
 AX_CUNIT
 AM_CONDITIONAL(HAVE_CUNIT, test "x$ax_cv_cunit" = "xyes" )
@@ -605,7 +635,10 @@ AC_CONFIG_FILES(Makefile \
                 matlab/Makefile \
                 matlab/nfsft/Makefile \
                 matlab/nfft/Makefile \
+                matlab/nfct/Makefile \
+                matlab/nfst/Makefile \
                 matlab/nnfft/Makefile \
+                matlab/fastsum/Makefile \
                 matlab/nfsft/@f_hat/Makefile \
                 matlab/nfsoft/Makefile \
                 doxygen/Makefile \
diff --git a/doc/assets/sphere.pdf b/doc/assets/sphere.pdf
new file mode 100644
index 0000000..ee88c7d
Binary files /dev/null and b/doc/assets/sphere.pdf differ
diff --git a/doc/assets/sphere.png b/doc/assets/sphere.png
new file mode 100644
index 0000000..42612e1
Binary files /dev/null and b/doc/assets/sphere.png differ
diff --git a/doxygen.dox b/doxygen.dox
index 3812152..553bd18 100644
--- a/doxygen.dox
+++ b/doxygen.dox
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
@@ -21,15 +21,15 @@
  *
  * \section introduction Introduction
  *
- * \cite{nfft3} Fast Fourier transforms (FFTs) belong \cite{nfft3_2} to the '10 algorithms with the
+ * Fast Fourier transforms (FFTs) belong to the '10 algorithms with the
  * greatest influence on the development and practice of science and
- * engineering \cite{nfft3} in the 20th century'.
+ * engineering in the 20th century'.
  * The classic algorithm computes the discrete Fourier transform
  * \f[
  *   f_j= \sum_{k=-\frac{N}{2}}^{\frac{N}{2}-1} \hat{f}_{k}
  * {\rm e}^{2\pi{\rm i}\frac{kj}{N}}
  * \f]
- * for \f$j=-\frac{N}{2},\hdots,\frac{N}{2}-1\f$ and given complex
+ * for \f$j=-\frac{N}{2},\dots,\frac{N}{2}-1\f$ and given complex
  * coefficients \f$\hat{f}_{k}\in\mathbb{C}\f$.
  * Using a divide and conquer approach, the number of floating point
  * operations is reduced from \f${\cal O}(N^2)\f$ for a straightforward
@@ -44,14 +44,14 @@
  * Fourier transform (NDFT) and its generalisations in one or more dimensions,
  * of arbitrary input size, and of complex data.
  *
- * More precisely,we collect the possible frequencies
+ * More precisely, we collect the possible frequencies
  * \f$\mathbf{k}\in\mathbb{Z}^d\f$ in the multi-index set
  * \f[
- * I_{\mathbf{N}} := \left\{ \mathbf{k}=\left(k_t\right)_{t=0,\hdots,d-1}
+ * I_{\mathbf{N}} := \left\{ \mathbf{k}=\left(k_t\right)_{t=0,\dots,d-1}
  *  \in \mathbb{Z}^d: -
- *   \frac{N_t}{2} \le k_t < \frac{N_t}{2} ,\;t=0,\hdots,d-1\right\},
+ *   \frac{N_t}{2} \le k_t < \frac{N_t}{2} ,\;t=0,\dots,d-1\right\},
  * \f]
- * where \f$\mathbf{N}=\left(N_t\right)_{t=0,\hdots,d-1}\f$ is the
+ * where \f$\mathbf{N}=\left(N_t\right)_{t=0,\dots,d-1}\f$ is the
  * multibandlimit, i.e., \f$N_t\in 2\mathbb{N}\f$.
  * For a finite number of given Fourier coefficients
  * \f$\hat f_{\mathbf{k}} \in \mathbb{C}\f$,
diff --git a/doxygen/doxygen.Doxyfile.in b/doxygen/doxygen.Doxyfile.in
index beaa915..b387f27 100644
--- a/doxygen/doxygen.Doxyfile.in
+++ b/doxygen/doxygen.Doxyfile.in
@@ -755,6 +755,7 @@ WARN_LOGFILE           =
 # Note: If this tag is empty the current directory is searched.
 
 INPUT                  = @abs_top_srcdir@/doxygen.dox \
+                         @abs_top_srcdir@/support \
                          @abs_top_srcdir@/include \
                          @abs_top_srcdir@/kernel \
                          @abs_top_srcdir@/examples \
@@ -1017,8 +1018,9 @@ IGNORE_PREFIX          =
 
 # If the GENERATE_HTML tag is set to YES doxygen will generate HTML output
 # The default value is: YES.
-
-GENERATE_HTML          = YES
+#
+#deactivated because this is set by automake as environment variable
+#GENERATE_HTML          = YES
 
 # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a
 # relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
@@ -1219,8 +1221,9 @@ DOCSET_PUBLISHER_NAME  = Publisher
 # compressed HTML files.
 # The default value is: NO.
 # This tag requires that the tag GENERATE_HTML is set to YES.
-
-GENERATE_HTMLHELP      = NO
+#
+#deactivated because this is set by automake as environment variable
+#GENERATE_HTMLHELP      = NO
 
 # The CHM_FILE tag can be used to specify the file name of the resulting .chm
 # file. You can add a path in front of the file if the result should not be
@@ -1241,8 +1244,9 @@ HHC_LOCATION           =
 # YES) or that it should be included in the master .chm file ( NO).
 # The default value is: NO.
 # This tag requires that the tag GENERATE_HTMLHELP is set to YES.
-
-GENERATE_CHI           = NO
+#
+#deactivated because this is set by automake as environment variable
+#GENERATE_CHI           = NO
 
 # The CHM_INDEX_ENCODING is used to encode HtmlHelp index ( hhk), content ( hhc)
 # and project file content.
@@ -1561,8 +1565,9 @@ EXTRA_SEARCH_MAPPINGS  =
 
 # If the GENERATE_LATEX tag is set to YES doxygen will generate LaTeX output.
 # The default value is: YES.
-
-GENERATE_LATEX         = NO
+#
+#deactivated because this is set by automake as environment variable
+#GENERATE_LATEX         = NO
 
 # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. If a
 # relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
@@ -1709,8 +1714,9 @@ LATEX_BIB_STYLE        = plain
 # RTF output is optimized for Word 97 and may not look too pretty with other RTF
 # readers/editors.
 # The default value is: NO.
-
-GENERATE_RTF           = NO
+#
+#deactivated because this is set by automake as environment variable
+#GENERATE_RTF           = NO
 
 # The RTF_OUTPUT tag is used to specify where the RTF docs will be put. If a
 # relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
@@ -1764,8 +1770,9 @@ RTF_EXTENSIONS_FILE    =
 # If the GENERATE_MAN tag is set to YES doxygen will generate man pages for
 # classes and files.
 # The default value is: NO.
-
-GENERATE_MAN           = NO
+#
+#deactivated because this is set by automake as environment variable
+#GENERATE_MAN           = NO
 
 # The MAN_OUTPUT tag is used to specify where the man pages will be put. If a
 # relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
@@ -1808,8 +1815,9 @@ MAN_LINKS              = NO
 # If the GENERATE_XML tag is set to YES doxygen will generate an XML file that
 # captures the structure of the code including all documentation.
 # The default value is: NO.
-
-GENERATE_XML           = NO
+#
+#deactivated because this is set by automake as environment variable
+#GENERATE_XML           = NO
 
 # The XML_OUTPUT tag is used to specify where the XML pages will be put. If a
 # relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
@@ -2022,8 +2030,9 @@ EXTERNAL_PAGES         = YES
 # The PERL_PATH should be the absolute path and name of the perl script
 # interpreter (i.e. the result of 'which perl').
 # The default file (with absolute path) is: /usr/bin/perl.
-
-PERL_PATH              = /usr/bin/perl
+#
+#deactivated because this is set by automake as environment variable
+#PERL_PATH              = /usr/bin/perl
 
 #---------------------------------------------------------------------------
 # Configuration options related to the dot tool
@@ -2066,8 +2075,9 @@ HIDE_UNDOC_RELATIONS   = YES
 # Bell Labs. The other options in this section have no effect if this option is
 # set to NO
 # The default value is: NO.
-
-HAVE_DOT               = NO
+#
+#deactivated because this is set by automake as environment variable
+#HAVE_DOT               = NO
 
 # The DOT_NUM_THREADS specifies the number of dot invocations doxygen is allowed
 # to run in parallel. When set to 0 doxygen will base this on the number of
@@ -2238,8 +2248,9 @@ INTERACTIVE_SVG        = NO
 # The DOT_PATH tag can be used to specify the path where the dot tool can be
 # found. If left blank, it is assumed the dot tool can be found in the path.
 # This tag requires that the tag HAVE_DOT is set to YES.
-
-DOT_PATH               =
+#
+#deactivated because this is set by automake as environment variable
+#DOT_PATH               =
 
 # The DOTFILE_DIRS tag can be used to specify one or more directories that
 # contain dot files that are included in the documentation (see the \dotfile
diff --git a/examples/doxygen.c b/examples/doxygen.c
index 1c33a1f..1701284 100644
--- a/examples/doxygen.c
+++ b/examples/doxygen.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/examples/fpt/simple_test.c b/examples/fpt/simple_test.c
index f085c2b..8b334f0 100644
--- a/examples/fpt/simple_test.c
+++ b/examples/fpt/simple_test.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/examples/nfct/simple_test.c.in b/examples/nfct/simple_test.c.in
index 9257c8b..2c02466 100644
--- a/examples/nfct/simple_test.c.in
+++ b/examples/nfct/simple_test.c.in
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/examples/nfft/flags.c b/examples/nfft/flags.c
index 39ab92d..ef53884 100644
--- a/examples/nfft/flags.c
+++ b/examples/nfft/flags.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/examples/nfft/flags.m b/examples/nfft/flags.m
index 2c856d5..2cbc719 100644
--- a/examples/nfft/flags.m
+++ b/examples/nfft/flags.m
@@ -1,4 +1,4 @@
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/examples/nfft/ndft_fast.c b/examples/nfft/ndft_fast.c
index ea49d7a..00cd5dd 100644
--- a/examples/nfft/ndft_fast.c
+++ b/examples/nfft/ndft_fast.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/examples/nfft/ndft_fast.m b/examples/nfft/ndft_fast.m
index 871a8c9..9dd1de9 100644
--- a/examples/nfft/ndft_fast.m
+++ b/examples/nfft/ndft_fast.m
@@ -1,4 +1,4 @@
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/examples/nfft/nfft_benchomp.c b/examples/nfft/nfft_benchomp.c
index 0c1caca..5731aa9 100644
--- a/examples/nfft/nfft_benchomp.c
+++ b/examples/nfft/nfft_benchomp.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/examples/nfft/nfft_benchomp_createdataset.c b/examples/nfft/nfft_benchomp_createdataset.c
index 925bebb..8330b0c 100644
--- a/examples/nfft/nfft_benchomp_createdataset.c
+++ b/examples/nfft/nfft_benchomp_createdataset.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/examples/nfft/nfft_benchomp_detail.c b/examples/nfft/nfft_benchomp_detail.c
index d7fc341..22887e3 100644
--- a/examples/nfft/nfft_benchomp_detail.c
+++ b/examples/nfft/nfft_benchomp_detail.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/examples/nfft/nfft_times.c b/examples/nfft/nfft_times.c
index 0aad447..f7fb3b4 100644
--- a/examples/nfft/nfft_times.c
+++ b/examples/nfft/nfft_times.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/examples/nfft/simple_test.c.in b/examples/nfft/simple_test.c.in
index 000b5bf..d5516ef 100644
--- a/examples/nfft/simple_test.c.in
+++ b/examples/nfft/simple_test.c.in
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/examples/nfft/simple_test_threads.c.in b/examples/nfft/simple_test_threads.c.in
index 9790e1b..9c5b0fe 100644
--- a/examples/nfft/simple_test_threads.c.in
+++ b/examples/nfft/simple_test_threads.c.in
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/examples/nfft/taylor_nfft.c b/examples/nfft/taylor_nfft.c
index 8000a87..c7a64f4 100644
--- a/examples/nfft/taylor_nfft.c
+++ b/examples/nfft/taylor_nfft.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/examples/nfft/taylor_nfft.m b/examples/nfft/taylor_nfft.m
index 052e164..f7c0be0 100644
--- a/examples/nfft/taylor_nfft.m
+++ b/examples/nfft/taylor_nfft.m
@@ -1,4 +1,4 @@
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/examples/nfsft/nfsft_benchomp.c b/examples/nfsft/nfsft_benchomp.c
index d83508a..4dd94ef 100644
--- a/examples/nfsft/nfsft_benchomp.c
+++ b/examples/nfsft/nfsft_benchomp.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/examples/nfsft/nfsft_benchomp_createdataset.c b/examples/nfsft/nfsft_benchomp_createdataset.c
index a167a29..567b127 100644
--- a/examples/nfsft/nfsft_benchomp_createdataset.c
+++ b/examples/nfsft/nfsft_benchomp_createdataset.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/examples/nfsft/nfsft_benchomp_detail.c b/examples/nfsft/nfsft_benchomp_detail.c
index 4635df8..a37e9d7 100644
--- a/examples/nfsft/nfsft_benchomp_detail.c
+++ b/examples/nfsft/nfsft_benchomp_detail.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/examples/nfsft/simple_test.c b/examples/nfsft/simple_test.c
index ff2051d..06908ef 100644
--- a/examples/nfsft/simple_test.c
+++ b/examples/nfsft/simple_test.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/examples/nfsft/simple_test_threads.c b/examples/nfsft/simple_test_threads.c
index 8a2a762..f8fa235 100644
--- a/examples/nfsft/simple_test_threads.c
+++ b/examples/nfsft/simple_test_threads.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/examples/nfsoft/simple_test.c b/examples/nfsoft/simple_test.c
index 0f95a53..e531480 100644
--- a/examples/nfsoft/simple_test.c
+++ b/examples/nfsoft/simple_test.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/examples/nfst/simple_test.c.in b/examples/nfst/simple_test.c.in
index 32d746a..083c63c 100644
--- a/examples/nfst/simple_test.c.in
+++ b/examples/nfst/simple_test.c.in
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/examples/nnfft/accuracy.c b/examples/nnfft/accuracy.c
index 2f3344d..b12ed17 100644
--- a/examples/nnfft/accuracy.c
+++ b/examples/nnfft/accuracy.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/examples/nnfft/accuracy.m b/examples/nnfft/accuracy.m
index 1cc86a0..986001e 100644
--- a/examples/nnfft/accuracy.m
+++ b/examples/nnfft/accuracy.m
@@ -1,4 +1,4 @@
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/examples/nnfft/simple_test.c b/examples/nnfft/simple_test.c
index a81bb59..bcc2ea0 100644
--- a/examples/nnfft/simple_test.c
+++ b/examples/nnfft/simple_test.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/examples/nsfft/nsfft_test.c b/examples/nsfft/nsfft_test.c
index 918963f..ba0c347 100644
--- a/examples/nsfft/nsfft_test.c
+++ b/examples/nsfft/nsfft_test.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/examples/nsfft/simple_test.c b/examples/nsfft/simple_test.c
index e21cb9d..4a06a1c 100644
--- a/examples/nsfft/simple_test.c
+++ b/examples/nsfft/simple_test.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/examples/solver/doxygen.h b/examples/solver/doxygen.h
index 07d3a6a..98d6ec9 100644
--- a/examples/solver/doxygen.h
+++ b/examples/solver/doxygen.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/examples/solver/glacier.c.in b/examples/solver/glacier.c.in
index a33fa63..9348763 100644
--- a/examples/solver/glacier.c.in
+++ b/examples/solver/glacier.c.in
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/examples/solver/glacier.m b/examples/solver/glacier.m
index ab445b3..9c3f4c5 100644
--- a/examples/solver/glacier.m
+++ b/examples/solver/glacier.m
@@ -1,4 +1,4 @@
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/examples/solver/glacier_cv.m b/examples/solver/glacier_cv.m
index 3fb9017..f974423 100644
--- a/examples/solver/glacier_cv.m
+++ b/examples/solver/glacier_cv.m
@@ -1,4 +1,4 @@
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/examples/solver/simple_test.c.in b/examples/solver/simple_test.c.in
index 18cd241..4eb2e81 100644
--- a/examples/solver/simple_test.c.in
+++ b/examples/solver/simple_test.c.in
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/include/api.h b/include/api.h
index e77deef..89ca499 100644
--- a/include/api.h
+++ b/include/api.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/include/infft.h b/include/infft.h
index 9f17f7a..f751247 100644
--- a/include/infft.h
+++ b/include/infft.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
@@ -53,7 +53,7 @@
 #include "ticks.h"
 
 /**
- * @defgroup nfftutil Util - Auxilliary functions
+ * @defgroup nfftutil Util - Auxiliary functions
  * @{
  *
  * This module implements frequently used utility functions.
@@ -1247,17 +1247,14 @@ extern double _Complex catanh(double _Complex z);
 #endif
 
 #if defined(NFFT_LDOUBLE)
-  #define EPSILON LDBL_EPSILON//4.0E-31L
   #define MANT_DIG LDBL_MANT_DIG
   #define MIN_EXP LDBL_MIN_EXP
   #define MAX_EXP LDBL_MAX_EXP
 #elif defined(NFFT_SINGLE)
-  #define EPSILON FLT_EPSILON
   #define MANT_DIG FLT_MANT_DIG
   #define MIN_EXP FLT_MIN_EXP
   #define MAX_EXP FLT_MAX_EXP
 #else
-  #define EPSILON DBL_EPSILON
   #define MANT_DIG DBL_MANT_DIG
   #define MIN_EXP DBL_MIN_EXP
   #define MAX_EXP DBL_MAX_EXP
@@ -1429,7 +1426,7 @@ R Y(bessel_i0)(R x);
 R Y(bsplines)(const INT, const R x);
 
 /* float.c: */
-typedef enum {NFFT_EPSILON = 0, NFFT_SAFE__MIN = 1, NFFT_BASE = 2,
+typedef enum {NFFT_SAFE__MIN = 1, NFFT_BASE = 2,
   NFFT_PRECISION = 3, NFFT_MANT_DIG = 4, NFFT_FLTROUND = 5, NFFT_E_MIN = 6,
   NFFT_R_MIN = 7, NFFT_E_MAX = 8, NFFT_R_MAX = 9} float_property;
 
diff --git a/include/nfft3.h b/include/nfft3.h
index e2a44d3..1864fce 100644
--- a/include/nfft3.h
+++ b/include/nfft3.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
@@ -30,7 +30,7 @@ extern "C"
 #define NFFT_CONCAT(prefix, name) prefix ## name
 
 /* IMPORTANT: for Windows compilers, you should add a line
- *   #define FFTW_DLL
+ *   #define NFFT_DLL
  * here and in kernel/infft.h if you are compiling/using NFFT as a DLL, in order
  * to do the proper importing/exporting, or alternatively compile with
  * -DNFFT_DLL or the equivalent command-line flag. This is not necessary under
@@ -144,7 +144,7 @@ typedef struct\
   Y(plan) my_fftw_plan2; /**< Backward FFTW plan */\
 \
   R **c_phi_inv; /**< Precomputed data for the diagonal matrix \f$D\f$, size \
-    is \f$N_0+\hdots+N_{d-1}\f$ doubles*/\
+    is \f$N_0+\dots+N_{d-1}\f$ doubles*/\
   R *psi; /**< Precomputed data for the sparse matrix \f$B\f$, size depends
                     on precomputation scheme */\
   NFFT_INT *psi_index_g; /**< Indices in source/target vector for \ref PRE_FULL_PSI */\
@@ -705,6 +705,7 @@ NFFT_EXTERN void X(SO3_fpt_transposed)(C *coeffs, Z(set) set,int l, int k, int m
 NFFT_EXTERN void X(init)(X(plan) *plan, int N, int M); \
 NFFT_EXTERN void X(init_advanced)(X(plan) *plan, int N, int M,unsigned int nfsoft_flags); \
 NFFT_EXTERN void X(init_guru)(X(plan) *plan, int N, int M,unsigned int nfsoft_flags,unsigned int nfft_flags,int nfft_cutoff,int fpt_kappa); \
+NFFT_EXTERN void X(init_guru_advanced)(X(plan) *plan, int N, int M,unsigned int nfsoft_flags,unsigned int nfft_flags,int nfft_cutoff,int fpt_kappa, int nn_oversampled); \
 NFFT_EXTERN void X(trafo)(X(plan) *plan_nfsoft); \
 NFFT_EXTERN void X(adjoint)(X(plan) *plan_nfsoft); \
 NFFT_EXTERN void X(finalize)(X(plan) *plan); \
@@ -877,7 +878,14 @@ void Y(upd_axpy_complex)(C *x, R a, C *y, NFFT_INT n); \
 /** Swaps each half over N[d]/2. */ \
 void Y(fftshift_complex)(C *x, NFFT_INT d, NFFT_INT* N); \
 void Y(fftshift_complex_int)(C *x, int d, int* N); \
-void Y(get_version)(unsigned *major, unsigned *minor, unsigned *patch);
+/** Return library version. */ \
+void Y(get_version)(unsigned *major, unsigned *minor, unsigned *patch); \
+/** \
+ * Return name of window function. \
+ * \
+ * The window function to be used is configured at compile time. \
+ */ \
+const char *Y(get_window_name)();
 
 NFFT_DEFINE_UTIL_API(NFFT_MANGLE_FLOAT,float,fftwf_complex)
 NFFT_DEFINE_UTIL_API(NFFT_MANGLE_DOUBLE,double,fftw_complex)
diff --git a/include/nfft3mp.h b/include/nfft3mp.h
index de707c8..c308938 100644
--- a/include/nfft3mp.h
+++ b/include/nfft3mp.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2012 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/include/solver_adjoint.h b/include/solver_adjoint.h
index 0d95f4c..e5c1384 100644
--- a/include/solver_adjoint.h
+++ b/include/solver_adjoint.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/include/ticks.h.in b/include/ticks.h.in
index afbf363..b6308c4 100644
--- a/include/ticks.h.in
+++ b/include/ticks.h.in
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/kernel/fpt/fpt.c b/kernel/fpt/fpt.c
index 4ffb47b..896b432 100644
--- a/kernel/fpt/fpt.c
+++ b/kernel/fpt/fpt.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/kernel/fpt/fpt.h b/kernel/fpt/fpt.h
index ea4ead8..146d2cb 100644
--- a/kernel/fpt/fpt.h
+++ b/kernel/fpt/fpt.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/kernel/mri/mri.c b/kernel/mri/mri.c
index 15218b8..91fa4e1 100644
--- a/kernel/mri/mri.c
+++ b/kernel/mri/mri.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/kernel/nfct/nfct.c b/kernel/nfct/nfct.c
index 16778d0..5c53a38 100644
--- a/kernel/nfct/nfct.c
+++ b/kernel/nfct/nfct.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
@@ -726,7 +726,7 @@ void X(trafo)(X(plan) *ths)
         full_psi__A(ths);*/
 
       /* Set \f$ f_j = \sum_{l \in I_n,m(x_j)} g_l \psi\left(x_j-\frac{l}{n}\right)
-       * \text{ for } j=0,\hdots,M-1 \f$ */
+       * \text{ for } j=0,\dots,M-1 \f$ */
       TIC(2)
       B_A(ths);
       TOC(2)
diff --git a/kernel/nfft/nfft.c b/kernel/nfft/nfft.c
index d5d7fe6..1c43e29 100644
--- a/kernel/nfft/nfft.c
+++ b/kernel/nfft/nfft.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
@@ -2478,6 +2478,12 @@ static void nfft_adjoint_1d_B(X(plan) *ths)
 
 void X(trafo_1d)(X(plan) *ths)
 {
+  if((ths->N[0] <= ths->m) || (ths->n[0] <= 2*ths->m+2))
+  {
+    X(trafo_direct)(ths);
+    return;
+  }
+  
   const INT N = ths->N[0], N2 = N/2, n = ths->n[0];
   C *f_hat1 = (C*)ths->f_hat, *f_hat2 = (C*)&ths->f_hat[N2];
 
@@ -2540,6 +2546,12 @@ void X(trafo_1d)(X(plan) *ths)
 
 void X(adjoint_1d)(X(plan) *ths)
 {
+  if((ths->N[0] <= ths->m) || (ths->n[0] <= 2*ths->m+2))
+  {
+    X(adjoint_direct)(ths);
+    return;
+  }
+  
   INT n,N;
   C *g_hat1,*g_hat2,*f_hat1,*f_hat2;
   R *c_phi_inv1, *c_phi_inv2;
@@ -3523,6 +3535,12 @@ static void nfft_adjoint_2d_B(X(plan) *ths)
 
 void X(trafo_2d)(X(plan) *ths)
 {
+  if((ths->N[0] <= ths->m) || (ths->N[1] <= ths->m) || (ths->n[0] <= 2*ths->m+2) || (ths->n[1] <= 2*ths->m+2))
+  {
+    X(trafo_direct)(ths);
+    return;
+  }
+  
   INT k0,k1,n0,n1,N0,N1;
   C *g_hat,*f_hat;
   R *c_phi_inv01, *c_phi_inv02, *c_phi_inv11, *c_phi_inv12;
@@ -3617,6 +3635,12 @@ void X(trafo_2d)(X(plan) *ths)
 
 void X(adjoint_2d)(X(plan) *ths)
 {
+  if((ths->N[0] <= ths->m) || (ths->N[1] <= ths->m) || (ths->n[0] <= 2*ths->m+2) || (ths->n[1] <= 2*ths->m+2))
+  {
+    X(adjoint_direct)(ths);
+    return;
+  }
+  
   INT k0,k1,n0,n1,N0,N1;
   C *g_hat,*f_hat;
   R *c_phi_inv01, *c_phi_inv02, *c_phi_inv11, *c_phi_inv12;
@@ -5114,6 +5138,12 @@ static void nfft_adjoint_3d_B(X(plan) *ths)
 
 void X(trafo_3d)(X(plan) *ths)
 {
+  if((ths->N[0] <= ths->m) || (ths->N[1] <= ths->m) || (ths->N[2] <= ths->m) || (ths->n[0] <= 2*ths->m+2) || (ths->n[1] <= 2*ths->m+2) || (ths->n[2] <= 2*ths->m+2))
+  {
+    X(trafo_direct)(ths);
+    return;
+  }
+  
   INT k0,k1,k2,n0,n1,n2,N0,N1,N2;
   C *g_hat,*f_hat;
   R *c_phi_inv01, *c_phi_inv02, *c_phi_inv11, *c_phi_inv12, *c_phi_inv21, *c_phi_inv22;
@@ -5245,6 +5275,12 @@ void X(trafo_3d)(X(plan) *ths)
 
 void X(adjoint_3d)(X(plan) *ths)
 {
+  if((ths->N[0] <= ths->m) || (ths->N[1] <= ths->m) || (ths->N[2] <= ths->m) || (ths->n[0] <= 2*ths->m+2) || (ths->n[1] <= 2*ths->m+2) || (ths->n[2] <= 2*ths->m+2))
+  {
+    X(adjoint_direct)(ths);
+    return;
+  }
+  
   INT k0,k1,k2,n0,n1,n2,N0,N1,N2;
   C *g_hat,*f_hat;
   R *c_phi_inv01, *c_phi_inv02, *c_phi_inv11, *c_phi_inv12, *c_phi_inv21, *c_phi_inv22;
@@ -5370,6 +5406,16 @@ void X(adjoint_3d)(X(plan) *ths)
  */
 void X(trafo)(X(plan) *ths)
 {
+  /* use direct transform if degree N is too low */
+  for (int j = 0; j < ths->d; j++)
+  {
+    if((ths->N[j] <= ths->m) || (ths->n[j] <= 2*ths->m+2))
+    {
+      X(trafo_direct)(ths);
+      return;
+    }
+  }
+  
   switch(ths->d)
   {
     case 1: X(trafo_1d)(ths); break;
@@ -5397,7 +5443,7 @@ void X(trafo)(X(plan) *ths)
       TOC_FFTW(1)
 
       /** set \f$ f_j =\sum_{l \in I_n,m(x_j)} g_l \psi\left(x_j-\frac{l}{n}\right)
-       *  \text{ for } j=0,\hdots,M_total-1 \f$
+       *  \text{ for } j=0,\dots,M_total-1 \f$
        */
       TIC(2)
       B_A(ths);
@@ -5408,6 +5454,16 @@ void X(trafo)(X(plan) *ths)
 
 void X(adjoint)(X(plan) *ths)
 {
+  /* use direct transform if degree N is too low */
+  for (int j = 0; j < ths->d; j++)
+  {
+    if((ths->N[j] <= ths->m) || (ths->n[j] <= 2*ths->m+2))
+    {
+      X(adjoint_direct)(ths);
+      return;
+    }
+  }
+  
   switch(ths->d)
   {
     case 1: X(adjoint_1d)(ths); break;
@@ -5892,9 +5948,11 @@ const char* X(check)(X(plan) *ths)
   {
     if (ths->sigma[j] <= 1)
       return "Oversampling factor too small";
-
+    
+    /* Automatically calls trafo_direct if 
     if(ths->N[j] <= ths->m)
-      return "Polynomial degree N is smaller than cut-off m";
+      return "Polynomial degree N is <= cut-off m";
+    */
 
     if(ths->N[j]%2 == 1)
       return "polynomial degree N has to be even";
diff --git a/kernel/nfsft/api.h b/kernel/nfsft/api.h
index a43625f..5bc3ae6 100644
--- a/kernel/nfsft/api.h
+++ b/kernel/nfsft/api.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/kernel/nfsft/legendre.c b/kernel/nfsft/legendre.c
index 10bf76e..33cbd4e 100644
--- a/kernel/nfsft/legendre.c
+++ b/kernel/nfsft/legendre.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/kernel/nfsft/legendre.h b/kernel/nfsft/legendre.h
index 7ee17b2..ea687be 100644
--- a/kernel/nfsft/legendre.h
+++ b/kernel/nfsft/legendre.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/kernel/nfsft/nfsft.c b/kernel/nfsft/nfsft.c
index a66de0f..e410ba5 100644
--- a/kernel/nfsft/nfsft.c
+++ b/kernel/nfsft/nfsft.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/kernel/nfsoft/nfsoft.c b/kernel/nfsoft/nfsoft.c
old mode 100755
new mode 100644
index 549257a..58aceb6
--- a/kernel/nfsoft/nfsoft.c
+++ b/kernel/nfsoft/nfsoft.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
@@ -52,6 +52,13 @@ void nfsoft_init_guru(nfsoft_plan *plan, int B, int M,
     unsigned int nfsoft_flags, unsigned int nfft_flags, int nfft_cutoff,
     int fpt_kappa)
 {
+	nfsoft_init_guru_advanced(plan, B, M, nfsoft_flags, nfft_flags, nfft_cutoff, fpt_kappa, 8* B);
+}
+
+void nfsoft_init_guru_advanced(nfsoft_plan *plan, int B, int M,
+    unsigned int nfsoft_flags, unsigned int nfft_flags, int nfft_cutoff,
+    int fpt_kappa, int nn_oversampled)
+{
   int N[3];
   int n[3];
 
@@ -59,9 +66,9 @@ void nfsoft_init_guru(nfsoft_plan *plan, int B, int M,
   N[1] = 2* B + 2;
   N[2] = 2* B + 2;
 
-  n[0] = 8* B ;
-  n[1] = 8* B ;
-  n[2] = 8* B ;
+  n[0] = nn_oversampled ;
+  n[1] = nn_oversampled ;
+  n[2] = nn_oversampled ;
 
   nfft_init_guru(&plan->p_nfft, 3, N, M, n, nfft_cutoff, nfft_flags,
       FFTW_ESTIMATE | FFTW_DESTROY_INPUT);
@@ -142,7 +149,7 @@ static void c2e(nfsoft_plan *my_plan, int even)
     }
 
   }
-  free(aux);
+  nfft_free(aux);
   aux = NULL;
 }
 
@@ -206,9 +213,9 @@ static fpt_set SO3_fpt_init(int l, unsigned int flags, int kappa)
       glo++;
     }
 
-  free(alpha);
-  free(beta);
-  free(gamma);
+  nfft_free(alpha);
+  nfft_free(beta);
+  nfft_free(gamma);
   alpha = NULL;
   beta = NULL;
   gamma = NULL;
@@ -273,9 +280,9 @@ static fpt_set SO3_single_fpt_init(int l, int k, int m, unsigned int flags, int
 
   fpt_precompute(set, 0, alpha, beta, gamma, k_start, kappa);
 
-  free(alpha);
-  free(beta);
-  free(gamma);
+  nfft_free(alpha);
+  nfft_free(beta);
+  nfft_free(gamma);
   alpha = NULL;
   beta = NULL;
   gamma = NULL;
@@ -353,8 +360,8 @@ void SO3_fpt(C *coeffs, fpt_set set, int l, int k, int m, unsigned int flags)
 
   /** Free memory. */
 
-  free(x);
-  free(y);
+  nfft_free(x);
+  nfft_free(y);
   x = NULL;
   y = NULL;
 }
@@ -422,8 +429,8 @@ void SO3_fpt_transposed(C *coeffs, fpt_set set, int l, int k, int m,
   }
 
   /** Free memory. */
-  free(x);
-  free(y);
+  nfft_free(x);
+  nfft_free(y);
   x = NULL;
   y = NULL;
 }
@@ -685,9 +692,9 @@ void nfsoft_finalize(nfsoft_plan *plan)
 {
   /* Finalise the nfft plan. */
   nfft_finalize(&plan->p_nfft);
-  free(plan->wig_coeffs);
-  free(plan->cheby);
-  free(plan->aux);
+  nfft_free(plan->wig_coeffs);
+  nfft_free(plan->cheby);
+  nfft_free(plan->aux);
 
   fpt_finalize(plan->internal_fpt_set);
   plan->internal_fpt_set = NULL;
@@ -695,21 +702,21 @@ void nfsoft_finalize(nfsoft_plan *plan)
   if (plan->flags & NFSOFT_MALLOC_F_HAT)
   {
     //fprintf(stderr,"deallocating f_hat\n");
-    free(plan->f_hat);
+    nfft_free(plan->f_hat);
   }
 
   /* De-allocate memory for samples, if neccesary. */
   if (plan->flags & NFSOFT_MALLOC_F)
   {
     //fprintf(stderr,"deallocating f\n");
-    free(plan->f);
+    nfft_free(plan->f);
   }
 
   /* De-allocate memory for nodes, if neccesary. */
   if (plan->flags & NFSOFT_MALLOC_X)
   {
     //fprintf(stderr,"deallocating x\n");
-    free(plan->x);
+    nfft_free(plan->x);
   }
 }
 
diff --git a/kernel/nfsoft/wigner.c b/kernel/nfsoft/wigner.c
old mode 100755
new mode 100644
index 6649e00..11adbd9
--- a/kernel/nfsoft/wigner.c
+++ b/kernel/nfsoft/wigner.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/kernel/nfsoft/wigner.h b/kernel/nfsoft/wigner.h
old mode 100755
new mode 100644
index 4e38d87..7cf1a7f
--- a/kernel/nfsoft/wigner.h
+++ b/kernel/nfsoft/wigner.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/kernel/nfst/nfst.c b/kernel/nfst/nfst.c
index 6c80c49..51af682 100644
--- a/kernel/nfst/nfst.c
+++ b/kernel/nfst/nfst.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
@@ -725,7 +725,7 @@ void X(trafo)(X(plan) *ths)
         full_psi__A(ths);*/
 
       /* Set \f$ f_j = \sum_{l \in I_n,m(x_j)} g_l \psi\left(x_j-\frac{l}{n}\right)
-       * \text{ for } j=0,\hdots,M-1 \f$ */
+       * \text{ for } j=0,\dots,M-1 \f$ */
       TIC(2)
       B_A(ths);
       TOC(2)
diff --git a/kernel/nnfft/nnfft.c b/kernel/nnfft/nnfft.c
index 5f8a863..e7de30d 100644
--- a/kernel/nnfft/nnfft.c
+++ b/kernel/nnfft/nnfft.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/kernel/nsfft/nsfft.c b/kernel/nsfft/nsfft.c
index 516e647..1e96516 100644
--- a/kernel/nsfft/nsfft.c
+++ b/kernel/nsfft/nsfft.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/kernel/solver/solver.c b/kernel/solver/solver.c
index 084744f..d8c4d58 100644
--- a/kernel/solver/solver.c
+++ b/kernel/solver/solver.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/kernel/util/assert.c b/kernel/util/assert.c
index 652098d..48e3e34 100644
--- a/kernel/util/assert.c
+++ b/kernel/util/assert.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/kernel/util/bessel_i0.c b/kernel/util/bessel_i0.c
index 2f5b27d..9d8650f 100644
--- a/kernel/util/bessel_i0.c
+++ b/kernel/util/bessel_i0.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/kernel/util/bspline.c b/kernel/util/bspline.c
index c21c0ee..dd847b3 100644
--- a/kernel/util/bspline.c
+++ b/kernel/util/bspline.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/kernel/util/damp.c b/kernel/util/damp.c
index 9fbca72..cd6cf73 100644
--- a/kernel/util/damp.c
+++ b/kernel/util/damp.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/kernel/util/error.c b/kernel/util/error.c
index 88cdd41..781c8e8 100644
--- a/kernel/util/error.c
+++ b/kernel/util/error.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/kernel/util/float.c b/kernel/util/float.c
index 0e867bc..6b7484b 100644
--- a/kernel/util/float.c
+++ b/kernel/util/float.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
@@ -21,7 +21,7 @@
 R Y(float_property)(const float_property p)
 {
   const R base = FLT_RADIX;
-  const R eps = EPSILON;
+  const R eps = NFFT_EPSILON;
   const R t = MANT_DIG;
   const R emin = MIN_EXP;
   const R emax = MAX_EXP;
@@ -61,9 +61,7 @@ R Y(float_property)(const float_property p)
     first = FALSE;
   }
 
-  if (p == NFFT_EPSILON)
-    return eps;
-  else if (p == NFFT_SAFE__MIN)
+  if (p == NFFT_SAFE__MIN)
     return sfmin;
   else if (p == NFFT_BASE)
     return base;
diff --git a/kernel/util/int.c b/kernel/util/int.c
index c4cf51a..8019fe3 100644
--- a/kernel/util/int.c
+++ b/kernel/util/int.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
@@ -23,50 +23,112 @@ INT Y(exp2i)(const INT a)
   return (1U << a);
 }
 
+/**
+ * Return floor(log2(x)) for an integer input x. If x is zero or negative this
+ * method returns -1.
+ *
+ * see https://graphics.stanford.edu/~seander/bithacks.html#IntegerLogDeBruijn
+ */
 INT Y(log2i)(const INT m)
 {
-  INT l = 0;
-  INT mm = m;
+  /* Special case, zero or negative input. */
+  if (m <= 0)
+    return -1;
 
-  while (mm > 0)
+#if SIZEOF_PTRDIFF_T == 8
+  /* Hash map with return values based on De Bruijn sequence. */
+  static INT debruijn[64] =
   {
-    mm = (mm >> 1);
-    l++;
-  }
-  return (l-1);
+    0, 58, 1, 59, 47, 53, 2, 60, 39, 48, 27, 54, 33, 42, 3, 61, 51, 37, 40, 49,
+    18, 28, 20, 55, 30, 34, 11, 43, 14, 22, 4, 62, 57, 46, 52, 38, 26, 32, 41,
+    50, 36, 17, 19, 29, 10, 13, 21, 56, 45, 25, 31, 35, 16, 9, 12, 44, 24, 15,
+    8, 23, 7, 6, 5, 63
+  };
+
+  register uint64_t v = (uint64_t)(m);
+
+  /* Round down to one less than a power of 2. */
+  v |= v >> 1;
+  v |= v >> 2;
+  v |= v >> 4;
+  v |= v >> 8;
+  v |= v >> 16;
+  v |= v >> 32;
+
+  /* 0x03f6eaf2cd271461 is a hexadecimal representation of a De Bruijn
+   * sequence for binary words of length 6. The binary representation
+   * starts with 000000111111. This is required to make it work with one less
+   * than a power of 2 instead of an actual power of 2.
+   */
+  return debruijn[(uint64_t)(v * 0x03f6eaf2cd271461LU) >> 58];
+#elif SIZEOF_PTRDIFF_T == 4
+  /* Hash map with return values based on De Bruijn sequence. */
+  static INT debruijn[32] =
+  {
+    0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30, 8, 12, 20, 28,
+    15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31
+  };
+
+  register uint32_t v = (uint32_t)(m);
+
+  /* Round down to one less than a power of 2. */
+  v |= v >> 1;
+  v |= v >> 2;
+  v |= v >> 4;
+  v |= v >> 8;
+  v |= v >> 16;
+
+  /* 0x07C4ACDD is a hexadecimal representation of a De Bruijn sequence for
+   * binary words of length 5. The binary representation starts with
+   * 0000011111. This is required to make it work with one less than a power of
+   * 2 instead of an actual power of 2.
+   */
+  return debruijn[(uint32_t)(v * 0x07C4ACDDU) >> 27];
+#else
+#error Incompatible size of ptrdiff_t
+#endif
 }
 
-/** Computes /f$n\ge N/f$ such that /f$n=2^j,\, j\in\mathhb{N}_0/f$.
+/**
+ * Calculate next power of two larger or equal to a given integer value.
+ *
+ * If the input is negative, this method returns -1. As a special case, 2 is
+ * returned when the input is 1. In all other cases, the smallest power of 2
+ * larger or equal to the input is returned.
+ *
+ * see https://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2
  */
-INT Y(next_power_of_2)(const INT N)
+INT Y(next_power_of_2)(const INT x)
 {
-  INT n,i,logn;
-  INT N_is_not_power_of_2=0;
-
-  if (N == 0)
-    return 1;
-  else if (N == 1)
-    return 2;
-  else
-  {
-    n = N;
-    logn = 0;
-    while (n != 1)
+    if (x < 0)
+        return -1;
+    else if (x < 2)
+        return x + 1;
+    else
     {
-      if (n%2 == 1)
-        N_is_not_power_of_2=1;
-      n = n/2;
-      logn++;
+        uint64_t v = (uint64_t)x;
+
+        /* Subtract one, so we return the input if it is a power of two. */
+        v--;
+
+        /* Round down to one less than a power of two. */
+        v |= v >> 1;
+        v |= v >> 2;
+        v |= v >> 4;
+#if SIZEOF_PTRDIFF_T >= 2
+        v |= v >> 8;
+#endif
+#if SIZEOF_PTRDIFF_T >= 4
+        v |= v >> 16;
+#endif
+#if SIZEOF_PTRDIFF_T >= 8
+        v |= v >> 32;
+#endif
+        /* Add one to get power of two. */
+        v++;
+
+        return v;
     }
-
-    if (!N_is_not_power_of_2)
-      logn--;
-
-    for (i = 0; i <= logn; i++)
-      n = n*2;
-
-    return n;
-  }
 }
 
 /** Computes /f$n\ge N/f$ such that /f$n=2^j,\, j\in\mathhb{N}_0/f$.
diff --git a/kernel/util/lambda.c b/kernel/util/lambda.c
index 8688c24..5b922cc 100644
--- a/kernel/util/lambda.c
+++ b/kernel/util/lambda.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/kernel/util/malloc.c b/kernel/util/malloc.c
index 554bcd8..cbd2b35 100644
--- a/kernel/util/malloc.c
+++ b/kernel/util/malloc.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/kernel/util/print.c b/kernel/util/print.c
index b2d7997..84d8217 100644
--- a/kernel/util/print.c
+++ b/kernel/util/print.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/kernel/util/rand.c b/kernel/util/rand.c
index 113a6cb..82fdb79 100644
--- a/kernel/util/rand.c
+++ b/kernel/util/rand.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/kernel/util/sinc.c b/kernel/util/sinc.c
index b9f589f..5b578e4 100644
--- a/kernel/util/sinc.c
+++ b/kernel/util/sinc.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
@@ -21,7 +21,7 @@
 R Y(sinc)(const R x)
 {
   /* Based on sinc function from Boost C++ library. */
-  const R b =  EPSILON;
+  const R b = NFFT_EPSILON;
   const R bs = SQRT(b);
   const R bs2 = SQRT(bs);
 
diff --git a/kernel/util/sort.c b/kernel/util/sort.c
index 27b1664..d5ad490 100644
--- a/kernel/util/sort.c
+++ b/kernel/util/sort.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/kernel/util/thread.c b/kernel/util/thread.c
index fd197f8..f7bfa83 100644
--- a/kernel/util/thread.c
+++ b/kernel/util/thread.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/kernel/util/time.c b/kernel/util/time.c
index 7c68126..bad681e 100644
--- a/kernel/util/time.c
+++ b/kernel/util/time.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/kernel/util/vector1.c b/kernel/util/vector1.c
index 449f3ea..708915c 100644
--- a/kernel/util/vector1.c
+++ b/kernel/util/vector1.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/kernel/util/vector2.c b/kernel/util/vector2.c
index 0268cf8..59a5b9c 100644
--- a/kernel/util/vector2.c
+++ b/kernel/util/vector2.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/kernel/util/vector3.c b/kernel/util/vector3.c
index 3e7c723..2976470 100644
--- a/kernel/util/vector3.c
+++ b/kernel/util/vector3.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/kernel/util/version.c b/kernel/util/version.c
index 753085c..1aae0ac 100644
--- a/kernel/util/version.c
+++ b/kernel/util/version.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/kernel/util/voronoi.c b/kernel/util/voronoi.c
index e5b3b76..d1b80ca 100644
--- a/kernel/util/voronoi.c
+++ b/kernel/util/voronoi.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/kernel/util/window.c b/kernel/util/window.c
index 7236e97..423ed80 100644
--- a/kernel/util/window.c
+++ b/kernel/util/window.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
@@ -16,9 +16,10 @@
  * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
-#include "infft.h"
+#include "api.h"
 
 #if defined(DIRAC_DELTA)
+  static const INT m2K_[] = {0};
 #elif defined(GAUSSIAN)
   static const INT m2K_[] = {0, 1, 3, 6, 7, 9, 11, 13, 15, 17, 19, 21, 22, 23, 24};
 #elif defined(B_SPLINE)
@@ -38,3 +39,8 @@ INT Y(m2K)(const INT m)
   int j = MIN(((int)(m)), ((int)((sizeof(m2K_) / sizeof(m2K_[0])) - 1)));
   return (INT)((1U << m2K_[j]) * (m + 2));
 }
+
+const char *Y(get_window_name)()
+{
+  return STRINGIZE(WINDOW_NAME);
+}
diff --git a/m4/ax_eps_calc.m4 b/m4/ax_eps_calc.m4
new file mode 100644
index 0000000..a4673ef
--- /dev/null
+++ b/m4/ax_eps_calc.m4
@@ -0,0 +1,71 @@
+# Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+# details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, write to the Free Software Foundation, Inc., 51
+# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# @synopsis AX_EPS_CALC
+# @summary Calculate machine epsilon for given floating-point type (d = double, 
+#     f = float, l = long double).
+# @category C
+#
+# @version 2017-08-13
+# @license GPLWithACException
+# @author Jens Keiner <jens at nfft.org>
+AC_DEFUN([AX_EPS_CALC],
+[AC_REQUIRE([AC_PROG_CC])
+AC_LANG_PUSH([C])
+AC_CACHE_CHECK(for floating-point epsilon as per calculation, ax_cv_eps_calc,
+ [AC_RUN_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>
+#define d 1
+#define l 2
+#define s 3
+#define PRECISION $1
+ 
+#if PRECISION == 1
+typedef double R;
+#define __FE__ "%.16lE"
+#define K(x) ((R) x)
+#elif PRECISION == 2
+typedef long double R;
+#define __FE__ "%.32LE"
+#define K(x) ((R) x##L)
+#elif PRECISION == 3
+typedef float R;
+#define __FE__ "%.8E"
+#define K(x) ((R) x)
+#else
+#error "Unknown floating-point precision."
+#endif], [  FILE *f;
+  volatile R eps = K(1.0), one_plus_eps;
+  int i = 0;
+  for (i = 0; i < 100000; i++) {
+    one_plus_eps = K(1.0) + eps;
+    if (one_plus_eps == K(1.0))
+      break;
+    eps /= K(2.0);
+  }
+  if (eps == K(0.0))
+    return 1;
+  if (one_plus_eps != K(1.0))
+    return 1;
+  eps *= K(2.0);
+  f = fopen("conftest_eps_calc", "w"); if (!f) return 1;
+  fprintf(f, __FE__ "\n", eps);
+  fclose(f);
+  return 0;])], 
+  [ax_cv_eps_calc=`cat conftest_eps_calc`; rm -f conftest_eps_calc],
+  [ax_cv_eps_calc=unknown; rm -f conftest_eps_calc],
+  [ax_cv_eps_calc=unknown])])
+AC_LANG_POP([C])
+])
diff --git a/m4/ax_eps_def.m4 b/m4/ax_eps_def.m4
new file mode 100644
index 0000000..8d782c6
--- /dev/null
+++ b/m4/ax_eps_def.m4
@@ -0,0 +1,56 @@
+# Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+# details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, write to the Free Software Foundation, Inc., 51
+# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# @synopsis AX_EPS_DEF
+# @summary Dtermine machine epsilon for given floating-point type (d = double, 
+#     f = float, l = long double) from corresponding macro defined in float.h.
+# @category C
+#
+# @version 2017-08-13
+# @license GPLWithACException
+# @author Jens Keiner <jens at nfft.org>
+AC_DEFUN([AX_EPS_DEF],
+[AC_REQUIRE([AC_PROG_CC])
+AC_LANG_PUSH([C])
+AC_CACHE_CHECK(for floating-point epsilon as per macro, ax_cv_eps_def,
+ [AC_RUN_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>
+#include <float.h>
+#define d 1
+#define l 2
+#define s 3
+#define PRECISION $1
+ 
+#if PRECISION == 1
+#define __FE__ "%.16lE"
+#define EPSILON DBL_EPSILON
+#elif PRECISION == 2
+#define __FE__ "%.32LE"
+#define EPSILON LDBL_EPSILON
+#elif PRECISION == 3
+#define __FE__ "%.8E"
+#define EPSILON FLT_EPSILON
+#else
+#error "Unknown floating-point precision."
+#endif], [  FILE *f;
+  f = fopen("conftest_eps_def", "w"); if (!f) return 1;
+  fprintf(f, __FE__ "\n", EPSILON);
+  fclose(f);
+  return 0;])], 
+  [ax_cv_eps_def=`cat conftest_eps_def`; rm -f conftest_eps_def],
+  [ax_cv_eps_def=unknown; rm -f conftest_eps_def],
+  [ax_cv_eps_def=unknown])])
+AC_LANG_POP([C])
+])
diff --git a/m4/ax_lib_fftw3.m4 b/m4/ax_lib_fftw3.m4
index 35f7d7e..5afb45b 100644
--- a/m4/ax_lib_fftw3.m4
+++ b/m4/ax_lib_fftw3.m4
@@ -1,4 +1,4 @@
-# Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+# Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 #
 # This program is free software; you can redistribute it and/or modify it under
 # the terms of the GNU General Public License as published by the Free Software
@@ -75,8 +75,15 @@ AC_DEFUN([AX_LIB_FFTW3],
     saved_LIBS="$LIBS"
     AC_SEARCH_LIBS([fftw${PREC_SUFFIX}_execute], [fftw3${PREC_SUFFIX} fftw3${PREC_SUFFIX}-3], [ax_lib_fftw3=yes], [ax_lib_fftw3=no], [-lm])
     fftw3_libvar=ac_cv_search_fftw${PREC_SUFFIX}_execute
-    fftw3_libname="${!fftw3_libvar:2}"
-    fftw3_LIBS="-l${fftw3_libname} -lm"
+    if test "x$ac_res" = "xnone required"; then
+      fftw3_libname=""
+      fftw3_lib_flag=""
+      fftw3_LIBS=""
+    else
+      fftw3_libname="${!fftw3_libvar:2}"
+      fftw3_lib_flag="-l${fftw3_libname}"
+      fftw3_LIBS="${fftw3_lib_flag} -lm"
+    fi
     LIBS="$saved_LIBS"
   fi
 
@@ -84,13 +91,17 @@ AC_DEFUN([AX_LIB_FFTW3],
     saved_LIBS="$LIBS"
 
     # Check for combined fftw threads
-    AC_CHECK_LIB([${fftw3_libname}], [fftw${PREC_SUFFIX}_init_threads], [ax_lib_fftw3_threads=yes], [ax_lib_fftw3_threads=no], [-lpthread -lm])
-    fftw3_threads_LIBS="-l${fftw3_libname} -lpthread -lm"
+    LIBS="${fftw3_lib_flag} -lpthread -lm"
+    AC_MSG_CHECKING([for threaded fftw3 library with combined threads (-lpthread -lm set)])
+    AC_LINK_IFELSE([AC_LANG_CALL([], [fftw${PREC_SUFFIX}_init_threads])], [ax_lib_fftw3_threads=yes],[ax_lib_fftw3_threads=no])
+    AC_MSG_RESULT([$ax_lib_fftw3_threads])
+    fftw3_threads_LIBS="${fftw3_lib_flag} -lpthread -lm"
 
+    LIBS="$saved_LIBS"
     # Check for extra fftw threads library
     if test "x$ax_lib_fftw3_threads" = "xno"; then
-      AC_SEARCH_LIBS([fftw${PREC_SUFFIX}_init_threads], [fftw3${PREC_SUFFIX}_threads], [ax_lib_fftw3_threads=yes], [ax_lib_fftw3_threads=no], [-l${fftw3_libname} -lpthread -lm])
-      fftw3_threads_LIBS="-lfftw3${PREC_SUFFIX}_threads -l${fftw3_libname} -lpthread -lm"
+      AC_SEARCH_LIBS([fftw${PREC_SUFFIX}_init_threads], [fftw3${PREC_SUFFIX}_threads], [ax_lib_fftw3_threads=yes], [ax_lib_fftw3_threads=no], [${fftw3_lib_flag} -lpthread -lm])
+      fftw3_threads_LIBS="-lfftw3${PREC_SUFFIX}_threads ${fftw3_lib_flag} -lpthread -lm"
     fi
 
     LIBS="$saved_LIBS"
diff --git a/m4/ax_prog_matlab.m4 b/m4/ax_prog_matlab.m4
index 1e95505..b0010e9 100644
--- a/m4/ax_prog_matlab.m4
+++ b/m4/ax_prog_matlab.m4
@@ -1,4 +1,4 @@
-# Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+# Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 #
 # This program is free software; you can redistribute it and/or modify it under
 # the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/Makefile.am b/matlab/Makefile.am
index 0828b90..840099f 100644
--- a/matlab/Makefile.am
+++ b/matlab/Makefile.am
@@ -12,13 +12,31 @@ endif
 
 DIR_NFFT=nfft
 
+if HAVE_NFCT
+  DIR_NFCT=nfct
+else
+  DIR_NFCT=
+endif
+
+if HAVE_NFST
+  DIR_NFST=nfst
+else
+  DIR_NFST=
+endif
+
 if HAVE_NNFFT
   DIR_NNFFT=nnfft
 else
   DIR_NNFFT=
 endif
 
-SUBDIRS = . $(DIR_NFFT) $(DIR_NFSFT) $(DIR_NFSOFT) $(DIR_NNFFT)
+if HAVE_APPLICATIONS
+  DIR_FASTSUM=fastsum
+else
+  DIR_FASTSUM=
+endif
+
+SUBDIRS = . $(DIR_NFFT) $(DIR_NFCT) $(DIR_NFST) $(DIR_NFSFT) $(DIR_NFSOFT) $(DIR_NNFFT) $(DIR_FASTSUM)
 
 AM_CPPFLAGS = -I$(top_srcdir)/include $(matlab_CPPFLAGS)
 
diff --git a/matlab/args.c b/matlab/args.c
index cc048a6..d3b4050 100644
--- a/matlab/args.c
+++ b/matlab/args.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/fastsum/Contents.m b/matlab/fastsum/Contents.m
new file mode 100644
index 0000000..e69de29
diff --git a/matlab/nnfft/nnfftmex.m b/matlab/fastsum/EXACT_NEARFIELD.m
similarity index 77%
copy from matlab/nnfft/nnfftmex.m
copy to matlab/fastsum/EXACT_NEARFIELD.m
index 55c8b9a..f423cec 100644
--- a/matlab/nnfft/nnfftmex.m
+++ b/matlab/fastsum/EXACT_NEARFIELD.m
@@ -1,7 +1,9 @@
-%NFFTMEX Gateway function to NFFT module from NFFT3
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% EXACT_NEARFIELD
+%   Return identity.
+%
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -16,4 +18,5 @@
 % You should have received a copy of the GNU General Public License along with
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-%
+function f = EXACT_NEARFIELD()
+f = 1;
\ No newline at end of file
diff --git a/matlab/fastsum/Makefile.am b/matlab/fastsum/Makefile.am
new file mode 100644
index 0000000..66efd47
--- /dev/null
+++ b/matlab/fastsum/Makefile.am
@@ -0,0 +1,38 @@
+# compiler flags
+AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/applications/fastsum -I$(top_srcdir)/matlab $(matlab_CPPFLAGS)
+
+# matlab wrapper directory
+fastsummatlabdir = $(datadir)/nfft/matlab/fastsum
+
+# library
+lib_LTLIBRARIES = libfastsum.la
+libfastsum_la_SOURCES = fastsummex.c
+
+libfastsum_la_LIBADD = $(top_builddir)/libnfft3_matlab.la @matlab_fftw3_LIBS@ $(top_builddir)/matlab/libmatlab.la $(matlab_LIBS)
+
+libfastsum_la_LDFLAGS = -no-undefined -module -shared -shrext $(matlab_mexext) -avoid-version @matlab_fftw3_LDFLAGS@ $(matlab_LDFLAGS)
+
+if HAVE_MATLAB_THREADS
+libfastsum_la_CFLAGS = $(OPENMP_CFLAGS)
+endif
+
+
+dist_fastsummatlab_DATA = Contents.m EXACT_NEARFIELD.m NEARFIELD_BOXES.m fastsum.m fastsum_get_num_threads.m fastsum_init.m fastsum_set_x.m fastsum_set_alpha.m fastsum_set_y.m fastsum_trafo.m fastsum_trafo_direct.m fastsum_get_f.m fastsum_finalize.m test_fastsum.m
+
+# target all-am builds .libs/libfastsum at matlab_mexext@
+fastsummex at matlab_mexext@: all-am 
+	rm -f ./fastsummex at matlab_mexext@
+	$(LN_S) .libs/libfastsum at matlab_mexext@ ./fastsummex at matlab_mexext@
+
+all: all-am fastsummex at matlab_mexext@
+
+clean: clean-am
+	rm -f ./fastsummex at matlab_mexext@
+
+install-exec-hook:
+	rm -f $(libdir)/fastsummex at matlab_mexext@
+	$(LN_S) $(libdir)/libfastsum at matlab_mexext@ $(libdir)/fastsummex at matlab_mexext@
+
+uninstall-hook:
+	rm -f $(libdir)/fastsummex at matlab_mexext@
+
diff --git a/matlab/nnfft/nnfftmex.m b/matlab/fastsum/NEARFIELD_BOXES.m
similarity index 79%
copy from matlab/nnfft/nnfftmex.m
copy to matlab/fastsum/NEARFIELD_BOXES.m
index 55c8b9a..b82cf88 100644
--- a/matlab/nnfft/nnfftmex.m
+++ b/matlab/fastsum/NEARFIELD_BOXES.m
@@ -1,7 +1,7 @@
-%NFFTMEX Gateway function to NFFT module from NFFT3
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%NEARFIELD_BOXES
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -16,4 +16,5 @@
 % You should have received a copy of the GNU General Public License along with
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-%
+function f = NEARFIELD_BOXES()
+f = 2;
\ No newline at end of file
diff --git a/matlab/fastsum/fastsum.m b/matlab/fastsum/fastsum.m
new file mode 100644
index 0000000..5196425
--- /dev/null
+++ b/matlab/fastsum/fastsum.m
@@ -0,0 +1,355 @@
+
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
+%
+% This program is free software; you can redistribute it and/or modify it under
+% the terms of the GNU General Public License as published by the Free Software
+% Foundation; either version 2 of the License, or (at your option) any later
+% version.
+%
+% This program is distributed in the hope that it will be useful, but WITHOUT
+% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+% FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+% details.
+%
+% You should have received a copy of the GNU General Public License along with
+% this program; if not, write to the Free Software Foundation, Inc., 51
+% Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+% This class provides a Matlab interface to the FASTSUM application.
+classdef fastsum < handle
+
+properties(Dependent=true)
+	x           % source nodes in d-ball with radius 1/4-eps_b/2 (real Nxd matrix)
+	alpha       % fourier coefficients (column vector of length N)
+	y           % target nodes in d-ball with radius 1/4-eps_b/2 (real Mxd matrix)
+end %properties
+
+properties(Dependent=true,SetAccess='private')
+    f;          % function evaluations in y
+    b;          % expansion coefficients
+    N;          % number of source nodes
+end %properties
+
+properties(SetAccess='private')
+	d               % spatial dimension 
+    kernel          % kernel
+    c               % kernel parameter
+    flags  = 0      % flags
+    n               % expansion degree (of NFFT)
+    p               % degree of smoothness of regularization
+    eps_I           % inner boundary
+    eps_B           % outer boundary
+    nn_x            % oversampled nn in x
+    nn_y            % oversampled nn in y
+    m_x             % NFFT-cutoff in x
+    m_y             % NFFT-cutoff in y
+end %properties
+
+properties(Hidden=true,SetAccess='private',GetAccess='private')
+	plan
+	x_is_set=false      % flag if x is set
+	y_is_set=false      % flag if y is set
+	alpha_is_set=false  % flag if alpha is set
+	f_is_set=false      % flag if f is set
+	plan_is_set=false   % flag if plan was created
+end %properties
+
+methods
+
+% Constructer and destructor %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+function h=fastsum(d,kernel,c,flags,n,p,eps_I,eps_B,nn_x,m_x,nn_y,m_y)
+% Constructor
+%
+% h=fastsum(d,kernel,c,flags,n,p,eps_I,eps_B)
+% h=fastsum(d,kernel,c,flags,n,p,eps_I,eps_B,nn,m)
+% h=fastsum(d,kernel,c,flags,n,p,eps_I,eps_B,nn_x,m_x,nn_y,m_y)
+%
+% INPUT
+% kernel = 'multiquadric', etc. (see options below)
+% c       kernel parameter
+% n       expansion degree
+% m       cut-off parameter for NFFT
+% p       degree of smoothness of regularization
+% eps_I   inner boundary
+% eps_B   outer boundary
+% nn      oversampled nn in NFFT (in x and y)
+% m       cut-off parameter for NFFT (in x and y)
+% nn_x    oversampled nn in NFFT (in x)
+% m_x     cut-off parameter for NFFT (in x)
+% nn_y    oversampled nn in NFFT (in y)
+% m_y     cut-off parameter for NFFT (in y)
+%
+% OUTPUT
+%   h   object of class type fastsum
+    narginchk(8,12);
+
+	h.d = d;
+    h.kernel = kernel;
+    h.c = c;
+    h.flags = flags;
+    h.n = n;
+    h.p = p;
+    h.eps_I = eps_I;
+    h.eps_B = eps_B;
+    
+    switch nargin
+    case 8
+        h.nn_x = 2*n;   % default oversampling factor 2
+        h.nn_y = 2*n;
+        h.m_x = p;      % default NFFT-cutoff
+        h.m_y = p;
+    case 10
+        h.nn_x=nn_x;
+        h.nn_y=nn_x;
+        h.m_x=m_x;
+        h.m_y=m_x;
+    case 12
+        h.nn_x=nn_x;
+        h.nn_y=nn_y;
+        h.m_x=m_x;
+        h.m_y=m_y;
+    otherwise
+        error('Wrong number of arguments')
+    end
+    
+    if nn_x<=h.n || nn_x<=h.n
+        error('Oversampled nn must be larger than n')
+    end
+    
+    h.plan=fastsummex('init',h.d,h.kernel,h.c,h.flags,h.n,h.p,h.eps_I,h.eps_B);
+    h.plan_is_set=true;
+end %function
+
+function delete(h)
+% Destructor
+	if(h.plan_is_set)
+		fastsummex('finalize',h.plan);
+	end %if
+end %function
+
+% Set functions %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+function set.x(h,x)
+    if (size(x,2)~=h.d || ~isreal(x))
+        error('x must be a real matrix with d columns');
+    end
+    if h.x_is_set && h.alpha_is_set && size(x,1)~=h.N
+        warning('fastsum:alphaDeleted',...
+            'Size of x has changed, so alpha is deleted');
+        h.alpha_is_set=false;
+    end
+    fastsummex('set_x',h.plan,x,h.nn_x,h.m_x)
+    h.x_is_set = true;
+end %function
+
+function set.alpha(h,alpha)
+    if ~h.x_is_set
+        error('You have to set x before you set alpha')
+    end
+    if (~iscolumn(alpha) || ~isnumeric(alpha) || length(alpha)~=h.N)
+        error('alpha must be a column vector of length N');
+    end
+    fastsummex('set_alpha',h.plan,alpha)
+    h.alpha_is_set=true;
+end %function
+
+function set.y(h,y)
+    if (size(y,2)~=h.d || ~isreal(y))
+        error('y must be a real matrix with d columns');
+    end
+    fastsummex('set_y',h.plan,y,h.nn_y,h.m_y)
+    h.y_is_set = true;
+end %function
+
+function set.d(h,d)
+    if (~isscalar(d) || ~isreal(d) || d<=0 || mod(d,1)~=0)
+        error('d must be a positive integer')
+    end
+    h.d = d;
+end %function
+
+function set.flags(h,n)
+    if (~isscalar(n) || ~isreal(n) || n<0 || mod(n,1)~=0)
+        error('flags must be a non-negative integer')
+    end
+    h.flags = n;
+end %function
+
+function set.n(h,n)
+    if (~isscalar(n) || ~isreal(n) || n<=0 || mod(n,2)~=0)
+        error('n must be a positive, even integer')
+    end
+    h.n = n;
+end %function
+
+function set.p(h,p)
+    if (~isscalar(p) || ~isreal(p) || p<=0 || mod(p,1)~=0)
+        error('p must be a positive integer')
+    end
+    h.p = p;
+end %function
+
+function set.eps_I(h,arg)
+    if (~isscalar(arg) || arg<0 || arg>=pi/4)
+        error('eps_I must be in the interval [0,pi/4)')
+    end
+    h.eps_I = arg;
+end %function
+
+function set.eps_B(h,arg)
+    if (~isscalar(arg) || arg<0 || arg>=pi/4)
+        error('eps_B must be in the interval [0,pi/4)')
+    end
+    h.eps_B = arg;
+end %function
+
+function set.nn_x(h,arg)
+    if (~isscalar(arg) || ~isreal(arg) || arg<=0 || mod(arg,1)~=0)
+        error('nn_x must be a positive integer')
+    end
+    h.nn_x = arg;
+end %function
+
+function set.m_x(h,arg)
+    if (~isscalar(arg) || ~isreal(arg) || arg<=0 || mod(arg,1)~=0)
+        error('m_x must be a positive integer')
+    end
+    h.m_x = arg;
+end %function
+
+function set.nn_y(h,arg)
+    if (~isscalar(arg) || ~isreal(arg) || arg<=0 || mod(arg,1)~=0)
+        error('nn_y must be a positive integer')
+    end
+    h.nn_y = arg;
+end %function
+
+function set.m_y(h,arg)
+    if (~isscalar(arg) || ~isreal(arg) || arg<=0 || mod(arg,1)~=0)
+        error('m_y must be a positive integer')
+    end
+    h.m_y = arg;
+end %function
+
+
+% Get functions %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+function x=get.x(h)
+    if h.x_is_set
+        x=fastsummex('get_x',h.plan);
+    else
+        x=[];
+    end
+end %function
+
+function alpha=get.alpha(h)
+    if h.alpha_is_set
+        alpha=fastsummex('get_alpha',h.plan);
+    else
+        alpha=[];
+    end
+end %function
+
+function y=get.y(h)
+    if h.y_is_set
+        y=fastsummex('get_y',h.plan);
+    else
+        y=[];
+    end
+end %function
+
+function b=get.b(h)
+	if(h.plan_is_set)
+		b=fastsummex('get_b',h.plan);
+	else
+		b=[];
+	end %if
+end %function
+
+function f=get.f(h)
+	if(h.f_is_set)
+		f=fastsummex('get_f',h.plan);
+	else
+		f=[];
+	end %if
+end %function
+
+function N=get.N(h)
+	if(h.x_is_set)
+		N=fastsummex('get_N_total',h.plan);
+	else
+		N=[];
+	end %if
+end %function
+
+% User methods %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+function fastsum_trafo(h)
+% NFFT.fastsum
+%
+% fastsum_trafo(h)
+%
+% INPUT
+%   h  object of class type nfft
+    if(~h.x_is_set)
+		error('Before doing a fastsum transform you have to set nodes x.');
+    end
+    if(~h.alpha_is_set)
+		error('Before doing a fastsum transform you have to set coefficients alpha.');
+    end
+    if(~h.y_is_set)
+		error('Before doing a fastsum transform you have to set nodes y.');
+    end
+        
+	fastsummex('trafo',h.plan);
+	h.f_is_set=true;
+end %function
+
+function fastsum_trafo_direct(h)
+% NFFT.fastsum
+%
+% fastsum_trafo_direct(h)
+%
+% INPUT
+%   h  object of class type nfft
+    if(~h.x_is_set)
+		error('Before doing a fastsum transform you have to set nodes x.');
+    end
+    if(~h.alpha_is_set)
+		error('Before doing a fastsum transform you have to set coefficients alpha.');
+    end
+    if(~h.y_is_set)
+		error('Before doing a fastsum transform you have to set nodes y.');
+    end
+    
+    fastsummex('trafo_direct',h.plan);
+    h.f_is_set=true;
+end %function
+
+% Save and load %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+function s = saveobj(h)
+    s=struct('x',h.x,'y',h.y,'alpha',h.alpha,'d',h.d,'kernel',h.kernel,'c',h.c,...
+        'flags',h.flags,'n',h.n,'p',h.p,'eps_I',h.eps_I,'eps_B',h.eps_B,...
+        'nn_x',h.nn_x,'nn_y',h.nn_y,'m_x',h.m_x,'m_y',h.m_y);
+end
+
+end %methods
+
+methods(Static)
+function h = loadobj(s)
+    h=fastsum(s.d,s.kernel,s.c,s.flags,s.n,s.p,s.eps_I,s.eps_B,...
+        s.nn_x,s.m_x,s.nn_y,s.m_y);
+    if ~isempty(s.x)
+        h.x=s.x;
+    end
+    if ~isempty(s.alpha)
+        h.alpha=s.alpha;
+    end
+    if ~isempty(s.y)
+        h.y=s.y;
+    end
+end
+end %methods
+end %classdef
\ No newline at end of file
diff --git a/matlab/nfft/nfftmex.m b/matlab/fastsum/fastsum_finalize.m
similarity index 76%
copy from matlab/nfft/nfftmex.m
copy to matlab/fastsum/fastsum_finalize.m
index 55c8b9a..ae0026e 100644
--- a/matlab/nfft/nfftmex.m
+++ b/matlab/fastsum/fastsum_finalize.m
@@ -1,7 +1,8 @@
-%NFFTMEX Gateway function to NFFT module from NFFT3
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%FASTSUM_FINALIZE Finalize plan.
+%
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -16,4 +17,5 @@
 % You should have received a copy of the GNU General Public License along with
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-%
+function f = fastsum_finalize(plan)
+fastsummex('finalize',plan);
\ No newline at end of file
diff --git a/matlab/nfft/nfft_adjoint.m b/matlab/fastsum/fastsum_get_f.m
similarity index 75%
copy from matlab/nfft/nfft_adjoint.m
copy to matlab/fastsum/fastsum_get_f.m
index 3272b5d..c3cc408 100644
--- a/matlab/nfft/nfft_adjoint.m
+++ b/matlab/fastsum/fastsum_get_f.m
@@ -1,7 +1,7 @@
-%NFFT_ADJOINT Adjoint nonequispaced fast Fourier transform
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%FASTSUM_GET_F Get function values from plan.
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -16,6 +16,5 @@
 % You should have received a copy of the GNU General Public License along with
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-function nfft_adjoint(p)
-
-nfftmex('adjoint',p)
+function f = fastsum_get_f(plan)
+f = fastsummex('get_f',plan);
\ No newline at end of file
diff --git a/matlab/nfft/FFTW_MEASURE.m b/matlab/fastsum/fastsum_get_num_threads.m
similarity index 71%
copy from matlab/nfft/FFTW_MEASURE.m
copy to matlab/fastsum/fastsum_get_num_threads.m
index bbdd8c8..d165eda 100644
--- a/matlab/nfft/FFTW_MEASURE.m
+++ b/matlab/fastsum/fastsum_get_num_threads.m
@@ -1,9 +1,8 @@
-%FFTW_MEASURE FFT flag
-%   Valid for FFTW3
+%FASTSUM_GET_NUM_THREADS Get maximum number of threads used for computation.
 %
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -18,6 +17,5 @@
 % You should have received a copy of the GNU General Public License along with
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-function f = FFTW_MEASURE()
-
-f = 0;
+function nthreads = fastsum_get_num_threads()
+nthreads = fastsummex('get_num_threads');
diff --git a/matlab/nfft/FFT_OUT_OF_PLACE.m b/matlab/fastsum/fastsum_init.m
similarity index 71%
copy from matlab/nfft/FFT_OUT_OF_PLACE.m
copy to matlab/fastsum/fastsum_init.m
index 2bb217e..03ffab7 100644
--- a/matlab/nfft/FFT_OUT_OF_PLACE.m
+++ b/matlab/fastsum/fastsum_init.m
@@ -1,9 +1,8 @@
-%FFT_OUT_OF_PLACE FFT flag
-%   If this flag is set, FFTW uses disjoint input/output vectors.
+%FASTSUM_INIT Initialise plan.
 %
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -18,6 +17,5 @@
 % You should have received a copy of the GNU General Public License along with
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-function f = FFT_OUT_OF_PLACE()
-
-f = bitshift(1, 9);
+function plan=fastsum_init(d,kernel,c,flags,n,p,eps_I,eps_B)
+plan = fastsummex('init',d,kernel,c,flags,n,p,eps_I,eps_B);
diff --git a/matlab/nfft/nfftmex.m b/matlab/fastsum/fastsum_set_alpha.m
similarity index 74%
copy from matlab/nfft/nfftmex.m
copy to matlab/fastsum/fastsum_set_alpha.m
index 55c8b9a..61a69bc 100644
--- a/matlab/nfft/nfftmex.m
+++ b/matlab/fastsum/fastsum_set_alpha.m
@@ -1,7 +1,8 @@
-%NFFTMEX Gateway function to NFFT module from NFFT3
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%FASTSUM_SET_ALPHA Set source coefficients.
+%
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -16,4 +17,5 @@
 % You should have received a copy of the GNU General Public License along with
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-%
+function fastsum_set_alpha(plan,alpha)
+fastsummex('set_alpha',plan,alpha);
\ No newline at end of file
diff --git a/matlab/nfft/nfftmex.m b/matlab/fastsum/fastsum_set_x.m
similarity index 73%
copy from matlab/nfft/nfftmex.m
copy to matlab/fastsum/fastsum_set_x.m
index 55c8b9a..36ee93f 100644
--- a/matlab/nfft/nfftmex.m
+++ b/matlab/fastsum/fastsum_set_x.m
@@ -1,7 +1,8 @@
-%NFFTMEX Gateway function to NFFT module from NFFT3
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%FASTSUM_SET_X Set source nodes in plan.
+%
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -16,4 +17,5 @@
 % You should have received a copy of the GNU General Public License along with
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-%
+function fastsum_set_x(plan,x,nn_oversampled,m)
+fastsummex('set_x',plan,x,nn_oversampled,m);
diff --git a/matlab/nfft/nfftmex.m b/matlab/fastsum/fastsum_set_y.m
similarity index 73%
copy from matlab/nfft/nfftmex.m
copy to matlab/fastsum/fastsum_set_y.m
index 55c8b9a..1de7f55 100644
--- a/matlab/nfft/nfftmex.m
+++ b/matlab/fastsum/fastsum_set_y.m
@@ -1,7 +1,8 @@
-%NFFTMEX Gateway function to NFFT module from NFFT3
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%FASTSUM_SET_Y Set target nodes in plan.
+%
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -16,4 +17,5 @@
 % You should have received a copy of the GNU General Public License along with
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-%
+function fastsum_set_y(plan,y,nn_oversampled,m)
+fastsummex('set_y',plan,y,nn_oversampled,m);
\ No newline at end of file
diff --git a/matlab/fastsum/fastsum_simple.m b/matlab/fastsum/fastsum_simple.m
new file mode 100644
index 0000000..6d796c9
--- /dev/null
+++ b/matlab/fastsum/fastsum_simple.m
@@ -0,0 +1,86 @@
+%FASTSUM_SIMPLE Compute fast and, optionally, direct fast summation.
+%
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
+%
+% Computes the sums
+% 
+%   f(y_j) = sum_{k=1}^N alpha_k kernel(x_k-y_j)   (j=1:M)
+% 
+% Calling:
+%   f = fastsum(x,alpha,y,kernel,c,m,n,p,eps_I,eps_B)
+%   [f,f_direct] = fastsum(x,alpha,y,kernel,c,m,n,p,eps_I,eps_B)
+% 
+% Output:
+% f           fast summation
+% f_direct    computed with direct summation
+% 
+% Input:
+% size(x)     = [N,d]   source knots in d-ball with radius 1/4-eps_b/2
+% size(alpha) = [N,1]   source coefficients (complex)
+% size(y)     = [M,d]   target knots in d-ball with radius 1/4-eps_b/2
+% size(f)     = [N,1]   target evaluations (complex)
+% kernel = 'multiquadric', etc. (see options below)
+% c       kernel parameter
+% n       expansion degree
+% m       cut-off parameter for NFFT
+% p       degree of smoothness of regularization
+% eps_I   inner boundary
+% eps_B   outer boundary
+% 
+% Kernel functions:
+% 'gaussian'                K(x) = EXP(-x^2/c^2) 
+% 'multiquadric'            K(x) = SQRT(x^2+c^2)
+% 'inverse_multiquadric'    K(x) = 1/SQRT(x^2+c^2)
+% 'logarithm'               K(x) = LOG |x|
+% 'thinplate_spline'        K(x) = x^2 LOG |x|
+% 'one_over_square'         K(x) = 1/x^2
+% 'one_over_modulus'        K(x) = 1/|x|
+% 'one_over_x'              K(x) = 1/x
+% 'inverse_multiquadric3'   K(x) = 1/SQRT(x^2+c^2)^3
+% 'sinc_kernel'             K(x) = SIN(cx)/x
+% 'cosc'                    K(x) = COS(cx)/x
+% 'cot'                     K(x) = cot(cx)
+% 'one_over_cube'           K(x) = 1/x^3
+% 'log_sin'                 K(x) = LOG(|SIN(cx)|)
+
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
+%
+% This program is free software; you can redistribute it and/or modify it under
+% the terms of the GNU General Public License as published by the Free Software
+% Foundation; either version 2 of the License, or (at your option) any later
+% version.
+%
+% This program is distributed in the hope that it will be useful, but WITHOUT
+% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+% FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+% details.
+%
+% You should have received a copy of the GNU General Public License along with
+% this program; if not, write to the Free Software Foundation, Inc., 51
+% Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+function [f,f_direct]=fastsum_simple(x,alpha,y,kernel,c,m,n,p,eps_I,eps_B...
+    ,nn_oversampled,flags)
+
+nargoutchk(1, 2)
+d = size(x,2);
+
+if(nargin<12)
+    flags = 0;
+end
+if (nargin<11)
+    nn_oversampled = 2*n;
+end
+
+plan=fastsum_init(d,kernel,c,flags,n,p,eps_I,eps_B);
+fastsum_set_x_alpha(plan,x,alpha,nn_oversampled,m)
+fastsum_set_y(plan,y,nn_oversampled,m)
+
+if(nargout==2)
+    fastsum_trafo_direct(plan)   % direct computation
+    f_direct = fastsum_get_f(plan);
+end
+
+fastsum_trafo(plan)         % fast computation
+f = fastsum_get_f(plan);
+fastsum_finalize(plan)
+end
diff --git a/matlab/nfft/nfftmex.m b/matlab/fastsum/fastsum_trafo.m
similarity index 77%
copy from matlab/nfft/nfftmex.m
copy to matlab/fastsum/fastsum_trafo.m
index 55c8b9a..2d4cbb0 100644
--- a/matlab/nfft/nfftmex.m
+++ b/matlab/fastsum/fastsum_trafo.m
@@ -1,7 +1,8 @@
-%NFFTMEX Gateway function to NFFT module from NFFT3
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%FASTSUM_TRAFO Finalize plan.
+%
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -16,4 +17,5 @@
 % You should have received a copy of the GNU General Public License along with
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-%
+function fastsum_trafo(plan)
+fastsummex('trafo',plan);
\ No newline at end of file
diff --git a/matlab/nfft/nfftmex.m b/matlab/fastsum/fastsum_trafo_direct.m
similarity index 75%
copy from matlab/nfft/nfftmex.m
copy to matlab/fastsum/fastsum_trafo_direct.m
index 55c8b9a..ea0684e 100644
--- a/matlab/nfft/nfftmex.m
+++ b/matlab/fastsum/fastsum_trafo_direct.m
@@ -1,7 +1,8 @@
-%NFFTMEX Gateway function to NFFT module from NFFT3
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%FASTSUM_TRAFO_DIRECT Finalize plan.
+%
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -16,4 +17,5 @@
 % You should have received a copy of the GNU General Public License along with
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-%
+function fastsum_trafo_direct(plan)
+fastsummex('trafo_direct',plan);
\ No newline at end of file
diff --git a/matlab/fastsum/fastsummex.c b/matlab/fastsum/fastsummex.c
new file mode 100644
index 0000000..01f7328
--- /dev/null
+++ b/matlab/fastsum/fastsummex.c
@@ -0,0 +1,619 @@
+/*
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+#include "config.h"
+
+#ifdef HAVE_COMPLEX_H
+#include <complex.h>
+#endif
+#include <string.h>
+#include <stdio.h>
+#include <stdint.h>
+#include "nfft3.h"
+#include "infft.h"
+#include "imex.h"
+#include "fastsum.c"
+#include "kernels.c"
+
+#ifdef HAVE_MEXVERSION_C
+  #include "mexversion.c"
+#endif
+
+#define PLANS_START 10 /* initial number of plans */
+#define CMD_LEN_MAX 40 /* maximum length of command argument */
+
+/* global flags */
+#define FASTSUM_MEX_FIRST_CALL (1U << 0)
+static unsigned short gflags = FASTSUM_MEX_FIRST_CALL;
+
+static fastsum_plan** plans = NULL; /* plans */
+static unsigned int plans_num_allocated = 0;
+
+static inline void check_nargs(const int nrhs, const int n, const char* errmsg)
+{
+  DM(if (nrhs != n)
+    mexErrMsgTxt(errmsg);)
+}
+
+static inline void check_plan(int i)
+{
+  DM(if (i < 0 || i >= plans_num_allocated || plans[i] == 0)
+     mexErrMsgTxt("Plan was not initialized or has already been finalized");)
+}
+
+static inline void check_plan_source_nodes(int i)
+{
+  DM(
+	if (!(plans[i]->x))
+		mexErrMsgTxt("Required to set source nodes first");
+	)
+}
+
+static inline void check_plan_target_nodes(int i)
+{
+  DM(
+	if (!(plans[i]->y))
+		mexErrMsgTxt("Required to set target nodes first");
+	)
+}
+
+static inline void check_plan_nodes(int i)
+{
+  DM(
+    if (!(plans[i]->x) && !(plans[i]->y))
+		mexErrMsgTxt("Required to set source and target nodes first");
+	else if (!(plans[i]->x))
+		mexErrMsgTxt("Required to set source nodes first");
+	else if (!(plans[i]->y))
+		mexErrMsgTxt("Required to set target nodes first");
+	)
+}
+
+static inline int mkplan()
+{
+  int i = 0;
+  while (i < plans_num_allocated && plans[i] != 0) i++;
+  if (i == plans_num_allocated)
+  {
+    int l;
+
+    if (plans_num_allocated >= INT_MAX - PLANS_START - 1)
+      mexErrMsgTxt("fastsum: Too many plans already allocated.");
+
+    fastsum_plan** plans_old = plans;
+    plans = nfft_malloc((plans_num_allocated+PLANS_START)*sizeof(fastsum_plan*));
+    for (l = 0; l < plans_num_allocated; l++)
+      plans[l] = plans_old[l];
+    for (l = plans_num_allocated; l < plans_num_allocated+PLANS_START; l++)
+      plans[l] = 0;
+    if (plans_num_allocated > 0)
+      nfft_free(plans_old);
+    plans_num_allocated += PLANS_START;
+  }
+  plans[i] = nfft_malloc(sizeof(fastsum_plan));
+  return i;
+}
+
+static kernel get_kernel(const mxArray *p)
+{
+  kernel ker;
+  char s[CMD_LEN_MAX+1]; /**< name of kernel          */
+  if (mxGetString(p, s, CMD_LEN_MAX))
+    mexErrMsgTxt("Could not get kernel string.");
+  if (strcmp(s, "gaussian") == 0)
+    ker = gaussian;
+  else if (strcmp(s, "multiquadric") == 0)
+    ker = multiquadric;
+  else if (strcmp(s, "inverse_multiquadric") == 0)
+    ker = inverse_multiquadric;
+  else if (strcmp(s, "logarithm") == 0)
+    ker = logarithm;
+  else if (strcmp(s, "thinplate_spline") == 0)
+    ker = thinplate_spline;
+  else if (strcmp(s, "one_over_square") == 0)
+    ker = one_over_square;
+  else if (strcmp(s, "one_over_modulus") == 0)
+    ker = one_over_modulus;
+  else if (strcmp(s, "one_over_x") == 0)
+    ker = one_over_x;
+  else if (strcmp(s, "inverse_multiquadric3") == 0)
+    ker = inverse_multiquadric3;
+  else if (strcmp(s, "sinc_kernel") == 0)
+    ker = sinc_kernel;
+  else if (strcmp(s, "cosc") == 0)
+    ker = cosc;
+  else if (strcmp(s, "cot") == 0)
+    ker = kcot;
+  else if (strcmp(s, "one_over_cube") == 0)
+    ker = one_over_cube;
+  else if (strcmp(s, "log_sin") == 0)
+    ker = log_sin;
+  else
+    mexErrMsgTxt("fastsum: Unknown kernel function.");
+  return ker;
+}
+
+static inline void zero_nodes_pointer(int i)
+{
+  // Initialize pointers that are set in init_nodes
+  plans[i]->x = 0;
+  plans[i]->y = 0;
+}
+
+/* cleanup on mex function unload */
+static void cleanup(void)
+{
+  int i;
+
+  if (!(gflags & FASTSUM_MEX_FIRST_CALL))
+  {
+    for (i = 0; i < plans_num_allocated; i++)
+      if (plans[i])
+      {
+        nfft_free(plans[i]->kernel_param);
+        if(plans[i]->x)
+          fastsum_finalize_source_nodes(plans[i]);
+        if(plans[i]->y)
+          fastsum_finalize_target_nodes(plans[i]);
+        fastsum_finalize_kernel(plans[i]);
+        nfft_free(plans[i]);
+	plans[i] = 0;
+      }
+
+    if (plans_num_allocated > 0)
+    {
+      nfft_free(plans);
+      plans = NULL;
+      plans_num_allocated = 0;
+    }
+    gflags |= FASTSUM_MEX_FIRST_CALL;
+  }
+}
+
+void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
+{
+  char cmd[CMD_LEN_MAX];
+  if (gflags & FASTSUM_MEX_FIRST_CALL)
+  {
+    /* Force Matlab to load libfftw3. There is at least one version of Matlab
+     * which otherwise crashes upon invocation of this mex function. */
+    mexEvalString("fft([1,2,3,4]);");
+
+    nfft_mex_install_mem_hooks();
+
+    mexAtExit(cleanup);
+    gflags &= ~FASTSUM_MEX_FIRST_CALL;
+  }
+
+  /* command string */
+  DM(if (nrhs == 0)
+    mexErrMsgTxt("At least one input required.");)
+
+  DM(if (!mxIsChar(prhs[0]))
+    mexErrMsgTxt("First argument must be a string.");)
+
+  if (mxGetString(prhs[0], cmd, CMD_LEN_MAX))
+    mexErrMsgTxt("Could not get command string.");
+
+  if(strcmp(cmd,"get_num_threads") == 0)
+  {
+    int32_t nthreads = X(get_num_threads)();
+    plhs[0] = mxCreateNumericMatrix(1, 1, mxINT32_CLASS, mxREAL);
+    *((int32_t *)mxGetData(plhs[0])) = nthreads;
+
+    return;
+  }
+  
+  else if (strcmp(cmd,"init") == 0)
+  {
+    check_nargs(nrhs,9,"Wrong number of arguments for init.");
+    
+    int i;  /**< fastsum plan    */
+    
+    int d; /**< number of dimensions    */
+    int n; /**< expansion degree        */
+    int p; /**< degree of smoothness    */
+    kernel ker; /**< kernel function         */
+    double *param; /**< parameter for kernel    */
+    double eps_I; /**< inner boundary          */
+    double eps_B; /**< outer boundary          */
+    param = nfft_malloc(sizeof(double));
+  
+    d = nfft_mex_get_int(prhs[1],"fastsum init: Input argument d must be a scalar.");
+    DM(if (d < 1)
+      mexErrMsgTxt("fastsum init: Input argument d must be positive.");)
+    
+    ker = get_kernel(prhs[2]);
+    
+    *param = nfft_mex_get_double(prhs[3],"fastsum init: Input argument c must be a scalar.");
+    
+    int flags_int = nfft_mex_get_int(prhs[4],"fastsum init: Input argument flags must be a scalar.");
+    DM( if (flags_int < 0)
+      mexErrMsgTxt("fastsum init: Input argument flags must be non-negative.");)
+    unsigned flags = (unsigned) flags_int;
+    
+    n = nfft_mex_get_int(prhs[5],"fastsum init: Input argument n must be a scalar.");
+    DM(if ((n < 1) || (n%2))
+      mexErrMsgTxt("fastsum init: Input argument n must be an even, positive integer.");)
+    
+    p = nfft_mex_get_int(prhs[6],"fastsum init: Input argument p must be a scalar.");
+    DM(if (p < 1)
+      mexErrMsgTxt("fastsum init: Input argument p must be positive.");)
+    
+    eps_I = nfft_mex_get_double(prhs[7],"fastsum init: Input argument eps_I must be a scalar.");
+    eps_B = nfft_mex_get_double(prhs[8],"fastsum init: Input argument eps_B must be a scalar.");
+
+    i = mkplan();
+    
+    fastsum_init_guru_kernel(plans[i], d, ker, param, flags | STORE_PERMUTATION_X_ALPHA, n, p, eps_I, eps_B);
+    
+    zero_nodes_pointer(i);
+
+    plhs[0] = mxCreateDoubleScalar((double)i);
+
+    return;
+  }
+  
+  else if (strcmp(cmd,"set_x") == 0)
+  {
+    check_nargs(nrhs,5,"Wrong number of arguments for set_x.");
+    
+    int i = nfft_mex_get_int(prhs[1],"fastsum set_x: Input argument plan must be a scalar.");
+    check_plan(i);
+    int d = plans[i]->d;
+    
+    DM(if (!mxIsDouble(prhs[2]) || (mxGetNumberOfDimensions(prhs[2]) > 2) || (mxGetN(prhs[2]) != (unsigned)d))
+      mexErrMsgTxt("Input argument x must be a matrix with d columns");
+    if (mxGetM(prhs[2]) > INT_MAX)
+      mexErrMsgTxt("fastsum set_x: Input argument x is too large");)
+    
+    int N = (int) mxGetM(prhs[2]);
+    
+    int nn_oversampled = nfft_mex_get_int(prhs[3],"fastsum set_x: Input argument nn_oversampled must be a scalar.");
+    DM(if (nn_oversampled < 1)
+      mexErrMsgTxt("fastsum set_x: Input argument nn_oversampled must be positive.");)
+    
+    int m = nfft_mex_get_int(prhs[4],"fastsum set_x: Input argument m must be a scalar.");
+    DM(if (m < 1)
+      mexErrMsgTxt("fastsum set_x: Input argument m must be positive.");)
+    
+    if(!(plans[i]->x)) 
+      fastsum_init_guru_source_nodes(plans[i], N, nn_oversampled, m);
+    else if( (N != plans[i]->N_total) || (m != plans[i]->mv1.m) || (nn_oversampled != plans[i]->mv1.n[0]) )
+    {
+      fastsum_finalize_source_nodes(plans[i]);
+      fastsum_init_guru_source_nodes(plans[i], N, nn_oversampled, m);
+    }
+    
+    double *x = mxGetPr(prhs[2]);
+    DM(double norm_max = (.25-(plans[i]->eps_B)*.5)*(.25-(plans[i]->eps_B)*.5);
+      short warn=0;)
+    if (plans[i]->flags & NEARFIELD_BOXES)
+    {
+      for (int k = 0; k < N; k++)
+      {
+        DM(double norm = 0;)
+        for (int t = 0; t < d; t++)
+        {
+        plans[i]->x[k*d+t] = x[k+t*N];
+        DM( if((plans[i]->x[k*d+t] < -0.5) || (plans[i]->x[k*d+t] >= 0.5))
+          mexErrMsgTxt("x must be in interval [-0.5,0.5)");
+        norm += plans[i]->x[k*d+t] * plans[i]->x[k*d+t];)
+        }
+        DM(if( norm > norm_max)
+          warn = 1;)
+      }
+    }
+    else
+    {
+      for (int k = 0; k < N; k++)
+      {
+        DM(double norm = 0;)
+        for (int t = 0; t < d; t++)
+        {
+        plans[i]->x[k*d+t] = x[plans[i]->permutation_x_alpha[k]+t*N];
+        DM( if((plans[i]->x[k*d+t] < -0.5) || (plans[i]->x[k*d+t] >= 0.5))
+          mexErrMsgTxt("x must be in interval [-0.5,0.5)");
+        norm += plans[i]->x[k*d+t] * plans[i]->x[k*d+t];)
+        }
+        DM(if( norm > norm_max)
+          warn = 1;)
+      }
+    }
+    
+    DM(if(warn)
+      mexWarnMsgIdAndTxt("fastsum:nodesOutsideBall","x must be in ball with radius 1/4-eps_B/2.\nThis may cause wrong results or crashes!!");)
+    
+    fastsum_precompute_source_nodes(plans[i]);
+    
+    return;
+  }
+  
+  else if (strcmp(cmd,"set_alpha") == 0)
+  {
+    check_nargs(nrhs,3,"Wrong number of arguments for set_alpha.");
+    int i = nfft_mex_get_int(prhs[1],"fastsum set_x_alpha: Input argument plan must be a scalar.");
+    check_plan(i);
+    
+    if(!(plans[i]->x)) 
+      mexErrMsgTxt("You have to set x before you set alpha.");
+    
+    DM(if (!(mxIsDouble(prhs[2]) || mxIsComplex(prhs[2])) || (mxGetNumberOfDimensions(prhs[2]) > 2) || (mxGetM(prhs[2]) != plans[i]->N_total) || (mxGetN(prhs[2]) != 1))
+        mexErrMsgTxt("Input argument alpha must be an N x 1 array");
+    if (mxGetM(prhs[2]) > INT_MAX)
+    mexErrMsgTxt("fastsum set_alpha: Input argument alpha is too large");)
+    
+    double *ar = mxGetPr(prhs[2]), *ai=0;
+    if(mxIsComplex(prhs[2])) 
+      ai = mxGetPi(prhs[2]);
+    for (int k = 0; k < plans[i]->N_total; k++)
+    {
+      if (plans[i]->flags & NEARFIELD_BOXES)
+      {
+        if(ai)
+          plans[i]->alpha[k] = ar[k] + _Complex_I*ai[k];
+        else
+          plans[i]->alpha[k] = ar[k];
+      }
+      else
+      {
+        if(ai)
+          plans[i]->alpha[k] = ar[plans[i]->permutation_x_alpha[k]] + _Complex_I*ai[plans[i]->permutation_x_alpha[k]];
+        else
+          plans[i]->alpha[k] = ar[plans[i]->permutation_x_alpha[k]];
+      }
+    }
+    return;
+  }
+  
+  else if (strcmp(cmd,"set_y") == 0)
+  {
+    check_nargs(nrhs,5,"Wrong number of arguments for set_y.");
+    int i = nfft_mex_get_int(prhs[1],"fastsum set_y: Input argument plan must be a scalar.");
+    check_plan(i);
+
+    int d = plans[i]->d;
+    DM(if (!mxIsDouble(prhs[2]) || mxGetNumberOfDimensions(prhs[2]) > 2 || mxGetN(prhs[2]) != (unsigned)d)
+      mexErrMsgTxt("fastsum set_y: Input argument y must be an M x d double array");
+    if(mxGetM(prhs[2]) > INT_MAX)
+      mexErrMsgTxt("fastsum set_y: Input argument y is too large");)
+    int M = (int) mxGetM(prhs[2]);
+    
+    int nn_oversampled = nfft_mex_get_int(prhs[3],"fastsum set_y: Input argument nn_oversampled must be a scalar.");
+    DM(if (nn_oversampled < 1)
+      mexErrMsgTxt("fastsum set_y: Input argument nn_oversampled must be positive.");)
+    
+    int m = nfft_mex_get_int(prhs[4],"fastsum set_y: Input argument m must be a scalar.");
+    DM(if (m < 1)
+      mexErrMsgTxt("fastsum set_y: Input argument m must be positive.");)
+    
+    if(!(plans[i]->y))
+      fastsum_init_guru_target_nodes(plans[i], M, nn_oversampled, m);
+    else if( (M != plans[i]->M_total) || (m != plans[i]->mv2.m) || (nn_oversampled != plans[i]->mv2.n[0]) )
+    {
+      fastsum_finalize_target_nodes(plans[i]);
+      fastsum_init_guru_target_nodes(plans[i], M, nn_oversampled, m);
+    }
+    
+    double *y = mxGetPr(prhs[2]);
+    DM(double norm_max = (.25-(plans[i]->eps_B)*.5)*(.25-(plans[i]->eps_B)*.5);
+    short warn=0;)
+    for (int j = 0; j < M; j++)
+    {
+      DM(double norm = 0;)
+      for (int t = 0; t < d; t++)
+      {
+        plans[i]->y[d*j+t] = y[j+t*M];
+        DM( if((plans[i]->y[d*j+t] < -0.5) || (plans[i]->y[d*j+t] >= 0.5))
+          mexErrMsgTxt("y must be in interval [-0.5,0.5)");
+        norm += plans[i]->y[d*j+t] * plans[i]->y[d*j+t];)
+      }
+      DM(if( norm > norm_max)
+        warn = 1;)
+    }
+    DM(if(warn)
+      mexWarnMsgIdAndTxt("fastsum:nodesOutsideBall","y must be in ball with radius 1/4-eps_B/2.\nThis may cause wrong results or crashes!!");)
+    
+    fastsum_precompute_target_nodes(plans[i]);
+    return;
+  }
+  
+  else if (strcmp(cmd,"trafo_direct") == 0)
+  {
+    check_nargs(nrhs,2,"Wrong number of arguments for trafo_direct.");
+    const int i = nfft_mex_get_int(prhs[1],"fastsum trafo_direct: Input argument plan must be a scalar.");
+    check_plan(i);
+    check_plan_nodes(i);
+    fastsum_exact(plans[i]);
+    return;
+  }
+  
+  else if (strcmp(cmd,"trafo") == 0)
+  {
+    check_nargs(nrhs,2,"Wrong number of arguments for trafo.");
+    const int i = nfft_mex_get_int(prhs[1],"fastsum trafo: Input argument plan must be a scalar.");
+    check_plan(i);
+    check_plan_nodes(i);
+    fastsum_trafo(plans[i]);
+    return;
+  }
+  
+  else if (strcmp(cmd,"get_f") == 0)
+  {
+    check_nargs(nrhs,2,"Wrong number of arguments for get_f.");
+    const int i = nfft_mex_get_int(prhs[1],"fastsum get_f: Input argument plan must be a scalar.");
+    check_plan(i);
+    check_plan_nodes(i);
+    const int M = plans[i]->M_total;
+    plhs[0] = mxCreateDoubleMatrix((unsigned int)M, 1, mxCOMPLEX);
+    double *fr = mxGetPr(plhs[0]), *fi = mxGetPi(plhs[0]);
+    for (int j = 0; j < M; j++)
+    {
+      fr[j] = creal(plans[i]->f[j]);
+      fi[j] = cimag(plans[i]->f[j]);
+    }
+    return;
+  }
+  
+  else if (strcmp(cmd,"finalize") == 0)
+  {
+    check_nargs(nrhs,2,"Wrong number of arguments for finalize.");
+    const int i = nfft_mex_get_int(prhs[1],"fastsum finalize: Input argument plan must be a scalar.");
+    check_plan(i);
+    nfft_free(plans[i]->kernel_param);
+    if(plans[i]->x || plans[i]->alpha)
+      fastsum_finalize_source_nodes(plans[i]);
+    if(plans[i]->y)
+      fastsum_finalize_target_nodes(plans[i]);
+    fastsum_finalize_kernel(plans[i]);
+    nfft_free(plans[i]);
+    plans[i] = 0;
+    return;
+  }
+  
+  else if (strcmp(cmd,"get_x") == 0)
+  {
+    check_nargs(nrhs,2,"Wrong number of arguments for get_x.");
+    const int i = nfft_mex_get_int(prhs[1],"fastsum: Input argument plan must be a scalar.");
+    check_plan(i);
+    check_plan_source_nodes(i);
+    const int d = plans[i]->d;
+    const int N = plans[i]->N_total;
+    plhs[0] = mxCreateDoubleMatrix((unsigned int)N, (unsigned int)d, mxREAL);
+    double *x = mxGetPr(plhs[0]);
+    for (int j = 0; j < N; j++)
+    {
+      for (int t = 0; t < d; t++)
+      {
+        if (plans[i]->flags & NEARFIELD_BOXES)
+          x[j+t*N] = plans[i]->x[d*j+t];
+        else
+          x[plans[i]->permutation_x_alpha[j]+t*N] = plans[i]->x[d*j+t];
+      }
+    }
+    return;
+  }
+  
+  else if (strcmp(cmd,"get_alpha") == 0)
+  {
+    check_nargs(nrhs,2,"Wrong number of arguments for get_alpha.");
+    const int i = nfft_mex_get_int(prhs[1],"fastsum: Input argument plan must be a scalar.");
+    check_plan(i);
+    check_plan_source_nodes(i);
+    const int N = plans[i]->N_total;
+    plhs[0] = mxCreateDoubleMatrix((unsigned int)N, 1, mxCOMPLEX);
+    double *ar = mxGetPr(plhs[0]), *ai = mxGetPi(plhs[0]);
+    for (int j = 0; j < N; j++)
+    {
+      if (plans[i]->flags & NEARFIELD_BOXES)
+      {
+        ar[j] = creal(plans[i]->alpha[j]);
+        ai[j] = cimag(plans[i]->alpha[j]);
+      }
+      else
+      {
+        ar[plans[i]->permutation_x_alpha[j]] = creal(plans[i]->alpha[j]);
+        ai[plans[i]->permutation_x_alpha[j]] = cimag(plans[i]->alpha[j]);
+      }
+    }
+    return;
+  }
+  
+  else if (strcmp(cmd,"get_y") == 0)
+  {
+    check_nargs(nrhs,2,"Wrong number of arguments for get_y.");
+    const int i = nfft_mex_get_int(prhs[1],"fastsum: Input argument plan must be a scalar.");
+    check_plan(i);
+    check_plan_target_nodes(i);
+    const int d = plans[i]->d;
+    const int M = plans[i]->M_total;
+    
+    plhs[0] = mxCreateDoubleMatrix((unsigned int)M, (unsigned int)d, mxREAL);
+    double *y = mxGetPr(plhs[0]);
+    for (int j = 0; j < M; j++)
+    {
+      for (int t = 0; t < d; t++)
+        y[j+t*M] = plans[i]->y[d*j+t];
+    }
+    return;
+  }
+  
+  else if (strcmp(cmd,"get_b") == 0)
+  {
+    check_nargs(nrhs,2,"Wrong number of arguments for get_b.");
+    const int i = nfft_mex_get_int(prhs[1],"fastsum: Input argument plan must be a scalar.");
+    check_plan(i);
+    const int d = plans[i]->d;
+    mwSize dims[d];
+    int n_total = 1;
+    for(int j=0; j<d; j++)
+    {
+      dims[j] = (unsigned int) plans[i]->n;
+      n_total *= plans[i]->n;
+    }
+    
+    plhs[0] = mxCreateNumericArray((unsigned int)d, dims, mxDOUBLE_CLASS, mxCOMPLEX);
+    double *br = mxGetPr(plhs[0]), *bi = mxGetPi(plhs[0]);
+    for (int j = 0; j < n_total; j++)
+    {
+      br[j] = creal(plans[i]->b[j]);
+      bi[j] = cimag(plans[i]->b[j]);
+    }
+    return;
+  }
+  
+  else if (strcmp(cmd,"get_N_total") == 0)
+  {
+    check_nargs(nrhs,2,"Wrong number of arguments for get_N_total.");
+    const int i = nfft_mex_get_int(prhs[1],"fastsum: Input argument plan must be a scalar.");
+    check_plan(i);
+    plhs[0] = mxCreateDoubleMatrix(1, 1, mxREAL);
+    double *pr = mxGetPr(plhs[0]);
+    pr[0] = plans[i]->N_total;
+    return;
+  }
+  
+  else if (strcmp(cmd,"display") == 0)
+  {
+    check_nargs(nrhs,2,"Wrong number of arguments for display.");
+    {
+      const int i = nfft_mex_get_int(prhs[1],"fastsum: Input argument plan must be a scalar.");
+	  check_plan(i);
+      mexPrintf("Plan %d\n",i);
+      mexPrintf("  pointer: %p\n",plans[i]);
+      mexPrintf("        d: %d\n",plans[i]->d);
+      mexPrintf("  N_total: %d\n",plans[i]->N_total);
+      mexPrintf("  M_total: %d\n",plans[i]->M_total);
+      mexPrintf("        n: %d\n",plans[i]->n);
+      mexPrintf("        p: %d\n",plans[i]->p);
+      mexPrintf("    eps_I: %f\n",plans[i]->eps_I);
+      mexPrintf("    eps_B: %f\n",plans[i]->eps_B);
+      mexPrintf("        x: %p\n",plans[i]->x);
+      mexPrintf("        y: %p\n",plans[i]->y);
+      mexPrintf("    alpha: %p\n",plans[i]->alpha);
+      mexPrintf("        f: %p\n",plans[i]->f);
+      mexPrintf("   kernel: %p\n",plans[i]->k);
+      mexPrintf("   _param: %p\n",plans[i]->kernel_param);
+      mexPrintf("  *_param: %f\n",*(plans[i]->kernel_param));
+      mexPrintf("    flags: %d\n",plans[i]->flags);
+    }
+    return;
+  }
+  
+  else
+    mexErrMsgTxt("fastsum: Unknown command.\n");
+}
diff --git a/matlab/fastsum/test_fastsum.m b/matlab/fastsum/test_fastsum.m
new file mode 100644
index 0000000..2d4f038
--- /dev/null
+++ b/matlab/fastsum/test_fastsum.m
@@ -0,0 +1,94 @@
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
+%
+% This program is free software; you can redistribute it and/or modify it under
+% the terms of the GNU General Public License as published by the Free Software
+% Foundation; either version 2 of the License, or (at your option) any later
+% version.
+%
+% This program is distributed in the hope that it will be useful, but WITHOUT
+% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+% FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+% details.
+%
+% You should have received a copy of the GNU General Public License along with
+% this program; if not, write to the Free Software Foundation, Inc., 51
+% Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+%
+% Computes the sums
+% 
+%   f(y_j) = sum_{k=1}^N alpha_k kernel(x_k-y_j)   (j=1:M).
+% 
+% size(x)     = [N,d]   source knots in d-ball with radius 1/4-eps_b/2
+% size(alpha) = [N,1]   source coefficients (complex)
+% size(y)     = [M,d]   target knots in d-ball with radius 1/4-eps_b/2
+% size(f)     = [N,1]   target evaluations (complex)
+% 
+% Kernel functions:
+% 'gaussian'                K(x) = EXP(-x^2/c^2) 
+% 'multiquadric'            K(x) = SQRT(x^2+c^2)
+% 'inverse_multiquadric'    K(x) = 1/SQRT(x^2+c^2)
+% 'logarithm'               K(x) = LOG |x|
+% 'thinplate_spline'        K(x) = x^2 LOG |x|
+% 'one_over_square'         K(x) = 1/x^2
+% 'one_over_modulus'        K(x) = 1/|x|
+% 'one_over_x'              K(x) = 1/x
+% 'inverse_multiquadric3'   K(x) = 1/SQRT(x^2+c^2)^3
+% 'sinc_kernel'             K(x) = SIN(cx)/x
+% 'cosc'                    K(x) = COS(cx)/x
+% 'cot'                     K(x) = cot(cx)
+% 'one_over_cube'           K(x) = 1/x^3
+% 'log_sin'                 K(x) = LOG(|SIN(cx)|)
+
+%% Initialize parameters
+d = 2;          % number of dimensions
+N = 2000;       % number of source knots
+M = 2000;       % number of target knots
+kernel = 'multiquadric';
+c = 1/sqrt(N);  % kernel parameter
+p = 3;          % degree of smoothness of regularization
+flags = 0;      % flags (could be EXACT_NEARFIELD or NEARFIELD_BOXES)
+n = 156;        % expansion degree
+eps_I = p/n;    % inner boundary
+eps_B = 1/16;   % outer boundary
+m = p;          % cut-off parameter for NFFT
+nn_oversampled=2*n; % oversampling factor for NFFT
+
+%% random source nodes in circle of radius 0.25-eps_B/2
+r = sqrt(rand(N,1))*(0.25-eps_B/2);
+phi = rand(N,1)*2*pi;
+x = [r.*cos(phi) r.*sin(phi)];
+% random coefficients
+alpha = rand(N,1) + 1i*rand(N,1);
+% random target nodes in circle of radius 0.25-eps_B/2
+r = sqrt(rand(M,1))*(0.25-eps_B/2);
+phi = rand(M,1)*2*pi;
+y = [r.*cos(phi) r.*sin(phi)];
+
+%% Perform fastsum
+plan=fastsum_init(d,kernel,c,flags,n,p,eps_I,eps_B);
+fastsum_set_x(plan,x,nn_oversampled,m)
+fastsum_set_alpha(plan,alpha)
+fastsum_set_y(plan,y,nn_oversampled,m)
+
+fastsum_trafo_direct(plan)   % direct computation
+f_dir = fastsum_get_f(plan);
+
+fastsum_trafo(plan)         % fast computation
+f = fastsum_get_f(plan);
+fastsum_finalize(plan)
+
+%% fastsum class
+a=fastsum(d,kernel,c,flags,n,p,eps_I,eps_B,nn_oversampled,m);
+a.x=x;
+a.alpha=alpha;
+a.y=y;
+fastsum_trafo(a);
+disp(max(a.f-f))
+
+%% plot source and target evaluations
+figure(1)
+scatter(x(:,1),x(:,2),120,real(alpha),'.')
+colorbar
+figure(2)
+scatter(y(:,1),y(:,2),120,abs(f./f_dir-1),'.')
+colorbar
diff --git a/matlab/imex.h b/matlab/imex.h
index dabc27f..e502c3d 100644
--- a/matlab/imex.h
+++ b/matlab/imex.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
@@ -35,6 +35,10 @@
   #define __STDC_UTF_16__
 #endif
 
+#ifndef INT_MAX
+  #define INT_MAX 2147483647 /* from limits.h */
+#endif
+
 /*----------------------------------------------------------------------------*/
 /* Replacements for nfft_malloc and nfft_free plus install routine */
 extern void *nfft_mex_malloc(size_t n);
diff --git a/matlab/infft_1D/README b/matlab/infft_1D/README
new file mode 100644
index 0000000..cedaa1b
--- /dev/null
+++ b/matlab/infft_1D/README
@@ -0,0 +1,55 @@
+infft - Algorithm for fast computation of an iNFFT using fast summation
+
+ Computes an inverse NFFT, i.e. approximates the Fourier coefficients fhat
+ in sums of the form
+ 
+   f(y_j) = sum_{k = -N/2}^{N/2-1} fhat_k * exp(2*pi*i*k*y_j),  j = 1,...,M,
+ 
+ where y_j and f(y_j) are given.
+
+ For this purpose a new direct method is used in case that the number of 
+ knots (M) equals the number of the unknown Fourier coefficients (N).
+ Another restriction is that this algorithm only works in 1-D because it 
+ uses the Lagrange interpolation scheme which is only feasible in the 
+ one-dimensional setting.
+
+ Hence, the computation of an iNFFT can be reduced to the computation of 
+ some needed coefficients and the application of one FFT afterwards.
+ For the evaluation of thereby occurrent sums fast summation is used.
+
+ For more details see [1].
+
+------------------------------------------------------------------------------------------------
+ INPUT:
+ y - Knots where the iNFFT should be computed      
+ f - Function evaluations at points y                    
+ m - Cut-off parameter for NFFT                    (optional)        default: m = 4
+ p - Degree of smoothness of regularization        (optional)        default: p = 4
+ n - Expansion degree                              (optional)        default: n = 2*N
+ eps_I - Inner boundary (<=1/4)                    (optional)        default: eps_I = 4*p/n
+ sigma - Oversampling factor for NFFT              (optional)        default: sigma = 2
+------------------------------------------------------------------------------------------------
+ OUTPUT:
+ fbar - Computed Fourier coefficients
+ times - Includes the following fields:            (optional)
+   times.t_c - Computing time for coefficients c_l
+   times.t_d - Computing time for coefficients d_j
+   times.t_g - Computing time for coefficients g_l
+   times.t_fft - Computing time for FFT
+   times.t_total - Total computing time for iNFFT
+   times.t_direct - Total computing time for the exact computation
+------------------------------------------------------------------------------------------------
+
+ The optional input arguments can be commited to infft.m as follows
+     infft(y,'name',value,'name',value,...)
+ e.g. 
+     infft(y,'sigma',2).
+
+ Use the Matlab script file simple_test.m for a simple demonstration.
+
+
+
+Reference:
+
+   [1]  M. Kircheis. Die Direkte Inverse NFFT,
+        Bachelor Thesis, Chemnitz University of Technology, 2017.
diff --git a/matlab/infft_1D/infft.m b/matlab/infft_1D/infft.m
new file mode 100644
index 0000000..6df74e9
--- /dev/null
+++ b/matlab/infft_1D/infft.m
@@ -0,0 +1,355 @@
+classdef infft < handle
+    
+    properties(Dependent=true)
+        f                       % Dummy variable
+    end
+    
+    properties(SetAccess=private)
+        y                       % Knots where inversion should be done
+        m                       % Cut-off parameter for NFFT 
+        p                       % Degree of smoothness of fastsum
+        sigma                   % Oversampling factor for NFFT
+        n                       % Expansion degree  
+        eps_B = 0;              % Outer boundary
+        eps_I                   % Inner boundary (<=1/4)
+        fbar                    % Approximated Fourier coefficients
+        fbar_direct             % Direcly computed Fourier coefficients
+        times                   % Computing times
+    end
+    
+    properties(GetAccess=private, SetAccess=private)
+        N                       % Number of knots
+        x                       % Additional equidistant knots
+        perm                    % Permutaion to sort y (if unsorted)
+        f_storage               % Evaluations at points y
+        nn_oversampled          % n*sigma
+        abs                     % Distance needed for a shift
+        c                       % Needed coefficients for iNFFT
+        d                       % Needed coefficients for iNFFT
+        trafo_done = false;     % Flag if trafo is done
+        direct_done = false;    % Flag if direct trafo is done
+    end
+    
+    methods
+        function h = infft(y,varargin)
+           % Constructor
+           
+           s=fileparts(mfilename('fullpath'));
+           s=strcat(s,'/../fastsum');
+           addpath(s)         
+            
+           % Check input and determine whether knots are in the correct interval
+           if ( nargin==0 || sum(size(y))==0 )
+               error('No knots were given. The input "y" is compulsory.');
+           elseif mod(nargin,2)==0
+               error('Wrong number of arguments.')
+           elseif ( size(y,1)~=1 && size(y,2)~=1 )
+               error('Input must be a vector.');
+           elseif ( sum(y < -0.5) + sum(y >= 0.5) ~= 0 )
+               error('Knots are in the wrong interval. Only knots in [-0.5,0.5) are allowed.');
+           end
+            
+           % Make it a row vector if necessary
+           if size(y,2)==1             
+               h.y = transpose(y);
+           else
+               h.y = y;
+           end 
+            
+           % Sort it if necessary
+           if issorted(h.y)==0
+               [h.y,h.perm] = sort(h.y);
+           else
+               h.perm = [];
+           end
+           
+           % Number of knots
+           h.N = length(h.y);
+
+           % Optional Input
+           P = inputParser;
+           P.KeepUnmatched = true;
+           
+           addParameter(P,'m',4, @(x) (x>0 && round(x)==x && isreal(x)))
+           addParameter(P,'p',4, @(x) (x>=0 && x<=12 && isreal(x)))
+           addParameter(P,'sigma',2, @(x) (x>=1 && isreal(x)))
+           addParameter(P,'n',2*h.N, @(x) (x>0 && mod(x,2) == 0 && isreal(x)))
+           addParameter(P,'eps_I',NaN, @(x) (x>0 && x<=1/4 && isreal(x)))
+                    
+           parse(P,varargin{:});
+
+           h.m = P.Results.m;
+           h.p = P.Results.p;
+           h.sigma = P.Results.sigma;   
+           h.n = P.Results.n;
+           h.eps_I = P.Results.eps_I;
+           
+           h.nn_oversampled = ceil(h.sigma*h.n);             
+           % Check if it is odd and make it even if necessary            
+           if mod(h.nn_oversampled,2)==1
+               h.nn_oversampled = h.nn_oversampled+1;
+           end
+           
+           % Set default value for eps_I if it is not set
+           if not(isfinite(h.eps_I))
+               const = 2;
+               h.eps_I = const * 2*h.p/h.n;
+               while (h.eps_I > 1/4)
+                   const = const/2;
+                   h.eps_I = const * 2*h.p/h.n;
+               end
+           end
+           
+           % Suppress warnings (knots are in an interval that is bigger than normal)
+           warning('off','fastsum:alphaDeleted')
+           warning('off','fastsum:nodesOutsideBall')
+           
+           tic
+           % Set constants for fastsum
+           o = ones(h.N,1);
+           % Set additional equidistant knots
+           h.x = -0.5:1/h.N:0.5-1/h.N;
+           
+           % Set vector for correction of sign and shift x if necessary
+           vec = compute_sign(h);
+           help = toc;
+           
+           % Computation of coefficients c_l 
+           tic
+           plan = fastsum(1,'log_sin',pi,0,h.n,h.p,h.eps_I,h.eps_B,h.nn_oversampled,h.m);
+           h.c = compute_coeff(h,plan,h.x,h.y,o);
+           h.times.t_c = toc;
+
+           % Computation of coefficients d_j    
+           tic
+           h.d = compute_coeff(h,plan,h.y,h.y,o);
+           h.d = -h.d;
+           h.times.t_d = toc;
+           
+           % Set constant and divide it out
+           tic
+           s = min(abs(min(abs(h.d))), abs(min(abs(h.c))));
+           h.c = h.c + s;
+           h.d = h.d - s;
+           h.c = exp(h.c);
+           h.d = exp(h.d);
+           
+           % Correction of sign
+           h.c = h.c .* vec;
+           h.d = h.d .* repmat([-1;1],h.N/2,1);
+           
+           h.times.t_total = help + toc;
+        end %function
+        
+    % Set functions %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+        function set.f(h,f)
+            % Check whether the parameters y and f match 
+            if ( isvector(f) ~= 1 )
+                error('Input must be a vector.');
+            elseif ( length(f) ~= h.N )
+                error('The input vectors y and f need to have same length.');
+            end
+            
+            % Make it a column vector
+            f = f(:);
+            
+            % If y needed to get sorted, also sort f
+            if h.perm
+                f = f(h.perm);
+            end
+            
+            h.f_storage = f;
+            h.trafo_done = false;
+            h.direct_done = false;
+        end %function
+        
+    % Get functions %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+                                     
+        function f=get.f(h)
+            f = h.f_storage;
+        end %function
+        
+        function fbar=get.fbar(h)
+            if(~h.trafo_done)
+                error('No trafo was done.');
+            else
+                fbar = h.fbar;
+            end
+        end %function 
+        
+        function fbar_direct=get.fbar_direct(h)
+            if(~h.direct_done)
+                error('No trafo was done.');
+            else
+                fbar_direct = h.fbar_direct;
+            end
+        end %function
+        
+    % User methods %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+    
+        function infft_direct(h,f)
+        % Exact computation of an iNFFT, i.e. inversion of the nonequispaced Fourier-matrix.
+            tic
+            A = zeros(h.N,h.N);
+            j = 1:h.N;
+            for k = -h.N/2 : h.N/2-1
+                A(:,k + h.N/2 + 1) = exp(2*pi*1i*k*h.y(j));
+            end
+            h.fbar_direct = A\f;
+            h.times.t_direct = toc;
+            h.direct_done = true;
+        end %function
+        
+        function infft_trafo(h)
+        % Final computations for iNFFT.             
+            % Set constants for fastsum of g_l
+            tic
+            alpha = h.f_storage.*h.d;
+            h.times.t_total = h.times.t_total + toc;
+            
+            % Computation of coefficients g_l
+            tic
+            plan = fastsum(1,'cot',pi,0,h.n,h.p,h.eps_I,h.eps_B,h.nn_oversampled,h.m);
+            g = compute_coeff(h,plan,h.x,h.y,alpha);
+            h.times.t_g = toc; 
+            
+            % Final computation
+            tic
+            g = -h.c.*(-g + 1i*h.d'*h.f_storage);
+            h.times.t_total = h.times.t_total + toc;
+            
+            % Computation of the Fourier-coefficients by FFT
+            tic
+            fhat = fft(g);
+            fhat = fhat.*transpose(exp(-pi*1i*(0:h.N-1)));
+            fhat = fftshift(fhat);
+            fhat = fhat/h.N;   
+            fhat = fhat.*transpose(exp(-pi*1i*(-h.N/2:h.N/2-1)*h.abs));
+            h.times.t_fft = toc;
+            
+            % Time required
+            h.times.t_total = h.times.t_total + h.times.t_c + h.times.t_d + h.times.t_g + h.times.t_fft;
+                        
+            % If y got sorted, use the inverse permutation to get back the order of the user
+            if h.perm
+                h.fbar(h.perm) = fhat;
+            else 
+                h.fbar = fhat;
+            end
+            
+            h.trafo_done = true;
+        end %function
+    
+    end %methods
+    
+    % Private methods %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+    methods(Access=private)
+        function vec = compute_sign(h)
+            % Auxiliary function for computing the correction of sign.
+            anz = zeros(h.N,1);
+            h.abs = 1;
+            i = 1;
+            j = 1;
+
+            while (i <= h.N && j <= h.N)
+            if h.x(i) < h.y(j)
+                diff = h.y(j)-h.x(i);
+                if diff < h.abs
+                    h.abs = diff;
+                end
+                i = i + 1;
+                if i <= h.N
+                    anz(i) = anz(i-1);
+                end
+            elseif h.x(i) > h.y(j)
+                anz(i) = anz(i) + 1;
+                j = j + 1;
+            else
+                if j < h.N
+                    diff = h.y(j+1)-h.x(i);
+                    if diff < h.abs
+                        h.abs = diff;
+                    end
+                end
+                i = i + 1;
+                if i <= h.N
+                    anz(i) = anz(i-1);
+                end
+                anz(i-1) = anz(i-1) + 1;
+            end
+            end
+
+            % If necessary do a shift
+            if not(isempty(intersect(h.x,h.y)))
+                h.x = h.x + h.abs/2;
+            else
+                h.abs = 0;
+            end
+
+            vec = (-1).^anz;
+        end %function
+        
+        function coeff = compute_coeff(h,plan,a,b,alpha)
+            % Auxiliary function for computing coefficients.
+            coeff = zeros(h.N,1);
+
+            % New index sets for knots a
+            A1 = a<-0.25;
+            A2 = a>=0.25;
+            A3 = and(not(A1),not(A2));
+
+            % New index sets for knots b
+            B1 = b<0.25;
+            B2 = not(B1);
+            B3 = b>=-0.25;
+            B4 = not(B3);
+
+            %------------------------------------------------------------------
+            % Case 1 (a < -0.25)
+            % Without shift of knots
+
+            plan.x = b(B1)';
+            plan.alpha = alpha(B1);
+            plan.y = a(A1)';
+            fastsum_trafo(plan)
+            coeff(A1) = plan.f;
+
+            % With shift
+
+            plan.x = (b(B2)-1/4)';
+            plan.alpha = alpha(B2);
+            plan.y = (a(A1)+3/4)';
+            fastsum_trafo(plan)
+            coeff(A1) = coeff(A1) + plan.f;
+            
+            %------------------------------------------------------------------
+            % Case 2 (a >= 0.25)
+            % Without shift of knots
+
+            plan.x = b(B3)';
+            plan.alpha = alpha(B3);
+            plan.y = a(A2)';
+            fastsum_trafo(plan)
+            coeff(A2) = plan.f;
+
+            % With shift
+
+            plan.x = (b(B4)+1/4)';
+            plan.alpha = alpha(B4);
+            plan.y = (a(A2)-3/4)';
+            fastsum_trafo(plan)
+            coeff(A2) = coeff(A2) + plan.f;
+
+            %------------------------------------------------------------------
+            % Case 3 (-0.25 <= a < 0.25)
+
+            plan.x = b';
+            plan.alpha = alpha;
+            plan.y = a(A3)';
+            fastsum_trafo(plan)
+            coeff(A3) = plan.f;
+            
+        end %function
+    end % methods
+end %classdef
\ No newline at end of file
diff --git a/matlab/infft_1D/simple_test.m b/matlab/infft_1D/simple_test.m
new file mode 100644
index 0000000..705b071
--- /dev/null
+++ b/matlab/infft_1D/simple_test.m
@@ -0,0 +1,40 @@
+% Example for the usage of infft.
+
+clear
+
+% Number of knots
+N = 1024;             
+
+% Random integer fourier coefficients in [1,100]
+fhat = ceil(rand(N,1)*100);                     
+
+% Jittered knots in [-0.5,0.5)
+y = (-0.5:1/N:0.5-1/N) + 1/(4*N)*rand(1,N); 
+
+% Evaluations of a trigonometric polynomial
+f = exp(2*pi*1i*y'*(-N/2:N/2-1))*fhat;          
+ 
+
+%% Fast computation
+
+plan = infft(y);
+% Using the default values. Could also be computed as
+%   infft(y,'m',4,'p',4,'n',2*N,'eps_I',4*4/(2*N),'sigma',2);
+
+plan.f = f;
+infft_trafo(plan);
+
+fbar = plan.fbar;                                   % Approximated Fourier coefficients
+times = plan.times;                                 % Computing times
+
+err_max_abs = max(abs(fhat-fbar));                  % Maximum absolute error
+err_max_rel = max(abs(fhat-fbar)./abs(fhat));       % Maximum relative error
+err_mean_abs = sum(abs(fhat-fbar))/N;               % Mean absolute error
+err_mean_rel = sum(abs(fhat-fbar)./abs(fhat))/N;	% Mean relative error
+
+%% Direct computation
+
+infft_direct(plan,f);
+
+fbar_direct = plan.fbar_direct;                     % Direcly computed Fourier coefficients
+times.t_direct = plan.times.t_direct;
\ No newline at end of file
diff --git a/matlab/malloc.c b/matlab/malloc.c
index 753724b..4909f05 100644
--- a/matlab/malloc.c
+++ b/matlab/malloc.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
@@ -27,6 +27,9 @@ void *nfft_mex_malloc(size_t n)
 
  #pragma omp critical (nfft_omp_matlab)
  {
+  if (n == 0)
+    n = 1;
+
   p = mxMalloc(n);
 
   /* Should never be reached if mxMalloc fails (in a mex file) but in Matlab
diff --git a/matlab/nfct/Contents.m b/matlab/nfct/Contents.m
new file mode 100644
index 0000000..d43f0e7
--- /dev/null
+++ b/matlab/nfct/Contents.m
@@ -0,0 +1,30 @@
+% NFCT
+%
+% Files
+%   FFT_OUT_OF_PLACE    - FFT flag
+%   FFTW_ESTIMATE       - FFT flag
+%   FFTW_MEASURE        - FFT flag
+%   FG_PSI              - Precompuation flag
+%   ndct_adjoint        - Adjoint nonequispaced discrete cosine transform (direct algorithm)
+%   ndct_trafo          - Nonequispaced discrete cosine transform (direct algorithm)
+%   nfct_adjoint        - Adjoint nonequispaced fast cosine transform
+%   nfct_finalize       - Finalize plan
+%   nfct_get_f          - Get function values from plan
+%   nfct_get_f_hat      - Get Fourier coefficients from plan
+%   nfct_get_x          - Get nodes from plan
+%   nfct_init_1d        - Initialise plans
+%   nfct_init_2d        - Initialise plans
+%   nfct_init_3d        - Initialise plans
+%   nfct_init_guru      - Initialise plans, no error handling
+%   nfct_precompute_psi - Precompute psi, dependent on nodes x
+%   nfct_set_f          - Set function values in plan
+%   nfct_set_f_hat      - Set Fourier coefficients in plan
+%   nfct_set_x          - Set nodes in plan
+%   nfct_trafo          - nonequispaced fast cosine transform
+%   nfctmex             - Gateway function to NFCT module from NFFT3
+%   PRE_FG_PSI          - Precomputation flag
+%   PRE_FULL_PSI        - Precomputation flag
+%   PRE_LIN_PSI         - Precomputation flag
+%   PRE_PHI_HUT         - Precomputation flag
+%   PRE_PSI             - Precomputation flag
+%   simple_test         - Example program: Basic usage principles
diff --git a/matlab/nfft/FFTW_ESTIMATE.m b/matlab/nfct/FFTW_ESTIMATE.m
similarity index 86%
copy from matlab/nfft/FFTW_ESTIMATE.m
copy to matlab/nfct/FFTW_ESTIMATE.m
index ea4848b..4a2ab18 100644
--- a/matlab/nfft/FFTW_ESTIMATE.m
+++ b/matlab/nfct/FFTW_ESTIMATE.m
@@ -1,9 +1,9 @@
 % FFTW_ESTIMATE FFT flag
 %   Valid for FFTW3
 %
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfft/FFTW_MEASURE.m b/matlab/nfct/FFTW_MEASURE.m
similarity index 86%
copy from matlab/nfft/FFTW_MEASURE.m
copy to matlab/nfct/FFTW_MEASURE.m
index bbdd8c8..1c352a3 100644
--- a/matlab/nfft/FFTW_MEASURE.m
+++ b/matlab/nfct/FFTW_MEASURE.m
@@ -1,9 +1,9 @@
 %FFTW_MEASURE FFT flag
 %   Valid for FFTW3
 %
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfft/FFT_OUT_OF_PLACE.m b/matlab/nfct/FFT_OUT_OF_PLACE.m
similarity index 87%
copy from matlab/nfft/FFT_OUT_OF_PLACE.m
copy to matlab/nfct/FFT_OUT_OF_PLACE.m
index 2bb217e..15afa2f 100644
--- a/matlab/nfft/FFT_OUT_OF_PLACE.m
+++ b/matlab/nfct/FFT_OUT_OF_PLACE.m
@@ -1,9 +1,9 @@
 %FFT_OUT_OF_PLACE FFT flag
 %   If this flag is set, FFTW uses disjoint input/output vectors.
 %
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfft/FG_PSI.m b/matlab/nfct/FG_PSI.m
similarity index 88%
copy from matlab/nfft/FG_PSI.m
copy to matlab/nfct/FG_PSI.m
index d892abd..09435b3 100644
--- a/matlab/nfft/FG_PSI.m
+++ b/matlab/nfct/FG_PSI.m
@@ -3,9 +3,9 @@
 %   sparse matrix B) uses particular properties of the Gaussian window function
 %   to trade multiplications for direct calls to exponential function.
 %
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfct/Makefile.am b/matlab/nfct/Makefile.am
new file mode 100644
index 0000000..a30b72f
--- /dev/null
+++ b/matlab/nfct/Makefile.am
@@ -0,0 +1,44 @@
+# compiler flags
+AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/matlab $(matlab_CPPFLAGS)
+
+# matlab wrapper directory
+nfctmatlabdir = $(datadir)/nfft/matlab/nfct
+
+# library
+lib_LTLIBRARIES = libnfct.la
+libnfct_la_SOURCES = nfctmex.c
+
+libnfct_la_LIBADD = $(top_builddir)/libnfft3_matlab.la @matlab_fftw3_LIBS@ $(top_builddir)/matlab/libmatlab.la $(matlab_LIBS)
+
+libnfct_la_LDFLAGS = -no-undefined -module -shared -shrext $(matlab_mexext) -avoid-version @matlab_fftw3_LDFLAGS@ $(matlab_LDFLAGS)
+
+if HAVE_MATLAB_THREADS
+libnfct_la_CFLAGS = $(OPENMP_CFLAGS)
+endif
+
+dist_nfctmatlab_DATA = Contents.m FFTW_ESTIMATE.m FFTW_MEASURE.m \
+	FFT_OUT_OF_PLACE.m FG_PSI.m PRE_FG_PSI.m PRE_FULL_PSI.m PRE_LIN_PSI.m \
+	PRE_PHI_HUT.m PRE_PSI.m ndct_adjoint.m ndct_trafo.m nfct.m \
+	nfct_adjoint.m nfct_finalize.m nfct_get_f.m nfct_get_f_hat.m \
+	nfct_get_num_threads.m nfct_get_x.m nfct_init_1d.m nfct_init_2d.m \
+	nfct_init_3d.m nfct_init_guru.m nfct_set_f.m nfct_set_f_hat.m \
+	nfct_set_x.m nfct_trafo.m simple_test.m test_nfct1d.m test_nfct2d.m \
+	test_nfct3d.m
+
+# target all-am builds .libs/libnfct at matlab_mexext@
+nfctmex at matlab_mexext@: all-am
+	rm -f ./nfctmex at matlab_mexext@
+	$(LN_S) .libs/libnfct at matlab_mexext@ ./nfctmex at matlab_mexext@
+
+all: all-am nfctmex at matlab_mexext@
+
+clean: clean-am
+	rm -f ./nfctmex at matlab_mexext@
+
+install-exec-hook:
+	rm -f $(libdir)/nfctmex at matlab_mexext@
+	$(LN_S) $(libdir)/libnfct at matlab_mexext@ $(libdir)/nfctmex at matlab_mexext@
+
+uninstall-hook:
+	rm -f $(libdir)/nfctmex at matlab_mexext@
+
diff --git a/matlab/nfft/PRE_FG_PSI.m b/matlab/nfct/PRE_FG_PSI.m
similarity index 89%
copy from matlab/nfft/PRE_FG_PSI.m
copy to matlab/nfct/PRE_FG_PSI.m
index 6824e44..d5262f3 100644
--- a/matlab/nfft/PRE_FG_PSI.m
+++ b/matlab/nfct/PRE_FG_PSI.m
@@ -4,9 +4,9 @@
 %   multiplications for direct calls to exponential function (the remaining 2dM
 %   direct calls are precomputed).
 %
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfft/PRE_FULL_PSI.m b/matlab/nfct/PRE_FULL_PSI.m
similarity index 88%
copy from matlab/nfft/PRE_FULL_PSI.m
copy to matlab/nfct/PRE_FULL_PSI.m
index ad6761e..b2b403f 100644
--- a/matlab/nfft/PRE_FULL_PSI.m
+++ b/matlab/nfct/PRE_FULL_PSI.m
@@ -3,9 +3,9 @@
 %   matrix B) uses (2m+2)^dM precomputed values of the window function, in
 %   addition indices of source and target vectors are stored.
 %
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nnfft/PRE_LIN_PSI.m b/matlab/nfct/PRE_LIN_PSI.m
similarity index 89%
copy from matlab/nnfft/PRE_LIN_PSI.m
copy to matlab/nfct/PRE_LIN_PSI.m
index dfab51c..a139fbf 100644
--- a/matlab/nnfft/PRE_LIN_PSI.m
+++ b/matlab/nfct/PRE_LIN_PSI.m
@@ -3,9 +3,9 @@
 %   matrix B) uses linear interpolation from a lookup table of equispaced samples
 %   of the window function instead of exact values of the window function.
 %
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfft/PRE_PHI_HUT.m b/matlab/nfct/PRE_PHI_HUT.m
similarity index 88%
copy from matlab/nfft/PRE_PHI_HUT.m
copy to matlab/nfct/PRE_PHI_HUT.m
index a66ae1d..61871d3 100644
--- a/matlab/nfft/PRE_PHI_HUT.m
+++ b/matlab/nfct/PRE_PHI_HUT.m
@@ -3,9 +3,9 @@
 %   diagonal matrix D) uses precomputed values of the Fourier transformed window
 %   function.
 %
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nnfft/PRE_PSI.m b/matlab/nfct/PRE_PSI.m
similarity index 88%
copy from matlab/nnfft/PRE_PSI.m
copy to matlab/nfct/PRE_PSI.m
index 482b8fc..4b93aac 100644
--- a/matlab/nnfft/PRE_PSI.m
+++ b/matlab/nfct/PRE_PSI.m
@@ -1,9 +1,9 @@
 %PRE_PSI Precomputation flag
 %   If this flag is set, the convolution step (the multiplication with the sparse
 %   matrix B uses (2m+2)dM precomputed values of the window function.
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfft/ndft_trafo.m b/matlab/nfct/ndct_adjoint.m
similarity index 73%
copy from matlab/nfft/ndft_trafo.m
copy to matlab/nfct/ndct_adjoint.m
index f72517d..f444c0a 100644
--- a/matlab/nfft/ndft_trafo.m
+++ b/matlab/nfct/ndct_adjoint.m
@@ -1,7 +1,7 @@
-%NDFT_TRAFO  Nonequispaced discrete Fourier transformation (direct algorithm)
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%NDCT_ADJOINT Adjoint nonequispaced discrete cosine transform (direct algorithm)
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -16,6 +16,6 @@
 % You should have received a copy of the GNU General Public License along with
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-function ndft_trafo(p)
+function ndct_adjoint(p)
 
-nfftmex('trafo_direct',p)
+nfctmex('adjoint_direct',p)
diff --git a/matlab/nfft/nfft_adjoint.m b/matlab/nfct/ndct_trafo.m
similarity index 74%
copy from matlab/nfft/nfft_adjoint.m
copy to matlab/nfct/ndct_trafo.m
index 3272b5d..16a1bba 100644
--- a/matlab/nfft/nfft_adjoint.m
+++ b/matlab/nfct/ndct_trafo.m
@@ -1,7 +1,7 @@
-%NFFT_ADJOINT Adjoint nonequispaced fast Fourier transform
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%NDCT_TRAFO  Nonequispaced discrete cosine transform (direct algorithm)
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -16,6 +16,6 @@
 % You should have received a copy of the GNU General Public License along with
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-function nfft_adjoint(p)
+function ndct_trafo(p)
 
-nfftmex('adjoint',p)
+nfctmex('trafo_direct',p)
diff --git a/matlab/nfft/nfft.m b/matlab/nfct/nfct.m
similarity index 69%
copy from matlab/nfft/nfft.m
copy to matlab/nfct/nfct.m
index 16f5ae9..d89ad70 100644
--- a/matlab/nfft/nfft.m
+++ b/matlab/nfct/nfct.m
@@ -1,5 +1,4 @@
-
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -15,11 +14,11 @@
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
-% This class provides robust a Matlab interface to the NFFT library.
+% This class provides a Matlab interface to the NFCT module.
 %
 % Examples
-%   See Matlab scripts test_nfft*d.m.
-classdef nfft < handle
+%   See Matlab scripts test_nfct*d.m.
+classdef nfct < handle
 
 properties(Dependent=true)
 	x;     % nodes (real Mxd matrix)
@@ -53,30 +52,30 @@ methods
 
 % Constructer and destructor %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-function h=nfft(d,N,M,varargin)
+function h=nfct(d,N,M,varargin)
 % Constructor
 %
-% h=nfft(1,N,M) for spatial dimension d=1
-% h=nfft(2,N,M) for spatial dimension d=2
-% h=nfft(3,N,M) for spatial dimension d=3
+% h=nfct(1,N,M) for spatial dimension d=1
+% h=nfct(2,N,M) for spatial dimension d=2
+% h=nfct(3,N,M) for spatial dimension d=3
 %
-% h=nfft(d,N,M,varargin) for use of nfft_init_guru
+% h=nfct(d,N,M,varargin) for use of nfct_init_guru
 % For example
-% h=nfft(1,N,M,n,7,bitor(PRE_PHI_HUT,PRE_PSI),FFTW_MEASURE)     for d=1, m=7
-% h=nfft(2,N,M,n,n,7,bitor(PRE_PHI_HUT,bitor(PRE_PSI,NFFT_OMP_BLOCKWISE_ADJOINT)),FFTW_MEASURE)   for d=2, m=7
-% h=nfft(3,N,M,n,n,n,7,bitor(PRE_PHI_HUT,bitor(PRE_PSI,NFFT_OMP_BLOCKWISE_ADJOINT)),FFTW_MEASURE) for d=3, m=7
+% h=nfct(1,N,M,n,7,bitor(PRE_PHI_HUT,PRE_PSI),FFTW_MEASURE)     for d=1, m=7
+% h=nfct(2,N,M,n,n,7,bitor(PRE_PHI_HUT,bitor(PRE_PSI,NFFT_OMP_BLOCKWISE_ADJOINT)),FFTW_MEASURE)   for d=2, m=7
+% h=nfct(3,N,M,n,n,n,7,bitor(PRE_PHI_HUT,bitor(PRE_PSI,NFFT_OMP_BLOCKWISE_ADJOINT)),FFTW_MEASURE) for d=3, m=7
 % with n=2^(ceil(log(max(N))/log(2))+1)
-% Be careful: There is no error handling with using nfft_init_guru.
+% Be careful: There is no error handling with using nfct_init_guru.
 % Incorrect inputs can cause a Matlab crash!
 %
 % INPUT
 %   d         spatial dimension (d=1, d=2 or d=3)
 %   N         numbers of nodes in each direction (column vector of length d with positive even integers)
 %   M         number of sampling points (positive integer)
-%   varargin  parameters for use of nfft_init_guru (see documentation of NFFT for more details)
+%   varargin  parameters for use of nfct_init_guru (see documentation of NFCT for more details)
 %
 % OUTPUT
-%   h   object of class type nfft
+%   h   object of class type nfct
 
 	h.d=d;
 
@@ -93,19 +92,19 @@ function h=nfft(d,N,M,varargin)
 	elseif( 3==nargin )
 		switch d
 		case 1
-			h.plan=nfftmex('init_1d',N,M);
+			h.plan=nfctmex('init_1d',N,M);
 			h.plan_is_set=true;
 		case 2
-			h.plan=nfftmex('init_2d',N(1),N(2),M);
+			h.plan=nfctmex('init_2d',N(1),N(2),M);
 			h.plan_is_set=true;
 		case 3
-			h.plan=nfftmex('init_3d',N(1),N(2),N(3),M);
+			h.plan=nfctmex('init_3d',N(1),N(2),N(3),M);
 			h.plan_is_set=true;
 		otherwise
 			error('Invalid spatial dimension d.');
 		end %switch
-	else % nfft_init_guru
-		%disp('You are using nfft_init_guru. This is on your own risk. There will be no error handling. Incorrect inputs can cause a Matlab crash.');
+	else % nfct_init_guru
+		%disp('You are using nfct_init_guru. This is on your own risk. There will be no error handling. Incorrect inputs can cause a Matlab crash.');
 		switch d
 		case 1
 			args=[{d,N(1),M},varargin];
@@ -116,7 +115,7 @@ function h=nfft(d,N,M,varargin)
 		otherwise
 			error('Unknown error.');
 		end %switch
-		h.plan=nfftmex('init_guru',args);
+		h.plan=nfctmex('init_guru',args);
 		h.plan_is_set=true;
 	end %if
 end %function
@@ -124,7 +123,7 @@ end %function
 function delete(h)
 % Destructor
 	if(h.plan_is_set)
-		nfftmex('finalize',h.plan);
+		nfctmex('finalize',h.plan);
 	end %if
 end %function
 
@@ -179,7 +178,7 @@ function set.N3(h,N)
 end %function
 
 function set.M(h,M)
-	if( ndims(M)~=2 || size(M,1)~=1 || size(M,2)~=1)
+	if( ~ismatrix(M) || size(M,1)~=1 || size(M,2)~=1)
 		error('The number of sampling pints M has to be an positive integer.');
 	elseif( isempty(M) || ~isnumeric(M) || ~isreal(M) || mod(M,1)~=0 || ~(M>0) )
 		error('The number of sampling pints M has to be an positive integer.');
@@ -198,10 +197,10 @@ function set.x(h,x)
 	elseif( size(x,1)~=h.M || size(x,2)~=h.d )
 		error('The sampling points have to be a %ux%u matrix',h.M,h.d);
 	else
-		x=mod(x+0.5,1)-0.5;
-		nfftmex('set_x',h.plan,x.');
+		x=mod(x,0.5);
+		nfctmex('set_x',h.plan,x.');
 		h.x_is_set=true;
-		h.precomputations_done=false;
+		h.precomputations_done=true; % precompute is called within set_x
 	end %if
 end %function
 
@@ -226,11 +225,11 @@ function set.fhat(h,fhat)
 		case 1
 			% Do nothing.
 		case 2
-			% linearization in matlab with column (:) operator is columnwise, in NFFT it is rowwise
+			% linearization in matlab with column (:) operator is columnwise, in NFCT it is rowwise
 			fhat=reshape(fhat,h.N1,h.N2).';
 			fhat=fhat(:);
 		case 3
-			% linearization in matlab with column (:) operator is columnwise, in NFFT it is rowwise
+			% linearization in matlab with column (:) operator is columnwise, in NFCT it is rowwise
 			fhat=reshape(fhat,h.N1,h.N2,h.N3);
 			fhat=permute(fhat,[3,2,1]);
 			fhat=fhat(:);
@@ -238,7 +237,7 @@ function set.fhat(h,fhat)
 			error('Unknown error.');
 		end %switch
 
-		nfftmex('set_f_hat',h.plan,fhat);
+		nfctmex('set_f_hat',h.plan,fhat);
 		h.fhat_is_set=true;
 	end %if
 end %function
@@ -249,7 +248,7 @@ function set.f(h,f)
 	elseif( size(f,1)~=h.M || size(f,2)~=1 )
 		error('The samples f have to be an column vector of length M=%u',h.M);
 	else
-		nfftmex('set_f',h.plan,f);
+		nfctmex('set_f',h.plan,f);
 		h.f_is_set=true;
 	end %if
 end %function
@@ -258,7 +257,7 @@ end %function
 
 function x=get.x(h)
 	if(h.x_is_set)
-		x=nfftmex('get_x',h.plan).';
+		x=nfctmex('get_x',h.plan).';
 	else
 		x=[];
 	end %if
@@ -266,17 +265,17 @@ end %function
 
 function fhat=get.fhat(h)
 	if(h.fhat_is_set)
-		fhat=nfftmex('get_f_hat',h.plan);
+		fhat=nfctmex('get_f_hat',h.plan);
 
 		switch h.d
 		case 1
 			% Do nothing.
 		case 2
-			% linearization in matlab with column (:) operator is columnwise, in NFFT it is rowwise
+			% linearization in matlab with column (:) operator is columnwise, in NFCT it is rowwise
 			fhat=reshape(fhat,h.N2,h.N1).';
 			fhat=fhat(:);
 		case 3
-			% linearization in matlab with column (:) operator is columnwise, in NFFT it is rowwise
+			% linearization in matlab with column (:) operator is columnwise, in NFCT it is rowwise
 			fhat=reshape(fhat,h.N3,h.N2,h.N1);
 			fhat=permute(fhat,[3,2,1]);
 			fhat=fhat(:);
@@ -290,7 +289,7 @@ end %funcition
 
 function f=get.f(h)
 	if(h.f_is_set)
-		f=nfftmex('get_f',h.plan);
+		f=nfctmex('get_f',h.plan);
 	else
 		f=[];
 	end %if
@@ -302,84 +301,92 @@ end %function
 
 % User methods %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-function nfft_precompute_psi(h)
-% Precomputations for NFFT.
-	if(~h.x_is_set)
-		error('Before doing precomputations you have to set nodes in x.');
-	else
-		nfftmex('precompute_psi',h.plan)
-		h.precomputations_done=true;
-	end %if
-end %function
-
-function ndft_trafo(h)
-% NDFT.
+% function nfct_precompute_psi(h)
+% % Precomputations for NFCT.
+% 	if(~h.x_is_set)
+% 		error('Before doing precomputations you have to set nodes in x.');
+% 	else
+% 		nfctmex('precompute_psi',h.plan)
+% 		h.precomputations_done=true;
+% 	end %if
+% end %function
+
+function ndct_trafo(h)
+% NDCT.
 %
-% ndft_trafo(h)
+% ndct_trafo(h)
 %
 % INPUT
-%   h  object of class type nfft
+%   h  object of class type nfct
 
-	if(~h.precomputations_done)
-		error('Before doing a NFFT transform you have to do precomputations.');
+% 	if(~h.precomputations_done)
+% 		error('Before doing a NFCT transform you have to do precomputations.');
+	if(~h.x_is_set)
+		error('Before doing a NFCT transform you have to set the x nodes.');
 	elseif(~h.fhat_is_set)
-		error('Before doing a NFFT transform you have to set Fourier coefficients in fhat.');
+		error('Before doing a NFCT transform you have to set Fourier coefficients in fhat.');
 	else
-		nfftmex('trafo_direct',h.plan);
+		nfctmex('trafo_direct',h.plan);
 		h.f_is_set=true;
 	end %if
 end %function
 
-function nfft_trafo(h)
-% NFFT.
+function nfct_trafo(h)
+% NFCT.
 %
-% nfft_trafo(h)
+% nfct_trafo(h)
 %
 % INPUT
-%   h  object of class type nfft
+%   h  object of class type nfct
 
-	if(~h.precomputations_done)
-		error('Before doing a NFFT transform you have to do precomputations.');
+% 	if(~h.precomputations_done)
+% 		error('Before doing a NFCT transform you have to do precomputations.');
+	if(~h.x_is_set)
+		error('Before doing a NFCT transform you have to set the x nodes.');
 	elseif(~h.fhat_is_set)
-		error('Before doing a NFFT transform you have to set Fourier coefficients in fhat.');
+		error('Before doing a NFCT transform you have to set Fourier coefficients in fhat.');
 	else
-		nfftmex('trafo',h.plan);
+		nfctmex('trafo',h.plan);
 		h.f_is_set=true;
 	end %if
 end %function
 
-function ndft_adjoint(h)
-% Adjoint NDFT.
+function ndct_adjoint(h)
+% Adjoint NDCT.
 %
-% ndft_adjoint(h)
+% ndct_adjoint(h)
 %
 % INPUT
-%   h  object of class type nfft
+%   h  object of class type nfct
 
-	if(~h.precomputations_done)
-		error('Before doing a adjoint NFFT transform you have to do precomputations.');
+% 	if(~h.precomputations_done)
+% 		error('Before doing a adjoint NFCT transform you have to do precomputations.');
+	if(~h.x_is_set)
+		error('Before doing an adjoint NFCT transform you have to set the x nodes.');
 	elseif(~h.f_is_set)
-		error('Before doing a adjoint NFFT transform you have to set samples in f.');
+		error('Before doing an adjoint NFCT transform you have to set samples in f.');
 	else
-		nfftmex('adjoint_direct',h.plan);
+		nfctmex('adjoint_direct',h.plan);
 		h.fhat_is_set=true;
 	end %if
 end %function
 
-function nfft_adjoint(h)
-% Adjoint NFFT
+function nfct_adjoint(h)
+% Adjoint NFCT
 %
-% nfft_adjoint(h)
+% nfct_adjoint(h)
 %
 % INPUT
-%   h  object of class type nfft
+%   h  object of class type nfct
 
-	if(~h.precomputations_done)
-		error('Before doing a adjoint NFFT transform you have to do precomputations.');
+% 	if(~h.precomputations_done)
+% 		error('Before doing a adjoint NFCT transform you have to do precomputations.');
+	if(~h.x_is_set)
+		error('Before doing an adjoint NFCT transform you have to set the x nodes.');
 	elseif(~h.f_is_set)
-		error('Before doing a adjoint NFFT transform you have to set samples in f.');
+		error('Before doing a adjoint NFCT transform you have to set samples in f.');
 	else
-		nfftmex('adjoint',h.plan);
+		nfctmex('adjoint',h.plan);
 		h.fhat_is_set=true;
 	end %if
 end %function
diff --git a/matlab/nfft/nfft_get_f.m b/matlab/nfct/nfct_adjoint.m
similarity index 75%
copy from matlab/nfft/nfft_get_f.m
copy to matlab/nfct/nfct_adjoint.m
index 02aed96..bafc309 100644
--- a/matlab/nfft/nfft_get_f.m
+++ b/matlab/nfct/nfct_adjoint.m
@@ -1,7 +1,7 @@
-%NFFT_GET_F Get function values from plan
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%NFCT_ADJOINT Adjoint nonequispaced fast cosine transform
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -16,6 +16,6 @@
 % You should have received a copy of the GNU General Public License along with
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-function f = nfft_get_f(p)
+function nfct_adjoint(p)
 
-f = nfftmex('get_f',p);
+nfctmex('adjoint',p)
diff --git a/matlab/nfft/nfft_set_x.m b/matlab/nfct/nfct_finalize.m
similarity index 77%
copy from matlab/nfft/nfft_set_x.m
copy to matlab/nfct/nfct_finalize.m
index 997620e..e3ef4fc 100644
--- a/matlab/nfft/nfft_set_x.m
+++ b/matlab/nfct/nfct_finalize.m
@@ -1,7 +1,7 @@
-%NFFT_SET_X Set nodes in plan
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%NFCT_FINALIZE Finalize plan
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -16,6 +16,6 @@
 % You should have received a copy of the GNU General Public License along with
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-function nfft_set_x(p,x)
+function nfct_finalize(p)
 
-nfftmex('set_x',p,x)
+nfctmex('finalize',p)
diff --git a/matlab/nfft/nfft_get_f.m b/matlab/nfct/nfct_get_f.m
similarity index 76%
copy from matlab/nfft/nfft_get_f.m
copy to matlab/nfct/nfct_get_f.m
index 02aed96..f17fbbb 100644
--- a/matlab/nfft/nfft_get_f.m
+++ b/matlab/nfct/nfct_get_f.m
@@ -1,7 +1,7 @@
-%NFFT_GET_F Get function values from plan
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%NFCT_GET_F Get function values from plan
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -16,6 +16,6 @@
 % You should have received a copy of the GNU General Public License along with
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-function f = nfft_get_f(p)
+function f = nfct_get_f(p)
 
-f = nfftmex('get_f',p);
+f = nfctmex('get_f',p);
diff --git a/matlab/nfft/nfft_adjoint.m b/matlab/nfct/nfct_get_f_hat.m
similarity index 74%
copy from matlab/nfft/nfft_adjoint.m
copy to matlab/nfct/nfct_get_f_hat.m
index 3272b5d..de13f02 100644
--- a/matlab/nfft/nfft_adjoint.m
+++ b/matlab/nfct/nfct_get_f_hat.m
@@ -1,7 +1,7 @@
-%NFFT_ADJOINT Adjoint nonequispaced fast Fourier transform
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%NFCT_GET_F_HAT Get Fourier coefficients from plan
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -16,6 +16,6 @@
 % You should have received a copy of the GNU General Public License along with
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-function nfft_adjoint(p)
+function f_hat = nfct_get_f_hat(p)
 
-nfftmex('adjoint',p)
+f_hat = nfctmex('get_f_hat',p);
diff --git a/matlab/nfft/nfft_get_num_threads.m b/matlab/nfct/nfct_get_num_threads.m
similarity index 72%
copy from matlab/nfft/nfft_get_num_threads.m
copy to matlab/nfct/nfct_get_num_threads.m
index 14495fc..01ebde8 100644
--- a/matlab/nfft/nfft_get_num_threads.m
+++ b/matlab/nfct/nfct_get_num_threads.m
@@ -1,7 +1,7 @@
-%NFFT_GET_NUM_THREADS Get number of threads (at most) used for computation
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%NFCT_GET_NUM_THREADS Get number of threads (at most) used for computation
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -16,6 +16,6 @@
 % You should have received a copy of the GNU General Public License along with
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-function nthreads = nfft_get_num_threads()
+function nthreads = nfct_get_num_threads()
 
-nthreads = nfftmex('get_num_threads');
+nthreads = nfctmex('get_num_threads');
diff --git a/matlab/nfft/nfft_set_x.m b/matlab/nfct/nfct_get_x.m
similarity index 77%
copy from matlab/nfft/nfft_set_x.m
copy to matlab/nfct/nfct_get_x.m
index 997620e..97217ba 100644
--- a/matlab/nfft/nfft_set_x.m
+++ b/matlab/nfct/nfct_get_x.m
@@ -1,7 +1,7 @@
-%NFFT_SET_X Set nodes in plan
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%NFCT_GET_X Get nodes from plan
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -16,6 +16,6 @@
 % You should have received a copy of the GNU General Public License along with
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-function nfft_set_x(p,x)
+function x = nfct_get_x(p)
 
-nfftmex('set_x',p,x)
+x = nfctmex('get_x',p);
diff --git a/matlab/nfft/nfft_init_1d.m b/matlab/nfct/nfct_init_1d.m
similarity index 76%
copy from matlab/nfft/nfft_init_1d.m
copy to matlab/nfct/nfct_init_1d.m
index 29167f9..0cea8ab 100644
--- a/matlab/nfft/nfft_init_1d.m
+++ b/matlab/nfct/nfct_init_1d.m
@@ -1,7 +1,7 @@
-%NFFT_INIT_1D Initialise plans
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%NFCT_INIT_1D Initialise plans
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -16,6 +16,6 @@
 % You should have received a copy of the GNU General Public License along with
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-function p = nfft_init_1d(N,M)
+function p = nfct_init_1d(N,M)
 
-p = nfftmex('init_1d',N,M);
+p = nfctmex('init_1d',N,M);
diff --git a/matlab/nfft/nfft_get_f.m b/matlab/nfct/nfct_init_2d.m
similarity index 76%
copy from matlab/nfft/nfft_get_f.m
copy to matlab/nfct/nfct_init_2d.m
index 02aed96..97c5ca9 100644
--- a/matlab/nfft/nfft_get_f.m
+++ b/matlab/nfct/nfct_init_2d.m
@@ -1,7 +1,7 @@
-%NFFT_GET_F Get function values from plan
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%NFCT_INIT_2D Initialise plans
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -16,6 +16,6 @@
 % You should have received a copy of the GNU General Public License along with
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-function f = nfft_get_f(p)
+function p = nfct_init_2d(N1,N2,M)
 
-f = nfftmex('get_f',p);
+p = nfctmex('init_2d',N1,N2,M);
diff --git a/matlab/nfft/nfft_get_f.m b/matlab/nfct/nfct_init_3d.m
similarity index 75%
copy from matlab/nfft/nfft_get_f.m
copy to matlab/nfct/nfct_init_3d.m
index 02aed96..22db073 100644
--- a/matlab/nfft/nfft_get_f.m
+++ b/matlab/nfct/nfct_init_3d.m
@@ -1,7 +1,7 @@
-%NFFT_GET_F Get function values from plan
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%NFCT_INIT_3D Initialise plans
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -16,6 +16,6 @@
 % You should have received a copy of the GNU General Public License along with
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-function f = nfft_get_f(p)
+function p = nfct_init_3d(N1,N2,N3,M)
 
-f = nfftmex('get_f',p);
+p = nfctmex('init_3d',N1,N2,N3,M);
diff --git a/matlab/nfft/nfft_init_guru.m b/matlab/nfct/nfct_init_guru.m
similarity index 77%
copy from matlab/nfft/nfft_init_guru.m
copy to matlab/nfct/nfct_init_guru.m
index 65806d7..701162d 100644
--- a/matlab/nfft/nfft_init_guru.m
+++ b/matlab/nfct/nfct_init_guru.m
@@ -1,7 +1,7 @@
-%NFFT_INIT_GURU Initialise plans, no error handling
+%NFCT_INIT_GURU Initialise plans, no error handling
 %   Matlab might run into a segmentation violation for wrong parameters
 %
-%   nfft_init_guru(d,N1,...,Nd,M,n1,...,nd,m,flags,fftw_flags)
+%   nfct_init_guru(d,N1,...,Nd,M,n1,...,nd,m,flags,fftw_flags)
 %
 %   d            spatial dimension
 %   N1,...,Nd    bandwidths
@@ -12,9 +12,9 @@
 %	             PRE_FULL_PSI} | FFT_OUT_OF_PLACE
 %   fftw_flags   {FFTW_ESTIMATE, FFTW_MEASURE}
 %
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -29,6 +29,6 @@
 % You should have received a copy of the GNU General Public License along with
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-function p = nfft_init_guru(varargin)
+function p = nfct_init_guru(varargin)
 
-p = nfftmex('init_guru',varargin);
+p = nfctmex('init_guru',varargin);
diff --git a/matlab/nfft/nfft_set_f.m b/matlab/nfct/nfct_set_f.m
similarity index 77%
copy from matlab/nfft/nfft_set_f.m
copy to matlab/nfct/nfct_set_f.m
index ada43fc..0bf07d1 100644
--- a/matlab/nfft/nfft_set_f.m
+++ b/matlab/nfct/nfct_set_f.m
@@ -1,7 +1,7 @@
-%NFFT_SET_F Set function values in plan
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%NFCT_SET_F Set function values in plan
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -16,6 +16,6 @@
 % You should have received a copy of the GNU General Public License along with
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-function nfft_set_f(p,f)
+function nfct_set_f(p,f)
 
-nfftmex('set_f',p,f)
+nfctmex('set_f',p,f)
diff --git a/matlab/nfft/nfft_set_f_hat.m b/matlab/nfct/nfct_set_f_hat.m
similarity index 80%
copy from matlab/nfft/nfft_set_f_hat.m
copy to matlab/nfct/nfct_set_f_hat.m
index 8b22904..4993738 100644
--- a/matlab/nfft/nfft_set_f_hat.m
+++ b/matlab/nfct/nfct_set_f_hat.m
@@ -1,7 +1,7 @@
 %NFFT_SET_F_HAT Set Fourier coefficients in plan
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -16,6 +16,6 @@
 % You should have received a copy of the GNU General Public License along with
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-function nfft_set_f_hat(p,f_hat)
+function nfct_set_f_hat(p,f_hat)
 
-nfftmex('set_f_hat',p,f_hat)
+nfctmex('set_f_hat',p,f_hat)
diff --git a/matlab/nfft/nfft_set_x.m b/matlab/nfct/nfct_set_x.m
similarity index 77%
copy from matlab/nfft/nfft_set_x.m
copy to matlab/nfct/nfct_set_x.m
index 997620e..4884d46 100644
--- a/matlab/nfft/nfft_set_x.m
+++ b/matlab/nfct/nfct_set_x.m
@@ -1,7 +1,7 @@
-%NFFT_SET_X Set nodes in plan
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%NFCT_SET_X Set nodes in plan
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -16,6 +16,6 @@
 % You should have received a copy of the GNU General Public License along with
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-function nfft_set_x(p,x)
+function nfct_set_x(p,x)
 
-nfftmex('set_x',p,x)
+nfctmex('set_x',p,x)
diff --git a/matlab/nfft/nfft_init_1d.m b/matlab/nfct/nfct_trafo.m
similarity index 76%
copy from matlab/nfft/nfft_init_1d.m
copy to matlab/nfct/nfct_trafo.m
index 29167f9..f7ae771 100644
--- a/matlab/nfft/nfft_init_1d.m
+++ b/matlab/nfct/nfct_trafo.m
@@ -1,7 +1,7 @@
-%NFFT_INIT_1D Initialise plans
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%NFCT_TRAFO nonequispaced fast cosine transform
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -16,6 +16,6 @@
 % You should have received a copy of the GNU General Public License along with
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-function p = nfft_init_1d(N,M)
+function nfct_trafo(p)
 
-p = nfftmex('init_1d',N,M);
+nfctmex('trafo',p)
diff --git a/matlab/nfft/nfftmex.c b/matlab/nfct/nfctmex.c
similarity index 66%
copy from matlab/nfft/nfftmex.c
copy to matlab/nfct/nfctmex.c
index bde8cb3..23ff9ff 100644
--- a/matlab/nfft/nfftmex.c
+++ b/matlab/nfct/nfctmex.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
@@ -31,66 +31,67 @@
   #include "mexversion.c"
 #endif
 
-#define PLANS_MAX 100 /* maximum number of plans */
+#define PLANS_START 10 /* initial number of plans */
 #define CMD_LEN_MAX 20 /* maximum length of command argument */
 
 /* global flags */
-#define NFFT_MEX_FIRST_CALL (1U << 0)
-unsigned short gflags = NFFT_MEX_FIRST_CALL;
+#define NFCT_MEX_FIRST_CALL (1U << 0)
+static unsigned short gflags = NFCT_MEX_FIRST_CALL;
 
-nfft_plan* plans[PLANS_MAX]; /* plans */
-char cmd[CMD_LEN_MAX];
+static nfct_plan** plans = NULL; /* plans */
+static unsigned int plans_num_allocated = 0;
+static char cmd[CMD_LEN_MAX];
 
 static inline void get_nm(const mxArray *prhs[], int *n, int *m)
 {
-  int t = nfft_mex_get_int(prhs[1],"nfft: Input argument N must be a scalar.");
+  int t = nfft_mex_get_int(prhs[1],"nfct: Input argument N must be a scalar.");
   DM(if ((t < 0) || (t%2!=0))
-    mexErrMsgTxt("nfft: Input argument N must be non-negative and multiple of two.");)
+    mexErrMsgTxt("nfct: Input argument N must be non-negative and multiple of two.");)
   *n = t;
-  t = nfft_mex_get_int(prhs[2],"nfft: Input argument M must be a scalar.");
+  t = nfft_mex_get_int(prhs[2],"nfct: Input argument M must be a scalar.");
   DM(if (t < 1)
-    mexErrMsgTxt("nfft: Input argument M must be positive.");)
+    mexErrMsgTxt("nfct: Input argument M must be positive.");)
   *m = t;
 }
 
 static inline void get_n1n2m(const mxArray *prhs[], int *n1, int *n2, int *m)
 {
-  int t = nfft_mex_get_int(prhs[1],"nfft: Input argument N1 must be a scalar.");
+  int t = nfft_mex_get_int(prhs[1],"nfct: Input argument N1 must be a scalar.");
   DM(if ((t < 0) || (t%2!=0))
-    mexErrMsgTxt("nfft: Input argument N1 must be non-negative and even.");)
+    mexErrMsgTxt("nfct: Input argument N1 must be non-negative and even.");)
   *n1 = t;
 
-  t = nfft_mex_get_int(prhs[2],"nfft: Input argument N2 must be a scalar.");
+  t = nfft_mex_get_int(prhs[2],"nfct: Input argument N2 must be a scalar.");
   DM(if ((t < 0) || (t%2!=0))
-    mexErrMsgTxt("nfft: Input argument N2 must be non-negative and even.");)
+    mexErrMsgTxt("nfct: Input argument N2 must be non-negative and even.");)
   *n2 = t;
 
-  t = nfft_mex_get_int(prhs[3],"nfft: Input argument M must be a scalar.");
+  t = nfft_mex_get_int(prhs[3],"nfct: Input argument M must be a scalar.");
   DM(if (t < 1)
-    mexErrMsgTxt("nfft: Input argument M must be positive.");)
+    mexErrMsgTxt("nfct: Input argument M must be positive.");)
   *m = t;
 }
 
 static inline void get_n1n2n3m(const mxArray *prhs[], int *n1, int *n2, int *n3, int *m)
 {
-  int t = nfft_mex_get_int(prhs[1],"nfft: Input argument N1 must be a scalar.");
+  int t = nfft_mex_get_int(prhs[1],"nfct: Input argument N1 must be a scalar.");
   DM(if ((t < 0) || (t%2!=0))
-    mexErrMsgTxt("nfft: Input argument N1 must be non-negative and even.");)
+    mexErrMsgTxt("nfct: Input argument N1 must be non-negative and even.");)
   *n1 = t;
 
-  t = nfft_mex_get_int(prhs[2],"nfft: Input argument N2 must be a scalar.");
+  t = nfft_mex_get_int(prhs[2],"nfct: Input argument N2 must be a scalar.");
   DM(if ((t < 0) || (t%2!=0))
-    mexErrMsgTxt("nfft: Input argument N2 must be non-negative and even.");)
+    mexErrMsgTxt("nfct: Input argument N2 must be non-negative and even.");)
   *n2 = t;
 
-  t = nfft_mex_get_int(prhs[3],"nfft: Input argument N3 must be a scalar.");
+  t = nfft_mex_get_int(prhs[3],"nfct: Input argument N3 must be a scalar.");
   DM(if ((t < 0) || (t%2!=0))
-    mexErrMsgTxt("nfft: Input argument N3 must be non-negative and even.");)
+    mexErrMsgTxt("nfct: Input argument N3 must be non-negative and even.");)
   *n3 = t;
 
-  t = nfft_mex_get_int(prhs[4],"nfft: Input argument M must be a scalar.");
+  t = nfft_mex_get_int(prhs[4],"nfct: Input argument M must be a scalar.");
   DM(if (t < 1)
-    mexErrMsgTxt("nfft: Input argument M must be positive.");)
+    mexErrMsgTxt("nfct: Input argument M must be positive.");)
   *m = t;
 }
 
@@ -122,20 +123,32 @@ static inline void check_nargs(const int nrhs, const int n, const char* errmsg)
 
 static inline void check_plan(int i)
 {
-  DM(if (i < 0 || i >= PLANS_MAX)
-    mexErrMsgTxt("Invalid plan");)
-  DM(if (plans[i] == 0)
-    mexErrMsgTxt("Plan was not initialized or has already been finalized");)
+  DM(if (i < 0 || i >= plans_num_allocated || plans[i] == 0)
+     mexErrMsgTxt("Plan was not initialized or has already been finalized");)
 }
 
 static inline int mkplan(void)
 {
-  mexLock();
   int i = 0;
-  while (i < PLANS_MAX && plans[i] != 0) i++;
-  if (i == PLANS_MAX)
-    mexErrMsgTxt("nfft: Too many plans already allocated.");
-  plans[i] = nfft_malloc(sizeof(nfft_plan));
+  while (i < plans_num_allocated && plans[i] != 0) i++;
+  if (i == plans_num_allocated)
+  {
+    int l;
+
+    if (plans_num_allocated >= INT_MAX - PLANS_START - 1)
+      mexErrMsgTxt("nfct: Too many plans already allocated.");
+
+    nfct_plan** plans_old = plans;
+    plans = nfft_malloc((plans_num_allocated+PLANS_START)*sizeof(nfct_plan*));
+    for (l = 0; l < plans_num_allocated; l++)
+      plans[l] = plans_old[l];
+    for (l = plans_num_allocated; l < plans_num_allocated+PLANS_START; l++)
+      plans[l] = 0;
+    if (plans_num_allocated > 0)
+      nfft_free(plans_old);
+    plans_num_allocated += PLANS_START;
+  }
+  plans[i] = nfft_malloc(sizeof(nfct_plan));
   return i;
 }
 
@@ -144,23 +157,29 @@ static void cleanup(void)
 {
   int i;
 
-  mexUnlock();
-
-  if (!(gflags & NFFT_MEX_FIRST_CALL))
+  if (!(gflags & NFCT_MEX_FIRST_CALL))
   {
-    for (i = 0; i < PLANS_MAX; i++)
+    for (i = 0; i < plans_num_allocated; i++)
       if (plans[i])
       {
-        nfft_finalize(plans[i]);
-        plans[i] = 0;
+        nfct_finalize(plans[i]);
+	nfft_free(plans[i]);
+	plans[i] = 0;
       }
-    gflags |= NFFT_MEX_FIRST_CALL;
+
+    if (plans_num_allocated > 0)
+    {
+      nfft_free(plans);
+      plans = NULL;
+      plans_num_allocated = 0;
+    }
+    gflags |= NFCT_MEX_FIRST_CALL;
   }
 }
 
 void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
 {
-  if (gflags & NFFT_MEX_FIRST_CALL)
+  if (gflags & NFCT_MEX_FIRST_CALL)
   {
     /* Force Matlab to load libfftw3. There is at least one version of Matlab
      * which otherwise crashes upon invocation of this mex function. */
@@ -168,15 +187,8 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
 
     nfft_mex_install_mem_hooks();
 
-    /* plan pointers to zeros */
-    {
-      int i;
-      for (i = 0; i < PLANS_MAX; i++)
-        plans[i] = 0;
-    }
-
     mexAtExit(cleanup);
-    gflags &= ~NFFT_MEX_FIRST_CALL;
+    gflags &= ~NFCT_MEX_FIRST_CALL;
   }
 
   /* command string */
@@ -197,7 +209,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
       int n, m;
       get_nm(prhs,&n,&m);
       i = mkplan();
-      nfft_init_1d(plans[i],n,m);
+      nfct_init_1d(plans[i],n,m);
       plhs[0] = mxCreateDoubleScalar((double)i);
     }
     return;
@@ -210,7 +222,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
       int n1, n2, m;
       get_n1n2m(prhs,&n1,&n2,&m);
       i = mkplan();
-      nfft_init_2d(plans[i],n1,n2,m);
+      nfct_init_2d(plans[i],n1,n2,m);
       plhs[0] = mxCreateDoubleScalar((double)i);
     }
     return;
@@ -223,7 +235,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
       int n1, n2, n3, m;
       get_n1n2n3m(prhs,&n1,&n2,&n3,&m);
       i = mkplan();
-      nfft_init_3d(plans[i],n1,n2,n3,m);
+      nfct_init_3d(plans[i],n1,n2,n3,m);
       plhs[0] = mxCreateDoubleScalar((double)i);
     }
     return;
@@ -238,11 +250,11 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
     unsigned int f1,f2;
 
     DM(if ((d < 1) || (d>4)) 
-	 mexErrMsgTxt("nfft: Input argument d must be positive and smaller than 5.");)
+	 mexErrMsgTxt("nfct: Input argument d must be positive and smaller than 5.");)
 
     get_guru(prhs,d,N,&M,n,&m,&f1,&f2);
     i = mkplan();
-    nfft_init_guru(plans[i],d,N,M,n,m,
+    nfct_init_guru(plans[i],d,N,M,n,m,
 		   f1 | MALLOC_X | MALLOC_F | MALLOC_F_HAT | FFTW_INIT,
 		   f2);
 
@@ -252,21 +264,23 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
   }
   else if (strcmp(cmd,"precompute_psi") == 0)
   {
-    check_nargs(nrhs,2,"Wrong number of arguments for precompute_one_psi.");
+    mexErrMsgTxt("not implemented, precompute_psi is already called in set_x");
+/*    check_nargs(nrhs,2,"Wrong number of arguments for precompute_psi.");
     {
-      int i = nfft_mex_get_int(prhs[1],"nfft: Input argument plan must be a scalar.");
+      int i = nfft_mex_get_int(prhs[1],"nfct: Input argument plan must be a scalar.");
       check_plan(i);
-      nfft_precompute_one_psi(plans[i]);
+      nfct_precompute_one_psi(plans[i]);
     }
+*/
     return;
   }
   else if (strcmp(cmd,"trafo") == 0)
   {
     check_nargs(nrhs,2,"Wrong number of arguments for trafo.");
     {
-      int i = nfft_mex_get_int(prhs[1],"nfft: Input argument plan must be a scalar.");
+      int i = nfft_mex_get_int(prhs[1],"nfct: Input argument plan must be a scalar.");
       check_plan(i);
-      nfft_trafo(plans[i]);
+      nfct_trafo(plans[i]);
     }
     return;
   }
@@ -274,9 +288,9 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
   {
     check_nargs(nrhs,2,"Wrong number of arguments for adjoint.");
     {
-      int i = nfft_mex_get_int(prhs[1],"nfft: Input argument plan must be a scalar.");
+      int i = nfft_mex_get_int(prhs[1],"nfct: Input argument plan must be a scalar.");
       check_plan(i);
-      nfft_adjoint(plans[i]);
+      nfct_adjoint(plans[i]);
     }
     return;
   }
@@ -284,9 +298,9 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
   {
     check_nargs(nrhs,2,"Wrong number of arguments for finalize.");
     {
-      int i = nfft_mex_get_int(prhs[1],"nfft: Input argument plan must be a scalar.");
+      int i = nfft_mex_get_int(prhs[1],"nfct: Input argument plan must be a scalar.");
       check_plan(i);
-      nfft_finalize(plans[i]);
+      nfct_finalize(plans[i]);
       nfft_free(plans[i]);
       plans[i] = 0;
     }
@@ -296,9 +310,9 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
   {
     check_nargs(nrhs,2,"Wrong number of arguments for trafo direct.");
     {
-      int i = nfft_mex_get_int(prhs[1],"nfft: Input argument plan must be a scalar.");
+      int i = nfft_mex_get_int(prhs[1],"nfct: Input argument plan must be a scalar.");
       check_plan(i);
-      nfft_trafo_direct(plans[i]);
+      nfct_trafo_direct(plans[i]);
     }
     return;
   }
@@ -306,9 +320,9 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
   {
     check_nargs(nrhs,2,"Wrong number of arguments for adjoint direct.");
     {
-      int i = nfft_mex_get_int(prhs[1],"nfft: Input argument plan must be a scalar.");
+      int i = nfft_mex_get_int(prhs[1],"nfct: Input argument plan must be a scalar.");
       check_plan(i);
-      nfft_adjoint_direct(plans[i]);
+      nfct_adjoint_direct(plans[i]);
     }
     return;
   }
@@ -316,7 +330,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
   {
     check_nargs(nrhs,2,"Wrong number of arguments for get_x.");
     {
-      int i = nfft_mex_get_int(prhs[1],"nfft: Input argument plan must be a scalar.");
+      int i = nfft_mex_get_int(prhs[1],"nfct: Input argument plan must be a scalar.");
       int m, d;
       check_plan(i);
       m = plans[i]->M_total;
@@ -336,18 +350,17 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
   {
     check_nargs(nrhs,2,"Wrong number of arguments for get_f.");
     {
-      int i = nfft_mex_get_int(prhs[1],"nfft: Input argument plan must be a scalar.");
+      int i = nfft_mex_get_int(prhs[1],"nfct: Input argument plan must be a scalar.");
       int m;
       check_plan(i);
       m = plans[i]->M_total;
-      plhs[0] = mxCreateDoubleMatrix((unsigned int)m, 1, mxCOMPLEX);
+      plhs[0] = mxCreateDoubleMatrix((unsigned int)m, 1, mxREAL);
       {
-        double *fr = mxGetPr(plhs[0]), *fi = mxGetPi(plhs[0]);
+        double *fr = mxGetPr(plhs[0]);
         int j;
         for (j = 0; j < m; j++)
         {
-          fr[j] = creal(plans[i]->f[j]);
-          fi[j] = cimag(plans[i]->f[j]);
+          fr[j] = plans[i]->f[j];
         }
       }
     }
@@ -357,18 +370,17 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
   {
     check_nargs(nrhs,2,"Wrong number of arguments for get_f_hat.");
     {
-      int i = nfft_mex_get_int(prhs[1],"nfft: Input argument plan must be a scalar.");
+      int i = nfft_mex_get_int(prhs[1],"nfct: Input argument plan must be a scalar.");
       int n;
       check_plan(i);
       n = plans[i]->N_total;
-      plhs[0] = mxCreateDoubleMatrix((unsigned int)n, 1, mxCOMPLEX);
+      plhs[0] = mxCreateDoubleMatrix((unsigned int)n, 1, mxREAL);
       {
-        double *f_hatr = mxGetPr(plhs[0]), *f_hati = mxGetPi(plhs[0]);
+        double *f_hatr = mxGetPr(plhs[0]);
         int k;
         for (k = 0; k < n; k++)
         {
-          f_hatr[k] = creal(plans[i]->f_hat[k]);
-          f_hati[k] = cimag(plans[i]->f_hat[k]);
+          f_hatr[k] = plans[i]->f_hat[k];
         }
       }
     }
@@ -378,7 +390,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
   {
     check_nargs(nrhs,3,"Wrong number of arguments for set_x.");
     {
-      int i = nfft_mex_get_int(prhs[1],"nfft: Input argument plan must be a scalar.");
+      int i = nfft_mex_get_int(prhs[1],"nfct: Input argument plan must be a scalar.");
       int m, d;
       check_plan(i);
       m = plans[i]->M_total;
@@ -392,8 +404,13 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
         int j,t;
         for (j = 0; j < m; j++)
 	  for (t = 0; t < d; t++)
+	  {
+	    DM(if (x[d*j+t] < 0.0 || x[d*j+t] > 0.5)
+	      mexErrMsgTxt("Node coordinates must be within interval [0,0.5]");)
 	    plans[i]->x[d*j+t] = x[d*j+t];
+	  }
       }
+      nfct_precompute_one_psi(plans[i]);
     }
     return;
   }
@@ -401,7 +418,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
   {
     check_nargs(nrhs,3,"Wrong number of arguments for set_f.");
     {
-      int i = nfft_mex_get_int(prhs[1],"nfft: Input argument plan must be a scalar.");
+      int i = nfft_mex_get_int(prhs[1],"nfct: Input argument plan must be a scalar.");
       int m;
       check_plan(i);
       m = plans[i]->M_total;
@@ -410,12 +427,10 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
       {
         double *fr = mxGetPr(prhs[2]), *fi = mxGetPi(prhs[2]);
         int j;
-        if (fi)
-          for (j = 0; j < m; j++)
-            plans[i]->f[j] = fr[j] + _Complex_I*fi[j];
-        else
-          for (j = 0; j < m; j++)
-            plans[i]->f[j] = fr[j];
+        DM(if (fi)
+	  mexErrMsgTxt("Input argument f must be a double vector");)
+        for (j = 0; j < m; j++)
+          plans[i]->f[j] = fr[j];
       }
     }
     return;
@@ -424,7 +439,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
   {
     check_nargs(nrhs,3,"Wrong number of arguments for set_f_hat.");
     {
-      int i = nfft_mex_get_int(prhs[1],"nfft: Input argument plan must be a scalar.");
+      int i = nfft_mex_get_int(prhs[1],"nfct: Input argument plan must be a scalar.");
       int n;
       check_plan(i);
       n = plans[i]->N_total;
@@ -435,12 +450,10 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
       {
         double *f_hatr = mxGetPr(prhs[2]), *f_hati = mxGetPi(prhs[2]);
         int k;
-        if (f_hati)
-          for (k = 0; k < n; k++)
-            plans[i]->f_hat[k] = f_hatr[k] + _Complex_I*f_hati[k];
-        else
-          for (k = 0; k < n; k++)
-            plans[i]->f_hat[k] = f_hatr[k];
+        DM(if (f_hati)
+	  mexErrMsgTxt("Input argument f_hat must be a double vector");)
+        for (k = 0; k < n; k++)
+          plans[i]->f_hat[k] = f_hatr[k];
       }
     }
     return;
@@ -449,7 +462,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
   {
     check_nargs(nrhs,2,"Wrong number of arguments for set_f_hat_linear.");
     {
-      int i = nfft_mex_get_int(prhs[1],"nfft: Input argument plan must be a scalar.");
+      int i = nfft_mex_get_int(prhs[1],"nfct: Input argument plan must be a scalar.");
       mexPrintf("Plan %d\n",i);
       check_plan(i);
       mexPrintf("  pointer: %p\n",plans[i]);
@@ -472,5 +485,5 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
     return;
   }
   else
-    mexErrMsgTxt("nfft: Unknown command.\n");
+    mexErrMsgTxt("nfct: Unknown command.\n");
 }
diff --git a/matlab/nnfft/simple_test.m b/matlab/nfct/simple_test.m
similarity index 52%
copy from matlab/nnfft/simple_test.m
copy to matlab/nfct/simple_test.m
index 96ef23b..d967d38 100644
--- a/matlab/nnfft/simple_test.m
+++ b/matlab/nfct/simple_test.m
@@ -1,8 +1,8 @@
 %SIMPLE_TEST Example program: Basic usage principles
 %
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -18,68 +18,56 @@
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 %
-disp(sprintf('Number of threads: %d\n', nnfft_get_num_threads()));
+fprintf('Number of threads: %d\n', nfct_get_num_threads());
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 disp('A simple one dimensional example');
 
 % maximum degree (bandwidth)
-N = 8;
-%N1=sigma*N;
-N_total=3;
+N = 14;
+
 % number of nodes
-M = 17;
- 
+M = 19;
+
 % nodes
-x=rand(1,M)-0.5;
-%xi=N*(rand(1,N)-0.5);
-v=rand(1,N_total)-0.5;
+x=0.5*rand(1,M);
 
 % Create plan.
-%plan=nnfft_init(1,N_total,M,N);
-plan=nnfft_init_guru(1,N_total,M,N,2*N,6,bitor(PRE_PSI,PRE_PHI_HUT));
+plan = nfct_init_1d(N,M);
 
 % Set nodes.
-nnfft_set_x(plan,x);
-nnfft_set_v(plan,v);
-
+nfct_set_x(plan,x);
 
 % node-dependent precomputation
-nnfft_precompute_psi(plan);
+%nfct_precompute_psi(plan);
 
 % Fourier coefficients
-f_hat = rand(N_total,1)+i*rand(N_total,1);
+f_hat = rand(N,1);
 
 % Set Fourier coefficients.
-nnfft_set_f_hat(plan,double(f_hat));
+nfct_set_f_hat(plan,double(f_hat));
 
 % transform
-nnfft_trafo(plan);
+nfct_trafo(plan);
 
 % function values
-f = nnfft_get_f(plan)
-
-% finalize plan
-%nnfft_finalize(plan);
+f = nfct_get_f(plan);
 
+nfct_adjoint(plan);
 
-%%%%%%%%%%%%%%%%%%%%%
+f_hat_adjoint = nfct_get_f_hat(plan);
 
-nnfft_trafo_direct(plan);
-f2=nnfft_get_f(plan)
 % finalize plan
-nnfft_finalize(plan);
-%%%%%%%%%%%%%%%%%%%%%%%
-
-%A=exp(-2*pi*i*x'*(-N_total/2:N_total/2-1));
-A=exp(-2*pi*1i*x'*N*v);
-f3=A*f_hat
+nfct_finalize(plan);
 
-disp('NNFFT vs NNDFT');
-error_vector=f-f2;
-error_linfl1=norm(f-f2,inf)/norm(f_hat,1)
+A=cos(2*pi*x'*(0:N-1));
+f2 = A*f_hat;
 
-disp('NNFFT vs Direct');
-error_vector=f-f3;
-error_linfl1=norm(f-f3,inf)/norm(f_hat,1)
+f_hat_adjoint2 = A'*f;
 
+error_vector = f-f2;
+error_linfl1 = norm(f-f2,inf)/norm(f_hat,1);
+fprintf('error trafo: %.1e\n', error_linfl1);
 
+error_vector_adjoint = f_hat_adjoint-f_hat_adjoint2;
+error_linfl1_adjoint = norm(f_hat_adjoint-f_hat_adjoint2,inf)/norm(f,1);
+fprintf('error adjoint: %.1e\n', error_linfl1_adjoint);
diff --git a/matlab/nfft/test_nfft1d.m b/matlab/nfct/test_nfct1d.m
similarity index 64%
copy from matlab/nfft/test_nfft1d.m
copy to matlab/nfct/test_nfct1d.m
index 173210d..e7ddb87 100644
--- a/matlab/nfft/test_nfft1d.m
+++ b/matlab/nfct/test_nfct1d.m
@@ -1,5 +1,4 @@
-
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -15,54 +14,54 @@
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
-% Test script of class nfft for spatial dimension d=1.
+% Test script of class nfct for spatial dimension d=1.
 clear all;
 
 M=16; % number of nodes
 N=24; % number of Fourier coefficients in first direction
 
-x=rand(M,1)-0.5; %nodes
+x=0.5*rand(M,1); %nodes
 
 % Initialisation
-plan=nfft(1,N,M); % create plan of class type nfft
+plan=nfct(1,N,M); % create plan of class type nfct
 %n=2^(ceil(log(N)/log(2))+1);
-%plan=nfft(1,N,M,n,7,bitor(PRE_PHI_HUT,PRE_PSI),FFTW_MEASURE); % use of nfft_init_guru
+%plan=nfct(1,N,M,n,7,bitor(PRE_PHI_HUT,PRE_PSI),FFTW_MEASURE); % use of nfct_init_guru
 
 plan.x=x; % set nodes in plan
-nfft_precompute_psi(plan); % precomputations
+%nfct_precompute_psi(plan); % precomputations
 
-% NFFT %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% NFCT %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 fhat=rand(N,1); % Fourier coefficients
 fhatv=fhat(:);
 
-% Compute samples with NFFT
+% Compute samples with NFCT
 plan.fhat=fhatv; % set Fourier coefficients
-nfft_trafo(plan); % compute nonequispaced Fourier transform
+nfct_trafo(plan); % compute nonequispaced Fourier transform
 f1=plan.f; % get samples
 
 % Compute samples direct
-k1=(-N/2:N/2-1).';
+k1=(0:N-1).';
 f2=zeros(M,1);
 for j=1:M
 	x1j=x(j,1);
-	f2(j)=sum( fhatv.*exp(-2*pi*1i*k1*x1j) );
+	f2(j)=sum( fhatv.*cos(2*pi*k1*x1j) );
 end %for
 
 % Compare results
 max(abs(f1-f2))
 
-% Adjoint NFFT %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Adjoint NFCT %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-% Computation with NFFT
-nfft_adjoint(plan);
+% Computation with NFCT
+nfct_adjoint(plan);
 fhat1=plan.fhat;
 
 % Direct computation
 fhat2=zeros(N,1);
 for j=1:N
 	k1j=k1(j);
-	fhat2(j)=sum( plan.f.*exp(2*pi*1i*k1j*x(:,1)) );
+	fhat2(j)=sum( plan.f.*cos(2*pi*k1j*x(:,1)) );
 end %for
 
 % Compare results
diff --git a/matlab/nfft/test_nfft2d.m b/matlab/nfct/test_nfct2d.m
similarity index 65%
copy from matlab/nfft/test_nfft2d.m
copy to matlab/nfct/test_nfct2d.m
index 962d873..1d582a6 100644
--- a/matlab/nfft/test_nfft2d.m
+++ b/matlab/nfct/test_nfct2d.m
@@ -1,5 +1,5 @@
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -15,7 +15,7 @@
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
-% Test script of class nfft for spatial dimension d=2.
+% Test script of class nfct for spatial dimension d=2.
 clear all;
 
 M=16; % number of nodes
@@ -23,29 +23,29 @@ N1=24; % number of Fourier coefficients in first direction
 N2=32; % number of Fourier coefficients in second direction
 N=[N1;N2];
 
-x=rand(M,2)-0.5; %nodes
+x=0.5*rand(M,2); %nodes
 
 % Initialisation
-plan=nfft(2,N,M); % create plan of class type nfft
+plan=nfct(2,N,M); % create plan of class type nfct
 %n=2^(ceil(log(max(N))/log(2))+1);
-%plan=nfft(2,N,M,n,n,7,bitor(PRE_PHI_HUT,bitor(PRE_PSI,NFFT_OMP_BLOCKWISE_ADJOINT)),FFTW_MEASURE); % use of nfft_init_guru
+%plan=nfct(2,N,M,n,n,7,bitor(PRE_PHI_HUT,bitor(PRE_PSI,NFFT_OMP_BLOCKWISE_ADJOINT)),FFTW_MEASURE); % use of nfct_init_guru
 
 plan.x=x; % set nodes in plan
-nfft_precompute_psi(plan); % precomputations
+%nfct_precompute_psi(plan); % precomputations
 
-% NFFT %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% NFCT %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 fhat=rand(N1,N2); % Fourier coefficients
 fhatv=fhat(:);
 
-% Compute samples with NFFT
+% Compute samples with NFCT
 plan.fhat=fhatv; % set Fourier coefficients
-nfft_trafo(plan); % compute nonequispaced Fourier transform
+nfct_trafo(plan); % compute nonequispaced Fourier transform
 f1=plan.f; % get samples
 
 % Compute samples direct
-k1=-N1/2:N1/2-1;
-k2=-N2/2:N2/2-1;
+k1=0:N1-1;
+k2=0:N2-1;
 [K1,K2]=ndgrid(k1,k2);
 k1=K1(:); clear K1;
 k2=K2(:); clear K2;
@@ -53,16 +53,16 @@ f2=zeros(M,1);
 for j=1:M
 	x1j=x(j,1);
 	x2j=x(j,2);
-	f2(j)=sum( fhatv.*exp(-2*pi*1i*(k1*x1j+k2*x2j)) );
+	f2(j)=sum( fhatv.*cos(2*pi*k1*x1j).*cos(2*pi*k2*x2j) );
 end %for
 
 % Compare results
 max(abs(f1-f2))
 
-% Adjoint NFFT %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Adjoint NFCT %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-% Computation with NFFT
-nfft_adjoint(plan);
+% Computation with NFCT
+nfct_adjoint(plan);
 fhat1=plan.fhat;
 
 % Direct computation
@@ -70,7 +70,7 @@ fhat2=zeros(N1*N2,1);
 for j=1:N1*N2
 	k1j=k1(j);
 	k2j=k2(j);
-	fhat2(j)=sum( plan.f.*exp(2*pi*1i*(k1j*x(:,1)+k2j*x(:,2))) );
+	fhat2(j)=sum( plan.f.*cos(2*pi*k1j*x(:,1)).*cos(2*pi*k2j*x(:,2)) );
 end %for
 
 % Compare results
diff --git a/matlab/nfft/test_nfft3d.m b/matlab/nfct/test_nfct3d.m
similarity index 65%
copy from matlab/nfft/test_nfft3d.m
copy to matlab/nfct/test_nfct3d.m
index c97eee9..3e8880e 100644
--- a/matlab/nfft/test_nfft3d.m
+++ b/matlab/nfct/test_nfct3d.m
@@ -1,5 +1,5 @@
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -15,7 +15,7 @@
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
-% Test script of class nfft for spatial dimension d=3.
+% Test script of class nfct for spatial dimension d=3.
 clear all;
 
 M=16; % number of nodes
@@ -24,30 +24,30 @@ N2=32; % number of Fourier coefficients in second direction
 N3=30; % number of Fourier coefficients in third direction
 N=[N1;N2;N3];
 
-x=rand(M,3)-0.5; %nodes
+x=0.5*rand(M,3); %nodes
 
 % Initialisation
-plan=nfft(3,N,M); % create plan of class type nfft
+plan=nfct(3,N,M); % create plan of class type nfct
 %n=2^(ceil(log(max(N))/log(2))+1);
-%plan=nfft(3,N,M,n,n,n,7,bitor(PRE_PHI_HUT,bitor(PRE_PSI,NFFT_OMP_BLOCKWISE_ADJOINT)),FFTW_MEASURE); % use of nfft_init_guru
+%plan=nfct(3,N,M,n,n,n,7,bitor(PRE_PHI_HUT,bitor(PRE_PSI,NFFT_OMP_BLOCKWISE_ADJOINT)),FFTW_MEASURE); % use of nfct_init_guru
 
 plan.x=x; % set nodes in plan
-nfft_precompute_psi(plan); % precomputations
+%nfct_precompute_psi(plan); % precomputations
 
-% NFFT %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% NFCT %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 fhat=rand(N1,N2,N3); % Fourier coefficients
 fhatv=fhat(:);
 
-% Compute samples with NFFT
+% Compute samples with NFCT
 plan.fhat=fhatv; % set Fourier coefficients
-nfft_trafo(plan); % compute nonequispaced Fourier transform
+nfct_trafo(plan); % compute nonequispaced Fourier transform
 f1=plan.f; % get samples
 
 % Compute samples direct
-k1=-N1/2:N1/2-1;
-k2=-N2/2:N2/2-1;
-k3=-N3/2:N3/2-1;
+k1=0:N1-1;
+k2=0:N2-1;
+k3=0:N3-1;
 [K1,K2,K3]=ndgrid(k1,k2,k3);
 k1=K1(:); clear K1;
 k2=K2(:); clear K2;
@@ -57,16 +57,16 @@ for j=1:M
 	x1j=x(j,1);
 	x2j=x(j,2);
 	x3j=x(j,3);
-	f2(j)=sum( fhatv.*exp(-2*pi*1i*(k1*x1j+k2*x2j+k3*x3j)) );
+	f2(j)=sum( fhatv.*cos(2*pi*k1*x1j).*cos(2*pi*k2*x2j).*cos(2*pi*k3*x3j) );
 end %for
 
 % Compare results
 max(abs(f1-f2))
 
-% Adjoint NFFT %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Adjoint NFCT %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-% Computation with NFFT
-nfft_adjoint(plan);
+% Computation with NFCT
+nfct_adjoint(plan);
 fhat1=plan.fhat;
 
 % Direct computation
@@ -75,7 +75,7 @@ for j=1:N1*N2*N3
 	k1j=k1(j);
 	k2j=k2(j);
 	k3j=k3(j);
-	fhat2(j)=sum( plan.f.*exp(2*pi*1i*(k1j*x(:,1)+k2j*x(:,2)+k3j*x(:,3))) );
+	fhat2(j)=sum( plan.f.*cos(2*pi*k1j*x(:,1)).*cos(2*pi*k2j*x(:,2)).*cos(2*pi*k3j*x(:,3)) );
 end %for
 
 % Compare results
diff --git a/matlab/nfft/FFTW_ESTIMATE.m b/matlab/nfft/FFTW_ESTIMATE.m
index ea4848b..4a2ab18 100644
--- a/matlab/nfft/FFTW_ESTIMATE.m
+++ b/matlab/nfft/FFTW_ESTIMATE.m
@@ -1,9 +1,9 @@
 % FFTW_ESTIMATE FFT flag
 %   Valid for FFTW3
 %
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfft/FFTW_MEASURE.m b/matlab/nfft/FFTW_MEASURE.m
index bbdd8c8..1c352a3 100644
--- a/matlab/nfft/FFTW_MEASURE.m
+++ b/matlab/nfft/FFTW_MEASURE.m
@@ -1,9 +1,9 @@
 %FFTW_MEASURE FFT flag
 %   Valid for FFTW3
 %
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfft/FFT_OUT_OF_PLACE.m b/matlab/nfft/FFT_OUT_OF_PLACE.m
index 2bb217e..15afa2f 100644
--- a/matlab/nfft/FFT_OUT_OF_PLACE.m
+++ b/matlab/nfft/FFT_OUT_OF_PLACE.m
@@ -1,9 +1,9 @@
 %FFT_OUT_OF_PLACE FFT flag
 %   If this flag is set, FFTW uses disjoint input/output vectors.
 %
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfft/FG_PSI.m b/matlab/nfft/FG_PSI.m
index d892abd..09435b3 100644
--- a/matlab/nfft/FG_PSI.m
+++ b/matlab/nfft/FG_PSI.m
@@ -3,9 +3,9 @@
 %   sparse matrix B) uses particular properties of the Gaussian window function
 %   to trade multiplications for direct calls to exponential function.
 %
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfft/NFFT_OMP_BLOCKWISE_ADJOINT.m b/matlab/nfft/NFFT_OMP_BLOCKWISE_ADJOINT.m
index 2468be1..84b1c62 100644
--- a/matlab/nfft/NFFT_OMP_BLOCKWISE_ADJOINT.m
+++ b/matlab/nfft/NFFT_OMP_BLOCKWISE_ADJOINT.m
@@ -1,9 +1,9 @@
 %NFFT_OMP_BLOCKWISE_ADJOINT Flag which results in usage of (probably) faster algorithm in adjoint NFFT with OpenMP support.
 %   If this flag is set, additionally the nonequispaced nodes are sorted
 %   which may also accelerate the standard NFFT trafo due to cache effects.
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfft/PRE_FG_PSI.m b/matlab/nfft/PRE_FG_PSI.m
index 6824e44..d5262f3 100644
--- a/matlab/nfft/PRE_FG_PSI.m
+++ b/matlab/nfft/PRE_FG_PSI.m
@@ -4,9 +4,9 @@
 %   multiplications for direct calls to exponential function (the remaining 2dM
 %   direct calls are precomputed).
 %
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfft/PRE_FULL_PSI.m b/matlab/nfft/PRE_FULL_PSI.m
index ad6761e..b2b403f 100644
--- a/matlab/nfft/PRE_FULL_PSI.m
+++ b/matlab/nfft/PRE_FULL_PSI.m
@@ -3,9 +3,9 @@
 %   matrix B) uses (2m+2)^dM precomputed values of the window function, in
 %   addition indices of source and target vectors are stored.
 %
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfft/PRE_LIN_PSI.m b/matlab/nfft/PRE_LIN_PSI.m
index dfab51c..a139fbf 100644
--- a/matlab/nfft/PRE_LIN_PSI.m
+++ b/matlab/nfft/PRE_LIN_PSI.m
@@ -3,9 +3,9 @@
 %   matrix B) uses linear interpolation from a lookup table of equispaced samples
 %   of the window function instead of exact values of the window function.
 %
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfft/PRE_PHI_HUT.m b/matlab/nfft/PRE_PHI_HUT.m
index a66ae1d..61871d3 100644
--- a/matlab/nfft/PRE_PHI_HUT.m
+++ b/matlab/nfft/PRE_PHI_HUT.m
@@ -3,9 +3,9 @@
 %   diagonal matrix D) uses precomputed values of the Fourier transformed window
 %   function.
 %
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfft/PRE_PSI.m b/matlab/nfft/PRE_PSI.m
index 482b8fc..4b93aac 100644
--- a/matlab/nfft/PRE_PSI.m
+++ b/matlab/nfft/PRE_PSI.m
@@ -1,9 +1,9 @@
 %PRE_PSI Precomputation flag
 %   If this flag is set, the convolution step (the multiplication with the sparse
 %   matrix B uses (2m+2)dM precomputed values of the window function.
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfft/ndft_adjoint.m b/matlab/nfft/ndft_adjoint.m
index e834c0f..8e740de 100644
--- a/matlab/nfft/ndft_adjoint.m
+++ b/matlab/nfft/ndft_adjoint.m
@@ -1,7 +1,7 @@
 %NDFT_ADJOINT Adjoint nonequispaced discrete Fourier transform (direct algorithm)
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfft/ndft_trafo.m b/matlab/nfft/ndft_trafo.m
index f72517d..efb1b45 100644
--- a/matlab/nfft/ndft_trafo.m
+++ b/matlab/nfft/ndft_trafo.m
@@ -1,7 +1,7 @@
 %NDFT_TRAFO  Nonequispaced discrete Fourier transformation (direct algorithm)
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfft/nfft.m b/matlab/nfft/nfft.m
index 16f5ae9..5cbac5d 100644
--- a/matlab/nfft/nfft.m
+++ b/matlab/nfft/nfft.m
@@ -1,5 +1,4 @@
-
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -15,7 +14,7 @@
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
-% This class provides robust a Matlab interface to the NFFT library.
+% This class provides a Matlab interface to the NFFT module.
 %
 % Examples
 %   See Matlab scripts test_nfft*d.m.
diff --git a/matlab/nfft/nfft_adjoint.m b/matlab/nfft/nfft_adjoint.m
index 3272b5d..8099df9 100644
--- a/matlab/nfft/nfft_adjoint.m
+++ b/matlab/nfft/nfft_adjoint.m
@@ -1,7 +1,7 @@
 %NFFT_ADJOINT Adjoint nonequispaced fast Fourier transform
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfft/nfft_finalize.m b/matlab/nfft/nfft_finalize.m
index e8816a2..b12952d 100644
--- a/matlab/nfft/nfft_finalize.m
+++ b/matlab/nfft/nfft_finalize.m
@@ -1,7 +1,7 @@
 %NFFT_FINALIZE Finalize plan
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfft/nfft_get_f.m b/matlab/nfft/nfft_get_f.m
index 02aed96..3fb362d 100644
--- a/matlab/nfft/nfft_get_f.m
+++ b/matlab/nfft/nfft_get_f.m
@@ -1,7 +1,7 @@
 %NFFT_GET_F Get function values from plan
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfft/nfft_get_f_hat.m b/matlab/nfft/nfft_get_f_hat.m
index 13307ac..f1dc495 100644
--- a/matlab/nfft/nfft_get_f_hat.m
+++ b/matlab/nfft/nfft_get_f_hat.m
@@ -1,7 +1,7 @@
 %NFFT_GET_F_HAT Get Fourier coefficients from plan
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfft/nfft_get_num_threads.m b/matlab/nfft/nfft_get_num_threads.m
index 14495fc..82e1938 100644
--- a/matlab/nfft/nfft_get_num_threads.m
+++ b/matlab/nfft/nfft_get_num_threads.m
@@ -1,7 +1,7 @@
 %NFFT_GET_NUM_THREADS Get number of threads (at most) used for computation
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfft/nfft_get_x.m b/matlab/nfft/nfft_get_x.m
index 897aa86..5d27e91 100644
--- a/matlab/nfft/nfft_get_x.m
+++ b/matlab/nfft/nfft_get_x.m
@@ -1,7 +1,7 @@
 %NFFT_GET_X Get nodes from plan
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfft/nfft_init_1d.m b/matlab/nfft/nfft_init_1d.m
index 29167f9..ac1f7f2 100644
--- a/matlab/nfft/nfft_init_1d.m
+++ b/matlab/nfft/nfft_init_1d.m
@@ -1,7 +1,7 @@
 %NFFT_INIT_1D Initialise plans
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfft/nfft_init_2d.m b/matlab/nfft/nfft_init_2d.m
index 59025b6..a1b16ce 100644
--- a/matlab/nfft/nfft_init_2d.m
+++ b/matlab/nfft/nfft_init_2d.m
@@ -1,7 +1,7 @@
 %NFFT_INIT_2D Initialise plans
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfft/nfft_init_3d.m b/matlab/nfft/nfft_init_3d.m
index 03685ed..6a4570c 100644
--- a/matlab/nfft/nfft_init_3d.m
+++ b/matlab/nfft/nfft_init_3d.m
@@ -1,7 +1,7 @@
 %NFFT_INIT_3D Initialise plans
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfft/nfft_init_guru.m b/matlab/nfft/nfft_init_guru.m
index 65806d7..3ad384f 100644
--- a/matlab/nfft/nfft_init_guru.m
+++ b/matlab/nfft/nfft_init_guru.m
@@ -12,9 +12,9 @@
 %	             PRE_FULL_PSI} | FFT_OUT_OF_PLACE
 %   fftw_flags   {FFTW_ESTIMATE, FFTW_MEASURE}
 %
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfft/nfft_precompute_psi.m b/matlab/nfft/nfft_precompute_psi.m
index ed3edcd..510d0eb 100644
--- a/matlab/nfft/nfft_precompute_psi.m
+++ b/matlab/nfft/nfft_precompute_psi.m
@@ -1,7 +1,7 @@
 %NFFT_PRECOMPUTE_PSI Precompute psi, dependent on nodes x
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfft/nfft_set_f.m b/matlab/nfft/nfft_set_f.m
index ada43fc..225baa6 100644
--- a/matlab/nfft/nfft_set_f.m
+++ b/matlab/nfft/nfft_set_f.m
@@ -1,7 +1,7 @@
 %NFFT_SET_F Set function values in plan
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfft/nfft_set_f_hat.m b/matlab/nfft/nfft_set_f_hat.m
index 8b22904..40b7eb3 100644
--- a/matlab/nfft/nfft_set_f_hat.m
+++ b/matlab/nfft/nfft_set_f_hat.m
@@ -1,7 +1,7 @@
 %NFFT_SET_F_HAT Set Fourier coefficients in plan
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfft/nfft_set_x.m b/matlab/nfft/nfft_set_x.m
index 997620e..61dfdfe 100644
--- a/matlab/nfft/nfft_set_x.m
+++ b/matlab/nfft/nfft_set_x.m
@@ -1,7 +1,7 @@
 %NFFT_SET_X Set nodes in plan
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfft/nfft_trafo.m b/matlab/nfft/nfft_trafo.m
index 0b46095..f167a9b 100644
--- a/matlab/nfft/nfft_trafo.m
+++ b/matlab/nfft/nfft_trafo.m
@@ -1,7 +1,7 @@
 %NFFT_TRAFO nonequispaced fast Fourier transformat
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfft/nfftmex.c b/matlab/nfft/nfftmex.c
index bde8cb3..55dadd2 100644
--- a/matlab/nfft/nfftmex.c
+++ b/matlab/nfft/nfftmex.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
@@ -31,15 +31,16 @@
   #include "mexversion.c"
 #endif
 
-#define PLANS_MAX 100 /* maximum number of plans */
+#define PLANS_START 10 /* initial number of plans */
 #define CMD_LEN_MAX 20 /* maximum length of command argument */
 
 /* global flags */
 #define NFFT_MEX_FIRST_CALL (1U << 0)
-unsigned short gflags = NFFT_MEX_FIRST_CALL;
+static unsigned short gflags = NFFT_MEX_FIRST_CALL;
 
-nfft_plan* plans[PLANS_MAX]; /* plans */
-char cmd[CMD_LEN_MAX];
+static nfft_plan** plans = NULL; /* plans */
+static unsigned int plans_num_allocated = 0;
+static char cmd[CMD_LEN_MAX];
 
 static inline void get_nm(const mxArray *prhs[], int *n, int *m)
 {
@@ -122,19 +123,31 @@ static inline void check_nargs(const int nrhs, const int n, const char* errmsg)
 
 static inline void check_plan(int i)
 {
-  DM(if (i < 0 || i >= PLANS_MAX)
-    mexErrMsgTxt("Invalid plan");)
-  DM(if (plans[i] == 0)
+  DM(if (i < 0 || i >= plans_num_allocated || plans[i] == 0)
     mexErrMsgTxt("Plan was not initialized or has already been finalized");)
 }
 
 static inline int mkplan(void)
 {
-  mexLock();
   int i = 0;
-  while (i < PLANS_MAX && plans[i] != 0) i++;
-  if (i == PLANS_MAX)
-    mexErrMsgTxt("nfft: Too many plans already allocated.");
+  while (i < plans_num_allocated && plans[i] != 0) i++;
+  if (i == plans_num_allocated)
+  {
+    int l;
+
+    if (plans_num_allocated >= INT_MAX - PLANS_START - 1)
+      mexErrMsgTxt("nfft: Too many plans already allocated.");
+
+    nfft_plan** plans_old = plans;
+    plans = nfft_malloc((plans_num_allocated+PLANS_START)*sizeof(nfft_plan*));
+    for (l = 0; l < plans_num_allocated; l++)
+      plans[l] = plans_old[l];
+    for (l = plans_num_allocated; l < plans_num_allocated+PLANS_START; l++)
+      plans[l] = 0;
+    if (plans_num_allocated > 0)
+      nfft_free(plans_old);
+    plans_num_allocated += PLANS_START;
+  }
   plans[i] = nfft_malloc(sizeof(nfft_plan));
   return i;
 }
@@ -144,16 +157,22 @@ static void cleanup(void)
 {
   int i;
 
-  mexUnlock();
-
   if (!(gflags & NFFT_MEX_FIRST_CALL))
   {
-    for (i = 0; i < PLANS_MAX; i++)
+    for (i = 0; i < plans_num_allocated; i++)
       if (plans[i])
       {
         nfft_finalize(plans[i]);
-        plans[i] = 0;
+	nfft_free(plans[i]);
+	plans[i] = 0;
       }
+
+    if (plans_num_allocated > 0)
+    {
+      nfft_free(plans);
+      plans = NULL;
+      plans_num_allocated = 0;
+    }
     gflags |= NFFT_MEX_FIRST_CALL;
   }
 }
@@ -168,13 +187,6 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
 
     nfft_mex_install_mem_hooks();
 
-    /* plan pointers to zeros */
-    {
-      int i;
-      for (i = 0; i < PLANS_MAX; i++)
-        plans[i] = 0;
-    }
-
     mexAtExit(cleanup);
     gflags &= ~NFFT_MEX_FIRST_CALL;
   }
diff --git a/matlab/nfft/nfftmex.m b/matlab/nfft/nfftmex.m
index 55c8b9a..b1f4e44 100644
--- a/matlab/nfft/nfftmex.m
+++ b/matlab/nfft/nfftmex.m
@@ -1,7 +1,7 @@
 %NFFTMEX Gateway function to NFFT module from NFFT3
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfft/simple_test.m b/matlab/nfft/simple_test.m
index 6f76120..0c2dc60 100644
--- a/matlab/nfft/simple_test.m
+++ b/matlab/nfft/simple_test.m
@@ -1,8 +1,8 @@
 %SIMPLE_TEST Example program: Basic usage principles
 %
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -18,7 +18,7 @@
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 %
-disp(sprintf('Number of threads: %d\n', nfft_get_num_threads()));
+fprintf('Number of threads: %d\n\n', nfft_get_num_threads());
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 disp('A simple one dimensional example');
 
@@ -41,7 +41,7 @@ nfft_set_x(plan,x);
 nfft_precompute_psi(plan);
 
 % Fourier coefficients
-f_hat = rand(N,1)+i*rand(N,1);
+f_hat = rand(N,1)+1i*rand(N,1);
 
 % Set Fourier coefficients.
 nfft_set_f_hat(plan,double(f_hat));
@@ -62,7 +62,7 @@ error_vector=f-f2
 error_linfl1=norm(f-f2,inf)/norm(f_hat,1)
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-disp(sprintf('\nA two dimensional example'));
+fprintf('\nA two dimensional example, m=2\n');
 d=2;
 for logN=3:10
   N=2^logN;
@@ -71,7 +71,7 @@ for logN=3:10
   plan = nfft_init_guru(d,N,N,M,2*N,2*N,2,bitor(PRE_PHI_HUT,bitor(PRE_PSI,NFFT_OMP_BLOCKWISE_ADJOINT)),FFTW_MEASURE);
   nfft_set_x(plan,x);
   nfft_precompute_psi(plan);
-  f_hat = rand(N,N)+i*rand(N,N);
+  f_hat = rand(N,N)+1i*rand(N,N);
   nfft_set_f_hat(plan,double(f_hat(:)));
   tic
   nfft_trafo(plan);
@@ -87,13 +87,13 @@ for logN=3:10
   else
     t2=inf;
     e=nan;
-  end;
+  end
   nfft_finalize(plan);
-  disp(sprintf('t1=%1.2e, t2=%1.2e, e=%1.2e',t1,t2,e));
-end;
+  fprintf('t1=%1.2e, t2=%1.2e, e=%1.2e\n',t1,t2,e);
+end
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-disp(sprintf('\nAn asymmetric three dimensional example'));
+fprintf('\nAn asymmetric three dimensional example, m=2\n');
 d=3;
 for logN=3:10
   N1=2^logN;   n1=2*N1;
@@ -104,7 +104,7 @@ for logN=3:10
   plan = nfft_init_guru(d,N1,N2,N3,M,n1,n2,n3,2,bitor(PRE_PHI_HUT,bitor(PRE_PSI,NFFT_OMP_BLOCKWISE_ADJOINT)),FFTW_MEASURE);
   nfft_set_x(plan,x);
   nfft_precompute_psi(plan);
-  f_hat = rand(N1,N2,N3)+i*rand(N1,N2,N3);
+  f_hat = rand(N1,N2,N3)+1i*rand(N1,N2,N3);
   nfft_set_f_hat(plan,double(f_hat(:)));
   tic
   nfft_trafo(plan);
@@ -120,7 +120,7 @@ for logN=3:10
   else
     t2=inf;
     e=nan;
-  end;
+  end
   nfft_finalize(plan);
-  disp(sprintf('t1=%1.2e, t2=%1.2e, e=%1.2e',t1,t2,e));
-end;
+  fprintf('t1=%1.2e, t2=%1.2e, e=%1.2e\n',t1,t2,e);
+end
diff --git a/matlab/nfft/test_nfft1d.m b/matlab/nfft/test_nfft1d.m
index 173210d..aadc025 100644
--- a/matlab/nfft/test_nfft1d.m
+++ b/matlab/nfft/test_nfft1d.m
@@ -1,5 +1,5 @@
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfft/test_nfft2d.m b/matlab/nfft/test_nfft2d.m
index 962d873..5d878c2 100644
--- a/matlab/nfft/test_nfft2d.m
+++ b/matlab/nfft/test_nfft2d.m
@@ -1,5 +1,5 @@
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfft/test_nfft3d.m b/matlab/nfft/test_nfft3d.m
index c97eee9..fa3dbfa 100644
--- a/matlab/nfft/test_nfft3d.m
+++ b/matlab/nfft/test_nfft3d.m
@@ -1,5 +1,5 @@
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfsft/@f_hat/char.m b/matlab/nfsft/@f_hat/char.m
index 30871cf..bcbb1d6 100644
--- a/matlab/nfsft/@f_hat/char.m
+++ b/matlab/nfsft/@f_hat/char.m
@@ -1,7 +1,7 @@
 %CHAR Conversion to string for f_hat class
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfsft/@f_hat/display.m b/matlab/nfsft/@f_hat/display.m
index 7cf8a5e..704e171 100644
--- a/matlab/nfsft/@f_hat/display.m
+++ b/matlab/nfsft/@f_hat/display.m
@@ -1,7 +1,7 @@
 %DISPLAY Display function for f_hat class
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfsft/@f_hat/double.m b/matlab/nfsft/@f_hat/double.m
index 5c3c9a3..ae9e9ef 100644
--- a/matlab/nfsft/@f_hat/double.m
+++ b/matlab/nfsft/@f_hat/double.m
@@ -1,7 +1,7 @@
 %DOUBLE Double conversion for f_hat class
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfsft/@f_hat/f_hat.m b/matlab/nfsft/@f_hat/f_hat.m
index e2fa3b8..65afb97 100644
--- a/matlab/nfsft/@f_hat/f_hat.m
+++ b/matlab/nfsft/@f_hat/f_hat.m
@@ -1,7 +1,7 @@
 %F_HAT Constructor for f_hat class
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfsft/@f_hat/get.m b/matlab/nfsft/@f_hat/get.m
index a139fa1..0066bae 100644
--- a/matlab/nfsft/@f_hat/get.m
+++ b/matlab/nfsft/@f_hat/get.m
@@ -1,7 +1,7 @@
 %GET Get f_hat properties from the specified object
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfsft/@f_hat/minus.m b/matlab/nfsft/@f_hat/minus.m
index c8b7cef..c9cfa3c 100644
--- a/matlab/nfsft/@f_hat/minus.m
+++ b/matlab/nfsft/@f_hat/minus.m
@@ -1,8 +1,8 @@
 %MINUS Minus for f_hat
 %
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfsft/@f_hat/mtimes.m b/matlab/nfsft/@f_hat/mtimes.m
index dc6929a..7fab9a4 100644
--- a/matlab/nfsft/@f_hat/mtimes.m
+++ b/matlab/nfsft/@f_hat/mtimes.m
@@ -1,7 +1,7 @@
 %MTIMES Multiply for f_hat
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfsft/@f_hat/mtimesr.m b/matlab/nfsft/@f_hat/mtimesr.m
index 2a629dd..7af0641 100644
--- a/matlab/nfsft/@f_hat/mtimesr.m
+++ b/matlab/nfsft/@f_hat/mtimesr.m
@@ -1,7 +1,7 @@
 %MTIMESR Multiply for f_hat
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfsft/@f_hat/norm.m b/matlab/nfsft/@f_hat/norm.m
index 359cf87..51fbc86 100644
--- a/matlab/nfsft/@f_hat/norm.m
+++ b/matlab/nfsft/@f_hat/norm.m
@@ -1,7 +1,7 @@
 %NORM Norm for f_hat class
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfsft/@f_hat/plus.m b/matlab/nfsft/@f_hat/plus.m
index fd10b6e..81156a5 100644
--- a/matlab/nfsft/@f_hat/plus.m
+++ b/matlab/nfsft/@f_hat/plus.m
@@ -1,7 +1,7 @@
 %PLUS Plus for f_hat
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfsft/@f_hat/subsasgn.m b/matlab/nfsft/@f_hat/subsasgn.m
index 7e2011f..f3520c0 100644
--- a/matlab/nfsft/@f_hat/subsasgn.m
+++ b/matlab/nfsft/@f_hat/subsasgn.m
@@ -1,7 +1,7 @@
 %SUBSASGN Index assignment function for f_hat class
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfsft/@f_hat/subsref.m b/matlab/nfsft/@f_hat/subsref.m
index ba35ac8..4141986 100644
--- a/matlab/nfsft/@f_hat/subsref.m
+++ b/matlab/nfsft/@f_hat/subsref.m
@@ -1,7 +1,7 @@
 %SUBSREF Indexing funcction for f_hat class
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfsft/NFSFT_NORMALIZED.m b/matlab/nfsft/NFSFT_NORMALIZED.m
index a476e6f..04cd301 100644
--- a/matlab/nfsft/NFSFT_NORMALIZED.m
+++ b/matlab/nfsft/NFSFT_NORMALIZED.m
@@ -1,7 +1,7 @@
 %NFSFT_NORMALIZED Flag for using L^2-normalized Spherical harmonics
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfsft/NFSFT_NO_DIRECT_ALGORITHM.m b/matlab/nfsft/NFSFT_NO_DIRECT_ALGORITHM.m
index 21a7838..b779b42 100644
--- a/matlab/nfsft/NFSFT_NO_DIRECT_ALGORITHM.m
+++ b/matlab/nfsft/NFSFT_NO_DIRECT_ALGORITHM.m
@@ -1,7 +1,7 @@
 %NFSFT_NO_DIRECT_ALGORITHM Flag for not precomputing for the direct algorithm
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfsft/NFSFT_NO_FAST_ALGORITHM.m b/matlab/nfsft/NFSFT_NO_FAST_ALGORITHM.m
index 16fab4a..c55b340 100644
--- a/matlab/nfsft/NFSFT_NO_FAST_ALGORITHM.m
+++ b/matlab/nfsft/NFSFT_NO_FAST_ALGORITHM.m
@@ -1,7 +1,7 @@
 %NFSFT_NO_FAST_ALGORITHM Flag for not precomputing for the fast algorithm
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfsft/NFSFT_PRESERVE_F_HAT.m b/matlab/nfsft/NFSFT_PRESERVE_F_HAT.m
index d93fb4e..c36557a 100644
--- a/matlab/nfsft/NFSFT_PRESERVE_F_HAT.m
+++ b/matlab/nfsft/NFSFT_PRESERVE_F_HAT.m
@@ -1,7 +1,7 @@
 %NFSFT_PRESERVE_F_HAT Flag for NFSFT not destroying input in f_hat
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfsft/NFSFT_USE_DPT.m b/matlab/nfsft/NFSFT_USE_DPT.m
index 33f3943..cfe406d 100644
--- a/matlab/nfsft/NFSFT_USE_DPT.m
+++ b/matlab/nfsft/NFSFT_USE_DPT.m
@@ -1,7 +1,7 @@
 %NFSFT_USE_DPT Flag for using the DPT algorithm internally
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfsft/NFSFT_USE_NDFT.m b/matlab/nfsft/NFSFT_USE_NDFT.m
index 05068e9..3dcd46b 100644
--- a/matlab/nfsft/NFSFT_USE_NDFT.m
+++ b/matlab/nfsft/NFSFT_USE_NDFT.m
@@ -1,7 +1,7 @@
 %NFSFT_USE_NDFT Flag for using the NDFT algorithm internally
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfsft/cc.m b/matlab/nfsft/cc.m
old mode 100755
new mode 100644
index cc5ba6d..0e74df9
--- a/matlab/nfsft/cc.m
+++ b/matlab/nfsft/cc.m
@@ -28,9 +28,9 @@
 %   References
 %   TODO Add references.
 %
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfsft/f_hat_index.m b/matlab/nfsft/f_hat_index.m
index 4930b59..c7337cc 100644
--- a/matlab/nfsft/f_hat_index.m
+++ b/matlab/nfsft/f_hat_index.m
@@ -1,7 +1,7 @@
 %F_HAT_INDEX Return indices of Fourier coefficients
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfsft/gl.m b/matlab/nfsft/gl.m
index 4e21cc3..e830a85 100644
--- a/matlab/nfsft/gl.m
+++ b/matlab/nfsft/gl.m
@@ -22,9 +22,9 @@
 %   References
 %   TODO Add references.
 %
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfsft/ndsft_adjoint.m b/matlab/nfsft/ndsft_adjoint.m
index 3467283..1433bd8 100644
--- a/matlab/nfsft/ndsft_adjoint.m
+++ b/matlab/nfsft/ndsft_adjoint.m
@@ -1,7 +1,7 @@
 %NDSFT_ADJOINT Adjoint discrete spherical Fourier transform (direct alg.)
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfsft/ndsft_trafo.m b/matlab/nfsft/ndsft_trafo.m
index 6237954..e16da15 100644
--- a/matlab/nfsft/ndsft_trafo.m
+++ b/matlab/nfsft/ndsft_trafo.m
@@ -1,7 +1,7 @@
 %NDSFT_TRAFO Discrete spherical Fourier transform (direct algorithm)
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfsft/nfsft_adjoint.m b/matlab/nfsft/nfsft_adjoint.m
index a5d17b3..4a02100 100644
--- a/matlab/nfsft/nfsft_adjoint.m
+++ b/matlab/nfsft/nfsft_adjoint.m
@@ -1,7 +1,7 @@
 %NFSFT_ADJOINT Adjoint fast spherical Fourier transform
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfsft/nfsft_finalize.m b/matlab/nfsft/nfsft_finalize.m
index 66b9f2a..725b148 100644
--- a/matlab/nfsft/nfsft_finalize.m
+++ b/matlab/nfsft/nfsft_finalize.m
@@ -1,7 +1,7 @@
 %NFSFT_FINALIZE Finalize plan
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfsft/nfsft_forget.m b/matlab/nfsft/nfsft_forget.m
index 3916fd4..ab899f9 100644
--- a/matlab/nfsft/nfsft_forget.m
+++ b/matlab/nfsft/nfsft_forget.m
@@ -1,7 +1,7 @@
 %NFSFT_FORGET Forget precomputed data
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfsft/nfsft_get_f.m b/matlab/nfsft/nfsft_get_f.m
index 8f98fdb..678e9ef 100644
--- a/matlab/nfsft/nfsft_get_f.m
+++ b/matlab/nfsft/nfsft_get_f.m
@@ -1,7 +1,7 @@
 %NFSFT_GET_F Get function values from plan
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfsft/nfsft_get_f_hat.m b/matlab/nfsft/nfsft_get_f_hat.m
index 937275d..f501e62 100644
--- a/matlab/nfsft/nfsft_get_f_hat.m
+++ b/matlab/nfsft/nfsft_get_f_hat.m
@@ -1,7 +1,7 @@
 %NFSFT_GET_F_HAT Get Fourier coefficients in a matrix from plan
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfsft/nfsft_get_f_hat_linear.m b/matlab/nfsft/nfsft_get_f_hat_linear.m
index ed07834..e2c25da 100644
--- a/matlab/nfsft/nfsft_get_f_hat_linear.m
+++ b/matlab/nfsft/nfsft_get_f_hat_linear.m
@@ -1,7 +1,7 @@
 %NFSFT_GET_F_HAT_LINEAR Get Fourier coefficients in a linear vector from plan
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfsft/nfsft_get_num_threads.m b/matlab/nfsft/nfsft_get_num_threads.m
index 10d204a..e42f8b5 100644
--- a/matlab/nfsft/nfsft_get_num_threads.m
+++ b/matlab/nfsft/nfsft_get_num_threads.m
@@ -1,7 +1,7 @@
 %NFSFT_GET_NUM_THREADS Get number of threads (at most) used for computation
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfsft/nfsft_get_x.m b/matlab/nfsft/nfsft_get_x.m
index 2c75843..1cb6af1 100644
--- a/matlab/nfsft/nfsft_get_x.m
+++ b/matlab/nfsft/nfsft_get_x.m
@@ -1,7 +1,7 @@
 %NFSFT_GET_X Get nodes from plan
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfsft/nfsft_init.m b/matlab/nfsft/nfsft_init.m
index 411f4e1..ad9e1c5 100644
--- a/matlab/nfsft/nfsft_init.m
+++ b/matlab/nfsft/nfsft_init.m
@@ -1,7 +1,7 @@
 %NFSFT_INIT Plan initialization
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfsft/nfsft_init_advanced.m b/matlab/nfsft/nfsft_init_advanced.m
index fea958c..de1f52b 100644
--- a/matlab/nfsft/nfsft_init_advanced.m
+++ b/matlab/nfsft/nfsft_init_advanced.m
@@ -1,7 +1,7 @@
 %NFSFT_INIT_ADVANCED Advanced plan initialization routine
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfsft/nfsft_init_guru.m b/matlab/nfsft/nfsft_init_guru.m
index d483488..7a200c8 100644
--- a/matlab/nfsft/nfsft_init_guru.m
+++ b/matlab/nfsft/nfsft_init_guru.m
@@ -1,7 +1,7 @@
 %NFSFT_INIT_GURU Guru plan initialization
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfsft/nfsft_precompute.m b/matlab/nfsft/nfsft_precompute.m
index 81dae6f..2b13d30 100644
--- a/matlab/nfsft/nfsft_precompute.m
+++ b/matlab/nfsft/nfsft_precompute.m
@@ -1,7 +1,7 @@
 %NFSFT_PRECOMPUTE Node-independent precomputation (for FPT)
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfsft/nfsft_precompute_x.m b/matlab/nfsft/nfsft_precompute_x.m
index 47ea057..bb3bab1 100644
--- a/matlab/nfsft/nfsft_precompute_x.m
+++ b/matlab/nfsft/nfsft_precompute_x.m
@@ -1,7 +1,7 @@
 %NFSFT_PRECOMPUTE_X Node-dependent precomputation (for NFFT)
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfsft/nfsft_set_f.m b/matlab/nfsft/nfsft_set_f.m
index 0c8326c..25ef13a 100644
--- a/matlab/nfsft/nfsft_set_f.m
+++ b/matlab/nfsft/nfsft_set_f.m
@@ -1,7 +1,7 @@
 %NFSFT_SET_F Set function values in plan
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfsft/nfsft_set_f_hat.m b/matlab/nfsft/nfsft_set_f_hat.m
index 83f2fb0..ac244ca 100644
--- a/matlab/nfsft/nfsft_set_f_hat.m
+++ b/matlab/nfsft/nfsft_set_f_hat.m
@@ -1,7 +1,7 @@
 %NFSFT_SET_F_HAT Set Fourier coefficients in plan from a matrix
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfsft/nfsft_set_f_hat_linear.m b/matlab/nfsft/nfsft_set_f_hat_linear.m
index 0fb0175..2af6c4a 100644
--- a/matlab/nfsft/nfsft_set_f_hat_linear.m
+++ b/matlab/nfsft/nfsft_set_f_hat_linear.m
@@ -1,7 +1,7 @@
 %NFSFT_SET_F_HAT_LINEAR Set Fourier coefficients in plan from a linear vector
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfsft/nfsft_set_x.m b/matlab/nfsft/nfsft_set_x.m
index 95b9a64..c5569f6 100644
--- a/matlab/nfsft/nfsft_set_x.m
+++ b/matlab/nfsft/nfsft_set_x.m
@@ -1,7 +1,7 @@
 %NFSFT_SET_X Set nodes in plan
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfsft/nfsft_trafo.m b/matlab/nfsft/nfsft_trafo.m
index 082d1a7..bafd20c 100644
--- a/matlab/nfsft/nfsft_trafo.m
+++ b/matlab/nfsft/nfsft_trafo.m
@@ -1,7 +1,7 @@
 %NFSFT_TRAFO Fast spherical Fourier transform
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfsft/nfsftmex.c b/matlab/nfsft/nfsftmex.c
index 346a860..f6a961c 100644
--- a/matlab/nfsft/nfsftmex.c
+++ b/matlab/nfsft/nfsftmex.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
@@ -31,17 +31,18 @@
   #include "mexversion.c"
 #endif
 
-#define PLANS_MAX 100 /* maximum number of plans */
+#define PLANS_START 10 /* initial number of plans */
 #define CMD_LEN_MAX 20 /* maximum length of command argument */
 
 /* global flags */
 #define NFSFT_MEX_FIRST_CALL (1U << 0)
 #define NFSFT_MEX_PRECOMPUTED (1U << 1)
-unsigned short gflags = NFSFT_MEX_FIRST_CALL;
+static unsigned short gflags = NFSFT_MEX_FIRST_CALL;
 
-nfsft_plan* plans[PLANS_MAX]; /* plans */
-int n_max = -1; /* maximum degree precomputed */
-char cmd[CMD_LEN_MAX];
+static nfsft_plan** plans = NULL; /* plans */
+static unsigned int plans_num_allocated = 0;
+static int n_max = -1; /* maximum degree precomputed */
+static char cmd[CMD_LEN_MAX];
 
 static inline void get_nm(const mxArray *prhs[], int *n, int *m)
 {
@@ -81,12 +82,33 @@ static inline void check_nargs(const int nrhs, const int n, const char* errmsg)
     mexErrMsgTxt(errmsg);)
 }
 
+static inline void check_plan(int i)
+{
+  DM(if (i < 0 || i >= plans_num_allocated || plans[i] == 0)
+     mexErrMsgTxt("Plan was not initialized or has already been finalized");)
+}
+
 static inline int mkplan()
 {
   int i = 0;
-  while (i < PLANS_MAX && plans[i] != 0) i++;
-  if (i == PLANS_MAX)
-    mexErrMsgTxt("nfsft: Too many plans already allocated.");
+  while (i < plans_num_allocated && plans[i] != 0) i++;
+  if (i == plans_num_allocated)
+  {
+    int l;
+
+    if (plans_num_allocated >= INT_MAX - PLANS_START - 1)
+      mexErrMsgTxt("nfsft: Too many plans already allocated.");
+
+    nfsft_plan** plans_old = plans;
+    plans = nfft_malloc((plans_num_allocated+PLANS_START)*sizeof(nfsft_plan*));
+    for (l = 0; l < plans_num_allocated; l++)
+      plans[l] = plans_old[l];
+    for (l = plans_num_allocated; l < plans_num_allocated+PLANS_START; l++)
+      plans[l] = 0;
+    if (plans_num_allocated > 0)
+      nfft_free(plans_old);
+    plans_num_allocated += PLANS_START;
+  }
   plans[i] = nfft_malloc(sizeof(nfsft_plan));
   return i;
 }
@@ -98,13 +120,20 @@ static void cleanup(void)
 
   if (!(gflags & NFSFT_MEX_FIRST_CALL))
   {
-    for (i = 0; i < PLANS_MAX; i++)
+    for (i = 0; i < plans_num_allocated; i++)
       if (plans[i])
       {
         nfsft_finalize(plans[i]);
         nfft_free(plans[i]);
         plans[i] = 0;
       }
+
+    if (plans_num_allocated > 0)
+    {
+      nfft_free(plans);
+      plans = NULL;
+      plans_num_allocated = 0;
+    }
     nfsft_forget();
     gflags |= NFSFT_MEX_FIRST_CALL;
     gflags &= ~NFSFT_MEX_PRECOMPUTED;
@@ -122,13 +151,6 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
 
     nfft_mex_install_mem_hooks();
 
-    /* plan pointers to zeros */
-    {
-      int i;
-      for (i = 0; i < PLANS_MAX; i++)
-        plans[i] = 0;
-    }
-
     mexAtExit(cleanup);
     gflags &= ~NFSFT_MEX_FIRST_CALL;
   }
@@ -220,6 +242,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
     check_nargs(nrhs,2,"Wrong number of arguments for trafo.");
     {
       int i = nfft_mex_get_int(prhs[1],"nfsft: Input argument plan must be a scalar.");
+      check_plan(i);
       nfsft_trafo(plans[i]);
     }
     return;
@@ -229,6 +252,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
     check_nargs(nrhs,2,"Wrong number of arguments for adjoint.");
     {
       int i = nfft_mex_get_int(prhs[1],"nfsft: Input argument plan must be a scalar.");
+      check_plan(i);
       nfsft_adjoint(plans[i]);
     }
     return;
@@ -238,6 +262,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
     check_nargs(nrhs,2,"Wrong number of arguments for finalize.");
     {
       int i = nfft_mex_get_int(prhs[1],"nfsft: Input argument plan must be a scalar.");
+      check_plan(i);
       nfsft_finalize(plans[i]);
       nfft_free(plans[i]);
       plans[i] = 0;
@@ -249,6 +274,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
     check_nargs(nrhs,2,"Wrong number of arguments for precompute_x.");
     {
       int i = nfft_mex_get_int(prhs[1],"nfsft: Input argument plan must be a scalar.");
+      check_plan(i);
       nfsft_precompute_x(plans[i]);
     }
     return;
@@ -258,6 +284,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
     check_nargs(nrhs,2,"Wrong number of arguments for trafo direct.");
     {
       int i = nfft_mex_get_int(prhs[1],"nfsft: Input argument plan must be a scalar.");
+      check_plan(i);
       nfsft_trafo_direct(plans[i]);
     }
     return;
@@ -267,6 +294,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
     check_nargs(nrhs,2,"Wrong number of arguments for adjoint direct.");
     {
       int i = nfft_mex_get_int(prhs[1],"nfsft: Input argument plan must be a scalar.");
+      check_plan(i);
       nfsft_adjoint_direct(plans[i]);
     }
     return;
@@ -276,6 +304,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
     check_nargs(nrhs,2,"Wrong number of arguments for get_x.");
     {
       int i = nfft_mex_get_int(prhs[1],"nfsft: Input argument plan must be a scalar.");
+      check_plan(i);
       const int m = plans[i]->M_total;
       plhs[0] = mxCreateDoubleMatrix(2, (unsigned)m, mxREAL);
       {
@@ -297,6 +326,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
     check_nargs(nrhs,2,"Wrong number of arguments for get_f.");
     {
       int i = nfft_mex_get_int(prhs[1],"nfsft: Input argument plan must be a scalar.");
+      check_plan(i);
       const int m = plans[i]->M_total;
       plhs[0] = mxCreateDoubleMatrix((unsigned)m, 1, mxCOMPLEX);
       {
@@ -316,6 +346,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
     check_nargs(nrhs,2,"Wrong number of arguments for get_f_hat.");
     {
       int i = nfft_mex_get_int(prhs[1],"nfsft: Input argument plan must be a scalar.");
+      check_plan(i);
       const int n = plans[i]->N;
       plhs[0] = mxCreateDoubleMatrix((unsigned)(2*n+1), (unsigned)(n+1), mxCOMPLEX);
       {
@@ -336,6 +367,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
     check_nargs(nrhs,2,"Wrong number of arguments for get_f_hat_linear.");
     {
       int i = nfft_mex_get_int(prhs[1],"nfsft: Input argument plan must be a scalar.");
+      check_plan(i);
       const int n = plans[i]->N;
       plhs[0] = mxCreateDoubleMatrix((unsigned)((n+1)*(n+1)), 1, mxCOMPLEX);
       {
@@ -356,6 +388,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
     check_nargs(nrhs,3,"Wrong number of arguments for set_x.");
     {
       int i = nfft_mex_get_int(prhs[1],"nfsft: Input argument plan must be a scalar.");
+      check_plan(i);
       const int m = plans[i]->M_total;
       DM(if (!mxIsDouble(prhs[2]) || mxGetNumberOfDimensions(prhs[2]) > 2)
         mexErrMsgTxt("Input argument x must be a 2 x M double array");)
@@ -378,6 +411,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
     check_nargs(nrhs,3,"Wrong number of arguments for set_f.");
     {
       int i = nfft_mex_get_int(prhs[1],"nfsft: Input argument plan must be a scalar.");
+      check_plan(i);
       const int m = plans[i]->M_total;
       DM(if (mxGetM(prhs[2]) * mxGetN(prhs[2]) != (unsigned)m)
         mexErrMsgTxt("Input argument f must have correct size.");)
@@ -399,6 +433,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
     check_nargs(nrhs,3,"Wrong number of arguments for set_f_hat.");
     {
       int i = nfft_mex_get_int(prhs[1],"nfsft: Input argument plan must be a scalar.");
+      check_plan(i);
       const int n = plans[i]->N;
       DM(if (!mxIsDouble(prhs[2]))
         mexErrMsgTxt("Input argument f must be a double array");)
@@ -427,6 +462,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
     check_nargs(nrhs,3,"Wrong number of arguments for set_f_hat_linear.");
     {
       int i = nfft_mex_get_int(prhs[1],"nfsft: Input argument plan must be a scalar.");
+      check_plan(i);
       const int n = plans[i]->N;
       DM(if (!mxIsDouble(prhs[2]))
         mexErrMsgTxt("Input argument f_hat must be a double array");)
@@ -454,6 +490,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
     check_nargs(nrhs,2,"Wrong number of arguments for set_f_hat_linear.");
     {
       int i = nfft_mex_get_int(prhs[1],"nfsft: Input argument plan must be a scalar.");
+      check_plan(i);
       mexPrintf("Plan %d\n",i);
       mexPrintf("  pointer: %p\n",plans[i]);
       mexPrintf("        N: %d\n",plans[i]->N);
diff --git a/matlab/nfsft/nfsftmex.m b/matlab/nfsft/nfsftmex.m
index 4e08606..97971ee 100644
--- a/matlab/nfsft/nfsftmex.m
+++ b/matlab/nfsft/nfsftmex.m
@@ -1,7 +1,7 @@
 %NFSFTMEX Gateway routine to the NFSFT module
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -16,4 +16,4 @@
 % You should have received a copy of the GNU General Public License along with
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-%
\ No newline at end of file
+%
diff --git a/matlab/nfsft/projection.m b/matlab/nfsft/projection.m
index c48cd73..6610b43 100644
--- a/matlab/nfsft/projection.m
+++ b/matlab/nfsft/projection.m
@@ -1,8 +1,8 @@
 %PROJECTION Example program: Project a function onto spherical harmonics.
 %
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfsft/simple_test.m b/matlab/nfsft/simple_test.m
index 741f3c8..7eaf2f3 100644
--- a/matlab/nfsft/simple_test.m
+++ b/matlab/nfsft/simple_test.m
@@ -1,7 +1,7 @@
 %SIMPLE_TEST Example program: Basic usage principles
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfsoft/Makefile.am b/matlab/nfsoft/Makefile.am
index 58dd3a3..e152058 100644
--- a/matlab/nfsoft/Makefile.am
+++ b/matlab/nfsoft/Makefile.am
@@ -18,7 +18,8 @@ endif
 
 
 dist_nfsoftmatlab_DATA = Contents.m \
-	nfsoft_get_num_threads.m
+	nfsoft_adjoint.m nfsoft_get_num_threads.m nfsoft_f_hat_size.m nfsoft_finalize.m nfsoft_get_f_hat.m nfsoft_get_f.m nfsoft_init.m nfsoft_precompute.m nfsoft_set_f.m nfsoft_set_f_hat.m nfsoft_set_x.m nfsoft_trafo.m test_nfsoft.m \
+	NFSOFT_NORMALIZED.m NFSOFT_REPRESENT.m NFSOFT_USE_DPT.m NFSOFT_USE_NDFT.m 
 
 # target all-am builds .libs/libnfsoft at matlab_mexext@
 nfsoftmex at matlab_mexext@: all-am 
diff --git a/matlab/nfsoft/NFSOFT_NORMALIZED.m b/matlab/nfsoft/NFSOFT_NORMALIZED.m
new file mode 100644
index 0000000..667bcbc
--- /dev/null
+++ b/matlab/nfsoft/NFSOFT_NORMALIZED.m
@@ -0,0 +1,2 @@
+function f = NFSOFT_NORMALIZED()
+f = 2^0;
\ No newline at end of file
diff --git a/matlab/nfsoft/NFSOFT_REPRESENT.m b/matlab/nfsoft/NFSOFT_REPRESENT.m
new file mode 100644
index 0000000..e2132be
--- /dev/null
+++ b/matlab/nfsoft/NFSOFT_REPRESENT.m
@@ -0,0 +1,4 @@
+%Flag for using D-functions with representation property w.r.t. the
+%spherical harmonics in NFSFT
+function f = NFSOFT_REPRESENT()
+f = 2^4;
\ No newline at end of file
diff --git a/matlab/nfsoft/NFSOFT_USE_DPT.m b/matlab/nfsoft/NFSOFT_USE_DPT.m
new file mode 100644
index 0000000..08cde69
--- /dev/null
+++ b/matlab/nfsoft/NFSOFT_USE_DPT.m
@@ -0,0 +1,3 @@
+function f = NFSOFT_USE_DPT()
+f = 4;
+end
\ No newline at end of file
diff --git a/matlab/nfsoft/NFSOFT_USE_NDFT.m b/matlab/nfsoft/NFSOFT_USE_NDFT.m
new file mode 100644
index 0000000..be1ac49
--- /dev/null
+++ b/matlab/nfsoft/NFSOFT_USE_NDFT.m
@@ -0,0 +1,3 @@
+function f = NFSOFT_USE_NDFT()
+f = 2;
+end
\ No newline at end of file
diff --git a/matlab/nfsoft/nfsoft_adjoint.m b/matlab/nfsoft/nfsoft_adjoint.m
new file mode 100644
index 0000000..eb7ece3
--- /dev/null
+++ b/matlab/nfsoft/nfsoft_adjoint.m
@@ -0,0 +1,3 @@
+%Adjoint NFSOFT transformation
+function nfsoft_adjoint (plan)
+nfsoftmex('adjoint',plan)
\ No newline at end of file
diff --git a/matlab/nfsoft/nfsoft_f_hat_size.m b/matlab/nfsoft/nfsoft_f_hat_size.m
new file mode 100644
index 0000000..8f10cd0
--- /dev/null
+++ b/matlab/nfsoft/nfsoft_f_hat_size.m
@@ -0,0 +1,4 @@
+%Returns size of vector f_hat for degree N
+function f = nfsoft_f_hat_size(N)
+f = ((N+1).*(4*(N+1).*(N+1)-1)/3);
+return;
\ No newline at end of file
diff --git a/matlab/nfsoft/nfsoft_finalize.m b/matlab/nfsoft/nfsoft_finalize.m
new file mode 100644
index 0000000..d16168b
--- /dev/null
+++ b/matlab/nfsoft/nfsoft_finalize.m
@@ -0,0 +1,3 @@
+%Finalize plan
+function nfsoft_finalize(plan)
+nfsoftmex('finalize',plan)
\ No newline at end of file
diff --git a/matlab/nfsoft/nfsoft_get_f.m b/matlab/nfsoft/nfsoft_get_f.m
new file mode 100644
index 0000000..f350fe1
--- /dev/null
+++ b/matlab/nfsoft/nfsoft_get_f.m
@@ -0,0 +1,3 @@
+%Get function values from plan
+function f=nfsoft_get_f(plan)
+f=nfsoftmex('get_f',plan);
\ No newline at end of file
diff --git a/matlab/nfsoft/nfsoft_get_f_hat.m b/matlab/nfsoft/nfsoft_get_f_hat.m
new file mode 100644
index 0000000..abd50d8
--- /dev/null
+++ b/matlab/nfsoft/nfsoft_get_f_hat.m
@@ -0,0 +1,3 @@
+%Get Fourier coefficients from plan
+function f_hat = nfsoft_get_f_hat (plan)
+f_hat = nfsoftmex('get_f_hat',plan);
\ No newline at end of file
diff --git a/matlab/nfsoft/nfsoft_get_num_threads.m b/matlab/nfsoft/nfsoft_get_num_threads.m
index 446f59a..8f48ddf 100644
--- a/matlab/nfsoft/nfsoft_get_num_threads.m
+++ b/matlab/nfsoft/nfsoft_get_num_threads.m
@@ -1,5 +1,5 @@
 %NFSOFT_GET_NUM_THREADS Get number of threads (at most) used for computation
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfsoft/nfsoft_index.m b/matlab/nfsoft/nfsoft_index.m
new file mode 100644
index 0000000..ebcfd08
--- /dev/null
+++ b/matlab/nfsoft/nfsoft_index.m
@@ -0,0 +1,3 @@
+%Returns the index of f_hat from the Wigner D-function D^l_{m,k}
+function my_ind = nfsoft_index (l, m, k)
+my_ind = NFSOFT_F_HAT_SIZE(l-1) + (k+l).*(2*l+1) + (m+l) +1;
\ No newline at end of file
diff --git a/matlab/nfsoft/nfsoft_init.m b/matlab/nfsoft/nfsoft_init.m
new file mode 100644
index 0000000..d4cad1a
--- /dev/null
+++ b/matlab/nfsoft/nfsoft_init.m
@@ -0,0 +1,29 @@
+%Initialize NFSOFT plan
+% plan = nfsoft_init(N, M)
+% plan = nfsoft_init(N, M, nfsoft_flags)
+% plan = nfsoft_init(N, M, nfsoft_flags, nfft_flags, nfft_cutoff, fpt_kappa)
+% N ... polynomial degree (bandwidth)
+% M ... number of nodes
+% nfsoft_flags  ... can be NFSOFT_NORMALIZED, NFSOFT_REPRESENT,
+% NFSOFT_USE_DPT, NFSOFT_USE_NDFT (default=0)
+
+function plan = nfsoft_init(N, M, ...
+    nfsoft_flags, nfft_flags, nfft_cutoff, fpt_kappa, nn_oversampled)
+narginchk(2,7);
+if(nargin<7)
+    nn_oversampled=8*N; % oversampling of NFFT
+if(nargin<6)
+    fpt_kappa=1000;
+if(nargin<5)
+    nfft_cutoff=6;
+if(nargin<4)
+    nfft_flags=0;
+if( nargin<3)
+    nfsoft_flags=0;
+end
+end
+end
+end
+end
+plan = nfsoftmex('init',N,M,nfsoft_flags,nfft_flags,nfft_cutoff,...
+    fpt_kappa, nn_oversampled);
\ No newline at end of file
diff --git a/matlab/nfsoft/nfsoft_precompute.m b/matlab/nfsoft/nfsoft_precompute.m
new file mode 100644
index 0000000..e704a52
--- /dev/null
+++ b/matlab/nfsoft/nfsoft_precompute.m
@@ -0,0 +1,3 @@
+%Node-dependent precomputation
+function nfsoft_precompute(plan)
+nfsoftmex('precompute',plan)
\ No newline at end of file
diff --git a/matlab/nfsoft/nfsoft_set_f.m b/matlab/nfsoft/nfsoft_set_f.m
new file mode 100644
index 0000000..71cf844
--- /dev/null
+++ b/matlab/nfsoft/nfsoft_set_f.m
@@ -0,0 +1,3 @@
+%Set function values
+function nfsoft_set_f (plan,f)
+nfsoftmex('set_f',plan,f)
\ No newline at end of file
diff --git a/matlab/nfsoft/nfsoft_set_f_hat.m b/matlab/nfsoft/nfsoft_set_f_hat.m
new file mode 100644
index 0000000..f64385a
--- /dev/null
+++ b/matlab/nfsoft/nfsoft_set_f_hat.m
@@ -0,0 +1,3 @@
+%Set Fourier coefficients
+function nfsoft_set_f_hat (plan,f_hat)
+nfsoftmex('set_f_hat',plan,f_hat)
\ No newline at end of file
diff --git a/matlab/nfsoft/nfsoft_set_x.m b/matlab/nfsoft/nfsoft_set_x.m
new file mode 100644
index 0000000..2ebdfa8
--- /dev/null
+++ b/matlab/nfsoft/nfsoft_set_x.m
@@ -0,0 +1,6 @@
+%Set rotations in Euler angles for nfsoft
+% x(1,:) = alpha
+% x(2,:) = beta
+% x(3,:) = gamma
+function nfsoft_set_x(plan,x)
+nfsoftmex('set_x',plan,x)
\ No newline at end of file
diff --git a/matlab/nfsoft/nfsoft_trafo.m b/matlab/nfsoft/nfsoft_trafo.m
new file mode 100644
index 0000000..ac07de6
--- /dev/null
+++ b/matlab/nfsoft/nfsoft_trafo.m
@@ -0,0 +1,3 @@
+%Fast SO(3) Fourier transform
+function nfsoft_trafo(plan)
+nfsoftmex('trafo',plan)
\ No newline at end of file
diff --git a/matlab/nfsoft/nfsoftmex.c b/matlab/nfsoft/nfsoftmex.c
index 43ff5b8..1a0b497 100644
--- a/matlab/nfsoft/nfsoftmex.c
+++ b/matlab/nfsoft/nfsoftmex.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
@@ -31,61 +31,53 @@
   #include "mexversion.c"
 #endif
 
-#define PLANS_MAX 100 /* maximum number of plans */
+#define PLANS_START 10 /* initial number of plans */
 #define CMD_LEN_MAX 20 /* maximum length of command argument */
 
 /* global flags */
 #define NFSOFT_MEX_FIRST_CALL (1U << 0)
-unsigned short gflags = NFSOFT_MEX_FIRST_CALL;
+static unsigned short gflags = NFSOFT_MEX_FIRST_CALL;
 
-nfsoft_plan* plans[PLANS_MAX]; /* plans */
-int n_max = -1; /* maximum degree precomputed */
-char cmd[CMD_LEN_MAX];
+static nfsoft_plan** plans = NULL; /* plans */
+static unsigned int plans_num_allocated = 0;
+static int n_max = -1; /* maximum degree precomputed */
+static char cmd[CMD_LEN_MAX];
 
-static inline void get_nm(const mxArray *prhs[], int *n, int *m)
+static inline void check_nargs(const int nrhs, const int n, const char* errmsg)
 {
-  int t = nfft_mex_get_int(prhs[1],"nfsoft: Input argument N must be a scalar.");
-  DM(if (t < 0)
-    mexErrMsgTxt("nfsoft: Input argument N must be non-negative.");)
-  *n = t;
-  t = nfft_mex_get_int(prhs[2],"nfsoft: Input argument M must be a scalar.");
-  DM(if (t < 1)
-    mexErrMsgTxt("nfsoft: Input argument M must be positive.");)
-  *m = t;
+  DM(if (nrhs != n)
+    mexErrMsgTxt(errmsg);)
 }
 
-static inline void get_nmf(const mxArray *prhs[], int *n, int *m,
-  unsigned int *f)
+static inline int get_plan(const mxArray *pm)
 {
-  get_nm(prhs,n,m);
-  *f = nfft_mex_get_int(prhs[3],"nfsoft: Input argument flags must be a scalar.");
+  int i = nfft_mex_get_int(pm,"Input argument plan must be a scalar.");
+  DM(if (i < 0 || i >= plans_num_allocated || plans[i] == 0)
+    mexErrMsgTxt("Plan was not initialized or has already been finalized");)
+  return i;
 }
 
-static inline void get_nmffc(const mxArray *prhs[], int *n, int *m,
-  unsigned int *f, unsigned int *f2, int *c)
+static inline int mkplan()
 {
-  get_nmf(prhs,n,m,f);
-  *f2 = nfft_mex_get_int(prhs[4],"nfsoft: Input argument flags2 must be a scalar.");
+  int i = 0;
+  while (i < plans_num_allocated && plans[i] != 0) i++;
+  if (i == plans_num_allocated)
   {
-    int t = nfft_mex_get_int(prhs[5],"nfsoft: Input argument c must be a scalar.");
-    DM(if (t < 1)
-      mexErrMsgTxt("nfsoft: Input argument c must be positive.");)
-    *c = t;
-  }
-}
+    int l;
 
-static inline void check_nargs(const int nrhs, const int n, const char* errmsg)
-{
-  DM(if (nrhs != n)
-    mexErrMsgTxt(errmsg);)
-}
+    if (plans_num_allocated >= INT_MAX - PLANS_START - 1)
+      mexErrMsgTxt("nfsoft: Too many plans already allocated.");
 
-static inline int mkplan()
-{
-  int i = 0;
-  while (i < PLANS_MAX && plans[i] != 0) i++;
-  if (i == PLANS_MAX)
-    mexErrMsgTxt("nfsoft: Too many plans already allocated.");
+    nfsoft_plan** plans_old = plans;
+    plans = nfft_malloc((plans_num_allocated+PLANS_START)*sizeof(nfsoft_plan*));
+    for (l = 0; l < plans_num_allocated; l++)
+      plans[l] = plans_old[l];
+    for (l = plans_num_allocated; l < plans_num_allocated+PLANS_START; l++)
+      plans[l] = 0;
+    if (plans_num_allocated > 0)
+      nfft_free(plans_old);
+    plans_num_allocated += PLANS_START;
+  }
   plans[i] = nfft_malloc(sizeof(nfsoft_plan));
   return i;
 }
@@ -97,13 +89,20 @@ static void cleanup(void)
 
   if (!(gflags & NFSOFT_MEX_FIRST_CALL))
   {
-    for (i = 0; i < PLANS_MAX; i++)
+    for (i = 0; i < plans_num_allocated; i++)
       if (plans[i])
       {
         nfsoft_finalize(plans[i]);
         nfft_free(plans[i]);
         plans[i] = 0;
       }
+
+    if (plans_num_allocated > 0)
+    {
+      nfft_free(plans);
+      plans = NULL;
+      plans_num_allocated = 0;
+    }
     gflags |= NFSOFT_MEX_FIRST_CALL;
     n_max = -1;
   }
@@ -119,13 +118,6 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
 
     nfft_mex_install_mem_hooks();
 
-    /* plan pointers to zeros */
-    {
-      int i;
-      for (i = 0; i < PLANS_MAX; i++)
-        plans[i] = 0;
-    }
-
     mexAtExit(cleanup);
     gflags &= ~NFSOFT_MEX_FIRST_CALL;
   }
@@ -148,7 +140,196 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
 
     return;
   }
+
+  else if(strcmp(cmd,"init") == 0)
+  {
+    check_nargs(nrhs,8,"Wrong number of arguments for init.");
+	int N = nfft_mex_get_int(prhs[1],"N must be scalar");
+ 	DM( if (N <= 0)
+		mexErrMsgTxt("Input argument N must be positive.");)
+	int M = nfft_mex_get_int(prhs[2],"M must be scalar");
+	int flags_int = nfft_mex_get_int(prhs[3],"Input argument flags must be a scalar.");
+	DM( if (flags_int < 0)
+		mexErrMsgTxt("Input argument flags must be non-negative.");)
+	unsigned flags = (unsigned) flags_int;
+	int nfft_flags_int = nfft_mex_get_int(prhs[4],"Input argument nfft_flags must be a scalar.");
+	DM( if (nfft_flags_int < 0)
+		mexErrMsgTxt("Input argument nfft_flags must be non-negative.");)
+	unsigned nfft_flags = (unsigned) nfft_flags_int;
+	int nfft_cutoff = nfft_mex_get_int(prhs[5],"Input argument nfft_cutoff must be a scalar.");
+	int fpt_kappa = nfft_mex_get_int(prhs[6],"Input argument fpt_kappa must be a scalar.");
+	int nn_oversampled = nfft_mex_get_int(prhs[7],"Input argument nn_oversampled must be a scalar.");
+	
+	int i = mkplan();
+	nfsoft_init_guru_advanced(plans[i], N, M, flags | NFSOFT_MALLOC_X | NFSOFT_MALLOC_F | NFSOFT_MALLOC_F_HAT,
+	nfft_flags | PRE_PHI_HUT | PRE_PSI | MALLOC_X | MALLOC_F_HAT | MALLOC_F | FFTW_INIT | FFT_OUT_OF_PLACE, nfft_cutoff, fpt_kappa, nn_oversampled);
+    plhs[0] = mxCreateDoubleScalar((double)i);
+    return;
+  }
+
+  else if(strcmp(cmd,"set_x") == 0)
+  {
+    check_nargs(nrhs,3,"Wrong number of arguments for set_x.");
+	int i = get_plan(prhs[1]);
+	
+	DM(if (!(mxIsDouble(prhs[2])) || (mxGetNumberOfDimensions(prhs[2]) > 2) || (mxGetN(prhs[2]) != plans[i]->M_total) || mxGetM(prhs[2]) != 3))
+        mexErrMsgTxt("Input argument x must be a real 3 x M array");
+	double *x = mxGetPr(prhs[2]);
+	
+	for (int j = 0; j < 3*(plans[i]->M_total); j++)
+    {
+    plans[i]->x[j] = x[j];
+    }
+	return;
+  }
+
+  else if(strcmp(cmd,"set_f_hat") == 0)
+  {
+    check_nargs(nrhs,3,"Wrong number of arguments for set_f_hat.");
+	int i = get_plan(prhs[1]);
+	
+	int N = plans[i]->N_total;
+	int fh_size = NFSOFT_F_HAT_SIZE(N);
+	
+	DM(if (!(mxIsDouble(prhs[2]) || mxIsComplex(prhs[2])) || (mxGetNumberOfDimensions(prhs[2]) > 2) || (mxGetN(prhs[2]) != 1) || mxGetM(prhs[2]) != fh_size))
+        mexErrMsgTxt("Input argument f_hat must be a NFSOFT_F_HAT_SIZE(N) x 1 array");
+	double *fh_real = mxGetPr(prhs[2]), *fh_imag = mxGetPi(prhs[2]);
+	int glo1 = 0;
+	for (int k = -N; k <= N; k++)
+	{
+	for (int m = -N; m <= N; m++)
+	{
+		int max = (ABS(m) > ABS(k) ? ABS(m) : ABS(k));
+		for (int j = max; j <= N; j++)		// j = polynomial degree
+		{
+		int my_ind = NFSOFT_F_HAT_SIZE(j-1) + (m+j)*(2*j+1) + (k+j);
+		if(fh_imag)
+			plans[i]->f_hat[glo1] = fh_real[my_ind] + I*fh_imag[my_ind];
+		else 
+			plans[i]->f_hat[glo1] = fh_real[my_ind];
+		glo1++;
+		}
+	}
+	}
+    return;
+  }
+
+  else if(strcmp(cmd,"set_f") == 0)
+  {
+    check_nargs(nrhs,3,"Wrong number of arguments for set_f.");
+	int i = get_plan(prhs[1]);
+	
+	DM(if (!(mxIsDouble(prhs[2]) || mxIsComplex(prhs[2])) || (mxGetNumberOfDimensions(prhs[2]) > 2) || (mxGetN(prhs[2]) != 1) || mxGetM(prhs[2]) != plans[i]->M_total))
+        mexErrMsgTxt("Input argument f must be an M x 1 array");
+	double *f_real = mxGetPr(prhs[2]), *f_imag=0;
+	if(mxIsComplex(prhs[2])) 
+		f_imag = mxGetPi(prhs[2]);
+	for (int j = 0; j < plans[i]->M_total;j++)
+		{
+		if(f_imag)
+			plans[i]->f[j] = f_real[j] + I*f_imag[j];
+		else plans[i]->f[j] = f_real[j];
+		}
+    return;
+  }
+
+  else if(strcmp(cmd,"precompute") == 0)
+  {
+    check_nargs(nrhs,2,"Wrong number of arguments for precompute.");
+	int i = get_plan(prhs[1]);
+	nfsoft_precompute(plans[i]);
+    return;
+  }
+
+  else if(strcmp(cmd,"trafo") == 0)
+  {
+    check_nargs(nrhs,2,"Wrong number of arguments for trafo.");
+	int i = get_plan(prhs[1]);
+	nfsoft_trafo(plans[i]);
+    return;
+  }
+
+  else if(strcmp(cmd,"adjoint") == 0)
+  {
+    check_nargs(nrhs,2,"Wrong number of arguments for adjoint.");
+	int i = get_plan(prhs[1]);
+	nfsoft_adjoint(plans[i]);
+    return;
+  }
+
+  else if(strcmp(cmd,"get_f") == 0)
+  {
+    check_nargs(nrhs,2,"Wrong number of arguments for get_f.");
+	int i = get_plan(prhs[1]);
+	
+      plhs[0] = mxCreateDoubleMatrix((unsigned int)plans[i]->M_total, 1, mxCOMPLEX);
+      {
+        double *fr = mxGetPr(plhs[0]), *fi = mxGetPi(plhs[0]);
+        for (int j = 0; j < plans[i]->M_total; j++)
+        {
+          fr[j] = creal(plans[i]->f[j]);
+          fi[j] = cimag(plans[i]->f[j]);
+        }
+      }
+    return;
+  }
+
+  else if(strcmp(cmd,"get_f_hat") == 0)
+  {
+    check_nargs(nrhs,2,"Wrong number of arguments for get_f_hat.");
+	int i = get_plan(prhs[1]);
+	int N = plans[i]->N_total;
+	int fh_size = NFSOFT_F_HAT_SIZE(N);
+	
+    plhs[0] = mxCreateDoubleMatrix((unsigned int)fh_size, 1, mxCOMPLEX);
+    double *fr = mxGetPr(plhs[0]), *fi = mxGetPi(plhs[0]);
+	
+	int glo1 = 0;
+	for (int k = -N; k <= N; k++)
+	{
+	  for (int m = -N; m <= N; m++)
+	  {
+		int max = (ABS(m) > ABS(k) ? ABS(m) : ABS(k));
+		for (int j = max; j <= N; j++)		// j = polynomial degree
+		{
+		int my_ind = NFSOFT_F_HAT_SIZE(j-1) + (m+j)*(2*j+1) + (k+j);
+		fr[my_ind] = creal(plans[i]->f_hat[glo1]);
+		fi[my_ind] = cimag(plans[i]->f_hat[glo1]);
+		glo1++;
+		}
+	  }
+	}
+    return;
+  }
+
+  else if(strcmp(cmd,"finalize") == 0)
+  {
+    check_nargs(nrhs,2,"Wrong number of arguments finalize.");
+	int i = get_plan(prhs[1]);
+	
+    nfsoft_finalize(plans[i]);
+    nfft_free(plans[i]);
+    plans[i] = 0;
+    return;
+  }
+  
+  else if (strcmp(cmd,"display") == 0)
+  {
+    check_nargs(nrhs,2,"Wrong number of arguments for display.");
+    {
+	  int i = get_plan(prhs[1]);
+      mexPrintf("Plan %d\n",i);
+      mexPrintf("  pointer: %p\n",plans[i]);
+      mexPrintf("  N_total: %d\n",plans[i]->N_total);
+      mexPrintf("  M_total: %d\n",plans[i]->M_total);
+      mexPrintf("        x: %p\n",plans[i]->x);
+      mexPrintf("        f: %p\n",plans[i]->f);
+      mexPrintf("    f_hat: %p\n",plans[i]->f_hat);
+      mexPrintf("    flags: %d\n",plans[i]->flags);
+    }
+    return;
+  }
+  
   else
     mexErrMsgTxt("nfsoft: Unknown command.\n");
 }
-
diff --git a/matlab/nfsoft/test_nfsoft.m b/matlab/nfsoft/test_nfsoft.m
new file mode 100644
index 0000000..850799b
--- /dev/null
+++ b/matlab/nfsoft/test_nfsoft.m
@@ -0,0 +1,28 @@
+N = 32;     % bandwidth (polynomial degree)
+M = nfsoft_f_hat_size(N);	% number of points
+
+% random nodes
+alpha = rand(M,1)*2*pi;
+beta = acos(rand(M,1)*2-1);
+gamma = rand(M,1)*2*pi;
+x = [alpha';beta';gamma'];
+M = length(alpha);
+
+%% random Fourier coefficients
+fh = rand(nfsoft_f_hat_size(N),1)./(1:nfsoft_f_hat_size(N)).';
+
+plan = nfsoft_init(N,M,NFSOFT_NORMALIZED);  % create plan
+nfsoft_set_x(plan,x);           % set nodes
+nfsoft_precompute(plan);        % node-dependent precomputation
+nfsoft_set_f_hat(plan,fh);      % set Fourier coefficients
+nfsoft_trafo(plan);             % transform
+f = nfsoft_get_f(plan);         % get function values
+nfsoft_finalize(plan);
+
+%% adjoint
+plan = nfsoft_init(N,M,NFSOFT_NORMALIZED);
+nfsoft_set_x(plan,x);
+nfsoft_set_f(plan,f/M);
+nfsoft_precompute(plan);
+nfsoft_adjoint(plan);
+fh2 = nfsoft_get_f_hat(plan);
\ No newline at end of file
diff --git a/matlab/nfst/Contents.m b/matlab/nfst/Contents.m
new file mode 100644
index 0000000..d43f0e7
--- /dev/null
+++ b/matlab/nfst/Contents.m
@@ -0,0 +1,30 @@
+% NFCT
+%
+% Files
+%   FFT_OUT_OF_PLACE    - FFT flag
+%   FFTW_ESTIMATE       - FFT flag
+%   FFTW_MEASURE        - FFT flag
+%   FG_PSI              - Precompuation flag
+%   ndct_adjoint        - Adjoint nonequispaced discrete cosine transform (direct algorithm)
+%   ndct_trafo          - Nonequispaced discrete cosine transform (direct algorithm)
+%   nfct_adjoint        - Adjoint nonequispaced fast cosine transform
+%   nfct_finalize       - Finalize plan
+%   nfct_get_f          - Get function values from plan
+%   nfct_get_f_hat      - Get Fourier coefficients from plan
+%   nfct_get_x          - Get nodes from plan
+%   nfct_init_1d        - Initialise plans
+%   nfct_init_2d        - Initialise plans
+%   nfct_init_3d        - Initialise plans
+%   nfct_init_guru      - Initialise plans, no error handling
+%   nfct_precompute_psi - Precompute psi, dependent on nodes x
+%   nfct_set_f          - Set function values in plan
+%   nfct_set_f_hat      - Set Fourier coefficients in plan
+%   nfct_set_x          - Set nodes in plan
+%   nfct_trafo          - nonequispaced fast cosine transform
+%   nfctmex             - Gateway function to NFCT module from NFFT3
+%   PRE_FG_PSI          - Precomputation flag
+%   PRE_FULL_PSI        - Precomputation flag
+%   PRE_LIN_PSI         - Precomputation flag
+%   PRE_PHI_HUT         - Precomputation flag
+%   PRE_PSI             - Precomputation flag
+%   simple_test         - Example program: Basic usage principles
diff --git a/matlab/nfft/FFTW_ESTIMATE.m b/matlab/nfst/FFTW_ESTIMATE.m
similarity index 86%
copy from matlab/nfft/FFTW_ESTIMATE.m
copy to matlab/nfst/FFTW_ESTIMATE.m
index ea4848b..4a2ab18 100644
--- a/matlab/nfft/FFTW_ESTIMATE.m
+++ b/matlab/nfst/FFTW_ESTIMATE.m
@@ -1,9 +1,9 @@
 % FFTW_ESTIMATE FFT flag
 %   Valid for FFTW3
 %
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfft/FFTW_MEASURE.m b/matlab/nfst/FFTW_MEASURE.m
similarity index 86%
copy from matlab/nfft/FFTW_MEASURE.m
copy to matlab/nfst/FFTW_MEASURE.m
index bbdd8c8..1c352a3 100644
--- a/matlab/nfft/FFTW_MEASURE.m
+++ b/matlab/nfst/FFTW_MEASURE.m
@@ -1,9 +1,9 @@
 %FFTW_MEASURE FFT flag
 %   Valid for FFTW3
 %
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfft/FFT_OUT_OF_PLACE.m b/matlab/nfst/FFT_OUT_OF_PLACE.m
similarity index 87%
copy from matlab/nfft/FFT_OUT_OF_PLACE.m
copy to matlab/nfst/FFT_OUT_OF_PLACE.m
index 2bb217e..15afa2f 100644
--- a/matlab/nfft/FFT_OUT_OF_PLACE.m
+++ b/matlab/nfst/FFT_OUT_OF_PLACE.m
@@ -1,9 +1,9 @@
 %FFT_OUT_OF_PLACE FFT flag
 %   If this flag is set, FFTW uses disjoint input/output vectors.
 %
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfft/FG_PSI.m b/matlab/nfst/FG_PSI.m
similarity index 88%
copy from matlab/nfft/FG_PSI.m
copy to matlab/nfst/FG_PSI.m
index d892abd..09435b3 100644
--- a/matlab/nfft/FG_PSI.m
+++ b/matlab/nfst/FG_PSI.m
@@ -3,9 +3,9 @@
 %   sparse matrix B) uses particular properties of the Gaussian window function
 %   to trade multiplications for direct calls to exponential function.
 %
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfst/Makefile.am b/matlab/nfst/Makefile.am
new file mode 100644
index 0000000..913e947
--- /dev/null
+++ b/matlab/nfst/Makefile.am
@@ -0,0 +1,44 @@
+# compiler flags
+AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/matlab $(matlab_CPPFLAGS)
+
+# matlab wrapper directory
+nfstmatlabdir = $(datadir)/nfft/matlab/nfst
+
+# library
+lib_LTLIBRARIES = libnfst.la
+libnfst_la_SOURCES = nfstmex.c
+
+libnfst_la_LIBADD = $(top_builddir)/libnfft3_matlab.la @matlab_fftw3_LIBS@ $(top_builddir)/matlab/libmatlab.la $(matlab_LIBS)
+
+libnfst_la_LDFLAGS = -no-undefined -module -shared -shrext $(matlab_mexext) -avoid-version @matlab_fftw3_LDFLAGS@ $(matlab_LDFLAGS)
+
+if HAVE_MATLAB_THREADS
+libnfst_la_CFLAGS = $(OPENMP_CFLAGS)
+endif
+
+dist_nfstmatlab_DATA = Contents.m FFTW_ESTIMATE.m FFTW_MEASURE.m \
+	FFT_OUT_OF_PLACE.m FG_PSI.m PRE_FG_PSI.m PRE_FULL_PSI.m PRE_LIN_PSI.m \
+	PRE_PHI_HUT.m PRE_PSI.m ndst_adjoint.m ndst_trafo.m nfst.m \
+	nfst_adjoint.m nfst_finalize.m nfst_get_f.m nfst_get_f_hat.m \
+	nfst_get_num_threads.m nfst_get_x.m nfst_init_1d.m nfst_init_2d.m \
+	nfst_init_3d.m nfst_init_guru.m nfst_set_f.m nfst_set_f_hat.m \
+	nfst_set_x.m nfst_trafo.m simple_test.m test_nfst1d.m test_nfst2d.m \
+	test_nfst3d.m
+
+# target all-am builds .libs/libnfst at matlab_mexext@
+nfstmex at matlab_mexext@: all-am
+	rm -f ./nfstmex at matlab_mexext@
+	$(LN_S) .libs/libnfst at matlab_mexext@ ./nfstmex at matlab_mexext@
+
+all: all-am nfstmex at matlab_mexext@
+
+clean: clean-am
+	rm -f ./nfstmex at matlab_mexext@
+
+install-exec-hook:
+	rm -f $(libdir)/nfstmex at matlab_mexext@
+	$(LN_S) $(libdir)/libnfst at matlab_mexext@ $(libdir)/nfstmex at matlab_mexext@
+
+uninstall-hook:
+	rm -f $(libdir)/nfstmex at matlab_mexext@
+
diff --git a/matlab/nfft/PRE_FG_PSI.m b/matlab/nfst/PRE_FG_PSI.m
similarity index 89%
copy from matlab/nfft/PRE_FG_PSI.m
copy to matlab/nfst/PRE_FG_PSI.m
index 6824e44..d5262f3 100644
--- a/matlab/nfft/PRE_FG_PSI.m
+++ b/matlab/nfst/PRE_FG_PSI.m
@@ -4,9 +4,9 @@
 %   multiplications for direct calls to exponential function (the remaining 2dM
 %   direct calls are precomputed).
 %
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfft/PRE_FULL_PSI.m b/matlab/nfst/PRE_FULL_PSI.m
similarity index 88%
copy from matlab/nfft/PRE_FULL_PSI.m
copy to matlab/nfst/PRE_FULL_PSI.m
index ad6761e..b2b403f 100644
--- a/matlab/nfft/PRE_FULL_PSI.m
+++ b/matlab/nfst/PRE_FULL_PSI.m
@@ -3,9 +3,9 @@
 %   matrix B) uses (2m+2)^dM precomputed values of the window function, in
 %   addition indices of source and target vectors are stored.
 %
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nnfft/PRE_LIN_PSI.m b/matlab/nfst/PRE_LIN_PSI.m
similarity index 89%
copy from matlab/nnfft/PRE_LIN_PSI.m
copy to matlab/nfst/PRE_LIN_PSI.m
index dfab51c..a139fbf 100644
--- a/matlab/nnfft/PRE_LIN_PSI.m
+++ b/matlab/nfst/PRE_LIN_PSI.m
@@ -3,9 +3,9 @@
 %   matrix B) uses linear interpolation from a lookup table of equispaced samples
 %   of the window function instead of exact values of the window function.
 %
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfft/PRE_PHI_HUT.m b/matlab/nfst/PRE_PHI_HUT.m
similarity index 88%
copy from matlab/nfft/PRE_PHI_HUT.m
copy to matlab/nfst/PRE_PHI_HUT.m
index a66ae1d..61871d3 100644
--- a/matlab/nfft/PRE_PHI_HUT.m
+++ b/matlab/nfst/PRE_PHI_HUT.m
@@ -3,9 +3,9 @@
 %   diagonal matrix D) uses precomputed values of the Fourier transformed window
 %   function.
 %
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nnfft/PRE_PSI.m b/matlab/nfst/PRE_PSI.m
similarity index 88%
copy from matlab/nnfft/PRE_PSI.m
copy to matlab/nfst/PRE_PSI.m
index 482b8fc..4b93aac 100644
--- a/matlab/nnfft/PRE_PSI.m
+++ b/matlab/nfst/PRE_PSI.m
@@ -1,9 +1,9 @@
 %PRE_PSI Precomputation flag
 %   If this flag is set, the convolution step (the multiplication with the sparse
 %   matrix B uses (2m+2)dM precomputed values of the window function.
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nfft/ndft_trafo.m b/matlab/nfst/ndst_adjoint.m
similarity index 73%
copy from matlab/nfft/ndft_trafo.m
copy to matlab/nfst/ndst_adjoint.m
index f72517d..a0c8986 100644
--- a/matlab/nfft/ndft_trafo.m
+++ b/matlab/nfst/ndst_adjoint.m
@@ -1,7 +1,7 @@
-%NDFT_TRAFO  Nonequispaced discrete Fourier transformation (direct algorithm)
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%NDST_ADJOINT Adjoint nonequispaced discrete sine transform (direct algorithm)
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -16,6 +16,6 @@
 % You should have received a copy of the GNU General Public License along with
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-function ndft_trafo(p)
+function ndst_adjoint(p)
 
-nfftmex('trafo_direct',p)
+nfstmex('adjoint_direct',p)
diff --git a/matlab/nfft/nfft_adjoint.m b/matlab/nfst/ndst_trafo.m
similarity index 74%
copy from matlab/nfft/nfft_adjoint.m
copy to matlab/nfst/ndst_trafo.m
index 3272b5d..70a05d6 100644
--- a/matlab/nfft/nfft_adjoint.m
+++ b/matlab/nfst/ndst_trafo.m
@@ -1,7 +1,7 @@
-%NFFT_ADJOINT Adjoint nonequispaced fast Fourier transform
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%NDST_TRAFO  Nonequispaced discrete sine transform (direct algorithm)
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -16,6 +16,6 @@
 % You should have received a copy of the GNU General Public License along with
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-function nfft_adjoint(p)
+function ndst_trafo(p)
 
-nfftmex('adjoint',p)
+nfstmex('trafo_direct',p)
diff --git a/matlab/nfft/nfft.m b/matlab/nfst/nfst.m
similarity index 67%
copy from matlab/nfft/nfft.m
copy to matlab/nfst/nfst.m
index 16f5ae9..534281e 100644
--- a/matlab/nfft/nfft.m
+++ b/matlab/nfst/nfst.m
@@ -1,5 +1,4 @@
-
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -15,11 +14,11 @@
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
-% This class provides robust a Matlab interface to the NFFT library.
+% This class provides a Matlab interface to the NFST module.
 %
 % Examples
-%   See Matlab scripts test_nfft*d.m.
-classdef nfft < handle
+%   See Matlab scripts test_nfst*d.m.
+classdef nfst < handle
 
 properties(Dependent=true)
 	x;     % nodes (real Mxd matrix)
@@ -53,30 +52,30 @@ methods
 
 % Constructer and destructor %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-function h=nfft(d,N,M,varargin)
+function h=nfst(d,N,M,varargin)
 % Constructor
 %
-% h=nfft(1,N,M) for spatial dimension d=1
-% h=nfft(2,N,M) for spatial dimension d=2
-% h=nfft(3,N,M) for spatial dimension d=3
+% h=nfst(1,N,M) for spatial dimension d=1
+% h=nfst(2,N,M) for spatial dimension d=2
+% h=nfst(3,N,M) for spatial dimension d=3
 %
-% h=nfft(d,N,M,varargin) for use of nfft_init_guru
+% h=nfst(d,N,M,varargin) for use of nfst_init_guru
 % For example
-% h=nfft(1,N,M,n,7,bitor(PRE_PHI_HUT,PRE_PSI),FFTW_MEASURE)     for d=1, m=7
-% h=nfft(2,N,M,n,n,7,bitor(PRE_PHI_HUT,bitor(PRE_PSI,NFFT_OMP_BLOCKWISE_ADJOINT)),FFTW_MEASURE)   for d=2, m=7
-% h=nfft(3,N,M,n,n,n,7,bitor(PRE_PHI_HUT,bitor(PRE_PSI,NFFT_OMP_BLOCKWISE_ADJOINT)),FFTW_MEASURE) for d=3, m=7
+% h=nfst(1,N,M,n,7,bitor(PRE_PHI_HUT,PRE_PSI),FFTW_MEASURE)     for d=1, m=7
+% h=nfst(2,N,M,n,n,7,bitor(PRE_PHI_HUT,bitor(PRE_PSI,NFFT_OMP_BLOCKWISE_ADJOINT)),FFTW_MEASURE)   for d=2, m=7
+% h=nfst(3,N,M,n,n,n,7,bitor(PRE_PHI_HUT,bitor(PRE_PSI,NFFT_OMP_BLOCKWISE_ADJOINT)),FFTW_MEASURE) for d=3, m=7
 % with n=2^(ceil(log(max(N))/log(2))+1)
-% Be careful: There is no error handling with using nfft_init_guru.
+% Be careful: There is no error handling with using nfst_init_guru.
 % Incorrect inputs can cause a Matlab crash!
 %
 % INPUT
 %   d         spatial dimension (d=1, d=2 or d=3)
 %   N         numbers of nodes in each direction (column vector of length d with positive even integers)
 %   M         number of sampling points (positive integer)
-%   varargin  parameters for use of nfft_init_guru (see documentation of NFFT for more details)
+%   varargin  parameters for use of nfst_init_guru (see documentation of NFST for more details)
 %
 % OUTPUT
-%   h   object of class type nfft
+%   h   object of class type nfst
 
 	h.d=d;
 
@@ -93,19 +92,19 @@ function h=nfft(d,N,M,varargin)
 	elseif( 3==nargin )
 		switch d
 		case 1
-			h.plan=nfftmex('init_1d',N,M);
+			h.plan=nfstmex('init_1d',N,M);
 			h.plan_is_set=true;
 		case 2
-			h.plan=nfftmex('init_2d',N(1),N(2),M);
+			h.plan=nfstmex('init_2d',N(1),N(2),M);
 			h.plan_is_set=true;
 		case 3
-			h.plan=nfftmex('init_3d',N(1),N(2),N(3),M);
+			h.plan=nfstmex('init_3d',N(1),N(2),N(3),M);
 			h.plan_is_set=true;
 		otherwise
 			error('Invalid spatial dimension d.');
 		end %switch
-	else % nfft_init_guru
-		%disp('You are using nfft_init_guru. This is on your own risk. There will be no error handling. Incorrect inputs can cause a Matlab crash.');
+	else % nfst_init_guru
+		%disp('You are using nfst_init_guru. This is on your own risk. There will be no error handling. Incorrect inputs can cause a Matlab crash.');
 		switch d
 		case 1
 			args=[{d,N(1),M},varargin];
@@ -116,7 +115,7 @@ function h=nfft(d,N,M,varargin)
 		otherwise
 			error('Unknown error.');
 		end %switch
-		h.plan=nfftmex('init_guru',args);
+		h.plan=nfstmex('init_guru',args);
 		h.plan_is_set=true;
 	end %if
 end %function
@@ -124,7 +123,7 @@ end %function
 function delete(h)
 % Destructor
 	if(h.plan_is_set)
-		nfftmex('finalize',h.plan);
+		nfstmex('finalize',h.plan);
 	end %if
 end %function
 
@@ -179,7 +178,7 @@ function set.N3(h,N)
 end %function
 
 function set.M(h,M)
-	if( ndims(M)~=2 || size(M,1)~=1 || size(M,2)~=1)
+	if( ~ismatrix(M) || size(M,1)~=1 || size(M,2)~=1)
 		error('The number of sampling pints M has to be an positive integer.');
 	elseif( isempty(M) || ~isnumeric(M) || ~isreal(M) || mod(M,1)~=0 || ~(M>0) )
 		error('The number of sampling pints M has to be an positive integer.');
@@ -198,21 +197,21 @@ function set.x(h,x)
 	elseif( size(x,1)~=h.M || size(x,2)~=h.d )
 		error('The sampling points have to be a %ux%u matrix',h.M,h.d);
 	else
-		x=mod(x+0.5,1)-0.5;
-		nfftmex('set_x',h.plan,x.');
+		x=mod(x,0.5);
+		nfstmex('set_x',h.plan,x.');
 		h.x_is_set=true;
-		h.precomputations_done=false;
+		h.precomputations_done=true; % precompute is called within set_x
 	end %if
 end %function
 
 function set.fhat(h,fhat)
 	switch h.d
 	case 1
-		n=h.N1;
+		n=h.N1-1;
 	case 2
-		n=h.N1*h.N2;
+		n=(h.N1-1)*(h.N2-1);
 	case 3
-		n=h.N1*h.N2*h.N3;
+		n=(h.N1-1)*(h.N2-1)*(h.N3-1);
 	otherwise
 		error('Unknown error.');
 	end % switch
@@ -226,19 +225,19 @@ function set.fhat(h,fhat)
 		case 1
 			% Do nothing.
 		case 2
-			% linearization in matlab with column (:) operator is columnwise, in NFFT it is rowwise
-			fhat=reshape(fhat,h.N1,h.N2).';
+			% linearization in matlab with column (:) operator is columnwise, in NFST it is rowwise
+			fhat=reshape(fhat,h.N1-1,h.N2-1).';
 			fhat=fhat(:);
 		case 3
-			% linearization in matlab with column (:) operator is columnwise, in NFFT it is rowwise
-			fhat=reshape(fhat,h.N1,h.N2,h.N3);
+			% linearization in matlab with column (:) operator is columnwise, in NFST it is rowwise
+			fhat=reshape(fhat,h.N1-1,h.N2-1,h.N3-1);
 			fhat=permute(fhat,[3,2,1]);
 			fhat=fhat(:);
 		otherwise
 			error('Unknown error.');
 		end %switch
 
-		nfftmex('set_f_hat',h.plan,fhat);
+		nfstmex('set_f_hat',h.plan,fhat);
 		h.fhat_is_set=true;
 	end %if
 end %function
@@ -249,7 +248,7 @@ function set.f(h,f)
 	elseif( size(f,1)~=h.M || size(f,2)~=1 )
 		error('The samples f have to be an column vector of length M=%u',h.M);
 	else
-		nfftmex('set_f',h.plan,f);
+		nfstmex('set_f',h.plan,f);
 		h.f_is_set=true;
 	end %if
 end %function
@@ -258,7 +257,7 @@ end %function
 
 function x=get.x(h)
 	if(h.x_is_set)
-		x=nfftmex('get_x',h.plan).';
+		x=nfstmex('get_x',h.plan).';
 	else
 		x=[];
 	end %if
@@ -266,18 +265,18 @@ end %function
 
 function fhat=get.fhat(h)
 	if(h.fhat_is_set)
-		fhat=nfftmex('get_f_hat',h.plan);
+		fhat=nfstmex('get_f_hat',h.plan);
 
 		switch h.d
 		case 1
 			% Do nothing.
 		case 2
-			% linearization in matlab with column (:) operator is columnwise, in NFFT it is rowwise
-			fhat=reshape(fhat,h.N2,h.N1).';
+			% linearization in matlab with column (:) operator is columnwise, in NFST it is rowwise
+			fhat=reshape(fhat,h.N2-1,h.N1-1).';
 			fhat=fhat(:);
 		case 3
-			% linearization in matlab with column (:) operator is columnwise, in NFFT it is rowwise
-			fhat=reshape(fhat,h.N3,h.N2,h.N1);
+			% linearization in matlab with column (:) operator is columnwise, in NFST it is rowwise
+			fhat=reshape(fhat,h.N3-1,h.N2-1,h.N1-1);
 			fhat=permute(fhat,[3,2,1]);
 			fhat=fhat(:);
 		otherwise
@@ -290,7 +289,7 @@ end %funcition
 
 function f=get.f(h)
 	if(h.f_is_set)
-		f=nfftmex('get_f',h.plan);
+		f=nfstmex('get_f',h.plan);
 	else
 		f=[];
 	end %if
@@ -302,84 +301,92 @@ end %function
 
 % User methods %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-function nfft_precompute_psi(h)
-% Precomputations for NFFT.
-	if(~h.x_is_set)
-		error('Before doing precomputations you have to set nodes in x.');
-	else
-		nfftmex('precompute_psi',h.plan)
-		h.precomputations_done=true;
-	end %if
-end %function
-
-function ndft_trafo(h)
-% NDFT.
+% function nfst_precompute_psi(h)
+% % Precomputations for NFST.
+% 	if(~h.x_is_set)
+% 		error('Before doing precomputations you have to set nodes in x.');
+% 	else
+% 		nfstmex('precompute_psi',h.plan)
+% 		h.precomputations_done=true;
+% 	end %if
+% end %function
+
+function ndst_trafo(h)
+% NDCT.
 %
-% ndft_trafo(h)
+% ndst_trafo(h)
 %
 % INPUT
-%   h  object of class type nfft
+%   h  object of class type nfst
 
-	if(~h.precomputations_done)
-		error('Before doing a NFFT transform you have to do precomputations.');
+% 	if(~h.precomputations_done)
+% 		error('Before doing a NFST transform you have to do precomputations.');
+	if(~h.x_is_set)
+		error('Before doing a NFST transform you have to set the x nodes.');
 	elseif(~h.fhat_is_set)
-		error('Before doing a NFFT transform you have to set Fourier coefficients in fhat.');
+		error('Before doing a NFST transform you have to set Fourier coefficients in fhat.');
 	else
-		nfftmex('trafo_direct',h.plan);
+		nfstmex('trafo_direct',h.plan);
 		h.f_is_set=true;
 	end %if
 end %function
 
-function nfft_trafo(h)
-% NFFT.
+function nfst_trafo(h)
+% NFST.
 %
-% nfft_trafo(h)
+% nfst_trafo(h)
 %
 % INPUT
-%   h  object of class type nfft
+%   h  object of class type nfst
 
-	if(~h.precomputations_done)
-		error('Before doing a NFFT transform you have to do precomputations.');
+% 	if(~h.precomputations_done)
+% 		error('Before doing a NFST transform you have to do precomputations.');
+	if(~h.x_is_set)
+		error('Before doing a NFST transform you have to set the x nodes.');
 	elseif(~h.fhat_is_set)
-		error('Before doing a NFFT transform you have to set Fourier coefficients in fhat.');
+		error('Before doing a NFST transform you have to set Fourier coefficients in fhat.');
 	else
-		nfftmex('trafo',h.plan);
+		nfstmex('trafo',h.plan);
 		h.f_is_set=true;
 	end %if
 end %function
 
-function ndft_adjoint(h)
-% Adjoint NDFT.
+function ndst_adjoint(h)
+% Adjoint NDCT.
 %
-% ndft_adjoint(h)
+% ndst_adjoint(h)
 %
 % INPUT
-%   h  object of class type nfft
+%   h  object of class type nfst
 
-	if(~h.precomputations_done)
-		error('Before doing a adjoint NFFT transform you have to do precomputations.');
+% 	if(~h.precomputations_done)
+% 		error('Before doing a adjoint NFST transform you have to do precomputations.');
+	if(~h.x_is_set)
+		error('Before doing an adjoint NFST transform you have to set the x nodes.');
 	elseif(~h.f_is_set)
-		error('Before doing a adjoint NFFT transform you have to set samples in f.');
+		error('Before doing an adjoint NFST transform you have to set samples in f.');
 	else
-		nfftmex('adjoint_direct',h.plan);
+		nfstmex('adjoint_direct',h.plan);
 		h.fhat_is_set=true;
 	end %if
 end %function
 
-function nfft_adjoint(h)
-% Adjoint NFFT
+function nfst_adjoint(h)
+% Adjoint NFST
 %
-% nfft_adjoint(h)
+% nfst_adjoint(h)
 %
 % INPUT
-%   h  object of class type nfft
+%   h  object of class type nfst
 
-	if(~h.precomputations_done)
-		error('Before doing a adjoint NFFT transform you have to do precomputations.');
+% 	if(~h.precomputations_done)
+% 		error('Before doing a adjoint NFST transform you have to do precomputations.');
+	if(~h.x_is_set)
+		error('Before doing an adjoint NFST transform you have to set the x nodes.');
 	elseif(~h.f_is_set)
-		error('Before doing a adjoint NFFT transform you have to set samples in f.');
+		error('Before doing an adjoint NFST transform you have to set samples in f.');
 	else
-		nfftmex('adjoint',h.plan);
+		nfstmex('adjoint',h.plan);
 		h.fhat_is_set=true;
 	end %if
 end %function
diff --git a/matlab/nfft/nfft_get_f.m b/matlab/nfst/nfst_adjoint.m
similarity index 75%
copy from matlab/nfft/nfft_get_f.m
copy to matlab/nfst/nfst_adjoint.m
index 02aed96..27a2cde 100644
--- a/matlab/nfft/nfft_get_f.m
+++ b/matlab/nfst/nfst_adjoint.m
@@ -1,7 +1,7 @@
-%NFFT_GET_F Get function values from plan
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%NFST_ADJOINT Adjoint nonequispaced fast sine transform
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -16,6 +16,6 @@
 % You should have received a copy of the GNU General Public License along with
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-function f = nfft_get_f(p)
+function nfst_adjoint(p)
 
-f = nfftmex('get_f',p);
+nfstmex('adjoint',p)
diff --git a/matlab/nfft/nfft_set_x.m b/matlab/nfst/nfst_finalize.m
similarity index 77%
copy from matlab/nfft/nfft_set_x.m
copy to matlab/nfst/nfst_finalize.m
index 997620e..6fab673 100644
--- a/matlab/nfft/nfft_set_x.m
+++ b/matlab/nfst/nfst_finalize.m
@@ -1,7 +1,7 @@
-%NFFT_SET_X Set nodes in plan
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%NFST_FINALIZE Finalize plan
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -16,6 +16,6 @@
 % You should have received a copy of the GNU General Public License along with
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-function nfft_set_x(p,x)
+function nfst_finalize(p)
 
-nfftmex('set_x',p,x)
+nfstmex('finalize',p)
diff --git a/matlab/nfft/nfft_get_f.m b/matlab/nfst/nfst_get_f.m
similarity index 76%
copy from matlab/nfft/nfft_get_f.m
copy to matlab/nfst/nfst_get_f.m
index 02aed96..07c16e1 100644
--- a/matlab/nfft/nfft_get_f.m
+++ b/matlab/nfst/nfst_get_f.m
@@ -1,7 +1,7 @@
-%NFFT_GET_F Get function values from plan
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%NFST_GET_F Get function values from plan
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -16,6 +16,6 @@
 % You should have received a copy of the GNU General Public License along with
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-function f = nfft_get_f(p)
+function f = nfst_get_f(p)
 
-f = nfftmex('get_f',p);
+f = nfstmex('get_f',p);
diff --git a/matlab/nfft/nfft_adjoint.m b/matlab/nfst/nfst_get_f_hat.m
similarity index 74%
copy from matlab/nfft/nfft_adjoint.m
copy to matlab/nfst/nfst_get_f_hat.m
index 3272b5d..99db07b 100644
--- a/matlab/nfft/nfft_adjoint.m
+++ b/matlab/nfst/nfst_get_f_hat.m
@@ -1,7 +1,7 @@
-%NFFT_ADJOINT Adjoint nonequispaced fast Fourier transform
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%NFST_GET_F_HAT Get Fourier coefficients from plan
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -16,6 +16,6 @@
 % You should have received a copy of the GNU General Public License along with
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-function nfft_adjoint(p)
+function f_hat = nfst_get_f_hat(p)
 
-nfftmex('adjoint',p)
+f_hat = nfstmex('get_f_hat',p);
diff --git a/matlab/nfft/nfft_get_num_threads.m b/matlab/nfst/nfst_get_num_threads.m
similarity index 72%
copy from matlab/nfft/nfft_get_num_threads.m
copy to matlab/nfst/nfst_get_num_threads.m
index 14495fc..0cbf1ee 100644
--- a/matlab/nfft/nfft_get_num_threads.m
+++ b/matlab/nfst/nfst_get_num_threads.m
@@ -1,7 +1,7 @@
-%NFFT_GET_NUM_THREADS Get number of threads (at most) used for computation
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%NFST_GET_NUM_THREADS Get number of threads (at most) used for computation
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -16,6 +16,6 @@
 % You should have received a copy of the GNU General Public License along with
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-function nthreads = nfft_get_num_threads()
+function nthreads = nfst_get_num_threads()
 
-nthreads = nfftmex('get_num_threads');
+nthreads = nfstmex('get_num_threads');
diff --git a/matlab/nfft/nfft_set_x.m b/matlab/nfst/nfst_get_x.m
similarity index 77%
copy from matlab/nfft/nfft_set_x.m
copy to matlab/nfst/nfst_get_x.m
index 997620e..0f3d538 100644
--- a/matlab/nfft/nfft_set_x.m
+++ b/matlab/nfst/nfst_get_x.m
@@ -1,7 +1,7 @@
-%NFFT_SET_X Set nodes in plan
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%NFST_GET_X Get nodes from plan
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -16,6 +16,6 @@
 % You should have received a copy of the GNU General Public License along with
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-function nfft_set_x(p,x)
+function x = nfst_get_x(p)
 
-nfftmex('set_x',p,x)
+x = nfstmex('get_x',p);
diff --git a/matlab/nfft/nfft_init_1d.m b/matlab/nfst/nfst_init_1d.m
similarity index 76%
copy from matlab/nfft/nfft_init_1d.m
copy to matlab/nfst/nfst_init_1d.m
index 29167f9..39fda4d 100644
--- a/matlab/nfft/nfft_init_1d.m
+++ b/matlab/nfst/nfst_init_1d.m
@@ -1,7 +1,7 @@
-%NFFT_INIT_1D Initialise plans
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%NFST_INIT_1D Initialise plans
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -16,6 +16,6 @@
 % You should have received a copy of the GNU General Public License along with
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-function p = nfft_init_1d(N,M)
+function p = nfst_init_1d(N,M)
 
-p = nfftmex('init_1d',N,M);
+p = nfstmex('init_1d',N,M);
diff --git a/matlab/nfft/nfft_get_f.m b/matlab/nfst/nfst_init_2d.m
similarity index 76%
copy from matlab/nfft/nfft_get_f.m
copy to matlab/nfst/nfst_init_2d.m
index 02aed96..76a9893 100644
--- a/matlab/nfft/nfft_get_f.m
+++ b/matlab/nfst/nfst_init_2d.m
@@ -1,7 +1,7 @@
-%NFFT_GET_F Get function values from plan
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%NFST_INIT_2D Initialise plans
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -16,6 +16,6 @@
 % You should have received a copy of the GNU General Public License along with
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-function f = nfft_get_f(p)
+function p = nfst_init_2d(N1,N2,M)
 
-f = nfftmex('get_f',p);
+p = nfstmex('init_2d',N1,N2,M);
diff --git a/matlab/nfft/nfft_get_f.m b/matlab/nfst/nfst_init_3d.m
similarity index 75%
copy from matlab/nfft/nfft_get_f.m
copy to matlab/nfst/nfst_init_3d.m
index 02aed96..799c986 100644
--- a/matlab/nfft/nfft_get_f.m
+++ b/matlab/nfst/nfst_init_3d.m
@@ -1,7 +1,7 @@
-%NFFT_GET_F Get function values from plan
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%NFST_INIT_3D Initialise plans
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -16,6 +16,6 @@
 % You should have received a copy of the GNU General Public License along with
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-function f = nfft_get_f(p)
+function p = nfst_init_3d(N1,N2,N3,M)
 
-f = nfftmex('get_f',p);
+p = nfstmex('init_3d',N1,N2,N3,M);
diff --git a/matlab/nfft/nfft_init_guru.m b/matlab/nfst/nfst_init_guru.m
similarity index 77%
copy from matlab/nfft/nfft_init_guru.m
copy to matlab/nfst/nfst_init_guru.m
index 65806d7..7a25edf 100644
--- a/matlab/nfft/nfft_init_guru.m
+++ b/matlab/nfst/nfst_init_guru.m
@@ -1,7 +1,7 @@
-%NFFT_INIT_GURU Initialise plans, no error handling
+%NFST_INIT_GURU Initialise plans, no error handling
 %   Matlab might run into a segmentation violation for wrong parameters
 %
-%   nfft_init_guru(d,N1,...,Nd,M,n1,...,nd,m,flags,fftw_flags)
+%   nfst_init_guru(d,N1,...,Nd,M,n1,...,nd,m,flags,fftw_flags)
 %
 %   d            spatial dimension
 %   N1,...,Nd    bandwidths
@@ -12,9 +12,9 @@
 %	             PRE_FULL_PSI} | FFT_OUT_OF_PLACE
 %   fftw_flags   {FFTW_ESTIMATE, FFTW_MEASURE}
 %
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -29,6 +29,6 @@
 % You should have received a copy of the GNU General Public License along with
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-function p = nfft_init_guru(varargin)
+function p = nfst_init_guru(varargin)
 
-p = nfftmex('init_guru',varargin);
+p = nfstmex('init_guru',varargin);
diff --git a/matlab/nfft/nfft_set_f.m b/matlab/nfst/nfst_set_f.m
similarity index 77%
copy from matlab/nfft/nfft_set_f.m
copy to matlab/nfst/nfst_set_f.m
index ada43fc..f83ad1b 100644
--- a/matlab/nfft/nfft_set_f.m
+++ b/matlab/nfst/nfst_set_f.m
@@ -1,7 +1,7 @@
-%NFFT_SET_F Set function values in plan
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%NFST_SET_F Set function values in plan
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -16,6 +16,6 @@
 % You should have received a copy of the GNU General Public License along with
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-function nfft_set_f(p,f)
+function nfst_set_f(p,f)
 
-nfftmex('set_f',p,f)
+nfstmex('set_f',p,f)
diff --git a/matlab/nfft/nfft_adjoint.m b/matlab/nfst/nfst_set_f_hat.m
similarity index 75%
copy from matlab/nfft/nfft_adjoint.m
copy to matlab/nfst/nfst_set_f_hat.m
index 3272b5d..fefb6a9 100644
--- a/matlab/nfft/nfft_adjoint.m
+++ b/matlab/nfst/nfst_set_f_hat.m
@@ -1,7 +1,7 @@
-%NFFT_ADJOINT Adjoint nonequispaced fast Fourier transform
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%NFST_SET_F_HAT Set Fourier coefficients in plan
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -16,6 +16,6 @@
 % You should have received a copy of the GNU General Public License along with
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-function nfft_adjoint(p)
+function nfst_set_f_hat(p,f_hat)
 
-nfftmex('adjoint',p)
+nfstmex('set_f_hat',p,f_hat)
diff --git a/matlab/nfft/nfft_set_x.m b/matlab/nfst/nfst_set_x.m
similarity index 77%
copy from matlab/nfft/nfft_set_x.m
copy to matlab/nfst/nfst_set_x.m
index 997620e..ece18cc 100644
--- a/matlab/nfft/nfft_set_x.m
+++ b/matlab/nfst/nfst_set_x.m
@@ -1,7 +1,7 @@
-%NFFT_SET_X Set nodes in plan
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%NFST_SET_X Set nodes in plan
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -16,6 +16,6 @@
 % You should have received a copy of the GNU General Public License along with
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-function nfft_set_x(p,x)
+function nfst_set_x(p,x)
 
-nfftmex('set_x',p,x)
+nfstmex('set_x',p,x)
diff --git a/matlab/nfft/nfft_set_f.m b/matlab/nfst/nfst_trafo.m
similarity index 76%
copy from matlab/nfft/nfft_set_f.m
copy to matlab/nfst/nfst_trafo.m
index ada43fc..38bb9ef 100644
--- a/matlab/nfft/nfft_set_f.m
+++ b/matlab/nfst/nfst_trafo.m
@@ -1,7 +1,7 @@
-%NFFT_SET_F Set function values in plan
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%NFST_TRAFO nonequispaced fast sine transform
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -16,6 +16,6 @@
 % You should have received a copy of the GNU General Public License along with
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-function nfft_set_f(p,f)
+function nfst_trafo(p)
 
-nfftmex('set_f',p,f)
+nfstmex('trafo',p)
diff --git a/matlab/nfft/nfftmex.c b/matlab/nfst/nfstmex.c
similarity index 66%
copy from matlab/nfft/nfftmex.c
copy to matlab/nfst/nfstmex.c
index bde8cb3..48d9fdc 100644
--- a/matlab/nfft/nfftmex.c
+++ b/matlab/nfst/nfstmex.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
@@ -31,66 +31,67 @@
   #include "mexversion.c"
 #endif
 
-#define PLANS_MAX 100 /* maximum number of plans */
+#define PLANS_START 10 /* initial number of plans */
 #define CMD_LEN_MAX 20 /* maximum length of command argument */
 
 /* global flags */
-#define NFFT_MEX_FIRST_CALL (1U << 0)
-unsigned short gflags = NFFT_MEX_FIRST_CALL;
+#define NFST_MEX_FIRST_CALL (1U << 0)
+static unsigned short gflags = NFST_MEX_FIRST_CALL;
 
-nfft_plan* plans[PLANS_MAX]; /* plans */
-char cmd[CMD_LEN_MAX];
+static nfst_plan** plans = NULL; /* plans */
+static unsigned int plans_num_allocated = 0;
+static char cmd[CMD_LEN_MAX];
 
 static inline void get_nm(const mxArray *prhs[], int *n, int *m)
 {
-  int t = nfft_mex_get_int(prhs[1],"nfft: Input argument N must be a scalar.");
+  int t = nfft_mex_get_int(prhs[1],"nfst: Input argument N must be a scalar.");
   DM(if ((t < 0) || (t%2!=0))
-    mexErrMsgTxt("nfft: Input argument N must be non-negative and multiple of two.");)
+    mexErrMsgTxt("nfst: Input argument N must be non-negative and multiple of two.");)
   *n = t;
-  t = nfft_mex_get_int(prhs[2],"nfft: Input argument M must be a scalar.");
+  t = nfft_mex_get_int(prhs[2],"nfst: Input argument M must be a scalar.");
   DM(if (t < 1)
-    mexErrMsgTxt("nfft: Input argument M must be positive.");)
+    mexErrMsgTxt("nfst: Input argument M must be positive.");)
   *m = t;
 }
 
 static inline void get_n1n2m(const mxArray *prhs[], int *n1, int *n2, int *m)
 {
-  int t = nfft_mex_get_int(prhs[1],"nfft: Input argument N1 must be a scalar.");
+  int t = nfft_mex_get_int(prhs[1],"nfst: Input argument N1 must be a scalar.");
   DM(if ((t < 0) || (t%2!=0))
-    mexErrMsgTxt("nfft: Input argument N1 must be non-negative and even.");)
+    mexErrMsgTxt("nfst: Input argument N1 must be non-negative and even.");)
   *n1 = t;
 
-  t = nfft_mex_get_int(prhs[2],"nfft: Input argument N2 must be a scalar.");
+  t = nfft_mex_get_int(prhs[2],"nfst: Input argument N2 must be a scalar.");
   DM(if ((t < 0) || (t%2!=0))
-    mexErrMsgTxt("nfft: Input argument N2 must be non-negative and even.");)
+    mexErrMsgTxt("nfst: Input argument N2 must be non-negative and even.");)
   *n2 = t;
 
-  t = nfft_mex_get_int(prhs[3],"nfft: Input argument M must be a scalar.");
+  t = nfft_mex_get_int(prhs[3],"nfst: Input argument M must be a scalar.");
   DM(if (t < 1)
-    mexErrMsgTxt("nfft: Input argument M must be positive.");)
+    mexErrMsgTxt("nfst: Input argument M must be positive.");)
   *m = t;
 }
 
 static inline void get_n1n2n3m(const mxArray *prhs[], int *n1, int *n2, int *n3, int *m)
 {
-  int t = nfft_mex_get_int(prhs[1],"nfft: Input argument N1 must be a scalar.");
+  int t = nfft_mex_get_int(prhs[1],"nfst: Input argument N1 must be a scalar.");
   DM(if ((t < 0) || (t%2!=0))
-    mexErrMsgTxt("nfft: Input argument N1 must be non-negative and even.");)
+    mexErrMsgTxt("nfst: Input argument N1 must be non-negative and even.");)
   *n1 = t;
 
-  t = nfft_mex_get_int(prhs[2],"nfft: Input argument N2 must be a scalar.");
+  t = nfft_mex_get_int(prhs[2],"nfst: Input argument N2 must be a scalar.");
   DM(if ((t < 0) || (t%2!=0))
-    mexErrMsgTxt("nfft: Input argument N2 must be non-negative and even.");)
+    mexErrMsgTxt("nfst: Input argument N2 must be non-negative and even.");)
   *n2 = t;
 
-  t = nfft_mex_get_int(prhs[3],"nfft: Input argument N3 must be a scalar.");
+  t = nfft_mex_get_int(prhs[3],"nfst: Input argument N3 must be a scalar.");
   DM(if ((t < 0) || (t%2!=0))
-    mexErrMsgTxt("nfft: Input argument N3 must be non-negative and even.");)
+    mexErrMsgTxt("nfst: Input argument N3 must be non-negative and even.");)
   *n3 = t;
 
-  t = nfft_mex_get_int(prhs[4],"nfft: Input argument M must be a scalar.");
+  t = nfft_mex_get_int(prhs[4],"nfst: Input argument M must be a scalar.");
   DM(if (t < 1)
-    mexErrMsgTxt("nfft: Input argument M must be positive.");)
+    mexErrMsgTxt("nfst: Input argument M must be positive.");)
   *m = t;
 }
 
@@ -122,20 +123,32 @@ static inline void check_nargs(const int nrhs, const int n, const char* errmsg)
 
 static inline void check_plan(int i)
 {
-  DM(if (i < 0 || i >= PLANS_MAX)
-    mexErrMsgTxt("Invalid plan");)
-  DM(if (plans[i] == 0)
+  DM(if (i < 0 || i >= plans_num_allocated || plans[i] == 0)
     mexErrMsgTxt("Plan was not initialized or has already been finalized");)
 }
 
 static inline int mkplan(void)
 {
-  mexLock();
   int i = 0;
-  while (i < PLANS_MAX && plans[i] != 0) i++;
-  if (i == PLANS_MAX)
-    mexErrMsgTxt("nfft: Too many plans already allocated.");
-  plans[i] = nfft_malloc(sizeof(nfft_plan));
+  while (i < plans_num_allocated && plans[i] != 0) i++;
+  if (i == plans_num_allocated)
+  {
+    int l;
+
+    if (plans_num_allocated >= INT_MAX - PLANS_START - 1)
+      mexErrMsgTxt("nsft: Too many plans already allocated.");
+
+    nfst_plan** plans_old = plans;
+    plans = nfft_malloc((plans_num_allocated+PLANS_START)*sizeof(nfst_plan*));
+    for (l = 0; l < plans_num_allocated; l++)
+      plans[l] = plans_old[l];
+    for (l = plans_num_allocated; l < plans_num_allocated+PLANS_START; l++)
+      plans[l] = 0;
+    if (plans_num_allocated > 0)
+      nfft_free(plans_old);
+    plans_num_allocated += PLANS_START;
+  }
+  plans[i] = nfft_malloc(sizeof(nfst_plan));
   return i;
 }
 
@@ -144,23 +157,29 @@ static void cleanup(void)
 {
   int i;
 
-  mexUnlock();
-
-  if (!(gflags & NFFT_MEX_FIRST_CALL))
+  if (!(gflags & NFST_MEX_FIRST_CALL))
   {
-    for (i = 0; i < PLANS_MAX; i++)
+    for (i = 0; i < plans_num_allocated; i++)
       if (plans[i])
       {
-        nfft_finalize(plans[i]);
-        plans[i] = 0;
+        nfst_finalize(plans[i]);
+	nfft_free(plans[i]);
+        plans[i] = NULL;
       }
-    gflags |= NFFT_MEX_FIRST_CALL;
+
+    if (plans_num_allocated > 0)
+    {
+      nfft_free(plans);
+      plans = NULL;
+      plans_num_allocated = 0;
+    }
+    gflags |= NFST_MEX_FIRST_CALL;
   }
 }
 
 void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
 {
-  if (gflags & NFFT_MEX_FIRST_CALL)
+  if (gflags & NFST_MEX_FIRST_CALL)
   {
     /* Force Matlab to load libfftw3. There is at least one version of Matlab
      * which otherwise crashes upon invocation of this mex function. */
@@ -168,15 +187,8 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
 
     nfft_mex_install_mem_hooks();
 
-    /* plan pointers to zeros */
-    {
-      int i;
-      for (i = 0; i < PLANS_MAX; i++)
-        plans[i] = 0;
-    }
-
     mexAtExit(cleanup);
-    gflags &= ~NFFT_MEX_FIRST_CALL;
+    gflags &= ~NFST_MEX_FIRST_CALL;
   }
 
   /* command string */
@@ -197,7 +209,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
       int n, m;
       get_nm(prhs,&n,&m);
       i = mkplan();
-      nfft_init_1d(plans[i],n,m);
+      nfst_init_1d(plans[i],n,m);
       plhs[0] = mxCreateDoubleScalar((double)i);
     }
     return;
@@ -210,7 +222,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
       int n1, n2, m;
       get_n1n2m(prhs,&n1,&n2,&m);
       i = mkplan();
-      nfft_init_2d(plans[i],n1,n2,m);
+      nfst_init_2d(plans[i],n1,n2,m);
       plhs[0] = mxCreateDoubleScalar((double)i);
     }
     return;
@@ -223,7 +235,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
       int n1, n2, n3, m;
       get_n1n2n3m(prhs,&n1,&n2,&n3,&m);
       i = mkplan();
-      nfft_init_3d(plans[i],n1,n2,n3,m);
+      nfst_init_3d(plans[i],n1,n2,n3,m);
       plhs[0] = mxCreateDoubleScalar((double)i);
     }
     return;
@@ -238,11 +250,11 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
     unsigned int f1,f2;
 
     DM(if ((d < 1) || (d>4)) 
-	 mexErrMsgTxt("nfft: Input argument d must be positive and smaller than 5.");)
+	 mexErrMsgTxt("nfst: Input argument d must be positive and smaller than 5.");)
 
     get_guru(prhs,d,N,&M,n,&m,&f1,&f2);
     i = mkplan();
-    nfft_init_guru(plans[i],d,N,M,n,m,
+    nfst_init_guru(plans[i],d,N,M,n,m,
 		   f1 | MALLOC_X | MALLOC_F | MALLOC_F_HAT | FFTW_INIT,
 		   f2);
 
@@ -252,21 +264,23 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
   }
   else if (strcmp(cmd,"precompute_psi") == 0)
   {
-    check_nargs(nrhs,2,"Wrong number of arguments for precompute_one_psi.");
+    mexErrMsgTxt("not implemented, precompute_psi is already called in set_x");
+/*    check_nargs(nrhs,2,"Wrong number of arguments for precompute_psi.");
     {
-      int i = nfft_mex_get_int(prhs[1],"nfft: Input argument plan must be a scalar.");
+      int i = nfft_mex_get_int(prhs[1],"nfst: Input argument plan must be a scalar.");
       check_plan(i);
-      nfft_precompute_one_psi(plans[i]);
+      nfst_precompute_one_psi(plans[i]);
     }
+*/
     return;
   }
   else if (strcmp(cmd,"trafo") == 0)
   {
     check_nargs(nrhs,2,"Wrong number of arguments for trafo.");
     {
-      int i = nfft_mex_get_int(prhs[1],"nfft: Input argument plan must be a scalar.");
+      int i = nfft_mex_get_int(prhs[1],"nfst: Input argument plan must be a scalar.");
       check_plan(i);
-      nfft_trafo(plans[i]);
+      nfst_trafo(plans[i]);
     }
     return;
   }
@@ -274,9 +288,9 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
   {
     check_nargs(nrhs,2,"Wrong number of arguments for adjoint.");
     {
-      int i = nfft_mex_get_int(prhs[1],"nfft: Input argument plan must be a scalar.");
+      int i = nfft_mex_get_int(prhs[1],"nfst: Input argument plan must be a scalar.");
       check_plan(i);
-      nfft_adjoint(plans[i]);
+      nfst_adjoint(plans[i]);
     }
     return;
   }
@@ -284,9 +298,9 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
   {
     check_nargs(nrhs,2,"Wrong number of arguments for finalize.");
     {
-      int i = nfft_mex_get_int(prhs[1],"nfft: Input argument plan must be a scalar.");
+      int i = nfft_mex_get_int(prhs[1],"nfst: Input argument plan must be a scalar.");
       check_plan(i);
-      nfft_finalize(plans[i]);
+      nfst_finalize(plans[i]);
       nfft_free(plans[i]);
       plans[i] = 0;
     }
@@ -296,9 +310,9 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
   {
     check_nargs(nrhs,2,"Wrong number of arguments for trafo direct.");
     {
-      int i = nfft_mex_get_int(prhs[1],"nfft: Input argument plan must be a scalar.");
+      int i = nfft_mex_get_int(prhs[1],"nfst: Input argument plan must be a scalar.");
       check_plan(i);
-      nfft_trafo_direct(plans[i]);
+      nfst_trafo_direct(plans[i]);
     }
     return;
   }
@@ -306,9 +320,9 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
   {
     check_nargs(nrhs,2,"Wrong number of arguments for adjoint direct.");
     {
-      int i = nfft_mex_get_int(prhs[1],"nfft: Input argument plan must be a scalar.");
+      int i = nfft_mex_get_int(prhs[1],"nfst: Input argument plan must be a scalar.");
       check_plan(i);
-      nfft_adjoint_direct(plans[i]);
+      nfst_adjoint_direct(plans[i]);
     }
     return;
   }
@@ -316,7 +330,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
   {
     check_nargs(nrhs,2,"Wrong number of arguments for get_x.");
     {
-      int i = nfft_mex_get_int(prhs[1],"nfft: Input argument plan must be a scalar.");
+      int i = nfft_mex_get_int(prhs[1],"nfst: Input argument plan must be a scalar.");
       int m, d;
       check_plan(i);
       m = plans[i]->M_total;
@@ -336,18 +350,17 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
   {
     check_nargs(nrhs,2,"Wrong number of arguments for get_f.");
     {
-      int i = nfft_mex_get_int(prhs[1],"nfft: Input argument plan must be a scalar.");
+      int i = nfft_mex_get_int(prhs[1],"nfst: Input argument plan must be a scalar.");
       int m;
       check_plan(i);
       m = plans[i]->M_total;
-      plhs[0] = mxCreateDoubleMatrix((unsigned int)m, 1, mxCOMPLEX);
+      plhs[0] = mxCreateDoubleMatrix((unsigned int)m, 1, mxREAL);
       {
-        double *fr = mxGetPr(plhs[0]), *fi = mxGetPi(plhs[0]);
+        double *fr = mxGetPr(plhs[0]);
         int j;
         for (j = 0; j < m; j++)
         {
-          fr[j] = creal(plans[i]->f[j]);
-          fi[j] = cimag(plans[i]->f[j]);
+          fr[j] = plans[i]->f[j];
         }
       }
     }
@@ -357,18 +370,17 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
   {
     check_nargs(nrhs,2,"Wrong number of arguments for get_f_hat.");
     {
-      int i = nfft_mex_get_int(prhs[1],"nfft: Input argument plan must be a scalar.");
+      int i = nfft_mex_get_int(prhs[1],"nfst: Input argument plan must be a scalar.");
       int n;
       check_plan(i);
       n = plans[i]->N_total;
-      plhs[0] = mxCreateDoubleMatrix((unsigned int)n, 1, mxCOMPLEX);
+      plhs[0] = mxCreateDoubleMatrix((unsigned int)n, 1, mxREAL);
       {
-        double *f_hatr = mxGetPr(plhs[0]), *f_hati = mxGetPi(plhs[0]);
+        double *f_hatr = mxGetPr(plhs[0]);
         int k;
         for (k = 0; k < n; k++)
         {
-          f_hatr[k] = creal(plans[i]->f_hat[k]);
-          f_hati[k] = cimag(plans[i]->f_hat[k]);
+          f_hatr[k] = plans[i]->f_hat[k];
         }
       }
     }
@@ -378,7 +390,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
   {
     check_nargs(nrhs,3,"Wrong number of arguments for set_x.");
     {
-      int i = nfft_mex_get_int(prhs[1],"nfft: Input argument plan must be a scalar.");
+      int i = nfft_mex_get_int(prhs[1],"nfst: Input argument plan must be a scalar.");
       int m, d;
       check_plan(i);
       m = plans[i]->M_total;
@@ -392,8 +404,13 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
         int j,t;
         for (j = 0; j < m; j++)
 	  for (t = 0; t < d; t++)
+	  {
+	    DM(if (x[d*j+t] < 0.0 || x[d*j+t] > 0.5)
+	      mexErrMsgTxt("Node coordinates must be within interval [0,0.5]");)
 	    plans[i]->x[d*j+t] = x[d*j+t];
+	  }
       }
+      nfst_precompute_one_psi(plans[i]);
     }
     return;
   }
@@ -401,7 +418,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
   {
     check_nargs(nrhs,3,"Wrong number of arguments for set_f.");
     {
-      int i = nfft_mex_get_int(prhs[1],"nfft: Input argument plan must be a scalar.");
+      int i = nfft_mex_get_int(prhs[1],"nfst: Input argument plan must be a scalar.");
       int m;
       check_plan(i);
       m = plans[i]->M_total;
@@ -410,12 +427,10 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
       {
         double *fr = mxGetPr(prhs[2]), *fi = mxGetPi(prhs[2]);
         int j;
-        if (fi)
-          for (j = 0; j < m; j++)
-            plans[i]->f[j] = fr[j] + _Complex_I*fi[j];
-        else
-          for (j = 0; j < m; j++)
-            plans[i]->f[j] = fr[j];
+        DM(if (fi)
+	  mexErrMsgTxt("Input argument f must be a double vector");)
+        for (j = 0; j < m; j++)
+          plans[i]->f[j] = fr[j];
       }
     }
     return;
@@ -424,7 +439,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
   {
     check_nargs(nrhs,3,"Wrong number of arguments for set_f_hat.");
     {
-      int i = nfft_mex_get_int(prhs[1],"nfft: Input argument plan must be a scalar.");
+      int i = nfft_mex_get_int(prhs[1],"nfst: Input argument plan must be a scalar.");
       int n;
       check_plan(i);
       n = plans[i]->N_total;
@@ -435,12 +450,10 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
       {
         double *f_hatr = mxGetPr(prhs[2]), *f_hati = mxGetPi(prhs[2]);
         int k;
-        if (f_hati)
-          for (k = 0; k < n; k++)
-            plans[i]->f_hat[k] = f_hatr[k] + _Complex_I*f_hati[k];
-        else
-          for (k = 0; k < n; k++)
-            plans[i]->f_hat[k] = f_hatr[k];
+        DM(if (f_hati)
+	  mexErrMsgTxt("Input argument f_hat must be a double vector");)
+        for (k = 0; k < n; k++)
+          plans[i]->f_hat[k] = f_hatr[k];
       }
     }
     return;
@@ -449,7 +462,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
   {
     check_nargs(nrhs,2,"Wrong number of arguments for set_f_hat_linear.");
     {
-      int i = nfft_mex_get_int(prhs[1],"nfft: Input argument plan must be a scalar.");
+      int i = nfft_mex_get_int(prhs[1],"nfst: Input argument plan must be a scalar.");
       mexPrintf("Plan %d\n",i);
       check_plan(i);
       mexPrintf("  pointer: %p\n",plans[i]);
@@ -472,5 +485,5 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
     return;
   }
   else
-    mexErrMsgTxt("nfft: Unknown command.\n");
+    mexErrMsgTxt("nfst: Unknown command.\n");
 }
diff --git a/matlab/nnfft/simple_test.m b/matlab/nfst/simple_test.m
similarity index 52%
copy from matlab/nnfft/simple_test.m
copy to matlab/nfst/simple_test.m
index 96ef23b..27ffb95 100644
--- a/matlab/nnfft/simple_test.m
+++ b/matlab/nfst/simple_test.m
@@ -1,8 +1,8 @@
 %SIMPLE_TEST Example program: Basic usage principles
 %
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -18,68 +18,56 @@
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 %
-disp(sprintf('Number of threads: %d\n', nnfft_get_num_threads()));
+fprintf('Number of threads: %d\n', nfst_get_num_threads());
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 disp('A simple one dimensional example');
 
 % maximum degree (bandwidth)
-N = 8;
-%N1=sigma*N;
-N_total=3;
+N = 14;
+
 % number of nodes
-M = 17;
- 
+M = 19;
+
 % nodes
-x=rand(1,M)-0.5;
-%xi=N*(rand(1,N)-0.5);
-v=rand(1,N_total)-0.5;
+x=0.5*rand(1,M);
 
 % Create plan.
-%plan=nnfft_init(1,N_total,M,N);
-plan=nnfft_init_guru(1,N_total,M,N,2*N,6,bitor(PRE_PSI,PRE_PHI_HUT));
+plan = nfst_init_1d(N,M);
 
 % Set nodes.
-nnfft_set_x(plan,x);
-nnfft_set_v(plan,v);
-
+nfst_set_x(plan,x);
 
 % node-dependent precomputation
-nnfft_precompute_psi(plan);
+%nfst_precompute_psi(plan);
 
 % Fourier coefficients
-f_hat = rand(N_total,1)+i*rand(N_total,1);
+f_hat = rand(N-1,1);
 
 % Set Fourier coefficients.
-nnfft_set_f_hat(plan,double(f_hat));
+nfst_set_f_hat(plan,double(f_hat));
 
 % transform
-nnfft_trafo(plan);
+nfst_trafo(plan);
 
 % function values
-f = nnfft_get_f(plan)
-
-% finalize plan
-%nnfft_finalize(plan);
+f = nfst_get_f(plan);
 
+nfst_adjoint(plan);
 
-%%%%%%%%%%%%%%%%%%%%%
+f_hat_adjoint = nfst_get_f_hat(plan);
 
-nnfft_trafo_direct(plan);
-f2=nnfft_get_f(plan)
 % finalize plan
-nnfft_finalize(plan);
-%%%%%%%%%%%%%%%%%%%%%%%
-
-%A=exp(-2*pi*i*x'*(-N_total/2:N_total/2-1));
-A=exp(-2*pi*1i*x'*N*v);
-f3=A*f_hat
+nfst_finalize(plan);
 
-disp('NNFFT vs NNDFT');
-error_vector=f-f2;
-error_linfl1=norm(f-f2,inf)/norm(f_hat,1)
+A=sin(2*pi*x'*(1:N-1));
+f2 = A*f_hat;
 
-disp('NNFFT vs Direct');
-error_vector=f-f3;
-error_linfl1=norm(f-f3,inf)/norm(f_hat,1)
+f_hat_adjoint2 = A'*f;
 
+error_vector = f-f2;
+error_linfl1 = norm(f-f2,inf)/norm(f_hat,1);
+fprintf('error trafo: %.1e\n', error_linfl1);
 
+error_vector_adjoint = f_hat_adjoint-f_hat_adjoint2;
+error_linfl1_adjoint = norm(f_hat_adjoint-f_hat_adjoint2,inf)/norm(f,1);
+fprintf('error adjoint: %.1e\n', error_linfl1_adjoint);
diff --git a/matlab/nfft/test_nfft1d.m b/matlab/nfst/test_nfst1d.m
similarity index 61%
copy from matlab/nfft/test_nfft1d.m
copy to matlab/nfst/test_nfst1d.m
index 173210d..42fbe07 100644
--- a/matlab/nfft/test_nfft1d.m
+++ b/matlab/nfst/test_nfst1d.m
@@ -1,5 +1,4 @@
-
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -15,54 +14,54 @@
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
-% Test script of class nfft for spatial dimension d=1.
+% Test script of class nfst for spatial dimension d=1.
 clear all;
 
 M=16; % number of nodes
 N=24; % number of Fourier coefficients in first direction
 
-x=rand(M,1)-0.5; %nodes
+x=0.5*rand(M,1); %nodes
 
 % Initialisation
-plan=nfft(1,N,M); % create plan of class type nfft
+plan=nfst(1,N,M); % create plan of class type nfst
 %n=2^(ceil(log(N)/log(2))+1);
-%plan=nfft(1,N,M,n,7,bitor(PRE_PHI_HUT,PRE_PSI),FFTW_MEASURE); % use of nfft_init_guru
+%plan=nfst(1,N,M,n,7,bitor(PRE_PHI_HUT,PRE_PSI),FFTW_MEASURE); % use of nfst_init_guru
 
 plan.x=x; % set nodes in plan
-nfft_precompute_psi(plan); % precomputations
+%nfst_precompute_psi(plan); % precomputations
 
-% NFFT %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% NFCT %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-fhat=rand(N,1); % Fourier coefficients
+fhat=rand(N-1,1); % Fourier coefficients
 fhatv=fhat(:);
 
-% Compute samples with NFFT
+% Compute samples with NFCT
 plan.fhat=fhatv; % set Fourier coefficients
-nfft_trafo(plan); % compute nonequispaced Fourier transform
+nfst_trafo(plan); % compute nonequispaced Fourier transform
 f1=plan.f; % get samples
 
 % Compute samples direct
-k1=(-N/2:N/2-1).';
+k1=(1:N-1).';
 f2=zeros(M,1);
 for j=1:M
 	x1j=x(j,1);
-	f2(j)=sum( fhatv.*exp(-2*pi*1i*k1*x1j) );
+	f2(j)=sum( fhatv.*sin(2*pi*k1*x1j) );
 end %for
 
 % Compare results
 max(abs(f1-f2))
 
-% Adjoint NFFT %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Adjoint NFCT %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-% Computation with NFFT
-nfft_adjoint(plan);
+% Computation with NFCT
+nfst_adjoint(plan);
 fhat1=plan.fhat;
 
 % Direct computation
-fhat2=zeros(N,1);
-for j=1:N
+fhat2=zeros(N-1,1);
+for j=1:N-1
 	k1j=k1(j);
-	fhat2(j)=sum( plan.f.*exp(2*pi*1i*k1j*x(:,1)) );
+	fhat2(j)=sum( plan.f.*sin(2*pi*k1j*x(:,1)) );
 end %for
 
 % Compare results
diff --git a/matlab/nfft/test_nfft2d.m b/matlab/nfst/test_nfst2d.m
similarity index 61%
copy from matlab/nfft/test_nfft2d.m
copy to matlab/nfst/test_nfst2d.m
index 962d873..962aec9 100644
--- a/matlab/nfft/test_nfft2d.m
+++ b/matlab/nfst/test_nfst2d.m
@@ -1,5 +1,5 @@
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -15,7 +15,7 @@
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
-% Test script of class nfft for spatial dimension d=2.
+% Test script of class nfst for spatial dimension d=2.
 clear all;
 
 M=16; % number of nodes
@@ -23,29 +23,29 @@ N1=24; % number of Fourier coefficients in first direction
 N2=32; % number of Fourier coefficients in second direction
 N=[N1;N2];
 
-x=rand(M,2)-0.5; %nodes
+x=0.5*rand(M,2); %nodes
 
 % Initialisation
-plan=nfft(2,N,M); % create plan of class type nfft
+plan=nfst(2,N,M); % create plan of class type nfst
 %n=2^(ceil(log(max(N))/log(2))+1);
-%plan=nfft(2,N,M,n,n,7,bitor(PRE_PHI_HUT,bitor(PRE_PSI,NFFT_OMP_BLOCKWISE_ADJOINT)),FFTW_MEASURE); % use of nfft_init_guru
+%plan=nfst(2,N,M,n,n,7,bitor(PRE_PHI_HUT,bitor(PRE_PSI,NFFT_OMP_BLOCKWISE_ADJOINT)),FFTW_MEASURE); % use of nfst_init_guru
 
 plan.x=x; % set nodes in plan
-nfft_precompute_psi(plan); % precomputations
+%nfst_precompute_psi(plan); % precomputations
 
-% NFFT %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% NFCT %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-fhat=rand(N1,N2); % Fourier coefficients
+fhat=rand(N1-1,N2-1); % Fourier coefficients
 fhatv=fhat(:);
 
-% Compute samples with NFFT
+% Compute samples with NFCT
 plan.fhat=fhatv; % set Fourier coefficients
-nfft_trafo(plan); % compute nonequispaced Fourier transform
+nfst_trafo(plan); % compute nonequispaced Fourier transform
 f1=plan.f; % get samples
 
 % Compute samples direct
-k1=-N1/2:N1/2-1;
-k2=-N2/2:N2/2-1;
+k1=1:N1-1;
+k2=1:N2-1;
 [K1,K2]=ndgrid(k1,k2);
 k1=K1(:); clear K1;
 k2=K2(:); clear K2;
@@ -53,24 +53,24 @@ f2=zeros(M,1);
 for j=1:M
 	x1j=x(j,1);
 	x2j=x(j,2);
-	f2(j)=sum( fhatv.*exp(-2*pi*1i*(k1*x1j+k2*x2j)) );
+	f2(j)=sum( fhatv.*sin(2*pi*k1*x1j).*sin(2*pi*k2*x2j) );
 end %for
 
 % Compare results
 max(abs(f1-f2))
 
-% Adjoint NFFT %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Adjoint NFCT %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-% Computation with NFFT
-nfft_adjoint(plan);
+% Computation with NFCT
+nfst_adjoint(plan);
 fhat1=plan.fhat;
 
 % Direct computation
-fhat2=zeros(N1*N2,1);
-for j=1:N1*N2
+fhat2=zeros((N1-1)*(N2-1),1);
+for j=1:(N1-1)*(N2-1)
 	k1j=k1(j);
 	k2j=k2(j);
-	fhat2(j)=sum( plan.f.*exp(2*pi*1i*(k1j*x(:,1)+k2j*x(:,2))) );
+	fhat2(j)=sum( plan.f.*sin(2*pi*k1j*x(:,1)).*sin(2*pi*k2j*x(:,2)) );
 end %for
 
 % Compare results
diff --git a/matlab/nfft/test_nfft3d.m b/matlab/nfst/test_nfst3d.m
similarity index 61%
copy from matlab/nfft/test_nfft3d.m
copy to matlab/nfst/test_nfst3d.m
index c97eee9..127416b 100644
--- a/matlab/nfft/test_nfft3d.m
+++ b/matlab/nfst/test_nfst3d.m
@@ -1,5 +1,5 @@
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -15,7 +15,7 @@
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
-% Test script of class nfft for spatial dimension d=3.
+% Test script of class nfst for spatial dimension d=3.
 clear all;
 
 M=16; % number of nodes
@@ -24,30 +24,30 @@ N2=32; % number of Fourier coefficients in second direction
 N3=30; % number of Fourier coefficients in third direction
 N=[N1;N2;N3];
 
-x=rand(M,3)-0.5; %nodes
+x=0.5*rand(M,3); %nodes
 
 % Initialisation
-plan=nfft(3,N,M); % create plan of class type nfft
+plan=nfst(3,N,M); % create plan of class type nfst
 %n=2^(ceil(log(max(N))/log(2))+1);
-%plan=nfft(3,N,M,n,n,n,7,bitor(PRE_PHI_HUT,bitor(PRE_PSI,NFFT_OMP_BLOCKWISE_ADJOINT)),FFTW_MEASURE); % use of nfft_init_guru
+%plan=nfst(3,N,M,n,n,n,7,bitor(PRE_PHI_HUT,bitor(PRE_PSI,NFFT_OMP_BLOCKWISE_ADJOINT)),FFTW_MEASURE); % use of nfst_init_guru
 
 plan.x=x; % set nodes in plan
-nfft_precompute_psi(plan); % precomputations
+%nfst_precompute_psi(plan); % precomputations
 
-% NFFT %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% NFCT %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-fhat=rand(N1,N2,N3); % Fourier coefficients
+fhat=rand(N1-1,N2-1,N3-1); % Fourier coefficients
 fhatv=fhat(:);
 
-% Compute samples with NFFT
+% Compute samples with NFCT
 plan.fhat=fhatv; % set Fourier coefficients
-nfft_trafo(plan); % compute nonequispaced Fourier transform
+nfst_trafo(plan); % compute nonequispaced Fourier transform
 f1=plan.f; % get samples
 
 % Compute samples direct
-k1=-N1/2:N1/2-1;
-k2=-N2/2:N2/2-1;
-k3=-N3/2:N3/2-1;
+k1=1:N1-1;
+k2=1:N2-1;
+k3=1:N3-1;
 [K1,K2,K3]=ndgrid(k1,k2,k3);
 k1=K1(:); clear K1;
 k2=K2(:); clear K2;
@@ -57,25 +57,25 @@ for j=1:M
 	x1j=x(j,1);
 	x2j=x(j,2);
 	x3j=x(j,3);
-	f2(j)=sum( fhatv.*exp(-2*pi*1i*(k1*x1j+k2*x2j+k3*x3j)) );
+	f2(j)=sum( fhatv.*sin(2*pi*k1*x1j).*sin(2*pi*k2*x2j).*sin(2*pi*k3*x3j) );
 end %for
 
 % Compare results
 max(abs(f1-f2))
 
-% Adjoint NFFT %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Adjoint NFCT %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-% Computation with NFFT
-nfft_adjoint(plan);
+% Computation with NFCT
+nfst_adjoint(plan);
 fhat1=plan.fhat;
 
 % Direct computation
-fhat2=zeros(N1*N2*N3,1);
-for j=1:N1*N2*N3
+fhat2=zeros((N1-1)*(N2-1)*(N3-1),1);
+for j=1:(N1-1)*(N2-1)*(N3-1)
 	k1j=k1(j);
 	k2j=k2(j);
 	k3j=k3(j);
-	fhat2(j)=sum( plan.f.*exp(2*pi*1i*(k1j*x(:,1)+k2j*x(:,2)+k3j*x(:,3))) );
+	fhat2(j)=sum( plan.f.*sin(2*pi*k1j*x(:,1)).*sin(2*pi*k2j*x(:,2)).*sin(2*pi*k3j*x(:,3)) );
 end %for
 
 % Compare results
diff --git a/matlab/nnfft/PRE_FULL_PSI.m b/matlab/nnfft/PRE_FULL_PSI.m
index ad6761e..b2b403f 100644
--- a/matlab/nnfft/PRE_FULL_PSI.m
+++ b/matlab/nnfft/PRE_FULL_PSI.m
@@ -3,9 +3,9 @@
 %   matrix B) uses (2m+2)^dM precomputed values of the window function, in
 %   addition indices of source and target vectors are stored.
 %
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nnfft/PRE_LIN_PSI.m b/matlab/nnfft/PRE_LIN_PSI.m
index dfab51c..a139fbf 100644
--- a/matlab/nnfft/PRE_LIN_PSI.m
+++ b/matlab/nnfft/PRE_LIN_PSI.m
@@ -3,9 +3,9 @@
 %   matrix B) uses linear interpolation from a lookup table of equispaced samples
 %   of the window function instead of exact values of the window function.
 %
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nnfft/PRE_PHI_HUT.m b/matlab/nnfft/PRE_PHI_HUT.m
index a66ae1d..61871d3 100644
--- a/matlab/nnfft/PRE_PHI_HUT.m
+++ b/matlab/nnfft/PRE_PHI_HUT.m
@@ -3,9 +3,9 @@
 %   diagonal matrix D) uses precomputed values of the Fourier transformed window
 %   function.
 %
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nnfft/PRE_PSI.m b/matlab/nnfft/PRE_PSI.m
index 482b8fc..4b93aac 100644
--- a/matlab/nnfft/PRE_PSI.m
+++ b/matlab/nnfft/PRE_PSI.m
@@ -1,9 +1,9 @@
 %PRE_PSI Precomputation flag
 %   If this flag is set, the convolution step (the multiplication with the sparse
 %   matrix B uses (2m+2)dM precomputed values of the window function.
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nnfft/nnfft.m b/matlab/nnfft/nnfft.m
index 750ee2d..fdfcf36 100644
--- a/matlab/nnfft/nnfft.m
+++ b/matlab/nnfft/nnfft.m
@@ -1,5 +1,5 @@
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
@@ -15,7 +15,7 @@
 % this program; if not, write to the Free Software Foundation, Inc., 51
 % Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
-% This class provides robust a Matlab interface to the NFFT library.
+% This class provides a Matlab interface to the NNFFT module.
 %
 % Examples
 %   See Matlab scripts test_nnfft*d.m.
diff --git a/matlab/nnfft/nnfft_display.m b/matlab/nnfft/nnfft_display.m
index 14468f7..ea13dbf 100644
--- a/matlab/nnfft/nnfft_display.m
+++ b/matlab/nnfft/nnfft_display.m
@@ -12,9 +12,9 @@
 %	             PRE_FULL_PSI} | FFT_OUT_OF_PLACE
 %   fftw_flags   {FFTW_ESTIMATE, FFTW_MEASURE}
 %
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nnfft/nnfft_finalize.m b/matlab/nnfft/nnfft_finalize.m
index 2606d9a..b54e6bc 100644
--- a/matlab/nnfft/nnfft_finalize.m
+++ b/matlab/nnfft/nnfft_finalize.m
@@ -1,7 +1,7 @@
 %NFFT_FINALIZE Finalize plan
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nnfft/nnfft_get_f.m b/matlab/nnfft/nnfft_get_f.m
index 391ba59..31f22b3 100644
--- a/matlab/nnfft/nnfft_get_f.m
+++ b/matlab/nnfft/nnfft_get_f.m
@@ -1,7 +1,7 @@
 %NFFT_GET_F Get function values from plan
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nnfft/nnfft_get_f_hat.m b/matlab/nnfft/nnfft_get_f_hat.m
index c5b99ff..0237f00 100644
--- a/matlab/nnfft/nnfft_get_f_hat.m
+++ b/matlab/nnfft/nnfft_get_f_hat.m
@@ -1,7 +1,7 @@
 %NFFT_GET_F_HAT Get Fourier coefficients from plan
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nnfft/nnfft_get_num_threads.m b/matlab/nnfft/nnfft_get_num_threads.m
index a6315db..5c7a3a9 100644
--- a/matlab/nnfft/nnfft_get_num_threads.m
+++ b/matlab/nnfft/nnfft_get_num_threads.m
@@ -1,7 +1,7 @@
 %NFFT_GET_NUM_THREADS Get number of threads (at most) used for computation
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nnfft/nnfft_get_x.m b/matlab/nnfft/nnfft_get_x.m
index 7085dcb..6314ee7 100644
--- a/matlab/nnfft/nnfft_get_x.m
+++ b/matlab/nnfft/nnfft_get_x.m
@@ -1,7 +1,7 @@
 %NFFT_GET_X Get nodes from plan
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nnfft/nnfft_init.m b/matlab/nnfft/nnfft_init.m
index afb7233..f92d836 100644
--- a/matlab/nnfft/nnfft_init.m
+++ b/matlab/nnfft/nnfft_init.m
@@ -1,7 +1,7 @@
 %NFFT_INIT Initialise plans
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nnfft/nnfft_init_1d.m b/matlab/nnfft/nnfft_init_1d.m
index cc143a5..4d333f7 100644
--- a/matlab/nnfft/nnfft_init_1d.m
+++ b/matlab/nnfft/nnfft_init_1d.m
@@ -1,7 +1,7 @@
 %NNFFT_INIT_1D Initialise plans
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nnfft/nnfft_init_2d.m b/matlab/nnfft/nnfft_init_2d.m
index 5fde238..279272c 100644
--- a/matlab/nnfft/nnfft_init_2d.m
+++ b/matlab/nnfft/nnfft_init_2d.m
@@ -1,7 +1,7 @@
 %NNFFT_INIT_2D Initialise plans
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nnfft/nnfft_init_3d.m b/matlab/nnfft/nnfft_init_3d.m
index ac7dfa8..c26e8e7 100644
--- a/matlab/nnfft/nnfft_init_3d.m
+++ b/matlab/nnfft/nnfft_init_3d.m
@@ -1,7 +1,7 @@
 %NNFFT_INIT_3D Initialise plans
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nnfft/nnfft_init_guru.m b/matlab/nnfft/nnfft_init_guru.m
index eb1eb9f..04551e9 100644
--- a/matlab/nnfft/nnfft_init_guru.m
+++ b/matlab/nnfft/nnfft_init_guru.m
@@ -11,9 +11,9 @@
 %   flags   PRE_PHI_HUT | {FG_PSI, PRE_LIN_PSI, PRE_FG_PSI, PRE_PSI,
 %	             PRE_FULL_PSI} | FFT_OUT_OF_PLACE
 %
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nnfft/nnfft_precompute_psi.m b/matlab/nnfft/nnfft_precompute_psi.m
index 873c61d..3527338 100644
--- a/matlab/nnfft/nnfft_precompute_psi.m
+++ b/matlab/nnfft/nnfft_precompute_psi.m
@@ -1,7 +1,7 @@
 %NFFT_PRECOMPUTE_PSI Precompute one psi, dependent on nodes x
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nnfft/nnfft_set_f.m b/matlab/nnfft/nnfft_set_f.m
index 2370cad..4dbe8a0 100644
--- a/matlab/nnfft/nnfft_set_f.m
+++ b/matlab/nnfft/nnfft_set_f.m
@@ -1,7 +1,7 @@
 %NFFT_SET_F Set function values in plan
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nnfft/nnfft_set_f_hat.m b/matlab/nnfft/nnfft_set_f_hat.m
index 149912c..3d70df3 100644
--- a/matlab/nnfft/nnfft_set_f_hat.m
+++ b/matlab/nnfft/nnfft_set_f_hat.m
@@ -1,7 +1,7 @@
 %NFFT_SET_F_HAT Set Fourier coefficients in plan
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nnfft/nnfft_set_v.m b/matlab/nnfft/nnfft_set_v.m
index c3fea09..afc68ba 100644
--- a/matlab/nnfft/nnfft_set_v.m
+++ b/matlab/nnfft/nnfft_set_v.m
@@ -1,8 +1,8 @@
 
 %NFFT_SET_X Set nodes in plan
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nnfft/nnfft_set_x.m b/matlab/nnfft/nnfft_set_x.m
index cc79094..89eed45 100644
--- a/matlab/nnfft/nnfft_set_x.m
+++ b/matlab/nnfft/nnfft_set_x.m
@@ -1,7 +1,7 @@
 %NFFT_SET_X Set nodes in plan
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nnfft/nnfft_trafo.m b/matlab/nnfft/nnfft_trafo.m
index 9ce2bd5..074c722 100644
--- a/matlab/nnfft/nnfft_trafo.m
+++ b/matlab/nnfft/nnfft_trafo.m
@@ -1,7 +1,7 @@
 %NFFT_TRAFO nonequispaced fast Fourier transformat
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nnfft/nnfft_trafo_direct.m b/matlab/nnfft/nnfft_trafo_direct.m
index a38058c..16ca948 100644
--- a/matlab/nnfft/nnfft_trafo_direct.m
+++ b/matlab/nnfft/nnfft_trafo_direct.m
@@ -1,8 +1,8 @@
 
 %NFFT_TRAFO nonequispaced fast Fourier transformat
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nnfft/nnfftmex.c b/matlab/nnfft/nnfftmex.c
index 7c41529..02bcfc5 100644
--- a/matlab/nnfft/nnfftmex.c
+++ b/matlab/nnfft/nnfftmex.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
@@ -31,15 +31,16 @@
   #include "mexversion.c"
 #endif
 
-#define PLANS_MAX 100 /* maximum number of plans */
+#define PLANS_START 10 /* initial number of plans */
 #define CMD_LEN_MAX 20 /* maximum length of command argument */
 
 /* global flags */
 #define NNFFT_MEX_FIRST_CALL (1U << 0)
-unsigned short gflags = NNFFT_MEX_FIRST_CALL;
+static unsigned short gflags = NNFFT_MEX_FIRST_CALL;
 
-nnfft_plan* plans[PLANS_MAX]; /* plans */
-char cmd[CMD_LEN_MAX];
+static nnfft_plan** plans = NULL; /* plans */
+static unsigned int plans_num_allocated = 0;
+static char cmd[CMD_LEN_MAX];
 
 static inline void get_initArg(const mxArray *prhs[], int d,int *N_total, int *M,int *N)
 {
@@ -122,19 +123,31 @@ static inline void check_nargs(const int nrhs, const int n, const char* errmsg)
 
 static inline void check_plan(int i)
 {
-  DM(if (i < 0 || i >= PLANS_MAX)
-    mexErrMsgTxt("Invalid plan");)
-  DM(if (plans[i] == 0)
+  DM(if (i < 0 || i >= plans_num_allocated || plans[i] == 0)
     mexErrMsgTxt("Plan was not initialized or has already been finalized");)
 }
 
 static inline int mkplan(void)
 {
-  mexLock();
   int i = 0;
-  while (i < PLANS_MAX && plans[i] != 0) i++;
-  if (i == PLANS_MAX)
-    mexErrMsgTxt("nnfft: Too many plans already allocated.");
+  while (i < plans_num_allocated && plans[i] != 0) i++;
+  if (i == plans_num_allocated)
+  {
+    int l;
+
+    if (plans_num_allocated >= INT_MAX - PLANS_START - 1)
+      mexErrMsgTxt("nnfft: Too many plans already allocated.");
+
+    nnfft_plan** plans_old = plans;
+    plans = nfft_malloc((plans_num_allocated+PLANS_START)*sizeof(nnfft_plan*));
+    for (l = 0; l < plans_num_allocated; l++)
+      plans[l] = plans_old[l];
+    for (l = plans_num_allocated; l < plans_num_allocated+PLANS_START; l++)
+      plans[l] = 0;
+    if (plans_num_allocated > 0)
+      nfft_free(plans_old);
+    plans_num_allocated += PLANS_START;
+  }
   plans[i] = nfft_malloc(sizeof(nnfft_plan));
   return i;
 }
@@ -144,16 +157,22 @@ static void cleanup(void)
 {
   int i;
 
-  mexUnlock();
-
   if (!(gflags & NNFFT_MEX_FIRST_CALL))
   {
-    for (i = 0; i < PLANS_MAX; i++)
+    for (i = 0; i < plans_num_allocated; i++)
       if (plans[i])
       {
         nnfft_finalize(plans[i]);
+	nfft_free(plans[i]);
         plans[i] = 0;
       }
+
+    if (plans_num_allocated > 0)
+    {
+      nfft_free(plans);
+      plans = NULL;
+      plans_num_allocated = 0;
+    }
     gflags |= NNFFT_MEX_FIRST_CALL;
   }
 }
@@ -168,13 +187,6 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
 
     nfft_mex_install_mem_hooks();
 
-    /* plan pointers to zeros */
-    {
-      int i;
-      for (i = 0; i < PLANS_MAX; i++)
-        plans[i] = 0;
-    }
-
     mexAtExit(cleanup);
     gflags &= ~NNFFT_MEX_FIRST_CALL;
   }
diff --git a/matlab/nnfft/nnfftmex.m b/matlab/nnfft/nnfftmex.m
index 55c8b9a..b1f4e44 100644
--- a/matlab/nnfft/nnfftmex.m
+++ b/matlab/nnfft/nnfftmex.m
@@ -1,7 +1,7 @@
 %NFFTMEX Gateway function to NFFT module from NFFT3
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nnfft/simple_test.m b/matlab/nnfft/simple_test.m
index 96ef23b..e8946ff 100644
--- a/matlab/nnfft/simple_test.m
+++ b/matlab/nnfft/simple_test.m
@@ -1,8 +1,8 @@
 %SIMPLE_TEST Example program: Basic usage principles
 %
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nnfft/test_nnfft1d.m b/matlab/nnfft/test_nnfft1d.m
index a8723df..31df6f9 100644
--- a/matlab/nnfft/test_nnfft1d.m
+++ b/matlab/nnfft/test_nnfft1d.m
@@ -1,5 +1,5 @@
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nnfft/test_nnfft2d.m b/matlab/nnfft/test_nnfft2d.m
index cbb1d37..42a20c6 100644
--- a/matlab/nnfft/test_nnfft2d.m
+++ b/matlab/nnfft/test_nnfft2d.m
@@ -1,5 +1,5 @@
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/matlab/nnfft/test_nnfft2d_N215.m b/matlab/nnfft/test_nnfft2d_N215.m
index bef9eca..ba68594 100644
--- a/matlab/nnfft/test_nnfft2d_N215.m
+++ b/matlab/nnfft/test_nnfft2d_N215.m
@@ -1,5 +1,5 @@
 
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/support/Portfile b/support/Portfile
index a5be6a1..216ced6 100644
--- a/support/Portfile
+++ b/support/Portfile
@@ -4,7 +4,7 @@
 PortSystem          1.0
 
 name                nfft-3
-version             3.3.1
+version             3.3.2
 categories          math
 license             GPL-2+
 platforms           darwin
@@ -36,8 +36,8 @@ long_description    NFFT3 is a software library written in C for computing noneq
                         - polar FFT, discrete Radon transform, ridgelet transform
 homepage            http://www.nfft.org
 master_sites        https://github.com/NFFT/nfft/releases/download/${version}/
-checksums           rmd160 08b4ff6b8d35b2ebc90159a8e86ff400e565528c \
-                    sha256 74cc7f4c8922d72131c59f88ecb542e06254eaded09018d6367f8a46c0fb3125
+checksums           rmd160 5cbb6877aa313b076ef53a4247451f5b62503d0c \
+                    sha256 9dcebd905a82c4f0a339d0d5e666b68c507169d9173b66d5ac588aae5d50b57c
 depends_lib         port:fftw-3
 use_autoreconf      no
 configure.args      --enable-shared --enable-static --enable-all
diff --git a/support/copyright.txt b/support/copyright.txt
index e0c6958..28b746b 100644
--- a/support/copyright.txt
+++ b/support/copyright.txt
@@ -1,4 +1,4 @@
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/support/copyright_m4.txt b/support/copyright_m4.txt
index 1fffac3..4874276 100644
--- a/support/copyright_m4.txt
+++ b/support/copyright_m4.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+# Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 #
 # This program is free software; you can redistribute it and/or modify it under
 # the terms of the GNU General Public License as published by the Free Software
diff --git a/support/copyright_matlab.txt b/support/copyright_matlab.txt
index 573205c..019c2cd 100644
--- a/support/copyright_matlab.txt
+++ b/support/copyright_matlab.txt
@@ -1,4 +1,4 @@
-% Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
 %
 % This program is free software; you can redistribute it and/or modify it under
 % the terms of the GNU General Public License as published by the Free Software
diff --git a/support/copyright_matlab_single_line.txt b/support/copyright_matlab_single_line.txt
index 324d40f..deacccc 100644
--- a/support/copyright_matlab_single_line.txt
+++ b/support/copyright_matlab_single_line.txt
@@ -1 +1 @@
-%   Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+%   Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
diff --git a/support/fpt.dox b/support/fpt.dox
index 899f5f0..891e5bf 100644
--- a/support/fpt.dox
+++ b/support/fpt.dox
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
@@ -44,14 +44,14 @@
  * \arg set The set of DPT transform data where the computed data will be stored.
  * \arg m The transform index \f$m \in \mathbb{N}, 0 \le m \le M\f$.
  * \arg alpha The three-term recurrence coefficients \f$\alpha_k \in
- *      \mathbb{R}\f$ for \f$k=0,\ldots,N\f$ such that \verbatim alpha[k]
- *      \endverbatim \f$=\alpha_k\f$.
+ *      \mathbb{R}\f$ for \f$k=0,\ldots,N\f$ such that <tt> alpha[k]</tt>
+ *      \f$=\alpha_k\f$.
  * \arg beta The three-term recurrence coefficients \f$\beta_k \in \mathbb{R}\f$
- *            for \f$k=0,\ldots,N\f$ such that \verbatim beta[k] \endverbatim
+ *            for \f$k=0,\ldots,N\f$ such that <tt> beta[k] </tt>
  *            \f$=\beta_k\f$.
  * \arg gamma The three-term recurrence coefficients \f$\gamma_k \in
- *            \mathbb{R}\f$ for \f$k=0,\ldots,N\f$ such that \verbatim gamma[k]
- *            \endverbatim \f$=\gamma_k\f$.
+ *            \mathbb{R}\f$ for \f$k=0,\ldots,N\f$ such that <tt> gamma[k]  </tt>
+ *            \f$=\gamma_k\f$.
  * \arg k_start The index \f$k_{\text{start}} \in \mathbb{N}_0,
  *              0 \le k_{\text{start}} \le N\f$
  * \arg threshold The treshold \f$\kappa \in \mathbb{R}, \kappa > 0\f$.
diff --git a/support/mri.dox b/support/mri.dox
index 276b2a1..96a69b4 100644
--- a/support/mri.dox
+++ b/support/mri.dox
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/support/nfct.dox b/support/nfct.dox
index 1d0d11a..7f2c08a 100644
--- a/support/nfct.dox
+++ b/support/nfct.dox
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/support/nfft.dox b/support/nfft.dox
index ef75176..e77db74 100644
--- a/support/nfft.dox
+++ b/support/nfft.dox
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
@@ -37,18 +37,18 @@
  * Let the torus
  * \f[
  *   \mathbb{T}^d
- *    := \left\{ \mathbf{x}=\left(x_t\right)_{t=0,\hdots,d-1}\in\mathbb{R}^{d}:
- *    \; - \frac{1}{2} \le x_t < \frac{1}{2},\; t=0,\hdots,d-1 \right\}
+ *    := \left\{ \mathbf{x}=\left(x_t\right)_{t=0,\dots,d-1}\in\mathbb{R}^{d}:
+ *    \; - \frac{1}{2} \le x_t < \frac{1}{2},\; t=0,\dots,d-1 \right\}
  * \f]
  * of dimension \f$d\f$ be given.
  * It will serve as domain from which the nonequispaced nodes \f$\mathbf{x}\f$
  * are taken.
  * The sampling set is given by \f${\cal X}:=\{\mathbf{x}_j \in {\mathbb T}^d:
- * \,j=0,\hdots,M-1\}\f$.
+ * \,j=0,\dots,M-1\}\f$.
  * Possible frequencies \f$\mathbf{k}\f$ are collected in the multi index set
  * \f[
- *   I_{\mathbf{N}} := \left\{ \mathbf{k}=\left(k_t\right)_{t=0,\hdots,d-1}\in
- *   \mathbb{Z}^d: - \frac{N_t}{2} \le k_t < \frac{N_t}{2} ,\;t=0,\hdots,d-1
+ *   I_{\mathbf{N}} := \left\{ \mathbf{k}=\left(k_t\right)_{t=0,\dots,d-1}\in
+ *   \mathbb{Z}^d: - \frac{N_t}{2} \le k_t < \frac{N_t}{2} ,\;t=0,\dots,d-1
  * \right\}.
  * \f]
  *
@@ -57,7 +57,7 @@
  * \f[
  * f_j = \sum_{\mathbf{k}\in I_{\mathbf{N}}}
  * \hat{f}_{\mathbf{k}} {\rm e}^{-2\pi{\rm i} \mathbf{k}\mathbf{x}_j}, \qquad
- * j=0,\hdots,M-1.
+ * j=0,\dots,M-1.
  * \f]
  * The corresponding adjoint NDFT is the computation of
  * \f[
diff --git a/support/nfsft.dox b/support/nfsft.dox
index 43ec828..ba2c240 100644
--- a/support/nfsft.dox
+++ b/support/nfsft.dox
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
@@ -42,8 +42,12 @@
  * and identify a point from \f$\mathbb{S}^2\f$ with the corresponding vector
  * \f$(\vartheta,\varphi)^{\mathrm{T}}\f$. The
  * spherical coordinate system is illustrated in the following figure:
+ *
+ * <center>
  * \image html sphere.png ""
  * \image latex sphere.pdf "" width=0.45\textwidth
+ * </center>
+ *
  * For consistency with the other modules and the conventions used there, we
  * also use \e swapped \e scaled \e spherical \e coordinates \f$x_1 :=
  * \frac{\varphi}{2\pi}\f$, \f$x_2 := \frac{\vartheta}{2\pi}\f$ and identify a
diff --git a/support/nfsoft.dox b/support/nfsoft.dox
index 9f157a7..22c57d6 100644
--- a/support/nfsoft.dox
+++ b/support/nfsoft.dox
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
@@ -171,8 +171,8 @@
  * If this flag is set, the Wigner-D functions will be normed
  * such that they satisfy the representation property of
  * the spherical harmonics as defined in the NFFT software package, i.e.
- * for every rotation matrix \f$A$\f with Euler angles \f$\alpha, \beta, \gamma$\f
- * and every unit vector \f$x$\f the Wigner-D functions will be normed such that
+ * for every rotation matrix \c A with Euler angles \f$\alpha, \beta, \gamma\f$
+ * and every unit vector \c x the Wigner-D functions will be normed such that
  *
  * \f[
  *  \sum_{m=-l}^l D_{mn}^l(\alpha,\beta,\gamma) Y_m^l(x) = Y_n^l(A^{-1} x)
diff --git a/support/nfst.dox b/support/nfst.dox
index 80832af..689ce49 100644
--- a/support/nfst.dox
+++ b/support/nfst.dox
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/support/nnfft.dox b/support/nnfft.dox
index 22500c3..09d090b 100644
--- a/support/nnfft.dox
+++ b/support/nnfft.dox
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/support/nsfft.dox b/support/nsfft.dox
index abbceb4..af03636 100644
--- a/support/nsfft.dox
+++ b/support/nsfft.dox
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
@@ -27,7 +27,7 @@
  */
 
 /*! \fn void nsfft_direct_trafo(nsfft_plan *ths)
- * Executes an NSDFT, computes for \f$j=0,\hdots,M-1\f$:
+ * Executes an NSDFT, computes for \f$j=0,\dots,M-1\f$:
  * \f[
  *   f_j = \sum_{k\in H_N^d}\hat f_k {\rm e}^{-2\pi{\rm\scriptsize i}k x_j}
  * \f]
@@ -40,7 +40,7 @@
 /*! \fn void nsfft_direct_adjoint(nsfft_plan *ths)
  * Executes an adjoint NSFFT, computes for \f$k\in H_N^d\f$:
  * \f[
- *   \hat f_k = \sum_{j=0,\hdots,M-1} f_j {\rm e}^{+2\pi{\rm\scriptsize i}k x_j}
+ *   \hat f_k = \sum_{j=0,\dots,M-1} f_j {\rm e}^{+2\pi{\rm\scriptsize i}k x_j}
  * \f]
  *
  * \arg ths The pointer to a nsfft plan
@@ -50,7 +50,7 @@
 
 /*! \fn void nsfft_trafo(nsfft_plan *ths)
  * Executes an NSFFT, computes \b fast and \b approximate for
- * \f$j=0,\hdots,M-1\f$:
+ * \f$j=0,\dots,M-1\f$:
  * \f[
  *   f_j = \sum_{k\in H_N^d}\hat f_k {\rm e}^{-2\pi{\rm\scriptsize i}k x_j}
  * \f]
@@ -64,7 +64,7 @@
  * Executes an adjoint NSFFT, computes \b fast and \b approximate for
  * \f$k\in H_N^d\f$:
  * \f[
- *   \hat f_k = \sum_{j=0,\hdots,M-1} f_j {\rm e}^{+2\pi{\rm\scriptsize i}k x_j}
+ *   \hat f_k = \sum_{j=0,\dots,M-1} f_j {\rm e}^{+2\pi{\rm\scriptsize i}k x_j}
  * \f]
  *
  * \arg ths The pointer to a nsfft plan
diff --git a/support/solver.dox b/support/solver.dox
index 81a2a4b..0c623d4 100644
--- a/support/solver.dox
+++ b/support/solver.dox
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/tests/Makefile.am b/tests/Makefile.am
index fbd0806..e9aec64 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -34,7 +34,7 @@ else
   NFST_SOURCES=
 endif
 
-checkall_SOURCES = check.c version.c version.h bspline.c bspline.h bessel.c bessel.h nfft.c nfft.h $(NFCT_SOURCES) $(NFST_SOURCES)
+checkall_SOURCES = check.c util.c util.h reflect.c reflect.h bspline.c bspline.h bessel.c bessel.h nfft.c nfft.h $(NFCT_SOURCES) $(NFST_SOURCES)
 checkall_LDADD = $(top_builddir)/libnfft3 at PREC_SUFFIX@.la -lm -lcunit -lncurses
 
 if HAVE_THREADS
diff --git a/tests/bessel.c b/tests/bessel.c
index 51a87fa..f21963a 100644
--- a/tests/bessel.c
+++ b/tests/bessel.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
@@ -135,11 +135,11 @@ static const R r[] =
 #define ERR(x,y) IF(ABS(x - y) == K(0.0), ABS(x - y), ABS(x - y) / ABS(y))
 
 #if defined(NFFT_LDOUBLE)
-static const R bound = K(58.0) * EPSILON;
+static const R bound = K(58.0) * NFFT_EPSILON;
 #elif defined(NFFT_SINGLE)
-static const R bound = K(16.0) * EPSILON;
+static const R bound = K(16.0) * NFFT_EPSILON;
 #else
-static const R bound = K(4.0) * EPSILON;
+static const R bound = K(4.0) * NFFT_EPSILON;
 #endif
 
 void X(check_bessel_i0)(void)
diff --git a/tests/bessel.h b/tests/bessel.h
index 060e21c..69f9eb1 100644
--- a/tests/bessel.h
+++ b/tests/bessel.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/tests/bspline.c b/tests/bspline.c
index 357eeb8..14785d8 100644
--- a/tests/bspline.c
+++ b/tests/bspline.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
@@ -6323,11 +6323,11 @@ static const R b30[] =
 #define ERR(x,y) IF(ABS(y) == K(0.0), ABS(x - y), ABS(x - y) / ABS(y))
 
 #if defined(NFFT_LDOUBLE)
-static const R bound = K(17.0) * EPSILON;
+static const R bound = K(17.0) * NFFT_EPSILON;
 #elif defined(NFFT_SINGLE)
-static const R bound = K(20.0) * EPSILON;
+static const R bound = K(20.0) * NFFT_EPSILON;
 #else
-static const R bound = K(16.0) * EPSILON;
+static const R bound = K(16.0) * NFFT_EPSILON;
 #endif
 
 static int check_bspline(const unsigned n, const unsigned int m, const R *r)
diff --git a/tests/bspline.h b/tests/bspline.h
index fe00ad8..4926323 100644
--- a/tests/bspline.h
+++ b/tests/bspline.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/tests/check.c b/tests/check.c
index 2e06db7..0fc1255 100644
--- a/tests/check.c
+++ b/tests/check.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
@@ -22,7 +22,8 @@
 #include <CUnit/Automated.h>
 
 #include "infft.h"
-#include "version.h"
+#include "reflect.h"
+#include "util.h"
 #include "bspline.h"
 #include "bessel.h"
 #include "nfft.h"
@@ -39,6 +40,16 @@ int main(void)
 #endif
 
 #undef X
+#define X(name) Y(name)
+  util = CU_add_suite("util", 0, 0);
+  CU_add_test(util, "bspline", X(check_bspline));
+  CU_add_test(util, "bessel_i0", X(check_bessel_i0));
+  CU_add_test(util, "version", X(check_get_version));
+  CU_add_test(util, "window_name", X(check_get_window_name));
+  CU_add_test(util, "log2i", X(check_log2i));
+  CU_add_test(util, "next_power_of_2", X(check_next_power_of_2));
+
+#undef X
 #define X(name) NFFT(name)
   nfft = CU_add_suite("nfft", 0, 0);
   CU_add_test(nfft, "nfft_1d_direct_file", X(check_1d_direct_file));
@@ -130,12 +141,6 @@ int main(void)
 #endif
 #endif
 #endif
-#undef X
-#define X(name) Y(name)
-  util = CU_add_suite("util", 0, 0);
-  CU_add_test(util, "bspline", X(check_bspline));
-  CU_add_test(util, "bessel_i0", X(check_bessel_i0));
-  CU_add_test(util, "version", X(check_version));
   CU_automated_run_tests();
   //CU_basic_run_tests();
   {
diff --git a/tests/check_nfsft.c b/tests/check_nfsft.c
index 455476e..29d5d0c 100644
--- a/tests/check_nfsft.c
+++ b/tests/check_nfsft.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/tests/nfct.c b/tests/nfct.c
index 31a3c13..bb68567 100644
--- a/tests/nfct.c
+++ b/tests/nfct.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
@@ -210,7 +210,7 @@ static R trafo_direct_cost(X(plan) *p)
 static R err_trafo_direct(X(plan) *p)
 {
   UNUSED(p);
-  return K(120.0) * EPSILON;
+  return K(120.0) * NFFT_EPSILON;
 }
 
 static R err_trafo(X(plan) *p)
@@ -219,7 +219,7 @@ static R err_trafo(X(plan) *p)
   R s; /* oversampling factor */
   R a;
   R b;
-  R eps = EPSILON;
+  R eps = NFFT_EPSILON;
   R err;
   int i;
   for (i = 0, s = ((R)p->sigma[0]); i < p->d; i++)
diff --git a/tests/nfct.h b/tests/nfct.h
index b5a5f18..6c9d774 100644
--- a/tests/nfct.h
+++ b/tests/nfct.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/tests/nfft.c b/tests/nfft.c
index ed68a97..0ebb06d 100644
--- a/tests/nfft.c
+++ b/tests/nfft.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
@@ -211,7 +211,7 @@ static R trafo_direct_cost(X(plan) *p)
 static R err_trafo_direct(X(plan) *p)
 {
   UNUSED(p);
-  return K(44.0) * EPSILON;
+  return K(44.0) * NFFT_EPSILON;
 }
 
 static R err_trafo(X(plan) *p)
@@ -220,7 +220,7 @@ static R err_trafo(X(plan) *p)
   R s; /* oversampling factor */
   R a;
   R b;
-  R eps = EPSILON;
+  R eps = NFFT_EPSILON;
   R err;
   int i;
   for (i = 0, s = ((R)p->sigma[0]); i < p->d; i++)
@@ -1396,7 +1396,7 @@ static int check_single_file(const testcase_delegate_t *testcase,
     R err = check_delegate->compare(check_delegate, &p, NN, M, f, f_hat);
     FILE *file = fopen(filename, "a");
     fprintf(file, "%d % 20.16lE\n", (int)p.m, (double)err);
-    printf(", %2d % 20.16lE (" __FE__ ")\n", (int)p.m, (double)err, EPSILON);
+    printf(", %2d % 20.16lE (" __FE__ ")\n", (int)p.m, (double)err, NFFT_EPSILON);
     fclose(file);
   }
 
diff --git a/tests/nfft.h b/tests/nfft.h
index 1b26162..6f10d7f 100644
--- a/tests/nfft.h
+++ b/tests/nfft.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/tests/nfst.c b/tests/nfst.c
index 99d7dd9..d5b50f6 100644
--- a/tests/nfst.c
+++ b/tests/nfst.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
@@ -210,7 +210,7 @@ static R trafo_direct_cost(X(plan) *p)
 static R err_trafo_direct(X(plan) *p)
 {
   UNUSED(p);
-  return K(120.0) * EPSILON;
+  return K(120.0) * NFFT_EPSILON;
 }
 
 static R err_trafo(X(plan) *p)
@@ -219,7 +219,7 @@ static R err_trafo(X(plan) *p)
   R s; /* oversampling factor */
   R a;
   R b;
-  R eps = EPSILON;
+  R eps = NFFT_EPSILON;
   R err;
   int i;
   for (i = 0, s = ((R)p->sigma[0]); i < p->d; i++)
diff --git a/tests/nfst.h b/tests/nfst.h
index 1bd5717..1c4a6a4 100644
--- a/tests/nfst.h
+++ b/tests/nfst.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
diff --git a/tests/version.c b/tests/reflect.c
similarity index 73%
rename from tests/version.c
rename to tests/reflect.c
index 0ec1179..a9dd8ce 100644
--- a/tests/version.c
+++ b/tests/reflect.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
@@ -24,9 +24,9 @@
 
 #include "nfft3.h"
 #include "infft.h"
-#include "version.h"
+#include "reflect.h"
 
-void X(check_version)(void)
+void X(check_get_version)(void)
 {
     unsigned major, minor, patch;
     char v1[20], v2[20];
@@ -38,3 +38,12 @@ void X(check_version)(void)
 
     CU_ASSERT(strncmp(v1, v2, sizeof(v1)) == 0);
 }
+
+void X(check_get_window_name)(void)
+{
+    const char *window_name1 = STRINGIZE(WINDOW_NAME);
+    const char *window_name2 = Y(get_window_name)();
+
+    /* Just compare what's returned by the method against the literal from config.h. */
+    CU_ASSERT(strncmp(window_name1, window_name2, sizeof(window_name1)) == 0);
+}
diff --git a/tests/bessel.h b/tests/reflect.h
similarity index 84%
copy from tests/bessel.h
copy to tests/reflect.h
index 060e21c..bbd8b96 100644
--- a/tests/bessel.h
+++ b/tests/reflect.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
@@ -18,4 +18,5 @@
 
 #include "infft.h"
 
-void X(check_bessel_i0)(void);
+void X(check_get_version)(void);
+void X(check_get_window_name)(void);
diff --git a/tests/util.c b/tests/util.c
new file mode 100644
index 0000000..60e3850
--- /dev/null
+++ b/tests/util.c
@@ -0,0 +1,153 @@
+/*
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/* Standard headers. */
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <CUnit/CUnit.h>
+
+#include "nfft3.h"
+#include "infft.h"
+
+static INT _log2i(const INT m)
+{
+  INT l = 0;
+  INT mm = m;
+
+  if (m <= 0)
+    return -1;
+
+  while (mm > (INT)(0))
+  {
+    mm = (mm >> 1);
+    l++;
+  }
+
+  return (l-1);
+}
+
+void X(check_log2i)(void)
+{
+    INT i;
+    INT j;
+
+    {
+        INT r = Y(log2i)(0);
+        int ok = r == -1;
+        printf("log2i("__D__") = "__D__" -> %s\n", (INT)(0), r, ok ? "OK" : "FAIL");
+        CU_ASSERT(ok)
+    }
+
+    {
+        INT r = Y(log2i)(-1);
+        int ok = r == -1;
+        printf("log2i("__D__") = "__D__" -> %s\n", (INT)(-1), r, ok ? "OK" : "FAIL");
+        CU_ASSERT(ok)
+    }
+
+    for (i = 0, j = 1; i < 8 * SIZEOF_PTRDIFF_T - 1; i++, j <<= 1)
+    {
+        {
+            INT r = Y(log2i)(j);
+            INT r2 = _log2i(j);
+            int ok = r == r2;
+            printf("log2i("__D__") = "__D__" -> %s\n", j, r, ok ? "OK" : "FAIL");
+            CU_ASSERT(ok)
+        }
+        {
+            INT r = Y(log2i)(j - 1);
+            INT r2 = _log2i(j - 1);
+            int ok = r == r2;
+            printf("log2i("__D__") = "__D__" -> %s\n", j - 1, r, ok ? "OK" : "FAIL");
+            CU_ASSERT(ok)
+        }
+    }
+}
+
+/** Computes /f$n\ge N/f$ such that /f$n=2^j,\, j\in\mathhb{N}_0/f$.
+ */
+static INT _next_power_of_2(const INT N)
+{
+  INT n,i,logn;
+  INT N_is_not_power_of_2=0;
+
+  if (N == 0)
+    return 1;
+  else if (N == 1)
+    return 2;
+  else
+  {
+    n = N;
+    logn = 0;
+    while (n != 1)
+    {
+      if (n%2 == 1)
+        N_is_not_power_of_2=1;
+      n = n/2;
+      logn++;
+    }
+
+    if (!N_is_not_power_of_2)
+      logn--;
+
+    for (i = 0; i <= logn; i++)
+      n = n*2;
+
+    return n;
+  }
+}
+
+void X(check_next_power_of_2)(void)
+{
+    INT i;
+    INT j;
+
+    {
+        INT r = Y(next_power_of_2)(0);
+        int ok = r == 1;
+        printf("next_power_of_2("__D__") = "__D__" -> %s\n", (INT)(0), r, ok ? "OK" : "FAIL");
+        CU_ASSERT(ok)
+    }
+
+    {
+        INT r = Y(next_power_of_2)(-1);
+        int ok = r == -1;
+        printf("log2i("__D__") = "__D__" -> %s\n", (INT)(-1), r, ok ? "OK" : "FAIL");
+        CU_ASSERT(ok)
+    }
+
+    for (i = 0, j = 1; i < 8 * SIZEOF_PTRDIFF_T - 1; i++, j <<= 1)
+    {
+        {
+            INT r = Y(next_power_of_2)(j);
+            INT r2 = _next_power_of_2(j);
+            int ok = r == r2;
+            printf("next_power_of_2("__D__") = "__D__" -> %s\n", j, r, ok ? "OK" : "FAIL");
+            CU_ASSERT(ok)
+        }
+        {
+            INT r = Y(next_power_of_2)(j - 1);
+            INT r2 = _next_power_of_2(j - 1);
+            int ok = r == r2;
+            printf("next_power_of_2("__D__") = "__D__" -> %s\n", j - 1, r, ok ? "OK" : "FAIL");
+            CU_ASSERT(ok)
+        }
+    }
+}
+
diff --git a/tests/version.h b/tests/util.h
similarity index 85%
rename from tests/version.h
rename to tests/util.h
index 018a638..92fd508 100644
--- a/tests/version.h
+++ b/tests/util.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
+ * Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
  *
  * This program is free software; you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
@@ -18,4 +18,5 @@
 
 #include "infft.h"
 
-void X(check_version)(void);
+void X(check_log2i)(void);
+void X(check_next_power_of_2)(void);

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



More information about the debian-science-commits mailing list