File: Matrix.h

package info (click to toggle)
cgal 3.6.1-2
  • links: PTS
  • area: non-free
  • in suites: squeeze
  • size: 62,184 kB
  • ctags: 95,782
  • sloc: cpp: 453,758; ansic: 96,821; sh: 226; makefile: 120; xml: 2
file content (33 lines) | stat: -rw-r--r-- 716 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#ifndef CGAL_DSRPDB_MATRIX_H
#define CGAL_DSRPDB_MATRIX_H
#include <CGAL/PDB/basic.h>
#include <CGAL/PDB/internal/tnt/tnt_array2d.h>

namespace CGAL { namespace PDB {
//! Use TNT::Array2D<double> as a matrix
typedef TNT::Array2D<double> Matrix;

double det(const Matrix& m) {
  CGAL_assertion(m.dim1() == 3);
  CGAL_assertion(m.dim2() == 3);
  
  return (m[0][0]*(m[1][1]*m[2][2] - m[1][2]*m[2][1]) -
	  m[0][1]*(m[1][0]*m[2][2] - m[1][2]*m[2][0]) +
	  m[0][2]*(m[1][0]*m[2][1] - m[1][1]*m[2][0]));
}


Matrix transpose(const Matrix& m) {
  Matrix mt(m.dim2(), m.dim1());
  for (int i = 0; i < m.dim1(); i++) {
    for (int j = 0; j < m.dim2(); j++) {
      mt[j][i] = m[i][j];
    }
  }
  return mt;
}



}}
#endif