Main Page
Related Pages
Modules
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
z
Variables
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
x
y
Typedefs
a
b
c
d
f
h
i
n
o
p
q
r
s
t
u
Enumerations
a
c
d
e
f
i
m
n
p
q
r
s
t
u
Enumerator
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
x
z
Classes
Class List
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
Enumerations
a
b
c
d
e
f
g
i
l
m
n
p
r
s
t
u
w
Enumerator
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
y
Related Functions
c
e
h
i
m
o
p
q
s
t
v
Files
File List
File Members
All
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
v
x
z
Variables
a
b
c
e
g
i
l
m
n
p
r
s
t
v
x
y
Typedefs
a
b
c
d
e
f
h
i
l
m
n
p
q
r
s
t
u
Enumerator
Macros
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Examples
src
extern
eigen3
Eigen
src
LU
Determinant.h
Go to the documentation of this file.
1
// This file is part of Eigen, a lightweight C++ template library
2
// for linear algebra.
3
//
4
// Copyright (C) 2008 Benoit Jacob <jacob.benoit.1@gmail.com>
5
//
6
// This Source Code Form is subject to the terms of the Mozilla
7
// Public License v. 2.0. If a copy of the MPL was not distributed
8
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9
10
#ifndef EIGEN_DETERMINANT_H
11
#define EIGEN_DETERMINANT_H
12
13
namespace
Eigen
{
14
15
namespace
internal
{
16
17
template
<
typename
Derived>
18
inline
const
typename
Derived::Scalar
bruteforce_det3_helper
19
(
const
MatrixBase<Derived>
&
matrix
,
int
a
,
int
b
,
int
c
)
20
{
21
return
matrix
.coeff(0,
a
)
22
* (
matrix
.coeff(1,
b
) *
matrix
.coeff(2,
c
) -
matrix
.coeff(1,
c
) *
matrix
.coeff(2,
b
));
23
}
24
25
template
<
typename
Derived>
26
const
typename
Derived::Scalar
bruteforce_det4_helper
27
(
const
MatrixBase<Derived>
&
matrix
,
int
j,
int
k,
int
m,
int
n
)
28
{
29
return
(
matrix
.coeff(j,0) *
matrix
.coeff(k,1) -
matrix
.coeff(k,0) *
matrix
.coeff(j,1))
30
* (
matrix
.coeff(m,2) *
matrix
.coeff(
n
,3) -
matrix
.coeff(
n
,2) *
matrix
.coeff(m,3));
31
}
32
33
template
<
typename
Derived,
34
int
DeterminantType = Derived::RowsAtCompileTime
35
>
struct
determinant_impl
36
{
37
static
inline
typename
traits<Derived>::Scalar
run
(
const
Derived& m)
38
{
39
if
(Derived::ColsAtCompileTime==
Dynamic
&& m.rows()==0)
40
return
typename
traits<Derived>::Scalar
(1);
41
return
m.partialPivLu().determinant();
42
}
43
};
44
45
template
<
typename
Derived>
struct
determinant_impl
<Derived, 1>
46
{
47
static
inline
typename
traits<Derived>::Scalar
run
(
const
Derived& m)
48
{
49
return
m.coeff(0,0);
50
}
51
};
52
53
template
<
typename
Derived>
struct
determinant_impl
<Derived, 2>
54
{
55
static
inline
typename
traits<Derived>::Scalar
run
(
const
Derived& m)
56
{
57
return
m.coeff(0,0) * m.coeff(1,1) - m.coeff(1,0) * m.coeff(0,1);
58
}
59
};
60
61
template
<
typename
Derived>
struct
determinant_impl
<Derived, 3>
62
{
63
static
inline
typename
traits<Derived>::Scalar
run
(
const
Derived& m)
64
{
65
return
bruteforce_det3_helper
(m,0,1,2)
66
-
bruteforce_det3_helper
(m,1,0,2)
67
+
bruteforce_det3_helper
(m,2,0,1);
68
}
69
};
70
71
template
<
typename
Derived>
struct
determinant_impl
<Derived, 4>
72
{
73
static
typename
traits<Derived>::Scalar
run
(
const
Derived& m)
74
{
75
// trick by Martin Costabel to compute 4x4 det with only 30 muls
76
return
bruteforce_det4_helper
(m,0,1,2,3)
77
-
bruteforce_det4_helper
(m,0,2,1,3)
78
+
bruteforce_det4_helper
(m,0,3,1,2)
79
+
bruteforce_det4_helper
(m,1,2,0,3)
80
-
bruteforce_det4_helper
(m,1,3,0,2)
81
+
bruteforce_det4_helper
(m,2,3,0,1);
82
}
83
};
84
85
}
// end namespace internal
86
91
template
<
typename
Derived>
92
inline
typename
internal::traits<Derived>::Scalar
MatrixBase<Derived>::determinant
()
const
93
{
94
eigen_assert
(rows() == cols());
95
typedef
typename
internal::nested_eval<Derived,Base::RowsAtCompileTime>::type
Nested;
96
return
internal::determinant_impl<typename internal::remove_all<Nested>::type
>
::run
(derived());
97
}
98
99
}
// end namespace Eigen
100
101
#endif // EIGEN_DETERMINANT_H
Eigen::internal::determinant_impl::run
static traits< Derived >::Scalar run(const Derived &m)
Definition:
Determinant.h:37
Eigen
Definition:
common.h:73
b
Scalar * b
Definition:
cholesky.cpp:56
Eigen::internal::determinant_impl< Derived, 4 >::run
static traits< Derived >::Scalar run(const Derived &m)
Definition:
Determinant.h:73
eigen_assert
#define eigen_assert(x)
Definition:
Macros.h:579
Eigen::internal::determinant_impl< Derived, 1 >::run
static traits< Derived >::Scalar run(const Derived &m)
Definition:
Determinant.h:47
Scalar
SCALAR Scalar
Definition:
common.h:84
matrix
Map< Matrix< T, Dynamic, Dynamic, ColMajor >, 0, OuterStride<> > matrix(T *data, int rows, int cols, int stride)
Definition:
common.h:102
Eigen::internal::determinant_impl< Derived, 2 >::run
static traits< Derived >::Scalar run(const Derived &m)
Definition:
Determinant.h:55
Eigen::MatrixBase::determinant
Scalar determinant() const
Definition:
Determinant.h:92
Eigen::internal::true_type
Definition:
Meta.h:54
Eigen::Dynamic
const int Dynamic
Definition:
Constants.h:21
Eigen::internal::bruteforce_det3_helper
const Derived::Scalar bruteforce_det3_helper(const MatrixBase< Derived > &matrix, int a, int b, int c)
Definition:
Determinant.h:19
Eigen::internal::determinant_impl< Derived, 3 >::run
static traits< Derived >::Scalar run(const Derived &m)
Definition:
Determinant.h:63
c
RealScalar c
Definition:
level1_cplx_impl.h:103
Eigen::internal::traits
Definition:
ForwardDeclarations.h:17
a
Scalar * a
Definition:
cholesky.cpp:26
Eigen::TensorSycl::run
void run(Expr &expr, Dev &dev)
Definition:
TensorSyclRun.h:47
Eigen::internal::bruteforce_det4_helper
const Derived::Scalar bruteforce_det4_helper(const MatrixBase< Derived > &matrix, int j, int k, int m, int n)
Definition:
Determinant.h:27
Eigen::internal::determinant_impl
Definition:
Determinant.h:35
internal
Definition:
BandTriangularSolver.h:13
Eigen::MatrixBase
Base class for all dense matrices, vectors, and expressions.
Definition:
MatrixBase.h:48
n
PlainMatrixType mat * n
Definition:
eigenvalues.cpp:41
control_box_rst
Author(s): Christoph Rösmann
autogenerated on Wed Mar 2 2022 00:05:44