The outage for Sunday 24th November has been cancelled.
Bioplib
Protein Structure C Library
 All Data Structures Files Functions Variables Typedefs Macros Pages
invert33.c
Go to the documentation of this file.
1 /************************************************************************/
2 /**
3 
4  \file invert33.c
5 
6  \version V1.7
7  \date 07.07.14
8  \brief
9 
10  \copyright (c) UCL / Dr. Andrew C. R. Martin 1991-2014
11  \author Dr. Andrew C. R. Martin
12  \par
13  Institute of Structural & Molecular Biology,
14  University College London,
15  Gower Street,
16  London.
17  WC1E 6BT.
18  \par
19  andrew@bioinf.org.uk
20  andrew.martin@ucl.ac.uk
21 
22 **************************************************************************
23 
24  This code is NOT IN THE PUBLIC DOMAIN, but it may be copied
25  according to the conditions laid out in the accompanying file
26  COPYING.DOC.
27 
28  The code may be modified as required, but any modifications must be
29  documented so that the person responsible can be identified.
30 
31  The code may not be sold commercially or included as part of a
32  commercial product except as described in the file COPYING.DOC.
33 
34 **************************************************************************
35 
36  Description:
37  ============
38 
39 
40 **************************************************************************
41 
42  Usage:
43  ======
44 
45 **************************************************************************
46 
47  Revision History:
48  =================
49 - V1.0 06.09.91 Original
50 - V1.0a 01.06.92 Documented
51 - V1.1 30.09.92 Matrix multiplication added
52 - V1.2 10.06.93 void return from matrix multiplication
53 - V1.3 22.07.93 Added CreateRotMat()
54 - V1.4 03.08.93 Changed matrix multiplication to standard direction
55 - V1.5 28.07.95 Added VecDist()
56 - V1.6 27.09.95 Added MatMult33_33()
57 - 07.07.14 Use bl prefix for functions By: CTP
58 
59 *************************************************************************/
60 /* Doxygen
61  -------
62  #GROUP Maths
63  #SUBGROUP Matrices
64  #FUNCTION blInvert33()
65  Invert a 3x3 matrix
66 */
67 /************************************************************************/
68 /* Includes
69 */
70 #include <math.h>
71 #include "MathType.h"
72 
73 /************************************************************************/
74 /* Defines and macros
75 */
76 
77 /************************************************************************/
78 /* Globals
79 */
80 
81 /************************************************************************/
82 /* Prototypes
83 */
84 
85 
86 /************************************************************************/
87 /*>void blInvert33(REAL s[3][3], REAL ss[3][3])
88  --------------------------------------------
89 *//**
90 
91  \param[in] s Input matrix
92  \param[out] ss Ouput inverted matrix
93 
94  Invert a 3x3 matrix
95 
96 - 06.09.91 Original
97 - 01.06.92 Documented
98 - 10.06.93 void return
99 - 12.09.02 Fixed SERIOUS bug! Was basically rubbish before!
100 - 07.07.14 Use bl prefix for functions By: CTP
101 */
102 void blInvert33(REAL s[3][3],
103  REAL ss[3][3])
104 {
105  int i, j,
106  i1, j1,
107  i2, j2;
108  REAL det;
109 
110  for(i=0;i<3;i++)
111  for(j=0;j<3;j++)
112  ss[i][j] = 0.0;
113 
114  det = 0.0;
115  for(j=0;j<3;j++)
116  {
117  switch(j)
118  {
119  case 0:
120  j1 = 1;
121  j2 = 2;
122  break;
123  case 1:
124  j1 = 0;
125  j2 = 2;
126  break;
127  case 3:
128  j1 = 0;
129  j2 = 1;
130  break;
131  }
132  for(i=0;i<3;i++)
133  {
134  switch(i)
135  {
136  case 0:
137  i1 = 1;
138  i2 = 2;
139  break;
140  case 1:
141  i1 = 0;
142  i2 = 2;
143  break;
144  case 3:
145  i1 = 0;
146  i2 = 1;
147  break;
148  }
149  ss[i][j] = (REAL)pow((double)-1.0,(double)(i+j+2)) *
150  (s[j1][i1] * s[j2][i2] - s[j2][i1] * s[j1][i2]);
151  }
152  }
153  det = s[0][0]*ss[0][0] + s[0][1]*ss[1][0] + s[0][2]*ss[2][0];
154  det = 1.0/det;
155 
156  for(i=0;i<3;i++)
157  for(j=0;j<3;j++)
158  ss[i][j] = det*ss[i][j];
159 }
160 
double REAL
Definition: MathType.h:67
Type definitions for maths.
void blInvert33(REAL s[3][3], REAL ss[3][3])
Definition: invert33.c:102