/* -*- c -*-
 * Time-stamp: <2005-04-16 11:28:16 rsmith>
 * 
 * matrix/matrix.h
 * Copyright (C) 2002,2005 R.F. Smith <rsmith@xs4all.nl>. All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 
 * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

/* If this code fails to compile, check that you compiler supports
 * variable-length automatic arrays. If compilation fails with GCC, try
 * adding the -fno-unit-at-a-time switch to the compilation command. */

#ifndef _MATRIX_H
#define _MATRIX_H

#ifdef __cplusplus
#  define BEGIN_C_DECLS extern "C" {
#  define END_C_DECLS   }
#else                           /* !__cplusplus */
#  define BEGIN_C_DECLS
#  define END_C_DECLS
#endif                          /* __cplusplus */

BEGIN_C_DECLS

/* Makes a matrix into the unity matrix */
extern int mat_unity(int n, double a[n][n]);

/* Cpoies matrix a into b */
extern int mat_cpy(int n, double a[n][n], double b[n][n]);

/* Multiplies a matrix with a vector */
extern int mat_xform(int n, double m[n][n], double v[n], double mv[n]);

/* multiplies two matrices */
extern int mat_mul(int n, double a[n][n], double b[n][n], double ab[n][n]);

/* Inverts a matrix, if possible. */
extern int mat_inv(int n, double m[n][n], double i[n][n]);

/* Print the matrix on stdout */
extern int mat_print(char *name, int n, double m[n][n]);

END_C_DECLS

#endif /* _MATRIX_H */
/* EOF matrix.h */


syntax highlighted by Code2HTML, v. 0.9.1