Skip to content

Commit

Permalink
matlab/octave ok w/o many_seq option.
Browse files Browse the repository at this point in the history
  • Loading branch information
ahbarnett committed Jul 29, 2018
1 parent a1586c4 commit 762cdcd
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 42 deletions.
7 changes: 4 additions & 3 deletions docs/matlab.rst
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
MATLAB/octave interfaces
========================

.. literalinclude:: matlabhelp.raw

A note on integer sizes:
In Matlab/MEX, mwrap uses ``int`` types, so that output arrays can only
be <2^31.
However, input arrays >=2^31 have been tested, and while they don't crash,
they result in wrong answers (all zeros). This has yet to be fixed.
An updated version of mwrap may be needed.
they result in wrong answers (all zeros). This has yet to be fixed
(please help; an updated version of mwrap might be needed).

For a full list of error codes see :ref:`errcodes`.

.. literalinclude:: matlabhelp.raw

2 changes: 0 additions & 2 deletions docs/matlabhelp.raw
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@
opts.modeord: 0 (CMCL increasing mode ordering, default), 1 (FFT ordering)
opts.chkbnds: 0 (don't check NU points valid), 1 (do, default).
opts.upsampfac: either 2.0 (default), or 1.25 (low RAM, smaller FFT size)
opts.many_seq: 0 (simultaneously do nufft on all data, default), 1 (seq)
Outputs:
f size (ms,mt,ndata) double complex array of Fourier transform values
(ordering given by opts.modeord in each dimension, ms fast, mt slow)
Expand Down Expand Up @@ -214,7 +213,6 @@
opts.modeord: 0 (CMCL increasing mode ordering, default), 1 (FFT ordering)
opts.chkbnds: 0 (don't check NU points valid), 1 (do, default).
opts.upsampfac: either 2.0 (default), or 1.25 (low RAM, smaller FFT size)
opts.many_seq: 0 (simultaneously do nufft on all data, default), 1 (seq)
Outputs:
c complex double array of nj*ndata answers at the targets.
ier - 0 if success, else:
Expand Down
54 changes: 27 additions & 27 deletions matlab/finufft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ mxWrapCopyZDef (mxWrapCopy_dcomplex, dcomplex,
mxWrapReturnZDef (mxWrapReturn_dcomplex, dcomplex,
real_dcomplex, imag_dcomplex)

/* ---- finufft.mw: 56 ----
/* ---- finufft.mw: 57 ----
* int ier = finufft1d1m(double nj, double[] x, dcomplex[] c, int isign, double eps, double ms, output dcomplex[ms] f, double[] opts);
*/
const char* stubids1_ = "o int = finufft1d1m(i double, i double[], i dcomplex[], i int, i double, i double, o dcomplex[x], i double[])";
Expand Down Expand Up @@ -376,7 +376,7 @@ void mexStub1(int nlhs, mxArray* plhs[],
mexErrMsgTxt(mw_err_txt_);
}

/* ---- finufft.mw: 96 ----
/* ---- finufft.mw: 97 ----
* int ier = finufft1d2m(double nj, double[] x, output dcomplex[nj] c, int isign, double eps, double ms, dcomplex[] f, double[] opts);
*/
const char* stubids2_ = "o int = finufft1d2m(i double, i double[], o dcomplex[x], i int, i double, i double, i dcomplex[], i double[])";
Expand Down Expand Up @@ -440,7 +440,7 @@ void mexStub2(int nlhs, mxArray* plhs[],
mexErrMsgTxt(mw_err_txt_);
}

/* ---- finufft.mw: 132 ----
/* ---- finufft.mw: 133 ----
* int ier = finufft1d3m(double nj, double[] x, dcomplex[nj] c, int isign, double eps, double nk, double[] s, output dcomplex[nk] f, double[] opts);
*/
const char* stubids3_ = "o int = finufft1d3m(i double, i double[], i dcomplex[x], i int, i double, i double, i double[], o dcomplex[x], i double[])";
Expand Down Expand Up @@ -515,7 +515,7 @@ void mexStub3(int nlhs, mxArray* plhs[],
mexErrMsgTxt(mw_err_txt_);
}

/* ---- finufft.mw: 177 ----
/* ---- finufft.mw: 178 ----
* int ier = finufft2d1m(double nj, double[] x, double[] y, dcomplex[] c, int isign, double eps, double ms, double mt, output dcomplex[ms, mt] f, double[] opts);
*/
const char* stubids4_ = "o int = finufft2d1m(i double, i double[], i double[], i dcomplex[], i int, i double, i double, i double, o dcomplex[xx], i double[])";
Expand Down Expand Up @@ -740,7 +740,7 @@ void mexStub6(int nlhs, mxArray* plhs[],
mexErrMsgTxt(mw_err_txt_);
}

/* ---- finufft.mw: 312 ----
/* ---- finufft.mw: 311 ----
* int ier = finufft2d2manym(double ndata, double nj, double[] x, double[] y, output dcomplex[nj, ndata] c, int isign, double eps, double ms, double mt, dcomplex[] f, double[] opts);
*/
const char* stubids7_ = "o int = finufft2d2manym(i double, i double, i double[], i double[], o dcomplex[xx], i int, i double, i double, i double, i dcomplex[], i double[])";
Expand Down Expand Up @@ -819,7 +819,7 @@ void mexStub7(int nlhs, mxArray* plhs[],
mexErrMsgTxt(mw_err_txt_);
}

/* ---- finufft.mw: 350 ----
/* ---- finufft.mw: 349 ----
* int ier = finufft2d3m(double nj, double[] x, double[] y, dcomplex[nj] c, int isign, double eps, double nk, double[] s, double[] t, output dcomplex[nk] f, double[] opts);
*/
const char* stubids8_ = "o int = finufft2d3m(i double, i double[], i double[], i dcomplex[x], i int, i double, i double, i double[], i double[], o dcomplex[x], i double[])";
Expand Down Expand Up @@ -904,7 +904,7 @@ void mexStub8(int nlhs, mxArray* plhs[],
mexErrMsgTxt(mw_err_txt_);
}

/* ---- finufft.mw: 400 ----
/* ---- finufft.mw: 399 ----
* int ier = finufft3d1m(double nj, double[] x, double[] y, double[] z, dcomplex[] c, int isign, double eps, double ms, double mt, double mu, output dcomplex[mtot] f, double[] opts);
*/
const char* stubids9_ = "o int = finufft3d1m(i double, i double[], i double[], i double[], i dcomplex[], i int, i double, i double, i double, i double, o dcomplex[x], i double[])";
Expand Down Expand Up @@ -986,7 +986,7 @@ void mexStub9(int nlhs, mxArray* plhs[],
mexErrMsgTxt(mw_err_txt_);
}

/* ---- finufft.mw: 448 ----
/* ---- finufft.mw: 447 ----
* int ier = finufft3d2m(double nj, double[] x, double[] y, double[] z, output dcomplex[nj] c, int isign, double eps, double ms, double mt, double mu, dcomplex[] f, double[] opts);
*/
const char* stubids10_ = "o int = finufft3d2m(i double, i double[], i double[], i double[], o dcomplex[x], i int, i double, i double, i double, i double, i dcomplex[], i double[])";
Expand Down Expand Up @@ -1068,7 +1068,7 @@ void mexStub10(int nlhs, mxArray* plhs[],
mexErrMsgTxt(mw_err_txt_);
}

/* ---- finufft.mw: 489 ----
/* ---- finufft.mw: 488 ----
* int ier = finufft3d3m(double nj, double[] x, double[] y, double[] z, dcomplex[nj] c, int isign, double eps, double nk, double[] s, double[] t, double[] u, output dcomplex[nk] f, double[] opts);
*/
const char* stubids11_ = "o int = finufft3d3m(i double, i double[], i double[], i double[], i dcomplex[x], i int, i double, i double, i double[], i double[], i double[], o dcomplex[x], i double[])";
Expand Down Expand Up @@ -1213,17 +1213,17 @@ void mexFunction(int nlhs, mxArray* plhs[],
} else if (strcmp(id, "*profile report*") == 0) {
if (!mexprofrecord_)
mexPrintf("Profiler inactive\n");
mexPrintf("%d calls to finufft.mw:56\n", mexprofrecord_[1]);
mexPrintf("%d calls to finufft.mw:96\n", mexprofrecord_[2]);
mexPrintf("%d calls to finufft.mw:132\n", mexprofrecord_[3]);
mexPrintf("%d calls to finufft.mw:177\n", mexprofrecord_[4]);
mexPrintf("%d calls to finufft.mw:57\n", mexprofrecord_[1]);
mexPrintf("%d calls to finufft.mw:97\n", mexprofrecord_[2]);
mexPrintf("%d calls to finufft.mw:133\n", mexprofrecord_[3]);
mexPrintf("%d calls to finufft.mw:178\n", mexprofrecord_[4]);
mexPrintf("%d calls to finufft.mw:226\n", mexprofrecord_[5]);
mexPrintf("%d calls to finufft.mw:269\n", mexprofrecord_[6]);
mexPrintf("%d calls to finufft.mw:312\n", mexprofrecord_[7]);
mexPrintf("%d calls to finufft.mw:350\n", mexprofrecord_[8]);
mexPrintf("%d calls to finufft.mw:400\n", mexprofrecord_[9]);
mexPrintf("%d calls to finufft.mw:448\n", mexprofrecord_[10]);
mexPrintf("%d calls to finufft.mw:489\n", mexprofrecord_[11]);
mexPrintf("%d calls to finufft.mw:311\n", mexprofrecord_[7]);
mexPrintf("%d calls to finufft.mw:349\n", mexprofrecord_[8]);
mexPrintf("%d calls to finufft.mw:399\n", mexprofrecord_[9]);
mexPrintf("%d calls to finufft.mw:447\n", mexprofrecord_[10]);
mexPrintf("%d calls to finufft.mw:488\n", mexprofrecord_[11]);
} else if (strcmp(id, "*profile log*") == 0) {
FILE* logfp;
if (nrhs != 2 || mxGetString(prhs[1], id, sizeof(id)) != 0)
Expand All @@ -1233,17 +1233,17 @@ void mexFunction(int nlhs, mxArray* plhs[],
mexErrMsgTxt("Cannot open log for output");
if (!mexprofrecord_)
fprintf(logfp, "Profiler inactive\n");
fprintf(logfp, "%d calls to finufft.mw:56\n", mexprofrecord_[1]);
fprintf(logfp, "%d calls to finufft.mw:96\n", mexprofrecord_[2]);
fprintf(logfp, "%d calls to finufft.mw:132\n", mexprofrecord_[3]);
fprintf(logfp, "%d calls to finufft.mw:177\n", mexprofrecord_[4]);
fprintf(logfp, "%d calls to finufft.mw:57\n", mexprofrecord_[1]);
fprintf(logfp, "%d calls to finufft.mw:97\n", mexprofrecord_[2]);
fprintf(logfp, "%d calls to finufft.mw:133\n", mexprofrecord_[3]);
fprintf(logfp, "%d calls to finufft.mw:178\n", mexprofrecord_[4]);
fprintf(logfp, "%d calls to finufft.mw:226\n", mexprofrecord_[5]);
fprintf(logfp, "%d calls to finufft.mw:269\n", mexprofrecord_[6]);
fprintf(logfp, "%d calls to finufft.mw:312\n", mexprofrecord_[7]);
fprintf(logfp, "%d calls to finufft.mw:350\n", mexprofrecord_[8]);
fprintf(logfp, "%d calls to finufft.mw:400\n", mexprofrecord_[9]);
fprintf(logfp, "%d calls to finufft.mw:448\n", mexprofrecord_[10]);
fprintf(logfp, "%d calls to finufft.mw:489\n", mexprofrecord_[11]);
fprintf(logfp, "%d calls to finufft.mw:311\n", mexprofrecord_[7]);
fprintf(logfp, "%d calls to finufft.mw:349\n", mexprofrecord_[8]);
fprintf(logfp, "%d calls to finufft.mw:399\n", mexprofrecord_[9]);
fprintf(logfp, "%d calls to finufft.mw:447\n", mexprofrecord_[10]);
fprintf(logfp, "%d calls to finufft.mw:488\n", mexprofrecord_[11]);
fclose(logfp);
} else
mexErrMsgTxt("Unknown identifier");
Expand Down
5 changes: 2 additions & 3 deletions matlab/finufft.mw
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
% MWrap file to generate all MEX interfaces directly to C++ to FINUFFT library.
% Also allows control of number of openmp threads the library uses.
% Barnett 3/22/17.
% Dependence of C++11 removed, opts passed as double array, 10/30/17
% Dependence of C++11 removed, opts passed as double array, 10/30/17.
% Many interface Jun 2018, Melody Shih.

% Hints for linux OS. To generate the MEX C++ file:
% mwrap -list -mex finufft -cppcomplex -mb finufft.mw
Expand Down Expand Up @@ -205,7 +206,6 @@ if numel(c)~=nj, error('c must have the same number of elements as x'); end
% opts.modeord: 0 (CMCL increasing mode ordering, default), 1 (FFT ordering)
% opts.chkbnds: 0 (don't check NU points valid), 1 (do, default).
% opts.upsampfac: either 2.0 (default), or 1.25 (low RAM, smaller FFT size)
% opts.many_seq: 0 (simultaneously do nufft on all data, default), 1 (seq)
% Outputs:
% f size (ms,mt,ndata) double complex array of Fourier transform values
% (ordering given by opts.modeord in each dimension, ms fast, mt slow)
Expand Down Expand Up @@ -295,7 +295,6 @@ if numel(y)~=nj, error('y must have the same number of elements as x'); end
% opts.modeord: 0 (CMCL increasing mode ordering, default), 1 (FFT ordering)
% opts.chkbnds: 0 (don't check NU points valid), 1 (do, default).
% opts.upsampfac: either 2.0 (default), or 1.25 (low RAM, smaller FFT size)
% opts.many_seq: 0 (simultaneously do nufft on all data, default), 1 (seq)
% Outputs:
% c complex double array of nj*ndata answers at the targets.
% ier - 0 if success, else:
Expand Down
1 change: 0 additions & 1 deletion matlab/finufft2d1many.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
% opts.modeord: 0 (CMCL increasing mode ordering, default), 1 (FFT ordering)
% opts.chkbnds: 0 (don't check NU points valid), 1 (do, default).
% opts.upsampfac: either 2.0 (default), or 1.25 (low RAM, smaller FFT size)
% opts.many_seq: 0 (simultaneously do nufft on all data, default), 1 (seq)
% Outputs:
% f size (ms,mt,ndata) double complex array of Fourier transform values
% (ordering given by opts.modeord in each dimension, ms fast, mt slow)
Expand Down
1 change: 0 additions & 1 deletion matlab/finufft2d2many.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
% opts.modeord: 0 (CMCL increasing mode ordering, default), 1 (FFT ordering)
% opts.chkbnds: 0 (don't check NU points valid), 1 (do, default).
% opts.upsampfac: either 2.0 (default), or 1.25 (low RAM, smaller FFT size)
% opts.many_seq: 0 (simultaneously do nufft on all data, default), 1 (seq)
% Outputs:
% c complex double array of nj*ndata answers at the targets.
% ier - 0 if success, else:
Expand Down
1 change: 0 additions & 1 deletion matlab/finufft_m.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ void finufft_mex_opts(nufft_opts &opts, double *mexo)
opts.modeord = IROUND(mexo[4]); // unused by type-3
opts.chkbnds = IROUND(mexo[5]); // "
opts.upsampfac = mexo[6];
opts.many_seq = IROUND(mexo[7]);
}


Expand Down
6 changes: 2 additions & 4 deletions matlab/finufft_opts.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function opts = finufft_opts(o)
% FINUFFTS_OPTS. Global set opts for matlab interface to FINUFFT, with defaults
% Barnett. Added upsampfac 6/18/18.
% Added many_seq 6/23/18
% Added many_seq 6/23/18, then removed 7/28/18.

% sets defaults, used if field absent or empty, and handles fields in o...
debug=0; if isfield(o,'debug') && ~isempty(o.debug), debug = o.debug; end
Expand All @@ -11,16 +11,14 @@
modeord=0; if isfield(o,'modeord') && ~isempty(o.modeord), modeord=o.modeord; end
chkbnds=0; if isfield(o,'chkbnds') && ~isempty(o.chkbnds), chkbnds=o.chkbnds; end
upsampfac=2.0; if isfield(o,'upsampfac') && ~isempty(o.upsampfac), upsampfac=o.upsampfac; end
many_seq=0; if isfield(o,'many_seq') && ~isempty(o.many_seq), many_seq=o.many_seq; end

% pack up: ordering of opts must match that in finufft_m.cpp:finufft_mex_opts()
% (placement in opts now explicit, catches errors if inputs are not 1x1 sized)
opts = zeros(1,8,'double');
opts = zeros(1,7,'double');
opts(1) = debug;
opts(2) = nthreads;
opts(3) = spread_sort;
opts(4) = fftw;
opts(5) = modeord;
opts(6) = chkbnds;
opts(7) = upsampfac;
opts(8) = many_seq;

0 comments on commit 762cdcd

Please sign in to comment.