#ifndef MATRIX_H
#define MATRIX_H
#include <std.h>

#define M_NORM	1
#define M_DIAG	2
#define M_SYMM	3
#define M_UTRI	4
#define M_LTRI	5

struct m_matrix	{
	int m_m, m_n;
	TINY m_type;
	TBITS	m_wflg;
	double *m_mat;
	};

#define M_WIPEME	1
typedef struct m_matrix matrix;

int badmat(matrix a);
matrix dcmakem(char *array,int m,int n,int type);
matrix ddmakem(double *array,int m,int n,int type);
matrix dentermat(matrix a,char *heading);
matrix dfmakem(float *array,int m,int n,int type);
matrix dimakem(int *array,int m,int n,int type);
matrix dlmakem(long *array,int m,int n,int type);
matrix dmadd(matrix a,matrix b);
matrix dmatinv(matrix m,double *pd);
matrix dmmult(matrix a,matrix b);
matrix dmscalm(matrix a,double scalar);
double dmtrace(matrix a);
matrix dmtrans(matrix m);
matrix dmwipe(matrix a);
matrix dputelem(double x,matrix a,int r,int c);
matrix dsettype(matrix m,int type);
double getelem(matrix m,int r,int c);
int kputelem(double x,matrix a,int r,int c);
matrix madd(matrix a,matrix b);
matrix makemat(int m,int n,int type,char *heading);
matrix devec(matrix m,matrix *v);
matrix mevec(matrix m,matrix *v);
matrix matinv(matrix a,double *pd);
matrix mcopy(matrix a);
int mfree(matrix a);
matrix midentity(int n);
double mmdot(matrix a,matrix b);
double dmdot(matrix a,matrix b);
matrix mminus(matrix a,matrix b);
matrix dmminus(matrix a,matrix b);
matrix mmult(matrix a,matrix b);
static  void fwn(matrix a,matrix b,double *pc);
matrix mscalm(matrix a,double scalar);
double mtrace(matrix a);
matrix mtrans(matrix a);
matrix nullmat(void );
void fprintmat(struct _iobuf *fp,matrix a,char *heading);
void printmat(matrix a,char *s);
matrix putelem(double x,matrix a,int r,int c);
matrix settype(matrix a,int type);
unsigned short sizmat(matrix a);
#endif
