/*
 * @(#)mcc.h    generated by: makeheader    Fri Oct 20 12:13:30 1995
 *
 *		built from:	mccdata.h
 *				mcmdata.h
 *				libmcc0.c
 *				libmcc1.c
 *				libmcc2.c
 *				libmcc3.c
 *				libmcm0.c
 */

#ifndef mcc_h
#define mcc_h




/*
 * CONFIDENTIAL AND CONTAINING PROPRIETARY TRADE SECRETS
 * Copyright (c) 1984 by The MathWorks, Inc.
 * The source code contained in this listing contains proprietary and
 * confidential trade secrets of The MathWorks, Inc.   The use, modification,
 * or development of derivative work based on the code or ideas obtained
 * from the code is prohibited without the express written permission of The
 * MathWorks, Inc.  The disclosure of this code to any party not authorized
 * by The MathWorks, Inc. is strictly forbidden.
 * CONFIDENTIAL AND CONTAINING PROPRIETARY TRADE SECRETS
 */

/*
 * This is the include file for the PC which tells compilers how
 * to return doubles.
 * NB:  If names of functions change or new functions which return
 *      doubles are added, they must be added to this file.
 */
#ifdef __WATCOMC__
#ifndef MATLAB_MEX_FILE
#include "doubret.h"
#endif
#endif
/*
 *	Define the matrix structure agreeing with the Matlab V4.2c matrix structure.
 *  Here are the typedefs needed.
 */

#define mxMAXNAM    20		/* maximum name length */
#define mxMAXTAG     4      /* maximum tag length */
#define mxMAXDIM     2      /* unused: replaced by m and n */
#define mxMAXARG    50      /* max # of args: compiler currently supports 32 */

#define mxFULL (0L)			/* for full matrices */
#define mxSPARSE (1L)		/* for sparse matrices */
#define mxDOUBLE (0L)		/* the only valid value for the compiler */
#define mxNUMBER (0L)		/* display as a number */
#define mxSTRING (1L)		/* display as a string */

/*
 *  Here is the matrix structure itself.
 *  Because there is a 'typedef struct matrix Matrix;' in force, all uses
 *  of Matrix will now refer to this structure.
 */

#if defined(THINK_C) || defined(applec)
typedef unsigned char ENUM_SIZE;
#define PAD_ENUM unsigned char :8;
#else
typedef int ENUM_SIZE;
#define PAD_ENUM
#endif

struct matrix
{
	char name[mxMAXNAM];			/* name */
	ENUM_SIZE struc;				/* should be 0 for full matrices */
	ENUM_SIZE type;					/* should be 0 always */
	ENUM_SIZE dmode;				/* number or string */
	PAD_ENUM
	/* original is char tag[mxMAXTAG];			*/	
	int tags;						/* unused by compiler or interpreter */
	int m;							/* number of rows */
	int n;							/* number of columns */
	double *pr;						/* base of allocated storage */
	double *pi;						/* base of imaginary part  */
	int alloc;						/* number of doubles allocated in pr */

	/* go to this trouble to make sure that the structure is the same size */
	/* even if pointers are bigger than ints */

	int flags;						/* flag bits for the compiler */
	char dummy[ 2*sizeof(int *) - sizeof(int) ];  /* try to pad out */
};

/*
 *  Here are flags for the 'flags' field in the matrix structure.
 *  Note: must not use the mxSTRING bit in this field.
 */

#define	mccCOMPLEX	0x02	/* matrix is complex */
#define mccSTATIC	0x04	/* matrix is static */
#define mccNOTSET	0x08	/* matrix is not initialized */
#define mccSET      0x10    /* variable has been set */
#define mccNOTFIRST 0x20    /* output variable is not the first one */

/*
 *	For standalone code, do not include mex.h.
 *  Use local definitions for Matrix, etc.
 */

#ifdef __WATCOMC__
#undef mexGetEps
#undef mexGetInf
#endif

double mexGetInf();
double mexGetNaN();
double mexGetEps();

/*
 *  Macro to initialize matrix that has never been set.
 */

#define mccINITIALIZE(p) if( (p)->flags & mccNOTSET ) { \
	int f = (p)->flags; *(p) = mccInitialMatrix; (p)->flags=(f & ~mccNOTSET); }

