0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 SUBROUTINE MEXFUNCTION(NLHS, PLHS, NRHS, PRHS)
0014
0015
0016
0017
0018
0019 mwPointer PLHS(*), PRHS(*)
0020
0021
0022
0023 mwSize NLHS, NRHS
0024
0025
0026
0027
0028
0029 mwPointer MXCREATEDOUBLEMATRIX, MXGETPR
0030
0031
0032
0033
0034 mwSize MXGETM, MXGETN
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044 mwSize i,nx,nin
0045 mwPointer xrp,xip,zrp,zip,ninp
0046 mwSize matone
0047 parameter (matone=1)
0048
0049 LOGICAL flag
0050 PARAMETER (nx = 65536)
0051
0052 real*8 ninr,xr(nx),xi(nx),yr,yi
0053 real*8 zr(nx),zi(nx)
0054
0055
0056
0057 IF (NRHS .NE. 3) THEN
0058 CALL MEXERRMSGTXT('erfcc_mex_jd requires 3 input arguments')
0059 ENDIF
0060 IF (NLHS .GT. 2) THEN
0061 CALL MEXERRMSGTXT('erfcc_mex_jd requires 2 output arg. or less')
0062 ENDIF
0063
0064
0065
0066 IF ((MXGETM(PRHS(1)) .NE. 1).OR.(MXGETN(PRHS(1)).NE.1)) THEN
0067 CALL MEXERRMSGTXT('Argument 1 must be a scalar')
0068 ENDIF
0069
0070 ninp = MXGETPR(PRHS(1))
0071 CALL MXCOPYPTRTOREAL8(ninp, ninr, matone)
0072 nin = INT(ninr);
0073
0074
0075 IF (nin .GT. 65536) THEN
0076 CALL MEXERRMSGTXT('nin must be <= 65536')
0077 ENDIF
0078
0079 IF (MXGETM(PRHS(2)) .NE. 1) THEN
0080 CALL MEXERRMSGTXT('Argument 2 must be a row vector')
0081 ENDIF
0082
0083 IF (MXGETM(PRHS(3)) .NE. 1) THEN
0084 CALL MEXERRMSGTXT('Argument 3 must be a row vector')
0085 ENDIF
0086
0087 IF (MXGETN(PRHS(2)) .NE. nx) THEN
0088 CALL MEXERRMSGTXT('Length of Arg. 2 must be 65536')
0089 ENDIF
0090
0091 IF (MXGETN(PRHS(3)) .NE. MXGETN(PRHS(2))) THEN
0092 CALL MEXERRMSGTXT('Arg. 1 and 2 must have the same size')
0093 ENDIF
0094
0095
0096
0097 PLHS(1) = MXCREATEDOUBLEMATRIX(matone,nx,0)
0098 PLHS(2) = MXCREATEDOUBLEMATRIX(matone,nx,0)
0099
0100
0101
0102 zrp = MXGETPR(PLHS(1))
0103 zip = MXGETPR(PLHS(2))
0104
0105 xrp = MXGETPR(PRHS(2))
0106 xip = MXGETPR(PRHS(3))
0107
0108
0109
0110
0111 CALL MXCOPYPTRTOREAL8(xrp, xr, nx)
0112 CALL MXCOPYPTRTOREAL8(xip, xi, nx)
0113
0114
0115
0116
0117 do 10 i=1,nin
0118
0119 CALL WOFZ(xr(i),xi(i),yr,yi,flag)
0120
0121
0122
0123 zr(i) = yr
0124 zi(i) = yi
0125 10 continue
0126
0127
0128 zr(i) = 0.0
0129 zi(i) = 0.0
0130 20 continue
0131
0132
0133 CALL MXCOPYREAL8TOPTR(zr, zrp, nx)
0134 CALL MXCOPYREAL8TOPTR(zi, zip, nx)
0135
0136 RETURN
0137 END