#include "math.h" /* * DISUFQ Is an internal function to spec2nlsdat * * CALL: disufq(rvec,ivec,rA,iA, w,kw,h,g,nmin,nmax,m,n) * * rvec, ivec = real and imaginary parts of the resultant (size m X n). * rA, iA = real and imaginary parts of the amplitudes (size m X n). * w = vector with angular frequencies (w>=0) * kw = vector with wavenumbers (kw>=0) * h = water depth (h >=0) * g = constant acceleration of gravity * nmin = minimum index where rA(:,nmin) and iA(:,nmin) is * greater than zero. * nmax = maximum index where rA(:,nmax) and iA(:,nmax) is * greater than zero. * m = size(rA,1),size(iA,1) * n = size(rA,2),size(iA,2), or size(rvec,2),size(ivec,2) * * DISUFQ returns the summation of difference frequency and sum * frequency effects in the vector vec = rvec +sqrt(-1)*ivec. * The 2'nd order contribution to the Stokes wave is then calculated by * a simple 1D Fourier transform, real(FFT(vec)). * * Install gfortran and run the following to build the module: * f2py diffsumfunq.pyf disufq1.c -c --fcompiler=gnu95 --compiler=mingw32 -lmsvcr71 * * by Per Andreas Brodtkorb 15.08.2001 * revised pab 14.03.2002, 01.05.2002 22.07.2002, oct 2008 */ void disufq(double *rvec, double *ivec, double *rA, double *iA, double *w, double *kw, double h, double g, int nmin, int nmax, int m, int n) { double Epij, Edij; double tmp1, tmp2, tmp3, tmp4, kfact; double w1, w2, kw1, kw2, Cg; double rrA, iiA, riA, irA; int i,jy,ix,iz1,iv1,ixi,jyi; //int iz2, iv2; //Initialize rvec and ivec to zero for (ix=0;ix10000){ /* deep water /Inifinite water depth */ for (ix = nmin-1;ix=0) * kw = vector with wavenumbers (kw>=0) * h = water depth (h >=0) * g = constant acceleration of gravity * nmin = minimum index where rA(:,nmin) and iA(:,nmin) is * greater than zero. * nmax = maximum index where rA(:,nmax) and iA(:,nmax) is * greater than zero. * m = size(rA,1),size(iA,1) * n = size(rA,2),size(iA,2), or size(rvec,2),size(ivec,2) * * DISUFQ2 returns the summation of sum and difference frequency * frequency effects in the vectors svec = rsvec +sqrt(-1)*isvec and * dvec = rdvec +sqrt(-1)*idvec. * The 2'nd order contribution to the Stokes wave is then calculated by * a simple 1D Fourier transform, real(FFT(svec+dvec)). * * * This is a MEX-file for MATLAB. * by Per Andreas Brodtkorb 15.08.2001 * revised pab 14.03.2002, 01.05.2002 */ void disufq2(double *rsvec, double *isvec, double *rdvec, double *idvec, double *rA, double *iA, double *w, double *kw, double h, double g, int nmin, int nmax, int m, int n) { double Epij, Edij; double tmp1, tmp2, tmp3, tmp4, kfact; double w1, w2, kw1, kw2, Cg; double rrA, iiA, riA, irA; int i,jy,ix,iz1,iv1,ixi,jyi; //int iz2,iv2 //Initialize rvec and ivec to zero for (ix=0;ix10000){ /* deep water /Inifinite water depth */ for (ix = nmin-1;ix