/*
 *	Functions to simulate nargin() and nargout().
 */

#define mccNargin() nrhs_
#define mccNargout() nlhs_

/*
 *	Macro for 'zeros(n)', n an integer.
 */

#define mccZerosN( p, n ) mccZerosMN( p, n, n )

/*
 *	Macro for 'clear' (this does nothing in compiled code).
 */

#define mccClear()

/*
 *	Define the 'i' and 'j' functions (sqrt(-1)).
 */

#define mccI(p,q) { *p=0.; *q=1.; }
#define mccJ(p,q) { *p=0.; *q=1.; }

/*
 *	Macros for converting 0-1 subscripts to index arrays.
 */

#define mccFindMatrixIndex(q,p,r) mccFindIndex(q,p,r,0)
#define mccFindColumnIndex(q,p,r) mccFindIndex(q,p,r,1)
#define mccFindRowIndex(q,p,r) mccFindIndex(q,p,r,2)
 
/*
 *	Macro defining sum that returns an integer scalar.
 */

#define IntRealVectorSum( m ) ((int)mccRealVectorSum( m ))

/*
 *  Initialization macros for local variables.
 */

#define mccRealInit(x) x.flags = mccNOTSET; x.dmode = mxNUMBER
#define mccComplexInit(x) x.flags=(mccNOTSET|mccCOMPLEX); x.dmode=mxNUMBER

void mexErrMsgTxt( const char * );	/* print error messages */




/*
 * CONFIDENTIAL AND CONTAINING PROPRIETARY TRADE SECRETS
 * Copyright (c) 1984 by The MathWorks, Inc.
 * The source code contained in this listing contains proprietary and
 * confidential trade secrets of The MathWorks, Inc.   The use, modification,
 * or development of derivative work based on the code or ideas obtained
 * from the code is prohibited without the express written permission of The
 * MathWorks, Inc.  The disclosure of this code to any party not authorized
 * by The MathWorks, Inc. is strictly forbidden.
 * CONFIDENTIAL AND CONTAINING PROPRIETARY TRADE SECRETS
 */

/* contains data definitions for the mcm library */

/*
 *	To get rid of the 'public' and 'package' keywords.
 */

#define public
#define package

/*
 *	'real' and 'imag' functions for scalar complex variables.
 */

#define mcmReal( x, y )    (x)
#define mcmImag( x, y )    (y)

/*
 *	Simple integer and real remainder functions.
 */

#define mcmIntRem( x, y )     ((y)?(((int)(x))%((int)(y))):0x7FFFFFFF)
#define mcmRealRem( x, y )     fmod(x,y)

/*
 *	Macro defining int^int in terms of real^int.
 */

#define mcmIntPowerInt( m, n ) ((int)mcmRealPowerInt( (double)(m), (n) ))

/*
 *	Macro defining sqrt(int n) in terms of the C sqrt function.
 */

#define mcmIntSqrt( n ) sqrt( (double)(n) )

/*
 *	Macro defining left complex division in terms of right complex division
 *	(for scalars).
 */

#define mcmLeftDivide( p, q, a, b, c, d) mcmDivide( p, q, c, d, a, b );

/*
 *	Macros defining isnan, isinf, isfinite for complex scalars.
 */

#define mcmIsNaN(re,im) (mexIsNaN(re) || mexIsNaN(im))
#define mcmIsInf(re,im) (mexIsInf(re) || mexIsInf(im))
#define mcmIsFinite(re,im) (mexIsFinite(re) && mexIsFinite(im))

#ifdef __WATCOMC__
#undef mexGetEps
#undef mexGetInf
#endif

/*
 *  mcmEps1 handles the 'eps(1)' case (archaic).
 */
#define mcmEps1(x) mcmEps()

/***********  SUPPORT FOR DEBUGGING MEMORY ALLOCATION **************/

/*
#define mcmDEBUGflag
*/

#ifdef mcmDEBUGflag

void *mcmDBCalloc(int,int); 
void mcmDBFree( void *, int, int );
void mcmDBCheck( void *, int, int );
void mcmEnter();
void mcmReturn();

#define mcmCalloc(m) mcmDBCalloc(m, __LINE__ )
#define mcmFree(p, n) mcmDBFree( p, n, __LINE__ );  
#define mcmCallocCheck(p,n) mcmDBCheck( p, n, __LINE__ );

