
This is a partial implementation of the Matlab MEX interface for use
in Octave.  It is only intended to support existing MEX functions, not
write new ones.  That's because every piece of data passed to and
returned from mexFunction and mexCallMATLAB must be copied (but see
TODO).

See INSTALL for instructions on how to build the mex support library.

Then for each mex-file blah.f or blah.c that you have, do
    mex name.c othersrc.c otherobj.o -L/other/lib/path -lotherlib
Put name.oct somewhere on your Octave LOADPATH and you are done.

The shell script mex creates an octave DLD file mex_name.cc which
handles the interface between Octave and the symbol mexFunction.

If you would normally use -V4 as one of your mex options, use -DV4 
instead.  This will select the Matlab version 4 interface rather than
the Matlab version 5 interface.

There are two test programs:
    myfeval is a poor implementation of feval which exercises
	the mexCallMATLAB function
    myset tests mexGetArray and mexPutArray; call it with a
	variable name and a value, and it will show the current
	value for the variable in the caller and the global space,
	and set the new value in the caller space.

NOTE: for ELF systems running older versions of octave (2.1.57 and earlier), 
you will need to include the -Wl,-Bsymbolic on the link line for the mex 
file explicitly, otherwise only one mex file can be loaded at a time.  
Check the output of

	mkoctfile -p DL_LDFLAGS

If it is empty, use:

    SH_LDFLAGS="`mkoctfile -p SH_LDFLAGS` -Wl,-Bsymbolic" mex ...

If it does not contain -Wl,-Bsymbolic, use:

    DL_LDFLAGS="`mkoctfile -p DL_LDFLAGS` -Wl,-Bsymbolic" mex ...

This is Bourne shell syntax.  If using something else, adjust appropriately.


The following functions are implemented:

Types
*   mxComplexity (enumerated type: mxREAL, mxCOMPLEX)
*   mxArray

User supplied information
*   mexFunctionName
*   mexFunction

Interpreter services
*   mexCallMATLAB 
*   mexEvalString 
*   mexSetTrapFlag 
*   mexErrMsgTxt 
*   mexWarnMsgTxt 
*   mexPrintf 

Memory management
*   mxMalloc 
*   mxCalloc 
*   mxRealloc 
*   mxFree 
*   mexMakeMemoryPersistent 

Array creation/destruction
*   mxCreateDoubleMatrix 
*   mxCreateFull
*   mxDestroyArray 
*   mxFreeMatrix
*   mexMakeArrayPersistent 

Array type
*   mxIsFull
*   mxIsEmpty 
*   mxIsNumeric 
*   mxIsComplex 
*   mxIsSparse 

Array data
*   mxGetM 
*   mxGetN 
*   mxGetPi 
*   mxGetPr 
*   mxSetM 
*   mxSetN 
*   mxSetPi 
*   mxSetPr 
*   mxGetScalar
*   mxGetNumberOfDimensions 

IEEE floating point support
*   mxGetEps 
*   mxGetInf 
*   mxGetNaN 
*   mxIsFinite 
*   mxIsInf 
*   mxIsNaN 
*   mexGetEps
*   mexGetInf
*   mexGetNaN
*   mexIsFinite
*   mexIsInf
*   mexIsNaN

String support
*   mxIsChar 
*   mxIsString
*   mxCreateString 
*   mxGetString 
*   mxArrayToString 
*   mxCreateCharMatrixFromStrings 


Symbol table manipulation
x   mexPutArray 
*   mexGetArray 
*   mexGetArrayPtr 
*   mexPutMatrix
*   mexGetMatrix
*   mexGetMatrixPtr
*   mexGetGlobal
*   mxGetName 
*   mxSetName 

Struct support
*   mxIsStruct 
?   mxCreateStructMatrix 
*   mxGetNumberOfFields 
*   mxGetField 
*   mxGetFieldByNumber 
*   mxGetFieldNameByNumber 
*   mxGetFieldNumber 
?   mxSetField 
?   mxSetFieldByNumber 


The following functions are not implemented:

Types
x   mxClassID 
x   mxChar 

Interpreter services
x   mexAddFlops 
x   mexAtExit 
x   mexUnlock 
x   mexIsLocked 
x   mexLock 

Debugging
x   mxAssert 
x   mxAssertS 

Plot controls
x   mexGet 
x   mexSet 

