// this matrix_h00.h file has the structures and definitions


#include "matrix_dll.h"



// structures

struct inherited {
	double trace, determinant;
	bool valid_t, valid_d; };

struct cmplx {
	double a, b; };	// a is the real-part and b is the imaginary part.

struct inherited_cmplx {
	cmplx trace;
	double sqmagdet;		// this is the square of the magnitude of the determinant
	bool valid_t, valid_d; };

// mx must be assigned a value of zero, immediately upon the declaration of the matrix.
// sym:  0=none, 1=symmetric, 2=skew-symmetric, 3=ortho-normal, 4=diagonal, 5=identity, 6=zero.
// WARNING:  since some subroutines employ the symmetri in their program-flow logic,
//    a misleading assignment of symmetry may yield meaningless results.
// if imx is 1; we have a row vector.  if jmx is 1; ... column.  if both imx and jmx each is 1; ... scalar.
// we do not support partitioned complex matrices.
struct matrix {
	double *a;		// this is the actual matrix.
	inherited inh;
	unsigned long imx, jmx, mx, imp, jmp;	// imx = height of the matrix.  jmx = width.  mx is their product.
	unsigned int sym;		// if 1 or 2; then imx & jmx must be equal.
	bool cmp, part, positive; };	// cmp: 0=real, 1=complex.  If 1; then both imx and jmx must be even.
typedef struct matrix MAT;	// Partitioned matrix:  If part is 1; then, 0<imp<imx & 0<jmp<jmx.

// mx must be assigned a value of zero, immediately upon the declaration of the matrix.
// sym:  0=none, 1=Hermitian, 2=skew-Hermitian, 3=unitary, 4=diagonal, 5=identity, 6=zero.
// WARNING:  since some subroutines employ the symmetri in their program-flow logic,
//    a misleading assignment of symmetry may yield meaningless results.
// if imx is 1; we have a row vector.  if jmx is 1; ... column.  if both imx and jmx each is 1; ... scalar.
struct matrix_cmplx {
	cmplx *a;		// this is the actual matrix.
	inherited_cmplx inh;
	unsigned long imx, jmx, mx;	// imx is the width of the matrix.  jmx is the height.  mx is their product.
	unsigned int sym; };		// if 1 or 2; then imx & jmx must be equal.


// definitions.  Note:  either one of the two following definitions would work just as well.

#define arsub(arr, i, j)   (arr->a[(i) + (j) * (arr->imx)])
// #define arsub(arr, i, j)   (arr->a[(i) * (arr->jmx) + (j)])


struct matrix_preferences {
	double test_inv, test_Jac, singular;	// anything less than or equal to this will be considered to be zero.
	unsigned long inversion,	// 0=system default 1=Gauss-Jorday 2=LDU 3=partition & conquer.
		pivot,			// 0=no 1=yes.  reputedly, pivoting improves the precision of matrix inversion.
		eigenpairs,		// 0=system default 1=Jacobi 2=squaring
		Jacobi_style,	// 0=original 1=by rows 2=by super-diagonals
		Jacobi_angle,	// 0=always+ 1=always1 2=small 3=large
		twice,			// 0=system default 1=no 2=yes.
		random,			// 0=system default 1=199017 2=352345383.
		seed; };		// the seed for the pseudo random number generator.

MATRIX_DLL_API
void matrix_set_preferences(void);

MATRIX_DLL_API
void matrix_display(MAT *array, char *title);

MATRIX_DLL_API
void matrix_diagonal_display(MAT *array, char *title);

MATRIX_DLL_API
void matrix_about();


/*  there is a small family of specialized subroutines that employ applicable short-cuts to operate upon
diagonal matrices.  All other subroutines propagate; but do not take advantage, of it.  among others ---
		diag multiply
		diag inverse
		diag square
		diag sqrt
		diag determinant
*/



/*	TABLE OF CONTENTS
00	structures and global preferences.
01	matrix storage allocation & deallocation, complex & partitioned, and additon & multiplication.
02	Fibonacci norm, diagonal, and check_isit?.
03	inverse.
04  specialized multiplication.
05	eigenvalue, eigenvector, etc. for a symmetric matrix.
06  Gramm-Schmidth, Rayligh, Gaussian, Poisson, random.
07  factorization of a non-symmetric, complex, or partitioned matrix.
08	factor analysis & multi-dimensional linear-regression.
	channel rate, angle, and effective correlation coefficient.  cascaded channels.
09  I/O of event data-set and matrices.  computation of variance and average of a data-set.
*/


// copyright (c) 2003,4 by R.I. 'Scibor-Marchocki.  last modified Monday 10-th May 2004.


// eof