#else

#define mcmCalloc(m) mxCalloc(m,8)
#define mcmFree(p,n) if( (n)>0 )mxFree(p)
#define mcmCallocCheck(p,n)

#endif


/*
 *  Used to initialize the automatic Matrix structures.
 */
extern Matrix mccInitialMatrix;


/*
 *  Empty constant matrix.
 */
extern Matrix C_Empty_;


/*
 *	Import a MATLAB matrix.  Optionally free the MATLAB matrix.
 */
extern void
mccImport( Matrix *p, Matrix *q, int flg, int line );


/*
 *	Import a MATLAB matrix, making a copy so we can change it.
 *  Optionally free the MATLAB data structure.
 */
extern void
mccImportCopy( Matrix *p, Matrix *q, int flg, int line );


/*
 *	Like mxGetScalar, but checks that the value really is a real scalar.
 *  Frees the return matrix after getting the value.
 *	If there the dimension is not 1x1 or there is a complex part,
 *	a fatal error is produced.
 */
extern double
mccGetReal( int *pflag, Matrix *q, char *ss );


/*
 *	Like mxGetScalar, but checks that the value really is a real scalar.
 *	If there the dimension is not 1x1 or there is a complex part,
 *	a fatal error is produced.
 */
extern double
mccImportReal( int *pflag, Matrix *q, char *ss );


/*
 *	Like mxGetScalar, but checks that the value really is a (complex) scalar.
 *  Frees the return matrix after getting the value.
 *	If there the dimension is not 1x1 or there is a complex part,
 *	a fatal error is produced.
 */
extern double
mccGetScalar( double *p, int *pflag, Matrix *q, char *ss );


/*
 *	Like mxGetScalar, but checks that the value really is a (complex) scalar.
 *	If there the dimension is not 1x1 or there is a complex part,
 *	a fatal error is produced.
 */
extern double
mccImportScalar( double *p, int *pflag, Matrix *q, char *ss );


/*
 *	Create an mxn array, p.
 *  If the complex flag of p is on, the created matrix is complex.
 *  If the returned space is not zeroed (e.g., reuse of older space)
 *  The function returns 1; otherwise, it returns 0.
 */
extern int
mccAllocateMatrix( Matrix *p, int m, int n );


/*
 *  Routine to free a matrix.
 */
extern void
mccFreeMatrix( Matrix *p );


/*
 *	Internal version of a=length(b).
 */

extern int
mccGetLength( Matrix *p );


/*
 *	Internal version of a=isempty(b).
 */
extern int
mccIsEmpty( Matrix *p );


/*
 *  Internal version of isempty for integer scalar inputs
 */
extern int
mccIntIsEmpty( int n );


/*
 *  Internal version of isempty for scalar inputs
 */
extern int
mccScalarIsEmpty( double re, double im );


/*
 *	Internal version of [m,n] = size(a).
 */
extern void
mccGetMatrixSize( int *pm, int *pn, Matrix *p );


/*
 *	Internal version of a = size(b,n).
 */
extern int
mccGetDimensionSize( Matrix *p, int nn );


/*
 *	Internal version of a=size(b).
 */
extern void
mccSize( Matrix *p, Matrix *q );


/*
 *	Grow a 1-dimensional array p to have size mn.
 */
extern void
mccGrowVector( Matrix *p, int mn );


/*
 *	Grow a 2-dimensional array p to have size mxn.
 *	Don't even try to grow in place for 2-d arrays.
 *	However, if it looks like a 1d array would work, call mccGrowVector.
 */
extern void
mccGrowMatrix( Matrix *p, int m, int n );


/*
 *	Check size of 1-dimensional array assignment.
 */
extern void
mccCheckVectorSize( Matrix *p, int mn );


/*
 *  Check the sizes of an assignment to a(:).
 */
extern void
mccColonOnLhs( Matrix *p, int mn );


/*
 *	Check size of 2-dimensional array assignment.
 */
extern void
mccCheckMatrixSize( Matrix *p, int m, int n );


/*
 *	Return the maximum element in an index array p.
 *  Account for the possibility that the array is a 0-1 array.
 */
extern int
mccGetMaxIndex( Matrix *p, int asz );


/*
 *	calculates dimensions of a(b).
 */