Data manipulation
x   mxSetAllocFcns 
x   mxDuplicateArray 
x   mxIsFromGlobalWS 
x   mexIsGlobal 
x   mexPutFull
x   mexGetFull

Generic data handling
x   mxGetClassID 
x   mxGetNumberOfElements 
x   mxGetElementSize 
x   mxGetData 
x   mxSetData 
x   mxGetImagData 
x   mxSetImagData 

Precision support
x   mxCreateNumericMatrix 
x   mxIsSingle 
x   mxIsDouble 
x   mxIsInt8 
x   mxIsInt16 
x   mxIsInt32 
x   mxIsUint8 
x   mxIsUint16 
x   mxIsUint32 

Boolean support
x   mxIsLogical 
x   mxSetLogical 
x   mxClearLogical 

n-D arrays
x   mxCreateNumericArray 
x   mxCreateCharArray 
x   mxCreateStructArray 
x   mxCreateCellArray 
x   mxCalcSingleSubscript
x   mxSetDimensions 
x   mxGetDimensions 

Cell array support
x   mxIsCell 
x   mxCreateCellMatrix 
x   mxSetCell 
x   mxGetCell 

Sparse support
x   mxCreateSparse 
x   mxGetNzmax 
x   mxSetNzmax 
x   mxGetIr 
x   mxGetJc 
x   mxSetIr 
x   mxSetJc 

Object support
x   mxIsClass 
x   mxGetClassName 
x   mxSetClassName 

MAT file interface
x   matClose 
x   matDeleteArray 
x   matGetArray 
x   matGetArrayHeader 
x   matGetDir 
x   matGetFp 
x   matGetNextArray 
x   matGetNextArrayHeader 
x   matOpen 
x   matPutArray 
x   matPutArrayAsGlobal 

MAT file interface (V4 functions)
x   matDeleteMatrix 
x   matGetFull
x   matGetMatrix
x   matGetNextMatrix
x   matGetString
x   matPutFull
x   matPutMatrix
x   matPutString

DDE Interface
x   ddeadv 
x   ddeexec 
x   ddeinit 
x   ddepoke 
x   ddereq 
x   determ 
x   ddeunadv 

The following compute engine routines are implemented by Jesse Bennet in
liboct-0.1 <http://www.octave.org/octave/mailing-lists/help-octave/1999/549>

*   engClose 
*   engEvalString 
*   engOpen 
*   engOutputBuffer 
*   engGetFull
*   engPutFull

The following compute engine routines are missing

x   engOpenSingleUse 
x   engGetArray 
x   engPutArray 
x   engGetMatrix
x   engPutMatrix
x   engSetEvalCallback
x   engSetEvalTimeout
x   engWinInit

The following FORTRAN routines are implemented

*   mexFunction
*   mexPrintf
*   mexErrMsgTxt
*   mexCallMATLAB

*   mexGetEps
*   mexGetInf
*   mexGetNaN
*   mexIsFinite
*   mexIsInf
*   mexIsNaN

*   mxMalloc
*   mxCalloc
*   mxFree

*   mxCreateFull
*   mxFreeMatrix

*   mxGetM
*   mxGetN
*   mxGetPr
*   mxGetPi

*   mxSetM
*   mxSetN
*   mxSetPr
*   mxSetPi

*   mxIsComplex
*   mxIsDouble
*   mxIsNumeric
*   mxIsFull
*   mxIsSparse

*   mxGetString
*   mxIsString

*   mxCopyComplex16ToPtr
*   mxCopyPtrToComplex16
*   mxCopyReal8ToPtr
*   mxCopyPtrToReal8

The following fortran routines are not implemented

x   mexSetTrapFlag
x   mexEvalString

x   mexGetGlobal
x   mexGetFull
x   mexPutFull
x   mexGetMatrix
x   mexPutMatrix
x   mexGetMatrixPtr

x   mxCopyPtrToCharacter
x   mxCopyCharacterToPtr
x   mxCopyPtrToInteger4
x   mxCopyInteger4ToPtr

x   mxCreateSparse
x   mxCreateString
x   mxFreeMatrix
x   mxGetName

x   mxGetNzmax
x   mxGetIr
x   mxGetJc
x   mxSetNzmax
x   mxSetIr
x   mxSetJc

x   mxGetScalar
