00001 /* 00002 * Copyright (C) 2007 David Churches, Duncan Brown, Jolien Creighton 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation; either version 2 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with with program; see the file COPYING. If not, write to the 00016 * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, 00017 * MA 02111-1307 USA 00018 */ 00019 00020 /* <lalVerbatim file="LALDeterminant3CV"> 00021 Author: Sathyaprakash, B. S. 00022 $Id: LALDeterminant3.c,v 1.10 2007/06/08 14:41:42 bema Exp $ 00023 </lalVerbatim> */ 00024 00025 /* <lalLaTeX> 00026 00027 \subsection{Module \texttt{LALDeterminant.c}} 00028 00029 Module to calculate the determinant of a 3-dimensional matrix $g_{ij}$. 00030 00031 \subsubsection*{Prototypes} 00032 \vspace{0.1in} 00033 \input{LALDeterminant3CP} 00034 \idx{LALDeterminant() 3D determinant} 00035 \begin{itemize} 00036 \item \texttt{determinant,} Output, determinant of the matrix. 00037 \item \texttt{matrix,} Input, the input $(3\times 3)$ matrix whose determinant is required. 00038 \end{itemize} 00039 00040 \subsubsection*{Description} 00041 00042 This code computes the determinant of a 3-dimensional matrix. 00043 00044 \subsubsection*{Algorithm} 00045 Given a matrix $g_{ij}$ its determinant 00046 is computed using the formula $g = \epsilon^{ijk} g_{i1} g_{j2} g_{k3},$ 00047 where $\epsilon$ is the totally anti-symmetric tensor in 3-dimensions. 00048 00049 \subsubsection*{Uses} 00050 None. 00051 00052 \subsubsection*{Notes} 00053 Don't ever generalise this to higher dimensions since this 00054 would take many more operations than some of the standard routines. 00055 00056 \vfill{\footnotesize\input{LALDeterminant3CV}} 00057 00058 </lalLaTeX> */ 00059 00060 #include <lal/LALInspiralBank.h> 00061 00062 NRCSID(LALDETERMINANT3C, "$Id: LALDeterminant3.c,v 1.10 2007/06/08 14:41:42 bema Exp $"); 00063 00064 /* <lalVerbatim file="LALDeterminant3CP"> */ 00065 00066 void LALDeterminant3(LALStatus *status, 00067 REAL8 *determinant, 00068 REAL8 **matrix) 00069 { /* </lalVerbatim> */ 00070 00071 REAL8 epsilon[3][3][3] = {{ 00072 { 0, 0, 0}, 00073 { 0, 0, 1}, 00074 { 0,-1, 0}}, 00075 {{ 0, 0,-1}, 00076 { 0, 0, 0}, 00077 { 1, 0, 0}}, 00078 {{ 0, 1, 0}, 00079 {-1, 0, 0}, 00080 { 0, 0, 0}}}; 00081 INT4 Dim=3,i,j,k; 00082 INITSTATUS(status, "LALDeterminant3", LALDETERMINANT3C); 00083 ATTATCHSTATUSPTR(status); 00084 00085 ASSERT (matrix, status, LALINSPIRALBANKH_ENULL, LALINSPIRALBANKH_MSGENULL); 00086 00087 *determinant = 0; 00088 for (i=0; i<Dim; i++) { 00089 for (j=0; j<Dim; j++) { 00090 for (k=0; k<Dim; k++) { 00091 *determinant+=epsilon[i][j][k]*matrix[0][i]*matrix[1][j]*matrix[2][k]; 00092 }}} 00093 00094 ASSERT (*determinant != 0, status, LALINSPIRALH_ESIZE, LALINSPIRALH_MSGESIZE); 00095 00096 DETATCHSTATUSPTR(status); 00097 RETURN(status); 00098 }
1.5.2