extern int
mccCalcSubscriptDimensions( int mm, int *pn, int bm, int bn, Matrix *p );


/*
 *	Implements 'ones(a)'.
 */
extern void
mccOnes( Matrix *p, Matrix *q );


/*
 *	Implements 'ones(m,n)'.
 */
extern void
mccOnesMN( Matrix *p, int m, int n );


/*
 *	Implements zeros(x), for x a matrix.
 */
extern void
mccZeros( Matrix *p, Matrix *q );


/*
 *	Implements zeros(m,n), m and n integers.
 */
extern void
mccZerosMN( Matrix *p, int m, int n );


/*
 *	Make p a matrix of zeros of the same shape as q.
 */
extern void
mccZerosCopyShape( Matrix *p, Matrix *q );


/*
 *	Return 1 if matrix p has nontrivial imaginary part.
 */
extern int
mccIsImag( Matrix *p );


/*
 *  This routine returns the first argument of a function.
 *  Note that the semantics are slightly different for the first
 *  argument if the output argument has never been set.
 */
extern void
mccReturnFirstValue( Matrix **qin, Matrix *p );


/*
 *	Return the second and later return values from a compiled function.
 */
extern void
mccReturnValue( Matrix **qin, Matrix *p );


/*
 *  Create and return a scalar quantity.
 *  The flag describes various situations:
 *      If mxSTRING or mccSET is on, the varible has been set.
 *      The mccCOMPLEX bit is true if the result is to be complex
 *           (otherwise, im must be 0).
 *      The mccNOTFIRST bit is true if the result is not the 1st output argument
 *           (this affects whether a null or an empty matrix is returned
 *           if the value was never set).
 *      The mxSTRING bit is true if the result is a string.
 */
extern void
mccReturnScalar( Matrix **qin, double re, double im, int flag );


/*
 *	Implement 'real' of a matrix.
 */
extern void
mccReal( Matrix *p, Matrix *q );


/*
 *	Implement 'imag' of a matrix.
 */
extern void
mccImag( Matrix *p, Matrix *q );


/*
 *	Create p equal to lo:hi.
 */
extern void
mccColon2( Matrix *p, double lo, double hi );


/*
 *	Create p equal to lo:step:hi.
 */
extern void
mccColon( Matrix *p, double lo, double step, double hi );


/*
 *	Version of colon2 that accepts complex matrices.
 */
extern void
mccMatrixColon2( Matrix *p, Matrix *q, Matrix *r );


/*
 *	Version of colon that accepts complex matrices.
 */
extern void
mccMatrixColon( Matrix *p, Matrix *q, Matrix *r, Matrix *s );


/*
 *	Store the real value (re) in the (i,j)'th element of p.
 *	Check the current size, and grow if necessary.
 */
extern void
mccSetRealMatrixElement( Matrix *p, int i, int j, double re );


/*
 *	Store the real value (re) in the i'th element of p.
 *	Check the current size, and grow if necessary.
 */
extern void
mccSetRealVectorElement( Matrix *p, int i, double re );


/*
 *	Make p a 1x1 matrix and store the value (re) in the (1,1) element.
 */
extern void
mccCreateRealScalar( Matrix *p, double re );


/*
 *	Store the value (re+i*im) in the (i,j)'th element of p.
 *	Check the current size, and grow if necessary.
 */
extern void
mccSetMatrixElement( Matrix *p, int i, int j, double re, double im );


/*
 *	Store the value (re+i*im) in the i'th element of p.
 *	Check the current size, and grow if necessary.
 */
extern void
mccSetVectorElement( Matrix *p, int i, double re, double im );


/*
 *	Replace p by a 1x1 matrix, and store (re+i*im) in the (1,1) element.
 */
extern void
mccCreateScalar( Matrix *p, double re, double im );


/*
 *	Expand the scalar re+i*im into matrix p whose dimension is given by q.
 */
extern void
mccCreateConstantMatrix( Matrix *p, double re, double im, Matrix *q );


/*
 *	Expand the scalar re+i*im into matrix p whose dimensions are given by
 *  the matrices (of ones) q and r.
 */
extern void
mccCreateConstant2DMatrix( Matrix *p, double re, double im, Matrix *q,Matrix *r);


/*
 *	Expands the scalar re into a matrix p whose dimension is given by q.
 */
