/*__*
 *__*
 *__* WEIGHBOR 1.0.1
 *__*
 *__* Copyright (c) 1997-2000 
 *__*    Los Alamos National Laboratories
 *__*    The Rockefeller University
 *__*
 *__* This file is part of the WEIGHBOR program that can be used free of
 *__* charge in academic research and teaching. Any commercial use of
 *__* this software requires prior permission and possibly a license. For
 *__* commercial use contact: W. Bruno at billb@t10.lanl.gov Los Alamos
 *__* National Laboratories makes no representations about the
 *__* suitability of this software for any purpose. It is provided 
 *__* "as is" without express or implied warranty
 *__*	
 *__* For those using this program for research please use the following 
 *__* citation for this program:
 *__*
 *__*    Bruno, W. J., Socci, N. D. and Halpern, A. L., ``Weighted 
 *__*        Neighbor Joining: A Fast Approximation to Maximum-Likelihood
 *__*        Phylogeny Reconstruction,'' Molecular Biology and Evolution, 
 *__*        17(1): 189-197, (2000).
 *__*
 *__* 
 *__*/
/*
  
  \input cnoweb

  Program: weighbor                             \hfill\break
  File: matrix.h                                \hfill\break
  Author: N. D. Socci                           \hfill\break
  Created: 4-Feb-97                             \hfill\break
  
  \title{matrix.h}
  \job{Weighbor}
  
  \synopsis{Include file for various linear algebra data types: matrix
  and vector} 
  

  */

/* $Id: matrix.h,v 1.10 2000/01/12 00:49:33 nds Exp $ */

/*
  
  $Log: matrix.h,v $
  Revision 1.10  2000/01/12 00:49:33  nds
  Fixed copyright tags

  Revision 1.9  2000/01/06 05:50:34  nds
  Fixed copywrite notice (must be post-added with a script)

  Removed the HASH1 code

  Fixed assert redef warning

  Fixed roundoff error in sigma_na

  Can not read lower triagular matrices

  Revision 1.1.1.1  2000/01/05 19:47:29  nds
  Import to CVS

  Revision 1.3  1999/06/09 03:18:13  nds
  Historical Source 6-Jun-99

  Revision 1.13  1998/06/15 23:56:17  nds
  First Release Version!

  Revision 1.12  1998-06-09 18:33:40-04  nds
  Version 0.2.13
      Added -Xx option
      Changed the normalization on the -Xn option
      Copyright notice added to all files

  Revision 1.11  1997-11-15 00:31:32-05  nds
  Changes for weighor version 0.2.7.1

  Revision 1.10  1997-09-18 16:56:22-04  nds
  Final 1.x version of weighbor. Uses approximate residual computation
  to calculate the pairs to join and averages the various branch lengths
  estimates to get the new branch lengths for the joinded pairs.

  Revision 1.1  1997-08-08 13:58:30-04  nds
  Initial revision

  
  */


#ifndef __MATRIX_H
#define __MATRIX_H

#include <math.h>

/*

  \section{Introduction}

  This file contains a rudimentary vector and square matrix datatype.

  */

/*
  
  \section{Data Types}

  Here are the basic data types: \|MatrixT| which is a 2D dimensional
  array of doubles. 
  It will have the \"C" index convention; ie $i=0\ldots N-1$. 
  The data will be stored in C (row-first)
  ordering. \|VectorT| is a 1D array of doubles again with the index
  going from 0 to $N-1$.

  I also include the ever useful BooleanT here.

  */

typedef double **MatrixT;
typedef double *VectorT;

typedef enum {False=0, True=-1} BooleanT;


/*

  \section{Function Definitions}

  \subsection{Allocation and Deallocation}

  This functions allocate \& deallocate matrices and vectors. 
  Note all the matrices used by weighbor are square so matrix takes
  just one argument.


  */

MatrixT matrix(int);
VectorT vector(int);

void freeVector(VectorT);
void freeMatrix(MatrixT);

/*
  
  \subsection{Linear Algebra Routines}

  Here are the function def's for any linear algebra routines that
  weighbor will used. They will simply be wrappers around other
  standard library routines
  */

void setMM(int, MatrixT, MatrixT);
void delRowCol(int, MatrixT, int);


/* \section{Printing} */

void printMatrix(int, MatrixT);
void printVector(int, VectorT);

/* \section{Miscellaneous Functions} */

/* 

   Complimentary error function: in source file \|calerf.c| Using our
   own code since the clib of gcc only computes to single precision
   even though it returns a double.

   */

double derf(double x); 
double derfc(double x); 
double derfcx(double x); 

#endif /* __MATRIX_H */

/* \endc */ 






