cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vctDeterminant.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */
3 
4 /*
5 
6  Author(s): Ofri Sadowsky
7  Created on: 2004-04-16
8 
9  (C) Copyright 2004-2007 Johns Hopkins University (JHU), All Rights
10  Reserved.
11 
12 --- begin cisst license - do not edit ---
13 
14 This software is provided "as is" under an open source license, with
15 no warranty. The complete license can be found in license.txt and
16 http://www.cisst.org/cisst/license.txt.
17 
18 --- end cisst license ---
19 */
20 
21 #pragma once
22 #ifndef _vctDeterminant_h
23 #define _vctDeterminant_h
24 
31 
41 template <vct::size_type _size>
43 {
44 public:
45  enum {SIZE = _size};
51  template <vct::stride_type _rowStride, vct::stride_type _colStride, class _elementType, class _dataPtrType>
53 };
54 
55 
56 #ifndef DOXYGEN
57 
58 template<>
60 {
61 public:
62  enum {SIZE = 1};
63  template <vct::stride_type _rowStride, vct::stride_type _colStride, class _elementType, class _dataPtrType>
65  {
66  return matrix.Element(0, 0);
67  }
68 };
69 
70 
71 template<>
73 {
74 public:
75  enum {SIZE = 2};
76  template <vct::stride_type _rowStride, vct::stride_type _colStride, class _elementType, class _dataPtrType>
78  {
79  return matrix.Element(0, 0) * matrix.Element(1, 1) - matrix.Element(0, 1) * matrix.Element(1, 0);
80  }
81 };
82 
83 
84 template<>
86 {
87 public:
88  enum {SIZE = 3};
89  template<vct::stride_type _rowStride, vct::stride_type _colStride, class _elementType, class _dataPtrType>
91  {
92  return
93  matrix.Element(0, 0) * ( matrix.Element(1, 1) * matrix.Element(2, 2) - matrix.Element(1, 2) * matrix.Element(2, 1) ) -
94  matrix.Element(0, 1) * ( matrix.Element(1, 0) * matrix.Element(2, 2) - matrix.Element(1, 2) * matrix.Element(2, 0) ) +
95  matrix.Element(0, 2) * ( matrix.Element(1, 0) * matrix.Element(2, 1) - matrix.Element(1, 1) * matrix.Element(2, 0) );
96  }
97 };
98 
99 
100 #endif // DOXYGEN
101 
102 #endif // _vctDeterminant_h
103 
Determinant function for fixed size matrices.
Definition: vctDeterminant.h:42
A template for a fixed size matrix with fixed spacing in memory.
Definition: vctFixedSizeConstMatrixBase.h:103
static _elementType Compute(const vctFixedSizeConstMatrixBase< SIZE, SIZE, _rowStride, _colStride, _elementType, _dataPtrType > &matrix)
Definition: vctDeterminant.h:77
Definition: vctDeterminant.h:45
static _elementType Compute(const vctFixedSizeConstMatrixBase< SIZE, SIZE, _rowStride, _colStride, _elementType, _dataPtrType > &matrix)
Definition: vctDeterminant.h:90
static _elementType Compute(const vctFixedSizeConstMatrixBase< _size, _size, _rowStride, _colStride, _elementType, _dataPtrType > &matrix)
static _elementType Compute(const vctFixedSizeConstMatrixBase< SIZE, SIZE, _rowStride, _colStride, _elementType, _dataPtrType > &matrix)
Definition: vctDeterminant.h:64
Declaration of vctFixedSizeConstMatrixBase.