extern void
mccCreateRealConstantMatrix( Matrix *p, double re, Matrix *q );


/*
 *	Expands the scalar re into a matrix p whose dimensions are given by
 *  the matrices (of ones) q and r.
 */
extern void
mccCreateRealConstant2DMatrix( Matrix *p, double re, Matrix *q, Matrix *r );


/*
 *	Return element (i,j) of the real part of matrix p.
 */
extern double
mccGetRealMatrixElement( Matrix *p, int i, int j );


/*
 *	Return element i of the real part of matrix p.
 */
extern double
mccGetRealVectorElement( Matrix *p, int i );


/*
 *  Convert one element of a vector into a scalar matrix; preserve string flag.
 */
extern Matrix *
mccTempVectorElement( Matrix *p, double di );


/*
 *  Convert one element of a matrix into a scalar matrix; preserve string flag.
 */
extern Matrix *
mccTempMatrixElement( Matrix *p, double di, double dj );


/*
 *	Return the imaginary part of element (i,j) of matrix p.
 */
extern double
mccGetImagMatrixElement( Matrix *p, int i, int j );


/*
 *	Return the imaginary part of element i of matrix p.
 */
extern double
mccGetImagVectorElement( Matrix *p, int i );


/*
 *	Return a <very> temporary MATLAB matrix, good only for a callback.
 */
extern Matrix *
mccTempMatrix( double re, double im, int cx );


/*
 *	Return a temporary MATLAB matrix containing string s.
 *  This is good only for callbacks.
 */
extern Matrix *
mccTempMATStr( char *s );


/*
 *  Print the matrix passed as the first argument with a label given by
 *  the second.  Intended for debugging (not all matrix elements printed).
 */
extern void
mccDEBUG( Matrix *p, char *ss );


/*
 *	Does what Matlab does in if's of arrays.
 *  Note: this is subtly different from all(all(p)).
 */
extern int
mccIfCondition( Matrix *p );


/*
 *	Copy matrix q into matrix p.
 */
extern void
mccCopy( Matrix *p, Matrix *q );


/*
 *	Copy the string s into the matrix p.
 */
extern void
mccCreateString( Matrix *p, char *s );


/*
 *	Implements 'setstr'.
 */
extern void
mccSetString( Matrix *p, Matrix *q );


/*
 *	Implements isstr.
 */
extern int
mccIsString( Matrix *q );


/*
 *	implements ppp = [a,b].
 */
extern void
mccCatenateColumns( Matrix *ppp, Matrix *a, Matrix *b );


/*
 *	Implement pp = [a;b].
 */
extern void
mccCatenateRows( Matrix *pp, Matrix *a, Matrix *b );


/*
 *	Generate column of data for a 'for' statememtn.
 */
extern void
mccForCol( Matrix *p, Matrix *q, int n );


/*
 *	Remove the elements of p indicated by r.  Put the result in q.
 */
extern void
mccZapElements( Matrix *q, Matrix *p, Matrix *r );


/*
 *	Remove the rows of p indicated by r.  Put the result in q.
 */
extern void
mccZapRows( Matrix *q, Matrix *p, Matrix *r );


/*
 *	Remove the columns of p indicated by r.  Put the result in q.
 */
extern void
mccZapColumns( Matrix *q, Matrix *p, Matrix *r );


/*
 *  q is set to p unless p is all 0's and 1's and its size matches r
 *  In this case, q is set to find(p).
 *  If the type is 0, the matched size is r->m * r->n (matrix index).
 *  If the type is 1, the matched size is r->m (column index).
 *  If the type is 2, the matched size is r->n (row index).
 */
extern void
mccFindIndex( Matrix *q, Matrix *p, Matrix *r, int type );


/*
 *	Convert a compiler matrix into a C string (for use with feval only).
 */
extern char *
mccGetString( Matrix *p );


/*
 *	Make p into an empty matrix.
 */
extern void
mccCreateEmpty( Matrix *p );


/*
 *  Complain about the use of a function argument not present
 *  This function is for the case where the value is used
 */
extern void
mccUndefVariable( Matrix *p, Matrix *s );


/*
 *  Complain about a use of a function argument not present in the call.
 */
extern void
mccUndefVariable1( Matrix *s );


/*
 *	Absolute value function.
 */
