#if !defined(PS_MATRIX_H)
#define PS_MATRIX_H

/** \file psMatrix.h
 *  \brief matrix math operators
 *  \ingroup MathGroup
 */

/** Functions **************************************************************/
/** \addtogroup MathGroup Math Utilities
 *  \{
 */


/* Linear Algebra */

/** LU Decomposition of a matrix */
psImage *
psMatrixLUD(psImage *out,		///< Matrix to return, or NULL
	    psVector *perm, 		///< Permutation vector
	    const psImage *in)		///< Matrix to decompose
;

/** LU Solution.  Solves for and returns x in the equation Ax = b */
psVector *
psMatrixLUSolve(psVector *out,		///< Vector to return, or NULL
		const psImage *LU,	///< LU-decomposed matrix
		const psVector *RHS,	///< right-hand-side of the equation
		const psVector *perm	///< Permutation vector
;

/** Invert matrix.  Not using restrict, to allow inversion to be done in-place */
psImage *
psMatrixInvert(psImage *out,		///< Matrix to return, or NULL
	       const psImage *myMatrix, ///< Matrix to be inverted
	       float *determinant)	///< Determinant to return, or NULL
;

/** Matrix determinant */
float
psMatrixDeterminant(const psImage *myMatrix) ///< Matrix to get determinant for
;

/** Matrix operation: addition, subtraction, multiplication */
psImage *
psMatrixMultiply(psImage *out,		///< Matrix to return, or NULL
		 const psImage *in1,	///< Matrix 1
		 const psImage *in2)	///< Matrix 2
;

/** Transpose Matrix */
psImage *
psMatrixTranspose(psImage *out,		///< Matrix to return, or NULL
		  const psImage *in)	///< Matrix to transpose
;

/** Eigenvectors of a matrix */
psVector *
psMatrixEigenvectors(psImage *myMatrix)	///< Matrix to get eigenvectors for
;

/***********************************************************************************************************/

/* Conversions */

/** Convert matrix to vector.  Intended for a 1-d matrix. */
psVector *
psMatrixToVector(psVector *out,		///< Vector to return, or NULL
		 const psImage *in)	///< Matrix to convert
;

/** Convert vector to matrix. */
psImage *
psVectorToMatrix(psImage *out,		///< Matrix to return, or NULL
		 const psVector *in)	///< Vector to convert
;

/* \} */ // End of MathGroup Functions

#endif
