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="LALInverse3CV"> 00021 Author: Sathyaprakash, B. S. 00022 $Id: LALInverse3.c,v 1.8 2007/06/08 14:41:42 bema Exp $ 00023 </lalVerbatim> */ 00024 00025 /* <lalLaTeX> 00026 00027 \subsection{Module \texttt{LALInverse3.c}} 00028 00029 00030 Uses $g^{ij} = 1/(2g) e^{ikl} e^{jab} g_{ka} g_{lb}$ to compute the inverse. 00031 00032 \subsubsection*{Prototypes} 00033 \vspace{0.1in} 00034 \input{LALInverse3CP} 00035 \idx{LALInverse3()} 00036 00037 \begin{itemize} 00038 \item \texttt{inverse,} Output, inverse of the $(3\times 3)$ input matrix 00039 \item \texttt{*matrix,} Input, matrix whose inverse is required 00040 \end{itemize} 00041 \subsubsection*{Description} 00042 00043 00044 Uses $g^{ij} = 1/(2g) e^{ikl} e^{jab} g_{ka} g_{lb}$ to compute 00045 the inverse; though not efficient, it is good enough for the 00046 3-d matrix that we have. Prevents the need for having a new library. 00047 00048 \subsubsection*{Algorithm} 00049 00050 00051 \subsubsection*{Uses} 00052 00053 \begin{verbatim} 00054 LALDeterminant3 00055 \end{verbatim} 00056 00057 \subsubsection*{Notes} 00058 Do not generalise to more than 3 dimensions. 00059 00060 \vfill{\footnotesize\input{LALInverse3CV}} 00061 00062 </lalLaTeX> */ 00063 00064 #include <lal/LALInspiralBank.h> 00065 00066 NRCSID(LALINVERSE3C, "$Id: LALInverse3.c,v 1.8 2007/06/08 14:41:42 bema Exp $"); 00067 #define Dim 3 00068 00069 /* <lalVerbatim file="LALInverse3CP"> */ 00070 00071 void LALInverse3(LALStatus *status, 00072 REAL8 **inverse, 00073 REAL8 **matrix) 00074 { /* </lalVerbatim> */ 00075 00076 REAL8 epsilon[Dim][Dim][Dim] = {{ 00077 { 0, 0, 0}, 00078 { 0, 0, 1}, 00079 { 0,-1, 0}}, 00080 {{ 0, 0,-1}, 00081 { 0, 0, 0}, 00082 { 1, 0, 0}}, 00083 {{ 0, 1, 0}, 00084 {-1, 0, 0}, 00085 { 0, 0, 0}}}; 00086 REAL8 det,x; 00087 int i,j,p,q,a,b; 00088 00089 INITSTATUS(status, "LALInverse3", LALINVERSE3C); 00090 ATTATCHSTATUSPTR(status); 00091 ASSERT (inverse, status, LALINSPIRALBANKH_ENULL, LALINSPIRALBANKH_MSGENULL); 00092 ASSERT (matrix, status, LALINSPIRALBANKH_ENULL, LALINSPIRALBANKH_MSGENULL); 00093 00094 LALDeterminant3(status->statusPtr, &det, matrix); CHECKSTATUSPTR(status); 00095 00096 ASSERT (det!=0, status, LALINSPIRALBANKH_EDIV0, LALINSPIRALBANKH_MSGEDIV0); 00097 00098 for (i=0; i<Dim; i++) { 00099 for (j=0; j<Dim; j++) { 00100 x = 0; 00101 for (a=0; a<Dim; a++) { for (b=0; b<Dim; b++) { 00102 for (p=0; p<Dim; p++) { for (q=0; q<Dim; q++) { 00103 x+=epsilon[j][a][p] * epsilon[i][b][q] * matrix[a][b] * matrix[p][q]; 00104 }}}} 00105 inverse[i][j] = x/(2.*det); 00106 }} 00107 DETATCHSTATUSPTR(status); 00108 RETURN(status); 00109 } 00110 00111 #undef Dim
1.5.2