extern void
mccAbs( Matrix *ppp, Matrix *q );


/*
 *	Inner product of two real vectors.
 */
extern double
mccRealInnerProduct( Matrix *p, Matrix *q );


/*
 *	Integer value of integer inner product.
 */
extern int
mccIntInnerProduct( Matrix *p, Matrix *q );


/*
 *  Complex inner product of two complex vectors.
 */
extern void
mccInnerProduct( double *re, double *im, Matrix *p, Matrix *q );


/*
 *	Implements 'any' function.
 */
extern void
mccAny( Matrix *p, Matrix *q );


/*
 *	Implements 'any' function returning a scalar integer.
 */
extern int
mccIntAny( Matrix *q );


/*
 *	Implements 'all' function.
 */
extern void
mccAll( Matrix *p, Matrix *q );


/*
 *	Implements 'all' function returning a scalar integer.
 */
extern int
mccIntAll( Matrix *q );


/*
 *	Implements Conjugate Transpose function.
 */
extern void
mccConjTrans( Matrix *ppp, Matrix *q );


/*
 *	Implements Transpose operator.
 */
extern void
mccTrans( Matrix *ppp, Matrix *q );


/*
 *	Implements Complex matrix multiply.
 */
extern void
mccMultiply( Matrix *ppp, Matrix *q, Matrix *r );


/*
 *	Implements Real matrix multiply.
 */
extern void
mccRealMatrixMultiply( Matrix *ppp, Matrix *q, Matrix *r );


/*
 *	Implements 'fix' function.
 */
extern void
mccFix( Matrix *p, Matrix *q );


/*
 *	Implements 'round' function.
 */
extern void
mccRound( Matrix *p, Matrix *q );


/*
 *	Implements 'floor' function.
 */
extern void
mccFloor( Matrix *p, Matrix *q );


/*
 *  Implements 'ceil' function.
 */
extern void
mccCeil( Matrix *p, Matrix *q );


/*
 *	Implements 'find' function.
 */
extern void
mccFind( Matrix *pp, Matrix *q );


/*
 *	Implements 'reshape' function
 */
extern void
mccReshape( Matrix *p, Matrix *q, int m, int n );


/*
 *	Implements 'sin' function (currently, real only).
 */
extern void
mccSin( Matrix *p, Matrix *q );


/*
 *	Implements 'cos' function (currently, real only).
 */
extern void
mccCos( Matrix *p, Matrix *q );


/*
 *	Implements 'tan' function (currently, real only).
 */
extern void
mccTan( Matrix *p, Matrix *q );


/*
 *	Implements 'asin' function (currently, real only).
 */
extern void
mccAsin( Matrix *p, Matrix *q );


/*
 *	Implements 'acos' function (currently, real only).
 */
extern void
mccAcos( Matrix *p, Matrix *q );


/*
 *	Implements 'atan' function (currently, real only)
 */
extern void
mccAtan( Matrix *p, Matrix *q );


/*
 *	Implements array power (currently, real only).
 */
extern void
mccRealPower( Matrix *p, Matrix *q, Matrix *r );


/*
 *	Implements 'atan2' function (currently, real only).
 */
extern void
mccAtan2( Matrix *p, Matrix *q, Matrix *r );


/*
 *	Implements 'log10' function (currently, real only).
 */
extern void
mccLog10( Matrix *p, Matrix *q );


/*
 *	Implements 'log' function (currently, real only).
 */
extern void
mccLog( Matrix *p, Matrix *q );


/*
 *	Implements 'sqrt' function (currently, real only).
 */
extern void
mccSqrt( Matrix *p, Matrix *q );


/*
 *	Implements 'sign' function (currently, real only).
 */
extern void
mccSign( Matrix *p, Matrix *q );


/*
 *	Implements 'sum' on complex vector, returning scalar result.
 */
extern void
mccVectorSum( double *pr, double *pi, Matrix *p );


/*
 *	Implements 'sum' on real vector, returning scalar result.
 */
extern double
mccRealVectorSum( Matrix *p );


/*
 *  Implements 'sum' of a matrix (currently, real only).
 */
extern void
mccSum( Matrix *p, Matrix *q );


/*
 *	Implements scalar product of a complex vector
 */
extern void
mccVectorProduct( double *pr, double *pi, Matrix *p );


