/* AMTieee.library v. 1.02 Include File */

#ifndef AMT_H
#define AMT_H

enum {	MATROW,MATCOL,		/* flags to point to row or column dim */
	TOTALDIMS};

enum {	ROWCOL=1,COLCOL,	/* flags to identify matrix multiplying */
	COLROW,ROWROW,		/* method. 0 reserved to error condition */
	TOTALPERID};

enum {	PER=1,PERCOL,		/* some other names for the same flags */
	PERROW=ROWROW};		/* just to avoid everyone using ign=79 */

enum {	PLUS=TOTALPERID,	/* Debug flags to use within checkdim */
	POWER,INV,COPY,SQUARE,
	TRS,TOTALDEBUGFLAGS};

enum {	INTFMT,FLOATFMT};	/* flags used to point number format */


enum {	ALLVAR,CHOOSE};		/* configure matinp & file2matrix */

enum {	AMT_RUN,AMT_FIRST,	/* configure iterative methods */
	AMT_ITERATE,AMT_LAST,
	TOTALAMTFLAGS};		

#define MAXFILEFIELDS	100	/* max number of file fields allowed */

#define DEFTERMCOLS	78	/* default terminal columns */
#define DEFTERMROWS	24	/* default terminal rows */

#include "AMT:amtieee_protos.h"

#define AMTNAME	"amtieee.library"

/************************************************/
/*                                              */
/*   Matrix and Matrix Functions Definitions    */
/*                                              */
/************************************************/

struct matrix  {
        double  **mt;
        UWORD  rows, cols;
};

struct matfunc  {
        double  (***mt)();
        UWORD  rows, cols;
};

/************************************************/
/*                                              */
/*   Matrix Dimension Debug Functions           */
/*                                              */
/************************************************/

/* Sorry! still no debug support for these functions! */

#define MatTrace mattrace
#define MatCopyRd matcopyrd
#define MatTransform mattransform
#define SetTransform settransform
#define MatInv matinv
#define MatAvl matavl
#define MatStd matstd
#define MatInp matinp
#define ChooseMatVar choosematvar
#define OpenMatFile openmatfile

/* While for these other functions debug is not required or has no sense */

#define AllocMat allocmat
#define AllocMatMem allocmatmem
#define AllocMatCopy allocmatcopy
#define FreeMat freemat
#define FreeMatMem freematmem
#define GetArray getarray
#define GetDim getdim
#define GetPrecision getprecision
#define GetIterations getiterations
#define GetSeed getseed
#define GetEpsilon getepsilon
#define GetFormat getformat
#define GetMatPerId getmatperid
#define GetLastPrecision getlastprecision
#define GetLastIteration getlastiteration
#define GetFuncDim getfuncdim
#define GetFuncArray getfuncarray /* Sorry this function does not work */
#define SetPrecision setprecision
#define SetIterations setiterations
#define SetMatPerId setmatperid
#define SetTerm setterm
#define MatEq mateq
#define MatZer matzer
#define MatScal matscal
#define File2Matrix file2matrix
#define PrintUsing printusing
#define MatPrint matprint
#define MatRawPrint matrawprint
#define MatRandom matrandom
#define AllocFuncMat allocfuncmat
#define AllocFuncMatMem allocfuncmatmem
#define AllocFuncMatCopy allocfuncmatcopy
#define FreeFuncMat freefuncmat
#define FreeFuncMatmem freefuncmatmem
#define LoadMatFunc loadmatfunc
#define MatFuncNull matfuncnull
#define MatFuncEq matfunceq

/* and of course for debug functions themselves! */

#define MatDbg matdbg
#define CheckDim checkdim

#if MYDEBUG /* Debug alternative functions */

#define MatPlus(A,B,C) {D(bug("matplus\n")); if(checkdim(A,B,C,PLUS)) matplus(A,B,C); }
#define MatPer(A,B,C) {D(bug("matper\n")); if(checkdim(A,B,C,getmatperid())) matper(A,B,C); }
#define MatRowCol(A,B,C) {D(bug("matrowcol\n")); if(checkdim(A,B,C,PER)) matrowcol(A,B,C); }
#define MatPower(A,B) {D(bug("matpower\n")); if(checkdim(A,B,NULL,POWER)) matpower(A,B); }
#define MatIdn(A) {D(bug("matidn\n")); if(checkdim(A,NULL,NULL,SQUARE)) matidn(A); }
#define MatSymm(A,B,C) {D(bug("matsymm\n")); if(checkdim(A,B,C,PLUS) && checkdim(A,B,C,SQUARE)) matsymm(A,B,C); }
#define MatNorm(A,B,C) {D(bug("matnorm\n")); if(checkdim(A,NULL,NULL,SQUARE)) matnorm(A,B,C);}
#define MatTrs(A,B) {D(bug("mattrs\n")); if(checkdim(A,B,NULL,TRS)) mattrs(A,B);}
#define MatTrsRd(A) {D(bug("mattrsrd\n")); if(checkdim(A,NULL,NULL,SQUARE)) mattrsrd(A);}
#define MatCopy(A,B) {D(bug("matcopy\n")); if(checkdim(A,B,NULL,COPY)) matcopy(A,B);}
#define MatPerCol(A,B,C) {D(bug("matpercol\n")); if(checkdim(A,B,C,PERCOL)) matpercol(A,B,C);}
#define MatOrder(A,B) {D(bug("matorder\n")); if(checkdim(A,NULL,NULL,SQUARE)&&checkdim(B,NULL,NULL,SQUARE)) matorder(A,B);}
#define MatFuncIdn(A) {D(bug("matfuncidn\n")); if(checkdim((struct matrix *)A,NULL,NULL,SQUARE)) matfuncidn(A);}
#define MatFuncCopy(A,t,B) {D(bug("matfunccopy\n")); if(checkdim((struct matrix *)A,(struct matrix *)B,NULL,COPY)) matfunccopy(A,t,B);}

#else /* no debug defaults to simple function calls */

#define MatPlus matplus
#define MatPer matper
#define MatRowCol matrowcol
#define MatPower matpower
#define MatIdn matidn
#define MatSymm matsymm
#define MatNorm matnorm
#define MatTrs mattrs
#define MatTrsRd mattrsrd
#define MatCopy matcopy
#define MatPerCol matpercol
#define MatOrder matorder
#define MatFuncIdn matfuncidn
#define MatFuncCopy matfunccopy

#endif

#if MYDEBUG
#define matdbg(string,matpointer) matprint(string,matpointer)
#else
#define matdbg(string,matpointer) ;
#endif

#endif /* AMT_H */