/*
 *	Implements scalar product of a real vector
 */
extern double
mccRealVectorProduct( Matrix *p );


/*
 *	Implements 'max' of a vector of integers. 
 */
extern int
mccIntMax( Matrix *p );


/*
 *	Implements 'min' of a vector of integers.
 */
extern int
mccIntMin( Matrix *p );


/*
 *	Implements 'max' of a real vector.
 */
extern double
mccRealVectorMax( Matrix *p );


/*
 *	Implements 'min' of a vector of reals.
 */
extern double
mccRealVectorMin( Matrix *p );


/*
 *  Implements 'max' of a matrix (currently, real only).
 */
extern void
mccMax( Matrix *p, Matrix *q );


/*
 *  Implements 'min' of a matrix (currently, real only).
 */
extern void
mccMin( Matrix *p, Matrix *q );


/*
 *	Implements 'strcmp' function.
 *  This will compare complex parts as well, like the interpreter version.
 */
extern int
mccStrcmp( Matrix *p, Matrix *q );


/*
 *	Implements 'findstr' function.
 *  This function works with complex arguments as well as usual strings.
 *  If the inputs are not vectors, it will sometimes return []
 *  where the usual M-file returns an error message.
 */
extern void
mccFindstr( Matrix *p, Matrix *q, Matrix *r );


/*
 *  Implement 'isletter'.
 */
extern void
mccIsLetter( Matrix *p, Matrix *q );


/*
 *  Implement 'lower'.
 */
extern void
mccLower( Matrix *p, Matrix *q );


/*
 *  Implement 'upper'.
 */
extern void
mccUpper( Matrix *p, Matrix *q );


/*
 *	C-callable version of the 'error' function.
 */
extern void
mccError( Matrix *p );


/*
 *	Get the value of global s and put it in p.
 */
extern void
mccGetGlobal( Matrix *p, Matrix *s );


/*
 *	set the global s to the value in p.
 */
extern void
mccSetGlobal( Matrix *s, Matrix *p );


/*
 *  General callback into MATLAB to run an M-file or mexfile.
 */
extern void
mccCallMATLAB( int nlhs, Matrix **plhs, int nrhs, Matrix **prhs, char *s,
														int line );


/*
 *	Implement complex array power.
 */
extern void
mccArrayPower( Matrix *p, Matrix *q, Matrix *r );


/*
 *	Implement complex matrix power.
 */
extern void
mccPower( Matrix *p, Matrix *q, Matrix *r );


/*
 *	Implement complex array right division.
 */
extern void
mccArrayRightDivide( Matrix *p, Matrix *q, Matrix *r );


/*
 *	Implement real array right division.
 */
extern void
mccRealArrayRightDivide( Matrix *p, Matrix *q, Matrix *r );


/*
 *	Implement complex matrix right division.
 */
extern void
mccRightDivide( Matrix *p, Matrix *q, Matrix *r );


/*
 *	Implement real matrix right divide.
 */
extern void
mccRealRightDivide( Matrix *p, Matrix *q, Matrix *r );


/*
 *	Implement complex array left division.
 */
extern void
mccArrayLeftDivide( Matrix *p, Matrix *q, Matrix *r );


/*
 *	Implement real array left division.
 */
extern void
mccRealArrayLeftDivide( Matrix *p, Matrix *q, Matrix *r );


/*
 *	Implement complex matrix left division.
 */
extern void
mccLeftDivide( Matrix *p, Matrix *q, Matrix *r );


/*
 *	Implement real matrix left division.
 */
extern void
mccRealLeftDivide( Matrix *p, Matrix *q, Matrix *r );


/*
 *  Stub 'eval' function that complains and dies.
 */
extern void
mccEval( Matrix *p );


/*
 *	Open the MATFile for 'save'.
 */
extern void
mccOpenMATFile( Matrix *name );


/*
 *	Close and write the MATFile for 'save'.
 */
extern void
mccCloseMATFile();


/*
 *	'save' function (modified for the compiler).
 */
extern void
mccSave( Matrix *name, Matrix *value );


/*
 *	Implement the printing of named expressions not ended by a ;.
 */
extern void
mccPrint( Matrix *p, char *s );


/*
 *  Get realmax from a local copy after the first time.
 */
extern double
mccRealmax();


/*
 *  Get realmin from a local copy after the first time.
 */
extern double
mccRealmin();


/*
 *  Output a string.
 */
extern void
mccPuts( char *s );


/*
 *  Get an argument for a standalone program
 */
extern void
mccArgv( Matrix *p, int n );


/*
 *  Get the argument count for a standalone program
 */
extern int
mccArgc();


/*
 *  Set the argc and argv arguments
 */
extern void
mccSetArgs( int argc, char **argv );


/*
 *	Line number, used by -l option (tracks the m-file line number).
 */
extern int mcmLineNumber;


/*
 *  Function returning value of pi
 */
extern double
mcmPi();


/*
 *	local copy of eps
 */
extern double mcmEpsValue;


/*
 *  Function return value of epsilon
 */
extern double
mcmEps();


/*
 *	Routine to print its argument and stop, with an m-file line number if
 *  the user compiled with the -l option.
 */
extern void
mcmError( char *ss );


/*
 *  Routine to print its argument and stop, supplying an m-file line number.
 */
extern void
mcmErrorWithLine( char *s, int line );


/*
 *  Routine to print a fatal internal error message and stop
 */
extern void
mcmFatal( char *ss );


/*
 *	Routine to print its first argument, with an internal (C++ source file)
 *  line number as well as a user (m-file) line number.  Used for debugging.
 */
extern void
mcmInternal( char *ss, int line );


/*
 *	Real raised to an integer power.
 */
extern double
mcmRealPowerInt( double d, int n );


/*
 *	Complex logarithm.
 */
extern void
mcmLog( double *par, double *pai, double br, double bi );


/*
 *	Compiler complex scalar power.
 */
extern void
mcmPower( double *par, double *pai, double br, double bi, double cr, double ci);


/*
 *	Complex divide routine.
 */
extern void
mcmDivide( double *cr, double *ci, double ar, double ai, double br, double bi );


/*
 *	Real part of a complex division.
 */
extern double
mcmDivideRealpart( double ar, double ai, double br, double bi );


/*
 *	Imaginary part of a complex division.
 */
extern double
mcmDivideImagPart( double ar, double ai, double br, double bi );


/*
 *	Check the total size of an assignment.
 */
extern void
mcmCheck( int sz1, int sz2 );


/*
 *	Array with 1 +/- 2*eps, for colon computations.
 */
extern double mcmEps2[2];


/*
 *	Number of elements in 3-argument colon expression.
 */
extern int
mcmColonCount( double lo, double step, double hi );


/*
 *	Largest element in 3-argument colon expression.
 */
extern int
mcmColonMax( double lo, double step, double hi );


/*
 *	mm and *pn are the current size of a matrix result.  A new matrix
 *  whose size is given by m and n is combined with the current size.
 *  mcmCalcResultSize returns the resulting value of m, and updates the
 *  value of n through *pn.
 */
extern int
mcmCalcResultSize( int mm, int *pn, int m, int n );


/*
 *	Hypot function.
 */
extern double
mcmHypot( double re, double im );


/*
 *	Round function.
 */
extern double
mcmRound( double d );


/*
 *  Complex Round function.
 */
extern void
mcmComplexRound( double *pr, double *pi, double qr, double qi );


/*
 *	Fix function.
 */
extern int
mcmFix( double d );


/*
 *	Constant used to convert log to log10.
 */
extern double mcmLog10Const;


/*
 *	Log10 function (real argument only).
 */
extern double
mcmLog10( double d );


/*
 *	Max of two integers.
 */
extern int
mcmIntMax( int m, int n );


/*
 *	Max of two reals.
 */
extern double
mcmMax( double m, double n );


/*
 *	Min of two integers.
 */
extern int
mcmIntMin( int m, int n );


/*
 *	Min of two reals. 
 */
extern double
mcmMin( double m, double n );


/*
 *	Sign function (real argument).
 */
extern double
mcmRealSign( double d );


/*
 *	Sign function (integer argument).
 */
extern int
mcmIntSign( int n );


/*
 *	Static allocation (uses calloc, not mxCalloc).
 */
extern void *
mcmStaticCalloc( int n );


/*
 *	Free storage allocated by mcmStaticCalloc
 */
extern void
mcmStaticFree( void *pp );

#endif /* mcc_h */
