mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Compare commits
316 Commits
gpu-dense-
...
3.4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
28ded8800c | ||
|
|
0295f81a83 | ||
|
|
d71c30c478 | ||
|
|
79488684e1 | ||
|
|
b66188b5df | ||
|
|
5c81034fc1 | ||
|
|
c3f9707824 | ||
|
|
4fc1cfeda5 | ||
|
|
cd7263e7f6 | ||
|
|
eb57d4bdf1 | ||
|
|
4a2c4901ce | ||
|
|
68f4e58cfa | ||
|
|
0e607fd350 | ||
|
|
13507d1efd | ||
|
|
85ffda9539 | ||
|
|
72f77ccb3e | ||
|
|
526a6328e2 | ||
|
|
7b378c2d91 | ||
|
|
129e003cdf | ||
|
|
6161ce5cde | ||
|
|
be62728876 | ||
|
|
1426855b68 | ||
|
|
b2deb94e4a | ||
|
|
c23abcf25c | ||
|
|
f23b8c0d78 | ||
|
|
d60c3a3341 | ||
|
|
57c8d7c93f | ||
|
|
ab92609cad | ||
|
|
551e95a409 | ||
|
|
2924f58188 | ||
|
|
f1922b6dac | ||
|
|
052d91349a | ||
|
|
72e38684c1 | ||
|
|
bb1dbb4df6 | ||
|
|
0a5abc042e | ||
|
|
42d9cc0b1d | ||
|
|
7312765992 | ||
|
|
88cd53774e | ||
|
|
c0378fedd8 | ||
|
|
414f0a1756 | ||
|
|
3adc78e39c | ||
|
|
e67c494cba | ||
|
|
3e7bcf54f7 | ||
|
|
9df21dc8b4 | ||
|
|
157756130a | ||
|
|
7893285e59 | ||
|
|
3ee06ec52f | ||
|
|
287c801780 | ||
|
|
42b04a08c4 | ||
|
|
b86ac5f1e7 | ||
|
|
380a9483e0 | ||
|
|
25270e35db | ||
|
|
ebf968b272 | ||
|
|
bd57b99f44 | ||
|
|
b8f894947a | ||
|
|
4be2870267 | ||
|
|
f7085a1096 | ||
|
|
63291e34bf | ||
|
|
23886fd7db | ||
|
|
7c6020e424 | ||
|
|
2e3f1d8044 | ||
|
|
fc5575264f | ||
|
|
bae907b8f6 | ||
|
|
cf207eacd5 | ||
|
|
e734787bb7 | ||
|
|
1217390db4 | ||
|
|
7176ae1623 | ||
|
|
0db5928f00 | ||
|
|
764b132a79 | ||
|
|
d0bfdc1658 | ||
|
|
75ebef26b6 | ||
|
|
208e44c979 | ||
|
|
17d57fb168 | ||
|
|
6973687c70 | ||
|
|
ac561cd038 | ||
|
|
554982beef | ||
|
|
89a71f3126 | ||
|
|
a605d6b996 | ||
|
|
dfcd6de20a | ||
|
|
1ec1b16d36 | ||
|
|
0f39c851a5 | ||
|
|
daa0b70a65 | ||
|
|
33ba98b641 | ||
|
|
e6e921f0e3 | ||
|
|
ebfdd6bdea | ||
|
|
357bb11066 | ||
|
|
9b3d104c02 | ||
|
|
af3ca50f0b | ||
|
|
26b8fabd80 | ||
|
|
385a0b38f8 | ||
|
|
a4ecfd8ead | ||
|
|
f296720d7d | ||
|
|
f04d02dbf6 | ||
|
|
6f9bffe8dd | ||
|
|
d4c24eca96 | ||
|
|
72b0759451 | ||
|
|
34d0d83278 | ||
|
|
63e8b31c94 | ||
|
|
99473f255b | ||
|
|
2ce5dc428f | ||
|
|
8f1b6198c2 | ||
|
|
dae8c6d7ad | ||
|
|
2dfdaa2abf | ||
|
|
a659b5dbb2 | ||
|
|
879854382c | ||
|
|
90dce8dfa3 | ||
|
|
b26ada1e03 | ||
|
|
f5593b4baa | ||
|
|
3eb0c8b69e | ||
|
|
26adb0e5af | ||
|
|
5547205092 | ||
|
|
771e91860b | ||
|
|
4786edba26 | ||
|
|
15e23ab849 | ||
|
|
af6e7cc66a | ||
|
|
3fbb1c1b48 | ||
|
|
28cd280726 | ||
|
|
8cc3ec8e47 | ||
|
|
d641062a05 | ||
|
|
1000cf9fbc | ||
|
|
fd2817e3d6 | ||
|
|
11dacc4802 | ||
|
|
ab6f39e1e3 | ||
|
|
6576ee4fb1 | ||
|
|
68f35d76b8 | ||
|
|
d0e2b3e58d | ||
|
|
669dc8fadf | ||
|
|
33a602eb37 | ||
|
|
a9490cd3c5 | ||
|
|
61efca2e90 | ||
|
|
a5469a6f0f | ||
|
|
6aaa45db5f | ||
|
|
ea57f9b78f | ||
|
|
f55a112cb1 | ||
|
|
a11bdf3965 | ||
|
|
b9ac284e52 | ||
|
|
3df7d7fec9 | ||
|
|
80c5b8b3c3 | ||
|
|
848db4ed2d | ||
|
|
5cb7505a44 | ||
|
|
af912a7b5c | ||
|
|
86d958e8f2 | ||
|
|
8e7bd5397f | ||
|
|
8a21df2d9c | ||
|
|
ac78f84b72 | ||
|
|
973b04f3e1 | ||
|
|
16844d7529 | ||
|
|
5cb2dfec1d | ||
|
|
c473d69d22 | ||
|
|
6469fbf93a | ||
|
|
3a4a4e9fde | ||
|
|
fab848d4f7 | ||
|
|
b158fcaa74 | ||
|
|
b6d9b6f48d | ||
|
|
b1f06aac61 | ||
|
|
f6954e4485 | ||
|
|
b30a2a527e | ||
|
|
bc1b354b32 | ||
|
|
bd0d873b16 | ||
|
|
e0fe006915 | ||
|
|
d259104c8d | ||
|
|
cd543434bf | ||
|
|
36be6747e0 | ||
|
|
d1ed3fe5c9 | ||
|
|
21e0ad056e | ||
|
|
709d704819 | ||
|
|
995714142d | ||
|
|
730a781221 | ||
|
|
77b2807322 | ||
|
|
52e545324e | ||
|
|
0cd4719f3e | ||
|
|
770ed0794e | ||
|
|
e7248b26a1 | ||
|
|
a1e1612c28 | ||
|
|
f3aaba8705 | ||
|
|
34e5f34b39 | ||
|
|
4612627355 | ||
|
|
3e71c621c9 | ||
|
|
b5d218d857 | ||
|
|
bd72e4a8c4 | ||
|
|
3af8c262ac | ||
|
|
7e3bc4177e | ||
|
|
c379a21191 | ||
|
|
6f57470bcc | ||
|
|
df53e28179 | ||
|
|
fbdaff81bd | ||
|
|
71320af66a | ||
|
|
962a596d21 | ||
|
|
0ab1f8ec03 | ||
|
|
b0fe14213e | ||
|
|
23469c3cda | ||
|
|
18824d10ea | ||
|
|
f9b2e92040 | ||
|
|
9c193db5c7 | ||
|
|
6b6ba41269 | ||
|
|
96007cae8c | ||
|
|
5d918b82a8 | ||
|
|
05c9d7ce20 | ||
|
|
943ef50a2d | ||
|
|
7ea4adb5f0 | ||
|
|
71498b32c9 | ||
|
|
ebd5c6d44b | ||
|
|
a8eb797a43 | ||
|
|
929bc0e191 | ||
|
|
f046e326d9 | ||
|
|
3335e0767c | ||
|
|
3395f4e604 | ||
|
|
f03d3e7072 | ||
|
|
b8cf1ed753 | ||
|
|
9263475740 | ||
|
|
0fdc99c65e | ||
|
|
07cc362238 | ||
|
|
4ef67cbfb2 | ||
|
|
c2b6df6e60 | ||
|
|
277d369060 | ||
|
|
7aee90b8d3 | ||
|
|
3147391d94 | ||
|
|
115591b9e3 | ||
|
|
fd100138dd | ||
|
|
1ec173b54e | ||
|
|
aef926abf6 | ||
|
|
f1032255d3 | ||
|
|
f57dec64ef | ||
|
|
926e1a8226 | ||
|
|
cd474d4cd0 | ||
|
|
0b56b62f30 | ||
|
|
44cc96e1a1 | ||
|
|
576e451b10 | ||
|
|
0d89012708 | ||
|
|
6d2506040c | ||
|
|
cb44a003de | ||
|
|
13d7658c5d | ||
|
|
338924602d | ||
|
|
93bff85a42 | ||
|
|
4e0357c6dd | ||
|
|
1e9f623f3e | ||
|
|
4240b480e0 | ||
|
|
5b83d3c4bc | ||
|
|
46ecdcd745 | ||
|
|
9a1691a14e | ||
|
|
bb33880e57 | ||
|
|
237c59a2aa | ||
|
|
3dc42eeaec | ||
|
|
7adc1545b4 | ||
|
|
c0c7b695cd | ||
|
|
c334eece44 | ||
|
|
5ccb72b2e4 | ||
|
|
9c90d5d832 | ||
|
|
5d37114fc0 | ||
|
|
930696fc53 | ||
|
|
56966fd2e6 | ||
|
|
5a3c9eddb4 | ||
|
|
69ec4907da | ||
|
|
7571704a43 | ||
|
|
84955d109f | ||
|
|
601814b575 | ||
|
|
05bab8139a | ||
|
|
eebde572d9 | ||
|
|
8190739f12 | ||
|
|
b6db013435 | ||
|
|
1f6b1c1a1f | ||
|
|
517294d6e1 | ||
|
|
94e2250b36 | ||
|
|
d82d915047 | ||
|
|
380d0e4916 | ||
|
|
e83af2cc24 | ||
|
|
413ff2b531 | ||
|
|
a235ddef39 | ||
|
|
4780d8dfb2 | ||
|
|
fd5d23fdf3 | ||
|
|
a2040ef796 | ||
|
|
c2c0f6f64b | ||
|
|
ee4e099aa2 | ||
|
|
9fc93ce31a | ||
|
|
1374f49f28 | ||
|
|
2d6eaaf687 | ||
|
|
47722a66f2 | ||
|
|
5e75331b9f | ||
|
|
b5fc69bdd8 | ||
|
|
4b683b65df | ||
|
|
1cb1ffd5b2 | ||
|
|
4b502a7215 | ||
|
|
85868564df | ||
|
|
cbb6ae6296 | ||
|
|
573570b6c9 | ||
|
|
98cf1e076f | ||
|
|
ee2a8f7139 | ||
|
|
3835046309 | ||
|
|
4fbd01cd4b | ||
|
|
a883a8797c | ||
|
|
0bd9e9bc45 | ||
|
|
77c66e368c | ||
|
|
2f908f8255 | ||
|
|
82f13830e6 | ||
|
|
d1825cbb68 | ||
|
|
d9288f078d | ||
|
|
85ebd6aff8 | ||
|
|
2947c0cc84 | ||
|
|
25424f4cf1 | ||
|
|
42acbd5700 | ||
|
|
9e0dc8f09b | ||
|
|
da19f7a910 | ||
|
|
fc2cc10842 | ||
|
|
a33855f6ee | ||
|
|
83df5df61b | ||
|
|
ac3c5aad31 | ||
|
|
63abb10000 | ||
|
|
baf601a0e3 | ||
|
|
587a691516 | ||
|
|
8830d66c02 | ||
|
|
54425a39b2 | ||
|
|
34d0be9ec1 | ||
|
|
42a8bdd4d7 | ||
|
|
28564957ac | ||
|
|
ab7fe215f9 | ||
|
|
1f4c0311cd |
37
.clang-tidy
37
.clang-tidy
@@ -1,37 +0,0 @@
|
|||||||
---
|
|
||||||
# Conservative clang-tidy configuration for Eigen.
|
|
||||||
#
|
|
||||||
# Focuses on bug-finding checks with low false-positive rates.
|
|
||||||
# Intentionally omits style-enforcement checks (modernize-*, google-*,
|
|
||||||
# cppcoreguidelines-*) since Eigen has its own conventions and is a
|
|
||||||
# heavily-templated math library where many "modern C++" idioms don't apply.
|
|
||||||
|
|
||||||
Checks: >
|
|
||||||
-*,
|
|
||||||
bugprone-*,
|
|
||||||
-bugprone-narrowing-conversions,
|
|
||||||
-bugprone-easily-swappable-parameters,
|
|
||||||
-bugprone-implicit-widening-of-multiplication-result,
|
|
||||||
-bugprone-exception-escape,
|
|
||||||
misc-redundant-expression,
|
|
||||||
misc-unused-using-decls,
|
|
||||||
misc-misleading-identifier,
|
|
||||||
performance-for-range-copy,
|
|
||||||
performance-implicit-conversion-in-loop,
|
|
||||||
performance-unnecessary-copy-initialization,
|
|
||||||
performance-unnecessary-value-param,
|
|
||||||
readability-container-size-empty,
|
|
||||||
readability-duplicate-include,
|
|
||||||
readability-misleading-indentation,
|
|
||||||
readability-redundant-control-flow,
|
|
||||||
readability-redundant-smartptr-get,
|
|
||||||
|
|
||||||
WarningsAsErrors: ''
|
|
||||||
|
|
||||||
HeaderFilterRegex: 'Eigen/.*|test/.*|blas/.*|lapack/.*|unsupported/Eigen/.*'
|
|
||||||
|
|
||||||
# Eigen uses its own assert macros.
|
|
||||||
CheckOptions:
|
|
||||||
- key: bugprone-assert-side-effect.AssertMacros
|
|
||||||
value: 'eigen_assert,eigen_internal_assert,EIGEN_STATIC_ASSERT,VERIFY,VERIFY_IS_APPROX,VERIFY_IS_EQUAL,VERIFY_IS_MUCH_SMALLER_THAN,VERIFY_IS_NOT_APPROX,VERIFY_IS_NOT_EQUAL,VERIFY_IS_UNITARY,VERIFY_RAISES_ASSERT'
|
|
||||||
...
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
# First major clang-format MR (https://gitlab.com/libeigen/eigen/-/merge_requests/1429).
|
|
||||||
f38e16c193d489c278c189bc06b448a94adb45fb
|
|
||||||
# Formatting of tests, examples, benchmarks, et cetera (https://gitlab.com/libeigen/eigen/-/merge_requests/1432).
|
|
||||||
46e9cdb7fea25d7f7aef4332b9c3ead3857e213d
|
|
||||||
3
.gitattributes
vendored
3
.gitattributes
vendored
@@ -1,3 +0,0 @@
|
|||||||
*.sh eol=lf
|
|
||||||
debug/msvc/*.dat eol=crlf
|
|
||||||
debug/msvc/*.natvis eol=crlf
|
|
||||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -12,7 +12,7 @@ core
|
|||||||
core.*
|
core.*
|
||||||
*.bak
|
*.bak
|
||||||
*~
|
*~
|
||||||
*.build*
|
*build*
|
||||||
*.moc.*
|
*.moc.*
|
||||||
*.moc
|
*.moc
|
||||||
ui_*
|
ui_*
|
||||||
@@ -39,4 +39,3 @@ Makefile
|
|||||||
!scripts/buildtests.in
|
!scripts/buildtests.in
|
||||||
!Eigen/Core
|
!Eigen/Core
|
||||||
!Eigen/src/Core
|
!Eigen/src/Core
|
||||||
CLAUDE.md
|
|
||||||
|
|||||||
@@ -7,27 +7,10 @@
|
|||||||
# Public License v. 2.0. If a copy of the MPL was not distributed
|
# Public License v. 2.0. If a copy of the MPL was not distributed
|
||||||
# with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
# with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
default:
|
|
||||||
interruptible: true
|
|
||||||
|
|
||||||
# For MR pipelines, auto-cancel running jobs when new commits are pushed.
|
|
||||||
# For scheduled (nightly) pipelines, never auto-cancel so all jobs run to
|
|
||||||
# completion and all failures are visible for debugging.
|
|
||||||
workflow:
|
|
||||||
auto_cancel:
|
|
||||||
on_new_commit: interruptible
|
|
||||||
on_job_failure: none
|
|
||||||
rules:
|
|
||||||
- if: $CI_PIPELINE_SOURCE == "schedule"
|
|
||||||
auto_cancel:
|
|
||||||
on_new_commit: none
|
|
||||||
- when: always
|
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- checkformat
|
- checkformat
|
||||||
- build
|
- build
|
||||||
- test
|
- test
|
||||||
- benchmark
|
|
||||||
- deploy
|
- deploy
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
@@ -48,5 +31,4 @@ include:
|
|||||||
- "/ci/build.windows.gitlab-ci.yml"
|
- "/ci/build.windows.gitlab-ci.yml"
|
||||||
- "/ci/test.linux.gitlab-ci.yml"
|
- "/ci/test.linux.gitlab-ci.yml"
|
||||||
- "/ci/test.windows.gitlab-ci.yml"
|
- "/ci/test.windows.gitlab-ci.yml"
|
||||||
- "/ci/benchmark.gitlab-ci.yml"
|
|
||||||
- "/ci/deploy.gitlab-ci.yml"
|
- "/ci/deploy.gitlab-ci.yml"
|
||||||
|
|||||||
@@ -1,37 +1,42 @@
|
|||||||
<!--
|
<!--
|
||||||
Thank you for submitting an issue!
|
Please read this!
|
||||||
|
|
||||||
Before opening a new issue, please search for keywords in the existing [list of issues](https://gitlab.com/libeigen/eigen/-/issues?state=opened) to verify it isn't a duplicate.
|
Before opening a new issue, make sure to search for keywords in the issues
|
||||||
-->
|
filtered by "bug::confirmed" or "bug::unconfirmed" and "bugzilla" label:
|
||||||
|
|
||||||
|
- https://gitlab.com/libeigen/eigen/-/issues?scope=all&utf8=%E2%9C%93&state=opened&label_name[]=bug%3A%3Aconfirmed
|
||||||
|
- https://gitlab.com/libeigen/eigen/-/issues?scope=all&utf8=%E2%9C%93&state=opened&label_name[]=bug%3A%3Aunconfirmed
|
||||||
|
- https://gitlab.com/libeigen/eigen/-/issues?scope=all&utf8=%E2%9C%93&state=opened&label_name[]=bugzilla
|
||||||
|
|
||||||
|
and verify the issue you're about to submit isn't a duplicate. -->
|
||||||
|
|
||||||
### Summary
|
### Summary
|
||||||
<!-- Summarize the bug encountered concisely. -->
|
<!-- Summarize the bug encountered concisely. -->
|
||||||
|
|
||||||
### Environment
|
### Environment
|
||||||
<!-- Please provide your development environment. -->
|
<!-- Please provide your development environment here -->
|
||||||
- **Operating System** : Windows/Linux
|
- **Operating System** : Windows/Linux
|
||||||
- **Architecture** : x64/Arm64/PowerPC ...
|
- **Architecture** : x64/Arm64/PowerPC ...
|
||||||
- **Eigen Version** : 5.0.0
|
- **Eigen Version** : 3.3.9
|
||||||
- **Compiler Version** : gcc-12.0
|
- **Compiler Version** : Gcc7.0
|
||||||
- **Compile Flags** : -O3 -march=native
|
- **Compile Flags** : -O3 -march=native
|
||||||
- **Vector Extension** : SSE/AVX/NEON ...
|
- **Vector Extension** : SSE/AVX/NEON ...
|
||||||
|
|
||||||
### Minimal Example
|
### Minimal Example
|
||||||
<!--
|
<!-- If possible, please create a minimal example here that exhibits the problematic behavior.
|
||||||
Please create a minimal reproducing example here that exhibits the problematic behavior.
|
You can also link to [godbolt](https://godbolt.org). But please note that you need to click
|
||||||
The example should be complete, in that it can fully build and run. See the [the guidelines on stackoverflow](https://stackoverflow.com/help/minimal-reproducible-example) for how to create a good minimal example.
|
the "Share" button in the top right-hand corner of the godbolt page where you reproduce the sample
|
||||||
|
code to get the share link instead of in your browser address bar.
|
||||||
|
|
||||||
You can also link to [godbolt](https://godbolt.org). Note that you need to click
|
You can read [the guidelines on stackoverflow](https://stackoverflow.com/help/minimal-reproducible-example)
|
||||||
the "Share" button in the top right-hand corner of the godbolt page to get the share link
|
on how to create a good minimal example. -->
|
||||||
instead of the URL in your browser address bar.
|
|
||||||
-->
|
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
// Insert your code here.
|
//show your code here
|
||||||
```
|
```
|
||||||
|
|
||||||
### Steps to reproduce the issue
|
### Steps to reproduce
|
||||||
<!-- Describe the necessary steps to reproduce the issue. -->
|
<!-- Describe how one can reproduce the issue - this is very important. Please use an ordered list. -->
|
||||||
|
|
||||||
1. first step
|
1. first step
|
||||||
2. second step
|
2. second step
|
||||||
@@ -44,16 +49,21 @@ instead of the URL in your browser address bar.
|
|||||||
<!-- Describe what you should see instead. -->
|
<!-- Describe what you should see instead. -->
|
||||||
|
|
||||||
### Relevant logs
|
### Relevant logs
|
||||||
<!-- Add relevant build logs or program output within blocks marked by " ``` " -->
|
<!-- Add relevant code snippets or program output within blocks marked by " ``` " -->
|
||||||
|
|
||||||
### [Optional] Benchmark scripts and results
|
<!-- OPTIONAL: remove this section if you are not reporting a compilation warning issue.-->
|
||||||
|
### Warning Messages
|
||||||
|
<!-- Show us the warning messages you got! -->
|
||||||
|
|
||||||
|
<!-- OPTIONAL: remove this section if you are not reporting a performance issue. -->
|
||||||
|
### Benchmark scripts and results
|
||||||
<!-- Please share any benchmark scripts - either standalone, or using [Google Benchmark](https://github.com/google/benchmark). -->
|
<!-- Please share any benchmark scripts - either standalone, or using [Google Benchmark](https://github.com/google/benchmark). -->
|
||||||
|
|
||||||
### Anything else that might help
|
### Anything else that might help
|
||||||
<!--
|
<!-- It will be better to provide us more information to help narrow down the cause.
|
||||||
It will be better to provide us more information to help narrow down the cause.
|
|
||||||
Including but not limited to the following:
|
Including but not limited to the following:
|
||||||
- lines of code that might help us diagnose the problem.
|
- lines of code that might help us diagnose the problem.
|
||||||
- potential ways to address the issue.
|
- potential ways to address the issue.
|
||||||
- last known working/first broken version (release number or commit hash).
|
- last known working/first broken version (release number or commit hash). -->
|
||||||
-->
|
|
||||||
|
- [ ] Have a plan to fix this issue.
|
||||||
|
|||||||
@@ -1,13 +1,6 @@
|
|||||||
<!--
|
|
||||||
Thank you for submitting a Feature Request!
|
|
||||||
|
|
||||||
If you want to run ideas by the maintainers and the Eigen community first,
|
|
||||||
you can chat about them on the [Eigen Discord server](https://discord.gg/2SkEJGqZjR).
|
|
||||||
-->
|
|
||||||
|
|
||||||
### Describe the feature you would like to be implemented.
|
### Describe the feature you would like to be implemented.
|
||||||
|
|
||||||
### Why Would such a feature be useful for other users?
|
### Would such a feature be useful for other users? Why?
|
||||||
|
|
||||||
### Any hints on how to implement the requested feature?
|
### Any hints on how to implement the requested feature?
|
||||||
|
|
||||||
|
|||||||
@@ -1,30 +0,0 @@
|
|||||||
<!--
|
|
||||||
Thanks for contributing a merge request!
|
|
||||||
|
|
||||||
We recommend that first-time contributors read our [contribution guidelines](https://eigen.tuxfamily.org/index.php?title=Contributing_to_Eigen).
|
|
||||||
|
|
||||||
Before submitting the MR, please complete the following checks:
|
|
||||||
- Create one PR per feature or bugfix,
|
|
||||||
- Run the test suite to verify your changes.
|
|
||||||
See our [test guidelines](https://eigen.tuxfamily.org/index.php?title=Tests).
|
|
||||||
- Add tests to cover the bug addressed or any new feature.
|
|
||||||
- Document new features. If it is a substantial change, add it to the [Changelog](https://gitlab.com/libeigen/eigen/-/blob/master/CHANGELOG.md).
|
|
||||||
- Leave the following box checked when submitting: `Allow commits from members who can merge to the target branch`.
|
|
||||||
This allows us to rebase and merge your change.
|
|
||||||
|
|
||||||
Note that we are a team of volunteers; we appreciate your patience during the review process.
|
|
||||||
-->
|
|
||||||
|
|
||||||
### Description
|
|
||||||
<!--Please explain your changes.-->
|
|
||||||
|
|
||||||
%{first_multiline_commit}
|
|
||||||
|
|
||||||
### Reference issue
|
|
||||||
<!--
|
|
||||||
You can link to a specific issue using the gitlab syntax #<issue number>.
|
|
||||||
If the MR fixes an issue, write "Fixes #<issue number>" to have the issue automatically closed on merge.
|
|
||||||
-->
|
|
||||||
|
|
||||||
### Additional information
|
|
||||||
<!--Any additional information you think is important.-->
|
|
||||||
26
.gitlab/merge_request_templates/Merge Request Template.md
Normal file
26
.gitlab/merge_request_templates/Merge Request Template.md
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<!--
|
||||||
|
Thanks for contributing a merge request! Please name and fully describe your MR as you would for a commit message.
|
||||||
|
If the MR fixes an issue, please include "Fixes #issue" in the commit message and the MR description.
|
||||||
|
|
||||||
|
In addition, we recommend that first-time contributors read our [contribution guidelines](https://eigen.tuxfamily.org/index.php?title=Contributing_to_Eigen) and [git page](https://eigen.tuxfamily.org/index.php?title=Git), which will help you submit a more standardized MR.
|
||||||
|
|
||||||
|
Before submitting the MR, you also need to complete the following checks:
|
||||||
|
- Make one PR per feature/bugfix (don't mix multiple changes into one PR). Avoid committing unrelated changes.
|
||||||
|
- Rebase before committing
|
||||||
|
- For code changes, run the test suite (at least the tests that are likely affected by the change).
|
||||||
|
See our [test guidelines](https://eigen.tuxfamily.org/index.php?title=Tests).
|
||||||
|
- If possible, add a test (both for bug-fixes as well as new features)
|
||||||
|
- Make sure new features are documented
|
||||||
|
|
||||||
|
Note that we are a team of volunteers; we appreciate your patience during the review process.
|
||||||
|
|
||||||
|
Again, thanks for contributing! -->
|
||||||
|
|
||||||
|
### Reference issue
|
||||||
|
<!-- You can link to a specific issue using the gitlab syntax #<issue number> -->
|
||||||
|
|
||||||
|
### What does this implement/fix?
|
||||||
|
<!--Please explain your changes.-->
|
||||||
|
|
||||||
|
### Additional information
|
||||||
|
<!--Any additional information you think is important.-->
|
||||||
11
.hgeol
Normal file
11
.hgeol
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
[patterns]
|
||||||
|
*.sh = LF
|
||||||
|
*.MINPACK = CRLF
|
||||||
|
scripts/*.in = LF
|
||||||
|
debug/msvc/*.dat = CRLF
|
||||||
|
debug/msvc/*.natvis = CRLF
|
||||||
|
unsupported/test/mpreal/*.* = CRLF
|
||||||
|
** = native
|
||||||
|
|
||||||
|
[repository]
|
||||||
|
native = LF
|
||||||
1935
CHANGELOG.md
1935
CHANGELOG.md
File diff suppressed because it is too large
Load Diff
231
CMakeLists.txt
231
CMakeLists.txt
@@ -1,4 +1,4 @@
|
|||||||
cmake_minimum_required(VERSION 3.17)
|
cmake_minimum_required(VERSION 3.10.0)
|
||||||
|
|
||||||
#==============================================================================
|
#==============================================================================
|
||||||
# CMake Policy issues.
|
# CMake Policy issues.
|
||||||
@@ -9,7 +9,7 @@ if (POLICY CMP0077)
|
|||||||
endif (POLICY CMP0077)
|
endif (POLICY CMP0077)
|
||||||
|
|
||||||
# NOTE Remove setting the policy once the minimum required CMake version is
|
# NOTE Remove setting the policy once the minimum required CMake version is
|
||||||
# increased to at least 3.21. Retain enabling the export to package registry.
|
# increased to at least 3.15. Retain enabling the export to package registry.
|
||||||
if (POLICY CMP0090)
|
if (POLICY CMP0090)
|
||||||
# The export command does not populate package registry by default
|
# The export command does not populate package registry by default
|
||||||
cmake_policy (SET CMP0090 NEW)
|
cmake_policy (SET CMP0090 NEW)
|
||||||
@@ -29,16 +29,6 @@ if (POLICY CMP0146)
|
|||||||
cmake_policy(SET CMP0146 OLD)
|
cmake_policy(SET CMP0146 OLD)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
# Normalize DESTINATION paths
|
|
||||||
if (POLICY CMP0177)
|
|
||||||
cmake_policy(SET CMP0177 NEW)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
# Respect <PackageName>_ROOT variables.
|
|
||||||
if (POLICY CMP0074)
|
|
||||||
cmake_policy(SET CMP0074 NEW)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
#==============================================================================
|
#==============================================================================
|
||||||
# CMake Project.
|
# CMake Project.
|
||||||
#==============================================================================
|
#==============================================================================
|
||||||
@@ -68,12 +58,19 @@ option(EIGEN_LEAVE_TEST_IN_ALL_TARGET "Leaves tests in the all target, needed by
|
|||||||
option(EIGEN_BUILD_BLAS "Toggles the building of the Eigen Blas library" ${PROJECT_IS_TOP_LEVEL})
|
option(EIGEN_BUILD_BLAS "Toggles the building of the Eigen Blas library" ${PROJECT_IS_TOP_LEVEL})
|
||||||
option(EIGEN_BUILD_LAPACK "Toggles the building of the included Eigen LAPACK library" ${PROJECT_IS_TOP_LEVEL})
|
option(EIGEN_BUILD_LAPACK "Toggles the building of the included Eigen LAPACK library" ${PROJECT_IS_TOP_LEVEL})
|
||||||
if (EIGEN_BUILD_BLAS OR EIGEN_BUILD_LAPACK)
|
if (EIGEN_BUILD_BLAS OR EIGEN_BUILD_LAPACK)
|
||||||
# Determine if we should build shared libraries for BLAS/LAPACK on this platform.
|
# BLAS and LAPACK currently need a fortran compiler.
|
||||||
if (NOT EIGEN_BUILD_SHARED_LIBS)
|
include(CMakeDetermineFortranCompiler)
|
||||||
|
if (NOT CMAKE_Fortran_COMPILER)
|
||||||
|
set(EIGEN_BUILD_BLAS OFF)
|
||||||
|
set(EIGEN_BUILD_LAPACK OFF)
|
||||||
|
else()
|
||||||
|
# Determine if we should build shared libraries for BLAS/LAPACK on this platform.
|
||||||
get_cmake_property(EIGEN_BUILD_SHARED_LIBS TARGET_SUPPORTS_SHARED_LIBS)
|
get_cmake_property(EIGEN_BUILD_SHARED_LIBS TARGET_SUPPORTS_SHARED_LIBS)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
option(EIGEN_BUILD_BTL "Build benchmark suite" OFF)
|
||||||
|
option(EIGEN_BUILD_SPBENCH "Build sparse benchmark suite" OFF)
|
||||||
# Avoid building docs if included from another project.
|
# Avoid building docs if included from another project.
|
||||||
# Building documentation requires creating and running executables on the host
|
# Building documentation requires creating and running executables on the host
|
||||||
# platform. We shouldn't do this if cross-compiling.
|
# platform. We shouldn't do this if cross-compiling.
|
||||||
@@ -90,7 +87,7 @@ if(NOT WIN32 OR NOT CMAKE_HOST_SYSTEM_NAME MATCHES Windows)
|
|||||||
endif()
|
endif()
|
||||||
option(EIGEN_BUILD_CMAKE_PACKAGE "Enables the creation of EigenConfig.cmake and related files" ${PROJECT_IS_TOP_LEVEL})
|
option(EIGEN_BUILD_CMAKE_PACKAGE "Enables the creation of EigenConfig.cmake and related files" ${PROJECT_IS_TOP_LEVEL})
|
||||||
|
|
||||||
if (EIGEN_BUILD_TESTING OR EIGEN_BUILD_BLAS OR EIGEN_BUILD_LAPACK OR EIGEN_BUILD_DOC OR EIGEN_BUILD_DEMOS)
|
if (EIGEN_BUILD_TESTING OR EIGEN_BUILD_BLAS OR EIGEN_BUILD_LAPACK OR EIGEN_BUILT_BTL OR EIGEN_BUILD_BTL OR EIGEN_BUILD_SPBENCH OR EIGEN_BUILD_DOC OR EIGEN_BUILD_DEMOS)
|
||||||
set(EIGEN_IS_BUILDING_ ON)
|
set(EIGEN_IS_BUILDING_ ON)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@@ -98,28 +95,15 @@ endif()
|
|||||||
# Version Info.
|
# Version Info.
|
||||||
#==============================================================================
|
#==============================================================================
|
||||||
|
|
||||||
# If version information is not provided, automatically parse the version number
|
# Automatically parse the version number from header files.
|
||||||
# from header files.
|
file(READ "${PROJECT_SOURCE_DIR}/Eigen/src/Core/util/Macros.h" _eigen_version_header)
|
||||||
file(READ "${PROJECT_SOURCE_DIR}/Eigen/Version" _eigen_version_header)
|
string(REGEX MATCH "define[ \t]+EIGEN_WORLD_VERSION[ \t]+([0-9]+)" _eigen_world_version_match "${_eigen_version_header}")
|
||||||
if (NOT DEFINED EIGEN_WORLD_VERSION)
|
set(EIGEN_WORLD_VERSION "${CMAKE_MATCH_1}")
|
||||||
string(REGEX MATCH "define[ \t]+EIGEN_WORLD_VERSION[ \t]+([0-9]+)" _eigen_world_version_match "${_eigen_version_header}")
|
string(REGEX MATCH "define[ \t]+EIGEN_MAJOR_VERSION[ \t]+([0-9]+)" _eigen_major_version_match "${_eigen_version_header}")
|
||||||
set(EIGEN_WORLD_VERSION "${CMAKE_MATCH_1}" CACHE STRING "")
|
set(EIGEN_MAJOR_VERSION "${CMAKE_MATCH_1}")
|
||||||
endif()
|
string(REGEX MATCH "define[ \t]+EIGEN_MINOR_VERSION[ \t]+([0-9]+)" _eigen_minor_version_match "${_eigen_version_header}")
|
||||||
if (NOT DEFINED EIGEN_MAJOR_VERSION)
|
set(EIGEN_MINOR_VERSION "${CMAKE_MATCH_1}")
|
||||||
string(REGEX MATCH "define[ \t]+EIGEN_MAJOR_VERSION[ \t]+([0-9]+)" _eigen_major_version_match "${_eigen_version_header}")
|
set(EIGEN_VERSION_NUMBER ${EIGEN_WORLD_VERSION}.${EIGEN_MAJOR_VERSION}.${EIGEN_MINOR_VERSION})
|
||||||
set(EIGEN_MAJOR_VERSION "${CMAKE_MATCH_1}" CACHE STRING "")
|
|
||||||
endif()
|
|
||||||
if (NOT DEFINED EIGEN_MINOR_VERSION)
|
|
||||||
string(REGEX MATCH "define[ \t]+EIGEN_MINOR_VERSION[ \t]+([0-9]+)" _eigen_minor_version_match "${_eigen_version_header}")
|
|
||||||
set(EIGEN_MINOR_VERSION "${CMAKE_MATCH_1}" CACHE STRING "")
|
|
||||||
endif()
|
|
||||||
if (NOT DEFINED EIGEN_PATCH_VERSION)
|
|
||||||
string(REGEX MATCH "define[ \t]+EIGEN_PATCH_VERSION[ \t]+([0-9]+)" _eigen_patch_version_match "${_eigen_version_header}")
|
|
||||||
set(EIGEN_PATCH_VERSION "${CMAKE_MATCH_1}" CACHE STRING "")
|
|
||||||
endif()
|
|
||||||
if (NOT DEFINED EIGEN_PRERELEASE_VERSION)
|
|
||||||
set(EIGEN_PRERELEASE_VERSION "dev")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# If we are in a git repo, extract a changeset.
|
# If we are in a git repo, extract a changeset.
|
||||||
if(IS_DIRECTORY ${CMAKE_SOURCE_DIR}/.git)
|
if(IS_DIRECTORY ${CMAKE_SOURCE_DIR}/.git)
|
||||||
@@ -130,32 +114,16 @@ endif()
|
|||||||
|
|
||||||
# extract the git rev number from the git output...
|
# extract the git rev number from the git output...
|
||||||
if(EIGEN_GIT_OUTPUT)
|
if(EIGEN_GIT_OUTPUT)
|
||||||
string(REGEX MATCH "^([0-9;a-f]+).*" EIGEN_GIT_CHANGESET_MATCH "${EIGEN_GIT_OUTPUT}")
|
string(REGEX MATCH "^([0-9;a-f]+).*" EIGEN_GIT_CHANGESET_MATCH "${EIGEN_GIT_OUTPUT}")
|
||||||
set(EIGEN_GIT_REVNUM "${CMAKE_MATCH_1}")
|
set(EIGEN_GIT_REVNUM "${CMAKE_MATCH_1}")
|
||||||
endif()
|
endif()
|
||||||
|
#...and show it next to the version number
|
||||||
if (NOT DEFINED EIGEN_BUILD_VERSION AND DEFINED EIGEN_GIT_REVNUM)
|
if(EIGEN_GIT_REVNUM)
|
||||||
string(SUBSTRING "${EIGEN_GIT_REVNUM}" 0 8 EIGEN_BUILD_VERSION)
|
set(EIGEN_VERSION "${EIGEN_VERSION_NUMBER} (git rev ${EIGEN_GIT_REVNUM})")
|
||||||
else()
|
else()
|
||||||
set(EIGEN_BUILD_VERSION "" CACHE STRING "")
|
set(EIGEN_VERSION "${EIGEN_VERSION_NUMBER}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# The EIGEN_VERSION_NUMBER must be of the form <major.minor.patch>.
|
|
||||||
# The EIGEN_VERSION_STRING can contain the preprelease/build strings.
|
|
||||||
set(EIGEN_VERSION_NUMBER "${EIGEN_MAJOR_VERSION}.${EIGEN_MINOR_VERSION}.${EIGEN_PATCH_VERSION}" CACHE STRING "")
|
|
||||||
set(EIGEN_VERSION_STRING "${EIGEN_VERSION_NUMBER}" CACHE STRING "")
|
|
||||||
if (NOT "x${EIGEN_PRERELEASE_VERSION}" STREQUAL "x")
|
|
||||||
set(EIGEN_VERSION_STRING "${EIGEN_VERSION_STRING}-${EIGEN_PRERELEASE_VERSION}" CACHE STRING "")
|
|
||||||
endif()
|
|
||||||
if (NOT "x${EIGEN_BUILD_VERSION}" STREQUAL "x")
|
|
||||||
set(EIGEN_VERSION_STRING "${EIGEN_VERSION_STRING}+${EIGEN_BUILD_VERSION}" CACHE STRING "")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
|
|
||||||
# Generate version file.
|
|
||||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/Version.in"
|
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/include/Eigen/Version")
|
|
||||||
|
|
||||||
#==============================================================================
|
#==============================================================================
|
||||||
# Install Path Configuration.
|
# Install Path Configuration.
|
||||||
#==============================================================================
|
#==============================================================================
|
||||||
@@ -203,6 +171,14 @@ endforeach()
|
|||||||
# Eigen Library.
|
# Eigen Library.
|
||||||
#==============================================================================
|
#==============================================================================
|
||||||
|
|
||||||
|
set ( EIGEN_VERSION_STRING ${EIGEN_VERSION_NUMBER} )
|
||||||
|
set ( EIGEN_VERSION_MAJOR ${EIGEN_WORLD_VERSION} )
|
||||||
|
set ( EIGEN_VERSION_MINOR ${EIGEN_MAJOR_VERSION} )
|
||||||
|
set ( EIGEN_VERSION_PATCH ${EIGEN_MINOR_VERSION} )
|
||||||
|
set ( EIGEN_DEFINITIONS "")
|
||||||
|
set ( EIGEN_INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/${INCLUDE_INSTALL_DIR}" )
|
||||||
|
set ( EIGEN_ROOT_DIR ${CMAKE_INSTALL_PREFIX} )
|
||||||
|
|
||||||
# Alias Eigen_*_DIR to Eigen3_*_DIR:
|
# Alias Eigen_*_DIR to Eigen3_*_DIR:
|
||||||
set(Eigen_SOURCE_DIR ${Eigen3_SOURCE_DIR})
|
set(Eigen_SOURCE_DIR ${Eigen3_SOURCE_DIR})
|
||||||
set(Eigen_BINARY_DIR ${Eigen3_BINARY_DIR})
|
set(Eigen_BINARY_DIR ${Eigen3_BINARY_DIR})
|
||||||
@@ -215,9 +191,6 @@ target_include_directories (eigen INTERFACE
|
|||||||
$<INSTALL_INTERFACE:${INCLUDE_INSTALL_DIR}>
|
$<INSTALL_INTERFACE:${INCLUDE_INSTALL_DIR}>
|
||||||
)
|
)
|
||||||
|
|
||||||
# Eigen requires at least C++14
|
|
||||||
target_compile_features (eigen INTERFACE cxx_std_14)
|
|
||||||
|
|
||||||
# Export as title case Eigen
|
# Export as title case Eigen
|
||||||
set_target_properties (eigen PROPERTIES EXPORT_NAME Eigen)
|
set_target_properties (eigen PROPERTIES EXPORT_NAME Eigen)
|
||||||
|
|
||||||
@@ -237,9 +210,6 @@ if(EIGEN_BUILD_PKGCONFIG)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
install(DIRECTORY Eigen DESTINATION ${INCLUDE_INSTALL_DIR} COMPONENT Devel)
|
install(DIRECTORY Eigen DESTINATION ${INCLUDE_INSTALL_DIR} COMPONENT Devel)
|
||||||
# Replace the "Version" header file with the generated one.
|
|
||||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/include/Eigen/Version
|
|
||||||
DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/ COMPONENT Devel)
|
|
||||||
|
|
||||||
install(TARGETS eigen EXPORT Eigen3Targets)
|
install(TARGETS eigen EXPORT Eigen3Targets)
|
||||||
|
|
||||||
@@ -248,6 +218,7 @@ if(EIGEN_BUILD_CMAKE_PACKAGE)
|
|||||||
configure_package_config_file (
|
configure_package_config_file (
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/cmake/Eigen3Config.cmake.in
|
${CMAKE_CURRENT_SOURCE_DIR}/cmake/Eigen3Config.cmake.in
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/Eigen3Config.cmake
|
${CMAKE_CURRENT_BINARY_DIR}/Eigen3Config.cmake
|
||||||
|
PATH_VARS EIGEN_INCLUDE_DIR EIGEN_ROOT_DIR
|
||||||
INSTALL_DESTINATION ${CMAKEPACKAGE_INSTALL_DIR}
|
INSTALL_DESTINATION ${CMAKEPACKAGE_INSTALL_DIR}
|
||||||
NO_SET_AND_CHECK_MACRO # Eigen does not provide legacy style defines
|
NO_SET_AND_CHECK_MACRO # Eigen does not provide legacy style defines
|
||||||
NO_CHECK_REQUIRED_COMPONENTS_MACRO # Eigen does not provide components
|
NO_CHECK_REQUIRED_COMPONENTS_MACRO # Eigen does not provide components
|
||||||
@@ -267,12 +238,13 @@ if(EIGEN_BUILD_CMAKE_PACKAGE)
|
|||||||
|
|
||||||
install (EXPORT Eigen3Targets NAMESPACE Eigen3:: DESTINATION ${CMAKEPACKAGE_INSTALL_DIR})
|
install (EXPORT Eigen3Targets NAMESPACE Eigen3:: DESTINATION ${CMAKEPACKAGE_INSTALL_DIR})
|
||||||
|
|
||||||
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/Eigen3Config.cmake
|
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/UseEigen3.cmake
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/Eigen3Config.cmake
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/Eigen3ConfigVersion.cmake
|
${CMAKE_CURRENT_BINARY_DIR}/Eigen3ConfigVersion.cmake
|
||||||
DESTINATION ${CMAKEPACKAGE_INSTALL_DIR})
|
DESTINATION ${CMAKEPACKAGE_INSTALL_DIR})
|
||||||
|
|
||||||
# Add uninstall target
|
# Add uninstall target
|
||||||
if(NOT TARGET uninstall AND PROJECT_IS_TOP_LEVEL)
|
if(NOT TARGET uninstall)
|
||||||
add_custom_target ( uninstall
|
add_custom_target ( uninstall
|
||||||
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/EigenUninstall.cmake)
|
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/EigenUninstall.cmake)
|
||||||
endif()
|
endif()
|
||||||
@@ -282,13 +254,6 @@ endif()
|
|||||||
# General Build Configuration.
|
# General Build Configuration.
|
||||||
#==============================================================================
|
#==============================================================================
|
||||||
|
|
||||||
# Avoid setting the standard in a parent if unset.
|
|
||||||
if(PROJECT_IS_TOP_LEVEL)
|
|
||||||
set(CMAKE_CXX_STANDARD 14 CACHE STRING "Default C++ standard")
|
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON CACHE BOOL "Require C++ standard")
|
|
||||||
set(CMAKE_CXX_EXTENSIONS OFF CACHE BOOL "Allow C++ extensions")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Guard against in-source builds
|
# Guard against in-source builds
|
||||||
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
|
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
|
||||||
message(FATAL_ERROR "In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there. You may need to remove CMakeCache.txt. ")
|
message(FATAL_ERROR "In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there. You may need to remove CMakeCache.txt. ")
|
||||||
@@ -308,29 +273,17 @@ if (EIGEN_IS_BUILDING_)
|
|||||||
set(CMAKE_INCLUDE_CURRENT_DIR OFF)
|
set(CMAKE_INCLUDE_CURRENT_DIR OFF)
|
||||||
|
|
||||||
find_package(StandardMathLibrary)
|
find_package(StandardMathLibrary)
|
||||||
find_package(AOCL QUIET)
|
|
||||||
set(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO "")
|
set(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO "")
|
||||||
if(AOCL_FOUND)
|
if(NOT STANDARD_MATH_LIBRARY_FOUND)
|
||||||
list(APPEND EIGEN_STANDARD_LIBRARIES_TO_LINK_TO ${AOCL_LIBRARIES})
|
message(FATAL_ERROR
|
||||||
if(AOCL_INCLUDE_DIRS)
|
"Can't link to the standard math library. Please report to the Eigen developers, telling them about your platform.")
|
||||||
include_directories(${AOCL_INCLUDE_DIRS})
|
else()
|
||||||
|
if(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO)
|
||||||
|
set(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO "${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO} ${STANDARD_MATH_LIBRARY}")
|
||||||
|
else()
|
||||||
|
set(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO "${STANDARD_MATH_LIBRARY}")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT STANDARD_MATH_LIBRARY_FOUND)
|
|
||||||
message(FATAL_ERROR
|
|
||||||
"Can't link to the standard math library. Please report to the Eigen developers, telling them about your platform.")
|
|
||||||
else()
|
|
||||||
if(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO)
|
|
||||||
set(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO "${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO} ${STANDARD_MATH_LIBRARY}")
|
|
||||||
else()
|
|
||||||
set(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO "${STANDARD_MATH_LIBRARY}")
|
|
||||||
endif()
|
|
||||||
# Clean up any leading/trailing whitespace in the variable to avoid CMP0004 errors
|
|
||||||
string(STRIP "${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO}" EIGEN_STANDARD_LIBRARIES_TO_LINK_TO)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
|
|
||||||
if(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO)
|
if(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO)
|
||||||
message(STATUS "Standard libraries to link to explicitly: ${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO}")
|
message(STATUS "Standard libraries to link to explicitly: ${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO}")
|
||||||
else()
|
else()
|
||||||
@@ -373,6 +326,19 @@ if (EIGEN_BUILD_TESTING)
|
|||||||
endif()
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
check_cxx_compiler_flag("-std=c++11" EIGEN_COMPILER_SUPPORT_CPP11)
|
||||||
|
|
||||||
|
option(EIGEN_TEST_CXX11 "Enable testing with C++11 and C++11 features (e.g. Tensor module)." ${EIGEN_COMPILER_SUPPORT_CPP11})
|
||||||
|
if(EIGEN_TEST_CXX11)
|
||||||
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
|
if(EIGEN_COMPILER_SUPPORT_CPP11)
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
ei_add_cxx_compiler_flag("-std=c++03")
|
||||||
|
endif()
|
||||||
|
|
||||||
set(EIGEN_TEST_CUSTOM_LINKER_FLAGS "" CACHE STRING "Additional linker flags when linking unit tests.")
|
set(EIGEN_TEST_CUSTOM_LINKER_FLAGS "" CACHE STRING "Additional linker flags when linking unit tests.")
|
||||||
set(EIGEN_TEST_CUSTOM_CXX_FLAGS "" CACHE STRING "Additional compiler flags when compiling unit tests.")
|
set(EIGEN_TEST_CUSTOM_CXX_FLAGS "" CACHE STRING "Additional compiler flags when compiling unit tests.")
|
||||||
# Convert space-separated arguments into CMake lists for downstream consumption.
|
# Convert space-separated arguments into CMake lists for downstream consumption.
|
||||||
@@ -414,29 +380,12 @@ if (EIGEN_BUILD_TESTING)
|
|||||||
ei_add_cxx_compiler_flag("-Wno-psabi")
|
ei_add_cxx_compiler_flag("-Wno-psabi")
|
||||||
ei_add_cxx_compiler_flag("-Wno-variadic-macros")
|
ei_add_cxx_compiler_flag("-Wno-variadic-macros")
|
||||||
ei_add_cxx_compiler_flag("-Wno-long-long")
|
ei_add_cxx_compiler_flag("-Wno-long-long")
|
||||||
ei_add_cxx_compiler_flag("-Wno-pass-failed") # disable clang's warning for unrolling when the loop count is dynamic.
|
ei_add_cxx_compiler_flag("-fno-check-new")
|
||||||
ei_add_cxx_compiler_flag("-fno-common")
|
ei_add_cxx_compiler_flag("-fno-common")
|
||||||
ei_add_cxx_compiler_flag("-fstrict-aliasing")
|
ei_add_cxx_compiler_flag("-fstrict-aliasing")
|
||||||
ei_add_cxx_compiler_flag("-wd981") # disable ICC's "operands are evaluated in unspecified order" remark
|
ei_add_cxx_compiler_flag("-wd981") # disable ICC's "operands are evaluated in unspecified order" remark
|
||||||
ei_add_cxx_compiler_flag("-wd2304") # disable ICC's "warning #2304: non-explicit constructor with single argument may cause implicit type conversion" produced by -Wnon-virtual-dtor
|
ei_add_cxx_compiler_flag("-wd2304") # disable ICC's "warning #2304: non-explicit constructor with single argument may cause implicit type conversion" produced by -Wnon-virtual-dtor
|
||||||
|
|
||||||
# Clang emits warnings about unused flag.
|
|
||||||
if (NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
|
||||||
ei_add_cxx_compiler_flag("-fno-check-new")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# GCC 12+ emits false-positive -Warray-bounds, -Wmaybe-uninitialized,
|
|
||||||
# -Wstringop-overread, and -Wnonnull warnings at -O2/-O3 in heavily
|
|
||||||
# templated code with mixed static/dynamic sizes. These are well-known
|
|
||||||
# compiler bugs (see GCC PR 109394, 106247, 105329, 98610, among others).
|
|
||||||
if (CMAKE_COMPILER_IS_GNUCXX)
|
|
||||||
ei_add_cxx_compiler_flag("-Wno-array-bounds")
|
|
||||||
ei_add_cxx_compiler_flag("-Wno-maybe-uninitialized")
|
|
||||||
ei_add_cxx_compiler_flag("-Wno-stringop-overread")
|
|
||||||
ei_add_cxx_compiler_flag("-Wno-nonnull")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
|
|
||||||
if(ANDROID_NDK)
|
if(ANDROID_NDK)
|
||||||
ei_add_cxx_compiler_flag("-pie")
|
ei_add_cxx_compiler_flag("-pie")
|
||||||
ei_add_cxx_compiler_flag("-fPIE")
|
ei_add_cxx_compiler_flag("-fPIE")
|
||||||
@@ -534,12 +483,6 @@ if (EIGEN_BUILD_TESTING)
|
|||||||
message(STATUS "Enabling MSA in tests/examples")
|
message(STATUS "Enabling MSA in tests/examples")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
option(EIGEN_TEST_LSX "Enable/Disable LSX in tests/examples" OFF)
|
|
||||||
if(EIGEN_TEST_LSX)
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mlsx")
|
|
||||||
message(STATUS "Enabling LSX in tests/examples")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
option(EIGEN_TEST_NEON "Enable/Disable Neon in tests/examples" OFF)
|
option(EIGEN_TEST_NEON "Enable/Disable Neon in tests/examples" OFF)
|
||||||
if(EIGEN_TEST_NEON)
|
if(EIGEN_TEST_NEON)
|
||||||
if(EIGEN_TEST_FMA)
|
if(EIGEN_TEST_FMA)
|
||||||
@@ -672,7 +615,7 @@ if (EIGEN_BUILD_TESTING)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(EIGEN_CUDA_CXX_FLAGS "" CACHE STRING "Additional flags to pass to the cuda compiler.")
|
set(EIGEN_CUDA_CXX_FLAGS "" CACHE STRING "Additional flags to pass to the cuda compiler.")
|
||||||
set(EIGEN_CUDA_COMPUTE_ARCH 70 CACHE STRING "The CUDA compute architecture(s) to target when compiling CUDA code")
|
set(EIGEN_CUDA_COMPUTE_ARCH 30 CACHE STRING "The CUDA compute architecture(s) to target when compiling CUDA code")
|
||||||
|
|
||||||
option(EIGEN_TEST_SYCL "Add Sycl support." OFF)
|
option(EIGEN_TEST_SYCL "Add Sycl support." OFF)
|
||||||
if(EIGEN_TEST_SYCL)
|
if(EIGEN_TEST_SYCL)
|
||||||
@@ -762,6 +705,15 @@ if(EIGEN_BUILD_DOC)
|
|||||||
add_subdirectory(doc EXCLUDE_FROM_ALL)
|
add_subdirectory(doc EXCLUDE_FROM_ALL)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# TODO: consider also replacing EIGEN_BUILD_BTL by a custom target "make btl"?
|
||||||
|
if(EIGEN_BUILD_BTL)
|
||||||
|
add_subdirectory(bench/btl EXCLUDE_FROM_ALL)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT WIN32 AND EIGEN_BUILD_SPBENCH)
|
||||||
|
add_subdirectory(bench/spbench EXCLUDE_FROM_ALL)
|
||||||
|
endif()
|
||||||
|
|
||||||
if (EIGEN_BUILD_DEMOS)
|
if (EIGEN_BUILD_DEMOS)
|
||||||
add_subdirectory(demos EXCLUDE_FROM_ALL)
|
add_subdirectory(demos EXCLUDE_FROM_ALL)
|
||||||
endif()
|
endif()
|
||||||
@@ -783,37 +735,36 @@ if(PROJECT_IS_TOP_LEVEL)
|
|||||||
else()
|
else()
|
||||||
message(STATUS "Available targets (use: cmake --build . --target TARGET):")
|
message(STATUS "Available targets (use: cmake --build . --target TARGET):")
|
||||||
endif()
|
endif()
|
||||||
message(STATUS "------------+--------------------------------------------------------------")
|
message(STATUS "---------+--------------------------------------------------------------")
|
||||||
message(STATUS "Target | Description")
|
message(STATUS "Target | Description")
|
||||||
message(STATUS "------------+--------------------------------------------------------------")
|
message(STATUS "---------+--------------------------------------------------------------")
|
||||||
message(STATUS "install | Install Eigen. Headers will be installed to:")
|
message(STATUS "install | Install Eigen. Headers will be installed to:")
|
||||||
message(STATUS " | <CMAKE_INSTALL_PREFIX>/<INCLUDE_INSTALL_DIR>")
|
message(STATUS " | <CMAKE_INSTALL_PREFIX>/<INCLUDE_INSTALL_DIR>")
|
||||||
message(STATUS " | Using the following values:")
|
message(STATUS " | Using the following values:")
|
||||||
message(STATUS " | CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
|
message(STATUS " | CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
|
||||||
message(STATUS " | INCLUDE_INSTALL_DIR: ${INCLUDE_INSTALL_DIR}")
|
message(STATUS " | INCLUDE_INSTALL_DIR: ${INCLUDE_INSTALL_DIR}")
|
||||||
message(STATUS " | Change the install location of Eigen headers using:")
|
message(STATUS " | Change the install location of Eigen headers using:")
|
||||||
message(STATUS " | cmake . -DCMAKE_INSTALL_PREFIX=yourprefix")
|
message(STATUS " | cmake . -DCMAKE_INSTALL_PREFIX=yourprefix")
|
||||||
message(STATUS " | Or:")
|
message(STATUS " | Or:")
|
||||||
message(STATUS " | cmake . -DINCLUDE_INSTALL_DIR=yourdir")
|
message(STATUS " | cmake . -DINCLUDE_INSTALL_DIR=yourdir")
|
||||||
message(STATUS "uninstall | Remove files installed by the install target")
|
message(STATUS "uninstall| Remove files installed by the install target")
|
||||||
if (EIGEN_BUILD_DOC)
|
if (EIGEN_BUILD_DOC)
|
||||||
message(STATUS "doc | Generate the API documentation, requires Doxygen & LaTeX")
|
message(STATUS "doc | Generate the API documentation, requires Doxygen & LaTeX")
|
||||||
message(STATUS "install-doc | Install the API documentation")
|
|
||||||
endif()
|
endif()
|
||||||
if(EIGEN_BUILD_TESTING)
|
if(EIGEN_BUILD_TESTING)
|
||||||
message(STATUS "check | Build and run the unit-tests. Read this page:")
|
message(STATUS "check | Build and run the unit-tests. Read this page:")
|
||||||
message(STATUS " | http://eigen.tuxfamily.org/index.php?title=Tests")
|
message(STATUS " | http://eigen.tuxfamily.org/index.php?title=Tests")
|
||||||
endif()
|
endif()
|
||||||
if (EIGEN_BUILD_BLAS)
|
if (EIGEN_BUILD_BLAS)
|
||||||
message(STATUS "blas | Build BLAS library (not the same thing as Eigen)")
|
message(STATUS "blas | Build BLAS library (not the same thing as Eigen)")
|
||||||
endif()
|
endif()
|
||||||
if (EIGEN_BUILD_LAPACK)
|
if (EIGEN_BUILD_LAPACK)
|
||||||
message(STATUS "lapack | Build LAPACK subset library (not the same thing as Eigen)")
|
message(STATUS "lapack | Build LAPACK subset library (not the same thing as Eigen)")
|
||||||
endif()
|
endif()
|
||||||
message(STATUS "------------+--------------------------------------------------------------")
|
message(STATUS "---------+--------------------------------------------------------------")
|
||||||
message(STATUS "")
|
message(STATUS "")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
message(STATUS "")
|
message(STATUS "")
|
||||||
message(STATUS "Configured Eigen ${EIGEN_VERSION_STRING}")
|
message(STATUS "Configured Eigen ${EIGEN_VERSION_NUMBER}")
|
||||||
message(STATUS "")
|
message(STATUS "")
|
||||||
|
|||||||
674
COPYING.GPL
Normal file
674
COPYING.GPL
Normal file
@@ -0,0 +1,674 @@
|
|||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short
|
||||||
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, your program's commands
|
||||||
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
|
<http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your program
|
||||||
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
|
may consider it more useful to permit linking proprietary applications with
|
||||||
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License. But first, please read
|
||||||
|
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||||
502
COPYING.LGPL
Normal file
502
COPYING.LGPL
Normal file
@@ -0,0 +1,502 @@
|
|||||||
|
GNU LESSER GENERAL PUBLIC LICENSE
|
||||||
|
Version 2.1, February 1999
|
||||||
|
|
||||||
|
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||||
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
[This is the first released version of the Lesser GPL. It also counts
|
||||||
|
as the successor of the GNU Library Public License, version 2, hence
|
||||||
|
the version number 2.1.]
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The licenses for most software are designed to take away your
|
||||||
|
freedom to share and change it. By contrast, the GNU General Public
|
||||||
|
Licenses are intended to guarantee your freedom to share and change
|
||||||
|
free software--to make sure the software is free for all its users.
|
||||||
|
|
||||||
|
This license, the Lesser General Public License, applies to some
|
||||||
|
specially designated software packages--typically libraries--of the
|
||||||
|
Free Software Foundation and other authors who decide to use it. You
|
||||||
|
can use it too, but we suggest you first think carefully about whether
|
||||||
|
this license or the ordinary General Public License is the better
|
||||||
|
strategy to use in any particular case, based on the explanations below.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom of use,
|
||||||
|
not price. Our General Public Licenses are designed to make sure that
|
||||||
|
you have the freedom to distribute copies of free software (and charge
|
||||||
|
for this service if you wish); that you receive source code or can get
|
||||||
|
it if you want it; that you can change the software and use pieces of
|
||||||
|
it in new free programs; and that you are informed that you can do
|
||||||
|
these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to make restrictions that forbid
|
||||||
|
distributors to deny you these rights or to ask you to surrender these
|
||||||
|
rights. These restrictions translate to certain responsibilities for
|
||||||
|
you if you distribute copies of the library or if you modify it.
|
||||||
|
|
||||||
|
For example, if you distribute copies of the library, whether gratis
|
||||||
|
or for a fee, you must give the recipients all the rights that we gave
|
||||||
|
you. You must make sure that they, too, receive or can get the source
|
||||||
|
code. If you link other code with the library, you must provide
|
||||||
|
complete object files to the recipients, so that they can relink them
|
||||||
|
with the library after making changes to the library and recompiling
|
||||||
|
it. And you must show them these terms so they know their rights.
|
||||||
|
|
||||||
|
We protect your rights with a two-step method: (1) we copyright the
|
||||||
|
library, and (2) we offer you this license, which gives you legal
|
||||||
|
permission to copy, distribute and/or modify the library.
|
||||||
|
|
||||||
|
To protect each distributor, we want to make it very clear that
|
||||||
|
there is no warranty for the free library. Also, if the library is
|
||||||
|
modified by someone else and passed on, the recipients should know
|
||||||
|
that what they have is not the original version, so that the original
|
||||||
|
author's reputation will not be affected by problems that might be
|
||||||
|
introduced by others.
|
||||||
|
|
||||||
|
Finally, software patents pose a constant threat to the existence of
|
||||||
|
any free program. We wish to make sure that a company cannot
|
||||||
|
effectively restrict the users of a free program by obtaining a
|
||||||
|
restrictive license from a patent holder. Therefore, we insist that
|
||||||
|
any patent license obtained for a version of the library must be
|
||||||
|
consistent with the full freedom of use specified in this license.
|
||||||
|
|
||||||
|
Most GNU software, including some libraries, is covered by the
|
||||||
|
ordinary GNU General Public License. This license, the GNU Lesser
|
||||||
|
General Public License, applies to certain designated libraries, and
|
||||||
|
is quite different from the ordinary General Public License. We use
|
||||||
|
this license for certain libraries in order to permit linking those
|
||||||
|
libraries into non-free programs.
|
||||||
|
|
||||||
|
When a program is linked with a library, whether statically or using
|
||||||
|
a shared library, the combination of the two is legally speaking a
|
||||||
|
combined work, a derivative of the original library. The ordinary
|
||||||
|
General Public License therefore permits such linking only if the
|
||||||
|
entire combination fits its criteria of freedom. The Lesser General
|
||||||
|
Public License permits more lax criteria for linking other code with
|
||||||
|
the library.
|
||||||
|
|
||||||
|
We call this license the "Lesser" General Public License because it
|
||||||
|
does Less to protect the user's freedom than the ordinary General
|
||||||
|
Public License. It also provides other free software developers Less
|
||||||
|
of an advantage over competing non-free programs. These disadvantages
|
||||||
|
are the reason we use the ordinary General Public License for many
|
||||||
|
libraries. However, the Lesser license provides advantages in certain
|
||||||
|
special circumstances.
|
||||||
|
|
||||||
|
For example, on rare occasions, there may be a special need to
|
||||||
|
encourage the widest possible use of a certain library, so that it becomes
|
||||||
|
a de-facto standard. To achieve this, non-free programs must be
|
||||||
|
allowed to use the library. A more frequent case is that a free
|
||||||
|
library does the same job as widely used non-free libraries. In this
|
||||||
|
case, there is little to gain by limiting the free library to free
|
||||||
|
software only, so we use the Lesser General Public License.
|
||||||
|
|
||||||
|
In other cases, permission to use a particular library in non-free
|
||||||
|
programs enables a greater number of people to use a large body of
|
||||||
|
free software. For example, permission to use the GNU C Library in
|
||||||
|
non-free programs enables many more people to use the whole GNU
|
||||||
|
operating system, as well as its variant, the GNU/Linux operating
|
||||||
|
system.
|
||||||
|
|
||||||
|
Although the Lesser General Public License is Less protective of the
|
||||||
|
users' freedom, it does ensure that the user of a program that is
|
||||||
|
linked with the Library has the freedom and the wherewithal to run
|
||||||
|
that program using a modified version of the Library.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow. Pay close attention to the difference between a
|
||||||
|
"work based on the library" and a "work that uses the library". The
|
||||||
|
former contains code derived from the library, whereas the latter must
|
||||||
|
be combined with the library in order to run.
|
||||||
|
|
||||||
|
GNU LESSER GENERAL PUBLIC LICENSE
|
||||||
|
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||||
|
|
||||||
|
0. This License Agreement applies to any software library or other
|
||||||
|
program which contains a notice placed by the copyright holder or
|
||||||
|
other authorized party saying it may be distributed under the terms of
|
||||||
|
this Lesser General Public License (also called "this License").
|
||||||
|
Each licensee is addressed as "you".
|
||||||
|
|
||||||
|
A "library" means a collection of software functions and/or data
|
||||||
|
prepared so as to be conveniently linked with application programs
|
||||||
|
(which use some of those functions and data) to form executables.
|
||||||
|
|
||||||
|
The "Library", below, refers to any such software library or work
|
||||||
|
which has been distributed under these terms. A "work based on the
|
||||||
|
Library" means either the Library or any derivative work under
|
||||||
|
copyright law: that is to say, a work containing the Library or a
|
||||||
|
portion of it, either verbatim or with modifications and/or translated
|
||||||
|
straightforwardly into another language. (Hereinafter, translation is
|
||||||
|
included without limitation in the term "modification".)
|
||||||
|
|
||||||
|
"Source code" for a work means the preferred form of the work for
|
||||||
|
making modifications to it. For a library, complete source code means
|
||||||
|
all the source code for all modules it contains, plus any associated
|
||||||
|
interface definition files, plus the scripts used to control compilation
|
||||||
|
and installation of the library.
|
||||||
|
|
||||||
|
Activities other than copying, distribution and modification are not
|
||||||
|
covered by this License; they are outside its scope. The act of
|
||||||
|
running a program using the Library is not restricted, and output from
|
||||||
|
such a program is covered only if its contents constitute a work based
|
||||||
|
on the Library (independent of the use of the Library in a tool for
|
||||||
|
writing it). Whether that is true depends on what the Library does
|
||||||
|
and what the program that uses the Library does.
|
||||||
|
|
||||||
|
1. You may copy and distribute verbatim copies of the Library's
|
||||||
|
complete source code as you receive it, in any medium, provided that
|
||||||
|
you conspicuously and appropriately publish on each copy an
|
||||||
|
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||||
|
all the notices that refer to this License and to the absence of any
|
||||||
|
warranty; and distribute a copy of this License along with the
|
||||||
|
Library.
|
||||||
|
|
||||||
|
You may charge a fee for the physical act of transferring a copy,
|
||||||
|
and you may at your option offer warranty protection in exchange for a
|
||||||
|
fee.
|
||||||
|
|
||||||
|
2. You may modify your copy or copies of the Library or any portion
|
||||||
|
of it, thus forming a work based on the Library, and copy and
|
||||||
|
distribute such modifications or work under the terms of Section 1
|
||||||
|
above, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The modified work must itself be a software library.
|
||||||
|
|
||||||
|
b) You must cause the files modified to carry prominent notices
|
||||||
|
stating that you changed the files and the date of any change.
|
||||||
|
|
||||||
|
c) You must cause the whole of the work to be licensed at no
|
||||||
|
charge to all third parties under the terms of this License.
|
||||||
|
|
||||||
|
d) If a facility in the modified Library refers to a function or a
|
||||||
|
table of data to be supplied by an application program that uses
|
||||||
|
the facility, other than as an argument passed when the facility
|
||||||
|
is invoked, then you must make a good faith effort to ensure that,
|
||||||
|
in the event an application does not supply such function or
|
||||||
|
table, the facility still operates, and performs whatever part of
|
||||||
|
its purpose remains meaningful.
|
||||||
|
|
||||||
|
(For example, a function in a library to compute square roots has
|
||||||
|
a purpose that is entirely well-defined independent of the
|
||||||
|
application. Therefore, Subsection 2d requires that any
|
||||||
|
application-supplied function or table used by this function must
|
||||||
|
be optional: if the application does not supply it, the square
|
||||||
|
root function must still compute square roots.)
|
||||||
|
|
||||||
|
These requirements apply to the modified work as a whole. If
|
||||||
|
identifiable sections of that work are not derived from the Library,
|
||||||
|
and can be reasonably considered independent and separate works in
|
||||||
|
themselves, then this License, and its terms, do not apply to those
|
||||||
|
sections when you distribute them as separate works. But when you
|
||||||
|
distribute the same sections as part of a whole which is a work based
|
||||||
|
on the Library, the distribution of the whole must be on the terms of
|
||||||
|
this License, whose permissions for other licensees extend to the
|
||||||
|
entire whole, and thus to each and every part regardless of who wrote
|
||||||
|
it.
|
||||||
|
|
||||||
|
Thus, it is not the intent of this section to claim rights or contest
|
||||||
|
your rights to work written entirely by you; rather, the intent is to
|
||||||
|
exercise the right to control the distribution of derivative or
|
||||||
|
collective works based on the Library.
|
||||||
|
|
||||||
|
In addition, mere aggregation of another work not based on the Library
|
||||||
|
with the Library (or with a work based on the Library) on a volume of
|
||||||
|
a storage or distribution medium does not bring the other work under
|
||||||
|
the scope of this License.
|
||||||
|
|
||||||
|
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||||
|
License instead of this License to a given copy of the Library. To do
|
||||||
|
this, you must alter all the notices that refer to this License, so
|
||||||
|
that they refer to the ordinary GNU General Public License, version 2,
|
||||||
|
instead of to this License. (If a newer version than version 2 of the
|
||||||
|
ordinary GNU General Public License has appeared, then you can specify
|
||||||
|
that version instead if you wish.) Do not make any other change in
|
||||||
|
these notices.
|
||||||
|
|
||||||
|
Once this change is made in a given copy, it is irreversible for
|
||||||
|
that copy, so the ordinary GNU General Public License applies to all
|
||||||
|
subsequent copies and derivative works made from that copy.
|
||||||
|
|
||||||
|
This option is useful when you wish to copy part of the code of
|
||||||
|
the Library into a program that is not a library.
|
||||||
|
|
||||||
|
4. You may copy and distribute the Library (or a portion or
|
||||||
|
derivative of it, under Section 2) in object code or executable form
|
||||||
|
under the terms of Sections 1 and 2 above provided that you accompany
|
||||||
|
it with the complete corresponding machine-readable source code, which
|
||||||
|
must be distributed under the terms of Sections 1 and 2 above on a
|
||||||
|
medium customarily used for software interchange.
|
||||||
|
|
||||||
|
If distribution of object code is made by offering access to copy
|
||||||
|
from a designated place, then offering equivalent access to copy the
|
||||||
|
source code from the same place satisfies the requirement to
|
||||||
|
distribute the source code, even though third parties are not
|
||||||
|
compelled to copy the source along with the object code.
|
||||||
|
|
||||||
|
5. A program that contains no derivative of any portion of the
|
||||||
|
Library, but is designed to work with the Library by being compiled or
|
||||||
|
linked with it, is called a "work that uses the Library". Such a
|
||||||
|
work, in isolation, is not a derivative work of the Library, and
|
||||||
|
therefore falls outside the scope of this License.
|
||||||
|
|
||||||
|
However, linking a "work that uses the Library" with the Library
|
||||||
|
creates an executable that is a derivative of the Library (because it
|
||||||
|
contains portions of the Library), rather than a "work that uses the
|
||||||
|
library". The executable is therefore covered by this License.
|
||||||
|
Section 6 states terms for distribution of such executables.
|
||||||
|
|
||||||
|
When a "work that uses the Library" uses material from a header file
|
||||||
|
that is part of the Library, the object code for the work may be a
|
||||||
|
derivative work of the Library even though the source code is not.
|
||||||
|
Whether this is true is especially significant if the work can be
|
||||||
|
linked without the Library, or if the work is itself a library. The
|
||||||
|
threshold for this to be true is not precisely defined by law.
|
||||||
|
|
||||||
|
If such an object file uses only numerical parameters, data
|
||||||
|
structure layouts and accessors, and small macros and small inline
|
||||||
|
functions (ten lines or less in length), then the use of the object
|
||||||
|
file is unrestricted, regardless of whether it is legally a derivative
|
||||||
|
work. (Executables containing this object code plus portions of the
|
||||||
|
Library will still fall under Section 6.)
|
||||||
|
|
||||||
|
Otherwise, if the work is a derivative of the Library, you may
|
||||||
|
distribute the object code for the work under the terms of Section 6.
|
||||||
|
Any executables containing that work also fall under Section 6,
|
||||||
|
whether or not they are linked directly with the Library itself.
|
||||||
|
|
||||||
|
6. As an exception to the Sections above, you may also combine or
|
||||||
|
link a "work that uses the Library" with the Library to produce a
|
||||||
|
work containing portions of the Library, and distribute that work
|
||||||
|
under terms of your choice, provided that the terms permit
|
||||||
|
modification of the work for the customer's own use and reverse
|
||||||
|
engineering for debugging such modifications.
|
||||||
|
|
||||||
|
You must give prominent notice with each copy of the work that the
|
||||||
|
Library is used in it and that the Library and its use are covered by
|
||||||
|
this License. You must supply a copy of this License. If the work
|
||||||
|
during execution displays copyright notices, you must include the
|
||||||
|
copyright notice for the Library among them, as well as a reference
|
||||||
|
directing the user to the copy of this License. Also, you must do one
|
||||||
|
of these things:
|
||||||
|
|
||||||
|
a) Accompany the work with the complete corresponding
|
||||||
|
machine-readable source code for the Library including whatever
|
||||||
|
changes were used in the work (which must be distributed under
|
||||||
|
Sections 1 and 2 above); and, if the work is an executable linked
|
||||||
|
with the Library, with the complete machine-readable "work that
|
||||||
|
uses the Library", as object code and/or source code, so that the
|
||||||
|
user can modify the Library and then relink to produce a modified
|
||||||
|
executable containing the modified Library. (It is understood
|
||||||
|
that the user who changes the contents of definitions files in the
|
||||||
|
Library will not necessarily be able to recompile the application
|
||||||
|
to use the modified definitions.)
|
||||||
|
|
||||||
|
b) Use a suitable shared library mechanism for linking with the
|
||||||
|
Library. A suitable mechanism is one that (1) uses at run time a
|
||||||
|
copy of the library already present on the user's computer system,
|
||||||
|
rather than copying library functions into the executable, and (2)
|
||||||
|
will operate properly with a modified version of the library, if
|
||||||
|
the user installs one, as long as the modified version is
|
||||||
|
interface-compatible with the version that the work was made with.
|
||||||
|
|
||||||
|
c) Accompany the work with a written offer, valid for at
|
||||||
|
least three years, to give the same user the materials
|
||||||
|
specified in Subsection 6a, above, for a charge no more
|
||||||
|
than the cost of performing this distribution.
|
||||||
|
|
||||||
|
d) If distribution of the work is made by offering access to copy
|
||||||
|
from a designated place, offer equivalent access to copy the above
|
||||||
|
specified materials from the same place.
|
||||||
|
|
||||||
|
e) Verify that the user has already received a copy of these
|
||||||
|
materials or that you have already sent this user a copy.
|
||||||
|
|
||||||
|
For an executable, the required form of the "work that uses the
|
||||||
|
Library" must include any data and utility programs needed for
|
||||||
|
reproducing the executable from it. However, as a special exception,
|
||||||
|
the materials to be distributed need not include anything that is
|
||||||
|
normally distributed (in either source or binary form) with the major
|
||||||
|
components (compiler, kernel, and so on) of the operating system on
|
||||||
|
which the executable runs, unless that component itself accompanies
|
||||||
|
the executable.
|
||||||
|
|
||||||
|
It may happen that this requirement contradicts the license
|
||||||
|
restrictions of other proprietary libraries that do not normally
|
||||||
|
accompany the operating system. Such a contradiction means you cannot
|
||||||
|
use both them and the Library together in an executable that you
|
||||||
|
distribute.
|
||||||
|
|
||||||
|
7. You may place library facilities that are a work based on the
|
||||||
|
Library side-by-side in a single library together with other library
|
||||||
|
facilities not covered by this License, and distribute such a combined
|
||||||
|
library, provided that the separate distribution of the work based on
|
||||||
|
the Library and of the other library facilities is otherwise
|
||||||
|
permitted, and provided that you do these two things:
|
||||||
|
|
||||||
|
a) Accompany the combined library with a copy of the same work
|
||||||
|
based on the Library, uncombined with any other library
|
||||||
|
facilities. This must be distributed under the terms of the
|
||||||
|
Sections above.
|
||||||
|
|
||||||
|
b) Give prominent notice with the combined library of the fact
|
||||||
|
that part of it is a work based on the Library, and explaining
|
||||||
|
where to find the accompanying uncombined form of the same work.
|
||||||
|
|
||||||
|
8. You may not copy, modify, sublicense, link with, or distribute
|
||||||
|
the Library except as expressly provided under this License. Any
|
||||||
|
attempt otherwise to copy, modify, sublicense, link with, or
|
||||||
|
distribute the Library is void, and will automatically terminate your
|
||||||
|
rights under this License. However, parties who have received copies,
|
||||||
|
or rights, from you under this License will not have their licenses
|
||||||
|
terminated so long as such parties remain in full compliance.
|
||||||
|
|
||||||
|
9. You are not required to accept this License, since you have not
|
||||||
|
signed it. However, nothing else grants you permission to modify or
|
||||||
|
distribute the Library or its derivative works. These actions are
|
||||||
|
prohibited by law if you do not accept this License. Therefore, by
|
||||||
|
modifying or distributing the Library (or any work based on the
|
||||||
|
Library), you indicate your acceptance of this License to do so, and
|
||||||
|
all its terms and conditions for copying, distributing or modifying
|
||||||
|
the Library or works based on it.
|
||||||
|
|
||||||
|
10. Each time you redistribute the Library (or any work based on the
|
||||||
|
Library), the recipient automatically receives a license from the
|
||||||
|
original licensor to copy, distribute, link with or modify the Library
|
||||||
|
subject to these terms and conditions. You may not impose any further
|
||||||
|
restrictions on the recipients' exercise of the rights granted herein.
|
||||||
|
You are not responsible for enforcing compliance by third parties with
|
||||||
|
this License.
|
||||||
|
|
||||||
|
11. If, as a consequence of a court judgment or allegation of patent
|
||||||
|
infringement or for any other reason (not limited to patent issues),
|
||||||
|
conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot
|
||||||
|
distribute so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you
|
||||||
|
may not distribute the Library at all. For example, if a patent
|
||||||
|
license would not permit royalty-free redistribution of the Library by
|
||||||
|
all those who receive copies directly or indirectly through you, then
|
||||||
|
the only way you could satisfy both it and this License would be to
|
||||||
|
refrain entirely from distribution of the Library.
|
||||||
|
|
||||||
|
If any portion of this section is held invalid or unenforceable under any
|
||||||
|
particular circumstance, the balance of the section is intended to apply,
|
||||||
|
and the section as a whole is intended to apply in other circumstances.
|
||||||
|
|
||||||
|
It is not the purpose of this section to induce you to infringe any
|
||||||
|
patents or other property right claims or to contest validity of any
|
||||||
|
such claims; this section has the sole purpose of protecting the
|
||||||
|
integrity of the free software distribution system which is
|
||||||
|
implemented by public license practices. Many people have made
|
||||||
|
generous contributions to the wide range of software distributed
|
||||||
|
through that system in reliance on consistent application of that
|
||||||
|
system; it is up to the author/donor to decide if he or she is willing
|
||||||
|
to distribute software through any other system and a licensee cannot
|
||||||
|
impose that choice.
|
||||||
|
|
||||||
|
This section is intended to make thoroughly clear what is believed to
|
||||||
|
be a consequence of the rest of this License.
|
||||||
|
|
||||||
|
12. If the distribution and/or use of the Library is restricted in
|
||||||
|
certain countries either by patents or by copyrighted interfaces, the
|
||||||
|
original copyright holder who places the Library under this License may add
|
||||||
|
an explicit geographical distribution limitation excluding those countries,
|
||||||
|
so that distribution is permitted only in or among countries not thus
|
||||||
|
excluded. In such case, this License incorporates the limitation as if
|
||||||
|
written in the body of this License.
|
||||||
|
|
||||||
|
13. The Free Software Foundation may publish revised and/or new
|
||||||
|
versions of the Lesser General Public License from time to time.
|
||||||
|
Such new versions will be similar in spirit to the present version,
|
||||||
|
but may differ in detail to address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the Library
|
||||||
|
specifies a version number of this License which applies to it and
|
||||||
|
"any later version", you have the option of following the terms and
|
||||||
|
conditions either of that version or of any later version published by
|
||||||
|
the Free Software Foundation. If the Library does not specify a
|
||||||
|
license version number, you may choose any version ever published by
|
||||||
|
the Free Software Foundation.
|
||||||
|
|
||||||
|
14. If you wish to incorporate parts of the Library into other free
|
||||||
|
programs whose distribution conditions are incompatible with these,
|
||||||
|
write to the author to ask for permission. For software which is
|
||||||
|
copyrighted by the Free Software Foundation, write to the Free
|
||||||
|
Software Foundation; we sometimes make exceptions for this. Our
|
||||||
|
decision will be guided by the two goals of preserving the free status
|
||||||
|
of all derivatives of our free software and of promoting the sharing
|
||||||
|
and reuse of software generally.
|
||||||
|
|
||||||
|
NO WARRANTY
|
||||||
|
|
||||||
|
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||||
|
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||||
|
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||||
|
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||||
|
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||||
|
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||||
|
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||||
|
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||||
|
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||||
|
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||||
|
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||||
|
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||||
|
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||||
|
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||||
|
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||||
|
DAMAGES.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Libraries
|
||||||
|
|
||||||
|
If you develop a new library, and you want it to be of the greatest
|
||||||
|
possible use to the public, we recommend making it free software that
|
||||||
|
everyone can redistribute and change. You can do so by permitting
|
||||||
|
redistribution under these terms (or, alternatively, under the terms of the
|
||||||
|
ordinary General Public License).
|
||||||
|
|
||||||
|
To apply these terms, attach the following notices to the library. It is
|
||||||
|
safest to attach them to the start of each source file to most effectively
|
||||||
|
convey the exclusion of warranty; and each file should have at least the
|
||||||
|
"copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the library's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or your
|
||||||
|
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||||
|
necessary. Here is a sample; alter the names:
|
||||||
|
|
||||||
|
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||||
|
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||||
|
|
||||||
|
<signature of Ty Coon>, 1 April 1990
|
||||||
|
Ty Coon, President of Vice
|
||||||
|
|
||||||
|
That's all there is to it!
|
||||||
@@ -357,7 +357,7 @@ Exhibit A - Source Code Form License Notice
|
|||||||
|
|
||||||
This Source Code Form is subject to the terms of the Mozilla Public
|
This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
If it is not possible or desirable to put the notice in a particular
|
If it is not possible or desirable to put the notice in a particular
|
||||||
file, then You may include the notice in a location (such as a LICENSE
|
file, then You may include the notice in a location (such as a LICENSE
|
||||||
|
|||||||
@@ -2,10 +2,17 @@ Eigen is primarily MPL2 licensed. See COPYING.MPL2 and these links:
|
|||||||
http://www.mozilla.org/MPL/2.0/
|
http://www.mozilla.org/MPL/2.0/
|
||||||
http://www.mozilla.org/MPL/2.0/FAQ.html
|
http://www.mozilla.org/MPL/2.0/FAQ.html
|
||||||
|
|
||||||
Some files contain third-party code under BSD, LGPL, Apache, or other
|
Some files contain third-party code under BSD or LGPL licenses, whence the other
|
||||||
MPL2-compatible licenses, hence the other COPYING.* files here.
|
COPYING.* files here.
|
||||||
|
|
||||||
Note that some optional external dependencies (e.g. FFTW, MPFR C++)
|
All the LGPL code is either LGPL 2.1-only, or LGPL 2.1-or-later.
|
||||||
are distributed under different licenses, including the GPL. Refer to
|
For this reason, the COPYING.LGPL file contains the LGPL 2.1 text.
|
||||||
the individual source files and their respective COPYING files for
|
|
||||||
details.
|
If you want to guarantee that the Eigen code that you are #including is licensed
|
||||||
|
under the MPL2 and possibly more permissive licenses (like BSD), #define this
|
||||||
|
preprocessor symbol:
|
||||||
|
EIGEN_MPL2_ONLY
|
||||||
|
For example, with most compilers, you could add this to your project CXXFLAGS:
|
||||||
|
-DEIGEN_MPL2_ONLY
|
||||||
|
This will cause a compilation error to be generated if you #include any code that is
|
||||||
|
LGPL licensed.
|
||||||
|
|||||||
@@ -1,52 +0,0 @@
|
|||||||
// This file is part of Eigen, a lightweight C++ template library
|
|
||||||
// for linear algebra.
|
|
||||||
//
|
|
||||||
// This Source Code Form is subject to the terms of the Mozilla
|
|
||||||
// Public License v. 2.0. If a copy of the MPL was not distributed
|
|
||||||
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
#ifndef EIGEN_ACCELERATESUPPORT_MODULE_H
|
|
||||||
#define EIGEN_ACCELERATESUPPORT_MODULE_H
|
|
||||||
|
|
||||||
#include "SparseCore"
|
|
||||||
|
|
||||||
#include "src/Core/util/DisableStupidWarnings.h"
|
|
||||||
|
|
||||||
/** \ingroup Support_modules
|
|
||||||
* \defgroup AccelerateSupport_Module AccelerateSupport module
|
|
||||||
*
|
|
||||||
* This module provides an interface to the Apple Accelerate library.
|
|
||||||
* It provides the seven following main factorization classes:
|
|
||||||
* - class AccelerateLLT: a Cholesky (LL^T) factorization.
|
|
||||||
* - class AccelerateLDLT: the default LDL^T factorization.
|
|
||||||
* - class AccelerateLDLTUnpivoted: a Cholesky-like LDL^T factorization with only 1x1 pivots and no pivoting
|
|
||||||
* - class AccelerateLDLTSBK: an LDL^T factorization with Supernode Bunch-Kaufman and static pivoting
|
|
||||||
* - class AccelerateLDLTTPP: an LDL^T factorization with full threshold partial pivoting
|
|
||||||
* - class AccelerateQR: a QR factorization
|
|
||||||
* - class AccelerateCholeskyAtA: a QR factorization without storing Q (equivalent to A^TA = R^T R)
|
|
||||||
*
|
|
||||||
* \code
|
|
||||||
* #include <Eigen/AccelerateSupport>
|
|
||||||
* \endcode
|
|
||||||
*
|
|
||||||
* In order to use this module, the Accelerate headers must be accessible from
|
|
||||||
* the include paths, and your binary must be linked to the Accelerate framework.
|
|
||||||
* The Accelerate library is only available on Apple hardware.
|
|
||||||
*
|
|
||||||
* Note that many of the algorithms can be influenced by the UpLo template
|
|
||||||
* argument. All matrices are assumed to be symmetric. For example, the following
|
|
||||||
* creates an LDLT factorization where your matrix is symmetric (implicit) and
|
|
||||||
* uses the lower triangle:
|
|
||||||
*
|
|
||||||
* \code
|
|
||||||
* AccelerateLDLT<SparseMatrix<float>, Lower> ldlt;
|
|
||||||
* \endcode
|
|
||||||
*/
|
|
||||||
|
|
||||||
// IWYU pragma: begin_exports
|
|
||||||
#include "src/AccelerateSupport/AccelerateSupport.h"
|
|
||||||
// IWYU pragma: end_exports
|
|
||||||
|
|
||||||
#include "src/Core/util/ReenableStupidWarnings.h"
|
|
||||||
|
|
||||||
#endif // EIGEN_ACCELERATESUPPORT_MODULE_H
|
|
||||||
@@ -14,28 +14,32 @@
|
|||||||
#include "src/Core/util/DisableStupidWarnings.h"
|
#include "src/Core/util/DisableStupidWarnings.h"
|
||||||
|
|
||||||
/** \defgroup Cholesky_Module Cholesky module
|
/** \defgroup Cholesky_Module Cholesky module
|
||||||
*
|
*
|
||||||
* This module provides two variants of the Cholesky decomposition for selfadjoint (hermitian) matrices.
|
*
|
||||||
* Those decompositions are also accessible via the following methods:
|
*
|
||||||
* - MatrixBase::llt()
|
* This module provides two variants of the Cholesky decomposition for selfadjoint (hermitian) matrices.
|
||||||
* - MatrixBase::ldlt()
|
* Those decompositions are also accessible via the following methods:
|
||||||
* - SelfAdjointView::llt()
|
* - MatrixBase::llt()
|
||||||
* - SelfAdjointView::ldlt()
|
* - MatrixBase::ldlt()
|
||||||
*
|
* - SelfAdjointView::llt()
|
||||||
* \code
|
* - SelfAdjointView::ldlt()
|
||||||
* #include <Eigen/Cholesky>
|
*
|
||||||
* \endcode
|
* \code
|
||||||
*/
|
* #include <Eigen/Cholesky>
|
||||||
|
* \endcode
|
||||||
|
*/
|
||||||
|
|
||||||
// IWYU pragma: begin_exports
|
|
||||||
#include "src/Cholesky/LLT.h"
|
#include "src/Cholesky/LLT.h"
|
||||||
#include "src/Cholesky/LDLT.h"
|
#include "src/Cholesky/LDLT.h"
|
||||||
#ifdef EIGEN_USE_LAPACKE
|
#ifdef EIGEN_USE_LAPACKE
|
||||||
#include "src/misc/lapacke_helpers.h"
|
#ifdef EIGEN_USE_MKL
|
||||||
|
#include "mkl_lapacke.h"
|
||||||
|
#else
|
||||||
|
#include "src/misc/lapacke.h"
|
||||||
|
#endif
|
||||||
#include "src/Cholesky/LLT_LAPACKE.h"
|
#include "src/Cholesky/LLT_LAPACKE.h"
|
||||||
#endif
|
#endif
|
||||||
// IWYU pragma: end_exports
|
|
||||||
|
|
||||||
#include "src/Core/util/ReenableStupidWarnings.h"
|
#include "src/Core/util/ReenableStupidWarnings.h"
|
||||||
|
|
||||||
#endif // EIGEN_CHOLESKY_MODULE_H
|
#endif // EIGEN_CHOLESKY_MODULE_H
|
||||||
|
|||||||
@@ -12,37 +12,37 @@
|
|||||||
|
|
||||||
#include "src/Core/util/DisableStupidWarnings.h"
|
#include "src/Core/util/DisableStupidWarnings.h"
|
||||||
|
|
||||||
#include <cholmod.h>
|
extern "C" {
|
||||||
|
#include <cholmod.h>
|
||||||
|
}
|
||||||
|
|
||||||
/** \ingroup Support_modules
|
/** \ingroup Support_modules
|
||||||
* \defgroup CholmodSupport_Module CholmodSupport module
|
* \defgroup CholmodSupport_Module CholmodSupport module
|
||||||
*
|
*
|
||||||
* This module provides an interface to the Cholmod library which is part of the <a
|
* This module provides an interface to the Cholmod library which is part of the <a href="http://www.suitesparse.com">suitesparse</a> package.
|
||||||
* href="http://www.suitesparse.com">suitesparse</a> package. It provides the two following main factorization classes:
|
* It provides the two following main factorization classes:
|
||||||
* - class CholmodSupernodalLLT: a supernodal LLT Cholesky factorization.
|
* - class CholmodSupernodalLLT: a supernodal LLT Cholesky factorization.
|
||||||
* - class CholmodDecomposition: a general L(D)LT Cholesky factorization with automatic or explicit runtime selection of
|
* - class CholmodDecomposition: a general L(D)LT Cholesky factorization with automatic or explicit runtime selection of the underlying factorization method (supernodal or simplicial).
|
||||||
* the underlying factorization method (supernodal or simplicial).
|
*
|
||||||
*
|
* For the sake of completeness, this module also propose the two following classes:
|
||||||
* For the sake of completeness, this module also propose the two following classes:
|
* - class CholmodSimplicialLLT
|
||||||
* - class CholmodSimplicialLLT
|
* - class CholmodSimplicialLDLT
|
||||||
* - class CholmodSimplicialLDLT
|
* Note that these classes does not bring any particular advantage compared to the built-in
|
||||||
* Note that these classes do not bring any particular advantage compared to the built-in
|
* SimplicialLLT and SimplicialLDLT factorization classes.
|
||||||
* SimplicialLLT and SimplicialLDLT factorization classes.
|
*
|
||||||
*
|
* \code
|
||||||
* \code
|
* #include <Eigen/CholmodSupport>
|
||||||
* #include <Eigen/CholmodSupport>
|
* \endcode
|
||||||
* \endcode
|
*
|
||||||
*
|
* In order to use this module, the cholmod headers must be accessible from the include paths, and your binary must be linked to the cholmod library and its dependencies.
|
||||||
* In order to use this module, the cholmod headers must be accessible from the include paths, and your binary must be
|
* The dependencies depend on how cholmod has been compiled.
|
||||||
* linked to the cholmod library and its dependencies. The dependencies depend on how cholmod has been compiled. For a
|
* For a cmake based project, you can use our FindCholmod.cmake module to help you in this task.
|
||||||
* cmake based project, you can use our FindCholmod.cmake module to help you in this task.
|
*
|
||||||
*
|
*/
|
||||||
*/
|
|
||||||
|
|
||||||
// IWYU pragma: begin_exports
|
|
||||||
#include "src/CholmodSupport/CholmodSupport.h"
|
#include "src/CholmodSupport/CholmodSupport.h"
|
||||||
// IWYU pragma: end_exports
|
|
||||||
|
|
||||||
#include "src/Core/util/ReenableStupidWarnings.h"
|
#include "src/Core/util/ReenableStupidWarnings.h"
|
||||||
|
|
||||||
#endif // EIGEN_CHOLMODSUPPORT_MODULE_H
|
#endif // EIGEN_CHOLMODSUPPORT_MODULE_H
|
||||||
|
|
||||||
|
|||||||
350
Eigen/Core
350
Eigen/Core
@@ -8,11 +8,8 @@
|
|||||||
// Public License v. 2.0. If a copy of the MPL was not distributed
|
// Public License v. 2.0. If a copy of the MPL was not distributed
|
||||||
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
#ifndef EIGEN_CORE_MODULE_H
|
#ifndef EIGEN_CORE_H
|
||||||
#define EIGEN_CORE_MODULE_H
|
#define EIGEN_CORE_H
|
||||||
|
|
||||||
// Eigen version information.
|
|
||||||
#include "Version"
|
|
||||||
|
|
||||||
// first thing Eigen does: stop the compiler from reporting useless warnings.
|
// first thing Eigen does: stop the compiler from reporting useless warnings.
|
||||||
#include "src/Core/util/DisableStupidWarnings.h"
|
#include "src/Core/util/DisableStupidWarnings.h"
|
||||||
@@ -27,19 +24,27 @@
|
|||||||
// We need cuda_runtime.h/hip_runtime.h to ensure that
|
// We need cuda_runtime.h/hip_runtime.h to ensure that
|
||||||
// the EIGEN_USING_STD macro works properly on the device side
|
// the EIGEN_USING_STD macro works properly on the device side
|
||||||
#if defined(EIGEN_CUDACC)
|
#if defined(EIGEN_CUDACC)
|
||||||
#include <cuda_runtime.h>
|
#include <cuda_runtime.h>
|
||||||
#elif defined(EIGEN_HIPCC)
|
#elif defined(EIGEN_HIPCC)
|
||||||
#include <hip/hip_runtime.h>
|
#include <hip/hip_runtime.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef EIGEN_EXCEPTIONS
|
#ifdef EIGEN_EXCEPTIONS
|
||||||
#include <new>
|
#include <new>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Disable the ipa-cp-clone optimization flag with MinGW 6.x or newer (enabled by default with -O3)
|
||||||
|
// See http://eigen.tuxfamily.org/bz/show_bug.cgi?id=556 for details.
|
||||||
|
#if EIGEN_COMP_MINGW && EIGEN_GNUC_AT_LEAST(4,6) && EIGEN_GNUC_AT_MOST(5,5)
|
||||||
|
#pragma GCC optimize ("-fno-ipa-cp-clone")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Prevent ICC from specializing std::complex operators that silently fail
|
// Prevent ICC from specializing std::complex operators that silently fail
|
||||||
// on device. This allows us to use our own device-compatible specializations
|
// on device. This allows us to use our own device-compatible specializations
|
||||||
// instead.
|
// instead.
|
||||||
#if EIGEN_COMP_ICC && defined(EIGEN_GPU_COMPILE_PHASE) && !defined(_OVERRIDE_COMPLEX_SPECIALIZATION_)
|
#if defined(EIGEN_COMP_ICC) && defined(EIGEN_GPU_COMPILE_PHASE) \
|
||||||
|
&& !defined(_OVERRIDE_COMPLEX_SPECIALIZATION_)
|
||||||
#define _OVERRIDE_COMPLEX_SPECIALIZATION_ 1
|
#define _OVERRIDE_COMPLEX_SPECIALIZATION_ 1
|
||||||
#endif
|
#endif
|
||||||
#include <complex>
|
#include <complex>
|
||||||
@@ -47,27 +52,26 @@
|
|||||||
// this include file manages BLAS and MKL related macros
|
// this include file manages BLAS and MKL related macros
|
||||||
// and inclusion of their respective header files
|
// and inclusion of their respective header files
|
||||||
#include "src/Core/util/MKL_support.h"
|
#include "src/Core/util/MKL_support.h"
|
||||||
#include "src/Core/util/AOCL_Support.h"
|
|
||||||
|
|
||||||
|
|
||||||
// EIGEN_HAS_GPU_FP16 is now always true when compiling with CUDA or HIP.
|
#if defined(EIGEN_HAS_CUDA_FP16) || defined(EIGEN_HAS_HIP_FP16)
|
||||||
// Use EIGEN_GPUCC (compile-time) or EIGEN_GPU_COMPILE_PHASE (device phase) instead.
|
#define EIGEN_HAS_GPU_FP16
|
||||||
// TODO: Remove EIGEN_HAS_GPU_BF16 similarly once HIP bf16 guards are cleaned up.
|
#endif
|
||||||
|
|
||||||
#if defined(EIGEN_HAS_CUDA_BF16) || defined(EIGEN_HAS_HIP_BF16)
|
#if defined(EIGEN_HAS_CUDA_BF16) || defined(EIGEN_HAS_HIP_BF16)
|
||||||
#define EIGEN_HAS_GPU_BF16
|
#define EIGEN_HAS_GPU_BF16
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (defined _OPENMP) && (!defined EIGEN_DONT_PARALLELIZE)
|
#if (defined _OPENMP) && (!defined EIGEN_DONT_PARALLELIZE)
|
||||||
#define EIGEN_HAS_OPENMP
|
#define EIGEN_HAS_OPENMP
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef EIGEN_HAS_OPENMP
|
#ifdef EIGEN_HAS_OPENMP
|
||||||
#include <atomic>
|
|
||||||
#include <omp.h>
|
#include <omp.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !EIGEN_COMP_ARM
|
// MSVC for windows mobile does not have the errno.h file
|
||||||
|
#if !(EIGEN_COMP_MSVC && EIGEN_OS_WINCE) && !EIGEN_COMP_ARM
|
||||||
#define EIGEN_HAS_ERRNO
|
#define EIGEN_HAS_ERRNO
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -77,38 +81,26 @@
|
|||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <cassert>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#ifndef EIGEN_NO_IO
|
#ifndef EIGEN_NO_IO
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
#endif
|
#endif
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <climits> // for CHAR_BIT
|
#include <climits> // for CHAR_BIT
|
||||||
// for min/max:
|
// for min/max:
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
#if EIGEN_HAS_CXX11
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <memory>
|
#endif
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
// for std::is_nothrow_move_assignable
|
// for std::is_nothrow_move_assignable
|
||||||
|
#ifdef EIGEN_INCLUDE_TYPE_TRAITS
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
// for std::this_thread::yield().
|
|
||||||
#if !defined(EIGEN_USE_BLAS) && (defined(EIGEN_HAS_OPENMP) || defined(EIGEN_GEMM_THREADPOOL))
|
|
||||||
#include <thread>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// for __cpp_lib feature test macros
|
|
||||||
#if defined(__has_include) && __has_include(<version>)
|
|
||||||
#include <version>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// for std::bit_cast()
|
|
||||||
#if defined(__cpp_lib_bit_cast) && __cpp_lib_bit_cast >= 201806L
|
|
||||||
#include <bit>
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// for outputting debug info
|
// for outputting debug info
|
||||||
@@ -118,201 +110,142 @@
|
|||||||
|
|
||||||
// required for __cpuid, needs to be included after cmath
|
// required for __cpuid, needs to be included after cmath
|
||||||
// also required for _BitScanReverse on Windows on ARM
|
// also required for _BitScanReverse on Windows on ARM
|
||||||
#if EIGEN_COMP_MSVC && (EIGEN_ARCH_i386_OR_x86_64 || EIGEN_ARCH_ARM64)
|
#if EIGEN_COMP_MSVC && (EIGEN_ARCH_i386_OR_x86_64 || EIGEN_ARCH_ARM64) && !EIGEN_OS_WINCE
|
||||||
#include <intrin.h>
|
#include <intrin.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
// Required for querying cache sizes on Linux and macOS.
|
|
||||||
#if EIGEN_OS_LINUX
|
|
||||||
#include <unistd.h>
|
|
||||||
#elif EIGEN_OS_MAC
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/sysctl.h>
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(EIGEN_USE_SYCL)
|
#if defined(EIGEN_USE_SYCL)
|
||||||
#undef min
|
#undef min
|
||||||
#undef max
|
#undef max
|
||||||
#undef isnan
|
#undef isnan
|
||||||
#undef isinf
|
#undef isinf
|
||||||
#undef isfinite
|
#undef isfinite
|
||||||
#include <CL/sycl.hpp>
|
#include <CL/sycl.hpp>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <thread>
|
#include <memory>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#ifndef EIGEN_SYCL_LOCAL_THREAD_DIM0
|
#include <thread>
|
||||||
#define EIGEN_SYCL_LOCAL_THREAD_DIM0 16
|
#ifndef EIGEN_SYCL_LOCAL_THREAD_DIM0
|
||||||
#endif
|
#define EIGEN_SYCL_LOCAL_THREAD_DIM0 16
|
||||||
#ifndef EIGEN_SYCL_LOCAL_THREAD_DIM1
|
#endif
|
||||||
#define EIGEN_SYCL_LOCAL_THREAD_DIM1 16
|
#ifndef EIGEN_SYCL_LOCAL_THREAD_DIM1
|
||||||
|
#define EIGEN_SYCL_LOCAL_THREAD_DIM1 16
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if defined EIGEN2_SUPPORT_STAGE40_FULL_EIGEN3_STRICTNESS || defined EIGEN2_SUPPORT_STAGE30_FULL_EIGEN3_API || defined EIGEN2_SUPPORT_STAGE20_RESOLVE_API_CONFLICTS || defined EIGEN2_SUPPORT_STAGE10_FULL_EIGEN2_API || defined EIGEN2_SUPPORT
|
||||||
|
// This will generate an error message:
|
||||||
|
#error Eigen2-support is only available up to version 3.2. Please go to "http://eigen.tuxfamily.org/index.php?title=Eigen2" for further information
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace Eigen {
|
namespace Eigen {
|
||||||
|
|
||||||
|
// we use size_t frequently and we'll never remember to prepend it with std:: every time just to
|
||||||
|
// ensure QNX/QCC support
|
||||||
using std::size_t;
|
using std::size_t;
|
||||||
|
// gcc 4.6.0 wants std:: for ptrdiff_t
|
||||||
using std::ptrdiff_t;
|
using std::ptrdiff_t;
|
||||||
|
|
||||||
} // namespace Eigen
|
}
|
||||||
|
|
||||||
/** \defgroup Core_Module Core module
|
/** \defgroup Core_Module Core module
|
||||||
* This is the main module of Eigen providing dense matrix and vector support
|
* This is the main module of Eigen providing dense matrix and vector support
|
||||||
* (both fixed and dynamic size) with all the features corresponding to a BLAS library
|
* (both fixed and dynamic size) with all the features corresponding to a BLAS library
|
||||||
* and much more...
|
* and much more...
|
||||||
*
|
*
|
||||||
* \code
|
* \code
|
||||||
* #include <Eigen/Core>
|
* #include <Eigen/Core>
|
||||||
* \endcode
|
* \endcode
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef EIGEN_USE_LAPACKE
|
|
||||||
#ifdef EIGEN_USE_MKL
|
|
||||||
#include "mkl_lapacke.h"
|
|
||||||
#elif defined(EIGEN_LAPACKE_SYSTEM)
|
|
||||||
#include <lapacke.h>
|
|
||||||
#else
|
|
||||||
#include "src/misc/lapacke.h"
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// IWYU pragma: begin_exports
|
|
||||||
#include "src/Core/util/Constants.h"
|
#include "src/Core/util/Constants.h"
|
||||||
#include "src/Core/util/Meta.h"
|
#include "src/Core/util/Meta.h"
|
||||||
#include "src/Core/util/Assert.h"
|
|
||||||
#include "src/Core/util/ForwardDeclarations.h"
|
#include "src/Core/util/ForwardDeclarations.h"
|
||||||
#include "src/Core/util/StaticAssert.h"
|
#include "src/Core/util/StaticAssert.h"
|
||||||
#include "src/Core/util/XprHelper.h"
|
#include "src/Core/util/XprHelper.h"
|
||||||
#include "src/Core/util/Memory.h"
|
#include "src/Core/util/Memory.h"
|
||||||
#include "src/Core/util/IntegralConstant.h"
|
#include "src/Core/util/IntegralConstant.h"
|
||||||
#include "src/Core/util/Serializer.h"
|
|
||||||
#include "src/Core/util/SymbolicIndex.h"
|
#include "src/Core/util/SymbolicIndex.h"
|
||||||
#include "src/Core/util/EmulateArray.h"
|
|
||||||
#include "src/Core/util/MoreMeta.h"
|
|
||||||
|
|
||||||
#include "src/Core/NumTraits.h"
|
#include "src/Core/NumTraits.h"
|
||||||
#include "src/Core/MathFunctions.h"
|
#include "src/Core/MathFunctions.h"
|
||||||
#include "src/Core/RandomImpl.h"
|
|
||||||
#include "src/Core/GenericPacketMath.h"
|
#include "src/Core/GenericPacketMath.h"
|
||||||
#include "src/Core/MathFunctionsImpl.h"
|
#include "src/Core/MathFunctionsImpl.h"
|
||||||
#include "src/Core/arch/Default/ConjHelper.h"
|
#include "src/Core/arch/Default/ConjHelper.h"
|
||||||
// Generic half float support
|
// Generic half float support
|
||||||
#include "src/Core/arch/Default/Half.h"
|
#include "src/Core/arch/Default/Half.h"
|
||||||
#include "src/Core/arch/Default/BFloat16.h"
|
#include "src/Core/arch/Default/BFloat16.h"
|
||||||
|
#include "src/Core/arch/Default/TypeCasting.h"
|
||||||
#include "src/Core/arch/Default/GenericPacketMathFunctionsFwd.h"
|
#include "src/Core/arch/Default/GenericPacketMathFunctionsFwd.h"
|
||||||
|
|
||||||
#if defined(EIGEN_VECTORIZE_GENERIC) && !defined(EIGEN_DONT_VECTORIZE)
|
|
||||||
#include "src/Core/arch/clang/PacketMath.h"
|
|
||||||
#include "src/Core/arch/clang/TypeCasting.h"
|
|
||||||
#include "src/Core/arch/clang/Complex.h"
|
|
||||||
#include "src/Core/arch/clang/Reductions.h"
|
|
||||||
#include "src/Core/arch/clang/MathFunctions.h"
|
|
||||||
#else
|
|
||||||
#if defined EIGEN_VECTORIZE_AVX512
|
#if defined EIGEN_VECTORIZE_AVX512
|
||||||
#include "src/Core/arch/SSE/PacketMath.h"
|
#include "src/Core/arch/SSE/PacketMath.h"
|
||||||
#include "src/Core/arch/SSE/Reductions.h"
|
#include "src/Core/arch/SSE/TypeCasting.h"
|
||||||
#include "src/Core/arch/AVX/PacketMath.h"
|
#include "src/Core/arch/SSE/Complex.h"
|
||||||
#include "src/Core/arch/AVX/Reductions.h"
|
#include "src/Core/arch/AVX/PacketMath.h"
|
||||||
#include "src/Core/arch/AVX512/PacketMath.h"
|
#include "src/Core/arch/AVX/TypeCasting.h"
|
||||||
#include "src/Core/arch/AVX512/Reductions.h"
|
#include "src/Core/arch/AVX/Complex.h"
|
||||||
#if defined EIGEN_VECTORIZE_AVX512FP16
|
#include "src/Core/arch/AVX512/PacketMath.h"
|
||||||
#include "src/Core/arch/AVX512/PacketMathFP16.h"
|
#include "src/Core/arch/AVX512/TypeCasting.h"
|
||||||
#endif
|
#include "src/Core/arch/AVX512/Complex.h"
|
||||||
#include "src/Core/arch/SSE/TypeCasting.h"
|
#include "src/Core/arch/SSE/MathFunctions.h"
|
||||||
#include "src/Core/arch/AVX/TypeCasting.h"
|
#include "src/Core/arch/AVX/MathFunctions.h"
|
||||||
#include "src/Core/arch/AVX512/TypeCasting.h"
|
#include "src/Core/arch/AVX512/MathFunctions.h"
|
||||||
#if defined EIGEN_VECTORIZE_AVX512FP16
|
|
||||||
#include "src/Core/arch/AVX512/TypeCastingFP16.h"
|
|
||||||
#endif
|
|
||||||
#include "src/Core/arch/SSE/Complex.h"
|
|
||||||
#include "src/Core/arch/AVX/Complex.h"
|
|
||||||
#include "src/Core/arch/AVX512/Complex.h"
|
|
||||||
#include "src/Core/arch/SSE/MathFunctions.h"
|
|
||||||
#include "src/Core/arch/AVX/MathFunctions.h"
|
|
||||||
#include "src/Core/arch/AVX512/MathFunctions.h"
|
|
||||||
#if defined EIGEN_VECTORIZE_AVX512FP16
|
|
||||||
#include "src/Core/arch/AVX512/MathFunctionsFP16.h"
|
|
||||||
#endif
|
|
||||||
#include "src/Core/arch/AVX512/TrsmKernel.h"
|
|
||||||
#elif defined EIGEN_VECTORIZE_AVX
|
#elif defined EIGEN_VECTORIZE_AVX
|
||||||
// Use AVX for floats and doubles, SSE for integers
|
// Use AVX for floats and doubles, SSE for integers
|
||||||
#include "src/Core/arch/SSE/PacketMath.h"
|
#include "src/Core/arch/SSE/PacketMath.h"
|
||||||
#include "src/Core/arch/SSE/Reductions.h"
|
#include "src/Core/arch/SSE/TypeCasting.h"
|
||||||
#include "src/Core/arch/SSE/TypeCasting.h"
|
#include "src/Core/arch/SSE/Complex.h"
|
||||||
#include "src/Core/arch/SSE/Complex.h"
|
#include "src/Core/arch/AVX/PacketMath.h"
|
||||||
#include "src/Core/arch/AVX/PacketMath.h"
|
#include "src/Core/arch/AVX/TypeCasting.h"
|
||||||
#include "src/Core/arch/AVX/Reductions.h"
|
#include "src/Core/arch/AVX/Complex.h"
|
||||||
#include "src/Core/arch/AVX/TypeCasting.h"
|
#include "src/Core/arch/SSE/MathFunctions.h"
|
||||||
#include "src/Core/arch/AVX/Complex.h"
|
#include "src/Core/arch/AVX/MathFunctions.h"
|
||||||
#include "src/Core/arch/SSE/MathFunctions.h"
|
|
||||||
#include "src/Core/arch/AVX/MathFunctions.h"
|
|
||||||
#elif defined EIGEN_VECTORIZE_SSE
|
#elif defined EIGEN_VECTORIZE_SSE
|
||||||
#include "src/Core/arch/SSE/PacketMath.h"
|
#include "src/Core/arch/SSE/PacketMath.h"
|
||||||
#include "src/Core/arch/SSE/Reductions.h"
|
#include "src/Core/arch/SSE/TypeCasting.h"
|
||||||
#include "src/Core/arch/SSE/TypeCasting.h"
|
#include "src/Core/arch/SSE/MathFunctions.h"
|
||||||
#include "src/Core/arch/SSE/MathFunctions.h"
|
#include "src/Core/arch/SSE/Complex.h"
|
||||||
#include "src/Core/arch/SSE/Complex.h"
|
#elif defined(EIGEN_VECTORIZE_ALTIVEC) || defined(EIGEN_VECTORIZE_VSX)
|
||||||
#endif
|
#include "src/Core/arch/AltiVec/PacketMath.h"
|
||||||
|
#include "src/Core/arch/AltiVec/MathFunctions.h"
|
||||||
#if defined(EIGEN_VECTORIZE_ALTIVEC) || defined(EIGEN_VECTORIZE_VSX)
|
#include "src/Core/arch/AltiVec/Complex.h"
|
||||||
#include "src/Core/arch/AltiVec/PacketMath.h"
|
|
||||||
#include "src/Core/arch/AltiVec/TypeCasting.h"
|
|
||||||
#include "src/Core/arch/AltiVec/MathFunctions.h"
|
|
||||||
#include "src/Core/arch/AltiVec/Complex.h"
|
|
||||||
#elif defined EIGEN_VECTORIZE_NEON
|
#elif defined EIGEN_VECTORIZE_NEON
|
||||||
#include "src/Core/arch/NEON/PacketMath.h"
|
#include "src/Core/arch/NEON/PacketMath.h"
|
||||||
#include "src/Core/arch/NEON/TypeCasting.h"
|
#include "src/Core/arch/NEON/TypeCasting.h"
|
||||||
#include "src/Core/arch/NEON/MathFunctions.h"
|
#include "src/Core/arch/NEON/MathFunctions.h"
|
||||||
#include "src/Core/arch/NEON/Complex.h"
|
#include "src/Core/arch/NEON/Complex.h"
|
||||||
#elif defined EIGEN_VECTORIZE_LSX
|
|
||||||
#include "src/Core/arch/LSX/PacketMath.h"
|
|
||||||
#include "src/Core/arch/LSX/TypeCasting.h"
|
|
||||||
#include "src/Core/arch/LSX/MathFunctions.h"
|
|
||||||
#include "src/Core/arch/LSX/Complex.h"
|
|
||||||
#elif defined EIGEN_VECTORIZE_SVE
|
#elif defined EIGEN_VECTORIZE_SVE
|
||||||
#include "src/Core/arch/SVE/PacketMath.h"
|
#include "src/Core/arch/SVE/PacketMath.h"
|
||||||
#include "src/Core/arch/SVE/TypeCasting.h"
|
#include "src/Core/arch/SVE/TypeCasting.h"
|
||||||
#include "src/Core/arch/SVE/MathFunctions.h"
|
#include "src/Core/arch/SVE/MathFunctions.h"
|
||||||
#elif defined EIGEN_VECTORIZE_RVV10
|
|
||||||
#include "src/Core/arch/RVV10/PacketMath.h"
|
|
||||||
#include "src/Core/arch/RVV10/PacketMath4.h"
|
|
||||||
#include "src/Core/arch/RVV10/PacketMath2.h"
|
|
||||||
#include "src/Core/arch/RVV10/TypeCasting.h"
|
|
||||||
#include "src/Core/arch/RVV10/MathFunctions.h"
|
|
||||||
#if defined EIGEN_VECTORIZE_RVV10FP16
|
|
||||||
#include "src/Core/arch/RVV10/PacketMathFP16.h"
|
|
||||||
#endif
|
|
||||||
#if defined EIGEN_VECTORIZE_RVV10BF16
|
|
||||||
#include "src/Core/arch/RVV10/PacketMathBF16.h"
|
|
||||||
#endif
|
|
||||||
#elif defined EIGEN_VECTORIZE_ZVECTOR
|
#elif defined EIGEN_VECTORIZE_ZVECTOR
|
||||||
#include "src/Core/arch/ZVector/PacketMath.h"
|
#include "src/Core/arch/ZVector/PacketMath.h"
|
||||||
#include "src/Core/arch/ZVector/MathFunctions.h"
|
#include "src/Core/arch/ZVector/MathFunctions.h"
|
||||||
#include "src/Core/arch/ZVector/Complex.h"
|
#include "src/Core/arch/ZVector/Complex.h"
|
||||||
#elif defined EIGEN_VECTORIZE_MSA
|
#elif defined EIGEN_VECTORIZE_MSA
|
||||||
#include "src/Core/arch/MSA/PacketMath.h"
|
#include "src/Core/arch/MSA/PacketMath.h"
|
||||||
#include "src/Core/arch/MSA/MathFunctions.h"
|
#include "src/Core/arch/MSA/MathFunctions.h"
|
||||||
#include "src/Core/arch/MSA/Complex.h"
|
#include "src/Core/arch/MSA/Complex.h"
|
||||||
#elif defined EIGEN_VECTORIZE_HVX
|
|
||||||
#include "src/Core/arch/HVX/PacketMath.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined EIGEN_VECTORIZE_GPU
|
#if defined EIGEN_VECTORIZE_GPU
|
||||||
#include "src/Core/arch/GPU/PacketMath.h"
|
#include "src/Core/arch/GPU/PacketMath.h"
|
||||||
#include "src/Core/arch/GPU/MathFunctions.h"
|
#include "src/Core/arch/GPU/MathFunctions.h"
|
||||||
#include "src/Core/arch/GPU/TypeCasting.h"
|
#include "src/Core/arch/GPU/TypeCasting.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(EIGEN_USE_SYCL)
|
#if defined(EIGEN_USE_SYCL)
|
||||||
#include "src/Core/arch/SYCL/InteropHeaders.h"
|
#include "src/Core/arch/SYCL/SyclMemoryModel.h"
|
||||||
|
#include "src/Core/arch/SYCL/InteropHeaders.h"
|
||||||
#if !defined(EIGEN_DONT_VECTORIZE_SYCL)
|
#if !defined(EIGEN_DONT_VECTORIZE_SYCL)
|
||||||
#include "src/Core/arch/SYCL/PacketMath.h"
|
#include "src/Core/arch/SYCL/PacketMath.h"
|
||||||
#include "src/Core/arch/SYCL/MathFunctions.h"
|
#include "src/Core/arch/SYCL/MathFunctions.h"
|
||||||
#include "src/Core/arch/SYCL/TypeCasting.h"
|
#include "src/Core/arch/SYCL/TypeCasting.h"
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // #ifndef EIGEN_VECTORIZE_GENERIC
|
|
||||||
|
|
||||||
#include "src/Core/arch/Default/Settings.h"
|
#include "src/Core/arch/Default/Settings.h"
|
||||||
// This file provides generic implementations valid for scalar as well
|
// This file provides generic implementations valid for scalar as well
|
||||||
#include "src/Core/arch/Default/GenericPacketMathFunctions.h"
|
#include "src/Core/arch/Default/GenericPacketMathFunctions.h"
|
||||||
@@ -324,21 +257,17 @@ using std::ptrdiff_t;
|
|||||||
#include "src/Core/functors/StlFunctors.h"
|
#include "src/Core/functors/StlFunctors.h"
|
||||||
#include "src/Core/functors/AssignmentFunctors.h"
|
#include "src/Core/functors/AssignmentFunctors.h"
|
||||||
|
|
||||||
// Specialized functors for GPU.
|
// Specialized functors to enable the processing of complex numbers
|
||||||
#ifdef EIGEN_GPUCC
|
// on CUDA devices
|
||||||
#include "src/Core/arch/GPU/Complex.h"
|
#ifdef EIGEN_CUDACC
|
||||||
#endif
|
#include "src/Core/arch/CUDA/Complex.h"
|
||||||
|
|
||||||
// Specializations of vectorized activation functions for NEON.
|
|
||||||
#ifdef EIGEN_VECTORIZE_NEON
|
|
||||||
#include "src/Core/arch/NEON/UnaryFunctors.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "src/Core/util/IndexedViewHelper.h"
|
#include "src/Core/util/IndexedViewHelper.h"
|
||||||
#include "src/Core/util/ReshapedHelper.h"
|
#include "src/Core/util/ReshapedHelper.h"
|
||||||
#include "src/Core/ArithmeticSequence.h"
|
#include "src/Core/ArithmeticSequence.h"
|
||||||
#ifndef EIGEN_NO_IO
|
#ifndef EIGEN_NO_IO
|
||||||
#include "src/Core/IO.h"
|
#include "src/Core/IO.h"
|
||||||
#endif
|
#endif
|
||||||
#include "src/Core/DenseCoeffsBase.h"
|
#include "src/Core/DenseCoeffsBase.h"
|
||||||
#include "src/Core/DenseBase.h"
|
#include "src/Core/DenseBase.h"
|
||||||
@@ -348,27 +277,30 @@ using std::ptrdiff_t;
|
|||||||
#include "src/Core/Product.h"
|
#include "src/Core/Product.h"
|
||||||
#include "src/Core/CoreEvaluators.h"
|
#include "src/Core/CoreEvaluators.h"
|
||||||
#include "src/Core/AssignEvaluator.h"
|
#include "src/Core/AssignEvaluator.h"
|
||||||
#include "src/Core/RealView.h"
|
|
||||||
#include "src/Core/Assign.h"
|
#ifndef EIGEN_PARSED_BY_DOXYGEN // work around Doxygen bug triggered by Assign.h r814874
|
||||||
|
// at least confirmed with Doxygen 1.5.5 and 1.5.6
|
||||||
|
#include "src/Core/Assign.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "src/Core/ArrayBase.h"
|
#include "src/Core/ArrayBase.h"
|
||||||
#include "src/Core/util/BlasUtil.h"
|
#include "src/Core/util/BlasUtil.h"
|
||||||
#include "src/Core/DenseStorage.h"
|
#include "src/Core/DenseStorage.h"
|
||||||
#include "src/Core/NestByValue.h"
|
#include "src/Core/NestByValue.h"
|
||||||
|
|
||||||
|
// #include "src/Core/ForceAlignedAccess.h"
|
||||||
|
|
||||||
#include "src/Core/ReturnByValue.h"
|
#include "src/Core/ReturnByValue.h"
|
||||||
#include "src/Core/NoAlias.h"
|
#include "src/Core/NoAlias.h"
|
||||||
#include "src/Core/PlainObjectBase.h"
|
#include "src/Core/PlainObjectBase.h"
|
||||||
#include "src/Core/Matrix.h"
|
#include "src/Core/Matrix.h"
|
||||||
#include "src/Core/Array.h"
|
#include "src/Core/Array.h"
|
||||||
#include "src/Core/Fill.h"
|
|
||||||
#include "src/Core/CwiseTernaryOp.h"
|
#include "src/Core/CwiseTernaryOp.h"
|
||||||
#include "src/Core/CwiseBinaryOp.h"
|
#include "src/Core/CwiseBinaryOp.h"
|
||||||
#include "src/Core/CwiseUnaryOp.h"
|
#include "src/Core/CwiseUnaryOp.h"
|
||||||
#include "src/Core/CwiseNullaryOp.h"
|
#include "src/Core/CwiseNullaryOp.h"
|
||||||
#include "src/Core/CwiseUnaryView.h"
|
#include "src/Core/CwiseUnaryView.h"
|
||||||
#include "src/Core/SelfCwiseBinaryOp.h"
|
#include "src/Core/SelfCwiseBinaryOp.h"
|
||||||
#include "src/Core/InnerProduct.h"
|
|
||||||
#include "src/Core/Dot.h"
|
#include "src/Core/Dot.h"
|
||||||
#include "src/Core/StableNorm.h"
|
#include "src/Core/StableNorm.h"
|
||||||
#include "src/Core/Stride.h"
|
#include "src/Core/Stride.h"
|
||||||
@@ -383,10 +315,8 @@ using std::ptrdiff_t;
|
|||||||
#include "src/Core/DiagonalMatrix.h"
|
#include "src/Core/DiagonalMatrix.h"
|
||||||
#include "src/Core/Diagonal.h"
|
#include "src/Core/Diagonal.h"
|
||||||
#include "src/Core/DiagonalProduct.h"
|
#include "src/Core/DiagonalProduct.h"
|
||||||
#include "src/Core/SkewSymmetricMatrix3.h"
|
|
||||||
#include "src/Core/Redux.h"
|
#include "src/Core/Redux.h"
|
||||||
#include "src/Core/Visitor.h"
|
#include "src/Core/Visitor.h"
|
||||||
#include "src/Core/FindCoeff.h"
|
|
||||||
#include "src/Core/Fuzzy.h"
|
#include "src/Core/Fuzzy.h"
|
||||||
#include "src/Core/Swap.h"
|
#include "src/Core/Swap.h"
|
||||||
#include "src/Core/CommaInitializer.h"
|
#include "src/Core/CommaInitializer.h"
|
||||||
@@ -399,10 +329,6 @@ using std::ptrdiff_t;
|
|||||||
#include "src/Core/TriangularMatrix.h"
|
#include "src/Core/TriangularMatrix.h"
|
||||||
#include "src/Core/SelfAdjointView.h"
|
#include "src/Core/SelfAdjointView.h"
|
||||||
#include "src/Core/products/GeneralBlockPanelKernel.h"
|
#include "src/Core/products/GeneralBlockPanelKernel.h"
|
||||||
#include "src/Core/DeviceWrapper.h"
|
|
||||||
#ifdef EIGEN_GEMM_THREADPOOL
|
|
||||||
#include "ThreadPool"
|
|
||||||
#endif
|
|
||||||
#include "src/Core/products/Parallelizer.h"
|
#include "src/Core/products/Parallelizer.h"
|
||||||
#include "src/Core/ProductEvaluators.h"
|
#include "src/Core/ProductEvaluators.h"
|
||||||
#include "src/Core/products/GeneralMatrixVector.h"
|
#include "src/Core/products/GeneralMatrixVector.h"
|
||||||
@@ -421,22 +347,13 @@ using std::ptrdiff_t;
|
|||||||
#include "src/Core/CoreIterators.h"
|
#include "src/Core/CoreIterators.h"
|
||||||
#include "src/Core/ConditionEstimator.h"
|
#include "src/Core/ConditionEstimator.h"
|
||||||
|
|
||||||
#if !defined(EIGEN_VECTORIZE_GENERIC)
|
|
||||||
#if defined(EIGEN_VECTORIZE_VSX)
|
#if defined(EIGEN_VECTORIZE_VSX)
|
||||||
#include "src/Core/arch/AltiVec/MatrixProduct.h"
|
#include "src/Core/arch/AltiVec/MatrixProduct.h"
|
||||||
#elif defined EIGEN_VECTORIZE_NEON
|
#elif defined EIGEN_VECTORIZE_NEON
|
||||||
#include "src/Core/arch/NEON/GeneralBlockPanelKernel.h"
|
#include "src/Core/arch/NEON/GeneralBlockPanelKernel.h"
|
||||||
#elif defined EIGEN_VECTORIZE_LSX
|
|
||||||
#include "src/Core/arch/LSX/GeneralBlockPanelKernel.h"
|
|
||||||
#elif defined EIGEN_VECTORIZE_RVV10
|
|
||||||
#include "src/Core/arch/RVV10/GeneralBlockPanelKernel.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(EIGEN_VECTORIZE_AVX512)
|
|
||||||
#include "src/Core/arch/AVX512/GemmKernel.h"
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "src/Core/BooleanRedux.h"
|
||||||
#include "src/Core/Select.h"
|
#include "src/Core/Select.h"
|
||||||
#include "src/Core/VectorwiseOp.h"
|
#include "src/Core/VectorwiseOp.h"
|
||||||
#include "src/Core/PartialReduxEvaluator.h"
|
#include "src/Core/PartialReduxEvaluator.h"
|
||||||
@@ -455,19 +372,14 @@ using std::ptrdiff_t;
|
|||||||
#include "src/Core/products/TriangularMatrixMatrix_BLAS.h"
|
#include "src/Core/products/TriangularMatrixMatrix_BLAS.h"
|
||||||
#include "src/Core/products/TriangularMatrixVector_BLAS.h"
|
#include "src/Core/products/TriangularMatrixVector_BLAS.h"
|
||||||
#include "src/Core/products/TriangularSolverMatrix_BLAS.h"
|
#include "src/Core/products/TriangularSolverMatrix_BLAS.h"
|
||||||
#endif // EIGEN_USE_BLAS
|
#endif // EIGEN_USE_BLAS
|
||||||
|
|
||||||
#ifdef EIGEN_USE_MKL_VML
|
#ifdef EIGEN_USE_MKL_VML
|
||||||
#include "src/Core/Assign_MKL.h"
|
#include "src/Core/Assign_MKL.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef EIGEN_USE_AOCL_VML
|
|
||||||
#include "src/Core/Assign_AOCL.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "src/Core/GlobalFunctions.h"
|
#include "src/Core/GlobalFunctions.h"
|
||||||
// IWYU pragma: end_exports
|
|
||||||
|
|
||||||
#include "src/Core/util/ReenableStupidWarnings.h"
|
#include "src/Core/util/ReenableStupidWarnings.h"
|
||||||
|
|
||||||
#endif // EIGEN_CORE_MODULE_H
|
#endif // EIGEN_CORE_H
|
||||||
|
|||||||
12
Eigen/Dense
12
Eigen/Dense
@@ -1,13 +1,3 @@
|
|||||||
// This file is part of Eigen, a lightweight C++ template library
|
|
||||||
// for linear algebra.
|
|
||||||
//
|
|
||||||
// This Source Code Form is subject to the terms of the Mozilla
|
|
||||||
// Public License v. 2.0. If a copy of the MPL was not distributed
|
|
||||||
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
#ifndef EIGEN_DENSE_MODULE_H
|
|
||||||
#define EIGEN_DENSE_MODULE_H
|
|
||||||
|
|
||||||
#include "Core"
|
#include "Core"
|
||||||
#include "LU"
|
#include "LU"
|
||||||
#include "Cholesky"
|
#include "Cholesky"
|
||||||
@@ -15,5 +5,3 @@
|
|||||||
#include "SVD"
|
#include "SVD"
|
||||||
#include "Geometry"
|
#include "Geometry"
|
||||||
#include "Eigenvalues"
|
#include "Eigenvalues"
|
||||||
|
|
||||||
#endif // EIGEN_DENSE_MODULE_H
|
|
||||||
|
|||||||
12
Eigen/Eigen
12
Eigen/Eigen
@@ -1,14 +1,2 @@
|
|||||||
// This file is part of Eigen, a lightweight C++ template library
|
|
||||||
// for linear algebra.
|
|
||||||
//
|
|
||||||
// This Source Code Form is subject to the terms of the Mozilla
|
|
||||||
// Public License v. 2.0. If a copy of the MPL was not distributed
|
|
||||||
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
#ifndef EIGEN_EIGEN_MODULE_H
|
|
||||||
#define EIGEN_EIGEN_MODULE_H
|
|
||||||
|
|
||||||
#include "Dense"
|
#include "Dense"
|
||||||
#include "Sparse"
|
#include "Sparse"
|
||||||
|
|
||||||
#endif // EIGEN_EIGEN_MODULE_H
|
|
||||||
|
|||||||
@@ -11,25 +11,28 @@
|
|||||||
#include "Core"
|
#include "Core"
|
||||||
|
|
||||||
#include "Cholesky"
|
#include "Cholesky"
|
||||||
|
#include "Jacobi"
|
||||||
|
#include "Householder"
|
||||||
#include "LU"
|
#include "LU"
|
||||||
#include "Geometry"
|
#include "Geometry"
|
||||||
#include "Sparse" // Needed by ComplexQZ.
|
|
||||||
|
|
||||||
#include "src/Core/util/DisableStupidWarnings.h"
|
#include "src/Core/util/DisableStupidWarnings.h"
|
||||||
|
|
||||||
/** \defgroup Eigenvalues_Module Eigenvalues module
|
/** \defgroup Eigenvalues_Module Eigenvalues module
|
||||||
*
|
*
|
||||||
* This module mainly provides various eigenvalue solvers.
|
*
|
||||||
* This module also provides some MatrixBase methods, including:
|
*
|
||||||
* - MatrixBase::eigenvalues(),
|
* This module mainly provides various eigenvalue solvers.
|
||||||
* - MatrixBase::operatorNorm()
|
* This module also provides some MatrixBase methods, including:
|
||||||
*
|
* - MatrixBase::eigenvalues(),
|
||||||
* \code
|
* - MatrixBase::operatorNorm()
|
||||||
* #include <Eigen/Eigenvalues>
|
*
|
||||||
* \endcode
|
* \code
|
||||||
*/
|
* #include <Eigen/Eigenvalues>
|
||||||
|
* \endcode
|
||||||
|
*/
|
||||||
|
|
||||||
// IWYU pragma: begin_exports
|
#include "src/misc/RealSvd2x2.h"
|
||||||
#include "src/Eigenvalues/Tridiagonalization.h"
|
#include "src/Eigenvalues/Tridiagonalization.h"
|
||||||
#include "src/Eigenvalues/RealSchur.h"
|
#include "src/Eigenvalues/RealSchur.h"
|
||||||
#include "src/Eigenvalues/EigenSolver.h"
|
#include "src/Eigenvalues/EigenSolver.h"
|
||||||
@@ -39,14 +42,11 @@
|
|||||||
#include "src/Eigenvalues/ComplexSchur.h"
|
#include "src/Eigenvalues/ComplexSchur.h"
|
||||||
#include "src/Eigenvalues/ComplexEigenSolver.h"
|
#include "src/Eigenvalues/ComplexEigenSolver.h"
|
||||||
#include "src/Eigenvalues/RealQZ.h"
|
#include "src/Eigenvalues/RealQZ.h"
|
||||||
#include "src/Eigenvalues/ComplexQZ.h"
|
|
||||||
#include "src/Eigenvalues/GeneralizedEigenSolver.h"
|
#include "src/Eigenvalues/GeneralizedEigenSolver.h"
|
||||||
#include "src/Eigenvalues/MatrixBaseEigenvalues.h"
|
#include "src/Eigenvalues/MatrixBaseEigenvalues.h"
|
||||||
#ifdef EIGEN_USE_LAPACKE
|
#ifdef EIGEN_USE_LAPACKE
|
||||||
#ifdef EIGEN_USE_MKL
|
#ifdef EIGEN_USE_MKL
|
||||||
#include "mkl_lapacke.h"
|
#include "mkl_lapacke.h"
|
||||||
#elif defined(EIGEN_LAPACKE_SYSTEM)
|
|
||||||
#include <lapacke.h>
|
|
||||||
#else
|
#else
|
||||||
#include "src/misc/lapacke.h"
|
#include "src/misc/lapacke.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -54,8 +54,7 @@
|
|||||||
#include "src/Eigenvalues/ComplexSchur_LAPACKE.h"
|
#include "src/Eigenvalues/ComplexSchur_LAPACKE.h"
|
||||||
#include "src/Eigenvalues/SelfAdjointEigenSolver_LAPACKE.h"
|
#include "src/Eigenvalues/SelfAdjointEigenSolver_LAPACKE.h"
|
||||||
#endif
|
#endif
|
||||||
// IWYU pragma: end_exports
|
|
||||||
|
|
||||||
#include "src/Core/util/ReenableStupidWarnings.h"
|
#include "src/Core/util/ReenableStupidWarnings.h"
|
||||||
|
|
||||||
#endif // EIGEN_EIGENVALUES_MODULE_H
|
#endif // EIGEN_EIGENVALUES_MODULE_H
|
||||||
|
|||||||
58
Eigen/GPU
58
Eigen/GPU
@@ -1,58 +0,0 @@
|
|||||||
// This file is part of Eigen, a lightweight C++ template library
|
|
||||||
// for linear algebra.
|
|
||||||
//
|
|
||||||
// This Source Code Form is subject to the terms of the Mozilla
|
|
||||||
// Public License v. 2.0. If a copy of the MPL was not distributed
|
|
||||||
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
#ifndef EIGEN_GPU_MODULE_H
|
|
||||||
#define EIGEN_GPU_MODULE_H
|
|
||||||
|
|
||||||
#include "Core"
|
|
||||||
|
|
||||||
#include "src/Core/util/DisableStupidWarnings.h"
|
|
||||||
|
|
||||||
/** \defgroup GPU_Module GPU module
|
|
||||||
*
|
|
||||||
* GPU-accelerated solvers and operations using NVIDIA CUDA libraries
|
|
||||||
* (cuSOLVER, cuBLAS, cuSPARSE, cuFFT, cuDSS).
|
|
||||||
*
|
|
||||||
* This module provides explicit GPU solver classes that coexist with Eigen's
|
|
||||||
* CPU solvers. Unlike the LAPACKE dispatch (which replaces the CPU
|
|
||||||
* implementation globally), GPU classes are separate types the user
|
|
||||||
* instantiates by choice:
|
|
||||||
*
|
|
||||||
* \code
|
|
||||||
* #define EIGEN_USE_GPU
|
|
||||||
* #include <Eigen/GPU>
|
|
||||||
*
|
|
||||||
* // CPU path (unchanged)
|
|
||||||
* Eigen::LLT<Eigen::MatrixXd> llt_cpu(A);
|
|
||||||
*
|
|
||||||
* // GPU path (explicit)
|
|
||||||
* Eigen::GpuLLT<double> llt_gpu(A); // L stays on device
|
|
||||||
* auto X = llt_gpu.solve(B); // only B transferred per solve
|
|
||||||
* \endcode
|
|
||||||
*
|
|
||||||
* Requires CUDA 11.4+. See CLAUDE.md.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef EIGEN_USE_GPU
|
|
||||||
// IWYU pragma: begin_exports
|
|
||||||
#include "src/GPU/DeviceMatrix.h"
|
|
||||||
#include "src/GPU/GpuContext.h"
|
|
||||||
#include "src/GPU/DeviceExpr.h"
|
|
||||||
#include "src/GPU/DeviceBlasExpr.h"
|
|
||||||
#include "src/GPU/DeviceSolverExpr.h"
|
|
||||||
#include "src/GPU/DeviceDispatch.h"
|
|
||||||
#include "src/GPU/GpuLLT.h"
|
|
||||||
#include "src/GPU/GpuLU.h"
|
|
||||||
#include "src/GPU/GpuQR.h"
|
|
||||||
#include "src/GPU/GpuSVD.h"
|
|
||||||
#include "src/GPU/GpuEigenSolver.h"
|
|
||||||
// IWYU pragma: end_exports
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "src/Core/util/ReenableStupidWarnings.h"
|
|
||||||
|
|
||||||
#endif // EIGEN_GPU_MODULE_H
|
|
||||||
@@ -12,28 +12,30 @@
|
|||||||
|
|
||||||
#include "SVD"
|
#include "SVD"
|
||||||
#include "LU"
|
#include "LU"
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
#include "src/Core/util/DisableStupidWarnings.h"
|
#include "src/Core/util/DisableStupidWarnings.h"
|
||||||
|
|
||||||
/** \defgroup Geometry_Module Geometry module
|
/** \defgroup Geometry_Module Geometry module
|
||||||
*
|
*
|
||||||
* This module provides support for:
|
* This module provides support for:
|
||||||
* - fixed-size homogeneous transformations
|
* - fixed-size homogeneous transformations
|
||||||
* - translation, scaling, 2D and 3D rotations
|
* - translation, scaling, 2D and 3D rotations
|
||||||
* - \link Quaternion quaternions \endlink
|
* - \link Quaternion quaternions \endlink
|
||||||
* - cross products (\ref MatrixBase::cross(), \ref MatrixBase::cross3())
|
* - cross products (\ref MatrixBase::cross, \ref MatrixBase::cross3)
|
||||||
* - orthogonal vector generation (MatrixBase::unitOrthogonal)
|
* - orthognal vector generation (\ref MatrixBase::unitOrthogonal)
|
||||||
* - some linear components: \link ParametrizedLine parametrized-lines \endlink and \link Hyperplane hyperplanes \endlink
|
* - some linear components: \link ParametrizedLine parametrized-lines \endlink and \link Hyperplane hyperplanes \endlink
|
||||||
* - \link AlignedBox axis aligned bounding boxes \endlink
|
* - \link AlignedBox axis aligned bounding boxes \endlink
|
||||||
* - \link umeyama() least-square transformation fitting \endlink
|
* - \link umeyama least-square transformation fitting \endlink
|
||||||
* \code
|
*
|
||||||
* #include <Eigen/Geometry>
|
* \code
|
||||||
* \endcode
|
* #include <Eigen/Geometry>
|
||||||
*/
|
* \endcode
|
||||||
|
*/
|
||||||
|
|
||||||
// IWYU pragma: begin_exports
|
|
||||||
#include "src/Geometry/OrthoMethods.h"
|
#include "src/Geometry/OrthoMethods.h"
|
||||||
#include "src/Geometry/EulerAngles.h"
|
#include "src/Geometry/EulerAngles.h"
|
||||||
|
|
||||||
#include "src/Geometry/Homogeneous.h"
|
#include "src/Geometry/Homogeneous.h"
|
||||||
#include "src/Geometry/RotationBase.h"
|
#include "src/Geometry/RotationBase.h"
|
||||||
#include "src/Geometry/Rotation2D.h"
|
#include "src/Geometry/Rotation2D.h"
|
||||||
@@ -47,15 +49,11 @@
|
|||||||
#include "src/Geometry/AlignedBox.h"
|
#include "src/Geometry/AlignedBox.h"
|
||||||
#include "src/Geometry/Umeyama.h"
|
#include "src/Geometry/Umeyama.h"
|
||||||
|
|
||||||
#ifndef EIGEN_VECTORIZE_GENERIC
|
|
||||||
// TODO(rmlarsen): Make these work with generic vectorization if possible.
|
|
||||||
// Use the SSE optimized version whenever possible.
|
// Use the SSE optimized version whenever possible.
|
||||||
#if (defined EIGEN_VECTORIZE_SSE) || (defined EIGEN_VECTORIZE_NEON)
|
#if (defined EIGEN_VECTORIZE_SSE) || (defined EIGEN_VECTORIZE_NEON)
|
||||||
#include "src/Geometry/arch/Geometry_SIMD.h"
|
#include "src/Geometry/arch/Geometry_SIMD.h"
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
// IWYU pragma: end_exports
|
|
||||||
|
|
||||||
#include "src/Core/util/ReenableStupidWarnings.h"
|
#include "src/Core/util/ReenableStupidWarnings.h"
|
||||||
|
|
||||||
#endif // EIGEN_GEOMETRY_MODULE_H
|
#endif // EIGEN_GEOMETRY_MODULE_H
|
||||||
|
|||||||
@@ -13,19 +13,17 @@
|
|||||||
#include "src/Core/util/DisableStupidWarnings.h"
|
#include "src/Core/util/DisableStupidWarnings.h"
|
||||||
|
|
||||||
/** \defgroup Householder_Module Householder module
|
/** \defgroup Householder_Module Householder module
|
||||||
* This module provides Householder transformations.
|
* This module provides Householder transformations.
|
||||||
*
|
*
|
||||||
* \code
|
* \code
|
||||||
* #include <Eigen/Householder>
|
* #include <Eigen/Householder>
|
||||||
* \endcode
|
* \endcode
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// IWYU pragma: begin_exports
|
|
||||||
#include "src/Householder/Householder.h"
|
#include "src/Householder/Householder.h"
|
||||||
#include "src/Householder/BlockHouseholder.h"
|
|
||||||
#include "src/Householder/HouseholderSequence.h"
|
#include "src/Householder/HouseholderSequence.h"
|
||||||
// IWYU pragma: end_exports
|
#include "src/Householder/BlockHouseholder.h"
|
||||||
|
|
||||||
#include "src/Core/util/ReenableStupidWarnings.h"
|
#include "src/Core/util/ReenableStupidWarnings.h"
|
||||||
|
|
||||||
#endif // EIGEN_HOUSEHOLDER_MODULE_H
|
#endif // EIGEN_HOUSEHOLDER_MODULE_H
|
||||||
|
|||||||
@@ -13,11 +13,10 @@
|
|||||||
|
|
||||||
#include "src/Core/util/DisableStupidWarnings.h"
|
#include "src/Core/util/DisableStupidWarnings.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \defgroup IterativeLinearSolvers_Module IterativeLinearSolvers module
|
* \defgroup IterativeLinearSolvers_Module IterativeLinearSolvers module
|
||||||
*
|
*
|
||||||
* This module currently provides iterative methods to solve problems of the form \c A \c x = \c b, where \c A is a
|
* This module currently provides iterative methods to solve problems of the form \c A \c x = \c b, where \c A is a squared matrix, usually very large and sparse.
|
||||||
squared matrix, usually very large and sparse.
|
|
||||||
* Those solvers are accessible via the following classes:
|
* Those solvers are accessible via the following classes:
|
||||||
* - ConjugateGradient for selfadjoint (hermitian) matrices,
|
* - ConjugateGradient for selfadjoint (hermitian) matrices,
|
||||||
* - LeastSquaresConjugateGradient for rectangular least-square problems,
|
* - LeastSquaresConjugateGradient for rectangular least-square problems,
|
||||||
@@ -28,15 +27,13 @@
|
|||||||
* - DiagonalPreconditioner - also called Jacobi preconditioner, work very well on diagonal dominant matrices.
|
* - DiagonalPreconditioner - also called Jacobi preconditioner, work very well on diagonal dominant matrices.
|
||||||
* - IncompleteLUT - incomplete LU factorization with dual thresholding
|
* - IncompleteLUT - incomplete LU factorization with dual thresholding
|
||||||
*
|
*
|
||||||
* Such problems can also be solved using the direct sparse decomposition modules: SparseCholesky, CholmodSupport,
|
* Such problems can also be solved using the direct sparse decomposition modules: SparseCholesky, CholmodSupport, UmfPackSupport, SuperLUSupport.
|
||||||
UmfPackSupport, SuperLUSupport, AccelerateSupport.
|
|
||||||
*
|
*
|
||||||
\code
|
\code
|
||||||
#include <Eigen/IterativeLinearSolvers>
|
#include <Eigen/IterativeLinearSolvers>
|
||||||
\endcode
|
\endcode
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// IWYU pragma: begin_exports
|
|
||||||
#include "src/IterativeLinearSolvers/SolveWithGuess.h"
|
#include "src/IterativeLinearSolvers/SolveWithGuess.h"
|
||||||
#include "src/IterativeLinearSolvers/IterativeSolverBase.h"
|
#include "src/IterativeLinearSolvers/IterativeSolverBase.h"
|
||||||
#include "src/IterativeLinearSolvers/BasicPreconditioners.h"
|
#include "src/IterativeLinearSolvers/BasicPreconditioners.h"
|
||||||
@@ -45,8 +42,7 @@
|
|||||||
#include "src/IterativeLinearSolvers/BiCGSTAB.h"
|
#include "src/IterativeLinearSolvers/BiCGSTAB.h"
|
||||||
#include "src/IterativeLinearSolvers/IncompleteLUT.h"
|
#include "src/IterativeLinearSolvers/IncompleteLUT.h"
|
||||||
#include "src/IterativeLinearSolvers/IncompleteCholesky.h"
|
#include "src/IterativeLinearSolvers/IncompleteCholesky.h"
|
||||||
// IWYU pragma: end_exports
|
|
||||||
|
|
||||||
#include "src/Core/util/ReenableStupidWarnings.h"
|
#include "src/Core/util/ReenableStupidWarnings.h"
|
||||||
|
|
||||||
#endif // EIGEN_ITERATIVELINEARSOLVERS_MODULE_H
|
#endif // EIGEN_ITERATIVELINEARSOLVERS_MODULE_H
|
||||||
|
|||||||
25
Eigen/Jacobi
25
Eigen/Jacobi
@@ -13,21 +13,20 @@
|
|||||||
#include "src/Core/util/DisableStupidWarnings.h"
|
#include "src/Core/util/DisableStupidWarnings.h"
|
||||||
|
|
||||||
/** \defgroup Jacobi_Module Jacobi module
|
/** \defgroup Jacobi_Module Jacobi module
|
||||||
* This module provides Jacobi and Givens rotations.
|
* This module provides Jacobi and Givens rotations.
|
||||||
*
|
*
|
||||||
* \code
|
* \code
|
||||||
* #include <Eigen/Jacobi>
|
* #include <Eigen/Jacobi>
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* In addition to listed classes, it defines the two following MatrixBase methods to apply a Jacobi or Givens rotation:
|
* In addition to listed classes, it defines the two following MatrixBase methods to apply a Jacobi or Givens rotation:
|
||||||
* - MatrixBase::applyOnTheLeft()
|
* - MatrixBase::applyOnTheLeft()
|
||||||
* - MatrixBase::applyOnTheRight().
|
* - MatrixBase::applyOnTheRight().
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// IWYU pragma: begin_exports
|
|
||||||
#include "src/Jacobi/Jacobi.h"
|
#include "src/Jacobi/Jacobi.h"
|
||||||
// IWYU pragma: end_exports
|
|
||||||
|
|
||||||
#include "src/Core/util/ReenableStupidWarnings.h"
|
#include "src/Core/util/ReenableStupidWarnings.h"
|
||||||
|
|
||||||
#endif // EIGEN_JACOBI_MODULE_H
|
#endif // EIGEN_JACOBI_MODULE_H
|
||||||
|
|
||||||
|
|||||||
@@ -8,36 +8,34 @@
|
|||||||
#ifndef EIGEN_KLUSUPPORT_MODULE_H
|
#ifndef EIGEN_KLUSUPPORT_MODULE_H
|
||||||
#define EIGEN_KLUSUPPORT_MODULE_H
|
#define EIGEN_KLUSUPPORT_MODULE_H
|
||||||
|
|
||||||
#include "SparseCore"
|
#include <Eigen/SparseCore>
|
||||||
|
|
||||||
#include "src/Core/util/DisableStupidWarnings.h"
|
#include <Eigen/src/Core/util/DisableStupidWarnings.h>
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include <btf.h>
|
#include <btf.h>
|
||||||
#include <klu.h>
|
#include <klu.h>
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \ingroup Support_modules
|
/** \ingroup Support_modules
|
||||||
* \defgroup KLUSupport_Module KLUSupport module
|
* \defgroup KLUSupport_Module KLUSupport module
|
||||||
*
|
*
|
||||||
* This module provides an interface to the KLU library which is part of the <a
|
* This module provides an interface to the KLU library which is part of the <a href="http://www.suitesparse.com">suitesparse</a> package.
|
||||||
* href="http://www.suitesparse.com">suitesparse</a> package. It provides the following factorization class:
|
* It provides the following factorization class:
|
||||||
* - class KLU: a sparse LU factorization, well-suited for circuit simulation.
|
* - class KLU: a sparse LU factorization, well-suited for circuit simulation.
|
||||||
*
|
*
|
||||||
* \code
|
* \code
|
||||||
* #include <Eigen/KLUSupport>
|
* #include <Eigen/KLUSupport>
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* In order to use this module, the klu and btf headers must be accessible from the include paths, and your binary must
|
* In order to use this module, the klu and btf headers must be accessible from the include paths, and your binary must be linked to the klu library and its dependencies.
|
||||||
* be linked to the klu library and its dependencies. The dependencies depend on how KLU has been compiled. For a
|
* The dependencies depend on how umfpack has been compiled.
|
||||||
* cmake based project, you can use our FindKLU.cmake module to help you in this task.
|
* For a cmake based project, you can use our FindKLU.cmake module to help you in this task.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// IWYU pragma: begin_exports
|
|
||||||
#include "src/KLUSupport/KLUSupport.h"
|
#include "src/KLUSupport/KLUSupport.h"
|
||||||
// IWYU pragma: end_exports
|
|
||||||
|
|
||||||
#include "src/Core/util/ReenableStupidWarnings.h"
|
#include <Eigen/src/Core/util/ReenableStupidWarnings.h>
|
||||||
|
|
||||||
#endif // EIGEN_KLUSUPPORT_MODULE_H
|
#endif // EIGEN_KLUSUPPORT_MODULE_H
|
||||||
|
|||||||
34
Eigen/LU
34
Eigen/LU
@@ -13,37 +13,35 @@
|
|||||||
#include "src/Core/util/DisableStupidWarnings.h"
|
#include "src/Core/util/DisableStupidWarnings.h"
|
||||||
|
|
||||||
/** \defgroup LU_Module LU module
|
/** \defgroup LU_Module LU module
|
||||||
* This module includes %LU decomposition and related notions such as matrix inversion and determinant.
|
* This module includes %LU decomposition and related notions such as matrix inversion and determinant.
|
||||||
* This module defines the following MatrixBase methods:
|
* This module defines the following MatrixBase methods:
|
||||||
* - MatrixBase::inverse()
|
* - MatrixBase::inverse()
|
||||||
* - MatrixBase::determinant()
|
* - MatrixBase::determinant()
|
||||||
*
|
*
|
||||||
* \code
|
* \code
|
||||||
* #include <Eigen/LU>
|
* #include <Eigen/LU>
|
||||||
* \endcode
|
* \endcode
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// IWYU pragma: begin_exports
|
|
||||||
#include "src/misc/Kernel.h"
|
#include "src/misc/Kernel.h"
|
||||||
#include "src/misc/Image.h"
|
#include "src/misc/Image.h"
|
||||||
#include "src/misc/RankRevealingBase.h"
|
|
||||||
#include "src/LU/FullPivLU.h"
|
#include "src/LU/FullPivLU.h"
|
||||||
#include "src/LU/PartialPivLU.h"
|
#include "src/LU/PartialPivLU.h"
|
||||||
#ifdef EIGEN_USE_LAPACKE
|
#ifdef EIGEN_USE_LAPACKE
|
||||||
#include "src/misc/lapacke_helpers.h"
|
#ifdef EIGEN_USE_MKL
|
||||||
|
#include "mkl_lapacke.h"
|
||||||
|
#else
|
||||||
|
#include "src/misc/lapacke.h"
|
||||||
|
#endif
|
||||||
#include "src/LU/PartialPivLU_LAPACKE.h"
|
#include "src/LU/PartialPivLU_LAPACKE.h"
|
||||||
#endif
|
#endif
|
||||||
#include "src/LU/Determinant.h"
|
#include "src/LU/Determinant.h"
|
||||||
#include "src/LU/InverseImpl.h"
|
#include "src/LU/InverseImpl.h"
|
||||||
|
|
||||||
#ifndef EIGEN_VECTORIZE_GENERIC
|
|
||||||
// TODO(rmlarsen): Make these work with generic vectorization if possible.
|
|
||||||
#if defined EIGEN_VECTORIZE_SSE || defined EIGEN_VECTORIZE_NEON
|
#if defined EIGEN_VECTORIZE_SSE || defined EIGEN_VECTORIZE_NEON
|
||||||
#include "src/LU/arch/InverseSize4.h"
|
#include "src/LU/arch/InverseSize4.h"
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
// IWYU pragma: end_exports
|
|
||||||
|
|
||||||
#include "src/Core/util/ReenableStupidWarnings.h"
|
#include "src/Core/util/ReenableStupidWarnings.h"
|
||||||
|
|
||||||
#endif // EIGEN_LU_MODULE_H
|
#endif // EIGEN_LU_MODULE_H
|
||||||
|
|||||||
@@ -16,20 +16,20 @@ extern "C" {
|
|||||||
#include <metis.h>
|
#include <metis.h>
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \ingroup Support_modules
|
|
||||||
* \defgroup MetisSupport_Module MetisSupport module
|
|
||||||
*
|
|
||||||
* \code
|
|
||||||
* #include <Eigen/MetisSupport>
|
|
||||||
* \endcode
|
|
||||||
* This module defines an interface to the METIS reordering package (http://glaros.dtc.umn.edu/gkhome/views/metis).
|
|
||||||
* It can be used just as any other built-in method as explained in \link OrderingMethods_Module here. \endlink
|
|
||||||
*/
|
|
||||||
|
|
||||||
// IWYU pragma: begin_exports
|
/** \ingroup Support_modules
|
||||||
|
* \defgroup MetisSupport_Module MetisSupport module
|
||||||
|
*
|
||||||
|
* \code
|
||||||
|
* #include <Eigen/MetisSupport>
|
||||||
|
* \endcode
|
||||||
|
* This module defines an interface to the METIS reordering package (http://glaros.dtc.umn.edu/gkhome/views/metis).
|
||||||
|
* It can be used just as any other built-in method as explained in \link OrderingMethods_Module here. \endlink
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "src/MetisSupport/MetisSupport.h"
|
#include "src/MetisSupport/MetisSupport.h"
|
||||||
// IWYU pragma: end_exports
|
|
||||||
|
|
||||||
#include "src/Core/util/ReenableStupidWarnings.h"
|
#include "src/Core/util/ReenableStupidWarnings.h"
|
||||||
|
|
||||||
#endif // EIGEN_METISSUPPORT_MODULE_H
|
#endif // EIGEN_METISSUPPORT_MODULE_H
|
||||||
|
|||||||
@@ -12,62 +12,59 @@
|
|||||||
|
|
||||||
#include "src/Core/util/DisableStupidWarnings.h"
|
#include "src/Core/util/DisableStupidWarnings.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \defgroup OrderingMethods_Module OrderingMethods module
|
* \defgroup OrderingMethods_Module OrderingMethods module
|
||||||
*
|
*
|
||||||
* This module is currently for internal use only
|
* This module is currently for internal use only
|
||||||
*
|
*
|
||||||
* It defines various built-in and external ordering methods for sparse matrices.
|
* It defines various built-in and external ordering methods for sparse matrices.
|
||||||
* They are typically used to reduce the number of elements during
|
* They are typically used to reduce the number of elements during
|
||||||
* the sparse matrix decomposition (LLT, LU, QR).
|
* the sparse matrix decomposition (LLT, LU, QR).
|
||||||
* Precisely, in a preprocessing step, a permutation matrix P is computed using
|
* Precisely, in a preprocessing step, a permutation matrix P is computed using
|
||||||
* those ordering methods and applied to the columns of the matrix.
|
* those ordering methods and applied to the columns of the matrix.
|
||||||
* Using for instance the sparse Cholesky decomposition, it is expected that
|
* Using for instance the sparse Cholesky decomposition, it is expected that
|
||||||
* the nonzeros elements in LLT(A*P) will be much smaller than that in LLT(A).
|
* the nonzeros elements in LLT(A*P) will be much smaller than that in LLT(A).
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* Usage :
|
* Usage :
|
||||||
* \code
|
* \code
|
||||||
* #include <Eigen/OrderingMethods>
|
* #include <Eigen/OrderingMethods>
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* A simple usage is as a template parameter in the sparse decomposition classes :
|
* A simple usage is as a template parameter in the sparse decomposition classes :
|
||||||
*
|
*
|
||||||
* \code
|
* \code
|
||||||
* SparseLU<MatrixType, COLAMDOrdering<int> > solver;
|
* SparseLU<MatrixType, COLAMDOrdering<int> > solver;
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* \code
|
* \code
|
||||||
* SparseQR<MatrixType, COLAMDOrdering<int> > solver;
|
* SparseQR<MatrixType, COLAMDOrdering<int> > solver;
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* It is possible as well to call directly a particular ordering method for your own purpose,
|
* It is possible as well to call directly a particular ordering method for your own purpose,
|
||||||
* \code
|
* \code
|
||||||
* AMDOrdering<int> ordering;
|
* AMDOrdering<int> ordering;
|
||||||
* PermutationMatrix<Dynamic, Dynamic, int> perm;
|
* PermutationMatrix<Dynamic, Dynamic, int> perm;
|
||||||
* SparseMatrix<double> A;
|
* SparseMatrix<double> A;
|
||||||
* //Fill the matrix ...
|
* //Fill the matrix ...
|
||||||
*
|
*
|
||||||
* ordering(A, perm); // Call AMD
|
* ordering(A, perm); // Call AMD
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* \note Some of these methods (like AMD or METIS), need the sparsity pattern
|
* \note Some of these methods (like AMD or METIS), need the sparsity pattern
|
||||||
* of the input matrix to be symmetric. When the matrix is structurally unsymmetric,
|
* of the input matrix to be symmetric. When the matrix is structurally unsymmetric,
|
||||||
* Eigen computes internally the pattern of \f$A^T*A\f$ before calling the method.
|
* Eigen computes internally the pattern of \f$A^T*A\f$ before calling the method.
|
||||||
* If your matrix is already symmetric (at least in structure), you can avoid that
|
* If your matrix is already symmetric (at leat in structure), you can avoid that
|
||||||
* by calling the method with a SelfAdjointView type.
|
* by calling the method with a SelfAdjointView type.
|
||||||
*
|
*
|
||||||
* \code
|
* \code
|
||||||
* // Call the ordering on the pattern of the lower triangular matrix A
|
* // Call the ordering on the pattern of the lower triangular matrix A
|
||||||
* ordering(A.selfadjointView<Lower>(), perm);
|
* ordering(A.selfadjointView<Lower>(), perm);
|
||||||
* \endcode
|
* \endcode
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// IWYU pragma: begin_exports
|
|
||||||
#include "src/OrderingMethods/Amd.h"
|
#include "src/OrderingMethods/Amd.h"
|
||||||
#include "src/OrderingMethods/Ordering.h"
|
#include "src/OrderingMethods/Ordering.h"
|
||||||
// IWYU pragma: end_exports
|
|
||||||
|
|
||||||
#include "src/Core/util/ReenableStupidWarnings.h"
|
#include "src/Core/util/ReenableStupidWarnings.h"
|
||||||
|
|
||||||
#endif // EIGEN_ORDERINGMETHODS_MODULE_H
|
#endif // EIGEN_ORDERINGMETHODS_MODULE_H
|
||||||
|
|||||||
@@ -22,30 +22,28 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** \ingroup Support_modules
|
/** \ingroup Support_modules
|
||||||
* \defgroup PaStiXSupport_Module PaStiXSupport module
|
* \defgroup PaStiXSupport_Module PaStiXSupport module
|
||||||
*
|
*
|
||||||
* This module provides an interface to the <a href="http://pastix.gforge.inria.fr/">PaSTiX</a> library.
|
* This module provides an interface to the <a href="http://pastix.gforge.inria.fr/">PaSTiX</a> library.
|
||||||
* PaSTiX is a general \b supernodal, \b parallel and \b opensource sparse solver.
|
* PaSTiX is a general \b supernodal, \b parallel and \b opensource sparse solver.
|
||||||
* It provides the two following main factorization classes:
|
* It provides the two following main factorization classes:
|
||||||
* - class PastixLLT : a supernodal, parallel LLt Cholesky factorization.
|
* - class PastixLLT : a supernodal, parallel LLt Cholesky factorization.
|
||||||
* - class PastixLDLT: a supernodal, parallel LDLt Cholesky factorization.
|
* - class PastixLDLT: a supernodal, parallel LDLt Cholesky factorization.
|
||||||
* - class PastixLU : a supernodal, parallel LU factorization (optimized for a symmetric pattern).
|
* - class PastixLU : a supernodal, parallel LU factorization (optimized for a symmetric pattern).
|
||||||
*
|
*
|
||||||
* \code
|
* \code
|
||||||
* #include <Eigen/PaStiXSupport>
|
* #include <Eigen/PaStiXSupport>
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* In order to use this module, the PaSTiX headers must be accessible from the include paths, and your binary must be
|
* In order to use this module, the PaSTiX headers must be accessible from the include paths, and your binary must be linked to the PaSTiX library and its dependencies.
|
||||||
* linked to the PaSTiX library and its dependencies. This wrapper requires PaStiX version 5.x compiled without MPI
|
* This wrapper resuires PaStiX version 5.x compiled without MPI support.
|
||||||
* support. The dependencies depend on how PaSTiX has been compiled. For a cmake based project, you can use our
|
* The dependencies depend on how PaSTiX has been compiled.
|
||||||
* FindPaSTiX.cmake module to help you in this task.
|
* For a cmake based project, you can use our FindPaSTiX.cmake module to help you in this task.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// IWYU pragma: begin_exports
|
|
||||||
#include "src/PaStiXSupport/PaStiXSupport.h"
|
#include "src/PaStiXSupport/PaStiXSupport.h"
|
||||||
// IWYU pragma: end_exports
|
|
||||||
|
|
||||||
#include "src/Core/util/ReenableStupidWarnings.h"
|
#include "src/Core/util/ReenableStupidWarnings.h"
|
||||||
|
|
||||||
#endif // EIGEN_PASTIXSUPPORT_MODULE_H
|
#endif // EIGEN_PASTIXSUPPORT_MODULE_H
|
||||||
|
|||||||
@@ -15,24 +15,21 @@
|
|||||||
#include <mkl_pardiso.h>
|
#include <mkl_pardiso.h>
|
||||||
|
|
||||||
/** \ingroup Support_modules
|
/** \ingroup Support_modules
|
||||||
* \defgroup PardisoSupport_Module PardisoSupport module
|
* \defgroup PardisoSupport_Module PardisoSupport module
|
||||||
*
|
*
|
||||||
* This module brings support for the Intel(R) MKL PARDISO direct sparse solvers.
|
* This module brings support for the Intel(R) MKL PARDISO direct sparse solvers.
|
||||||
*
|
*
|
||||||
* \code
|
* \code
|
||||||
* #include <Eigen/PardisoSupport>
|
* #include <Eigen/PardisoSupport>
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* In order to use this module, the MKL headers must be accessible from the include paths, and your binary must be
|
* In order to use this module, the MKL headers must be accessible from the include paths, and your binary must be linked to the MKL library and its dependencies.
|
||||||
* linked to the MKL library and its dependencies. See this \ref TopicUsingIntelMKL "page" for more information on
|
* See this \ref TopicUsingIntelMKL "page" for more information on MKL-Eigen integration.
|
||||||
* MKL-Eigen integration.
|
*
|
||||||
*
|
*/
|
||||||
*/
|
|
||||||
|
|
||||||
// IWYU pragma: begin_exports
|
|
||||||
#include "src/PardisoSupport/PardisoSupport.h"
|
#include "src/PardisoSupport/PardisoSupport.h"
|
||||||
// IWYU pragma: end_exports
|
|
||||||
|
|
||||||
#include "src/Core/util/ReenableStupidWarnings.h"
|
#include "src/Core/util/ReenableStupidWarnings.h"
|
||||||
|
|
||||||
#endif // EIGEN_PARDISOSUPPORT_MODULE_H
|
#endif // EIGEN_PARDISOSUPPORT_MODULE_H
|
||||||
|
|||||||
37
Eigen/QR
37
Eigen/QR
@@ -11,37 +11,40 @@
|
|||||||
#include "Core"
|
#include "Core"
|
||||||
|
|
||||||
#include "Cholesky"
|
#include "Cholesky"
|
||||||
|
#include "Jacobi"
|
||||||
#include "Householder"
|
#include "Householder"
|
||||||
|
|
||||||
#include "src/Core/util/DisableStupidWarnings.h"
|
#include "src/Core/util/DisableStupidWarnings.h"
|
||||||
|
|
||||||
/** \defgroup QR_Module QR module
|
/** \defgroup QR_Module QR module
|
||||||
*
|
*
|
||||||
* This module provides various QR decompositions
|
*
|
||||||
* This module also provides some MatrixBase methods, including:
|
*
|
||||||
* - MatrixBase::householderQr()
|
* This module provides various QR decompositions
|
||||||
* - MatrixBase::colPivHouseholderQr()
|
* This module also provides some MatrixBase methods, including:
|
||||||
* - MatrixBase::fullPivHouseholderQr()
|
* - MatrixBase::householderQr()
|
||||||
*
|
* - MatrixBase::colPivHouseholderQr()
|
||||||
* \code
|
* - MatrixBase::fullPivHouseholderQr()
|
||||||
* #include <Eigen/QR>
|
*
|
||||||
* \endcode
|
* \code
|
||||||
*/
|
* #include <Eigen/QR>
|
||||||
|
* \endcode
|
||||||
|
*/
|
||||||
|
|
||||||
#include "src/misc/RankRevealingBase.h"
|
|
||||||
|
|
||||||
// IWYU pragma: begin_exports
|
|
||||||
#include "src/QR/HouseholderQR.h"
|
#include "src/QR/HouseholderQR.h"
|
||||||
#include "src/QR/FullPivHouseholderQR.h"
|
#include "src/QR/FullPivHouseholderQR.h"
|
||||||
#include "src/QR/ColPivHouseholderQR.h"
|
#include "src/QR/ColPivHouseholderQR.h"
|
||||||
#include "src/QR/CompleteOrthogonalDecomposition.h"
|
#include "src/QR/CompleteOrthogonalDecomposition.h"
|
||||||
#ifdef EIGEN_USE_LAPACKE
|
#ifdef EIGEN_USE_LAPACKE
|
||||||
#include "src/misc/lapacke_helpers.h"
|
#ifdef EIGEN_USE_MKL
|
||||||
|
#include "mkl_lapacke.h"
|
||||||
|
#else
|
||||||
|
#include "src/misc/lapacke.h"
|
||||||
|
#endif
|
||||||
#include "src/QR/HouseholderQR_LAPACKE.h"
|
#include "src/QR/HouseholderQR_LAPACKE.h"
|
||||||
#include "src/QR/ColPivHouseholderQR_LAPACKE.h"
|
#include "src/QR/ColPivHouseholderQR_LAPACKE.h"
|
||||||
#endif
|
#endif
|
||||||
// IWYU pragma: end_exports
|
|
||||||
|
|
||||||
#include "src/Core/util/ReenableStupidWarnings.h"
|
#include "src/Core/util/ReenableStupidWarnings.h"
|
||||||
|
|
||||||
#endif // EIGEN_QR_MODULE_H
|
#endif // EIGEN_QR_MODULE_H
|
||||||
|
|||||||
@@ -14,12 +14,19 @@
|
|||||||
|
|
||||||
#include "src/Core/util/DisableStupidWarnings.h"
|
#include "src/Core/util/DisableStupidWarnings.h"
|
||||||
|
|
||||||
inline void *qMalloc(std::size_t size) { return Eigen::internal::aligned_malloc(size); }
|
void *qMalloc(std::size_t size)
|
||||||
|
{
|
||||||
|
return Eigen::internal::aligned_malloc(size);
|
||||||
|
}
|
||||||
|
|
||||||
inline void qFree(void *ptr) { Eigen::internal::aligned_free(ptr); }
|
void qFree(void *ptr)
|
||||||
|
{
|
||||||
|
Eigen::internal::aligned_free(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
inline void *qRealloc(void *ptr, std::size_t size) {
|
void *qRealloc(void *ptr, std::size_t size)
|
||||||
void *newPtr = Eigen::internal::aligned_malloc(size);
|
{
|
||||||
|
void* newPtr = Eigen::internal::aligned_malloc(size);
|
||||||
std::memcpy(newPtr, ptr, size);
|
std::memcpy(newPtr, ptr, size);
|
||||||
Eigen::internal::aligned_free(ptr);
|
Eigen::internal::aligned_free(ptr);
|
||||||
return newPtr;
|
return newPtr;
|
||||||
@@ -29,4 +36,4 @@ inline void *qRealloc(void *ptr, std::size_t size) {
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // EIGEN_QTMALLOC_MODULE_H
|
#endif // EIGEN_QTMALLOC_MODULE_H
|
||||||
|
|||||||
@@ -15,27 +15,20 @@
|
|||||||
#include "SuiteSparseQR.hpp"
|
#include "SuiteSparseQR.hpp"
|
||||||
|
|
||||||
/** \ingroup Support_modules
|
/** \ingroup Support_modules
|
||||||
* \defgroup SPQRSupport_Module SuiteSparseQR module
|
* \defgroup SPQRSupport_Module SuiteSparseQR module
|
||||||
*
|
*
|
||||||
* This module provides an interface to the SPQR library, which is part of the <a
|
* This module provides an interface to the SPQR library, which is part of the <a href="http://www.suitesparse.com">suitesparse</a> package.
|
||||||
* href="http://www.suitesparse.com">suitesparse</a> package.
|
*
|
||||||
*
|
* \code
|
||||||
* \code
|
* #include <Eigen/SPQRSupport>
|
||||||
* #include <Eigen/SPQRSupport>
|
* \endcode
|
||||||
* \endcode
|
*
|
||||||
*
|
* In order to use this module, the SPQR headers must be accessible from the include paths, and your binary must be linked to the SPQR library and its dependencies (Cholmod, AMD, COLAMD,...).
|
||||||
* In order to use this module, the SPQR headers must be accessible from the include paths, and your binary must be
|
* For a cmake based project, you can use our FindSPQR.cmake and FindCholmod.Cmake modules
|
||||||
* linked to the SPQR library and its dependencies (Cholmod, AMD, COLAMD,...). For a cmake based project, you can use
|
*
|
||||||
* our FindSPQR.cmake and FindCholmod.Cmake modules
|
*/
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "CholmodSupport"
|
#include "src/CholmodSupport/CholmodSupport.h"
|
||||||
|
|
||||||
// IWYU pragma: begin_exports
|
|
||||||
#include "src/SPQRSupport/SuiteSparseQRSupport.h"
|
#include "src/SPQRSupport/SuiteSparseQRSupport.h"
|
||||||
// IWYU pragma: end_exports
|
|
||||||
|
|
||||||
#include "src/Core/util/ReenableStupidWarnings.h"
|
#endif
|
||||||
|
|
||||||
#endif // EIGEN_SPQRSUPPORT_MODULE_H
|
|
||||||
|
|||||||
43
Eigen/SVD
43
Eigen/SVD
@@ -9,45 +9,42 @@
|
|||||||
#define EIGEN_SVD_MODULE_H
|
#define EIGEN_SVD_MODULE_H
|
||||||
|
|
||||||
#include "QR"
|
#include "QR"
|
||||||
|
#include "Householder"
|
||||||
|
#include "Jacobi"
|
||||||
|
|
||||||
#include "src/Core/util/DisableStupidWarnings.h"
|
#include "src/Core/util/DisableStupidWarnings.h"
|
||||||
|
|
||||||
/** \defgroup SVD_Module SVD module
|
/** \defgroup SVD_Module SVD module
|
||||||
*
|
*
|
||||||
* This module provides SVD decomposition for matrices (both real and complex).
|
*
|
||||||
* Two decomposition algorithms are provided:
|
*
|
||||||
* - JacobiSVD implementing two-sided Jacobi iterations is numerically very accurate, fast for small matrices, but very
|
* This module provides SVD decomposition for matrices (both real and complex).
|
||||||
* slow for larger ones.
|
* Two decomposition algorithms are provided:
|
||||||
* - BDCSVD implementing a recursive divide & conquer strategy on top of an upper-bidiagonalization which remains fast
|
* - JacobiSVD implementing two-sided Jacobi iterations is numerically very accurate, fast for small matrices, but very slow for larger ones.
|
||||||
* for large problems. These decompositions are accessible via the respective classes and following MatrixBase methods:
|
* - BDCSVD implementing a recursive divide & conquer strategy on top of an upper-bidiagonalization which remains fast for large problems.
|
||||||
* - MatrixBase::jacobiSvd()
|
* These decompositions are accessible via the respective classes and following MatrixBase methods:
|
||||||
* - MatrixBase::bdcSvd()
|
* - MatrixBase::jacobiSvd()
|
||||||
*
|
* - MatrixBase::bdcSvd()
|
||||||
* \code
|
*
|
||||||
* #include <Eigen/SVD>
|
* \code
|
||||||
* \endcode
|
* #include <Eigen/SVD>
|
||||||
*/
|
* \endcode
|
||||||
|
*/
|
||||||
|
|
||||||
// IWYU pragma: begin_exports
|
#include "src/misc/RealSvd2x2.h"
|
||||||
#include "src/SVD/UpperBidiagonalization.h"
|
#include "src/SVD/UpperBidiagonalization.h"
|
||||||
#include "src/SVD/SVDBase.h"
|
#include "src/SVD/SVDBase.h"
|
||||||
#include "src/SVD/JacobiSVD.h"
|
#include "src/SVD/JacobiSVD.h"
|
||||||
#include "src/SVD/BDCSVD.h"
|
#include "src/SVD/BDCSVD.h"
|
||||||
#ifdef EIGEN_USE_LAPACKE
|
#if defined(EIGEN_USE_LAPACKE) && !defined(EIGEN_USE_LAPACKE_STRICT)
|
||||||
#ifdef EIGEN_USE_MKL
|
#ifdef EIGEN_USE_MKL
|
||||||
#include "mkl_lapacke.h"
|
#include "mkl_lapacke.h"
|
||||||
#elif defined(EIGEN_LAPACKE_SYSTEM)
|
|
||||||
#include <lapacke.h>
|
|
||||||
#else
|
#else
|
||||||
#include "src/misc/lapacke.h"
|
#include "src/misc/lapacke.h"
|
||||||
#endif
|
#endif
|
||||||
#ifndef EIGEN_USE_LAPACKE_STRICT
|
|
||||||
#include "src/SVD/JacobiSVD_LAPACKE.h"
|
#include "src/SVD/JacobiSVD_LAPACKE.h"
|
||||||
#endif
|
#endif
|
||||||
#include "src/SVD/BDCSVD_LAPACKE.h"
|
|
||||||
#endif
|
|
||||||
// IWYU pragma: end_exports
|
|
||||||
|
|
||||||
#include "src/Core/util/ReenableStupidWarnings.h"
|
#include "src/Core/util/ReenableStupidWarnings.h"
|
||||||
|
|
||||||
#endif // EIGEN_SVD_MODULE_H
|
#endif // EIGEN_SVD_MODULE_H
|
||||||
|
|||||||
@@ -30,4 +30,5 @@
|
|||||||
#include "SparseQR"
|
#include "SparseQR"
|
||||||
#include "IterativeLinearSolvers"
|
#include "IterativeLinearSolvers"
|
||||||
|
|
||||||
#endif // EIGEN_SPARSE_MODULE_H
|
#endif // EIGEN_SPARSE_MODULE_H
|
||||||
|
|
||||||
|
|||||||
@@ -15,26 +15,23 @@
|
|||||||
|
|
||||||
#include "src/Core/util/DisableStupidWarnings.h"
|
#include "src/Core/util/DisableStupidWarnings.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \defgroup SparseCholesky_Module SparseCholesky module
|
* \defgroup SparseCholesky_Module SparseCholesky module
|
||||||
*
|
*
|
||||||
* This module currently provides two variants of the direct sparse Cholesky decomposition for selfadjoint (hermitian)
|
* This module currently provides two variants of the direct sparse Cholesky decomposition for selfadjoint (hermitian) matrices.
|
||||||
* matrices. Those decompositions are accessible via the following classes:
|
* Those decompositions are accessible via the following classes:
|
||||||
* - SimplicialLLt,
|
* - SimplicialLLt,
|
||||||
* - SimplicialLDLt
|
* - SimplicialLDLt
|
||||||
*
|
*
|
||||||
* Such problems can also be solved using the ConjugateGradient solver from the IterativeLinearSolvers module.
|
* Such problems can also be solved using the ConjugateGradient solver from the IterativeLinearSolvers module.
|
||||||
*
|
*
|
||||||
* \code
|
* \code
|
||||||
* #include <Eigen/SparseCholesky>
|
* #include <Eigen/SparseCholesky>
|
||||||
* \endcode
|
* \endcode
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// IWYU pragma: begin_exports
|
|
||||||
#include "src/SparseCholesky/SimplicialCholesky.h"
|
#include "src/SparseCholesky/SimplicialCholesky.h"
|
||||||
#include "src/SparseCholesky/SimplicialCholesky_impl.h"
|
#include "src/SparseCholesky/SimplicialCholesky_impl.h"
|
||||||
// IWYU pragma: end_exports
|
|
||||||
|
|
||||||
#include "src/Core/util/ReenableStupidWarnings.h"
|
#include "src/Core/util/ReenableStupidWarnings.h"
|
||||||
|
|
||||||
#endif // EIGEN_SPARSECHOLESKY_MODULE_H
|
#endif // EIGEN_SPARSECHOLESKY_MODULE_H
|
||||||
|
|||||||
@@ -12,25 +12,27 @@
|
|||||||
|
|
||||||
#include "src/Core/util/DisableStupidWarnings.h"
|
#include "src/Core/util/DisableStupidWarnings.h"
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <numeric>
|
#include <cstdlib>
|
||||||
|
#include <cstring>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \defgroup SparseCore_Module SparseCore module
|
* \defgroup SparseCore_Module SparseCore module
|
||||||
*
|
*
|
||||||
* This module provides a sparse matrix representation, and basic associated matrix manipulations
|
* This module provides a sparse matrix representation, and basic associated matrix manipulations
|
||||||
* and operations.
|
* and operations.
|
||||||
*
|
*
|
||||||
* See the \ref TutorialSparse "Sparse tutorial"
|
* See the \ref TutorialSparse "Sparse tutorial"
|
||||||
*
|
*
|
||||||
* \code
|
* \code
|
||||||
* #include <Eigen/SparseCore>
|
* #include <Eigen/SparseCore>
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* This module depends on: Core.
|
* This module depends on: Core.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// IWYU pragma: begin_exports
|
|
||||||
#include "src/SparseCore/SparseUtil.h"
|
#include "src/SparseCore/SparseUtil.h"
|
||||||
#include "src/SparseCore/SparseMatrixBase.h"
|
#include "src/SparseCore/SparseMatrixBase.h"
|
||||||
#include "src/SparseCore/SparseAssign.h"
|
#include "src/SparseCore/SparseAssign.h"
|
||||||
@@ -39,6 +41,7 @@
|
|||||||
#include "src/SparseCore/SparseCompressedBase.h"
|
#include "src/SparseCore/SparseCompressedBase.h"
|
||||||
#include "src/SparseCore/SparseMatrix.h"
|
#include "src/SparseCore/SparseMatrix.h"
|
||||||
#include "src/SparseCore/SparseMap.h"
|
#include "src/SparseCore/SparseMap.h"
|
||||||
|
#include "src/SparseCore/MappedSparseMatrix.h"
|
||||||
#include "src/SparseCore/SparseVector.h"
|
#include "src/SparseCore/SparseVector.h"
|
||||||
#include "src/SparseCore/SparseRef.h"
|
#include "src/SparseCore/SparseRef.h"
|
||||||
#include "src/SparseCore/SparseCwiseUnaryOp.h"
|
#include "src/SparseCore/SparseCwiseUnaryOp.h"
|
||||||
@@ -59,8 +62,8 @@
|
|||||||
#include "src/SparseCore/SparsePermutation.h"
|
#include "src/SparseCore/SparsePermutation.h"
|
||||||
#include "src/SparseCore/SparseFuzzy.h"
|
#include "src/SparseCore/SparseFuzzy.h"
|
||||||
#include "src/SparseCore/SparseSolverBase.h"
|
#include "src/SparseCore/SparseSolverBase.h"
|
||||||
// IWYU pragma: end_exports
|
|
||||||
|
|
||||||
#include "src/Core/util/ReenableStupidWarnings.h"
|
#include "src/Core/util/ReenableStupidWarnings.h"
|
||||||
|
|
||||||
#endif // EIGEN_SPARSECORE_MODULE_H
|
#endif // EIGEN_SPARSECORE_MODULE_H
|
||||||
|
|
||||||
|
|||||||
@@ -13,19 +13,18 @@
|
|||||||
|
|
||||||
#include "SparseCore"
|
#include "SparseCore"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \defgroup SparseLU_Module SparseLU module
|
* \defgroup SparseLU_Module SparseLU module
|
||||||
* This module defines a supernodal factorization of general sparse matrices.
|
* This module defines a supernodal factorization of general sparse matrices.
|
||||||
* The code is fully optimized for supernode-panel updates with specialized kernels.
|
* The code is fully optimized for supernode-panel updates with specialized kernels.
|
||||||
* Please, see the documentation of the SparseLU class for more details.
|
* Please, see the documentation of the SparseLU class for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Ordering interface
|
// Ordering interface
|
||||||
#include "OrderingMethods"
|
#include "OrderingMethods"
|
||||||
|
|
||||||
#include "src/Core/util/DisableStupidWarnings.h"
|
#include "src/Core/util/DisableStupidWarnings.h"
|
||||||
|
|
||||||
// IWYU pragma: begin_exports
|
|
||||||
#include "src/SparseLU/SparseLU_Structs.h"
|
#include "src/SparseLU/SparseLU_Structs.h"
|
||||||
#include "src/SparseLU/SparseLU_SupernodalMatrix.h"
|
#include "src/SparseLU/SparseLU_SupernodalMatrix.h"
|
||||||
#include "src/SparseLU/SparseLUImpl.h"
|
#include "src/SparseLU/SparseLUImpl.h"
|
||||||
@@ -43,8 +42,7 @@
|
|||||||
#include "src/SparseLU/SparseLU_pruneL.h"
|
#include "src/SparseLU/SparseLU_pruneL.h"
|
||||||
#include "src/SparseLU/SparseLU_Utils.h"
|
#include "src/SparseLU/SparseLU_Utils.h"
|
||||||
#include "src/SparseLU/SparseLU.h"
|
#include "src/SparseLU/SparseLU.h"
|
||||||
// IWYU pragma: end_exports
|
|
||||||
|
|
||||||
#include "src/Core/util/ReenableStupidWarnings.h"
|
#include "src/Core/util/ReenableStupidWarnings.h"
|
||||||
|
|
||||||
#endif // EIGEN_SPARSELU_MODULE_H
|
#endif // EIGEN_SPARSELU_MODULE_H
|
||||||
|
|||||||
@@ -13,26 +13,24 @@
|
|||||||
#include "src/Core/util/DisableStupidWarnings.h"
|
#include "src/Core/util/DisableStupidWarnings.h"
|
||||||
|
|
||||||
/** \defgroup SparseQR_Module SparseQR module
|
/** \defgroup SparseQR_Module SparseQR module
|
||||||
* \brief Provides QR decomposition for sparse matrices
|
* \brief Provides QR decomposition for sparse matrices
|
||||||
*
|
*
|
||||||
* This module provides a simplicial version of the left-looking Sparse QR decomposition.
|
* This module provides a simplicial version of the left-looking Sparse QR decomposition.
|
||||||
* The columns of the input matrix should be reordered to limit the fill-in during the
|
* The columns of the input matrix should be reordered to limit the fill-in during the
|
||||||
* decomposition. Built-in methods (COLAMD, AMD) or external methods (METIS) can be used to this end.
|
* decomposition. Built-in methods (COLAMD, AMD) or external methods (METIS) can be used to this end.
|
||||||
* See the \link OrderingMethods_Module OrderingMethods\endlink module for the list
|
* See the \link OrderingMethods_Module OrderingMethods\endlink module for the list
|
||||||
* of built-in and external ordering methods.
|
* of built-in and external ordering methods.
|
||||||
*
|
*
|
||||||
* \code
|
* \code
|
||||||
* #include <Eigen/SparseQR>
|
* #include <Eigen/SparseQR>
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// IWYU pragma: begin_exports
|
|
||||||
#include "src/SparseCore/SparseColEtree.h"
|
#include "src/SparseCore/SparseColEtree.h"
|
||||||
#include "src/SparseQR/SparseQR.h"
|
#include "src/SparseQR/SparseQR.h"
|
||||||
// IWYU pragma: end_exports
|
|
||||||
|
|
||||||
#include "src/Core/util/ReenableStupidWarnings.h"
|
#include "src/Core/util/ReenableStupidWarnings.h"
|
||||||
|
|
||||||
#endif // EIGEN_SPARSEQR_MODULE_H
|
#endif
|
||||||
|
|||||||
@@ -14,17 +14,14 @@
|
|||||||
#include "Core"
|
#include "Core"
|
||||||
#include <deque>
|
#include <deque>
|
||||||
|
|
||||||
#if EIGEN_COMP_MSVC && EIGEN_OS_WIN64 && \
|
#if EIGEN_COMP_MSVC && EIGEN_OS_WIN64 && (EIGEN_MAX_STATIC_ALIGN_BYTES<=16) /* MSVC auto aligns up to 16 bytes in 64 bit builds */
|
||||||
(EIGEN_MAX_STATIC_ALIGN_BYTES <= 16) /* MSVC auto aligns up to 16 bytes in 64 bit builds */
|
|
||||||
|
|
||||||
#define EIGEN_DEFINE_STL_DEQUE_SPECIALIZATION(...)
|
#define EIGEN_DEFINE_STL_DEQUE_SPECIALIZATION(...)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
// IWYU pragma: begin_exports
|
|
||||||
#include "src/StlSupport/StdDeque.h"
|
#include "src/StlSupport/StdDeque.h"
|
||||||
// IWYU pragma: end_exports
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // EIGEN_STDDEQUE_MODULE_H
|
#endif // EIGEN_STDDEQUE_MODULE_H
|
||||||
|
|||||||
@@ -13,17 +13,14 @@
|
|||||||
#include "Core"
|
#include "Core"
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
#if EIGEN_COMP_MSVC && EIGEN_OS_WIN64 && \
|
#if EIGEN_COMP_MSVC && EIGEN_OS_WIN64 && (EIGEN_MAX_STATIC_ALIGN_BYTES<=16) /* MSVC auto aligns up to 16 bytes in 64 bit builds */
|
||||||
(EIGEN_MAX_STATIC_ALIGN_BYTES <= 16) /* MSVC auto aligns up to 16 bytes in 64 bit builds */
|
|
||||||
|
|
||||||
#define EIGEN_DEFINE_STL_LIST_SPECIALIZATION(...)
|
#define EIGEN_DEFINE_STL_LIST_SPECIALIZATION(...)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
// IWYU pragma: begin_exports
|
|
||||||
#include "src/StlSupport/StdList.h"
|
#include "src/StlSupport/StdList.h"
|
||||||
// IWYU pragma: end_exports
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // EIGEN_STDLIST_MODULE_H
|
#endif // EIGEN_STDLIST_MODULE_H
|
||||||
|
|||||||
@@ -14,17 +14,14 @@
|
|||||||
#include "Core"
|
#include "Core"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#if EIGEN_COMP_MSVC && EIGEN_OS_WIN64 && \
|
#if EIGEN_COMP_MSVC && EIGEN_OS_WIN64 && (EIGEN_MAX_STATIC_ALIGN_BYTES<=16) /* MSVC auto aligns up to 16 bytes in 64 bit builds */
|
||||||
(EIGEN_MAX_STATIC_ALIGN_BYTES <= 16) /* MSVC auto aligns up to 16 bytes in 64 bit builds */
|
|
||||||
|
|
||||||
#define EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(...)
|
#define EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(...)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
// IWYU pragma: begin_exports
|
|
||||||
#include "src/StlSupport/StdVector.h"
|
#include "src/StlSupport/StdVector.h"
|
||||||
// IWYU pragma: end_exports
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // EIGEN_STDVECTOR_MODULE_H
|
#endif // EIGEN_STDVECTOR_MODULE_H
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
#define EIGEN_EMPTY_WAS_ALREADY_DEFINED
|
#define EIGEN_EMPTY_WAS_ALREADY_DEFINED
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Required by SuperLU headers, which expect int_t to be defined as a global typedef.
|
|
||||||
typedef int int_t;
|
typedef int int_t;
|
||||||
#include <slu_Cnames.h>
|
#include <slu_Cnames.h>
|
||||||
#include <supermatrix.h>
|
#include <supermatrix.h>
|
||||||
@@ -27,45 +26,39 @@ typedef int int_t;
|
|||||||
// If EMPTY was already defined then we don't undef it.
|
// If EMPTY was already defined then we don't undef it.
|
||||||
|
|
||||||
#if defined(EIGEN_EMPTY_WAS_ALREADY_DEFINED)
|
#if defined(EIGEN_EMPTY_WAS_ALREADY_DEFINED)
|
||||||
#undef EIGEN_EMPTY_WAS_ALREADY_DEFINED
|
# undef EIGEN_EMPTY_WAS_ALREADY_DEFINED
|
||||||
#elif defined(EMPTY)
|
#elif defined(EMPTY)
|
||||||
#undef EMPTY
|
# undef EMPTY
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define SUPERLU_EMPTY (-1)
|
#define SUPERLU_EMPTY (-1)
|
||||||
|
|
||||||
namespace Eigen {
|
namespace Eigen { struct SluMatrix; }
|
||||||
struct SluMatrix;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** \ingroup Support_modules
|
/** \ingroup Support_modules
|
||||||
* \defgroup SuperLUSupport_Module SuperLUSupport module
|
* \defgroup SuperLUSupport_Module SuperLUSupport module
|
||||||
*
|
*
|
||||||
* This module provides an interface to the <a href="http://crd-legacy.lbl.gov/~xiaoye/SuperLU/">SuperLU</a> library.
|
* This module provides an interface to the <a href="http://crd-legacy.lbl.gov/~xiaoye/SuperLU/">SuperLU</a> library.
|
||||||
* It provides the following factorization class:
|
* It provides the following factorization class:
|
||||||
* - class SuperLU: a supernodal sequential LU factorization.
|
* - class SuperLU: a supernodal sequential LU factorization.
|
||||||
* - class SuperILU: a supernodal sequential incomplete LU factorization (to be used as a preconditioner for iterative
|
* - class SuperILU: a supernodal sequential incomplete LU factorization (to be used as a preconditioner for iterative methods).
|
||||||
* methods).
|
*
|
||||||
*
|
* \warning This wrapper requires at least versions 4.0 of SuperLU. The 3.x versions are not supported.
|
||||||
* \warning This wrapper requires at least versions 4.0 of SuperLU. The 3.x versions are not supported.
|
*
|
||||||
*
|
* \warning When including this module, you have to use SUPERLU_EMPTY instead of EMPTY which is no longer defined because it is too polluting.
|
||||||
* \warning When including this module, you have to use SUPERLU_EMPTY instead of EMPTY which is no longer defined
|
*
|
||||||
* because it is too polluting.
|
* \code
|
||||||
*
|
* #include <Eigen/SuperLUSupport>
|
||||||
* \code
|
* \endcode
|
||||||
* #include <Eigen/SuperLUSupport>
|
*
|
||||||
* \endcode
|
* In order to use this module, the superlu headers must be accessible from the include paths, and your binary must be linked to the superlu library and its dependencies.
|
||||||
*
|
* The dependencies depend on how superlu has been compiled.
|
||||||
* In order to use this module, the superlu headers must be accessible from the include paths, and your binary must be
|
* For a cmake based project, you can use our FindSuperLU.cmake module to help you in this task.
|
||||||
* linked to the superlu library and its dependencies. The dependencies depend on how superlu has been compiled. For a
|
*
|
||||||
* cmake based project, you can use our FindSuperLU.cmake module to help you in this task.
|
*/
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
// IWYU pragma: begin_exports
|
|
||||||
#include "src/SuperLUSupport/SuperLUSupport.h"
|
#include "src/SuperLUSupport/SuperLUSupport.h"
|
||||||
// IWYU pragma: end_exports
|
|
||||||
|
|
||||||
#include "src/Core/util/ReenableStupidWarnings.h"
|
#include "src/Core/util/ReenableStupidWarnings.h"
|
||||||
|
|
||||||
#endif // EIGEN_SUPERLUSUPPORT_MODULE_H
|
#endif // EIGEN_SUPERLUSUPPORT_MODULE_H
|
||||||
|
|||||||
@@ -1,80 +0,0 @@
|
|||||||
// This file is part of Eigen, a lightweight C++ template library
|
|
||||||
// for linear algebra.
|
|
||||||
//
|
|
||||||
// Copyright (C) 2016 Benoit Steiner <benoit.steiner.goog@gmail.com>
|
|
||||||
//
|
|
||||||
// This Source Code Form is subject to the terms of the Mozilla
|
|
||||||
// Public License v. 2.0. If a copy of the MPL was not distributed
|
|
||||||
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
#ifndef EIGEN_THREADPOOL_MODULE_H
|
|
||||||
#define EIGEN_THREADPOOL_MODULE_H
|
|
||||||
|
|
||||||
#include "Core"
|
|
||||||
|
|
||||||
#include "src/Core/util/DisableStupidWarnings.h"
|
|
||||||
|
|
||||||
/** \defgroup ThreadPool_Module ThreadPool Module
|
|
||||||
*
|
|
||||||
* This module provides 2 threadpool implementations
|
|
||||||
* - a simple reference implementation
|
|
||||||
* - a faster non blocking implementation
|
|
||||||
*
|
|
||||||
* \code
|
|
||||||
* #include <Eigen/ThreadPool>
|
|
||||||
* \endcode
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <cstddef>
|
|
||||||
#include <cstring>
|
|
||||||
#include <ctime>
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <atomic>
|
|
||||||
#include <condition_variable>
|
|
||||||
#include <deque>
|
|
||||||
#include <mutex>
|
|
||||||
#include <thread>
|
|
||||||
#include <functional>
|
|
||||||
#include <memory>
|
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
// There are non-parenthesized calls to "max" in the <unordered_map> header,
|
|
||||||
// which trigger a check in test/main.h causing compilation to fail.
|
|
||||||
// We work around the check here by removing the check for max in
|
|
||||||
// the case where we have to emulate thread_local.
|
|
||||||
#ifdef max
|
|
||||||
#undef max
|
|
||||||
#endif
|
|
||||||
#include <unordered_map>
|
|
||||||
|
|
||||||
#include "src/Core/util/Meta.h"
|
|
||||||
#include "src/Core/util/MaxSizeVector.h"
|
|
||||||
|
|
||||||
#ifndef EIGEN_MUTEX
|
|
||||||
#define EIGEN_MUTEX std::mutex
|
|
||||||
#endif
|
|
||||||
#ifndef EIGEN_MUTEX_LOCK
|
|
||||||
#define EIGEN_MUTEX_LOCK std::unique_lock<std::mutex>
|
|
||||||
#endif
|
|
||||||
#ifndef EIGEN_CONDVAR
|
|
||||||
#define EIGEN_CONDVAR std::condition_variable
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// IWYU pragma: begin_exports
|
|
||||||
#include "src/ThreadPool/ThreadLocal.h"
|
|
||||||
#include "src/ThreadPool/ThreadYield.h"
|
|
||||||
#include "src/ThreadPool/ThreadCancel.h"
|
|
||||||
#include "src/ThreadPool/EventCount.h"
|
|
||||||
#include "src/ThreadPool/RunQueue.h"
|
|
||||||
#include "src/ThreadPool/ThreadPoolInterface.h"
|
|
||||||
#include "src/ThreadPool/ThreadEnvironment.h"
|
|
||||||
#include "src/ThreadPool/Barrier.h"
|
|
||||||
#include "src/ThreadPool/NonBlockingThreadPool.h"
|
|
||||||
#include "src/ThreadPool/CoreThreadPoolDevice.h"
|
|
||||||
#include "src/ThreadPool/ForkJoin.h"
|
|
||||||
// IWYU pragma: end_exports
|
|
||||||
|
|
||||||
#include "src/Core/util/ReenableStupidWarnings.h"
|
|
||||||
|
|
||||||
#endif // EIGEN_THREADPOOL_MODULE_H
|
|
||||||
@@ -17,26 +17,24 @@ extern "C" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** \ingroup Support_modules
|
/** \ingroup Support_modules
|
||||||
* \defgroup UmfPackSupport_Module UmfPackSupport module
|
* \defgroup UmfPackSupport_Module UmfPackSupport module
|
||||||
*
|
*
|
||||||
* This module provides an interface to the UmfPack library which is part of the <a
|
* This module provides an interface to the UmfPack library which is part of the <a href="http://www.suitesparse.com">suitesparse</a> package.
|
||||||
* href="http://www.suitesparse.com">suitesparse</a> package. It provides the following factorization class:
|
* It provides the following factorization class:
|
||||||
* - class UmfPackLU: a multifrontal sequential LU factorization.
|
* - class UmfPackLU: a multifrontal sequential LU factorization.
|
||||||
*
|
*
|
||||||
* \code
|
* \code
|
||||||
* #include <Eigen/UmfPackSupport>
|
* #include <Eigen/UmfPackSupport>
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* In order to use this module, the umfpack headers must be accessible from the include paths, and your binary must be
|
* In order to use this module, the umfpack headers must be accessible from the include paths, and your binary must be linked to the umfpack library and its dependencies.
|
||||||
* linked to the umfpack library and its dependencies. The dependencies depend on how umfpack has been compiled. For a
|
* The dependencies depend on how umfpack has been compiled.
|
||||||
* cmake based project, you can use our FindUmfPack.cmake module to help you in this task.
|
* For a cmake based project, you can use our FindUmfPack.cmake module to help you in this task.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// IWYU pragma: begin_exports
|
|
||||||
#include "src/UmfPackSupport/UmfPackSupport.h"
|
#include "src/UmfPackSupport/UmfPackSupport.h"
|
||||||
// IWYU pragma: end_exports
|
|
||||||
|
|
||||||
#include "src/Core/util/ReenableStupidWarnings.h"
|
#include "src/Core/util/ReenableStupidWarnings.h"
|
||||||
|
|
||||||
#endif // EIGEN_UMFPACKSUPPORT_MODULE_H
|
#endif // EIGEN_UMFPACKSUPPORT_MODULE_H
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
// This file is part of Eigen, a lightweight C++ template library
|
|
||||||
// for linear algebra.
|
|
||||||
//
|
|
||||||
// This Source Code Form is subject to the terms of the Mozilla
|
|
||||||
// Public License v. 2.0. If a copy of the MPL was not distributed
|
|
||||||
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
#ifndef EIGEN_VERSION_H
|
|
||||||
#define EIGEN_VERSION_H
|
|
||||||
|
|
||||||
// The "WORLD" version will forever remain "3" for the "Eigen3" library.
|
|
||||||
#define EIGEN_WORLD_VERSION 3
|
|
||||||
// As of Eigen3 5.0.0, we have moved to Semantic Versioning (semver.org).
|
|
||||||
#define EIGEN_MAJOR_VERSION 5
|
|
||||||
#define EIGEN_MINOR_VERSION 0
|
|
||||||
#define EIGEN_PATCH_VERSION 1
|
|
||||||
#define EIGEN_PRERELEASE_VERSION "dev"
|
|
||||||
#define EIGEN_BUILD_VERSION "master"
|
|
||||||
#define EIGEN_VERSION_STRING "5.0.1-dev+master"
|
|
||||||
|
|
||||||
#endif // EIGEN_VERSION_H
|
|
||||||
@@ -1,423 +0,0 @@
|
|||||||
#ifndef EIGEN_ACCELERATESUPPORT_H
|
|
||||||
#define EIGEN_ACCELERATESUPPORT_H
|
|
||||||
|
|
||||||
#include <Accelerate/Accelerate.h>
|
|
||||||
|
|
||||||
#include <Eigen/Sparse>
|
|
||||||
|
|
||||||
namespace Eigen {
|
|
||||||
|
|
||||||
template <typename MatrixType_, int UpLo_, SparseFactorization_t Solver_, bool EnforceSquare_>
|
|
||||||
class AccelerateImpl;
|
|
||||||
|
|
||||||
/** \ingroup AccelerateSupport_Module
|
|
||||||
* \typedef AccelerateLLT
|
|
||||||
* \brief A direct Cholesky (LLT) factorization and solver based on Accelerate
|
|
||||||
*
|
|
||||||
* \warning Only single and double precision real scalar types are supported by Accelerate
|
|
||||||
*
|
|
||||||
* \tparam MatrixType_ the type of the sparse matrix A, it must be a SparseMatrix<>
|
|
||||||
* \tparam UpLo_ additional information about the matrix structure. Default is Lower.
|
|
||||||
*
|
|
||||||
* \sa \ref TutorialSparseSolverConcept, class AccelerateLLT
|
|
||||||
*/
|
|
||||||
template <typename MatrixType, int UpLo = Lower>
|
|
||||||
using AccelerateLLT = AccelerateImpl<MatrixType, UpLo | Symmetric, SparseFactorizationCholesky, true>;
|
|
||||||
|
|
||||||
/** \ingroup AccelerateSupport_Module
|
|
||||||
* \typedef AccelerateLDLT
|
|
||||||
* \brief The default Cholesky (LDLT) factorization and solver based on Accelerate
|
|
||||||
*
|
|
||||||
* \warning Only single and double precision real scalar types are supported by Accelerate
|
|
||||||
*
|
|
||||||
* \tparam MatrixType_ the type of the sparse matrix A, it must be a SparseMatrix<>
|
|
||||||
* \tparam UpLo_ additional information about the matrix structure. Default is Lower.
|
|
||||||
*
|
|
||||||
* \sa \ref TutorialSparseSolverConcept, class AccelerateLDLT
|
|
||||||
*/
|
|
||||||
template <typename MatrixType, int UpLo = Lower>
|
|
||||||
using AccelerateLDLT = AccelerateImpl<MatrixType, UpLo | Symmetric, SparseFactorizationLDLT, true>;
|
|
||||||
|
|
||||||
/** \ingroup AccelerateSupport_Module
|
|
||||||
* \typedef AccelerateLDLTUnpivoted
|
|
||||||
* \brief A direct Cholesky-like LDL^T factorization and solver based on Accelerate with only 1x1 pivots and no pivoting
|
|
||||||
*
|
|
||||||
* \warning Only single and double precision real scalar types are supported by Accelerate
|
|
||||||
*
|
|
||||||
* \tparam MatrixType_ the type of the sparse matrix A, it must be a SparseMatrix<>
|
|
||||||
* \tparam UpLo_ additional information about the matrix structure. Default is Lower.
|
|
||||||
*
|
|
||||||
* \sa \ref TutorialSparseSolverConcept, class AccelerateLDLTUnpivoted
|
|
||||||
*/
|
|
||||||
template <typename MatrixType, int UpLo = Lower>
|
|
||||||
using AccelerateLDLTUnpivoted = AccelerateImpl<MatrixType, UpLo | Symmetric, SparseFactorizationLDLTUnpivoted, true>;
|
|
||||||
|
|
||||||
/** \ingroup AccelerateSupport_Module
|
|
||||||
* \typedef AccelerateLDLTSBK
|
|
||||||
* \brief A direct Cholesky (LDLT) factorization and solver based on Accelerate with Supernode Bunch-Kaufman and static
|
|
||||||
* pivoting
|
|
||||||
*
|
|
||||||
* \warning Only single and double precision real scalar types are supported by Accelerate
|
|
||||||
*
|
|
||||||
* \tparam MatrixType_ the type of the sparse matrix A, it must be a SparseMatrix<>
|
|
||||||
* \tparam UpLo_ additional information about the matrix structure. Default is Lower.
|
|
||||||
*
|
|
||||||
* \sa \ref TutorialSparseSolverConcept, class AccelerateLDLTSBK
|
|
||||||
*/
|
|
||||||
template <typename MatrixType, int UpLo = Lower>
|
|
||||||
using AccelerateLDLTSBK = AccelerateImpl<MatrixType, UpLo | Symmetric, SparseFactorizationLDLTSBK, true>;
|
|
||||||
|
|
||||||
/** \ingroup AccelerateSupport_Module
|
|
||||||
* \typedef AccelerateLDLTTPP
|
|
||||||
* \brief A direct Cholesky (LDLT) factorization and solver based on Accelerate with full threshold partial pivoting
|
|
||||||
*
|
|
||||||
* \warning Only single and double precision real scalar types are supported by Accelerate
|
|
||||||
*
|
|
||||||
* \tparam MatrixType_ the type of the sparse matrix A, it must be a SparseMatrix<>
|
|
||||||
* \tparam UpLo_ additional information about the matrix structure. Default is Lower.
|
|
||||||
*
|
|
||||||
* \sa \ref TutorialSparseSolverConcept, class AccelerateLDLTTPP
|
|
||||||
*/
|
|
||||||
template <typename MatrixType, int UpLo = Lower>
|
|
||||||
using AccelerateLDLTTPP = AccelerateImpl<MatrixType, UpLo | Symmetric, SparseFactorizationLDLTTPP, true>;
|
|
||||||
|
|
||||||
/** \ingroup AccelerateSupport_Module
|
|
||||||
* \typedef AccelerateQR
|
|
||||||
* \brief A QR factorization and solver based on Accelerate
|
|
||||||
*
|
|
||||||
* \warning Only single and double precision real scalar types are supported by Accelerate
|
|
||||||
*
|
|
||||||
* \tparam MatrixType_ the type of the sparse matrix A, it must be a SparseMatrix<>
|
|
||||||
*
|
|
||||||
* \sa \ref TutorialSparseSolverConcept, class AccelerateQR
|
|
||||||
*/
|
|
||||||
template <typename MatrixType>
|
|
||||||
using AccelerateQR = AccelerateImpl<MatrixType, 0, SparseFactorizationQR, false>;
|
|
||||||
|
|
||||||
/** \ingroup AccelerateSupport_Module
|
|
||||||
* \typedef AccelerateCholeskyAtA
|
|
||||||
* \brief A QR factorization and solver based on Accelerate without storing Q (equivalent to A^TA = R^T R)
|
|
||||||
*
|
|
||||||
* \warning Only single and double precision real scalar types are supported by Accelerate
|
|
||||||
*
|
|
||||||
* \tparam MatrixType_ the type of the sparse matrix A, it must be a SparseMatrix<>
|
|
||||||
*
|
|
||||||
* \sa \ref TutorialSparseSolverConcept, class AccelerateCholeskyAtA
|
|
||||||
*/
|
|
||||||
template <typename MatrixType>
|
|
||||||
using AccelerateCholeskyAtA = AccelerateImpl<MatrixType, 0, SparseFactorizationCholeskyAtA, false>;
|
|
||||||
|
|
||||||
namespace internal {
|
|
||||||
template <typename T>
|
|
||||||
struct AccelFactorizationDeleter {
|
|
||||||
void operator()(T* sym) const {
|
|
||||||
if (sym) {
|
|
||||||
SparseCleanup(*sym);
|
|
||||||
delete sym;
|
|
||||||
sym = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename DenseVecT, typename DenseMatT, typename SparseMatT, typename NumFactT>
|
|
||||||
struct SparseTypesTraitBase {
|
|
||||||
typedef DenseVecT AccelDenseVector;
|
|
||||||
typedef DenseMatT AccelDenseMatrix;
|
|
||||||
typedef SparseMatT AccelSparseMatrix;
|
|
||||||
|
|
||||||
typedef SparseOpaqueSymbolicFactorization SymbolicFactorization;
|
|
||||||
typedef NumFactT NumericFactorization;
|
|
||||||
|
|
||||||
typedef AccelFactorizationDeleter<SymbolicFactorization> SymbolicFactorizationDeleter;
|
|
||||||
typedef AccelFactorizationDeleter<NumericFactorization> NumericFactorizationDeleter;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Scalar>
|
|
||||||
struct SparseTypesTrait {};
|
|
||||||
|
|
||||||
template <>
|
|
||||||
struct SparseTypesTrait<double> : SparseTypesTraitBase<DenseVector_Double, DenseMatrix_Double, SparseMatrix_Double,
|
|
||||||
SparseOpaqueFactorization_Double> {};
|
|
||||||
|
|
||||||
template <>
|
|
||||||
struct SparseTypesTrait<float>
|
|
||||||
: SparseTypesTraitBase<DenseVector_Float, DenseMatrix_Float, SparseMatrix_Float, SparseOpaqueFactorization_Float> {
|
|
||||||
};
|
|
||||||
|
|
||||||
} // end namespace internal
|
|
||||||
|
|
||||||
template <typename MatrixType_, int UpLo_, SparseFactorization_t Solver_, bool EnforceSquare_>
|
|
||||||
class AccelerateImpl : public SparseSolverBase<AccelerateImpl<MatrixType_, UpLo_, Solver_, EnforceSquare_> > {
|
|
||||||
protected:
|
|
||||||
using Base = SparseSolverBase<AccelerateImpl>;
|
|
||||||
using Base::derived;
|
|
||||||
using Base::m_isInitialized;
|
|
||||||
|
|
||||||
public:
|
|
||||||
using Base::_solve_impl;
|
|
||||||
|
|
||||||
typedef MatrixType_ MatrixType;
|
|
||||||
typedef typename MatrixType::Scalar Scalar;
|
|
||||||
typedef typename MatrixType::StorageIndex StorageIndex;
|
|
||||||
enum { ColsAtCompileTime = Dynamic, MaxColsAtCompileTime = Dynamic };
|
|
||||||
enum { UpLo = UpLo_ };
|
|
||||||
|
|
||||||
using AccelDenseVector = typename internal::SparseTypesTrait<Scalar>::AccelDenseVector;
|
|
||||||
using AccelDenseMatrix = typename internal::SparseTypesTrait<Scalar>::AccelDenseMatrix;
|
|
||||||
using AccelSparseMatrix = typename internal::SparseTypesTrait<Scalar>::AccelSparseMatrix;
|
|
||||||
using SymbolicFactorization = typename internal::SparseTypesTrait<Scalar>::SymbolicFactorization;
|
|
||||||
using NumericFactorization = typename internal::SparseTypesTrait<Scalar>::NumericFactorization;
|
|
||||||
using SymbolicFactorizationDeleter = typename internal::SparseTypesTrait<Scalar>::SymbolicFactorizationDeleter;
|
|
||||||
using NumericFactorizationDeleter = typename internal::SparseTypesTrait<Scalar>::NumericFactorizationDeleter;
|
|
||||||
|
|
||||||
AccelerateImpl() {
|
|
||||||
m_isInitialized = false;
|
|
||||||
|
|
||||||
auto check_flag_set = [](int value, int flag) { return ((value & flag) == flag); };
|
|
||||||
|
|
||||||
if (check_flag_set(UpLo_, Symmetric)) {
|
|
||||||
m_sparseKind = SparseSymmetric;
|
|
||||||
m_triType = (UpLo_ & Lower) ? SparseLowerTriangle : SparseUpperTriangle;
|
|
||||||
} else if (check_flag_set(UpLo_, UnitLower)) {
|
|
||||||
m_sparseKind = SparseUnitTriangular;
|
|
||||||
m_triType = SparseLowerTriangle;
|
|
||||||
} else if (check_flag_set(UpLo_, UnitUpper)) {
|
|
||||||
m_sparseKind = SparseUnitTriangular;
|
|
||||||
m_triType = SparseUpperTriangle;
|
|
||||||
} else if (check_flag_set(UpLo_, StrictlyLower)) {
|
|
||||||
m_sparseKind = SparseTriangular;
|
|
||||||
m_triType = SparseLowerTriangle;
|
|
||||||
} else if (check_flag_set(UpLo_, StrictlyUpper)) {
|
|
||||||
m_sparseKind = SparseTriangular;
|
|
||||||
m_triType = SparseUpperTriangle;
|
|
||||||
} else if (check_flag_set(UpLo_, Lower)) {
|
|
||||||
m_sparseKind = SparseTriangular;
|
|
||||||
m_triType = SparseLowerTriangle;
|
|
||||||
} else if (check_flag_set(UpLo_, Upper)) {
|
|
||||||
m_sparseKind = SparseTriangular;
|
|
||||||
m_triType = SparseUpperTriangle;
|
|
||||||
} else {
|
|
||||||
m_sparseKind = SparseOrdinary;
|
|
||||||
m_triType = (UpLo_ & Lower) ? SparseLowerTriangle : SparseUpperTriangle;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_order = SparseOrderDefault;
|
|
||||||
}
|
|
||||||
|
|
||||||
explicit AccelerateImpl(const MatrixType& matrix) : AccelerateImpl() { compute(matrix); }
|
|
||||||
|
|
||||||
~AccelerateImpl() {}
|
|
||||||
|
|
||||||
inline Index cols() const { return m_nCols; }
|
|
||||||
inline Index rows() const { return m_nRows; }
|
|
||||||
|
|
||||||
ComputationInfo info() const {
|
|
||||||
eigen_assert(m_isInitialized && "Decomposition is not initialized.");
|
|
||||||
return m_info;
|
|
||||||
}
|
|
||||||
|
|
||||||
void analyzePattern(const MatrixType& matrix);
|
|
||||||
|
|
||||||
void factorize(const MatrixType& matrix);
|
|
||||||
|
|
||||||
void compute(const MatrixType& matrix);
|
|
||||||
|
|
||||||
template <typename Rhs, typename Dest>
|
|
||||||
void _solve_impl(const MatrixBase<Rhs>& b, MatrixBase<Dest>& dest) const;
|
|
||||||
|
|
||||||
/** Sets the ordering algorithm to use. */
|
|
||||||
void setOrder(SparseOrder_t order) { m_order = order; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
template <typename T>
|
|
||||||
void buildAccelSparseMatrix(const SparseMatrix<T>& a, AccelSparseMatrix& A, std::vector<long>& columnStarts) {
|
|
||||||
const Index nColumnsStarts = a.cols() + 1;
|
|
||||||
|
|
||||||
columnStarts.resize(nColumnsStarts);
|
|
||||||
|
|
||||||
for (Index i = 0; i < nColumnsStarts; i++) columnStarts[i] = a.outerIndexPtr()[i];
|
|
||||||
|
|
||||||
SparseAttributes_t attributes{};
|
|
||||||
attributes.transpose = false;
|
|
||||||
attributes.triangle = m_triType;
|
|
||||||
attributes.kind = m_sparseKind;
|
|
||||||
|
|
||||||
SparseMatrixStructure structure{};
|
|
||||||
structure.attributes = attributes;
|
|
||||||
structure.rowCount = static_cast<int>(a.rows());
|
|
||||||
structure.columnCount = static_cast<int>(a.cols());
|
|
||||||
structure.blockSize = 1;
|
|
||||||
structure.columnStarts = columnStarts.data();
|
|
||||||
structure.rowIndices = const_cast<int*>(a.innerIndexPtr());
|
|
||||||
|
|
||||||
A.structure = structure;
|
|
||||||
A.data = const_cast<T*>(a.valuePtr());
|
|
||||||
}
|
|
||||||
|
|
||||||
void doAnalysis(AccelSparseMatrix& A) {
|
|
||||||
m_numericFactorization.reset(nullptr);
|
|
||||||
|
|
||||||
SparseSymbolicFactorOptions opts{};
|
|
||||||
opts.control = SparseDefaultControl;
|
|
||||||
opts.orderMethod = m_order;
|
|
||||||
opts.order = nullptr;
|
|
||||||
opts.ignoreRowsAndColumns = nullptr;
|
|
||||||
opts.malloc = malloc;
|
|
||||||
opts.free = free;
|
|
||||||
opts.reportError = nullptr;
|
|
||||||
|
|
||||||
m_symbolicFactorization.reset(new SymbolicFactorization(SparseFactor(Solver_, A.structure, opts)));
|
|
||||||
|
|
||||||
SparseStatus_t status = m_symbolicFactorization->status;
|
|
||||||
|
|
||||||
updateInfoStatus(status);
|
|
||||||
|
|
||||||
if (status != SparseStatusOK) m_symbolicFactorization.reset(nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void doFactorization(AccelSparseMatrix& A) {
|
|
||||||
SparseStatus_t status = SparseStatusReleased;
|
|
||||||
|
|
||||||
if (m_symbolicFactorization) {
|
|
||||||
m_numericFactorization.reset(new NumericFactorization(SparseFactor(*m_symbolicFactorization, A)));
|
|
||||||
|
|
||||||
status = m_numericFactorization->status;
|
|
||||||
|
|
||||||
if (status != SparseStatusOK) m_numericFactorization.reset(nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
updateInfoStatus(status);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void updateInfoStatus(SparseStatus_t status) const {
|
|
||||||
switch (status) {
|
|
||||||
case SparseStatusOK:
|
|
||||||
m_info = Success;
|
|
||||||
break;
|
|
||||||
case SparseFactorizationFailed:
|
|
||||||
case SparseMatrixIsSingular:
|
|
||||||
m_info = NumericalIssue;
|
|
||||||
break;
|
|
||||||
case SparseInternalError:
|
|
||||||
case SparseParameterError:
|
|
||||||
case SparseStatusReleased:
|
|
||||||
default:
|
|
||||||
m_info = InvalidInput;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mutable ComputationInfo m_info;
|
|
||||||
Index m_nRows, m_nCols;
|
|
||||||
std::unique_ptr<SymbolicFactorization, SymbolicFactorizationDeleter> m_symbolicFactorization;
|
|
||||||
std::unique_ptr<NumericFactorization, NumericFactorizationDeleter> m_numericFactorization;
|
|
||||||
SparseKind_t m_sparseKind;
|
|
||||||
SparseTriangle_t m_triType;
|
|
||||||
SparseOrder_t m_order;
|
|
||||||
};
|
|
||||||
|
|
||||||
/** Computes the symbolic and numeric decomposition of matrix \a a */
|
|
||||||
template <typename MatrixType_, int UpLo_, SparseFactorization_t Solver_, bool EnforceSquare_>
|
|
||||||
void AccelerateImpl<MatrixType_, UpLo_, Solver_, EnforceSquare_>::compute(const MatrixType& a) {
|
|
||||||
if (EnforceSquare_) eigen_assert(a.rows() == a.cols());
|
|
||||||
|
|
||||||
m_nRows = a.rows();
|
|
||||||
m_nCols = a.cols();
|
|
||||||
|
|
||||||
AccelSparseMatrix A{};
|
|
||||||
std::vector<long> columnStarts;
|
|
||||||
|
|
||||||
buildAccelSparseMatrix(a, A, columnStarts);
|
|
||||||
|
|
||||||
doAnalysis(A);
|
|
||||||
|
|
||||||
if (m_symbolicFactorization) doFactorization(A);
|
|
||||||
|
|
||||||
m_isInitialized = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Performs a symbolic decomposition on the sparsity pattern of matrix \a a.
|
|
||||||
*
|
|
||||||
* This function is particularly useful when solving for several problems having the same structure.
|
|
||||||
*
|
|
||||||
* \sa factorize()
|
|
||||||
*/
|
|
||||||
template <typename MatrixType_, int UpLo_, SparseFactorization_t Solver_, bool EnforceSquare_>
|
|
||||||
void AccelerateImpl<MatrixType_, UpLo_, Solver_, EnforceSquare_>::analyzePattern(const MatrixType& a) {
|
|
||||||
if (EnforceSquare_) eigen_assert(a.rows() == a.cols());
|
|
||||||
|
|
||||||
m_nRows = a.rows();
|
|
||||||
m_nCols = a.cols();
|
|
||||||
|
|
||||||
AccelSparseMatrix A{};
|
|
||||||
std::vector<long> columnStarts;
|
|
||||||
|
|
||||||
buildAccelSparseMatrix(a, A, columnStarts);
|
|
||||||
|
|
||||||
doAnalysis(A);
|
|
||||||
|
|
||||||
m_isInitialized = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Performs a numeric decomposition of matrix \a a.
|
|
||||||
*
|
|
||||||
* The given matrix must have the same sparsity pattern as the matrix on which the symbolic decomposition has been
|
|
||||||
* performed.
|
|
||||||
*
|
|
||||||
* \sa analyzePattern()
|
|
||||||
*/
|
|
||||||
template <typename MatrixType_, int UpLo_, SparseFactorization_t Solver_, bool EnforceSquare_>
|
|
||||||
void AccelerateImpl<MatrixType_, UpLo_, Solver_, EnforceSquare_>::factorize(const MatrixType& a) {
|
|
||||||
eigen_assert(m_symbolicFactorization && "You must first call analyzePattern()");
|
|
||||||
eigen_assert(m_nRows == a.rows() && m_nCols == a.cols());
|
|
||||||
|
|
||||||
if (EnforceSquare_) eigen_assert(a.rows() == a.cols());
|
|
||||||
|
|
||||||
AccelSparseMatrix A{};
|
|
||||||
std::vector<long> columnStarts;
|
|
||||||
|
|
||||||
buildAccelSparseMatrix(a, A, columnStarts);
|
|
||||||
|
|
||||||
doFactorization(A);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename MatrixType_, int UpLo_, SparseFactorization_t Solver_, bool EnforceSquare_>
|
|
||||||
template <typename Rhs, typename Dest>
|
|
||||||
void AccelerateImpl<MatrixType_, UpLo_, Solver_, EnforceSquare_>::_solve_impl(const MatrixBase<Rhs>& b,
|
|
||||||
MatrixBase<Dest>& x) const {
|
|
||||||
if (!m_numericFactorization) {
|
|
||||||
m_info = InvalidInput;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
eigen_assert(m_nRows == b.rows());
|
|
||||||
eigen_assert(((b.cols() == 1) || b.outerStride() == b.rows()));
|
|
||||||
|
|
||||||
SparseStatus_t status = SparseStatusOK;
|
|
||||||
|
|
||||||
Scalar* b_ptr = const_cast<Scalar*>(b.derived().data());
|
|
||||||
Scalar* x_ptr = const_cast<Scalar*>(x.derived().data());
|
|
||||||
|
|
||||||
AccelDenseMatrix xmat{};
|
|
||||||
xmat.attributes = SparseAttributes_t();
|
|
||||||
xmat.columnCount = static_cast<int>(x.cols());
|
|
||||||
xmat.rowCount = static_cast<int>(x.rows());
|
|
||||||
xmat.columnStride = xmat.rowCount;
|
|
||||||
xmat.data = x_ptr;
|
|
||||||
|
|
||||||
AccelDenseMatrix bmat{};
|
|
||||||
bmat.attributes = SparseAttributes_t();
|
|
||||||
bmat.columnCount = static_cast<int>(b.cols());
|
|
||||||
bmat.rowCount = static_cast<int>(b.rows());
|
|
||||||
bmat.columnStride = bmat.rowCount;
|
|
||||||
bmat.data = b_ptr;
|
|
||||||
|
|
||||||
SparseSolve(*m_numericFactorization, bmat, xmat);
|
|
||||||
|
|
||||||
updateInfoStatus(status);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // end namespace Eigen
|
|
||||||
|
|
||||||
#endif // EIGEN_ACCELERATESUPPORT_H
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
#ifndef EIGEN_ACCELERATESUPPORT_MODULE_H
|
|
||||||
#error "Please include Eigen/AccelerateSupport instead of including headers inside the src directory directly."
|
|
||||||
#endif
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
#ifndef EIGEN_CHOLESKY_MODULE_H
|
|
||||||
#error "Please include Eigen/Cholesky instead of including headers inside the src directory directly."
|
|
||||||
#endif
|
|
||||||
@@ -13,326 +13,335 @@
|
|||||||
#ifndef EIGEN_LDLT_H
|
#ifndef EIGEN_LDLT_H
|
||||||
#define EIGEN_LDLT_H
|
#define EIGEN_LDLT_H
|
||||||
|
|
||||||
// IWYU pragma: private
|
|
||||||
#include "./InternalHeaderCheck.h"
|
|
||||||
|
|
||||||
namespace Eigen {
|
namespace Eigen {
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
template <typename MatrixType_, int UpLo_>
|
template<typename _MatrixType, int _UpLo> struct traits<LDLT<_MatrixType, _UpLo> >
|
||||||
struct traits<LDLT<MatrixType_, UpLo_> > : traits<MatrixType_> {
|
: traits<_MatrixType>
|
||||||
typedef MatrixXpr XprKind;
|
{
|
||||||
typedef SolverStorage StorageKind;
|
typedef MatrixXpr XprKind;
|
||||||
typedef int StorageIndex;
|
typedef SolverStorage StorageKind;
|
||||||
enum { Flags = 0 };
|
typedef int StorageIndex;
|
||||||
};
|
enum { Flags = 0 };
|
||||||
|
};
|
||||||
|
|
||||||
template <typename MatrixType, int UpLo>
|
template<typename MatrixType, int UpLo> struct LDLT_Traits;
|
||||||
struct LDLT_Traits;
|
|
||||||
|
|
||||||
// PositiveSemiDef means positive semi-definite and non-zero; same for NegativeSemiDef
|
// PositiveSemiDef means positive semi-definite and non-zero; same for NegativeSemiDef
|
||||||
enum SignMatrix { PositiveSemiDef, NegativeSemiDef, ZeroSign, Indefinite };
|
enum SignMatrix { PositiveSemiDef, NegativeSemiDef, ZeroSign, Indefinite };
|
||||||
} // namespace internal
|
}
|
||||||
|
|
||||||
/** \ingroup Cholesky_Module
|
/** \ingroup Cholesky_Module
|
||||||
*
|
*
|
||||||
* \class LDLT
|
* \class LDLT
|
||||||
*
|
*
|
||||||
* \brief Robust Cholesky decomposition of a matrix with pivoting
|
* \brief Robust Cholesky decomposition of a matrix with pivoting
|
||||||
*
|
*
|
||||||
* \tparam MatrixType_ the type of the matrix of which to compute the LDL^T Cholesky decomposition
|
* \tparam _MatrixType the type of the matrix of which to compute the LDL^T Cholesky decomposition
|
||||||
* \tparam UpLo_ the triangular part that will be used for the decomposition: Lower (default) or Upper.
|
* \tparam _UpLo the triangular part that will be used for the decompositon: Lower (default) or Upper.
|
||||||
* The other triangular part won't be read.
|
* The other triangular part won't be read.
|
||||||
*
|
*
|
||||||
* Perform a robust Cholesky decomposition of a positive semidefinite or negative semidefinite
|
* Perform a robust Cholesky decomposition of a positive semidefinite or negative semidefinite
|
||||||
* matrix \f$ A \f$ such that \f$ A = P^TLDL^*P \f$, where P is a permutation matrix, L
|
* matrix \f$ A \f$ such that \f$ A = P^TLDL^*P \f$, where P is a permutation matrix, L
|
||||||
* is lower triangular with a unit diagonal and D is a diagonal matrix.
|
* is lower triangular with a unit diagonal and D is a diagonal matrix.
|
||||||
*
|
*
|
||||||
* The decomposition uses pivoting to ensure stability, so that D will have
|
* The decomposition uses pivoting to ensure stability, so that D will have
|
||||||
* zeros in the bottom right rank(A) - n submatrix. Avoiding the square root
|
* zeros in the bottom right rank(A) - n submatrix. Avoiding the square root
|
||||||
* on D also stabilizes the computation.
|
* on D also stabilizes the computation.
|
||||||
*
|
*
|
||||||
* Remember that Cholesky decompositions are not rank-revealing. Also, do not use a Cholesky
|
* Remember that Cholesky decompositions are not rank-revealing. Also, do not use a Cholesky
|
||||||
* decomposition to determine whether a system of equations has a solution.
|
* decomposition to determine whether a system of equations has a solution.
|
||||||
*
|
*
|
||||||
* This class supports the \link InplaceDecomposition inplace decomposition \endlink mechanism.
|
* This class supports the \link InplaceDecomposition inplace decomposition \endlink mechanism.
|
||||||
*
|
*
|
||||||
* \sa MatrixBase::ldlt(), SelfAdjointView::ldlt(), class LLT
|
* \sa MatrixBase::ldlt(), SelfAdjointView::ldlt(), class LLT
|
||||||
*/
|
*/
|
||||||
template <typename MatrixType_, int UpLo_>
|
template<typename _MatrixType, int _UpLo> class LDLT
|
||||||
class LDLT : public SolverBase<LDLT<MatrixType_, UpLo_> > {
|
: public SolverBase<LDLT<_MatrixType, _UpLo> >
|
||||||
public:
|
{
|
||||||
typedef MatrixType_ MatrixType;
|
public:
|
||||||
typedef SolverBase<LDLT> Base;
|
typedef _MatrixType MatrixType;
|
||||||
friend class SolverBase<LDLT>;
|
typedef SolverBase<LDLT> Base;
|
||||||
|
friend class SolverBase<LDLT>;
|
||||||
|
|
||||||
EIGEN_GENERIC_PUBLIC_INTERFACE(LDLT)
|
EIGEN_GENERIC_PUBLIC_INTERFACE(LDLT)
|
||||||
enum {
|
enum {
|
||||||
MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
|
MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
|
||||||
MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime,
|
MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime,
|
||||||
UpLo = UpLo_
|
UpLo = _UpLo
|
||||||
};
|
};
|
||||||
typedef Matrix<Scalar, RowsAtCompileTime, 1, 0, MaxRowsAtCompileTime, 1> TmpMatrixType;
|
typedef Matrix<Scalar, RowsAtCompileTime, 1, 0, MaxRowsAtCompileTime, 1> TmpMatrixType;
|
||||||
|
|
||||||
typedef Transpositions<RowsAtCompileTime, MaxRowsAtCompileTime> TranspositionType;
|
typedef Transpositions<RowsAtCompileTime, MaxRowsAtCompileTime> TranspositionType;
|
||||||
typedef PermutationMatrix<RowsAtCompileTime, MaxRowsAtCompileTime> PermutationType;
|
typedef PermutationMatrix<RowsAtCompileTime, MaxRowsAtCompileTime> PermutationType;
|
||||||
|
|
||||||
typedef internal::LDLT_Traits<MatrixType, UpLo> Traits;
|
typedef internal::LDLT_Traits<MatrixType,UpLo> Traits;
|
||||||
|
|
||||||
/** \brief Default Constructor.
|
/** \brief Default Constructor.
|
||||||
*
|
*
|
||||||
* The default constructor is useful in cases in which the user intends to
|
* The default constructor is useful in cases in which the user intends to
|
||||||
* perform decompositions via LDLT::compute(const MatrixType&).
|
* perform decompositions via LDLT::compute(const MatrixType&).
|
||||||
*/
|
*/
|
||||||
LDLT()
|
LDLT()
|
||||||
: m_matrix(),
|
: m_matrix(),
|
||||||
m_l1_norm(0),
|
|
||||||
m_transpositions(),
|
m_transpositions(),
|
||||||
m_sign(internal::ZeroSign),
|
m_sign(internal::ZeroSign),
|
||||||
m_isInitialized(false),
|
m_isInitialized(false)
|
||||||
m_info(InvalidInput) {}
|
{}
|
||||||
|
|
||||||
/** \brief Default Constructor with memory preallocation
|
/** \brief Default Constructor with memory preallocation
|
||||||
*
|
*
|
||||||
* Like the default constructor but with preallocation of the internal data
|
* Like the default constructor but with preallocation of the internal data
|
||||||
* according to the specified problem \a size.
|
* according to the specified problem \a size.
|
||||||
* \sa LDLT()
|
* \sa LDLT()
|
||||||
*/
|
*/
|
||||||
explicit LDLT(Index size)
|
explicit LDLT(Index size)
|
||||||
: m_matrix(size, size),
|
: m_matrix(size, size),
|
||||||
m_l1_norm(0),
|
|
||||||
m_transpositions(size),
|
m_transpositions(size),
|
||||||
m_temporary(size),
|
m_temporary(size),
|
||||||
m_sign(internal::ZeroSign),
|
m_sign(internal::ZeroSign),
|
||||||
m_isInitialized(false),
|
m_isInitialized(false)
|
||||||
m_info(InvalidInput) {}
|
{}
|
||||||
|
|
||||||
/** \brief Constructor with decomposition
|
/** \brief Constructor with decomposition
|
||||||
*
|
*
|
||||||
* This calculates the decomposition for the input \a matrix.
|
* This calculates the decomposition for the input \a matrix.
|
||||||
*
|
*
|
||||||
* \sa LDLT(Index size)
|
* \sa LDLT(Index size)
|
||||||
*/
|
*/
|
||||||
template <typename InputType>
|
template<typename InputType>
|
||||||
explicit LDLT(const EigenBase<InputType>& matrix)
|
explicit LDLT(const EigenBase<InputType>& matrix)
|
||||||
: m_matrix(matrix.rows(), matrix.cols()),
|
: m_matrix(matrix.rows(), matrix.cols()),
|
||||||
m_l1_norm(0),
|
|
||||||
m_transpositions(matrix.rows()),
|
m_transpositions(matrix.rows()),
|
||||||
m_temporary(matrix.rows()),
|
m_temporary(matrix.rows()),
|
||||||
m_sign(internal::ZeroSign),
|
m_sign(internal::ZeroSign),
|
||||||
m_isInitialized(false),
|
m_isInitialized(false)
|
||||||
m_info(InvalidInput) {
|
{
|
||||||
compute(matrix.derived());
|
compute(matrix.derived());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \brief Constructs a LDLT factorization from a given matrix
|
/** \brief Constructs a LDLT factorization from a given matrix
|
||||||
*
|
*
|
||||||
* This overloaded constructor is provided for \link InplaceDecomposition inplace decomposition \endlink when \c
|
* This overloaded constructor is provided for \link InplaceDecomposition inplace decomposition \endlink when \c MatrixType is a Eigen::Ref.
|
||||||
* MatrixType is a Eigen::Ref.
|
*
|
||||||
*
|
* \sa LDLT(const EigenBase&)
|
||||||
* \sa LDLT(const EigenBase&)
|
*/
|
||||||
*/
|
template<typename InputType>
|
||||||
template <typename InputType>
|
explicit LDLT(EigenBase<InputType>& matrix)
|
||||||
explicit LDLT(EigenBase<InputType>& matrix)
|
|
||||||
: m_matrix(matrix.derived()),
|
: m_matrix(matrix.derived()),
|
||||||
m_l1_norm(0),
|
|
||||||
m_transpositions(matrix.rows()),
|
m_transpositions(matrix.rows()),
|
||||||
m_temporary(matrix.rows()),
|
m_temporary(matrix.rows()),
|
||||||
m_sign(internal::ZeroSign),
|
m_sign(internal::ZeroSign),
|
||||||
m_isInitialized(false),
|
m_isInitialized(false)
|
||||||
m_info(InvalidInput) {
|
{
|
||||||
compute(matrix.derived());
|
compute(matrix.derived());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Clear any existing decomposition
|
/** Clear any existing decomposition
|
||||||
* \sa rankUpdate(w,sigma)
|
* \sa rankUpdate(w,sigma)
|
||||||
*/
|
*/
|
||||||
void setZero() { m_isInitialized = false; }
|
void setZero()
|
||||||
|
{
|
||||||
|
m_isInitialized = false;
|
||||||
|
}
|
||||||
|
|
||||||
/** \returns a view of the upper triangular matrix U */
|
/** \returns a view of the upper triangular matrix U */
|
||||||
inline typename Traits::MatrixU matrixU() const {
|
inline typename Traits::MatrixU matrixU() const
|
||||||
eigen_assert(m_isInitialized && "LDLT is not initialized.");
|
{
|
||||||
return Traits::getU(m_matrix);
|
eigen_assert(m_isInitialized && "LDLT is not initialized.");
|
||||||
}
|
return Traits::getU(m_matrix);
|
||||||
|
}
|
||||||
|
|
||||||
/** \returns a view of the lower triangular matrix L */
|
/** \returns a view of the lower triangular matrix L */
|
||||||
inline typename Traits::MatrixL matrixL() const {
|
inline typename Traits::MatrixL matrixL() const
|
||||||
eigen_assert(m_isInitialized && "LDLT is not initialized.");
|
{
|
||||||
return Traits::getL(m_matrix);
|
eigen_assert(m_isInitialized && "LDLT is not initialized.");
|
||||||
}
|
return Traits::getL(m_matrix);
|
||||||
|
}
|
||||||
|
|
||||||
/** \returns the permutation matrix P as a transposition sequence.
|
/** \returns the permutation matrix P as a transposition sequence.
|
||||||
*/
|
*/
|
||||||
inline const TranspositionType& transpositionsP() const {
|
inline const TranspositionType& transpositionsP() const
|
||||||
eigen_assert(m_isInitialized && "LDLT is not initialized.");
|
{
|
||||||
return m_transpositions;
|
eigen_assert(m_isInitialized && "LDLT is not initialized.");
|
||||||
}
|
return m_transpositions;
|
||||||
|
}
|
||||||
|
|
||||||
/** \returns the coefficients of the diagonal matrix D */
|
/** \returns the coefficients of the diagonal matrix D */
|
||||||
inline Diagonal<const MatrixType> vectorD() const {
|
inline Diagonal<const MatrixType> vectorD() const
|
||||||
eigen_assert(m_isInitialized && "LDLT is not initialized.");
|
{
|
||||||
return m_matrix.diagonal();
|
eigen_assert(m_isInitialized && "LDLT is not initialized.");
|
||||||
}
|
return m_matrix.diagonal();
|
||||||
|
}
|
||||||
|
|
||||||
/** \returns true if the matrix is positive (semidefinite) */
|
/** \returns true if the matrix is positive (semidefinite) */
|
||||||
inline bool isPositive() const {
|
inline bool isPositive() const
|
||||||
eigen_assert(m_isInitialized && "LDLT is not initialized.");
|
{
|
||||||
return m_sign == internal::PositiveSemiDef || m_sign == internal::ZeroSign;
|
eigen_assert(m_isInitialized && "LDLT is not initialized.");
|
||||||
}
|
return m_sign == internal::PositiveSemiDef || m_sign == internal::ZeroSign;
|
||||||
|
}
|
||||||
|
|
||||||
/** \returns true if the matrix is negative (semidefinite) */
|
/** \returns true if the matrix is negative (semidefinite) */
|
||||||
inline bool isNegative(void) const {
|
inline bool isNegative(void) const
|
||||||
eigen_assert(m_isInitialized && "LDLT is not initialized.");
|
{
|
||||||
return m_sign == internal::NegativeSemiDef || m_sign == internal::ZeroSign;
|
eigen_assert(m_isInitialized && "LDLT is not initialized.");
|
||||||
}
|
return m_sign == internal::NegativeSemiDef || m_sign == internal::ZeroSign;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef EIGEN_PARSED_BY_DOXYGEN
|
#ifdef EIGEN_PARSED_BY_DOXYGEN
|
||||||
/** \returns a solution x of \f$ A x = b \f$ using the current decomposition of A.
|
/** \returns a solution x of \f$ A x = b \f$ using the current decomposition of A.
|
||||||
*
|
*
|
||||||
* This function also supports in-place solves using the syntax <tt>x = decompositionObject.solve(x)</tt> .
|
* This function also supports in-place solves using the syntax <tt>x = decompositionObject.solve(x)</tt> .
|
||||||
*
|
*
|
||||||
* \note_about_checking_solutions
|
* \note_about_checking_solutions
|
||||||
*
|
*
|
||||||
* More precisely, this method solves \f$ A x = b \f$ using the decomposition \f$ A = P^T L D L^* P \f$
|
* More precisely, this method solves \f$ A x = b \f$ using the decomposition \f$ A = P^T L D L^* P \f$
|
||||||
* by solving the systems \f$ P^T y_1 = b \f$, \f$ L y_2 = y_1 \f$, \f$ D y_3 = y_2 \f$,
|
* by solving the systems \f$ P^T y_1 = b \f$, \f$ L y_2 = y_1 \f$, \f$ D y_3 = y_2 \f$,
|
||||||
* \f$ L^* y_4 = y_3 \f$ and \f$ P x = y_4 \f$ in succession. If the matrix \f$ A \f$ is singular, then
|
* \f$ L^* y_4 = y_3 \f$ and \f$ P x = y_4 \f$ in succession. If the matrix \f$ A \f$ is singular, then
|
||||||
* \f$ D \f$ will also be singular (all the other matrices are invertible). In that case, the
|
* \f$ D \f$ will also be singular (all the other matrices are invertible). In that case, the
|
||||||
* least-square solution of \f$ D y_3 = y_2 \f$ is computed. This does not mean that this function
|
* least-square solution of \f$ D y_3 = y_2 \f$ is computed. This does not mean that this function
|
||||||
* computes the least-square solution of \f$ A x = b \f$ if \f$ A \f$ is singular.
|
* computes the least-square solution of \f$ A x = b \f$ if \f$ A \f$ is singular.
|
||||||
*
|
*
|
||||||
* \sa MatrixBase::ldlt(), SelfAdjointView::ldlt()
|
* \sa MatrixBase::ldlt(), SelfAdjointView::ldlt()
|
||||||
*/
|
*/
|
||||||
template <typename Rhs>
|
template<typename Rhs>
|
||||||
inline Solve<LDLT, Rhs> solve(const MatrixBase<Rhs>& b) const;
|
inline const Solve<LDLT, Rhs>
|
||||||
#endif
|
solve(const MatrixBase<Rhs>& b) const;
|
||||||
|
#endif
|
||||||
|
|
||||||
template <typename Derived>
|
template<typename Derived>
|
||||||
bool solveInPlace(MatrixBase<Derived>& bAndX) const;
|
bool solveInPlace(MatrixBase<Derived> &bAndX) const;
|
||||||
|
|
||||||
template <typename InputType>
|
template<typename InputType>
|
||||||
LDLT& compute(const EigenBase<InputType>& matrix);
|
LDLT& compute(const EigenBase<InputType>& matrix);
|
||||||
|
|
||||||
/** \returns an estimate of the reciprocal condition number of the matrix of
|
/** \returns an estimate of the reciprocal condition number of the matrix of
|
||||||
* which \c *this is the LDLT decomposition.
|
* which \c *this is the LDLT decomposition.
|
||||||
*/
|
*/
|
||||||
RealScalar rcond() const {
|
RealScalar rcond() const
|
||||||
eigen_assert(m_isInitialized && "LDLT is not initialized.");
|
{
|
||||||
return internal::rcond_estimate_helper(m_l1_norm, *this);
|
eigen_assert(m_isInitialized && "LDLT is not initialized.");
|
||||||
}
|
return internal::rcond_estimate_helper(m_l1_norm, *this);
|
||||||
|
}
|
||||||
|
|
||||||
template <typename Derived>
|
template <typename Derived>
|
||||||
LDLT& rankUpdate(const MatrixBase<Derived>& w, const RealScalar& alpha = 1);
|
LDLT& rankUpdate(const MatrixBase<Derived>& w, const RealScalar& alpha=1);
|
||||||
|
|
||||||
/** \returns the internal LDLT decomposition matrix
|
/** \returns the internal LDLT decomposition matrix
|
||||||
*
|
*
|
||||||
* TODO: document the storage layout.
|
* TODO: document the storage layout
|
||||||
*/
|
*/
|
||||||
inline const MatrixType& matrixLDLT() const {
|
inline const MatrixType& matrixLDLT() const
|
||||||
eigen_assert(m_isInitialized && "LDLT is not initialized.");
|
{
|
||||||
return m_matrix;
|
eigen_assert(m_isInitialized && "LDLT is not initialized.");
|
||||||
}
|
return m_matrix;
|
||||||
|
}
|
||||||
|
|
||||||
MatrixType reconstructedMatrix() const;
|
MatrixType reconstructedMatrix() const;
|
||||||
|
|
||||||
/** \returns the adjoint of \c *this, that is, a const reference to the decomposition itself as the underlying matrix
|
/** \returns the adjoint of \c *this, that is, a const reference to the decomposition itself as the underlying matrix is self-adjoint.
|
||||||
* is self-adjoint.
|
*
|
||||||
*
|
* This method is provided for compatibility with other matrix decompositions, thus enabling generic code such as:
|
||||||
* This method is provided for compatibility with other matrix decompositions, thus enabling generic code such as:
|
* \code x = decomposition.adjoint().solve(b) \endcode
|
||||||
* \code x = decomposition.adjoint().solve(b) \endcode
|
*/
|
||||||
*/
|
const LDLT& adjoint() const { return *this; };
|
||||||
const LDLT& adjoint() const { return *this; }
|
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC constexpr Index rows() const noexcept { return m_matrix.rows(); }
|
EIGEN_DEVICE_FUNC inline EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT { return m_matrix.rows(); }
|
||||||
EIGEN_DEVICE_FUNC constexpr Index cols() const noexcept { return m_matrix.cols(); }
|
EIGEN_DEVICE_FUNC inline EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT { return m_matrix.cols(); }
|
||||||
|
|
||||||
/** \brief Reports whether previous computation was successful.
|
/** \brief Reports whether previous computation was successful.
|
||||||
*
|
*
|
||||||
* \returns \c Success if computation was successful,
|
* \returns \c Success if computation was successful,
|
||||||
* \c NumericalIssue if the factorization failed because of a zero pivot.
|
* \c NumericalIssue if the factorization failed because of a zero pivot.
|
||||||
*/
|
*/
|
||||||
ComputationInfo info() const {
|
ComputationInfo info() const
|
||||||
eigen_assert(m_isInitialized && "LDLT is not initialized.");
|
{
|
||||||
return m_info;
|
eigen_assert(m_isInitialized && "LDLT is not initialized.");
|
||||||
}
|
return m_info;
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
||||||
template <typename RhsType, typename DstType>
|
template<typename RhsType, typename DstType>
|
||||||
void _solve_impl(const RhsType& rhs, DstType& dst) const;
|
void _solve_impl(const RhsType &rhs, DstType &dst) const;
|
||||||
|
|
||||||
template <bool Conjugate, typename RhsType, typename DstType>
|
template<bool Conjugate, typename RhsType, typename DstType>
|
||||||
void _solve_impl_transposed(const RhsType& rhs, DstType& dst) const;
|
void _solve_impl_transposed(const RhsType &rhs, DstType &dst) const;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar)
|
|
||||||
|
|
||||||
/** \internal
|
static void check_template_parameters()
|
||||||
* Used to compute and store the Cholesky decomposition A = L D L^* = U^* D U.
|
{
|
||||||
* The strict upper part is used during the decomposition, the strict lower
|
EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar);
|
||||||
* part correspond to the coefficients of L (its diagonal is equal to 1 and
|
}
|
||||||
* is not stored), and the diagonal entries correspond to D.
|
|
||||||
*/
|
/** \internal
|
||||||
MatrixType m_matrix;
|
* Used to compute and store the Cholesky decomposition A = L D L^* = U^* D U.
|
||||||
RealScalar m_l1_norm;
|
* The strict upper part is used during the decomposition, the strict lower
|
||||||
TranspositionType m_transpositions;
|
* part correspond to the coefficients of L (its diagonal is equal to 1 and
|
||||||
TmpMatrixType m_temporary;
|
* is not stored), and the diagonal entries correspond to D.
|
||||||
internal::SignMatrix m_sign;
|
*/
|
||||||
bool m_isInitialized;
|
MatrixType m_matrix;
|
||||||
ComputationInfo m_info;
|
RealScalar m_l1_norm;
|
||||||
|
TranspositionType m_transpositions;
|
||||||
|
TmpMatrixType m_temporary;
|
||||||
|
internal::SignMatrix m_sign;
|
||||||
|
bool m_isInitialized;
|
||||||
|
ComputationInfo m_info;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
template <int UpLo>
|
template<int UpLo> struct ldlt_inplace;
|
||||||
struct ldlt_inplace;
|
|
||||||
|
|
||||||
template <>
|
template<> struct ldlt_inplace<Lower>
|
||||||
struct ldlt_inplace<Lower> {
|
{
|
||||||
template <typename MatrixType, typename TranspositionType, typename Workspace>
|
template<typename MatrixType, typename TranspositionType, typename Workspace>
|
||||||
static bool unblocked(MatrixType& mat, TranspositionType& transpositions, Workspace& temp, SignMatrix& sign) {
|
static bool unblocked(MatrixType& mat, TranspositionType& transpositions, Workspace& temp, SignMatrix& sign)
|
||||||
|
{
|
||||||
using std::abs;
|
using std::abs;
|
||||||
typedef typename MatrixType::Scalar Scalar;
|
typedef typename MatrixType::Scalar Scalar;
|
||||||
typedef typename MatrixType::RealScalar RealScalar;
|
typedef typename MatrixType::RealScalar RealScalar;
|
||||||
typedef typename TranspositionType::StorageIndex IndexType;
|
typedef typename TranspositionType::StorageIndex IndexType;
|
||||||
eigen_assert(mat.rows() == mat.cols());
|
eigen_assert(mat.rows()==mat.cols());
|
||||||
const Index size = mat.rows();
|
const Index size = mat.rows();
|
||||||
bool found_zero_pivot = false;
|
bool found_zero_pivot = false;
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
|
|
||||||
if (size <= 1) {
|
if (size <= 1)
|
||||||
|
{
|
||||||
transpositions.setIdentity();
|
transpositions.setIdentity();
|
||||||
if (size == 0)
|
if(size==0) sign = ZeroSign;
|
||||||
sign = ZeroSign;
|
else if (numext::real(mat.coeff(0,0)) > static_cast<RealScalar>(0) ) sign = PositiveSemiDef;
|
||||||
else if (numext::real(mat.coeff(0, 0)) > static_cast<RealScalar>(0))
|
else if (numext::real(mat.coeff(0,0)) < static_cast<RealScalar>(0)) sign = NegativeSemiDef;
|
||||||
sign = PositiveSemiDef;
|
else sign = ZeroSign;
|
||||||
else if (numext::real(mat.coeff(0, 0)) < static_cast<RealScalar>(0))
|
|
||||||
sign = NegativeSemiDef;
|
|
||||||
else
|
|
||||||
sign = ZeroSign;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Index k = 0; k < size; ++k) {
|
for (Index k = 0; k < size; ++k)
|
||||||
|
{
|
||||||
// Find largest diagonal element
|
// Find largest diagonal element
|
||||||
Index index_of_biggest_in_corner;
|
Index index_of_biggest_in_corner;
|
||||||
mat.diagonal().tail(size - k).cwiseAbs().maxCoeff(&index_of_biggest_in_corner);
|
mat.diagonal().tail(size-k).cwiseAbs().maxCoeff(&index_of_biggest_in_corner);
|
||||||
index_of_biggest_in_corner += k;
|
index_of_biggest_in_corner += k;
|
||||||
|
|
||||||
transpositions.coeffRef(k) = IndexType(index_of_biggest_in_corner);
|
transpositions.coeffRef(k) = IndexType(index_of_biggest_in_corner);
|
||||||
if (k != index_of_biggest_in_corner) {
|
if(k != index_of_biggest_in_corner)
|
||||||
|
{
|
||||||
// apply the transposition while taking care to consider only
|
// apply the transposition while taking care to consider only
|
||||||
// the lower triangular part
|
// the lower triangular part
|
||||||
Index s = size - index_of_biggest_in_corner - 1; // trailing size after the biggest element
|
Index s = size-index_of_biggest_in_corner-1; // trailing size after the biggest element
|
||||||
mat.row(k).head(k).swap(mat.row(index_of_biggest_in_corner).head(k));
|
mat.row(k).head(k).swap(mat.row(index_of_biggest_in_corner).head(k));
|
||||||
mat.col(k).tail(s).swap(mat.col(index_of_biggest_in_corner).tail(s));
|
mat.col(k).tail(s).swap(mat.col(index_of_biggest_in_corner).tail(s));
|
||||||
std::swap(mat.coeffRef(k, k), mat.coeffRef(index_of_biggest_in_corner, index_of_biggest_in_corner));
|
std::swap(mat.coeffRef(k,k),mat.coeffRef(index_of_biggest_in_corner,index_of_biggest_in_corner));
|
||||||
for (Index i = k + 1; i < index_of_biggest_in_corner; ++i) {
|
for(Index i=k+1;i<index_of_biggest_in_corner;++i)
|
||||||
Scalar tmp = mat.coeffRef(i, k);
|
{
|
||||||
mat.coeffRef(i, k) = numext::conj(mat.coeffRef(index_of_biggest_in_corner, i));
|
Scalar tmp = mat.coeffRef(i,k);
|
||||||
mat.coeffRef(index_of_biggest_in_corner, i) = numext::conj(tmp);
|
mat.coeffRef(i,k) = numext::conj(mat.coeffRef(index_of_biggest_in_corner,i));
|
||||||
|
mat.coeffRef(index_of_biggest_in_corner,i) = numext::conj(tmp);
|
||||||
}
|
}
|
||||||
if (NumTraits<Scalar>::IsComplex)
|
if(NumTraits<Scalar>::IsComplex)
|
||||||
mat.coeffRef(index_of_biggest_in_corner, k) = numext::conj(mat.coeff(index_of_biggest_in_corner, k));
|
mat.coeffRef(index_of_biggest_in_corner,k) = numext::conj(mat.coeff(index_of_biggest_in_corner,k));
|
||||||
}
|
}
|
||||||
|
|
||||||
// partition the matrix:
|
// partition the matrix:
|
||||||
@@ -340,53 +349,53 @@ struct ldlt_inplace<Lower> {
|
|||||||
// lu = A10 | A11 | -
|
// lu = A10 | A11 | -
|
||||||
// A20 | A21 | A22
|
// A20 | A21 | A22
|
||||||
Index rs = size - k - 1;
|
Index rs = size - k - 1;
|
||||||
Block<MatrixType, Dynamic, 1> A21(mat, k + 1, k, rs, 1);
|
Block<MatrixType,Dynamic,1> A21(mat,k+1,k,rs,1);
|
||||||
Block<MatrixType, 1, Dynamic> A10(mat, k, 0, 1, k);
|
Block<MatrixType,1,Dynamic> A10(mat,k,0,1,k);
|
||||||
Block<MatrixType, Dynamic, Dynamic> A20(mat, k + 1, 0, rs, k);
|
Block<MatrixType,Dynamic,Dynamic> A20(mat,k+1,0,rs,k);
|
||||||
|
|
||||||
if (k > 0) {
|
if(k>0)
|
||||||
|
{
|
||||||
temp.head(k) = mat.diagonal().real().head(k).asDiagonal() * A10.adjoint();
|
temp.head(k) = mat.diagonal().real().head(k).asDiagonal() * A10.adjoint();
|
||||||
mat.coeffRef(k, k) -= (A10 * temp.head(k)).value();
|
mat.coeffRef(k,k) -= (A10 * temp.head(k)).value();
|
||||||
if (rs > 0) A21.noalias() -= A20 * temp.head(k);
|
if(rs>0)
|
||||||
|
A21.noalias() -= A20 * temp.head(k);
|
||||||
}
|
}
|
||||||
|
|
||||||
// In some previous versions of Eigen (e.g., 3.2.1), the scaling was omitted if the pivot
|
// In some previous versions of Eigen (e.g., 3.2.1), the scaling was omitted if the pivot
|
||||||
// was smaller than the cutoff value. However, since LDLT is not rank-revealing
|
// was smaller than the cutoff value. However, since LDLT is not rank-revealing
|
||||||
// we should only make sure that we do not introduce INF or NaN values.
|
// we should only make sure that we do not introduce INF or NaN values.
|
||||||
// Remark that LAPACK also uses 0 as the cutoff value.
|
// Remark that LAPACK also uses 0 as the cutoff value.
|
||||||
RealScalar realAkk = numext::real(mat.coeffRef(k, k));
|
RealScalar realAkk = numext::real(mat.coeffRef(k,k));
|
||||||
bool pivot_is_valid = (abs(realAkk) > RealScalar(0));
|
bool pivot_is_valid = (abs(realAkk) > RealScalar(0));
|
||||||
|
|
||||||
if (k == 0 && !pivot_is_valid) {
|
if(k==0 && !pivot_is_valid)
|
||||||
|
{
|
||||||
// The entire diagonal is zero, there is nothing more to do
|
// The entire diagonal is zero, there is nothing more to do
|
||||||
// except filling the transpositions, and checking whether the matrix is zero.
|
// except filling the transpositions, and checking whether the matrix is zero.
|
||||||
sign = ZeroSign;
|
sign = ZeroSign;
|
||||||
for (Index j = 0; j < size; ++j) {
|
for(Index j = 0; j<size; ++j)
|
||||||
|
{
|
||||||
transpositions.coeffRef(j) = IndexType(j);
|
transpositions.coeffRef(j) = IndexType(j);
|
||||||
ret = ret && (mat.col(j).tail(size - j - 1).array() == Scalar(0)).all();
|
ret = ret && (mat.col(j).tail(size-j-1).array()==Scalar(0)).all();
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((rs > 0) && pivot_is_valid)
|
if((rs>0) && pivot_is_valid)
|
||||||
A21 /= realAkk;
|
A21 /= realAkk;
|
||||||
else if (rs > 0)
|
else if(rs>0)
|
||||||
ret = ret && (A21.array() == Scalar(0)).all();
|
ret = ret && (A21.array()==Scalar(0)).all();
|
||||||
|
|
||||||
if (found_zero_pivot && pivot_is_valid)
|
if(found_zero_pivot && pivot_is_valid) ret = false; // factorization failed
|
||||||
ret = false; // factorization failed
|
else if(!pivot_is_valid) found_zero_pivot = true;
|
||||||
else if (!pivot_is_valid)
|
|
||||||
found_zero_pivot = true;
|
|
||||||
|
|
||||||
if (sign == PositiveSemiDef) {
|
if (sign == PositiveSemiDef) {
|
||||||
if (realAkk < static_cast<RealScalar>(0)) sign = Indefinite;
|
if (realAkk < static_cast<RealScalar>(0)) sign = Indefinite;
|
||||||
} else if (sign == NegativeSemiDef) {
|
} else if (sign == NegativeSemiDef) {
|
||||||
if (realAkk > static_cast<RealScalar>(0)) sign = Indefinite;
|
if (realAkk > static_cast<RealScalar>(0)) sign = Indefinite;
|
||||||
} else if (sign == ZeroSign) {
|
} else if (sign == ZeroSign) {
|
||||||
if (realAkk > static_cast<RealScalar>(0))
|
if (realAkk > static_cast<RealScalar>(0)) sign = PositiveSemiDef;
|
||||||
sign = PositiveSemiDef;
|
else if (realAkk < static_cast<RealScalar>(0)) sign = NegativeSemiDef;
|
||||||
else if (realAkk < static_cast<RealScalar>(0))
|
|
||||||
sign = NegativeSemiDef;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -400,107 +409,113 @@ struct ldlt_inplace<Lower> {
|
|||||||
// original matrix is not of full rank.
|
// original matrix is not of full rank.
|
||||||
// Here only rank-1 updates are implemented, to reduce the
|
// Here only rank-1 updates are implemented, to reduce the
|
||||||
// requirement for intermediate storage and improve accuracy
|
// requirement for intermediate storage and improve accuracy
|
||||||
template <typename MatrixType, typename WDerived>
|
template<typename MatrixType, typename WDerived>
|
||||||
static bool updateInPlace(MatrixType& mat, MatrixBase<WDerived>& w,
|
static bool updateInPlace(MatrixType& mat, MatrixBase<WDerived>& w, const typename MatrixType::RealScalar& sigma=1)
|
||||||
const typename MatrixType::RealScalar& sigma = 1) {
|
{
|
||||||
using numext::isfinite;
|
using numext::isfinite;
|
||||||
typedef typename MatrixType::Scalar Scalar;
|
typedef typename MatrixType::Scalar Scalar;
|
||||||
typedef typename MatrixType::RealScalar RealScalar;
|
typedef typename MatrixType::RealScalar RealScalar;
|
||||||
|
|
||||||
const Index size = mat.rows();
|
const Index size = mat.rows();
|
||||||
eigen_assert(mat.cols() == size && w.size() == size);
|
eigen_assert(mat.cols() == size && w.size()==size);
|
||||||
|
|
||||||
RealScalar alpha = 1;
|
RealScalar alpha = 1;
|
||||||
|
|
||||||
// Apply the update
|
// Apply the update
|
||||||
for (Index j = 0; j < size; j++) {
|
for (Index j = 0; j < size; j++)
|
||||||
|
{
|
||||||
// Check for termination due to an original decomposition of low-rank
|
// Check for termination due to an original decomposition of low-rank
|
||||||
if (!(isfinite)(alpha)) break;
|
if (!(isfinite)(alpha))
|
||||||
|
break;
|
||||||
|
|
||||||
// Update the diagonal terms
|
// Update the diagonal terms
|
||||||
RealScalar dj = numext::real(mat.coeff(j, j));
|
RealScalar dj = numext::real(mat.coeff(j,j));
|
||||||
Scalar wj = w.coeff(j);
|
Scalar wj = w.coeff(j);
|
||||||
RealScalar swj2 = sigma * numext::abs2(wj);
|
RealScalar swj2 = sigma*numext::abs2(wj);
|
||||||
RealScalar gamma = dj * alpha + swj2;
|
RealScalar gamma = dj*alpha + swj2;
|
||||||
|
|
||||||
|
mat.coeffRef(j,j) += swj2/alpha;
|
||||||
|
alpha += swj2/dj;
|
||||||
|
|
||||||
mat.coeffRef(j, j) += swj2 / alpha;
|
|
||||||
alpha += swj2 / dj;
|
|
||||||
|
|
||||||
// Update the terms of L
|
// Update the terms of L
|
||||||
Index rs = size - j - 1;
|
Index rs = size-j-1;
|
||||||
w.tail(rs) -= wj * mat.col(j).tail(rs);
|
w.tail(rs) -= wj * mat.col(j).tail(rs);
|
||||||
if (!numext::is_exactly_zero(gamma)) mat.col(j).tail(rs) += (sigma * numext::conj(wj) / gamma) * w.tail(rs);
|
if(gamma != 0)
|
||||||
|
mat.col(j).tail(rs) += (sigma*numext::conj(wj)/gamma)*w.tail(rs);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename MatrixType, typename TranspositionType, typename Workspace, typename WType>
|
template<typename MatrixType, typename TranspositionType, typename Workspace, typename WType>
|
||||||
static bool update(MatrixType& mat, const TranspositionType& transpositions, Workspace& tmp, const WType& w,
|
static bool update(MatrixType& mat, const TranspositionType& transpositions, Workspace& tmp, const WType& w, const typename MatrixType::RealScalar& sigma=1)
|
||||||
const typename MatrixType::RealScalar& sigma = 1) {
|
{
|
||||||
// Apply the permutation to the input w
|
// Apply the permutation to the input w
|
||||||
tmp = transpositions * w;
|
tmp = transpositions * w;
|
||||||
|
|
||||||
return ldlt_inplace<Lower>::updateInPlace(mat, tmp, sigma);
|
return ldlt_inplace<Lower>::updateInPlace(mat,tmp,sigma);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template<> struct ldlt_inplace<Upper>
|
||||||
struct ldlt_inplace<Upper> {
|
{
|
||||||
template <typename MatrixType, typename TranspositionType, typename Workspace>
|
template<typename MatrixType, typename TranspositionType, typename Workspace>
|
||||||
static EIGEN_STRONG_INLINE bool unblocked(MatrixType& mat, TranspositionType& transpositions, Workspace& temp,
|
static EIGEN_STRONG_INLINE bool unblocked(MatrixType& mat, TranspositionType& transpositions, Workspace& temp, SignMatrix& sign)
|
||||||
SignMatrix& sign) {
|
{
|
||||||
Transpose<MatrixType> matt(mat);
|
Transpose<MatrixType> matt(mat);
|
||||||
return ldlt_inplace<Lower>::unblocked(matt, transpositions, temp, sign);
|
return ldlt_inplace<Lower>::unblocked(matt, transpositions, temp, sign);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename MatrixType, typename TranspositionType, typename Workspace, typename WType>
|
template<typename MatrixType, typename TranspositionType, typename Workspace, typename WType>
|
||||||
static EIGEN_STRONG_INLINE bool update(MatrixType& mat, TranspositionType& transpositions, Workspace& tmp, WType& w,
|
static EIGEN_STRONG_INLINE bool update(MatrixType& mat, TranspositionType& transpositions, Workspace& tmp, WType& w, const typename MatrixType::RealScalar& sigma=1)
|
||||||
const typename MatrixType::RealScalar& sigma = 1) {
|
{
|
||||||
Transpose<MatrixType> matt(mat);
|
Transpose<MatrixType> matt(mat);
|
||||||
return ldlt_inplace<Lower>::update(matt, transpositions, tmp, w.conjugate(), sigma);
|
return ldlt_inplace<Lower>::update(matt, transpositions, tmp, w.conjugate(), sigma);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename MatrixType>
|
template<typename MatrixType> struct LDLT_Traits<MatrixType,Lower>
|
||||||
struct LDLT_Traits<MatrixType, Lower> {
|
{
|
||||||
typedef const TriangularView<const MatrixType, UnitLower> MatrixL;
|
typedef const TriangularView<const MatrixType, UnitLower> MatrixL;
|
||||||
typedef const TriangularView<const typename MatrixType::AdjointReturnType, UnitUpper> MatrixU;
|
typedef const TriangularView<const typename MatrixType::AdjointReturnType, UnitUpper> MatrixU;
|
||||||
static inline MatrixL getL(const MatrixType& m) { return MatrixL(m); }
|
static inline MatrixL getL(const MatrixType& m) { return MatrixL(m); }
|
||||||
static inline MatrixU getU(const MatrixType& m) { return MatrixU(m.adjoint()); }
|
static inline MatrixU getU(const MatrixType& m) { return MatrixU(m.adjoint()); }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename MatrixType>
|
template<typename MatrixType> struct LDLT_Traits<MatrixType,Upper>
|
||||||
struct LDLT_Traits<MatrixType, Upper> {
|
{
|
||||||
typedef const TriangularView<const typename MatrixType::AdjointReturnType, UnitLower> MatrixL;
|
typedef const TriangularView<const typename MatrixType::AdjointReturnType, UnitLower> MatrixL;
|
||||||
typedef const TriangularView<const MatrixType, UnitUpper> MatrixU;
|
typedef const TriangularView<const MatrixType, UnitUpper> MatrixU;
|
||||||
static inline MatrixL getL(const MatrixType& m) { return MatrixL(m.adjoint()); }
|
static inline MatrixL getL(const MatrixType& m) { return MatrixL(m.adjoint()); }
|
||||||
static inline MatrixU getU(const MatrixType& m) { return MatrixU(m); }
|
static inline MatrixU getU(const MatrixType& m) { return MatrixU(m); }
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace internal
|
} // end namespace internal
|
||||||
|
|
||||||
/** Compute / recompute the LDLT decomposition A = L D L^* = U^* D U of \a matrix
|
/** Compute / recompute the LDLT decomposition A = L D L^* = U^* D U of \a matrix
|
||||||
*/
|
*/
|
||||||
template <typename MatrixType, int UpLo_>
|
template<typename MatrixType, int _UpLo>
|
||||||
template <typename InputType>
|
template<typename InputType>
|
||||||
LDLT<MatrixType, UpLo_>& LDLT<MatrixType, UpLo_>::compute(const EigenBase<InputType>& a) {
|
LDLT<MatrixType,_UpLo>& LDLT<MatrixType,_UpLo>::compute(const EigenBase<InputType>& a)
|
||||||
eigen_assert(a.rows() == a.cols());
|
{
|
||||||
|
check_template_parameters();
|
||||||
|
|
||||||
|
eigen_assert(a.rows()==a.cols());
|
||||||
const Index size = a.rows();
|
const Index size = a.rows();
|
||||||
|
|
||||||
m_matrix = a.derived();
|
m_matrix = a.derived();
|
||||||
|
|
||||||
// Compute matrix L1 norm = max abs column sum.
|
// Compute matrix L1 norm = max abs column sum.
|
||||||
m_l1_norm = RealScalar(0);
|
m_l1_norm = RealScalar(0);
|
||||||
// TODO: move this code to SelfAdjointView
|
// TODO move this code to SelfAdjointView
|
||||||
for (Index col = 0; col < size; ++col) {
|
for (Index col = 0; col < size; ++col) {
|
||||||
RealScalar abs_col_sum;
|
RealScalar abs_col_sum;
|
||||||
if (UpLo_ == Lower)
|
if (_UpLo == Lower)
|
||||||
abs_col_sum =
|
abs_col_sum = m_matrix.col(col).tail(size - col).template lpNorm<1>() + m_matrix.row(col).head(col).template lpNorm<1>();
|
||||||
m_matrix.col(col).tail(size - col).template lpNorm<1>() + m_matrix.row(col).head(col).template lpNorm<1>();
|
|
||||||
else
|
else
|
||||||
abs_col_sum =
|
abs_col_sum = m_matrix.col(col).head(col).template lpNorm<1>() + m_matrix.row(col).tail(size - col).template lpNorm<1>();
|
||||||
m_matrix.col(col).head(col).template lpNorm<1>() + m_matrix.row(col).tail(size - col).template lpNorm<1>();
|
if (abs_col_sum > m_l1_norm)
|
||||||
if (abs_col_sum > m_l1_norm) m_l1_norm = abs_col_sum;
|
m_l1_norm = abs_col_sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_transpositions.resize(size);
|
m_transpositions.resize(size);
|
||||||
@@ -508,8 +523,7 @@ LDLT<MatrixType, UpLo_>& LDLT<MatrixType, UpLo_>::compute(const EigenBase<InputT
|
|||||||
m_temporary.resize(size);
|
m_temporary.resize(size);
|
||||||
m_sign = internal::ZeroSign;
|
m_sign = internal::ZeroSign;
|
||||||
|
|
||||||
m_info = internal::ldlt_inplace<UpLo>::unblocked(m_matrix, m_transpositions, m_temporary, m_sign) ? Success
|
m_info = internal::ldlt_inplace<UpLo>::unblocked(m_matrix, m_transpositions, m_temporary, m_sign) ? Success : NumericalIssue;
|
||||||
: NumericalIssue;
|
|
||||||
|
|
||||||
m_isInitialized = true;
|
m_isInitialized = true;
|
||||||
return *this;
|
return *this;
|
||||||
@@ -517,24 +531,28 @@ LDLT<MatrixType, UpLo_>& LDLT<MatrixType, UpLo_>::compute(const EigenBase<InputT
|
|||||||
|
|
||||||
/** Update the LDLT decomposition: given A = L D L^T, efficiently compute the decomposition of A + sigma w w^T.
|
/** Update the LDLT decomposition: given A = L D L^T, efficiently compute the decomposition of A + sigma w w^T.
|
||||||
* \param w a vector to be incorporated into the decomposition.
|
* \param w a vector to be incorporated into the decomposition.
|
||||||
* \param sigma a scalar, +1 for updates and -1 for "downdates," which correspond to removing previously-added column
|
* \param sigma a scalar, +1 for updates and -1 for "downdates," which correspond to removing previously-added column vectors. Optional; default value is +1.
|
||||||
* vectors. Optional; default value is +1. \sa setZero()
|
* \sa setZero()
|
||||||
*/
|
*/
|
||||||
template <typename MatrixType, int UpLo_>
|
template<typename MatrixType, int _UpLo>
|
||||||
template <typename Derived>
|
template<typename Derived>
|
||||||
LDLT<MatrixType, UpLo_>& LDLT<MatrixType, UpLo_>::rankUpdate(
|
LDLT<MatrixType,_UpLo>& LDLT<MatrixType,_UpLo>::rankUpdate(const MatrixBase<Derived>& w, const typename LDLT<MatrixType,_UpLo>::RealScalar& sigma)
|
||||||
const MatrixBase<Derived>& w, const typename LDLT<MatrixType, UpLo_>::RealScalar& sigma) {
|
{
|
||||||
typedef typename TranspositionType::StorageIndex IndexType;
|
typedef typename TranspositionType::StorageIndex IndexType;
|
||||||
const Index size = w.rows();
|
const Index size = w.rows();
|
||||||
if (m_isInitialized) {
|
if (m_isInitialized)
|
||||||
eigen_assert(m_matrix.rows() == size);
|
{
|
||||||
} else {
|
eigen_assert(m_matrix.rows()==size);
|
||||||
m_matrix.resize(size, size);
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_matrix.resize(size,size);
|
||||||
m_matrix.setZero();
|
m_matrix.setZero();
|
||||||
m_transpositions.resize(size);
|
m_transpositions.resize(size);
|
||||||
for (Index i = 0; i < size; i++) m_transpositions.coeffRef(i) = IndexType(i);
|
for (Index i = 0; i < size; i++)
|
||||||
|
m_transpositions.coeffRef(i) = IndexType(i);
|
||||||
m_temporary.resize(size);
|
m_temporary.resize(size);
|
||||||
m_sign = sigma >= 0 ? internal::PositiveSemiDef : internal::NegativeSemiDef;
|
m_sign = sigma>=0 ? internal::PositiveSemiDef : internal::NegativeSemiDef;
|
||||||
m_isInitialized = true;
|
m_isInitialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -544,15 +562,17 @@ LDLT<MatrixType, UpLo_>& LDLT<MatrixType, UpLo_>::rankUpdate(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
||||||
template <typename MatrixType_, int UpLo_>
|
template<typename _MatrixType, int _UpLo>
|
||||||
template <typename RhsType, typename DstType>
|
template<typename RhsType, typename DstType>
|
||||||
void LDLT<MatrixType_, UpLo_>::_solve_impl(const RhsType& rhs, DstType& dst) const {
|
void LDLT<_MatrixType,_UpLo>::_solve_impl(const RhsType &rhs, DstType &dst) const
|
||||||
|
{
|
||||||
_solve_impl_transposed<true>(rhs, dst);
|
_solve_impl_transposed<true>(rhs, dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename MatrixType_, int UpLo_>
|
template<typename _MatrixType,int _UpLo>
|
||||||
template <bool Conjugate, typename RhsType, typename DstType>
|
template<bool Conjugate, typename RhsType, typename DstType>
|
||||||
void LDLT<MatrixType_, UpLo_>::_solve_impl_transposed(const RhsType& rhs, DstType& dst) const {
|
void LDLT<_MatrixType,_UpLo>::_solve_impl_transposed(const RhsType &rhs, DstType &dst) const
|
||||||
|
{
|
||||||
// dst = P b
|
// dst = P b
|
||||||
dst = m_transpositions * rhs;
|
dst = m_transpositions * rhs;
|
||||||
|
|
||||||
@@ -567,13 +587,15 @@ void LDLT<MatrixType_, UpLo_>::_solve_impl_transposed(const RhsType& rhs, DstTyp
|
|||||||
const typename Diagonal<const MatrixType>::RealReturnType vecD(vectorD());
|
const typename Diagonal<const MatrixType>::RealReturnType vecD(vectorD());
|
||||||
// In some previous versions, tolerance was set to the max of 1/highest (or rather numeric_limits::min())
|
// In some previous versions, tolerance was set to the max of 1/highest (or rather numeric_limits::min())
|
||||||
// and the maximal diagonal entry * epsilon as motivated by LAPACK's xGELSS:
|
// and the maximal diagonal entry * epsilon as motivated by LAPACK's xGELSS:
|
||||||
// RealScalar tolerance = numext::maxi(vecD.array().abs().maxCoeff() * NumTraits<RealScalar>::epsilon(),RealScalar(1)
|
// RealScalar tolerance = numext::maxi(vecD.array().abs().maxCoeff() * NumTraits<RealScalar>::epsilon(),RealScalar(1) / NumTraits<RealScalar>::highest());
|
||||||
// / NumTraits<RealScalar>::highest()); However, LDLT is not rank revealing, and so adjusting the tolerance wrt to the
|
// However, LDLT is not rank revealing, and so adjusting the tolerance wrt to the highest
|
||||||
// highest diagonal element is not well justified and leads to numerical issues in some cases. Moreover, Lapack's
|
// diagonal element is not well justified and leads to numerical issues in some cases.
|
||||||
// xSYTRS routines use 0 for the tolerance. Using numeric_limits::min() gives us more robustness to denormals.
|
// Moreover, Lapack's xSYTRS routines use 0 for the tolerance.
|
||||||
|
// Using numeric_limits::min() gives us more robustness to denormals.
|
||||||
RealScalar tolerance = (std::numeric_limits<RealScalar>::min)();
|
RealScalar tolerance = (std::numeric_limits<RealScalar>::min)();
|
||||||
for (Index i = 0; i < vecD.size(); ++i) {
|
for (Index i = 0; i < vecD.size(); ++i)
|
||||||
if (abs(vecD(i)) > tolerance)
|
{
|
||||||
|
if(abs(vecD(i)) > tolerance)
|
||||||
dst.row(i) /= vecD(i);
|
dst.row(i) /= vecD(i);
|
||||||
else
|
else
|
||||||
dst.row(i).setZero();
|
dst.row(i).setZero();
|
||||||
@@ -590,21 +612,22 @@ void LDLT<MatrixType_, UpLo_>::_solve_impl_transposed(const RhsType& rhs, DstTyp
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** \internal use x = ldlt_object.solve(x);
|
/** \internal use x = ldlt_object.solve(x);
|
||||||
*
|
*
|
||||||
* This is the \em in-place version of solve().
|
* This is the \em in-place version of solve().
|
||||||
*
|
*
|
||||||
* \param bAndX represents both the right-hand side matrix b and result x.
|
* \param bAndX represents both the right-hand side matrix b and result x.
|
||||||
*
|
*
|
||||||
* \returns true always! If you need to check for existence of solutions, use another decomposition like LU, QR, or SVD.
|
* \returns true always! If you need to check for existence of solutions, use another decomposition like LU, QR, or SVD.
|
||||||
*
|
*
|
||||||
* This version avoids a copy when the right hand side matrix b is not
|
* This version avoids a copy when the right hand side matrix b is not
|
||||||
* needed anymore.
|
* needed anymore.
|
||||||
*
|
*
|
||||||
* \sa LDLT::solve(), MatrixBase::ldlt()
|
* \sa LDLT::solve(), MatrixBase::ldlt()
|
||||||
*/
|
*/
|
||||||
template <typename MatrixType, int UpLo_>
|
template<typename MatrixType,int _UpLo>
|
||||||
template <typename Derived>
|
template<typename Derived>
|
||||||
bool LDLT<MatrixType, UpLo_>::solveInPlace(MatrixBase<Derived>& bAndX) const {
|
bool LDLT<MatrixType,_UpLo>::solveInPlace(MatrixBase<Derived> &bAndX) const
|
||||||
|
{
|
||||||
eigen_assert(m_isInitialized && "LDLT is not initialized.");
|
eigen_assert(m_isInitialized && "LDLT is not initialized.");
|
||||||
eigen_assert(m_matrix.rows() == bAndX.rows());
|
eigen_assert(m_matrix.rows() == bAndX.rows());
|
||||||
|
|
||||||
@@ -616,11 +639,12 @@ bool LDLT<MatrixType, UpLo_>::solveInPlace(MatrixBase<Derived>& bAndX) const {
|
|||||||
/** \returns the matrix represented by the decomposition,
|
/** \returns the matrix represented by the decomposition,
|
||||||
* i.e., it returns the product: P^T L D L^* P.
|
* i.e., it returns the product: P^T L D L^* P.
|
||||||
* This function is provided for debug purpose. */
|
* This function is provided for debug purpose. */
|
||||||
template <typename MatrixType, int UpLo_>
|
template<typename MatrixType, int _UpLo>
|
||||||
MatrixType LDLT<MatrixType, UpLo_>::reconstructedMatrix() const {
|
MatrixType LDLT<MatrixType,_UpLo>::reconstructedMatrix() const
|
||||||
|
{
|
||||||
eigen_assert(m_isInitialized && "LDLT is not initialized.");
|
eigen_assert(m_isInitialized && "LDLT is not initialized.");
|
||||||
const Index size = m_matrix.rows();
|
const Index size = m_matrix.rows();
|
||||||
MatrixType res(size, size);
|
MatrixType res(size,size);
|
||||||
|
|
||||||
// P
|
// P
|
||||||
res.setIdentity();
|
res.setIdentity();
|
||||||
@@ -638,24 +662,27 @@ MatrixType LDLT<MatrixType, UpLo_>::reconstructedMatrix() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** \cholesky_module
|
/** \cholesky_module
|
||||||
* \returns the Cholesky decomposition with full pivoting without square root of \c *this
|
* \returns the Cholesky decomposition with full pivoting without square root of \c *this
|
||||||
* \sa MatrixBase::ldlt()
|
* \sa MatrixBase::ldlt()
|
||||||
*/
|
*/
|
||||||
template <typename MatrixType, unsigned int UpLo>
|
template<typename MatrixType, unsigned int UpLo>
|
||||||
inline LDLT<typename SelfAdjointView<MatrixType, UpLo>::PlainObject, UpLo> SelfAdjointView<MatrixType, UpLo>::ldlt()
|
inline const LDLT<typename SelfAdjointView<MatrixType, UpLo>::PlainObject, UpLo>
|
||||||
const {
|
SelfAdjointView<MatrixType, UpLo>::ldlt() const
|
||||||
return LDLT<PlainObject, UpLo>(m_matrix);
|
{
|
||||||
|
return LDLT<PlainObject,UpLo>(m_matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \cholesky_module
|
/** \cholesky_module
|
||||||
* \returns the Cholesky decomposition with full pivoting without square root of \c *this
|
* \returns the Cholesky decomposition with full pivoting without square root of \c *this
|
||||||
* \sa SelfAdjointView::ldlt()
|
* \sa SelfAdjointView::ldlt()
|
||||||
*/
|
*/
|
||||||
template <typename Derived>
|
template<typename Derived>
|
||||||
inline LDLT<typename MatrixBase<Derived>::PlainObject> MatrixBase<Derived>::ldlt() const {
|
inline const LDLT<typename MatrixBase<Derived>::PlainObject>
|
||||||
|
MatrixBase<Derived>::ldlt() const
|
||||||
|
{
|
||||||
return LDLT<PlainObject>(derived());
|
return LDLT<PlainObject>(derived());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end namespace Eigen
|
} // end namespace Eigen
|
||||||
|
|
||||||
#endif // EIGEN_LDLT_H
|
#endif // EIGEN_LDLT_H
|
||||||
|
|||||||
@@ -10,412 +10,446 @@
|
|||||||
#ifndef EIGEN_LLT_H
|
#ifndef EIGEN_LLT_H
|
||||||
#define EIGEN_LLT_H
|
#define EIGEN_LLT_H
|
||||||
|
|
||||||
// IWYU pragma: private
|
|
||||||
#include "./InternalHeaderCheck.h"
|
|
||||||
|
|
||||||
namespace Eigen {
|
namespace Eigen {
|
||||||
|
|
||||||
namespace internal {
|
namespace internal{
|
||||||
|
|
||||||
template <typename MatrixType_, int UpLo_>
|
template<typename _MatrixType, int _UpLo> struct traits<LLT<_MatrixType, _UpLo> >
|
||||||
struct traits<LLT<MatrixType_, UpLo_> > : traits<MatrixType_> {
|
: traits<_MatrixType>
|
||||||
|
{
|
||||||
typedef MatrixXpr XprKind;
|
typedef MatrixXpr XprKind;
|
||||||
typedef SolverStorage StorageKind;
|
typedef SolverStorage StorageKind;
|
||||||
typedef int StorageIndex;
|
typedef int StorageIndex;
|
||||||
enum { Flags = 0 };
|
enum { Flags = 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename MatrixType, int UpLo>
|
template<typename MatrixType, int UpLo> struct LLT_Traits;
|
||||||
struct LLT_Traits;
|
}
|
||||||
} // namespace internal
|
|
||||||
|
|
||||||
/** \ingroup Cholesky_Module
|
/** \ingroup Cholesky_Module
|
||||||
*
|
*
|
||||||
* \class LLT
|
* \class LLT
|
||||||
*
|
*
|
||||||
* \brief Standard Cholesky decomposition (LL^T) of a matrix and associated features
|
* \brief Standard Cholesky decomposition (LL^T) of a matrix and associated features
|
||||||
*
|
*
|
||||||
* \tparam MatrixType_ the type of the matrix of which we are computing the LL^T Cholesky decomposition
|
* \tparam _MatrixType the type of the matrix of which we are computing the LL^T Cholesky decomposition
|
||||||
* \tparam UpLo_ the triangular part that will be used for the decomposition: Lower (default) or Upper.
|
* \tparam _UpLo the triangular part that will be used for the decompositon: Lower (default) or Upper.
|
||||||
* The other triangular part won't be read.
|
* The other triangular part won't be read.
|
||||||
*
|
*
|
||||||
* This class performs a LL^T Cholesky decomposition of a symmetric, positive definite
|
* This class performs a LL^T Cholesky decomposition of a symmetric, positive definite
|
||||||
* matrix A such that A = LL^* = U^*U, where L is lower triangular.
|
* matrix A such that A = LL^* = U^*U, where L is lower triangular.
|
||||||
*
|
*
|
||||||
* While the Cholesky decomposition is particularly useful to solve selfadjoint problems like D^*D x = b,
|
* While the Cholesky decomposition is particularly useful to solve selfadjoint problems like D^*D x = b,
|
||||||
* for that purpose, we recommend the Cholesky decomposition without square root which is more stable
|
* for that purpose, we recommend the Cholesky decomposition without square root which is more stable
|
||||||
* and even faster. Nevertheless, this standard Cholesky decomposition remains useful in many other
|
* and even faster. Nevertheless, this standard Cholesky decomposition remains useful in many other
|
||||||
* situations like generalised eigen problems with hermitian matrices.
|
* situations like generalised eigen problems with hermitian matrices.
|
||||||
*
|
*
|
||||||
* Remember that Cholesky decompositions are not rank-revealing. This LLT decomposition is only stable on positive
|
* Remember that Cholesky decompositions are not rank-revealing. This LLT decomposition is only stable on positive definite matrices,
|
||||||
* definite matrices, use LDLT instead for the semidefinite case. Also, do not use a Cholesky decomposition to determine
|
* use LDLT instead for the semidefinite case. Also, do not use a Cholesky decomposition to determine whether a system of equations
|
||||||
* whether a system of equations has a solution.
|
* has a solution.
|
||||||
*
|
*
|
||||||
* Example: \include LLT_example.cpp
|
* Example: \include LLT_example.cpp
|
||||||
* Output: \verbinclude LLT_example.out
|
* Output: \verbinclude LLT_example.out
|
||||||
*
|
*
|
||||||
* \b Performance: for best performance, it is recommended to use a column-major storage format
|
* \b Performance: for best performance, it is recommended to use a column-major storage format
|
||||||
* with the Lower triangular part (the default), or, equivalently, a row-major storage format
|
* with the Lower triangular part (the default), or, equivalently, a row-major storage format
|
||||||
* with the Upper triangular part. Otherwise, you might get a 20% slowdown for the full factorization
|
* with the Upper triangular part. Otherwise, you might get a 20% slowdown for the full factorization
|
||||||
* step, and rank-updates can be up to 3 times slower.
|
* step, and rank-updates can be up to 3 times slower.
|
||||||
*
|
*
|
||||||
* This class supports the \link InplaceDecomposition inplace decomposition \endlink mechanism.
|
* This class supports the \link InplaceDecomposition inplace decomposition \endlink mechanism.
|
||||||
*
|
*
|
||||||
* Note that during the decomposition, only the lower (or upper, as defined by UpLo_) triangular part of A is
|
* Note that during the decomposition, only the lower (or upper, as defined by _UpLo) triangular part of A is considered.
|
||||||
* considered. Therefore, the strict lower part does not have to store correct values.
|
* Therefore, the strict lower part does not have to store correct values.
|
||||||
*
|
*
|
||||||
* \sa MatrixBase::llt(), SelfAdjointView::llt(), class LDLT
|
* \sa MatrixBase::llt(), SelfAdjointView::llt(), class LDLT
|
||||||
*/
|
*/
|
||||||
template <typename MatrixType_, int UpLo_>
|
template<typename _MatrixType, int _UpLo> class LLT
|
||||||
class LLT : public SolverBase<LLT<MatrixType_, UpLo_> > {
|
: public SolverBase<LLT<_MatrixType, _UpLo> >
|
||||||
public:
|
{
|
||||||
typedef MatrixType_ MatrixType;
|
public:
|
||||||
typedef SolverBase<LLT> Base;
|
typedef _MatrixType MatrixType;
|
||||||
friend class SolverBase<LLT>;
|
typedef SolverBase<LLT> Base;
|
||||||
|
friend class SolverBase<LLT>;
|
||||||
|
|
||||||
EIGEN_GENERIC_PUBLIC_INTERFACE(LLT)
|
EIGEN_GENERIC_PUBLIC_INTERFACE(LLT)
|
||||||
enum { MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime };
|
enum {
|
||||||
|
MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
|
||||||
|
};
|
||||||
|
|
||||||
enum { PacketSize = internal::packet_traits<Scalar>::size, AlignmentMask = int(PacketSize) - 1, UpLo = UpLo_ };
|
enum {
|
||||||
|
PacketSize = internal::packet_traits<Scalar>::size,
|
||||||
|
AlignmentMask = int(PacketSize)-1,
|
||||||
|
UpLo = _UpLo
|
||||||
|
};
|
||||||
|
|
||||||
typedef internal::LLT_Traits<MatrixType, UpLo> Traits;
|
typedef internal::LLT_Traits<MatrixType,UpLo> Traits;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Default Constructor.
|
* \brief Default Constructor.
|
||||||
*
|
*
|
||||||
* The default constructor is useful in cases in which the user intends to
|
* The default constructor is useful in cases in which the user intends to
|
||||||
* perform decompositions via LLT::compute(const MatrixType&).
|
* perform decompositions via LLT::compute(const MatrixType&).
|
||||||
*/
|
*/
|
||||||
LLT() : m_matrix(), m_l1_norm(0), m_isInitialized(false), m_info(InvalidInput) {}
|
LLT() : m_matrix(), m_isInitialized(false) {}
|
||||||
|
|
||||||
/** \brief Default Constructor with memory preallocation
|
/** \brief Default Constructor with memory preallocation
|
||||||
*
|
*
|
||||||
* Like the default constructor but with preallocation of the internal data
|
* Like the default constructor but with preallocation of the internal data
|
||||||
* according to the specified problem \a size.
|
* according to the specified problem \a size.
|
||||||
* \sa LLT()
|
* \sa LLT()
|
||||||
*/
|
*/
|
||||||
explicit LLT(Index size) : m_matrix(size, size), m_l1_norm(0), m_isInitialized(false), m_info(InvalidInput) {}
|
explicit LLT(Index size) : m_matrix(size, size),
|
||||||
|
m_isInitialized(false) {}
|
||||||
|
|
||||||
template <typename InputType>
|
template<typename InputType>
|
||||||
explicit LLT(const EigenBase<InputType>& matrix)
|
explicit LLT(const EigenBase<InputType>& matrix)
|
||||||
: m_matrix(matrix.rows(), matrix.cols()), m_l1_norm(0), m_isInitialized(false), m_info(InvalidInput) {
|
: m_matrix(matrix.rows(), matrix.cols()),
|
||||||
compute(matrix.derived());
|
m_isInitialized(false)
|
||||||
}
|
{
|
||||||
|
compute(matrix.derived());
|
||||||
|
}
|
||||||
|
|
||||||
/** \brief Constructs a LLT factorization from a given matrix
|
/** \brief Constructs a LLT factorization from a given matrix
|
||||||
*
|
*
|
||||||
* This overloaded constructor is provided for \link InplaceDecomposition inplace decomposition \endlink when
|
* This overloaded constructor is provided for \link InplaceDecomposition inplace decomposition \endlink when
|
||||||
* \c MatrixType is a Eigen::Ref.
|
* \c MatrixType is a Eigen::Ref.
|
||||||
*
|
*
|
||||||
* \sa LLT(const EigenBase&)
|
* \sa LLT(const EigenBase&)
|
||||||
*/
|
*/
|
||||||
template <typename InputType>
|
template<typename InputType>
|
||||||
explicit LLT(EigenBase<InputType>& matrix)
|
explicit LLT(EigenBase<InputType>& matrix)
|
||||||
: m_matrix(matrix.derived()), m_l1_norm(0), m_isInitialized(false), m_info(InvalidInput) {
|
: m_matrix(matrix.derived()),
|
||||||
compute(matrix.derived());
|
m_isInitialized(false)
|
||||||
}
|
{
|
||||||
|
compute(matrix.derived());
|
||||||
|
}
|
||||||
|
|
||||||
/** \returns a view of the upper triangular matrix U */
|
/** \returns a view of the upper triangular matrix U */
|
||||||
inline typename Traits::MatrixU matrixU() const {
|
inline typename Traits::MatrixU matrixU() const
|
||||||
eigen_assert(m_isInitialized && "LLT is not initialized.");
|
{
|
||||||
return Traits::getU(m_matrix);
|
eigen_assert(m_isInitialized && "LLT is not initialized.");
|
||||||
}
|
return Traits::getU(m_matrix);
|
||||||
|
}
|
||||||
|
|
||||||
/** \returns a view of the lower triangular matrix L */
|
/** \returns a view of the lower triangular matrix L */
|
||||||
inline typename Traits::MatrixL matrixL() const {
|
inline typename Traits::MatrixL matrixL() const
|
||||||
eigen_assert(m_isInitialized && "LLT is not initialized.");
|
{
|
||||||
return Traits::getL(m_matrix);
|
eigen_assert(m_isInitialized && "LLT is not initialized.");
|
||||||
}
|
return Traits::getL(m_matrix);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef EIGEN_PARSED_BY_DOXYGEN
|
#ifdef EIGEN_PARSED_BY_DOXYGEN
|
||||||
/** \returns the solution x of \f$ A x = b \f$ using the current decomposition of A.
|
/** \returns the solution x of \f$ A x = b \f$ using the current decomposition of A.
|
||||||
*
|
*
|
||||||
* Since this LLT class assumes anyway that the matrix A is invertible, the solution
|
* Since this LLT class assumes anyway that the matrix A is invertible, the solution
|
||||||
* theoretically exists and is unique regardless of b.
|
* theoretically exists and is unique regardless of b.
|
||||||
*
|
*
|
||||||
* Example: \include LLT_solve.cpp
|
* Example: \include LLT_solve.cpp
|
||||||
* Output: \verbinclude LLT_solve.out
|
* Output: \verbinclude LLT_solve.out
|
||||||
*
|
*
|
||||||
* \sa solveInPlace(), MatrixBase::llt(), SelfAdjointView::llt()
|
* \sa solveInPlace(), MatrixBase::llt(), SelfAdjointView::llt()
|
||||||
*/
|
*/
|
||||||
template <typename Rhs>
|
template<typename Rhs>
|
||||||
inline Solve<LLT, Rhs> solve(const MatrixBase<Rhs>& b) const;
|
inline const Solve<LLT, Rhs>
|
||||||
#endif
|
solve(const MatrixBase<Rhs>& b) const;
|
||||||
|
#endif
|
||||||
|
|
||||||
template <typename Derived>
|
template<typename Derived>
|
||||||
void solveInPlace(const MatrixBase<Derived>& bAndX) const;
|
void solveInPlace(const MatrixBase<Derived> &bAndX) const;
|
||||||
|
|
||||||
template <typename InputType>
|
template<typename InputType>
|
||||||
LLT& compute(const EigenBase<InputType>& matrix);
|
LLT& compute(const EigenBase<InputType>& matrix);
|
||||||
|
|
||||||
/** \returns an estimate of the reciprocal condition number of the matrix of
|
/** \returns an estimate of the reciprocal condition number of the matrix of
|
||||||
* which \c *this is the Cholesky decomposition.
|
* which \c *this is the Cholesky decomposition.
|
||||||
*/
|
*/
|
||||||
RealScalar rcond() const {
|
RealScalar rcond() const
|
||||||
eigen_assert(m_isInitialized && "LLT is not initialized.");
|
{
|
||||||
eigen_assert(m_info == Success && "LLT failed because matrix appears to be negative");
|
eigen_assert(m_isInitialized && "LLT is not initialized.");
|
||||||
return internal::rcond_estimate_helper(m_l1_norm, *this);
|
eigen_assert(m_info == Success && "LLT failed because matrix appears to be negative");
|
||||||
}
|
return internal::rcond_estimate_helper(m_l1_norm, *this);
|
||||||
|
}
|
||||||
|
|
||||||
/** \returns the LLT decomposition matrix
|
/** \returns the LLT decomposition matrix
|
||||||
*
|
*
|
||||||
* TODO: document the storage layout
|
* TODO: document the storage layout
|
||||||
*/
|
*/
|
||||||
inline const MatrixType& matrixLLT() const {
|
inline const MatrixType& matrixLLT() const
|
||||||
eigen_assert(m_isInitialized && "LLT is not initialized.");
|
{
|
||||||
return m_matrix;
|
eigen_assert(m_isInitialized && "LLT is not initialized.");
|
||||||
}
|
return m_matrix;
|
||||||
|
}
|
||||||
|
|
||||||
MatrixType reconstructedMatrix() const;
|
MatrixType reconstructedMatrix() const;
|
||||||
|
|
||||||
/** \brief Reports whether previous computation was successful.
|
|
||||||
*
|
|
||||||
* \returns \c Success if computation was successful,
|
|
||||||
* \c NumericalIssue if the matrix.appears not to be positive definite.
|
|
||||||
*/
|
|
||||||
ComputationInfo info() const {
|
|
||||||
eigen_assert(m_isInitialized && "LLT is not initialized.");
|
|
||||||
return m_info;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** \returns the adjoint of \c *this, that is, a const reference to the decomposition itself as the underlying matrix
|
/** \brief Reports whether previous computation was successful.
|
||||||
* is self-adjoint.
|
*
|
||||||
*
|
* \returns \c Success if computation was successful,
|
||||||
* This method is provided for compatibility with other matrix decompositions, thus enabling generic code such as:
|
* \c NumericalIssue if the matrix.appears not to be positive definite.
|
||||||
* \code x = decomposition.adjoint().solve(b) \endcode
|
*/
|
||||||
*/
|
ComputationInfo info() const
|
||||||
const LLT& adjoint() const noexcept { return *this; }
|
{
|
||||||
|
eigen_assert(m_isInitialized && "LLT is not initialized.");
|
||||||
|
return m_info;
|
||||||
|
}
|
||||||
|
|
||||||
constexpr Index rows() const noexcept { return m_matrix.rows(); }
|
/** \returns the adjoint of \c *this, that is, a const reference to the decomposition itself as the underlying matrix is self-adjoint.
|
||||||
constexpr Index cols() const noexcept { return m_matrix.cols(); }
|
*
|
||||||
|
* This method is provided for compatibility with other matrix decompositions, thus enabling generic code such as:
|
||||||
|
* \code x = decomposition.adjoint().solve(b) \endcode
|
||||||
|
*/
|
||||||
|
const LLT& adjoint() const EIGEN_NOEXCEPT { return *this; };
|
||||||
|
|
||||||
template <typename VectorType>
|
inline EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT { return m_matrix.rows(); }
|
||||||
LLT& rankUpdate(const VectorType& vec, const RealScalar& sigma = 1);
|
inline EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT { return m_matrix.cols(); }
|
||||||
|
|
||||||
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
template<typename VectorType>
|
||||||
template <typename RhsType, typename DstType>
|
LLT & rankUpdate(const VectorType& vec, const RealScalar& sigma = 1);
|
||||||
void _solve_impl(const RhsType& rhs, DstType& dst) const;
|
|
||||||
|
|
||||||
template <bool Conjugate, typename RhsType, typename DstType>
|
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
||||||
void _solve_impl_transposed(const RhsType& rhs, DstType& dst) const;
|
template<typename RhsType, typename DstType>
|
||||||
#endif
|
void _solve_impl(const RhsType &rhs, DstType &dst) const;
|
||||||
|
|
||||||
protected:
|
template<bool Conjugate, typename RhsType, typename DstType>
|
||||||
EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar)
|
void _solve_impl_transposed(const RhsType &rhs, DstType &dst) const;
|
||||||
|
#endif
|
||||||
|
|
||||||
/** \internal
|
protected:
|
||||||
* Used to compute and store L
|
|
||||||
* The strict upper part is not used and even not initialized.
|
static void check_template_parameters()
|
||||||
*/
|
{
|
||||||
MatrixType m_matrix;
|
EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar);
|
||||||
RealScalar m_l1_norm;
|
}
|
||||||
bool m_isInitialized;
|
|
||||||
ComputationInfo m_info;
|
/** \internal
|
||||||
|
* Used to compute and store L
|
||||||
|
* The strict upper part is not used and even not initialized.
|
||||||
|
*/
|
||||||
|
MatrixType m_matrix;
|
||||||
|
RealScalar m_l1_norm;
|
||||||
|
bool m_isInitialized;
|
||||||
|
ComputationInfo m_info;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
template <typename Scalar, int UpLo>
|
template<typename Scalar, int UpLo> struct llt_inplace;
|
||||||
struct llt_inplace;
|
|
||||||
|
|
||||||
template <typename MatrixType, typename VectorType>
|
template<typename MatrixType, typename VectorType>
|
||||||
static Index llt_rank_update_lower(MatrixType& mat, const VectorType& vec,
|
static Index llt_rank_update_lower(MatrixType& mat, const VectorType& vec, const typename MatrixType::RealScalar& sigma)
|
||||||
const typename MatrixType::RealScalar& sigma) {
|
{
|
||||||
using std::sqrt;
|
using std::sqrt;
|
||||||
typedef typename MatrixType::Scalar Scalar;
|
typedef typename MatrixType::Scalar Scalar;
|
||||||
typedef typename MatrixType::RealScalar RealScalar;
|
typedef typename MatrixType::RealScalar RealScalar;
|
||||||
typedef typename MatrixType::ColXpr ColXpr;
|
typedef typename MatrixType::ColXpr ColXpr;
|
||||||
typedef internal::remove_all_t<ColXpr> ColXprCleaned;
|
typedef typename internal::remove_all<ColXpr>::type ColXprCleaned;
|
||||||
typedef typename ColXprCleaned::SegmentReturnType ColXprSegment;
|
typedef typename ColXprCleaned::SegmentReturnType ColXprSegment;
|
||||||
typedef Matrix<Scalar, Dynamic, 1> TempVectorType;
|
typedef Matrix<Scalar,Dynamic,1> TempVectorType;
|
||||||
typedef typename TempVectorType::SegmentReturnType TempVecSegment;
|
typedef typename TempVectorType::SegmentReturnType TempVecSegment;
|
||||||
|
|
||||||
Index n = mat.cols();
|
Index n = mat.cols();
|
||||||
eigen_assert(mat.rows() == n && vec.size() == n);
|
eigen_assert(mat.rows()==n && vec.size()==n);
|
||||||
|
|
||||||
TempVectorType temp;
|
TempVectorType temp;
|
||||||
|
|
||||||
if (sigma > 0) {
|
if(sigma>0)
|
||||||
|
{
|
||||||
// This version is based on Givens rotations.
|
// This version is based on Givens rotations.
|
||||||
// It is faster than the other one below, but only works for updates,
|
// It is faster than the other one below, but only works for updates,
|
||||||
// i.e., for sigma > 0
|
// i.e., for sigma > 0
|
||||||
temp = sqrt(sigma) * vec;
|
temp = sqrt(sigma) * vec;
|
||||||
|
|
||||||
for (Index i = 0; i < n; ++i) {
|
for(Index i=0; i<n; ++i)
|
||||||
|
{
|
||||||
JacobiRotation<Scalar> g;
|
JacobiRotation<Scalar> g;
|
||||||
g.makeGivens(mat(i, i), -temp(i), &mat(i, i));
|
g.makeGivens(mat(i,i), -temp(i), &mat(i,i));
|
||||||
|
|
||||||
Index rs = n - i - 1;
|
Index rs = n-i-1;
|
||||||
if (rs > 0) {
|
if(rs>0)
|
||||||
|
{
|
||||||
ColXprSegment x(mat.col(i).tail(rs));
|
ColXprSegment x(mat.col(i).tail(rs));
|
||||||
TempVecSegment y(temp.tail(rs));
|
TempVecSegment y(temp.tail(rs));
|
||||||
apply_rotation_in_the_plane(x, y, g);
|
apply_rotation_in_the_plane(x, y, g);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
temp = vec;
|
temp = vec;
|
||||||
RealScalar beta = 1;
|
RealScalar beta = 1;
|
||||||
for (Index j = 0; j < n; ++j) {
|
for(Index j=0; j<n; ++j)
|
||||||
RealScalar Ljj = numext::real(mat.coeff(j, j));
|
{
|
||||||
|
RealScalar Ljj = numext::real(mat.coeff(j,j));
|
||||||
RealScalar dj = numext::abs2(Ljj);
|
RealScalar dj = numext::abs2(Ljj);
|
||||||
Scalar wj = temp.coeff(j);
|
Scalar wj = temp.coeff(j);
|
||||||
RealScalar swj2 = sigma * numext::abs2(wj);
|
RealScalar swj2 = sigma*numext::abs2(wj);
|
||||||
RealScalar gamma = dj * beta + swj2;
|
RealScalar gamma = dj*beta + swj2;
|
||||||
|
|
||||||
RealScalar x = dj + swj2 / beta;
|
RealScalar x = dj + swj2/beta;
|
||||||
if (x <= RealScalar(0)) return j;
|
if (x<=RealScalar(0))
|
||||||
|
return j;
|
||||||
RealScalar nLjj = sqrt(x);
|
RealScalar nLjj = sqrt(x);
|
||||||
mat.coeffRef(j, j) = nLjj;
|
mat.coeffRef(j,j) = nLjj;
|
||||||
beta += swj2 / dj;
|
beta += swj2/dj;
|
||||||
|
|
||||||
// Update the terms of L
|
// Update the terms of L
|
||||||
Index rs = n - j - 1;
|
Index rs = n-j-1;
|
||||||
if (rs) {
|
if(rs)
|
||||||
temp.tail(rs) -= (wj / Ljj) * mat.col(j).tail(rs);
|
{
|
||||||
if (!numext::is_exactly_zero(gamma))
|
temp.tail(rs) -= (wj/Ljj) * mat.col(j).tail(rs);
|
||||||
mat.col(j).tail(rs) =
|
if(gamma != 0)
|
||||||
(nLjj / Ljj) * mat.col(j).tail(rs) + (nLjj * sigma * numext::conj(wj) / gamma) * temp.tail(rs);
|
mat.col(j).tail(rs) = (nLjj/Ljj) * mat.col(j).tail(rs) + (nLjj * sigma*numext::conj(wj)/gamma)*temp.tail(rs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Scalar>
|
template<typename Scalar> struct llt_inplace<Scalar, Lower>
|
||||||
struct llt_inplace<Scalar, Lower> {
|
{
|
||||||
typedef typename NumTraits<Scalar>::Real RealScalar;
|
typedef typename NumTraits<Scalar>::Real RealScalar;
|
||||||
template <typename MatrixType>
|
template<typename MatrixType>
|
||||||
static Index unblocked(MatrixType& mat) {
|
static Index unblocked(MatrixType& mat)
|
||||||
|
{
|
||||||
using std::sqrt;
|
using std::sqrt;
|
||||||
|
|
||||||
eigen_assert(mat.rows() == mat.cols());
|
eigen_assert(mat.rows()==mat.cols());
|
||||||
const Index size = mat.rows();
|
const Index size = mat.rows();
|
||||||
for (Index k = 0; k < size; ++k) {
|
for(Index k = 0; k < size; ++k)
|
||||||
Index rs = size - k - 1; // remaining size
|
{
|
||||||
|
Index rs = size-k-1; // remaining size
|
||||||
|
|
||||||
Block<MatrixType, Dynamic, 1> A21(mat, k + 1, k, rs, 1);
|
Block<MatrixType,Dynamic,1> A21(mat,k+1,k,rs,1);
|
||||||
Block<MatrixType, 1, Dynamic> A10(mat, k, 0, 1, k);
|
Block<MatrixType,1,Dynamic> A10(mat,k,0,1,k);
|
||||||
Block<MatrixType, Dynamic, Dynamic> A20(mat, k + 1, 0, rs, k);
|
Block<MatrixType,Dynamic,Dynamic> A20(mat,k+1,0,rs,k);
|
||||||
|
|
||||||
RealScalar x = numext::real(mat.coeff(k, k));
|
RealScalar x = numext::real(mat.coeff(k,k));
|
||||||
if (k > 0) x -= A10.squaredNorm();
|
if (k>0) x -= A10.squaredNorm();
|
||||||
if (x <= RealScalar(0)) return k;
|
if (x<=RealScalar(0))
|
||||||
mat.coeffRef(k, k) = x = sqrt(x);
|
return k;
|
||||||
if (k > 0 && rs > 0) A21.noalias() -= A20 * A10.adjoint();
|
mat.coeffRef(k,k) = x = sqrt(x);
|
||||||
if (rs > 0) A21 /= x;
|
if (k>0 && rs>0) A21.noalias() -= A20 * A10.adjoint();
|
||||||
|
if (rs>0) A21 /= x;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename MatrixType>
|
template<typename MatrixType>
|
||||||
static Index blocked(MatrixType& m) {
|
static Index blocked(MatrixType& m)
|
||||||
eigen_assert(m.rows() == m.cols());
|
{
|
||||||
|
eigen_assert(m.rows()==m.cols());
|
||||||
Index size = m.rows();
|
Index size = m.rows();
|
||||||
if (size < 32) return unblocked(m);
|
if(size<32)
|
||||||
|
return unblocked(m);
|
||||||
|
|
||||||
Index blockSize = size / 8;
|
Index blockSize = size/8;
|
||||||
blockSize = (blockSize / 16) * 16;
|
blockSize = (blockSize/16)*16;
|
||||||
blockSize = (std::min)((std::max)(blockSize, Index(8)), Index(128));
|
blockSize = (std::min)((std::max)(blockSize,Index(8)), Index(128));
|
||||||
|
|
||||||
for (Index k = 0; k < size; k += blockSize) {
|
for (Index k=0; k<size; k+=blockSize)
|
||||||
|
{
|
||||||
// partition the matrix:
|
// partition the matrix:
|
||||||
// A00 | - | -
|
// A00 | - | -
|
||||||
// lu = A10 | A11 | -
|
// lu = A10 | A11 | -
|
||||||
// A20 | A21 | A22
|
// A20 | A21 | A22
|
||||||
Index bs = (std::min)(blockSize, size - k);
|
Index bs = (std::min)(blockSize, size-k);
|
||||||
Index rs = size - k - bs;
|
Index rs = size - k - bs;
|
||||||
Block<MatrixType, Dynamic, Dynamic> A11(m, k, k, bs, bs);
|
Block<MatrixType,Dynamic,Dynamic> A11(m,k, k, bs,bs);
|
||||||
Block<MatrixType, Dynamic, Dynamic> A21(m, k + bs, k, rs, bs);
|
Block<MatrixType,Dynamic,Dynamic> A21(m,k+bs,k, rs,bs);
|
||||||
Block<MatrixType, Dynamic, Dynamic> A22(m, k + bs, k + bs, rs, rs);
|
Block<MatrixType,Dynamic,Dynamic> A22(m,k+bs,k+bs,rs,rs);
|
||||||
|
|
||||||
Index ret;
|
Index ret;
|
||||||
if ((ret = unblocked(A11)) >= 0) return k + ret;
|
if((ret=unblocked(A11))>=0) return k+ret;
|
||||||
if (rs > 0) A11.adjoint().template triangularView<Upper>().template solveInPlace<OnTheRight>(A21);
|
if(rs>0) A11.adjoint().template triangularView<Upper>().template solveInPlace<OnTheRight>(A21);
|
||||||
if (rs > 0)
|
if(rs>0) A22.template selfadjointView<Lower>().rankUpdate(A21,typename NumTraits<RealScalar>::Literal(-1)); // bottleneck
|
||||||
A22.template selfadjointView<Lower>().rankUpdate(A21,
|
|
||||||
typename NumTraits<RealScalar>::Literal(-1)); // bottleneck
|
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename MatrixType, typename VectorType>
|
template<typename MatrixType, typename VectorType>
|
||||||
static Index rankUpdate(MatrixType& mat, const VectorType& vec, const RealScalar& sigma) {
|
static Index rankUpdate(MatrixType& mat, const VectorType& vec, const RealScalar& sigma)
|
||||||
|
{
|
||||||
return Eigen::internal::llt_rank_update_lower(mat, vec, sigma);
|
return Eigen::internal::llt_rank_update_lower(mat, vec, sigma);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Scalar>
|
template<typename Scalar> struct llt_inplace<Scalar, Upper>
|
||||||
struct llt_inplace<Scalar, Upper> {
|
{
|
||||||
typedef typename NumTraits<Scalar>::Real RealScalar;
|
typedef typename NumTraits<Scalar>::Real RealScalar;
|
||||||
|
|
||||||
template <typename MatrixType>
|
template<typename MatrixType>
|
||||||
static EIGEN_STRONG_INLINE Index unblocked(MatrixType& mat) {
|
static EIGEN_STRONG_INLINE Index unblocked(MatrixType& mat)
|
||||||
|
{
|
||||||
Transpose<MatrixType> matt(mat);
|
Transpose<MatrixType> matt(mat);
|
||||||
return llt_inplace<Scalar, Lower>::unblocked(matt);
|
return llt_inplace<Scalar, Lower>::unblocked(matt);
|
||||||
}
|
}
|
||||||
template <typename MatrixType>
|
template<typename MatrixType>
|
||||||
static EIGEN_STRONG_INLINE Index blocked(MatrixType& mat) {
|
static EIGEN_STRONG_INLINE Index blocked(MatrixType& mat)
|
||||||
|
{
|
||||||
Transpose<MatrixType> matt(mat);
|
Transpose<MatrixType> matt(mat);
|
||||||
return llt_inplace<Scalar, Lower>::blocked(matt);
|
return llt_inplace<Scalar, Lower>::blocked(matt);
|
||||||
}
|
}
|
||||||
template <typename MatrixType, typename VectorType>
|
template<typename MatrixType, typename VectorType>
|
||||||
static Index rankUpdate(MatrixType& mat, const VectorType& vec, const RealScalar& sigma) {
|
static Index rankUpdate(MatrixType& mat, const VectorType& vec, const RealScalar& sigma)
|
||||||
|
{
|
||||||
Transpose<MatrixType> matt(mat);
|
Transpose<MatrixType> matt(mat);
|
||||||
return llt_inplace<Scalar, Lower>::rankUpdate(matt, vec.conjugate(), sigma);
|
return llt_inplace<Scalar, Lower>::rankUpdate(matt, vec.conjugate(), sigma);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename MatrixType>
|
template<typename MatrixType> struct LLT_Traits<MatrixType,Lower>
|
||||||
struct LLT_Traits<MatrixType, Lower> {
|
{
|
||||||
typedef const TriangularView<const MatrixType, Lower> MatrixL;
|
typedef const TriangularView<const MatrixType, Lower> MatrixL;
|
||||||
typedef const TriangularView<const typename MatrixType::AdjointReturnType, Upper> MatrixU;
|
typedef const TriangularView<const typename MatrixType::AdjointReturnType, Upper> MatrixU;
|
||||||
static inline MatrixL getL(const MatrixType& m) { return MatrixL(m); }
|
static inline MatrixL getL(const MatrixType& m) { return MatrixL(m); }
|
||||||
static inline MatrixU getU(const MatrixType& m) { return MatrixU(m.adjoint()); }
|
static inline MatrixU getU(const MatrixType& m) { return MatrixU(m.adjoint()); }
|
||||||
static bool inplace_decomposition(MatrixType& m) {
|
static bool inplace_decomposition(MatrixType& m)
|
||||||
return llt_inplace<typename MatrixType::Scalar, Lower>::blocked(m) == -1;
|
{ return llt_inplace<typename MatrixType::Scalar, Lower>::blocked(m)==-1; }
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename MatrixType>
|
template<typename MatrixType> struct LLT_Traits<MatrixType,Upper>
|
||||||
struct LLT_Traits<MatrixType, Upper> {
|
{
|
||||||
typedef const TriangularView<const typename MatrixType::AdjointReturnType, Lower> MatrixL;
|
typedef const TriangularView<const typename MatrixType::AdjointReturnType, Lower> MatrixL;
|
||||||
typedef const TriangularView<const MatrixType, Upper> MatrixU;
|
typedef const TriangularView<const MatrixType, Upper> MatrixU;
|
||||||
static inline MatrixL getL(const MatrixType& m) { return MatrixL(m.adjoint()); }
|
static inline MatrixL getL(const MatrixType& m) { return MatrixL(m.adjoint()); }
|
||||||
static inline MatrixU getU(const MatrixType& m) { return MatrixU(m); }
|
static inline MatrixU getU(const MatrixType& m) { return MatrixU(m); }
|
||||||
static bool inplace_decomposition(MatrixType& m) {
|
static bool inplace_decomposition(MatrixType& m)
|
||||||
return llt_inplace<typename MatrixType::Scalar, Upper>::blocked(m) == -1;
|
{ return llt_inplace<typename MatrixType::Scalar, Upper>::blocked(m)==-1; }
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace internal
|
} // end namespace internal
|
||||||
|
|
||||||
/** Computes / recomputes the Cholesky decomposition A = LL^* = U^*U of \a matrix
|
/** Computes / recomputes the Cholesky decomposition A = LL^* = U^*U of \a matrix
|
||||||
*
|
*
|
||||||
* \returns a reference to *this
|
* \returns a reference to *this
|
||||||
*
|
*
|
||||||
* Example: \include TutorialLinAlgComputeTwice.cpp
|
* Example: \include TutorialLinAlgComputeTwice.cpp
|
||||||
* Output: \verbinclude TutorialLinAlgComputeTwice.out
|
* Output: \verbinclude TutorialLinAlgComputeTwice.out
|
||||||
*/
|
*/
|
||||||
template <typename MatrixType, int UpLo_>
|
template<typename MatrixType, int _UpLo>
|
||||||
template <typename InputType>
|
template<typename InputType>
|
||||||
LLT<MatrixType, UpLo_>& LLT<MatrixType, UpLo_>::compute(const EigenBase<InputType>& a) {
|
LLT<MatrixType,_UpLo>& LLT<MatrixType,_UpLo>::compute(const EigenBase<InputType>& a)
|
||||||
eigen_assert(a.rows() == a.cols());
|
{
|
||||||
|
check_template_parameters();
|
||||||
|
|
||||||
|
eigen_assert(a.rows()==a.cols());
|
||||||
const Index size = a.rows();
|
const Index size = a.rows();
|
||||||
m_matrix.resize(size, size);
|
m_matrix.resize(size, size);
|
||||||
if (!internal::is_same_dense(m_matrix, a.derived())) m_matrix = a.derived();
|
if (!internal::is_same_dense(m_matrix, a.derived()))
|
||||||
|
m_matrix = a.derived();
|
||||||
|
|
||||||
// Compute matrix L1 norm = max abs column sum.
|
// Compute matrix L1 norm = max abs column sum.
|
||||||
m_l1_norm = RealScalar(0);
|
m_l1_norm = RealScalar(0);
|
||||||
// TODO: move this code to SelfAdjointView
|
// TODO move this code to SelfAdjointView
|
||||||
for (Index col = 0; col < size; ++col) {
|
for (Index col = 0; col < size; ++col) {
|
||||||
RealScalar abs_col_sum;
|
RealScalar abs_col_sum;
|
||||||
if (UpLo_ == Lower)
|
if (_UpLo == Lower)
|
||||||
abs_col_sum =
|
abs_col_sum = m_matrix.col(col).tail(size - col).template lpNorm<1>() + m_matrix.row(col).head(col).template lpNorm<1>();
|
||||||
m_matrix.col(col).tail(size - col).template lpNorm<1>() + m_matrix.row(col).head(col).template lpNorm<1>();
|
|
||||||
else
|
else
|
||||||
abs_col_sum =
|
abs_col_sum = m_matrix.col(col).head(col).template lpNorm<1>() + m_matrix.row(col).tail(size - col).template lpNorm<1>();
|
||||||
m_matrix.col(col).head(col).template lpNorm<1>() + m_matrix.row(col).tail(size - col).template lpNorm<1>();
|
if (abs_col_sum > m_l1_norm)
|
||||||
if (abs_col_sum > m_l1_norm) m_l1_norm = abs_col_sum;
|
m_l1_norm = abs_col_sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_isInitialized = true;
|
m_isInitialized = true;
|
||||||
@@ -426,17 +460,18 @@ LLT<MatrixType, UpLo_>& LLT<MatrixType, UpLo_>::compute(const EigenBase<InputTyp
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Performs a rank one update (or dowdate) of the current decomposition.
|
/** Performs a rank one update (or dowdate) of the current decomposition.
|
||||||
* If A = LL^* before the rank one update,
|
* If A = LL^* before the rank one update,
|
||||||
* then after it we have LL^* = A + sigma * v v^* where \a v must be a vector
|
* then after it we have LL^* = A + sigma * v v^* where \a v must be a vector
|
||||||
* of same dimension.
|
* of same dimension.
|
||||||
*/
|
*/
|
||||||
template <typename MatrixType_, int UpLo_>
|
template<typename _MatrixType, int _UpLo>
|
||||||
template <typename VectorType>
|
template<typename VectorType>
|
||||||
LLT<MatrixType_, UpLo_>& LLT<MatrixType_, UpLo_>::rankUpdate(const VectorType& v, const RealScalar& sigma) {
|
LLT<_MatrixType,_UpLo> & LLT<_MatrixType,_UpLo>::rankUpdate(const VectorType& v, const RealScalar& sigma)
|
||||||
|
{
|
||||||
EIGEN_STATIC_ASSERT_VECTOR_ONLY(VectorType);
|
EIGEN_STATIC_ASSERT_VECTOR_ONLY(VectorType);
|
||||||
eigen_assert(v.size() == m_matrix.cols());
|
eigen_assert(v.size()==m_matrix.cols());
|
||||||
eigen_assert(m_isInitialized);
|
eigen_assert(m_isInitialized);
|
||||||
if (internal::llt_inplace<typename MatrixType::Scalar, UpLo>::rankUpdate(m_matrix, v, sigma) >= 0)
|
if(internal::llt_inplace<typename MatrixType::Scalar, UpLo>::rankUpdate(m_matrix,v,sigma)>=0)
|
||||||
m_info = NumericalIssue;
|
m_info = NumericalIssue;
|
||||||
else
|
else
|
||||||
m_info = Success;
|
m_info = Success;
|
||||||
@@ -445,40 +480,43 @@ LLT<MatrixType_, UpLo_>& LLT<MatrixType_, UpLo_>::rankUpdate(const VectorType& v
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
||||||
template <typename MatrixType_, int UpLo_>
|
template<typename _MatrixType,int _UpLo>
|
||||||
template <typename RhsType, typename DstType>
|
template<typename RhsType, typename DstType>
|
||||||
void LLT<MatrixType_, UpLo_>::_solve_impl(const RhsType& rhs, DstType& dst) const {
|
void LLT<_MatrixType,_UpLo>::_solve_impl(const RhsType &rhs, DstType &dst) const
|
||||||
|
{
|
||||||
_solve_impl_transposed<true>(rhs, dst);
|
_solve_impl_transposed<true>(rhs, dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename MatrixType_, int UpLo_>
|
template<typename _MatrixType,int _UpLo>
|
||||||
template <bool Conjugate, typename RhsType, typename DstType>
|
template<bool Conjugate, typename RhsType, typename DstType>
|
||||||
void LLT<MatrixType_, UpLo_>::_solve_impl_transposed(const RhsType& rhs, DstType& dst) const {
|
void LLT<_MatrixType,_UpLo>::_solve_impl_transposed(const RhsType &rhs, DstType &dst) const
|
||||||
dst = rhs;
|
{
|
||||||
|
dst = rhs;
|
||||||
|
|
||||||
matrixL().template conjugateIf<!Conjugate>().solveInPlace(dst);
|
matrixL().template conjugateIf<!Conjugate>().solveInPlace(dst);
|
||||||
matrixU().template conjugateIf<!Conjugate>().solveInPlace(dst);
|
matrixU().template conjugateIf<!Conjugate>().solveInPlace(dst);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** \internal use x = llt_object.solve(x);
|
/** \internal use x = llt_object.solve(x);
|
||||||
*
|
*
|
||||||
* This is the \em in-place version of solve().
|
* This is the \em in-place version of solve().
|
||||||
*
|
*
|
||||||
* \param bAndX represents both the right-hand side matrix b and result x.
|
* \param bAndX represents both the right-hand side matrix b and result x.
|
||||||
*
|
*
|
||||||
* This version avoids a copy when the right hand side matrix b is not needed anymore.
|
* This version avoids a copy when the right hand side matrix b is not needed anymore.
|
||||||
*
|
*
|
||||||
* \warning The parameter is only marked 'const' to make the C++ compiler accept a temporary expression here.
|
* \warning The parameter is only marked 'const' to make the C++ compiler accept a temporary expression here.
|
||||||
* This function will const_cast it, so constness isn't honored here.
|
* This function will const_cast it, so constness isn't honored here.
|
||||||
*
|
*
|
||||||
* \sa LLT::solve(), MatrixBase::llt()
|
* \sa LLT::solve(), MatrixBase::llt()
|
||||||
*/
|
*/
|
||||||
template <typename MatrixType, int UpLo_>
|
template<typename MatrixType, int _UpLo>
|
||||||
template <typename Derived>
|
template<typename Derived>
|
||||||
void LLT<MatrixType, UpLo_>::solveInPlace(const MatrixBase<Derived>& bAndX) const {
|
void LLT<MatrixType,_UpLo>::solveInPlace(const MatrixBase<Derived> &bAndX) const
|
||||||
|
{
|
||||||
eigen_assert(m_isInitialized && "LLT is not initialized.");
|
eigen_assert(m_isInitialized && "LLT is not initialized.");
|
||||||
eigen_assert(m_matrix.rows() == bAndX.rows());
|
eigen_assert(m_matrix.rows()==bAndX.rows());
|
||||||
matrixL().solveInPlace(bAndX);
|
matrixL().solveInPlace(bAndX);
|
||||||
matrixU().solveInPlace(bAndX);
|
matrixU().solveInPlace(bAndX);
|
||||||
}
|
}
|
||||||
@@ -486,31 +524,35 @@ void LLT<MatrixType, UpLo_>::solveInPlace(const MatrixBase<Derived>& bAndX) cons
|
|||||||
/** \returns the matrix represented by the decomposition,
|
/** \returns the matrix represented by the decomposition,
|
||||||
* i.e., it returns the product: L L^*.
|
* i.e., it returns the product: L L^*.
|
||||||
* This function is provided for debug purpose. */
|
* This function is provided for debug purpose. */
|
||||||
template <typename MatrixType, int UpLo_>
|
template<typename MatrixType, int _UpLo>
|
||||||
MatrixType LLT<MatrixType, UpLo_>::reconstructedMatrix() const {
|
MatrixType LLT<MatrixType,_UpLo>::reconstructedMatrix() const
|
||||||
|
{
|
||||||
eigen_assert(m_isInitialized && "LLT is not initialized.");
|
eigen_assert(m_isInitialized && "LLT is not initialized.");
|
||||||
return matrixL() * matrixL().adjoint().toDenseMatrix();
|
return matrixL() * matrixL().adjoint().toDenseMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \cholesky_module
|
/** \cholesky_module
|
||||||
* \returns the LLT decomposition of \c *this
|
* \returns the LLT decomposition of \c *this
|
||||||
* \sa SelfAdjointView::llt()
|
* \sa SelfAdjointView::llt()
|
||||||
*/
|
*/
|
||||||
template <typename Derived>
|
template<typename Derived>
|
||||||
inline LLT<typename MatrixBase<Derived>::PlainObject> MatrixBase<Derived>::llt() const {
|
inline const LLT<typename MatrixBase<Derived>::PlainObject>
|
||||||
|
MatrixBase<Derived>::llt() const
|
||||||
|
{
|
||||||
return LLT<PlainObject>(derived());
|
return LLT<PlainObject>(derived());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \cholesky_module
|
/** \cholesky_module
|
||||||
* \returns the LLT decomposition of \c *this
|
* \returns the LLT decomposition of \c *this
|
||||||
* \sa SelfAdjointView::llt()
|
* \sa SelfAdjointView::llt()
|
||||||
*/
|
*/
|
||||||
template <typename MatrixType, unsigned int UpLo>
|
template<typename MatrixType, unsigned int UpLo>
|
||||||
inline LLT<typename SelfAdjointView<MatrixType, UpLo>::PlainObject, UpLo> SelfAdjointView<MatrixType, UpLo>::llt()
|
inline const LLT<typename SelfAdjointView<MatrixType, UpLo>::PlainObject, UpLo>
|
||||||
const {
|
SelfAdjointView<MatrixType, UpLo>::llt() const
|
||||||
return LLT<PlainObject, UpLo>(m_matrix);
|
{
|
||||||
|
return LLT<PlainObject,UpLo>(m_matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end namespace Eigen
|
} // end namespace Eigen
|
||||||
|
|
||||||
#endif // EIGEN_LLT_H
|
#endif // EIGEN_LLT_H
|
||||||
|
|||||||
@@ -33,92 +33,67 @@
|
|||||||
#ifndef EIGEN_LLT_LAPACKE_H
|
#ifndef EIGEN_LLT_LAPACKE_H
|
||||||
#define EIGEN_LLT_LAPACKE_H
|
#define EIGEN_LLT_LAPACKE_H
|
||||||
|
|
||||||
// IWYU pragma: private
|
namespace Eigen {
|
||||||
#include "./InternalHeaderCheck.h"
|
|
||||||
|
|
||||||
namespace Eigen {
|
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
namespace lapacke_helpers {
|
template<typename Scalar> struct lapacke_llt;
|
||||||
// -------------------------------------------------------------------------------------------------------------------
|
|
||||||
// Dispatch for rank update handling upper and lower parts
|
|
||||||
// -------------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
template <UpLoType Mode>
|
#define EIGEN_LAPACKE_LLT(EIGTYPE, BLASTYPE, LAPACKE_PREFIX) \
|
||||||
struct rank_update {};
|
template<> struct lapacke_llt<EIGTYPE> \
|
||||||
|
{ \
|
||||||
template <>
|
template<typename MatrixType> \
|
||||||
struct rank_update<Lower> {
|
static inline Index potrf(MatrixType& m, char uplo) \
|
||||||
template <typename MatrixType, typename VectorType>
|
{ \
|
||||||
static Index run(MatrixType &mat, const VectorType &vec, const typename MatrixType::RealScalar &sigma) {
|
lapack_int matrix_order; \
|
||||||
return Eigen::internal::llt_rank_update_lower(mat, vec, sigma);
|
lapack_int size, lda, info, StorageOrder; \
|
||||||
}
|
EIGTYPE* a; \
|
||||||
|
eigen_assert(m.rows()==m.cols()); \
|
||||||
|
/* Set up parameters for ?potrf */ \
|
||||||
|
size = convert_index<lapack_int>(m.rows()); \
|
||||||
|
StorageOrder = MatrixType::Flags&RowMajorBit?RowMajor:ColMajor; \
|
||||||
|
matrix_order = StorageOrder==RowMajor ? LAPACK_ROW_MAJOR : LAPACK_COL_MAJOR; \
|
||||||
|
a = &(m.coeffRef(0,0)); \
|
||||||
|
lda = convert_index<lapack_int>(m.outerStride()); \
|
||||||
|
\
|
||||||
|
info = LAPACKE_##LAPACKE_PREFIX##potrf( matrix_order, uplo, size, (BLASTYPE*)a, lda ); \
|
||||||
|
info = (info==0) ? -1 : info>0 ? info-1 : size; \
|
||||||
|
return info; \
|
||||||
|
} \
|
||||||
|
}; \
|
||||||
|
template<> struct llt_inplace<EIGTYPE, Lower> \
|
||||||
|
{ \
|
||||||
|
template<typename MatrixType> \
|
||||||
|
static Index blocked(MatrixType& m) \
|
||||||
|
{ \
|
||||||
|
return lapacke_llt<EIGTYPE>::potrf(m, 'L'); \
|
||||||
|
} \
|
||||||
|
template<typename MatrixType, typename VectorType> \
|
||||||
|
static Index rankUpdate(MatrixType& mat, const VectorType& vec, const typename MatrixType::RealScalar& sigma) \
|
||||||
|
{ return Eigen::internal::llt_rank_update_lower(mat, vec, sigma); } \
|
||||||
|
}; \
|
||||||
|
template<> struct llt_inplace<EIGTYPE, Upper> \
|
||||||
|
{ \
|
||||||
|
template<typename MatrixType> \
|
||||||
|
static Index blocked(MatrixType& m) \
|
||||||
|
{ \
|
||||||
|
return lapacke_llt<EIGTYPE>::potrf(m, 'U'); \
|
||||||
|
} \
|
||||||
|
template<typename MatrixType, typename VectorType> \
|
||||||
|
static Index rankUpdate(MatrixType& mat, const VectorType& vec, const typename MatrixType::RealScalar& sigma) \
|
||||||
|
{ \
|
||||||
|
Transpose<MatrixType> matt(mat); \
|
||||||
|
return llt_inplace<EIGTYPE, Lower>::rankUpdate(matt, vec.conjugate(), sigma); \
|
||||||
|
} \
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
EIGEN_LAPACKE_LLT(double, double, d)
|
||||||
struct rank_update<Upper> {
|
EIGEN_LAPACKE_LLT(float, float, s)
|
||||||
template <typename MatrixType, typename VectorType>
|
EIGEN_LAPACKE_LLT(dcomplex, lapack_complex_double, z)
|
||||||
static Index run(MatrixType &mat, const VectorType &vec, const typename MatrixType::RealScalar &sigma) {
|
EIGEN_LAPACKE_LLT(scomplex, lapack_complex_float, c)
|
||||||
Transpose<MatrixType> matt(mat);
|
|
||||||
return Eigen::internal::llt_rank_update_lower(matt, vec.conjugate(), sigma);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------------------------------
|
} // end namespace internal
|
||||||
// Generic lapacke llt implementation that hands of to the dispatches
|
|
||||||
// -------------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
template <typename Scalar, UpLoType Mode>
|
} // end namespace Eigen
|
||||||
struct lapacke_llt {
|
|
||||||
EIGEN_STATIC_ASSERT(((Mode == Lower) || (Mode == Upper)), MODE_MUST_BE_UPPER_OR_LOWER)
|
|
||||||
template <typename MatrixType>
|
|
||||||
static Index blocked(MatrixType &m) {
|
|
||||||
eigen_assert(m.rows() == m.cols());
|
|
||||||
if (m.rows() == 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
/* Set up parameters for ?potrf */
|
|
||||||
lapack_int size = to_lapack(m.rows());
|
|
||||||
lapack_int matrix_order = lapack_storage_of(m);
|
|
||||||
constexpr char uplo = Mode == Upper ? 'U' : 'L';
|
|
||||||
Scalar *a = &(m.coeffRef(0, 0));
|
|
||||||
lapack_int lda = to_lapack(m.outerStride());
|
|
||||||
|
|
||||||
lapack_int info = potrf(matrix_order, uplo, size, to_lapack(a), lda);
|
#endif // EIGEN_LLT_LAPACKE_H
|
||||||
info = (info == 0) ? -1 : info > 0 ? info - 1 : size;
|
|
||||||
return info;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename MatrixType, typename VectorType>
|
|
||||||
static Index rankUpdate(MatrixType &mat, const VectorType &vec, const typename MatrixType::RealScalar &sigma) {
|
|
||||||
return rank_update<Mode>::run(mat, vec, sigma);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} // namespace lapacke_helpers
|
|
||||||
// end namespace lapacke_helpers
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Here, we just put the generic implementation from lapacke_llt into a full specialization of the llt_inplace
|
|
||||||
* type. By being a full specialization, the versions defined here thus get precedence over the generic implementation
|
|
||||||
* in LLT.h for double, float and complex double, complex float types.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define EIGEN_LAPACKE_LLT(EIGTYPE) \
|
|
||||||
template <> \
|
|
||||||
struct llt_inplace<EIGTYPE, Lower> : public lapacke_helpers::lapacke_llt<EIGTYPE, Lower> {}; \
|
|
||||||
template <> \
|
|
||||||
struct llt_inplace<EIGTYPE, Upper> : public lapacke_helpers::lapacke_llt<EIGTYPE, Upper> {};
|
|
||||||
|
|
||||||
EIGEN_LAPACKE_LLT(double)
|
|
||||||
EIGEN_LAPACKE_LLT(float)
|
|
||||||
EIGEN_LAPACKE_LLT(std::complex<double>)
|
|
||||||
EIGEN_LAPACKE_LLT(std::complex<float>)
|
|
||||||
|
|
||||||
#undef EIGEN_LAPACKE_LLT
|
|
||||||
|
|
||||||
} // end namespace internal
|
|
||||||
|
|
||||||
} // end namespace Eigen
|
|
||||||
|
|
||||||
#endif // EIGEN_LLT_LAPACKE_H
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,3 +0,0 @@
|
|||||||
#ifndef EIGEN_CHOLMODSUPPORT_MODULE_H
|
|
||||||
#error "Please include Eigen/CholmodSupport instead of including headers inside the src directory directly."
|
|
||||||
#endif
|
|
||||||
@@ -10,202 +10,367 @@
|
|||||||
#ifndef EIGEN_ARITHMETIC_SEQUENCE_H
|
#ifndef EIGEN_ARITHMETIC_SEQUENCE_H
|
||||||
#define EIGEN_ARITHMETIC_SEQUENCE_H
|
#define EIGEN_ARITHMETIC_SEQUENCE_H
|
||||||
|
|
||||||
// IWYU pragma: private
|
|
||||||
#include "./InternalHeaderCheck.h"
|
|
||||||
|
|
||||||
namespace Eigen {
|
namespace Eigen {
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
// Helper to cleanup the type of the increment:
|
#if (!EIGEN_HAS_CXX11) || !((!EIGEN_COMP_GNUC) || EIGEN_COMP_GNUC>=48)
|
||||||
template <typename T>
|
template<typename T> struct aseq_negate {};
|
||||||
struct cleanup_seq_incr {
|
|
||||||
typedef typename cleanup_index_type<T, DynamicIndex>::type type;
|
template<> struct aseq_negate<Index> {
|
||||||
|
typedef Index type;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace internal
|
template<int N> struct aseq_negate<FixedInt<N> > {
|
||||||
|
typedef FixedInt<-N> type;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Compilation error in the following case:
|
||||||
|
template<> struct aseq_negate<FixedInt<DynamicIndex> > {};
|
||||||
|
|
||||||
|
template<typename FirstType,typename SizeType,typename IncrType,
|
||||||
|
bool FirstIsSymbolic=symbolic::is_symbolic<FirstType>::value,
|
||||||
|
bool SizeIsSymbolic =symbolic::is_symbolic<SizeType>::value>
|
||||||
|
struct aseq_reverse_first_type {
|
||||||
|
typedef Index type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename FirstType,typename SizeType,typename IncrType>
|
||||||
|
struct aseq_reverse_first_type<FirstType,SizeType,IncrType,true,true> {
|
||||||
|
typedef symbolic::AddExpr<FirstType,
|
||||||
|
symbolic::ProductExpr<symbolic::AddExpr<SizeType,symbolic::ValueExpr<FixedInt<-1> > >,
|
||||||
|
symbolic::ValueExpr<IncrType> >
|
||||||
|
> type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename SizeType,typename IncrType,typename EnableIf = void>
|
||||||
|
struct aseq_reverse_first_type_aux {
|
||||||
|
typedef Index type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename SizeType,typename IncrType>
|
||||||
|
struct aseq_reverse_first_type_aux<SizeType,IncrType,typename internal::enable_if<bool((SizeType::value+IncrType::value)|0x1)>::type> {
|
||||||
|
typedef FixedInt<(SizeType::value-1)*IncrType::value> type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename FirstType,typename SizeType,typename IncrType>
|
||||||
|
struct aseq_reverse_first_type<FirstType,SizeType,IncrType,true,false> {
|
||||||
|
typedef typename aseq_reverse_first_type_aux<SizeType,IncrType>::type Aux;
|
||||||
|
typedef symbolic::AddExpr<FirstType,symbolic::ValueExpr<Aux> > type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename FirstType,typename SizeType,typename IncrType>
|
||||||
|
struct aseq_reverse_first_type<FirstType,SizeType,IncrType,false,true> {
|
||||||
|
typedef symbolic::AddExpr<symbolic::ProductExpr<symbolic::AddExpr<SizeType,symbolic::ValueExpr<FixedInt<-1> > >,
|
||||||
|
symbolic::ValueExpr<IncrType> >,
|
||||||
|
symbolic::ValueExpr<> > type;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Helper to cleanup the type of the increment:
|
||||||
|
template<typename T> struct cleanup_seq_incr {
|
||||||
|
typedef typename cleanup_index_type<T,DynamicIndex>::type type;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------
|
||||||
// seq(first,last,incr) and seqN(first,size,incr)
|
// seq(first,last,incr) and seqN(first,size,incr)
|
||||||
//--------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
template <typename FirstType = Index, typename SizeType = Index, typename IncrType = internal::FixedInt<1> >
|
template<typename FirstType=Index,typename SizeType=Index,typename IncrType=internal::FixedInt<1> >
|
||||||
class ArithmeticSequence;
|
class ArithmeticSequence;
|
||||||
|
|
||||||
template <typename FirstType, typename SizeType, typename IncrType>
|
template<typename FirstType,typename SizeType,typename IncrType>
|
||||||
ArithmeticSequence<typename internal::cleanup_index_type<FirstType>::type,
|
ArithmeticSequence<typename internal::cleanup_index_type<FirstType>::type,
|
||||||
typename internal::cleanup_index_type<SizeType>::type,
|
typename internal::cleanup_index_type<SizeType>::type,
|
||||||
typename internal::cleanup_seq_incr<IncrType>::type>
|
typename internal::cleanup_seq_incr<IncrType>::type >
|
||||||
seqN(FirstType first, SizeType size, IncrType incr);
|
seqN(FirstType first, SizeType size, IncrType incr);
|
||||||
|
|
||||||
/** \class ArithmeticSequence
|
/** \class ArithmeticSequence
|
||||||
* \ingroup Core_Module
|
* \ingroup Core_Module
|
||||||
*
|
*
|
||||||
* This class represents an arithmetic progression \f$ a_0, a_1, a_2, ..., a_{n-1}\f$ defined by
|
* This class represents an arithmetic progression \f$ a_0, a_1, a_2, ..., a_{n-1}\f$ defined by
|
||||||
* its \em first value \f$ a_0 \f$, its \em size (aka length) \em n, and the \em increment (aka stride)
|
* its \em first value \f$ a_0 \f$, its \em size (aka length) \em n, and the \em increment (aka stride)
|
||||||
* that is equal to \f$ a_{i+1}-a_{i}\f$ for any \em i.
|
* that is equal to \f$ a_{i+1}-a_{i}\f$ for any \em i.
|
||||||
*
|
*
|
||||||
* It is internally used as the return type of the Eigen::seq and Eigen::seqN functions, and as the input arguments
|
* It is internally used as the return type of the Eigen::seq and Eigen::seqN functions, and as the input arguments
|
||||||
* of DenseBase::operator()(const RowIndices&, const ColIndices&), and most of the time this is the
|
* of DenseBase::operator()(const RowIndices&, const ColIndices&), and most of the time this is the
|
||||||
* only way it is used.
|
* only way it is used.
|
||||||
*
|
*
|
||||||
* \tparam FirstType type of the first element, usually an Index,
|
* \tparam FirstType type of the first element, usually an Index,
|
||||||
* but internally it can be a symbolic expression
|
* but internally it can be a symbolic expression
|
||||||
* \tparam SizeType type representing the size of the sequence, usually an Index
|
* \tparam SizeType type representing the size of the sequence, usually an Index
|
||||||
* or a compile time integral constant. Internally, it can also be a symbolic expression
|
* or a compile time integral constant. Internally, it can also be a symbolic expression
|
||||||
* \tparam IncrType type of the increment, can be a runtime Index, or a compile time integral constant (default is
|
* \tparam IncrType type of the increment, can be a runtime Index, or a compile time integral constant (default is compile-time 1)
|
||||||
* compile-time 1)
|
*
|
||||||
*
|
* \sa Eigen::seq, Eigen::seqN, DenseBase::operator()(const RowIndices&, const ColIndices&), class IndexedView
|
||||||
* \sa Eigen::seq, Eigen::seqN, DenseBase::operator()(const RowIndices&, const ColIndices&), class IndexedView
|
*/
|
||||||
*/
|
template<typename FirstType,typename SizeType,typename IncrType>
|
||||||
template <typename FirstType, typename SizeType, typename IncrType>
|
class ArithmeticSequence
|
||||||
class ArithmeticSequence {
|
{
|
||||||
public:
|
public:
|
||||||
constexpr ArithmeticSequence() = default;
|
ArithmeticSequence(FirstType first, SizeType size) : m_first(first), m_size(size) {}
|
||||||
constexpr ArithmeticSequence(FirstType first, SizeType size) : m_first(first), m_size(size) {}
|
ArithmeticSequence(FirstType first, SizeType size, IncrType incr) : m_first(first), m_size(size), m_incr(incr) {}
|
||||||
constexpr ArithmeticSequence(FirstType first, SizeType size, IncrType incr)
|
|
||||||
: m_first(first), m_size(size), m_incr(incr) {}
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
// SizeAtCompileTime = internal::get_fixed_value<SizeType>::value,
|
SizeAtCompileTime = internal::get_fixed_value<SizeType>::value,
|
||||||
IncrAtCompileTime = internal::get_fixed_value<IncrType, DynamicIndex>::value
|
IncrAtCompileTime = internal::get_fixed_value<IncrType,DynamicIndex>::value
|
||||||
};
|
};
|
||||||
|
|
||||||
/** \returns the size, i.e., number of elements, of the sequence */
|
/** \returns the size, i.e., number of elements, of the sequence */
|
||||||
constexpr Index size() const { return m_size; }
|
Index size() const { return m_size; }
|
||||||
|
|
||||||
/** \returns the first element \f$ a_0 \f$ in the sequence */
|
/** \returns the first element \f$ a_0 \f$ in the sequence */
|
||||||
constexpr Index first() const { return m_first; }
|
Index first() const { return m_first; }
|
||||||
|
|
||||||
/** \returns the value \f$ a_i \f$ at index \a i in the sequence. */
|
/** \returns the value \f$ a_i \f$ at index \a i in the sequence. */
|
||||||
constexpr Index operator[](Index i) const { return m_first + i * m_incr; }
|
Index operator[](Index i) const { return m_first + i * m_incr; }
|
||||||
|
|
||||||
constexpr const FirstType& firstObject() const { return m_first; }
|
const FirstType& firstObject() const { return m_first; }
|
||||||
constexpr const SizeType& sizeObject() const { return m_size; }
|
const SizeType& sizeObject() const { return m_size; }
|
||||||
constexpr const IncrType& incrObject() const { return m_incr; }
|
const IncrType& incrObject() const { return m_incr; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
FirstType m_first;
|
FirstType m_first;
|
||||||
SizeType m_size;
|
SizeType m_size;
|
||||||
IncrType m_incr;
|
IncrType m_incr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
constexpr auto reverse() const -> decltype(Eigen::seqN(m_first + (m_size + fix<-1>()) * m_incr, m_size, -m_incr)) {
|
|
||||||
return seqN(m_first + (m_size + fix<-1>()) * m_incr, m_size, -m_incr);
|
#if EIGEN_HAS_CXX11 && ((!EIGEN_COMP_GNUC) || EIGEN_COMP_GNUC>=48)
|
||||||
|
auto reverse() const -> decltype(Eigen::seqN(m_first+(m_size+fix<-1>())*m_incr,m_size,-m_incr)) {
|
||||||
|
return seqN(m_first+(m_size+fix<-1>())*m_incr,m_size,-m_incr);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
protected:
|
||||||
|
typedef typename internal::aseq_negate<IncrType>::type ReverseIncrType;
|
||||||
|
typedef typename internal::aseq_reverse_first_type<FirstType,SizeType,IncrType>::type ReverseFirstType;
|
||||||
|
public:
|
||||||
|
ArithmeticSequence<ReverseFirstType,SizeType,ReverseIncrType>
|
||||||
|
reverse() const {
|
||||||
|
return seqN(m_first+(m_size+fix<-1>())*m_incr,m_size,-m_incr);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/** \returns an ArithmeticSequence starting at \a first, of length \a size, and increment \a incr
|
/** \returns an ArithmeticSequence starting at \a first, of length \a size, and increment \a incr
|
||||||
*
|
*
|
||||||
* \sa seqN(FirstType,SizeType), seq(FirstType,LastType,IncrType) */
|
* \sa seqN(FirstType,SizeType), seq(FirstType,LastType,IncrType) */
|
||||||
template <typename FirstType, typename SizeType, typename IncrType>
|
template<typename FirstType,typename SizeType,typename IncrType>
|
||||||
ArithmeticSequence<typename internal::cleanup_index_type<FirstType>::type,
|
ArithmeticSequence<typename internal::cleanup_index_type<FirstType>::type,typename internal::cleanup_index_type<SizeType>::type,typename internal::cleanup_seq_incr<IncrType>::type >
|
||||||
typename internal::cleanup_index_type<SizeType>::type,
|
seqN(FirstType first, SizeType size, IncrType incr) {
|
||||||
typename internal::cleanup_seq_incr<IncrType>::type>
|
return ArithmeticSequence<typename internal::cleanup_index_type<FirstType>::type,typename internal::cleanup_index_type<SizeType>::type,typename internal::cleanup_seq_incr<IncrType>::type>(first,size,incr);
|
||||||
seqN(FirstType first, SizeType size, IncrType incr) {
|
|
||||||
return ArithmeticSequence<typename internal::cleanup_index_type<FirstType>::type,
|
|
||||||
typename internal::cleanup_index_type<SizeType>::type,
|
|
||||||
typename internal::cleanup_seq_incr<IncrType>::type>(first, size, incr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \returns an ArithmeticSequence starting at \a first, of length \a size, and unit increment
|
/** \returns an ArithmeticSequence starting at \a first, of length \a size, and unit increment
|
||||||
*
|
*
|
||||||
* \sa seqN(FirstType,SizeType,IncrType), seq(FirstType,LastType) */
|
* \sa seqN(FirstType,SizeType,IncrType), seq(FirstType,LastType) */
|
||||||
template <typename FirstType, typename SizeType>
|
template<typename FirstType,typename SizeType>
|
||||||
ArithmeticSequence<typename internal::cleanup_index_type<FirstType>::type,
|
ArithmeticSequence<typename internal::cleanup_index_type<FirstType>::type,typename internal::cleanup_index_type<SizeType>::type >
|
||||||
typename internal::cleanup_index_type<SizeType>::type>
|
seqN(FirstType first, SizeType size) {
|
||||||
seqN(FirstType first, SizeType size) {
|
return ArithmeticSequence<typename internal::cleanup_index_type<FirstType>::type,typename internal::cleanup_index_type<SizeType>::type>(first,size);
|
||||||
return ArithmeticSequence<typename internal::cleanup_index_type<FirstType>::type,
|
|
||||||
typename internal::cleanup_index_type<SizeType>::type>(first, size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef EIGEN_PARSED_BY_DOXYGEN
|
|
||||||
|
|
||||||
/** \returns an ArithmeticSequence starting at \a f, up (or down) to \a l, and with positive (or negative) increment \a
|
#if EIGEN_HAS_CXX11
|
||||||
* incr
|
|
||||||
*
|
/** \returns an ArithmeticSequence starting at \a f, up (or down) to \a l, and with positive (or negative) increment \a incr
|
||||||
* It is essentially an alias to:
|
*
|
||||||
* \code
|
* It is essentially an alias to:
|
||||||
* seqN(f, (l-f+incr)/incr, incr);
|
* \code
|
||||||
* \endcode
|
* seqN(f, (l-f+incr)/incr, incr);
|
||||||
*
|
* \endcode
|
||||||
* \sa seqN(FirstType,SizeType,IncrType), seq(FirstType,LastType)
|
*
|
||||||
*/
|
* \sa seqN(FirstType,SizeType,IncrType), seq(FirstType,LastType)
|
||||||
template <typename FirstType, typename LastType, typename IncrType>
|
*/
|
||||||
auto seq(FirstType f, LastType l, IncrType incr);
|
template<typename FirstType,typename LastType>
|
||||||
|
auto seq(FirstType f, LastType l) -> decltype(seqN(typename internal::cleanup_index_type<FirstType>::type(f),
|
||||||
|
( typename internal::cleanup_index_type<LastType>::type(l)
|
||||||
|
- typename internal::cleanup_index_type<FirstType>::type(f)+fix<1>())))
|
||||||
|
{
|
||||||
|
return seqN(typename internal::cleanup_index_type<FirstType>::type(f),
|
||||||
|
(typename internal::cleanup_index_type<LastType>::type(l)
|
||||||
|
-typename internal::cleanup_index_type<FirstType>::type(f)+fix<1>()));
|
||||||
|
}
|
||||||
|
|
||||||
/** \returns an ArithmeticSequence starting at \a f, up (or down) to \a l, and unit increment
|
/** \returns an ArithmeticSequence starting at \a f, up (or down) to \a l, and unit increment
|
||||||
*
|
*
|
||||||
* It is essentially an alias to:
|
* It is essentially an alias to:
|
||||||
* \code
|
* \code
|
||||||
* seqN(f,l-f+1);
|
* seqN(f,l-f+1);
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* \sa seqN(FirstType,SizeType), seq(FirstType,LastType,IncrType)
|
* \sa seqN(FirstType,SizeType), seq(FirstType,LastType,IncrType)
|
||||||
*/
|
*/
|
||||||
template <typename FirstType, typename LastType>
|
template<typename FirstType,typename LastType, typename IncrType>
|
||||||
auto seq(FirstType f, LastType l);
|
|
||||||
|
|
||||||
#else // EIGEN_PARSED_BY_DOXYGEN
|
|
||||||
|
|
||||||
template <typename FirstType, typename LastType>
|
|
||||||
auto seq(FirstType f, LastType l)
|
|
||||||
-> decltype(seqN(typename internal::cleanup_index_type<FirstType>::type(f),
|
|
||||||
(typename internal::cleanup_index_type<LastType>::type(l) -
|
|
||||||
typename internal::cleanup_index_type<FirstType>::type(f) + fix<1>()))) {
|
|
||||||
return seqN(typename internal::cleanup_index_type<FirstType>::type(f),
|
|
||||||
(typename internal::cleanup_index_type<LastType>::type(l) -
|
|
||||||
typename internal::cleanup_index_type<FirstType>::type(f) + fix<1>()));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename FirstType, typename LastType, typename IncrType>
|
|
||||||
auto seq(FirstType f, LastType l, IncrType incr)
|
auto seq(FirstType f, LastType l, IncrType incr)
|
||||||
-> decltype(seqN(typename internal::cleanup_index_type<FirstType>::type(f),
|
-> decltype(seqN(typename internal::cleanup_index_type<FirstType>::type(f),
|
||||||
(typename internal::cleanup_index_type<LastType>::type(l) -
|
( typename internal::cleanup_index_type<LastType>::type(l)
|
||||||
typename internal::cleanup_index_type<FirstType>::type(f) +
|
- typename internal::cleanup_index_type<FirstType>::type(f)+typename internal::cleanup_seq_incr<IncrType>::type(incr)
|
||||||
typename internal::cleanup_seq_incr<IncrType>::type(incr)) /
|
) / typename internal::cleanup_seq_incr<IncrType>::type(incr),
|
||||||
typename internal::cleanup_seq_incr<IncrType>::type(incr),
|
typename internal::cleanup_seq_incr<IncrType>::type(incr)))
|
||||||
typename internal::cleanup_seq_incr<IncrType>::type(incr))) {
|
{
|
||||||
typedef typename internal::cleanup_seq_incr<IncrType>::type CleanedIncrType;
|
typedef typename internal::cleanup_seq_incr<IncrType>::type CleanedIncrType;
|
||||||
return seqN(typename internal::cleanup_index_type<FirstType>::type(f),
|
return seqN(typename internal::cleanup_index_type<FirstType>::type(f),
|
||||||
(typename internal::cleanup_index_type<LastType>::type(l) -
|
( typename internal::cleanup_index_type<LastType>::type(l)
|
||||||
typename internal::cleanup_index_type<FirstType>::type(f) + CleanedIncrType(incr)) /
|
-typename internal::cleanup_index_type<FirstType>::type(f)+CleanedIncrType(incr)) / CleanedIncrType(incr),
|
||||||
CleanedIncrType(incr),
|
|
||||||
CleanedIncrType(incr));
|
CleanedIncrType(incr));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // EIGEN_PARSED_BY_DOXYGEN
|
#else // EIGEN_HAS_CXX11
|
||||||
|
|
||||||
namespace placeholders {
|
template<typename FirstType,typename LastType>
|
||||||
|
typename internal::enable_if<!(symbolic::is_symbolic<FirstType>::value || symbolic::is_symbolic<LastType>::value),
|
||||||
|
ArithmeticSequence<typename internal::cleanup_index_type<FirstType>::type,Index> >::type
|
||||||
|
seq(FirstType f, LastType l)
|
||||||
|
{
|
||||||
|
return seqN(typename internal::cleanup_index_type<FirstType>::type(f),
|
||||||
|
Index((typename internal::cleanup_index_type<LastType>::type(l)-typename internal::cleanup_index_type<FirstType>::type(f)+fix<1>())));
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename FirstTypeDerived,typename LastType>
|
||||||
|
typename internal::enable_if<!symbolic::is_symbolic<LastType>::value,
|
||||||
|
ArithmeticSequence<FirstTypeDerived, symbolic::AddExpr<symbolic::AddExpr<symbolic::NegateExpr<FirstTypeDerived>,symbolic::ValueExpr<> >,
|
||||||
|
symbolic::ValueExpr<internal::FixedInt<1> > > > >::type
|
||||||
|
seq(const symbolic::BaseExpr<FirstTypeDerived> &f, LastType l)
|
||||||
|
{
|
||||||
|
return seqN(f.derived(),(typename internal::cleanup_index_type<LastType>::type(l)-f.derived()+fix<1>()));
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename FirstType,typename LastTypeDerived>
|
||||||
|
typename internal::enable_if<!symbolic::is_symbolic<FirstType>::value,
|
||||||
|
ArithmeticSequence<typename internal::cleanup_index_type<FirstType>::type,
|
||||||
|
symbolic::AddExpr<symbolic::AddExpr<LastTypeDerived,symbolic::ValueExpr<> >,
|
||||||
|
symbolic::ValueExpr<internal::FixedInt<1> > > > >::type
|
||||||
|
seq(FirstType f, const symbolic::BaseExpr<LastTypeDerived> &l)
|
||||||
|
{
|
||||||
|
return seqN(typename internal::cleanup_index_type<FirstType>::type(f),(l.derived()-typename internal::cleanup_index_type<FirstType>::type(f)+fix<1>()));
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename FirstTypeDerived,typename LastTypeDerived>
|
||||||
|
ArithmeticSequence<FirstTypeDerived,
|
||||||
|
symbolic::AddExpr<symbolic::AddExpr<LastTypeDerived,symbolic::NegateExpr<FirstTypeDerived> >,symbolic::ValueExpr<internal::FixedInt<1> > > >
|
||||||
|
seq(const symbolic::BaseExpr<FirstTypeDerived> &f, const symbolic::BaseExpr<LastTypeDerived> &l)
|
||||||
|
{
|
||||||
|
return seqN(f.derived(),(l.derived()-f.derived()+fix<1>()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<typename FirstType,typename LastType, typename IncrType>
|
||||||
|
typename internal::enable_if<!(symbolic::is_symbolic<FirstType>::value || symbolic::is_symbolic<LastType>::value),
|
||||||
|
ArithmeticSequence<typename internal::cleanup_index_type<FirstType>::type,Index,typename internal::cleanup_seq_incr<IncrType>::type> >::type
|
||||||
|
seq(FirstType f, LastType l, IncrType incr)
|
||||||
|
{
|
||||||
|
typedef typename internal::cleanup_seq_incr<IncrType>::type CleanedIncrType;
|
||||||
|
return seqN(typename internal::cleanup_index_type<FirstType>::type(f),
|
||||||
|
Index((typename internal::cleanup_index_type<LastType>::type(l)-typename internal::cleanup_index_type<FirstType>::type(f)+CleanedIncrType(incr))/CleanedIncrType(incr)), incr);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename FirstTypeDerived,typename LastType, typename IncrType>
|
||||||
|
typename internal::enable_if<!symbolic::is_symbolic<LastType>::value,
|
||||||
|
ArithmeticSequence<FirstTypeDerived,
|
||||||
|
symbolic::QuotientExpr<symbolic::AddExpr<symbolic::AddExpr<symbolic::NegateExpr<FirstTypeDerived>,
|
||||||
|
symbolic::ValueExpr<> >,
|
||||||
|
symbolic::ValueExpr<typename internal::cleanup_seq_incr<IncrType>::type> >,
|
||||||
|
symbolic::ValueExpr<typename internal::cleanup_seq_incr<IncrType>::type> >,
|
||||||
|
typename internal::cleanup_seq_incr<IncrType>::type> >::type
|
||||||
|
seq(const symbolic::BaseExpr<FirstTypeDerived> &f, LastType l, IncrType incr)
|
||||||
|
{
|
||||||
|
typedef typename internal::cleanup_seq_incr<IncrType>::type CleanedIncrType;
|
||||||
|
return seqN(f.derived(),(typename internal::cleanup_index_type<LastType>::type(l)-f.derived()+CleanedIncrType(incr))/CleanedIncrType(incr), incr);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename FirstType,typename LastTypeDerived, typename IncrType>
|
||||||
|
typename internal::enable_if<!symbolic::is_symbolic<FirstType>::value,
|
||||||
|
ArithmeticSequence<typename internal::cleanup_index_type<FirstType>::type,
|
||||||
|
symbolic::QuotientExpr<symbolic::AddExpr<symbolic::AddExpr<LastTypeDerived,symbolic::ValueExpr<> >,
|
||||||
|
symbolic::ValueExpr<typename internal::cleanup_seq_incr<IncrType>::type> >,
|
||||||
|
symbolic::ValueExpr<typename internal::cleanup_seq_incr<IncrType>::type> >,
|
||||||
|
typename internal::cleanup_seq_incr<IncrType>::type> >::type
|
||||||
|
seq(FirstType f, const symbolic::BaseExpr<LastTypeDerived> &l, IncrType incr)
|
||||||
|
{
|
||||||
|
typedef typename internal::cleanup_seq_incr<IncrType>::type CleanedIncrType;
|
||||||
|
return seqN(typename internal::cleanup_index_type<FirstType>::type(f),
|
||||||
|
(l.derived()-typename internal::cleanup_index_type<FirstType>::type(f)+CleanedIncrType(incr))/CleanedIncrType(incr), incr);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename FirstTypeDerived,typename LastTypeDerived, typename IncrType>
|
||||||
|
ArithmeticSequence<FirstTypeDerived,
|
||||||
|
symbolic::QuotientExpr<symbolic::AddExpr<symbolic::AddExpr<LastTypeDerived,
|
||||||
|
symbolic::NegateExpr<FirstTypeDerived> >,
|
||||||
|
symbolic::ValueExpr<typename internal::cleanup_seq_incr<IncrType>::type> >,
|
||||||
|
symbolic::ValueExpr<typename internal::cleanup_seq_incr<IncrType>::type> >,
|
||||||
|
typename internal::cleanup_seq_incr<IncrType>::type>
|
||||||
|
seq(const symbolic::BaseExpr<FirstTypeDerived> &f, const symbolic::BaseExpr<LastTypeDerived> &l, IncrType incr)
|
||||||
|
{
|
||||||
|
typedef typename internal::cleanup_seq_incr<IncrType>::type CleanedIncrType;
|
||||||
|
return seqN(f.derived(),(l.derived()-f.derived()+CleanedIncrType(incr))/CleanedIncrType(incr), incr);
|
||||||
|
}
|
||||||
|
#endif // EIGEN_HAS_CXX11
|
||||||
|
|
||||||
|
#if EIGEN_HAS_CXX11
|
||||||
|
/** \cpp11
|
||||||
|
* \returns a symbolic ArithmeticSequence representing the last \a size elements with a unit increment.
|
||||||
|
*
|
||||||
|
* \anchor indexing_lastN
|
||||||
|
*
|
||||||
|
* It is a shortcut for: \code seq(last+fix<1>-size, last) \endcode
|
||||||
|
*
|
||||||
|
* \sa lastN(SizeType,IncrType, seqN(FirstType,SizeType), seq(FirstType,LastType) */
|
||||||
|
template<typename SizeType>
|
||||||
|
auto lastN(SizeType size)
|
||||||
|
-> decltype(seqN(Eigen::last+fix<1>()-size, size))
|
||||||
|
{
|
||||||
|
return seqN(Eigen::last+fix<1>()-size, size);
|
||||||
|
}
|
||||||
|
|
||||||
/** \cpp11
|
/** \cpp11
|
||||||
* \returns a symbolic ArithmeticSequence representing the last \a size elements with increment \a incr.
|
* \returns a symbolic ArithmeticSequence representing the last \a size elements with increment \a incr.
|
||||||
*
|
*
|
||||||
* It is a shortcut for: \code seqN(last-(size-fix<1>)*incr, size, incr) \endcode
|
* \anchor indexing_lastN_with_incr
|
||||||
* \anchor Eigen_placeholders_lastN
|
*
|
||||||
* \sa lastN(SizeType), seqN(FirstType,SizeType), seq(FirstType,LastType,IncrType) */
|
* It is a shortcut for: \code seqN(last-(size-fix<1>)*incr, size, incr) \endcode
|
||||||
template <typename SizeType, typename IncrType>
|
*
|
||||||
|
* \sa lastN(SizeType), seqN(FirstType,SizeType), seq(FirstType,LastType,IncrType) */
|
||||||
|
template<typename SizeType,typename IncrType>
|
||||||
auto lastN(SizeType size, IncrType incr)
|
auto lastN(SizeType size, IncrType incr)
|
||||||
-> decltype(seqN(Eigen::placeholders::last - (size - fix<1>()) * incr, size, incr)) {
|
-> decltype(seqN(Eigen::last-(size-fix<1>())*incr, size, incr))
|
||||||
return seqN(Eigen::placeholders::last - (size - fix<1>()) * incr, size, incr);
|
{
|
||||||
|
return seqN(Eigen::last-(size-fix<1>())*incr, size, incr);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace internal {
|
||||||
|
|
||||||
|
// Convert a symbolic span into a usable one (i.e., remove last/end "keywords")
|
||||||
|
template<typename T>
|
||||||
|
struct make_size_type {
|
||||||
|
typedef typename internal::conditional<symbolic::is_symbolic<T>::value, Index, T>::type type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename FirstType,typename SizeType,typename IncrType,int XprSize>
|
||||||
|
struct IndexedViewCompatibleType<ArithmeticSequence<FirstType,SizeType,IncrType>, XprSize> {
|
||||||
|
typedef ArithmeticSequence<Index,typename make_size_type<SizeType>::type,IncrType> type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename FirstType,typename SizeType,typename IncrType>
|
||||||
|
ArithmeticSequence<Index,typename make_size_type<SizeType>::type,IncrType>
|
||||||
|
makeIndexedViewCompatible(const ArithmeticSequence<FirstType,SizeType,IncrType>& ids, Index size,SpecializedType) {
|
||||||
|
return ArithmeticSequence<Index,typename make_size_type<SizeType>::type,IncrType>(
|
||||||
|
eval_expr_given_size(ids.firstObject(),size),eval_expr_given_size(ids.sizeObject(),size),ids.incrObject());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \cpp11
|
template<typename FirstType,typename SizeType,typename IncrType>
|
||||||
* \returns a symbolic ArithmeticSequence representing the last \a size elements with a unit increment.
|
struct get_compile_time_incr<ArithmeticSequence<FirstType,SizeType,IncrType> > {
|
||||||
*
|
enum { value = get_fixed_value<IncrType,DynamicIndex>::value };
|
||||||
* It is a shortcut for: \code seq(last+fix<1>-size, last) \endcode
|
};
|
||||||
*
|
|
||||||
* \sa lastN(SizeType,IncrType, seqN(FirstType,SizeType), seq(FirstType,LastType) */
|
|
||||||
template <typename SizeType>
|
|
||||||
auto lastN(SizeType size) -> decltype(seqN(Eigen::placeholders::last + fix<1>() - size, size)) {
|
|
||||||
return seqN(Eigen::placeholders::last + fix<1>() - size, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace placeholders
|
} // end namespace internal
|
||||||
|
|
||||||
/** \namespace Eigen::indexing
|
/** \namespace Eigen::indexing
|
||||||
* \ingroup Core_Module
|
* \ingroup Core_Module
|
||||||
*
|
*
|
||||||
* The sole purpose of this namespace is to be able to import all functions
|
* The sole purpose of this namespace is to be able to import all functions
|
||||||
* and symbols that are expected to be used within operator() for indexing
|
* and symbols that are expected to be used within operator() for indexing
|
||||||
* and slicing. If you already imported the whole Eigen namespace:
|
* and slicing. If you already imported the whole Eigen namespace:
|
||||||
@@ -215,25 +380,27 @@ auto lastN(SizeType size) -> decltype(seqN(Eigen::placeholders::last + fix<1>()
|
|||||||
* \code using namespace Eigen::indexing; \endcode
|
* \code using namespace Eigen::indexing; \endcode
|
||||||
* is equivalent to:
|
* is equivalent to:
|
||||||
* \code
|
* \code
|
||||||
using Eigen::fix;
|
using Eigen::all;
|
||||||
using Eigen::seq;
|
using Eigen::seq;
|
||||||
using Eigen::seqN;
|
using Eigen::seqN;
|
||||||
using Eigen::placeholders::all;
|
using Eigen::lastN; // c++11 only
|
||||||
using Eigen::placeholders::last;
|
using Eigen::last;
|
||||||
using Eigen::placeholders::lastN; // c++11 only
|
using Eigen::lastp1;
|
||||||
using Eigen::placeholders::lastp1;
|
using Eigen::fix;
|
||||||
\endcode
|
\endcode
|
||||||
*/
|
*/
|
||||||
namespace indexing {
|
namespace indexing {
|
||||||
using Eigen::fix;
|
using Eigen::all;
|
||||||
using Eigen::seq;
|
using Eigen::seq;
|
||||||
using Eigen::seqN;
|
using Eigen::seqN;
|
||||||
using Eigen::placeholders::all;
|
#if EIGEN_HAS_CXX11
|
||||||
using Eigen::placeholders::last;
|
using Eigen::lastN;
|
||||||
using Eigen::placeholders::lastN;
|
#endif
|
||||||
using Eigen::placeholders::lastp1;
|
using Eigen::last;
|
||||||
} // namespace indexing
|
using Eigen::lastp1;
|
||||||
|
using Eigen::fix;
|
||||||
|
}
|
||||||
|
|
||||||
} // end namespace Eigen
|
} // end namespace Eigen
|
||||||
|
|
||||||
#endif // EIGEN_ARITHMETIC_SEQUENCE_H
|
#endif // EIGEN_ARITHMETIC_SEQUENCE_H
|
||||||
|
|||||||
@@ -10,335 +10,384 @@
|
|||||||
#ifndef EIGEN_ARRAY_H
|
#ifndef EIGEN_ARRAY_H
|
||||||
#define EIGEN_ARRAY_H
|
#define EIGEN_ARRAY_H
|
||||||
|
|
||||||
// IWYU pragma: private
|
|
||||||
#include "./InternalHeaderCheck.h"
|
|
||||||
|
|
||||||
namespace Eigen {
|
namespace Eigen {
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
template <typename Scalar_, int Rows_, int Cols_, int Options_, int MaxRows_, int MaxCols_>
|
template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
|
||||||
struct traits<Array<Scalar_, Rows_, Cols_, Options_, MaxRows_, MaxCols_>>
|
struct traits<Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> > : traits<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> >
|
||||||
: traits<Matrix<Scalar_, Rows_, Cols_, Options_, MaxRows_, MaxCols_>> {
|
{
|
||||||
typedef ArrayXpr XprKind;
|
typedef ArrayXpr XprKind;
|
||||||
typedef ArrayBase<Array<Scalar_, Rows_, Cols_, Options_, MaxRows_, MaxCols_>> XprBase;
|
typedef ArrayBase<Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> > XprBase;
|
||||||
};
|
};
|
||||||
} // namespace internal
|
}
|
||||||
|
|
||||||
/** \class Array
|
/** \class Array
|
||||||
* \ingroup Core_Module
|
* \ingroup Core_Module
|
||||||
*
|
*
|
||||||
* \brief General-purpose arrays with easy API for coefficient-wise operations
|
* \brief General-purpose arrays with easy API for coefficient-wise operations
|
||||||
*
|
*
|
||||||
* The %Array class is very similar to the Matrix class. It provides
|
* The %Array class is very similar to the Matrix class. It provides
|
||||||
* general-purpose one- and two-dimensional arrays. The difference between the
|
* general-purpose one- and two-dimensional arrays. The difference between the
|
||||||
* %Array and the %Matrix class is primarily in the API: the API for the
|
* %Array and the %Matrix class is primarily in the API: the API for the
|
||||||
* %Array class provides easy access to coefficient-wise operations, while the
|
* %Array class provides easy access to coefficient-wise operations, while the
|
||||||
* API for the %Matrix class provides easy access to linear-algebra
|
* API for the %Matrix class provides easy access to linear-algebra
|
||||||
* operations.
|
* operations.
|
||||||
*
|
*
|
||||||
* See documentation of class Matrix for detailed information on the template parameters
|
* See documentation of class Matrix for detailed information on the template parameters
|
||||||
* storage layout.
|
* storage layout.
|
||||||
*
|
*
|
||||||
* This class can be extended with the help of the plugin mechanism described on the page
|
* This class can be extended with the help of the plugin mechanism described on the page
|
||||||
* \ref TopicCustomizing_Plugins by defining the preprocessor symbol \c EIGEN_ARRAY_PLUGIN.
|
* \ref TopicCustomizing_Plugins by defining the preprocessor symbol \c EIGEN_ARRAY_PLUGIN.
|
||||||
*
|
*
|
||||||
* \sa \blank \ref TutorialArrayClass, \ref TopicClassHierarchy
|
* \sa \blank \ref TutorialArrayClass, \ref TopicClassHierarchy
|
||||||
*/
|
*/
|
||||||
template <typename Scalar_, int Rows_, int Cols_, int Options_, int MaxRows_, int MaxCols_>
|
template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
|
||||||
class Array : public PlainObjectBase<Array<Scalar_, Rows_, Cols_, Options_, MaxRows_, MaxCols_>> {
|
class Array
|
||||||
public:
|
: public PlainObjectBase<Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> >
|
||||||
typedef PlainObjectBase<Array> Base;
|
{
|
||||||
EIGEN_DENSE_PUBLIC_INTERFACE(Array)
|
public:
|
||||||
|
|
||||||
enum { Options = Options_ };
|
typedef PlainObjectBase<Array> Base;
|
||||||
typedef typename Base::PlainObject PlainObject;
|
EIGEN_DENSE_PUBLIC_INTERFACE(Array)
|
||||||
|
|
||||||
protected:
|
enum { Options = _Options };
|
||||||
template <typename Derived, typename OtherDerived, bool IsVector>
|
typedef typename Base::PlainObject PlainObject;
|
||||||
friend struct internal::conservative_resize_like_impl;
|
|
||||||
|
|
||||||
using Base::m_storage;
|
protected:
|
||||||
|
template <typename Derived, typename OtherDerived, bool IsVector>
|
||||||
|
friend struct internal::conservative_resize_like_impl;
|
||||||
|
|
||||||
public:
|
using Base::m_storage;
|
||||||
using Base::base;
|
|
||||||
using Base::coeff;
|
|
||||||
using Base::coeffRef;
|
|
||||||
|
|
||||||
/**
|
public:
|
||||||
* The usage of
|
|
||||||
* using Base::operator=;
|
|
||||||
* fails on MSVC. Since the code below is working with GCC and MSVC, we skipped
|
|
||||||
* the usage of 'using'. This should be done only for operator=.
|
|
||||||
*/
|
|
||||||
template <typename OtherDerived>
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Array& operator=(const EigenBase<OtherDerived>& other) {
|
|
||||||
return Base::operator=(other);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Set all the entries to \a value.
|
using Base::base;
|
||||||
* \sa DenseBase::setConstant(), DenseBase::fill()
|
using Base::coeff;
|
||||||
*/
|
using Base::coeffRef;
|
||||||
/* This overload is needed because the usage of
|
|
||||||
* using Base::operator=;
|
|
||||||
* fails on MSVC. Since the code below is working with GCC and MSVC, we skipped
|
|
||||||
* the usage of 'using'. This should be done only for operator=.
|
|
||||||
*/
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Array& operator=(const Scalar& value) {
|
|
||||||
Base::setConstant(value);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Copies the value of the expression \a other into \c *this with automatic resizing.
|
/**
|
||||||
*
|
* The usage of
|
||||||
* *this might be resized to match the dimensions of \a other. If *this was a null matrix (not already initialized),
|
* using Base::operator=;
|
||||||
* it will be initialized.
|
* fails on MSVC. Since the code below is working with GCC and MSVC, we skipped
|
||||||
*
|
* the usage of 'using'. This should be done only for operator=.
|
||||||
* Note that copying a row-vector into a vector (and conversely) is allowed.
|
*/
|
||||||
* The resizing, if any, is then done in the appropriate way so that row-vectors
|
template<typename OtherDerived>
|
||||||
* remain row-vectors and vectors remain vectors.
|
EIGEN_DEVICE_FUNC
|
||||||
*/
|
EIGEN_STRONG_INLINE Array& operator=(const EigenBase<OtherDerived> &other)
|
||||||
template <typename OtherDerived>
|
{
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Array& operator=(const DenseBase<OtherDerived>& other) {
|
return Base::operator=(other);
|
||||||
return Base::_set(other);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/** Set all the entries to \a value.
|
||||||
* \brief Assigns arrays to each other.
|
* \sa DenseBase::setConstant(), DenseBase::fill()
|
||||||
*
|
*/
|
||||||
* \note This is a special case of the templated operator=. Its purpose is
|
/* This overload is needed because the usage of
|
||||||
* to prevent a default operator= from hiding the templated operator=.
|
* using Base::operator=;
|
||||||
*
|
* fails on MSVC. Since the code below is working with GCC and MSVC, we skipped
|
||||||
* \callgraph
|
* the usage of 'using'. This should be done only for operator=.
|
||||||
*/
|
*/
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Array& operator=(const Array& other) { return Base::_set(other); }
|
EIGEN_DEVICE_FUNC
|
||||||
|
EIGEN_STRONG_INLINE Array& operator=(const Scalar &value)
|
||||||
|
{
|
||||||
|
Base::setConstant(value);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
/** Default constructor.
|
/** Copies the value of the expression \a other into \c *this with automatic resizing.
|
||||||
*
|
*
|
||||||
* For fixed-size matrices, does nothing.
|
* *this might be resized to match the dimensions of \a other. If *this was a null matrix (not already initialized),
|
||||||
*
|
* it will be initialized.
|
||||||
* For dynamic-size matrices, creates an empty matrix of size 0. Does not allocate any array. Such a matrix
|
*
|
||||||
* is called a null matrix. This constructor is the unique way to create null matrices: resizing
|
* Note that copying a row-vector into a vector (and conversely) is allowed.
|
||||||
* a matrix to 0 is not supported.
|
* The resizing, if any, is then done in the appropriate way so that row-vectors
|
||||||
*
|
* remain row-vectors and vectors remain vectors.
|
||||||
* \sa resize(Index,Index)
|
*/
|
||||||
*/
|
template<typename OtherDerived>
|
||||||
#ifdef EIGEN_INITIALIZE_COEFFS
|
EIGEN_DEVICE_FUNC
|
||||||
EIGEN_DEVICE_FUNC constexpr Array() : Base() { EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED }
|
EIGEN_STRONG_INLINE Array& operator=(const DenseBase<OtherDerived>& other)
|
||||||
#else
|
{
|
||||||
EIGEN_DEVICE_FUNC constexpr Array() = default;
|
return Base::_set(other);
|
||||||
#endif
|
}
|
||||||
/** \brief Move constructor */
|
|
||||||
EIGEN_DEVICE_FUNC constexpr Array(Array&&) = default;
|
|
||||||
EIGEN_DEVICE_FUNC Array& operator=(Array&& other) noexcept(std::is_nothrow_move_assignable<Scalar>::value) {
|
|
||||||
Base::operator=(std::move(other));
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** \brief Construct a row of column vector with fixed size from an arbitrary number of coefficients.
|
/** This is a special case of the templated operator=. Its purpose is to
|
||||||
*
|
* prevent a default operator= from hiding the templated operator=.
|
||||||
* \only_for_vectors
|
*/
|
||||||
*
|
EIGEN_DEVICE_FUNC
|
||||||
* This constructor is for 1D array or vectors with more than 4 coefficients.
|
EIGEN_STRONG_INLINE Array& operator=(const Array& other)
|
||||||
*
|
{
|
||||||
* \warning To construct a column (resp. row) vector of fixed length, the number of values passed to this
|
return Base::_set(other);
|
||||||
* constructor must match the fixed number of rows (resp. columns) of \c *this.
|
}
|
||||||
*
|
|
||||||
*
|
|
||||||
* Example: \include Array_variadic_ctor_cxx11.cpp
|
|
||||||
* Output: \verbinclude Array_variadic_ctor_cxx11.out
|
|
||||||
*
|
|
||||||
* \sa Array(const std::initializer_list<std::initializer_list<Scalar>>&)
|
|
||||||
* \sa Array(const Scalar&), Array(const Scalar&,const Scalar&)
|
|
||||||
*/
|
|
||||||
template <typename... ArgTypes>
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Array(const Scalar& a0, const Scalar& a1, const Scalar& a2, const Scalar& a3,
|
|
||||||
const ArgTypes&... args)
|
|
||||||
: Base(a0, a1, a2, a3, args...) {}
|
|
||||||
|
|
||||||
/** \brief Constructs an array and initializes it from the coefficients given as initializer-lists grouped by row.
|
/** Default constructor.
|
||||||
* \cpp11
|
*
|
||||||
*
|
* For fixed-size matrices, does nothing.
|
||||||
* In the general case, the constructor takes a list of rows, each row being represented as a list of coefficients:
|
*
|
||||||
*
|
* For dynamic-size matrices, creates an empty matrix of size 0. Does not allocate any array. Such a matrix
|
||||||
* Example: \include Array_initializer_list_23_cxx11.cpp
|
* is called a null matrix. This constructor is the unique way to create null matrices: resizing
|
||||||
* Output: \verbinclude Array_initializer_list_23_cxx11.out
|
* a matrix to 0 is not supported.
|
||||||
*
|
*
|
||||||
* Each of the inner initializer lists must contain the exact same number of elements, otherwise an assertion is
|
* \sa resize(Index,Index)
|
||||||
* triggered.
|
*/
|
||||||
*
|
EIGEN_DEVICE_FUNC
|
||||||
* In the case of a compile-time column 1D array, implicit transposition from a single row is allowed.
|
EIGEN_STRONG_INLINE Array() : Base()
|
||||||
* Therefore <code> Array<int,Dynamic,1>{{1,2,3,4,5}}</code> is legal and the more verbose syntax
|
{
|
||||||
* <code>Array<int,Dynamic,1>{{1},{2},{3},{4},{5}}</code> can be avoided:
|
Base::_check_template_params();
|
||||||
*
|
EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
|
||||||
* Example: \include Array_initializer_list_vector_cxx11.cpp
|
}
|
||||||
* Output: \verbinclude Array_initializer_list_vector_cxx11.out
|
|
||||||
*
|
|
||||||
* In the case of fixed-sized arrays, the initializer list sizes must exactly match the array sizes,
|
|
||||||
* and implicit transposition is allowed for compile-time 1D arrays only.
|
|
||||||
*
|
|
||||||
* \sa Array(const Scalar& a0, const Scalar& a1, const Scalar& a2, const Scalar& a3, const ArgTypes&... args)
|
|
||||||
*/
|
|
||||||
EIGEN_DEVICE_FUNC constexpr Array(const std::initializer_list<std::initializer_list<Scalar>>& list) : Base(list) {}
|
|
||||||
|
|
||||||
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
||||||
template <typename T>
|
// FIXME is it still needed ??
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit Array(const T& x) {
|
/** \internal */
|
||||||
Base::template _init1<T>(x);
|
EIGEN_DEVICE_FUNC
|
||||||
}
|
Array(internal::constructor_without_unaligned_array_assert)
|
||||||
|
: Base(internal::constructor_without_unaligned_array_assert())
|
||||||
template <typename T0, typename T1>
|
{
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Array(const T0& val0, const T1& val1) {
|
Base::_check_template_params();
|
||||||
this->template _init2<T0, T1>(val0, val1);
|
EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
|
||||||
/** \brief Constructs a fixed-sized array initialized with coefficients starting at \a data */
|
|
||||||
EIGEN_DEVICE_FUNC explicit Array(const Scalar* data);
|
|
||||||
/** Constructs a vector or row-vector with given dimension. \only_for_vectors
|
|
||||||
*
|
|
||||||
* Note that this is only useful for dynamic-size vectors. For fixed-size vectors,
|
|
||||||
* it is redundant to pass the dimension here, so it makes more sense to use the default
|
|
||||||
* constructor Array() instead.
|
|
||||||
*/
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit Array(Index dim);
|
|
||||||
/** constructs an initialized 1x1 Array with the given coefficient
|
|
||||||
* \sa const Scalar& a0, const Scalar& a1, const Scalar& a2, const Scalar& a3, const ArgTypes&... args */
|
|
||||||
Array(const Scalar& value);
|
|
||||||
/** constructs an uninitialized array with \a rows rows and \a cols columns.
|
|
||||||
*
|
|
||||||
* This is useful for dynamic-size arrays. For fixed-size arrays,
|
|
||||||
* it is redundant to pass these parameters, so one should use the default constructor
|
|
||||||
* Array() instead. */
|
|
||||||
Array(Index rows, Index cols);
|
|
||||||
/** constructs an initialized 2D vector with given coefficients
|
|
||||||
* \sa Array(const Scalar& a0, const Scalar& a1, const Scalar& a2, const Scalar& a3, const ArgTypes&... args) */
|
|
||||||
Array(const Scalar& val0, const Scalar& val1);
|
|
||||||
#endif // end EIGEN_PARSED_BY_DOXYGEN
|
|
||||||
|
|
||||||
/** constructs an initialized 3D vector with given coefficients
|
|
||||||
* \sa Array(const Scalar& a0, const Scalar& a1, const Scalar& a2, const Scalar& a3, const ArgTypes&... args)
|
|
||||||
*/
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Array(const Scalar& val0, const Scalar& val1, const Scalar& val2) {
|
|
||||||
EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Array, 3)
|
|
||||||
m_storage.data()[0] = val0;
|
|
||||||
m_storage.data()[1] = val1;
|
|
||||||
m_storage.data()[2] = val2;
|
|
||||||
}
|
|
||||||
/** constructs an initialized 4D vector with given coefficients
|
|
||||||
* \sa Array(const Scalar& a0, const Scalar& a1, const Scalar& a2, const Scalar& a3, const ArgTypes&... args)
|
|
||||||
*/
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Array(const Scalar& val0, const Scalar& val1, const Scalar& val2,
|
|
||||||
const Scalar& val3) {
|
|
||||||
EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Array, 4)
|
|
||||||
m_storage.data()[0] = val0;
|
|
||||||
m_storage.data()[1] = val1;
|
|
||||||
m_storage.data()[2] = val2;
|
|
||||||
m_storage.data()[3] = val3;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Copy constructor */
|
|
||||||
EIGEN_DEVICE_FUNC constexpr Array(const Array&) = default;
|
|
||||||
|
|
||||||
private:
|
|
||||||
struct PrivateType {};
|
|
||||||
|
|
||||||
public:
|
|
||||||
/** \sa MatrixBase::operator=(const EigenBase<OtherDerived>&) */
|
|
||||||
template <typename OtherDerived>
|
|
||||||
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Array(
|
|
||||||
const EigenBase<OtherDerived>& other,
|
|
||||||
std::enable_if_t<internal::is_convertible<typename OtherDerived::Scalar, Scalar>::value, PrivateType> =
|
|
||||||
PrivateType())
|
|
||||||
: Base(other.derived()) {}
|
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC constexpr Index innerStride() const noexcept { return 1; }
|
|
||||||
EIGEN_DEVICE_FUNC constexpr Index outerStride() const noexcept { return this->innerSize(); }
|
|
||||||
|
|
||||||
#ifdef EIGEN_ARRAY_PLUGIN
|
|
||||||
#include EIGEN_ARRAY_PLUGIN
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
#if EIGEN_HAS_RVALUE_REFERENCES
|
||||||
template <typename MatrixType, typename OtherDerived, bool SwapPointers>
|
EIGEN_DEVICE_FUNC
|
||||||
friend struct internal::matrix_swap_impl;
|
Array(Array&& other) EIGEN_NOEXCEPT_IF(std::is_nothrow_move_constructible<Scalar>::value)
|
||||||
|
: Base(std::move(other))
|
||||||
|
{
|
||||||
|
Base::_check_template_params();
|
||||||
|
}
|
||||||
|
EIGEN_DEVICE_FUNC
|
||||||
|
Array& operator=(Array&& other) EIGEN_NOEXCEPT_IF(std::is_nothrow_move_assignable<Scalar>::value)
|
||||||
|
{
|
||||||
|
Base::operator=(std::move(other));
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if EIGEN_HAS_CXX11
|
||||||
|
/** \brief Construct a row of column vector with fixed size from an arbitrary number of coefficients. \cpp11
|
||||||
|
*
|
||||||
|
* \only_for_vectors
|
||||||
|
*
|
||||||
|
* This constructor is for 1D array or vectors with more than 4 coefficients.
|
||||||
|
* There exists C++98 analogue constructors for fixed-size array/vector having 1, 2, 3, or 4 coefficients.
|
||||||
|
*
|
||||||
|
* \warning To construct a column (resp. row) vector of fixed length, the number of values passed to this
|
||||||
|
* constructor must match the the fixed number of rows (resp. columns) of \c *this.
|
||||||
|
*
|
||||||
|
* Example: \include Array_variadic_ctor_cxx11.cpp
|
||||||
|
* Output: \verbinclude Array_variadic_ctor_cxx11.out
|
||||||
|
*
|
||||||
|
* \sa Array(const std::initializer_list<std::initializer_list<Scalar>>&)
|
||||||
|
* \sa Array(const Scalar&), Array(const Scalar&,const Scalar&)
|
||||||
|
*/
|
||||||
|
template <typename... ArgTypes>
|
||||||
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||||
|
Array(const Scalar& a0, const Scalar& a1, const Scalar& a2, const Scalar& a3, const ArgTypes&... args)
|
||||||
|
: Base(a0, a1, a2, a3, args...) {}
|
||||||
|
|
||||||
|
/** \brief Constructs an array and initializes it from the coefficients given as initializer-lists grouped by row. \cpp11
|
||||||
|
*
|
||||||
|
* In the general case, the constructor takes a list of rows, each row being represented as a list of coefficients:
|
||||||
|
*
|
||||||
|
* Example: \include Array_initializer_list_23_cxx11.cpp
|
||||||
|
* Output: \verbinclude Array_initializer_list_23_cxx11.out
|
||||||
|
*
|
||||||
|
* Each of the inner initializer lists must contain the exact same number of elements, otherwise an assertion is triggered.
|
||||||
|
*
|
||||||
|
* In the case of a compile-time column 1D array, implicit transposition from a single row is allowed.
|
||||||
|
* Therefore <code> Array<int,Dynamic,1>{{1,2,3,4,5}}</code> is legal and the more verbose syntax
|
||||||
|
* <code>Array<int,Dynamic,1>{{1},{2},{3},{4},{5}}</code> can be avoided:
|
||||||
|
*
|
||||||
|
* Example: \include Array_initializer_list_vector_cxx11.cpp
|
||||||
|
* Output: \verbinclude Array_initializer_list_vector_cxx11.out
|
||||||
|
*
|
||||||
|
* In the case of fixed-sized arrays, the initializer list sizes must exactly match the array sizes,
|
||||||
|
* and implicit transposition is allowed for compile-time 1D arrays only.
|
||||||
|
*
|
||||||
|
* \sa Array(const Scalar& a0, const Scalar& a1, const Scalar& a2, const Scalar& a3, const ArgTypes&... args)
|
||||||
|
*/
|
||||||
|
EIGEN_DEVICE_FUNC
|
||||||
|
EIGEN_STRONG_INLINE Array(const std::initializer_list<std::initializer_list<Scalar>>& list) : Base(list) {}
|
||||||
|
#endif // end EIGEN_HAS_CXX11
|
||||||
|
|
||||||
|
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
||||||
|
template<typename T>
|
||||||
|
EIGEN_DEVICE_FUNC
|
||||||
|
EIGEN_STRONG_INLINE explicit Array(const T& x)
|
||||||
|
{
|
||||||
|
Base::_check_template_params();
|
||||||
|
Base::template _init1<T>(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T0, typename T1>
|
||||||
|
EIGEN_DEVICE_FUNC
|
||||||
|
EIGEN_STRONG_INLINE Array(const T0& val0, const T1& val1)
|
||||||
|
{
|
||||||
|
Base::_check_template_params();
|
||||||
|
this->template _init2<T0,T1>(val0, val1);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
/** \brief Constructs a fixed-sized array initialized with coefficients starting at \a data */
|
||||||
|
EIGEN_DEVICE_FUNC explicit Array(const Scalar *data);
|
||||||
|
/** Constructs a vector or row-vector with given dimension. \only_for_vectors
|
||||||
|
*
|
||||||
|
* Note that this is only useful for dynamic-size vectors. For fixed-size vectors,
|
||||||
|
* it is redundant to pass the dimension here, so it makes more sense to use the default
|
||||||
|
* constructor Array() instead.
|
||||||
|
*/
|
||||||
|
EIGEN_DEVICE_FUNC
|
||||||
|
EIGEN_STRONG_INLINE explicit Array(Index dim);
|
||||||
|
/** constructs an initialized 1x1 Array with the given coefficient
|
||||||
|
* \sa const Scalar& a0, const Scalar& a1, const Scalar& a2, const Scalar& a3, const ArgTypes&... args */
|
||||||
|
Array(const Scalar& value);
|
||||||
|
/** constructs an uninitialized array with \a rows rows and \a cols columns.
|
||||||
|
*
|
||||||
|
* This is useful for dynamic-size arrays. For fixed-size arrays,
|
||||||
|
* it is redundant to pass these parameters, so one should use the default constructor
|
||||||
|
* Array() instead. */
|
||||||
|
Array(Index rows, Index cols);
|
||||||
|
/** constructs an initialized 2D vector with given coefficients
|
||||||
|
* \sa Array(const Scalar& a0, const Scalar& a1, const Scalar& a2, const Scalar& a3, const ArgTypes&... args) */
|
||||||
|
Array(const Scalar& val0, const Scalar& val1);
|
||||||
|
#endif // end EIGEN_PARSED_BY_DOXYGEN
|
||||||
|
|
||||||
|
/** constructs an initialized 3D vector with given coefficients
|
||||||
|
* \sa Array(const Scalar& a0, const Scalar& a1, const Scalar& a2, const Scalar& a3, const ArgTypes&... args)
|
||||||
|
*/
|
||||||
|
EIGEN_DEVICE_FUNC
|
||||||
|
EIGEN_STRONG_INLINE Array(const Scalar& val0, const Scalar& val1, const Scalar& val2)
|
||||||
|
{
|
||||||
|
Base::_check_template_params();
|
||||||
|
EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Array, 3)
|
||||||
|
m_storage.data()[0] = val0;
|
||||||
|
m_storage.data()[1] = val1;
|
||||||
|
m_storage.data()[2] = val2;
|
||||||
|
}
|
||||||
|
/** constructs an initialized 4D vector with given coefficients
|
||||||
|
* \sa Array(const Scalar& a0, const Scalar& a1, const Scalar& a2, const Scalar& a3, const ArgTypes&... args)
|
||||||
|
*/
|
||||||
|
EIGEN_DEVICE_FUNC
|
||||||
|
EIGEN_STRONG_INLINE Array(const Scalar& val0, const Scalar& val1, const Scalar& val2, const Scalar& val3)
|
||||||
|
{
|
||||||
|
Base::_check_template_params();
|
||||||
|
EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Array, 4)
|
||||||
|
m_storage.data()[0] = val0;
|
||||||
|
m_storage.data()[1] = val1;
|
||||||
|
m_storage.data()[2] = val2;
|
||||||
|
m_storage.data()[3] = val3;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Copy constructor */
|
||||||
|
EIGEN_DEVICE_FUNC
|
||||||
|
EIGEN_STRONG_INLINE Array(const Array& other)
|
||||||
|
: Base(other)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct PrivateType {};
|
||||||
|
public:
|
||||||
|
|
||||||
|
/** \sa MatrixBase::operator=(const EigenBase<OtherDerived>&) */
|
||||||
|
template<typename OtherDerived>
|
||||||
|
EIGEN_DEVICE_FUNC
|
||||||
|
EIGEN_STRONG_INLINE Array(const EigenBase<OtherDerived> &other,
|
||||||
|
typename internal::enable_if<internal::is_convertible<typename OtherDerived::Scalar,Scalar>::value,
|
||||||
|
PrivateType>::type = PrivateType())
|
||||||
|
: Base(other.derived())
|
||||||
|
{ }
|
||||||
|
|
||||||
|
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
|
||||||
|
inline Index innerStride() const EIGEN_NOEXCEPT{ return 1; }
|
||||||
|
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
|
||||||
|
inline Index outerStride() const EIGEN_NOEXCEPT { return this->innerSize(); }
|
||||||
|
|
||||||
|
#ifdef EIGEN_ARRAY_PLUGIN
|
||||||
|
#include EIGEN_ARRAY_PLUGIN
|
||||||
|
#endif
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
template<typename MatrixType, typename OtherDerived, bool SwapPointers>
|
||||||
|
friend struct internal::matrix_swap_impl;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** \defgroup arraytypedefs Global array typedefs
|
/** \defgroup arraytypedefs Global array typedefs
|
||||||
* \ingroup Core_Module
|
* \ingroup Core_Module
|
||||||
*
|
*
|
||||||
* %Eigen defines several typedef shortcuts for most common 1D and 2D array types.
|
* %Eigen defines several typedef shortcuts for most common 1D and 2D array types.
|
||||||
*
|
*
|
||||||
* The general patterns are the following:
|
* The general patterns are the following:
|
||||||
*
|
*
|
||||||
* \c ArrayRowsColsType where \c Rows and \c Cols can be \c 2,\c 3,\c 4 for fixed size square matrices or \c X for
|
* \c ArrayRowsColsType where \c Rows and \c Cols can be \c 2,\c 3,\c 4 for fixed size square matrices or \c X for dynamic size,
|
||||||
* dynamic size, and where \c Type can be \c i for integer, \c f for float, \c d for double, \c cf for complex float, \c
|
* and where \c Type can be \c i for integer, \c f for float, \c d for double, \c cf for complex float, \c cd
|
||||||
* cd for complex double.
|
* for complex double.
|
||||||
*
|
*
|
||||||
* For example, \c Array33d is a fixed-size 3x3 array type of doubles, and \c ArrayXXf is a dynamic-size matrix of
|
* For example, \c Array33d is a fixed-size 3x3 array type of doubles, and \c ArrayXXf is a dynamic-size matrix of floats.
|
||||||
* floats.
|
*
|
||||||
*
|
* There are also \c ArraySizeType which are self-explanatory. For example, \c Array4cf is
|
||||||
* There are also \c ArraySizeType which are self-explanatory. For example, \c Array4cf is
|
* a fixed-size 1D array of 4 complex floats.
|
||||||
* a fixed-size 1D array of 4 complex floats.
|
*
|
||||||
*
|
* With \cpp11, template alias are also defined for common sizes.
|
||||||
* With \cpp11, template alias are also defined for common sizes.
|
* They follow the same pattern as above except that the scalar type suffix is replaced by a
|
||||||
* They follow the same pattern as above except that the scalar type suffix is replaced by a
|
* template parameter, i.e.:
|
||||||
* template parameter, i.e.:
|
* - `ArrayRowsCols<Type>` where `Rows` and `Cols` can be \c 2,\c 3,\c 4, or \c X for fixed or dynamic size.
|
||||||
* - `ArrayRowsCols<Type>` where `Rows` and `Cols` can be \c 2,\c 3,\c 4, or \c X for fixed or dynamic size.
|
* - `ArraySize<Type>` where `Size` can be \c 2,\c 3,\c 4 or \c X for fixed or dynamic size 1D arrays.
|
||||||
* - `ArraySize<Type>` where `Size` can be \c 2,\c 3,\c 4 or \c X for fixed or dynamic size 1D arrays.
|
*
|
||||||
*
|
* \sa class Array
|
||||||
* \sa class Array
|
*/
|
||||||
*/
|
|
||||||
|
|
||||||
#define EIGEN_MAKE_ARRAY_TYPEDEFS(Type, TypeSuffix, Size, SizeSuffix) \
|
#define EIGEN_MAKE_ARRAY_TYPEDEFS(Type, TypeSuffix, Size, SizeSuffix) \
|
||||||
/** \ingroup arraytypedefs */ \
|
/** \ingroup arraytypedefs */ \
|
||||||
typedef Array<Type, Size, Size> Array##SizeSuffix##SizeSuffix##TypeSuffix; \
|
typedef Array<Type, Size, Size> Array##SizeSuffix##SizeSuffix##TypeSuffix; \
|
||||||
/** \ingroup arraytypedefs */ \
|
/** \ingroup arraytypedefs */ \
|
||||||
typedef Array<Type, Size, 1> Array##SizeSuffix##TypeSuffix;
|
typedef Array<Type, Size, 1> Array##SizeSuffix##TypeSuffix;
|
||||||
|
|
||||||
#define EIGEN_MAKE_ARRAY_FIXED_TYPEDEFS(Type, TypeSuffix, Size) \
|
#define EIGEN_MAKE_ARRAY_FIXED_TYPEDEFS(Type, TypeSuffix, Size) \
|
||||||
/** \ingroup arraytypedefs */ \
|
/** \ingroup arraytypedefs */ \
|
||||||
typedef Array<Type, Size, Dynamic> Array##Size##X##TypeSuffix; \
|
typedef Array<Type, Size, Dynamic> Array##Size##X##TypeSuffix; \
|
||||||
/** \ingroup arraytypedefs */ \
|
/** \ingroup arraytypedefs */ \
|
||||||
typedef Array<Type, Dynamic, Size> Array##X##Size##TypeSuffix;
|
typedef Array<Type, Dynamic, Size> Array##X##Size##TypeSuffix;
|
||||||
|
|
||||||
#define EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES(Type, TypeSuffix) \
|
#define EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES(Type, TypeSuffix) \
|
||||||
EIGEN_MAKE_ARRAY_TYPEDEFS(Type, TypeSuffix, 2, 2) \
|
EIGEN_MAKE_ARRAY_TYPEDEFS(Type, TypeSuffix, 2, 2) \
|
||||||
EIGEN_MAKE_ARRAY_TYPEDEFS(Type, TypeSuffix, 3, 3) \
|
EIGEN_MAKE_ARRAY_TYPEDEFS(Type, TypeSuffix, 3, 3) \
|
||||||
EIGEN_MAKE_ARRAY_TYPEDEFS(Type, TypeSuffix, 4, 4) \
|
EIGEN_MAKE_ARRAY_TYPEDEFS(Type, TypeSuffix, 4, 4) \
|
||||||
EIGEN_MAKE_ARRAY_TYPEDEFS(Type, TypeSuffix, Dynamic, X) \
|
EIGEN_MAKE_ARRAY_TYPEDEFS(Type, TypeSuffix, Dynamic, X) \
|
||||||
EIGEN_MAKE_ARRAY_FIXED_TYPEDEFS(Type, TypeSuffix, 2) \
|
EIGEN_MAKE_ARRAY_FIXED_TYPEDEFS(Type, TypeSuffix, 2) \
|
||||||
EIGEN_MAKE_ARRAY_FIXED_TYPEDEFS(Type, TypeSuffix, 3) \
|
EIGEN_MAKE_ARRAY_FIXED_TYPEDEFS(Type, TypeSuffix, 3) \
|
||||||
EIGEN_MAKE_ARRAY_FIXED_TYPEDEFS(Type, TypeSuffix, 4)
|
EIGEN_MAKE_ARRAY_FIXED_TYPEDEFS(Type, TypeSuffix, 4)
|
||||||
|
|
||||||
EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES(int, i)
|
EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES(int, i)
|
||||||
EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES(float, f)
|
EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES(float, f)
|
||||||
EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES(double, d)
|
EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES(double, d)
|
||||||
EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES(std::complex<float>, cf)
|
EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES(std::complex<float>, cf)
|
||||||
EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES(std::complex<double>, cd)
|
EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES(std::complex<double>, cd)
|
||||||
|
|
||||||
#undef EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES
|
#undef EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES
|
||||||
#undef EIGEN_MAKE_ARRAY_TYPEDEFS
|
#undef EIGEN_MAKE_ARRAY_TYPEDEFS
|
||||||
#undef EIGEN_MAKE_ARRAY_FIXED_TYPEDEFS
|
#undef EIGEN_MAKE_ARRAY_FIXED_TYPEDEFS
|
||||||
|
|
||||||
#define EIGEN_MAKE_ARRAY_TYPEDEFS(Size, SizeSuffix) \
|
#if EIGEN_HAS_CXX11
|
||||||
/** \ingroup arraytypedefs */ \
|
|
||||||
/** \brief \cpp11 */ \
|
|
||||||
template <typename Type> \
|
|
||||||
using Array##SizeSuffix##SizeSuffix = Array<Type, Size, Size>; \
|
|
||||||
/** \ingroup arraytypedefs */ \
|
|
||||||
/** \brief \cpp11 */ \
|
|
||||||
template <typename Type> \
|
|
||||||
using Array##SizeSuffix = Array<Type, Size, 1>;
|
|
||||||
|
|
||||||
#define EIGEN_MAKE_ARRAY_FIXED_TYPEDEFS(Size) \
|
#define EIGEN_MAKE_ARRAY_TYPEDEFS(Size, SizeSuffix) \
|
||||||
/** \ingroup arraytypedefs */ \
|
/** \ingroup arraytypedefs */ \
|
||||||
/** \brief \cpp11 */ \
|
/** \brief \cpp11 */ \
|
||||||
template <typename Type> \
|
template <typename Type> \
|
||||||
using Array##Size##X = Array<Type, Size, Dynamic>; \
|
using Array##SizeSuffix##SizeSuffix = Array<Type, Size, Size>; \
|
||||||
/** \ingroup arraytypedefs */ \
|
/** \ingroup arraytypedefs */ \
|
||||||
/** \brief \cpp11 */ \
|
/** \brief \cpp11 */ \
|
||||||
template <typename Type> \
|
template <typename Type> \
|
||||||
using Array##X##Size = Array<Type, Dynamic, Size>;
|
using Array##SizeSuffix = Array<Type, Size, 1>;
|
||||||
|
|
||||||
|
#define EIGEN_MAKE_ARRAY_FIXED_TYPEDEFS(Size) \
|
||||||
|
/** \ingroup arraytypedefs */ \
|
||||||
|
/** \brief \cpp11 */ \
|
||||||
|
template <typename Type> \
|
||||||
|
using Array##Size##X = Array<Type, Size, Dynamic>; \
|
||||||
|
/** \ingroup arraytypedefs */ \
|
||||||
|
/** \brief \cpp11 */ \
|
||||||
|
template <typename Type> \
|
||||||
|
using Array##X##Size = Array<Type, Dynamic, Size>;
|
||||||
|
|
||||||
EIGEN_MAKE_ARRAY_TYPEDEFS(2, 2)
|
EIGEN_MAKE_ARRAY_TYPEDEFS(2, 2)
|
||||||
EIGEN_MAKE_ARRAY_TYPEDEFS(3, 3)
|
EIGEN_MAKE_ARRAY_TYPEDEFS(3, 3)
|
||||||
@@ -351,24 +400,26 @@ EIGEN_MAKE_ARRAY_FIXED_TYPEDEFS(4)
|
|||||||
#undef EIGEN_MAKE_ARRAY_TYPEDEFS
|
#undef EIGEN_MAKE_ARRAY_TYPEDEFS
|
||||||
#undef EIGEN_MAKE_ARRAY_FIXED_TYPEDEFS
|
#undef EIGEN_MAKE_ARRAY_FIXED_TYPEDEFS
|
||||||
|
|
||||||
|
#endif // EIGEN_HAS_CXX11
|
||||||
|
|
||||||
#define EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, SizeSuffix) \
|
#define EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, SizeSuffix) \
|
||||||
using Eigen::Matrix##SizeSuffix##TypeSuffix; \
|
using Eigen::Matrix##SizeSuffix##TypeSuffix; \
|
||||||
using Eigen::Vector##SizeSuffix##TypeSuffix; \
|
using Eigen::Vector##SizeSuffix##TypeSuffix; \
|
||||||
using Eigen::RowVector##SizeSuffix##TypeSuffix;
|
using Eigen::RowVector##SizeSuffix##TypeSuffix;
|
||||||
|
|
||||||
#define EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE(TypeSuffix) \
|
#define EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE(TypeSuffix) \
|
||||||
EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 2) \
|
EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 2) \
|
||||||
EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 3) \
|
EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 3) \
|
||||||
EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 4) \
|
EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 4) \
|
||||||
EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, X)
|
EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, X) \
|
||||||
|
|
||||||
#define EIGEN_USING_ARRAY_TYPEDEFS \
|
#define EIGEN_USING_ARRAY_TYPEDEFS \
|
||||||
EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE(i) \
|
EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE(i) \
|
||||||
EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE(f) \
|
EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE(f) \
|
||||||
EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE(d) \
|
EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE(d) \
|
||||||
EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE(cf) \
|
EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE(cf) \
|
||||||
EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE(cd)
|
EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE(cd)
|
||||||
|
|
||||||
} // end namespace Eigen
|
} // end namespace Eigen
|
||||||
|
|
||||||
#endif // EIGEN_ARRAY_H
|
#endif // EIGEN_ARRAY_H
|
||||||
|
|||||||
@@ -10,201 +10,217 @@
|
|||||||
#ifndef EIGEN_ARRAYBASE_H
|
#ifndef EIGEN_ARRAYBASE_H
|
||||||
#define EIGEN_ARRAYBASE_H
|
#define EIGEN_ARRAYBASE_H
|
||||||
|
|
||||||
// IWYU pragma: private
|
namespace Eigen {
|
||||||
#include "./InternalHeaderCheck.h"
|
|
||||||
|
|
||||||
namespace Eigen {
|
template<typename ExpressionType> class MatrixWrapper;
|
||||||
|
|
||||||
template <typename ExpressionType>
|
|
||||||
class MatrixWrapper;
|
|
||||||
|
|
||||||
/** \class ArrayBase
|
/** \class ArrayBase
|
||||||
* \ingroup Core_Module
|
* \ingroup Core_Module
|
||||||
*
|
*
|
||||||
* \brief Base class for all 1D and 2D array, and related expressions
|
* \brief Base class for all 1D and 2D array, and related expressions
|
||||||
*
|
*
|
||||||
* An array is similar to a dense vector or matrix. While matrices are mathematical
|
* An array is similar to a dense vector or matrix. While matrices are mathematical
|
||||||
* objects with well defined linear algebra operators, an array is just a collection
|
* objects with well defined linear algebra operators, an array is just a collection
|
||||||
* of scalar values arranged in a one or two dimensional fashion. As the main consequence,
|
* of scalar values arranged in a one or two dimensionnal fashion. As the main consequence,
|
||||||
* all operations applied to an array are performed coefficient wise. Furthermore,
|
* all operations applied to an array are performed coefficient wise. Furthermore,
|
||||||
* arrays support scalar math functions of the c++ standard library (e.g., std::sin(x)), and convenient
|
* arrays support scalar math functions of the c++ standard library (e.g., std::sin(x)), and convenient
|
||||||
* constructors allowing to easily write generic code working for both scalar values
|
* constructors allowing to easily write generic code working for both scalar values
|
||||||
* and arrays.
|
* and arrays.
|
||||||
*
|
*
|
||||||
* This class is the base that is inherited by all array expression types.
|
* This class is the base that is inherited by all array expression types.
|
||||||
*
|
*
|
||||||
* \tparam Derived is the derived type, e.g., an array or an expression type.
|
* \tparam Derived is the derived type, e.g., an array or an expression type.
|
||||||
*
|
*
|
||||||
* This class can be extended with the help of the plugin mechanism described on the page
|
* This class can be extended with the help of the plugin mechanism described on the page
|
||||||
* \ref TopicCustomizing_Plugins by defining the preprocessor symbol \c EIGEN_ARRAYBASE_PLUGIN.
|
* \ref TopicCustomizing_Plugins by defining the preprocessor symbol \c EIGEN_ARRAYBASE_PLUGIN.
|
||||||
*
|
*
|
||||||
* \sa class MatrixBase, \ref TopicClassHierarchy
|
* \sa class MatrixBase, \ref TopicClassHierarchy
|
||||||
*/
|
*/
|
||||||
template <typename Derived>
|
template<typename Derived> class ArrayBase
|
||||||
class ArrayBase : public DenseBase<Derived> {
|
: public DenseBase<Derived>
|
||||||
public:
|
{
|
||||||
|
public:
|
||||||
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
||||||
/** The base class for a given storage type. */
|
/** The base class for a given storage type. */
|
||||||
typedef ArrayBase StorageBaseType;
|
typedef ArrayBase StorageBaseType;
|
||||||
|
|
||||||
typedef ArrayBase Eigen_BaseClassForSpecializationOfGlobalMathFuncImpl;
|
typedef ArrayBase Eigen_BaseClassForSpecializationOfGlobalMathFuncImpl;
|
||||||
|
|
||||||
typedef typename internal::traits<Derived>::StorageKind StorageKind;
|
typedef typename internal::traits<Derived>::StorageKind StorageKind;
|
||||||
typedef typename internal::traits<Derived>::Scalar Scalar;
|
typedef typename internal::traits<Derived>::Scalar Scalar;
|
||||||
typedef typename internal::packet_traits<Scalar>::type PacketScalar;
|
typedef typename internal::packet_traits<Scalar>::type PacketScalar;
|
||||||
typedef typename NumTraits<Scalar>::Real RealScalar;
|
typedef typename NumTraits<Scalar>::Real RealScalar;
|
||||||
|
|
||||||
typedef DenseBase<Derived> Base;
|
typedef DenseBase<Derived> Base;
|
||||||
using Base::ColsAtCompileTime;
|
using Base::RowsAtCompileTime;
|
||||||
using Base::Flags;
|
using Base::ColsAtCompileTime;
|
||||||
using Base::IsVectorAtCompileTime;
|
using Base::SizeAtCompileTime;
|
||||||
using Base::MaxColsAtCompileTime;
|
using Base::MaxRowsAtCompileTime;
|
||||||
using Base::MaxRowsAtCompileTime;
|
using Base::MaxColsAtCompileTime;
|
||||||
using Base::MaxSizeAtCompileTime;
|
using Base::MaxSizeAtCompileTime;
|
||||||
using Base::RowsAtCompileTime;
|
using Base::IsVectorAtCompileTime;
|
||||||
using Base::SizeAtCompileTime;
|
using Base::Flags;
|
||||||
|
|
||||||
|
using Base::derived;
|
||||||
|
using Base::const_cast_derived;
|
||||||
|
using Base::rows;
|
||||||
|
using Base::cols;
|
||||||
|
using Base::size;
|
||||||
|
using Base::coeff;
|
||||||
|
using Base::coeffRef;
|
||||||
|
using Base::lazyAssign;
|
||||||
|
using Base::operator-;
|
||||||
|
using Base::operator=;
|
||||||
|
using Base::operator+=;
|
||||||
|
using Base::operator-=;
|
||||||
|
using Base::operator*=;
|
||||||
|
using Base::operator/=;
|
||||||
|
|
||||||
using Base::coeff;
|
typedef typename Base::CoeffReturnType CoeffReturnType;
|
||||||
using Base::coeffRef;
|
|
||||||
using Base::cols;
|
|
||||||
using Base::const_cast_derived;
|
|
||||||
using Base::derived;
|
|
||||||
using Base::lazyAssign;
|
|
||||||
using Base::rows;
|
|
||||||
using Base::size;
|
|
||||||
using Base::operator-;
|
|
||||||
using Base::operator=;
|
|
||||||
using Base::operator+=;
|
|
||||||
using Base::operator-=;
|
|
||||||
using Base::operator*=;
|
|
||||||
using Base::operator/=;
|
|
||||||
|
|
||||||
typedef typename Base::CoeffReturnType CoeffReturnType;
|
#endif // not EIGEN_PARSED_BY_DOXYGEN
|
||||||
|
|
||||||
typedef typename Base::PlainObject PlainObject;
|
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
||||||
|
typedef typename Base::PlainObject PlainObject;
|
||||||
|
|
||||||
/** \internal Represents a matrix with all coefficients equal to one another*/
|
/** \internal Represents a matrix with all coefficients equal to one another*/
|
||||||
typedef CwiseNullaryOp<internal::scalar_constant_op<Scalar>, PlainObject> ConstantReturnType;
|
typedef CwiseNullaryOp<internal::scalar_constant_op<Scalar>,PlainObject> ConstantReturnType;
|
||||||
#endif // not EIGEN_PARSED_BY_DOXYGEN
|
#endif // not EIGEN_PARSED_BY_DOXYGEN
|
||||||
|
|
||||||
#define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::ArrayBase
|
#define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::ArrayBase
|
||||||
#define EIGEN_DOC_UNARY_ADDONS(X, Y)
|
#define EIGEN_DOC_UNARY_ADDONS(X,Y)
|
||||||
#include "../plugins/MatrixCwiseUnaryOps.inc"
|
# include "../plugins/MatrixCwiseUnaryOps.h"
|
||||||
#include "../plugins/ArrayCwiseUnaryOps.inc"
|
# include "../plugins/ArrayCwiseUnaryOps.h"
|
||||||
#include "../plugins/CommonCwiseBinaryOps.inc"
|
# include "../plugins/CommonCwiseBinaryOps.h"
|
||||||
#include "../plugins/MatrixCwiseBinaryOps.inc"
|
# include "../plugins/MatrixCwiseBinaryOps.h"
|
||||||
#include "../plugins/ArrayCwiseBinaryOps.inc"
|
# include "../plugins/ArrayCwiseBinaryOps.h"
|
||||||
#ifdef EIGEN_ARRAYBASE_PLUGIN
|
# ifdef EIGEN_ARRAYBASE_PLUGIN
|
||||||
#include EIGEN_ARRAYBASE_PLUGIN
|
# include EIGEN_ARRAYBASE_PLUGIN
|
||||||
#endif
|
# endif
|
||||||
#undef EIGEN_CURRENT_STORAGE_BASE_CLASS
|
#undef EIGEN_CURRENT_STORAGE_BASE_CLASS
|
||||||
#undef EIGEN_DOC_UNARY_ADDONS
|
#undef EIGEN_DOC_UNARY_ADDONS
|
||||||
|
|
||||||
/** Special case of the template operator=, in order to prevent the compiler
|
/** Special case of the template operator=, in order to prevent the compiler
|
||||||
* from generating a default operator= (issue hit with g++ 4.1)
|
* from generating a default operator= (issue hit with g++ 4.1)
|
||||||
*/
|
*/
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator=(const ArrayBase& other) {
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||||
internal::call_assignment(derived(), other.derived());
|
Derived& operator=(const ArrayBase& other)
|
||||||
return derived();
|
{
|
||||||
}
|
internal::call_assignment(derived(), other.derived());
|
||||||
|
return derived();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Set all the entries to \a value.
|
||||||
|
* \sa DenseBase::setConstant(), DenseBase::fill() */
|
||||||
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||||
|
Derived& operator=(const Scalar &value)
|
||||||
|
{ Base::setConstant(value); return derived(); }
|
||||||
|
|
||||||
/** Set all the entries to \a value.
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||||
* \sa DenseBase::setConstant(), DenseBase::fill() */
|
Derived& operator+=(const Scalar& scalar);
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator=(const Scalar& value) {
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||||
Base::setConstant(value);
|
Derived& operator-=(const Scalar& scalar);
|
||||||
return derived();
|
|
||||||
}
|
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator+=(const Scalar& other) {
|
template<typename OtherDerived>
|
||||||
internal::call_assignment(this->derived(), PlainObject::Constant(rows(), cols(), other),
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||||
internal::add_assign_op<Scalar, Scalar>());
|
Derived& operator+=(const ArrayBase<OtherDerived>& other);
|
||||||
return derived();
|
template<typename OtherDerived>
|
||||||
}
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||||
|
Derived& operator-=(const ArrayBase<OtherDerived>& other);
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator-=(const Scalar& other) {
|
template<typename OtherDerived>
|
||||||
internal::call_assignment(this->derived(), PlainObject::Constant(rows(), cols(), other),
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||||
internal::sub_assign_op<Scalar, Scalar>());
|
Derived& operator*=(const ArrayBase<OtherDerived>& other);
|
||||||
return derived();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** replaces \c *this by \c *this + \a other.
|
template<typename OtherDerived>
|
||||||
*
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||||
* \returns a reference to \c *this
|
Derived& operator/=(const ArrayBase<OtherDerived>& other);
|
||||||
*/
|
|
||||||
template <typename OtherDerived>
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator+=(const ArrayBase<OtherDerived>& other) {
|
|
||||||
call_assignment(derived(), other.derived(), internal::add_assign_op<Scalar, typename OtherDerived::Scalar>());
|
|
||||||
return derived();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** replaces \c *this by \c *this - \a other.
|
public:
|
||||||
*
|
EIGEN_DEVICE_FUNC
|
||||||
* \returns a reference to \c *this
|
ArrayBase<Derived>& array() { return *this; }
|
||||||
*/
|
EIGEN_DEVICE_FUNC
|
||||||
template <typename OtherDerived>
|
const ArrayBase<Derived>& array() const { return *this; }
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator-=(const ArrayBase<OtherDerived>& other) {
|
|
||||||
call_assignment(derived(), other.derived(), internal::sub_assign_op<Scalar, typename OtherDerived::Scalar>());
|
|
||||||
return derived();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** replaces \c *this by \c *this * \a other coefficient wise.
|
/** \returns an \link Eigen::MatrixBase Matrix \endlink expression of this array
|
||||||
*
|
* \sa MatrixBase::array() */
|
||||||
* \returns a reference to \c *this
|
EIGEN_DEVICE_FUNC
|
||||||
*/
|
MatrixWrapper<Derived> matrix() { return MatrixWrapper<Derived>(derived()); }
|
||||||
template <typename OtherDerived>
|
EIGEN_DEVICE_FUNC
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator*=(const ArrayBase<OtherDerived>& other) {
|
const MatrixWrapper<const Derived> matrix() const { return MatrixWrapper<const Derived>(derived()); }
|
||||||
call_assignment(derived(), other.derived(), internal::mul_assign_op<Scalar, typename OtherDerived::Scalar>());
|
|
||||||
return derived();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** replaces \c *this by \c *this / \a other coefficient wise.
|
// template<typename Dest>
|
||||||
*
|
// inline void evalTo(Dest& dst) const { dst = matrix(); }
|
||||||
* \returns a reference to \c *this
|
|
||||||
*/
|
|
||||||
template <typename OtherDerived>
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator/=(const ArrayBase<OtherDerived>& other) {
|
|
||||||
call_assignment(derived(), other.derived(), internal::div_assign_op<Scalar, typename OtherDerived::Scalar>());
|
|
||||||
return derived();
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
protected:
|
||||||
EIGEN_DEVICE_FUNC constexpr ArrayBase<Derived>& array() { return *this; }
|
EIGEN_DEFAULT_COPY_CONSTRUCTOR(ArrayBase)
|
||||||
EIGEN_DEVICE_FUNC constexpr const ArrayBase<Derived>& array() const { return *this; }
|
EIGEN_DEFAULT_EMPTY_CONSTRUCTOR_AND_DESTRUCTOR(ArrayBase)
|
||||||
|
|
||||||
/** \returns an \link Eigen::MatrixBase Matrix \endlink expression of this array
|
private:
|
||||||
* \sa MatrixBase::array() */
|
explicit ArrayBase(Index);
|
||||||
EIGEN_DEVICE_FUNC constexpr MatrixWrapper<Derived> matrix() { return MatrixWrapper<Derived>(derived()); }
|
ArrayBase(Index,Index);
|
||||||
EIGEN_DEVICE_FUNC constexpr const MatrixWrapper<const Derived> matrix() const {
|
template<typename OtherDerived> explicit ArrayBase(const ArrayBase<OtherDerived>&);
|
||||||
return MatrixWrapper<const Derived>(derived());
|
protected:
|
||||||
}
|
// mixing arrays and matrices is not legal
|
||||||
|
template<typename OtherDerived> Derived& operator+=(const MatrixBase<OtherDerived>& )
|
||||||
protected:
|
{EIGEN_STATIC_ASSERT(std::ptrdiff_t(sizeof(typename OtherDerived::Scalar))==-1,YOU_CANNOT_MIX_ARRAYS_AND_MATRICES); return *this;}
|
||||||
EIGEN_DEFAULT_COPY_CONSTRUCTOR(ArrayBase)
|
// mixing arrays and matrices is not legal
|
||||||
EIGEN_DEFAULT_EMPTY_CONSTRUCTOR_AND_DESTRUCTOR(ArrayBase)
|
template<typename OtherDerived> Derived& operator-=(const MatrixBase<OtherDerived>& )
|
||||||
|
{EIGEN_STATIC_ASSERT(std::ptrdiff_t(sizeof(typename OtherDerived::Scalar))==-1,YOU_CANNOT_MIX_ARRAYS_AND_MATRICES); return *this;}
|
||||||
private:
|
|
||||||
explicit ArrayBase(Index);
|
|
||||||
ArrayBase(Index, Index);
|
|
||||||
template <typename OtherDerived>
|
|
||||||
explicit ArrayBase(const ArrayBase<OtherDerived>&);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
// mixing arrays and matrices is not legal
|
|
||||||
template <typename OtherDerived>
|
|
||||||
Derived& operator+=(const MatrixBase<OtherDerived>&) {
|
|
||||||
EIGEN_STATIC_ASSERT(std::ptrdiff_t(sizeof(typename OtherDerived::Scalar)) == -1,
|
|
||||||
YOU_CANNOT_MIX_ARRAYS_AND_MATRICES);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
// mixing arrays and matrices is not legal
|
|
||||||
template <typename OtherDerived>
|
|
||||||
Derived& operator-=(const MatrixBase<OtherDerived>&) {
|
|
||||||
EIGEN_STATIC_ASSERT(std::ptrdiff_t(sizeof(typename OtherDerived::Scalar)) == -1,
|
|
||||||
YOU_CANNOT_MIX_ARRAYS_AND_MATRICES);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace Eigen
|
/** replaces \c *this by \c *this - \a other.
|
||||||
|
*
|
||||||
|
* \returns a reference to \c *this
|
||||||
|
*/
|
||||||
|
template<typename Derived>
|
||||||
|
template<typename OtherDerived>
|
||||||
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived &
|
||||||
|
ArrayBase<Derived>::operator-=(const ArrayBase<OtherDerived> &other)
|
||||||
|
{
|
||||||
|
call_assignment(derived(), other.derived(), internal::sub_assign_op<Scalar,typename OtherDerived::Scalar>());
|
||||||
|
return derived();
|
||||||
|
}
|
||||||
|
|
||||||
#endif // EIGEN_ARRAYBASE_H
|
/** replaces \c *this by \c *this + \a other.
|
||||||
|
*
|
||||||
|
* \returns a reference to \c *this
|
||||||
|
*/
|
||||||
|
template<typename Derived>
|
||||||
|
template<typename OtherDerived>
|
||||||
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived &
|
||||||
|
ArrayBase<Derived>::operator+=(const ArrayBase<OtherDerived>& other)
|
||||||
|
{
|
||||||
|
call_assignment(derived(), other.derived(), internal::add_assign_op<Scalar,typename OtherDerived::Scalar>());
|
||||||
|
return derived();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** replaces \c *this by \c *this * \a other coefficient wise.
|
||||||
|
*
|
||||||
|
* \returns a reference to \c *this
|
||||||
|
*/
|
||||||
|
template<typename Derived>
|
||||||
|
template<typename OtherDerived>
|
||||||
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived &
|
||||||
|
ArrayBase<Derived>::operator*=(const ArrayBase<OtherDerived>& other)
|
||||||
|
{
|
||||||
|
call_assignment(derived(), other.derived(), internal::mul_assign_op<Scalar,typename OtherDerived::Scalar>());
|
||||||
|
return derived();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** replaces \c *this by \c *this / \a other coefficient wise.
|
||||||
|
*
|
||||||
|
* \returns a reference to \c *this
|
||||||
|
*/
|
||||||
|
template<typename Derived>
|
||||||
|
template<typename OtherDerived>
|
||||||
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived &
|
||||||
|
ArrayBase<Derived>::operator/=(const ArrayBase<OtherDerived>& other)
|
||||||
|
{
|
||||||
|
call_assignment(derived(), other.derived(), internal::div_assign_op<Scalar,typename OtherDerived::Scalar>());
|
||||||
|
return derived();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // end namespace Eigen
|
||||||
|
|
||||||
|
#endif // EIGEN_ARRAYBASE_H
|
||||||
|
|||||||
@@ -10,157 +10,200 @@
|
|||||||
#ifndef EIGEN_ARRAYWRAPPER_H
|
#ifndef EIGEN_ARRAYWRAPPER_H
|
||||||
#define EIGEN_ARRAYWRAPPER_H
|
#define EIGEN_ARRAYWRAPPER_H
|
||||||
|
|
||||||
// IWYU pragma: private
|
|
||||||
#include "./InternalHeaderCheck.h"
|
|
||||||
|
|
||||||
namespace Eigen {
|
namespace Eigen {
|
||||||
|
|
||||||
/** \class ArrayWrapper
|
/** \class ArrayWrapper
|
||||||
* \ingroup Core_Module
|
* \ingroup Core_Module
|
||||||
*
|
*
|
||||||
* \brief Expression of a mathematical vector or matrix as an array object
|
* \brief Expression of a mathematical vector or matrix as an array object
|
||||||
*
|
*
|
||||||
* This class is the return type of MatrixBase::array(), and most of the time
|
* This class is the return type of MatrixBase::array(), and most of the time
|
||||||
* this is the only way it is used.
|
* this is the only way it is use.
|
||||||
*
|
*
|
||||||
* \sa MatrixBase::array(), class MatrixWrapper
|
* \sa MatrixBase::array(), class MatrixWrapper
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
template <typename ExpressionType>
|
template<typename ExpressionType>
|
||||||
struct traits<ArrayWrapper<ExpressionType> > : public traits<remove_all_t<typename ExpressionType::Nested> > {
|
struct traits<ArrayWrapper<ExpressionType> >
|
||||||
|
: public traits<typename remove_all<typename ExpressionType::Nested>::type >
|
||||||
|
{
|
||||||
typedef ArrayXpr XprKind;
|
typedef ArrayXpr XprKind;
|
||||||
// Let's remove NestByRefBit
|
// Let's remove NestByRefBit
|
||||||
enum {
|
enum {
|
||||||
Flags0 = traits<remove_all_t<typename ExpressionType::Nested> >::Flags,
|
Flags0 = traits<typename remove_all<typename ExpressionType::Nested>::type >::Flags,
|
||||||
LvalueBitFlag = is_lvalue<ExpressionType>::value ? LvalueBit : 0,
|
LvalueBitFlag = is_lvalue<ExpressionType>::value ? LvalueBit : 0,
|
||||||
Flags = (Flags0 & ~(NestByRefBit | LvalueBit)) | LvalueBitFlag
|
Flags = (Flags0 & ~(NestByRefBit | LvalueBit)) | LvalueBitFlag
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
} // namespace internal
|
}
|
||||||
|
|
||||||
template <typename ExpressionType>
|
template<typename ExpressionType>
|
||||||
class ArrayWrapper : public ArrayBase<ArrayWrapper<ExpressionType> > {
|
class ArrayWrapper : public ArrayBase<ArrayWrapper<ExpressionType> >
|
||||||
public:
|
{
|
||||||
typedef ArrayBase<ArrayWrapper> Base;
|
public:
|
||||||
EIGEN_DENSE_PUBLIC_INTERFACE(ArrayWrapper)
|
typedef ArrayBase<ArrayWrapper> Base;
|
||||||
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(ArrayWrapper)
|
EIGEN_DENSE_PUBLIC_INTERFACE(ArrayWrapper)
|
||||||
typedef internal::remove_all_t<ExpressionType> NestedExpression;
|
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(ArrayWrapper)
|
||||||
|
typedef typename internal::remove_all<ExpressionType>::type NestedExpression;
|
||||||
|
|
||||||
typedef std::conditional_t<internal::is_lvalue<ExpressionType>::value, Scalar, const Scalar>
|
typedef typename internal::conditional<
|
||||||
ScalarWithConstIfNotLvalue;
|
internal::is_lvalue<ExpressionType>::value,
|
||||||
|
Scalar,
|
||||||
|
const Scalar
|
||||||
|
>::type ScalarWithConstIfNotLvalue;
|
||||||
|
|
||||||
typedef typename internal::ref_selector<ExpressionType>::non_const_type NestedExpressionType;
|
typedef typename internal::ref_selector<ExpressionType>::non_const_type NestedExpressionType;
|
||||||
|
|
||||||
using Base::coeffRef;
|
using Base::coeffRef;
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC constexpr explicit EIGEN_STRONG_INLINE ArrayWrapper(ExpressionType& matrix)
|
EIGEN_DEVICE_FUNC
|
||||||
: m_expression(matrix) {}
|
explicit EIGEN_STRONG_INLINE ArrayWrapper(ExpressionType& matrix) : m_expression(matrix) {}
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC constexpr Index rows() const noexcept { return m_expression.rows(); }
|
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
|
||||||
EIGEN_DEVICE_FUNC constexpr Index cols() const noexcept { return m_expression.cols(); }
|
inline Index rows() const EIGEN_NOEXCEPT { return m_expression.rows(); }
|
||||||
EIGEN_DEVICE_FUNC constexpr Index outerStride() const noexcept { return m_expression.outerStride(); }
|
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
|
||||||
EIGEN_DEVICE_FUNC constexpr Index innerStride() const noexcept { return m_expression.innerStride(); }
|
inline Index cols() const EIGEN_NOEXCEPT { return m_expression.cols(); }
|
||||||
|
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
|
||||||
|
inline Index outerStride() const EIGEN_NOEXCEPT { return m_expression.outerStride(); }
|
||||||
|
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
|
||||||
|
inline Index innerStride() const EIGEN_NOEXCEPT { return m_expression.innerStride(); }
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC constexpr ScalarWithConstIfNotLvalue* data() { return m_expression.data(); }
|
EIGEN_DEVICE_FUNC
|
||||||
EIGEN_DEVICE_FUNC constexpr const Scalar* data() const { return m_expression.data(); }
|
inline ScalarWithConstIfNotLvalue* data() { return m_expression.data(); }
|
||||||
|
EIGEN_DEVICE_FUNC
|
||||||
|
inline const Scalar* data() const { return m_expression.data(); }
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC inline const Scalar& coeffRef(Index rowId, Index colId) const {
|
EIGEN_DEVICE_FUNC
|
||||||
return m_expression.coeffRef(rowId, colId);
|
inline const Scalar& coeffRef(Index rowId, Index colId) const
|
||||||
}
|
{
|
||||||
|
return m_expression.coeffRef(rowId, colId);
|
||||||
|
}
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC inline const Scalar& coeffRef(Index index) const { return m_expression.coeffRef(index); }
|
EIGEN_DEVICE_FUNC
|
||||||
|
inline const Scalar& coeffRef(Index index) const
|
||||||
|
{
|
||||||
|
return m_expression.coeffRef(index);
|
||||||
|
}
|
||||||
|
|
||||||
template <typename Dest>
|
template<typename Dest>
|
||||||
EIGEN_DEVICE_FUNC inline void evalTo(Dest& dst) const {
|
EIGEN_DEVICE_FUNC
|
||||||
dst = m_expression;
|
inline void evalTo(Dest& dst) const { dst = m_expression; }
|
||||||
}
|
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC constexpr const internal::remove_all_t<NestedExpressionType>& nestedExpression() const {
|
EIGEN_DEVICE_FUNC
|
||||||
return m_expression;
|
const typename internal::remove_all<NestedExpressionType>::type&
|
||||||
}
|
nestedExpression() const
|
||||||
|
{
|
||||||
|
return m_expression;
|
||||||
|
}
|
||||||
|
|
||||||
/** Forwards the resizing request to the nested expression
|
/** Forwards the resizing request to the nested expression
|
||||||
* \sa DenseBase::resize(Index) */
|
* \sa DenseBase::resize(Index) */
|
||||||
EIGEN_DEVICE_FUNC void resize(Index newSize) { m_expression.resize(newSize); }
|
EIGEN_DEVICE_FUNC
|
||||||
/** Forwards the resizing request to the nested expression
|
void resize(Index newSize) { m_expression.resize(newSize); }
|
||||||
* \sa DenseBase::resize(Index,Index)*/
|
/** Forwards the resizing request to the nested expression
|
||||||
EIGEN_DEVICE_FUNC void resize(Index rows, Index cols) { m_expression.resize(rows, cols); }
|
* \sa DenseBase::resize(Index,Index)*/
|
||||||
|
EIGEN_DEVICE_FUNC
|
||||||
|
void resize(Index rows, Index cols) { m_expression.resize(rows,cols); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
NestedExpressionType m_expression;
|
NestedExpressionType m_expression;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** \class MatrixWrapper
|
/** \class MatrixWrapper
|
||||||
* \ingroup Core_Module
|
* \ingroup Core_Module
|
||||||
*
|
*
|
||||||
* \brief Expression of an array as a mathematical vector or matrix
|
* \brief Expression of an array as a mathematical vector or matrix
|
||||||
*
|
*
|
||||||
* This class is the return type of ArrayBase::matrix(), and most of the time
|
* This class is the return type of ArrayBase::matrix(), and most of the time
|
||||||
* this is the only way it is used.
|
* this is the only way it is use.
|
||||||
*
|
*
|
||||||
* \sa MatrixBase::matrix(), class ArrayWrapper
|
* \sa MatrixBase::matrix(), class ArrayWrapper
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
template <typename ExpressionType>
|
template<typename ExpressionType>
|
||||||
struct traits<MatrixWrapper<ExpressionType> > : public traits<remove_all_t<typename ExpressionType::Nested> > {
|
struct traits<MatrixWrapper<ExpressionType> >
|
||||||
|
: public traits<typename remove_all<typename ExpressionType::Nested>::type >
|
||||||
|
{
|
||||||
typedef MatrixXpr XprKind;
|
typedef MatrixXpr XprKind;
|
||||||
// Let's remove NestByRefBit
|
// Let's remove NestByRefBit
|
||||||
enum {
|
enum {
|
||||||
Flags0 = traits<remove_all_t<typename ExpressionType::Nested> >::Flags,
|
Flags0 = traits<typename remove_all<typename ExpressionType::Nested>::type >::Flags,
|
||||||
LvalueBitFlag = is_lvalue<ExpressionType>::value ? LvalueBit : 0,
|
LvalueBitFlag = is_lvalue<ExpressionType>::value ? LvalueBit : 0,
|
||||||
Flags = (Flags0 & ~(NestByRefBit | LvalueBit)) | LvalueBitFlag
|
Flags = (Flags0 & ~(NestByRefBit | LvalueBit)) | LvalueBitFlag
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
} // namespace internal
|
}
|
||||||
|
|
||||||
template <typename ExpressionType>
|
template<typename ExpressionType>
|
||||||
class MatrixWrapper : public MatrixBase<MatrixWrapper<ExpressionType> > {
|
class MatrixWrapper : public MatrixBase<MatrixWrapper<ExpressionType> >
|
||||||
public:
|
{
|
||||||
typedef MatrixBase<MatrixWrapper<ExpressionType> > Base;
|
public:
|
||||||
EIGEN_DENSE_PUBLIC_INTERFACE(MatrixWrapper)
|
typedef MatrixBase<MatrixWrapper<ExpressionType> > Base;
|
||||||
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(MatrixWrapper)
|
EIGEN_DENSE_PUBLIC_INTERFACE(MatrixWrapper)
|
||||||
typedef internal::remove_all_t<ExpressionType> NestedExpression;
|
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(MatrixWrapper)
|
||||||
|
typedef typename internal::remove_all<ExpressionType>::type NestedExpression;
|
||||||
|
|
||||||
typedef std::conditional_t<internal::is_lvalue<ExpressionType>::value, Scalar, const Scalar>
|
typedef typename internal::conditional<
|
||||||
ScalarWithConstIfNotLvalue;
|
internal::is_lvalue<ExpressionType>::value,
|
||||||
|
Scalar,
|
||||||
|
const Scalar
|
||||||
|
>::type ScalarWithConstIfNotLvalue;
|
||||||
|
|
||||||
typedef typename internal::ref_selector<ExpressionType>::non_const_type NestedExpressionType;
|
typedef typename internal::ref_selector<ExpressionType>::non_const_type NestedExpressionType;
|
||||||
|
|
||||||
using Base::coeffRef;
|
using Base::coeffRef;
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC constexpr explicit inline MatrixWrapper(ExpressionType& matrix) : m_expression(matrix) {}
|
EIGEN_DEVICE_FUNC
|
||||||
|
explicit inline MatrixWrapper(ExpressionType& matrix) : m_expression(matrix) {}
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC constexpr Index rows() const noexcept { return m_expression.rows(); }
|
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
|
||||||
EIGEN_DEVICE_FUNC constexpr Index cols() const noexcept { return m_expression.cols(); }
|
inline Index rows() const EIGEN_NOEXCEPT { return m_expression.rows(); }
|
||||||
EIGEN_DEVICE_FUNC constexpr Index outerStride() const noexcept { return m_expression.outerStride(); }
|
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
|
||||||
EIGEN_DEVICE_FUNC constexpr Index innerStride() const noexcept { return m_expression.innerStride(); }
|
inline Index cols() const EIGEN_NOEXCEPT { return m_expression.cols(); }
|
||||||
|
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
|
||||||
|
inline Index outerStride() const EIGEN_NOEXCEPT { return m_expression.outerStride(); }
|
||||||
|
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
|
||||||
|
inline Index innerStride() const EIGEN_NOEXCEPT { return m_expression.innerStride(); }
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC constexpr ScalarWithConstIfNotLvalue* data() { return m_expression.data(); }
|
EIGEN_DEVICE_FUNC
|
||||||
EIGEN_DEVICE_FUNC constexpr const Scalar* data() const { return m_expression.data(); }
|
inline ScalarWithConstIfNotLvalue* data() { return m_expression.data(); }
|
||||||
|
EIGEN_DEVICE_FUNC
|
||||||
|
inline const Scalar* data() const { return m_expression.data(); }
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC inline const Scalar& coeffRef(Index rowId, Index colId) const {
|
EIGEN_DEVICE_FUNC
|
||||||
return m_expression.derived().coeffRef(rowId, colId);
|
inline const Scalar& coeffRef(Index rowId, Index colId) const
|
||||||
}
|
{
|
||||||
|
return m_expression.derived().coeffRef(rowId, colId);
|
||||||
|
}
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC inline const Scalar& coeffRef(Index index) const { return m_expression.coeffRef(index); }
|
EIGEN_DEVICE_FUNC
|
||||||
|
inline const Scalar& coeffRef(Index index) const
|
||||||
|
{
|
||||||
|
return m_expression.coeffRef(index);
|
||||||
|
}
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC constexpr const internal::remove_all_t<NestedExpressionType>& nestedExpression() const {
|
EIGEN_DEVICE_FUNC
|
||||||
return m_expression;
|
const typename internal::remove_all<NestedExpressionType>::type&
|
||||||
}
|
nestedExpression() const
|
||||||
|
{
|
||||||
|
return m_expression;
|
||||||
|
}
|
||||||
|
|
||||||
/** Forwards the resizing request to the nested expression
|
/** Forwards the resizing request to the nested expression
|
||||||
* \sa DenseBase::resize(Index) */
|
* \sa DenseBase::resize(Index) */
|
||||||
EIGEN_DEVICE_FUNC void resize(Index newSize) { m_expression.resize(newSize); }
|
EIGEN_DEVICE_FUNC
|
||||||
/** Forwards the resizing request to the nested expression
|
void resize(Index newSize) { m_expression.resize(newSize); }
|
||||||
* \sa DenseBase::resize(Index,Index)*/
|
/** Forwards the resizing request to the nested expression
|
||||||
EIGEN_DEVICE_FUNC void resize(Index rows, Index cols) { m_expression.resize(rows, cols); }
|
* \sa DenseBase::resize(Index,Index)*/
|
||||||
|
EIGEN_DEVICE_FUNC
|
||||||
|
void resize(Index rows, Index cols) { m_expression.resize(rows,cols); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
NestedExpressionType m_expression;
|
NestedExpressionType m_expression;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace Eigen
|
} // end namespace Eigen
|
||||||
|
|
||||||
#endif // EIGEN_ARRAYWRAPPER_H
|
#endif // EIGEN_ARRAYWRAPPER_H
|
||||||
|
|||||||
@@ -12,73 +12,79 @@
|
|||||||
#ifndef EIGEN_ASSIGN_H
|
#ifndef EIGEN_ASSIGN_H
|
||||||
#define EIGEN_ASSIGN_H
|
#define EIGEN_ASSIGN_H
|
||||||
|
|
||||||
// IWYU pragma: private
|
|
||||||
#include "./InternalHeaderCheck.h"
|
|
||||||
|
|
||||||
namespace Eigen {
|
namespace Eigen {
|
||||||
|
|
||||||
template <typename Derived>
|
template<typename Derived>
|
||||||
template <typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::lazyAssign(
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase<Derived>
|
||||||
const DenseBase<OtherDerived>& other) {
|
::lazyAssign(const DenseBase<OtherDerived>& other)
|
||||||
enum { SameType = internal::is_same<typename Derived::Scalar, typename OtherDerived::Scalar>::value };
|
{
|
||||||
|
enum{
|
||||||
|
SameType = internal::is_same<typename Derived::Scalar,typename OtherDerived::Scalar>::value
|
||||||
|
};
|
||||||
|
|
||||||
EIGEN_STATIC_ASSERT_LVALUE(Derived)
|
EIGEN_STATIC_ASSERT_LVALUE(Derived)
|
||||||
EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Derived, OtherDerived)
|
EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Derived,OtherDerived)
|
||||||
EIGEN_STATIC_ASSERT(
|
EIGEN_STATIC_ASSERT(SameType,YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
|
||||||
SameType,
|
|
||||||
YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
|
|
||||||
|
|
||||||
eigen_assert(rows() == other.rows() && cols() == other.cols());
|
eigen_assert(rows() == other.rows() && cols() == other.cols());
|
||||||
internal::call_assignment_no_alias(derived(), other.derived());
|
internal::call_assignment_no_alias(derived(),other.derived());
|
||||||
|
|
||||||
return derived();
|
return derived();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Derived>
|
template<typename Derived>
|
||||||
|
template<typename OtherDerived>
|
||||||
|
EIGEN_DEVICE_FUNC
|
||||||
|
EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::operator=(const DenseBase<OtherDerived>& other)
|
||||||
|
{
|
||||||
|
internal::call_assignment(derived(), other.derived());
|
||||||
|
return derived();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename Derived>
|
||||||
|
EIGEN_DEVICE_FUNC
|
||||||
|
EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::operator=(const DenseBase& other)
|
||||||
|
{
|
||||||
|
internal::call_assignment(derived(), other.derived());
|
||||||
|
return derived();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename Derived>
|
||||||
|
EIGEN_DEVICE_FUNC
|
||||||
|
EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::operator=(const MatrixBase& other)
|
||||||
|
{
|
||||||
|
internal::call_assignment(derived(), other.derived());
|
||||||
|
return derived();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename Derived>
|
||||||
template <typename OtherDerived>
|
template <typename OtherDerived>
|
||||||
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::operator=(
|
EIGEN_DEVICE_FUNC
|
||||||
const DenseBase<OtherDerived>& other) {
|
EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::operator=(const DenseBase<OtherDerived>& other)
|
||||||
|
{
|
||||||
internal::call_assignment(derived(), other.derived());
|
internal::call_assignment(derived(), other.derived());
|
||||||
return derived();
|
return derived();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Derived>
|
template<typename Derived>
|
||||||
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::operator=(const DenseBase& other) {
|
|
||||||
internal::call_assignment(derived(), other.derived());
|
|
||||||
return derived();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Derived>
|
|
||||||
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::operator=(const MatrixBase& other) {
|
|
||||||
internal::call_assignment(derived(), other.derived());
|
|
||||||
return derived();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Derived>
|
|
||||||
template <typename OtherDerived>
|
template <typename OtherDerived>
|
||||||
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::operator=(
|
EIGEN_DEVICE_FUNC
|
||||||
const DenseBase<OtherDerived>& other) {
|
EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::operator=(const EigenBase<OtherDerived>& other)
|
||||||
|
{
|
||||||
internal::call_assignment(derived(), other.derived());
|
internal::call_assignment(derived(), other.derived());
|
||||||
return derived();
|
return derived();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Derived>
|
template<typename Derived>
|
||||||
template <typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::operator=(
|
EIGEN_DEVICE_FUNC
|
||||||
const EigenBase<OtherDerived>& other) {
|
EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::operator=(const ReturnByValue<OtherDerived>& other)
|
||||||
internal::call_assignment(derived(), other.derived());
|
{
|
||||||
return derived();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Derived>
|
|
||||||
template <typename OtherDerived>
|
|
||||||
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::operator=(
|
|
||||||
const ReturnByValue<OtherDerived>& other) {
|
|
||||||
other.derived().evalTo(derived());
|
other.derived().evalTo(derived());
|
||||||
return derived();
|
return derived();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end namespace Eigen
|
} // end namespace Eigen
|
||||||
|
|
||||||
#endif // EIGEN_ASSIGN_H
|
#endif // EIGEN_ASSIGN_H
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,301 +0,0 @@
|
|||||||
/*
|
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
||||||
*
|
|
||||||
* Assign_AOCL.h - AOCL Vectorized Math Dispatch Layer for Eigen
|
|
||||||
*
|
|
||||||
* Copyright (c) 2025, Advanced Micro Devices, Inc. All rights reserved.
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* ------------
|
|
||||||
* This file implements a high-performance dispatch layer that automatically
|
|
||||||
* routes Eigen's element-wise mathematical operations to AMD Optimizing CPU
|
|
||||||
* Libraries (AOCL) Vector Math Library (VML) functions when beneficial for
|
|
||||||
* performance.
|
|
||||||
*
|
|
||||||
* The dispatch system uses C++ template specialization to intercept Eigen's
|
|
||||||
* assignment operations and redirect them to AOCL's VRDA functions, which
|
|
||||||
* provide optimized implementations for AMD Zen architectures.
|
|
||||||
*
|
|
||||||
* Key Features:
|
|
||||||
* -------------
|
|
||||||
* 1. Automatic Dispatch: Seamlessly routes supported operations to AOCL without
|
|
||||||
* requiring code changes in user applications
|
|
||||||
*
|
|
||||||
* 2. Performance Optimization: Uses AOCL VRDA functions optimized for Zen
|
|
||||||
* family processors with automatic SIMD instruction selection (AVX2, AVX-512)
|
|
||||||
*
|
|
||||||
* 3. Threshold-Based Activation: Only activates for vectors larger than
|
|
||||||
* EIGEN_AOCL_VML_THRESHOLD (default: 128 elements) to avoid overhead on
|
|
||||||
* small vectors
|
|
||||||
*
|
|
||||||
* 4. Precision-Specific Handling:
|
|
||||||
* - Double precision: AOCL VRDA vectorized functions
|
|
||||||
* - Single precision: Scalar fallback (preserves correctness)
|
|
||||||
*
|
|
||||||
* 5. Memory Layout Compatibility: Ensures direct memory access and compatible
|
|
||||||
* storage orders between source and destination for optimal performance
|
|
||||||
*
|
|
||||||
* Supported Operations:
|
|
||||||
* ---------------------
|
|
||||||
* UNARY OPERATIONS (vector → vector):
|
|
||||||
* - Transcendental: exp(), sin(), cos(), sqrt(), log(), log10(), log2()
|
|
||||||
*
|
|
||||||
* BINARY OPERATIONS (vector op vector → vector):
|
|
||||||
* - Arithmetic: +, *, pow()
|
|
||||||
*
|
|
||||||
* Template Specialization Mechanism:
|
|
||||||
* -----------------------------------
|
|
||||||
* The system works by specializing Eigen's Assignment template for:
|
|
||||||
* 1. CwiseUnaryOp with scalar_*_op functors (unary operations)
|
|
||||||
* 2. CwiseBinaryOp with scalar_*_op functors (binary operations)
|
|
||||||
* 3. Dense2Dense assignment context with AOCL-compatible traits
|
|
||||||
*
|
|
||||||
* Dispatch conditions (all must be true):
|
|
||||||
* - Source and destination have DirectAccessBit (contiguous memory)
|
|
||||||
* - Compatible storage orders (both row-major or both column-major)
|
|
||||||
* - Vector size ≥ EIGEN_AOCL_VML_THRESHOLD or Dynamic size
|
|
||||||
* - Supported data type (currently double precision for VRDA)
|
|
||||||
*
|
|
||||||
* Integration Example:
|
|
||||||
* --------------------
|
|
||||||
* // Standard Eigen code - no changes required
|
|
||||||
* VectorXd x = VectorXd::Random(10000);
|
|
||||||
* VectorXd y = VectorXd::Random(10000);
|
|
||||||
* VectorXd result;
|
|
||||||
*
|
|
||||||
* // These operations are automatically dispatched to AOCL:
|
|
||||||
* result = x.array().exp(); // → amd_vrda_exp()
|
|
||||||
* result = x.array().sin(); // → amd_vrda_sin()
|
|
||||||
* result = x.array() + y.array(); // → amd_vrda_add()
|
|
||||||
* result = x.array().pow(y.array()); // → amd_vrda_pow()
|
|
||||||
*
|
|
||||||
* Configuration:
|
|
||||||
* --------------
|
|
||||||
* Required preprocessor definitions:
|
|
||||||
* - EIGEN_USE_AOCL_ALL or EIGEN_USE_AOCL_MT: Enable AOCL integration
|
|
||||||
* - EIGEN_USE_AOCL_VML: Enable Vector Math Library dispatch
|
|
||||||
*
|
|
||||||
* Compilation Requirements:
|
|
||||||
* -------------------------
|
|
||||||
* Include paths:
|
|
||||||
* - AOCL headers: -I${AOCL_ROOT}/include
|
|
||||||
* - Eigen headers: -I/path/to/eigen
|
|
||||||
*
|
|
||||||
* Link libraries:
|
|
||||||
* - AOCL MathLib: -lamdlibm
|
|
||||||
* - Standard math: -lm
|
|
||||||
*
|
|
||||||
* Compiler flags:
|
|
||||||
* - Optimization: -O3 (required for inlining)
|
|
||||||
* - Architecture: -march=znver5 or -march=native
|
|
||||||
* - Vectorization: -mfma -mavx512f (if supported)
|
|
||||||
*
|
|
||||||
* Platform Support:
|
|
||||||
* ------------------
|
|
||||||
* - Primary: Linux x86_64 with AMD Zen family processors
|
|
||||||
* - Compilers: GCC 8+, Clang 10+, AOCC (recommended)
|
|
||||||
* - AOCL Version: 4.0+ (with VRDA support)
|
|
||||||
*
|
|
||||||
* Error Handling:
|
|
||||||
* ---------------
|
|
||||||
* - Graceful fallback to scalar operations for unsupported configurations
|
|
||||||
* - Compile-time detection of AOCL availability
|
|
||||||
* - Runtime size and alignment validation with eigen_assert()
|
|
||||||
*
|
|
||||||
* Developer:
|
|
||||||
* ----------
|
|
||||||
* Name: Sharad Saurabh Bhaskar
|
|
||||||
* Email: shbhaska@amd.com
|
|
||||||
* Organization: Advanced Micro Devices, Inc.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef EIGEN_ASSIGN_AOCL_H
|
|
||||||
#define EIGEN_ASSIGN_AOCL_H
|
|
||||||
|
|
||||||
namespace Eigen {
|
|
||||||
namespace internal {
|
|
||||||
|
|
||||||
// Traits for unary operations.
|
|
||||||
template <typename Dst, typename Src> class aocl_assign_traits {
|
|
||||||
private:
|
|
||||||
enum {
|
|
||||||
DstHasDirectAccess = !!(Dst::Flags & DirectAccessBit),
|
|
||||||
SrcHasDirectAccess = !!(Src::Flags & DirectAccessBit),
|
|
||||||
StorageOrdersAgree = (int(Dst::IsRowMajor) == int(Src::IsRowMajor)),
|
|
||||||
InnerSize = Dst::IsVectorAtCompileTime ? int(Dst::SizeAtCompileTime)
|
|
||||||
: (Dst::Flags & RowMajorBit) ? int(Dst::ColsAtCompileTime)
|
|
||||||
: int(Dst::RowsAtCompileTime),
|
|
||||||
LargeEnough =
|
|
||||||
(InnerSize == Dynamic) || (InnerSize >= EIGEN_AOCL_VML_THRESHOLD)
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
|
||||||
enum {
|
|
||||||
EnableAoclVML = DstHasDirectAccess && SrcHasDirectAccess &&
|
|
||||||
StorageOrdersAgree && LargeEnough,
|
|
||||||
Traversal = LinearTraversal
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
// Traits for binary operations (e.g., add, pow).
|
|
||||||
template <typename Dst, typename Lhs, typename Rhs>
|
|
||||||
class aocl_assign_binary_traits {
|
|
||||||
private:
|
|
||||||
enum {
|
|
||||||
DstHasDirectAccess = !!(Dst::Flags & DirectAccessBit),
|
|
||||||
LhsHasDirectAccess = !!(Lhs::Flags & DirectAccessBit),
|
|
||||||
RhsHasDirectAccess = !!(Rhs::Flags & DirectAccessBit),
|
|
||||||
StorageOrdersAgree = (int(Dst::IsRowMajor) == int(Lhs::IsRowMajor)) &&
|
|
||||||
(int(Dst::IsRowMajor) == int(Rhs::IsRowMajor)),
|
|
||||||
InnerSize = Dst::IsVectorAtCompileTime ? int(Dst::SizeAtCompileTime)
|
|
||||||
: (Dst::Flags & RowMajorBit) ? int(Dst::ColsAtCompileTime)
|
|
||||||
: int(Dst::RowsAtCompileTime),
|
|
||||||
LargeEnough =
|
|
||||||
(InnerSize == Dynamic) || (InnerSize >= EIGEN_AOCL_VML_THRESHOLD)
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
|
||||||
enum {
|
|
||||||
EnableAoclVML = DstHasDirectAccess && LhsHasDirectAccess &&
|
|
||||||
RhsHasDirectAccess && StorageOrdersAgree && LargeEnough
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
// Unary operation dispatch for float (scalar fallback).
|
|
||||||
#define EIGEN_AOCL_VML_UNARY_CALL_FLOAT(EIGENOP) \
|
|
||||||
template <typename DstXprType, typename SrcXprNested> \
|
|
||||||
struct Assignment< \
|
|
||||||
DstXprType, CwiseUnaryOp<scalar_##EIGENOP##_op<float>, SrcXprNested>, \
|
|
||||||
assign_op<float, float>, Dense2Dense, \
|
|
||||||
std::enable_if_t< \
|
|
||||||
aocl_assign_traits<DstXprType, SrcXprNested>::EnableAoclVML>> { \
|
|
||||||
typedef CwiseUnaryOp<scalar_##EIGENOP##_op<float>, SrcXprNested> \
|
|
||||||
SrcXprType; \
|
|
||||||
static void run(DstXprType &dst, const SrcXprType &src, \
|
|
||||||
const assign_op<float, float> &) { \
|
|
||||||
eigen_assert(dst.rows() == src.rows() && dst.cols() == src.cols()); \
|
|
||||||
Eigen::Index n = dst.size(); \
|
|
||||||
if (n <= 0) \
|
|
||||||
return; \
|
|
||||||
const float *input = \
|
|
||||||
reinterpret_cast<const float *>(src.nestedExpression().data()); \
|
|
||||||
float *output = reinterpret_cast<float *>(dst.data()); \
|
|
||||||
for (Eigen::Index i = 0; i < n; ++i) { \
|
|
||||||
output[i] = std::EIGENOP(input[i]); \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
};
|
|
||||||
|
|
||||||
// Unary operation dispatch for double (AOCL vectorized).
|
|
||||||
#define EIGEN_AOCL_VML_UNARY_CALL_DOUBLE(EIGENOP, AOCLOP) \
|
|
||||||
template <typename DstXprType, typename SrcXprNested> \
|
|
||||||
struct Assignment< \
|
|
||||||
DstXprType, CwiseUnaryOp<scalar_##EIGENOP##_op<double>, SrcXprNested>, \
|
|
||||||
assign_op<double, double>, Dense2Dense, \
|
|
||||||
std::enable_if_t< \
|
|
||||||
aocl_assign_traits<DstXprType, SrcXprNested>::EnableAoclVML>> { \
|
|
||||||
typedef CwiseUnaryOp<scalar_##EIGENOP##_op<double>, SrcXprNested> \
|
|
||||||
SrcXprType; \
|
|
||||||
static void run(DstXprType &dst, const SrcXprType &src, \
|
|
||||||
const assign_op<double, double> &) { \
|
|
||||||
eigen_assert(dst.rows() == src.rows() && dst.cols() == src.cols()); \
|
|
||||||
Eigen::Index n = dst.size(); \
|
|
||||||
eigen_assert(n <= INT_MAX && "AOCL does not support arrays larger than INT_MAX"); \
|
|
||||||
if (n <= 0) \
|
|
||||||
return; \
|
|
||||||
const double *input = \
|
|
||||||
reinterpret_cast<const double *>(src.nestedExpression().data()); \
|
|
||||||
double *output = reinterpret_cast<double *>(dst.data()); \
|
|
||||||
int aocl_n = internal::convert_index<int>(n); \
|
|
||||||
AOCLOP(aocl_n, const_cast<double *>(input), output); \
|
|
||||||
} \
|
|
||||||
};
|
|
||||||
|
|
||||||
// Instantiate unary calls for float (scalar).
|
|
||||||
// EIGEN_AOCL_VML_UNARY_CALL_FLOAT(exp)
|
|
||||||
|
|
||||||
// Instantiate unary calls for double (AOCL vectorized).
|
|
||||||
EIGEN_AOCL_VML_UNARY_CALL_DOUBLE(exp2, amd_vrda_exp2)
|
|
||||||
EIGEN_AOCL_VML_UNARY_CALL_DOUBLE(exp, amd_vrda_exp)
|
|
||||||
EIGEN_AOCL_VML_UNARY_CALL_DOUBLE(sin, amd_vrda_sin)
|
|
||||||
EIGEN_AOCL_VML_UNARY_CALL_DOUBLE(cos, amd_vrda_cos)
|
|
||||||
EIGEN_AOCL_VML_UNARY_CALL_DOUBLE(sqrt, amd_vrda_sqrt)
|
|
||||||
EIGEN_AOCL_VML_UNARY_CALL_DOUBLE(cbrt, amd_vrda_cbrt)
|
|
||||||
EIGEN_AOCL_VML_UNARY_CALL_DOUBLE(abs, amd_vrda_fabs)
|
|
||||||
EIGEN_AOCL_VML_UNARY_CALL_DOUBLE(log, amd_vrda_log)
|
|
||||||
EIGEN_AOCL_VML_UNARY_CALL_DOUBLE(log10, amd_vrda_log10)
|
|
||||||
EIGEN_AOCL_VML_UNARY_CALL_DOUBLE(log2, amd_vrda_log2)
|
|
||||||
|
|
||||||
// Binary operation dispatch for float (scalar fallback).
|
|
||||||
#define EIGEN_AOCL_VML_BINARY_CALL_FLOAT(EIGENOP, STDFUNC) \
|
|
||||||
template <typename DstXprType, typename LhsXprNested, typename RhsXprNested> \
|
|
||||||
struct Assignment< \
|
|
||||||
DstXprType, \
|
|
||||||
CwiseBinaryOp<scalar_##EIGENOP##_op<float, float>, LhsXprNested, \
|
|
||||||
RhsXprNested>, \
|
|
||||||
assign_op<float, float>, Dense2Dense, \
|
|
||||||
std::enable_if_t<aocl_assign_binary_traits< \
|
|
||||||
DstXprType, LhsXprNested, RhsXprNested>::EnableAoclVML>> { \
|
|
||||||
typedef CwiseBinaryOp<scalar_##EIGENOP##_op<float, float>, LhsXprNested, \
|
|
||||||
RhsXprNested> \
|
|
||||||
SrcXprType; \
|
|
||||||
static void run(DstXprType &dst, const SrcXprType &src, \
|
|
||||||
const assign_op<float, float> &) { \
|
|
||||||
eigen_assert(dst.rows() == src.rows() && dst.cols() == src.cols()); \
|
|
||||||
Eigen::Index n = dst.size(); \
|
|
||||||
if (n <= 0) \
|
|
||||||
return; \
|
|
||||||
const float *lhs = reinterpret_cast<const float *>(src.lhs().data()); \
|
|
||||||
const float *rhs = reinterpret_cast<const float *>(src.rhs().data()); \
|
|
||||||
float *output = reinterpret_cast<float *>(dst.data()); \
|
|
||||||
for (Eigen::Index i = 0; i < n; ++i) { \
|
|
||||||
output[i] = STDFUNC(lhs[i], rhs[i]); \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
};
|
|
||||||
|
|
||||||
// Binary operation dispatch for double (AOCL vectorized).
|
|
||||||
#define EIGEN_AOCL_VML_BINARY_CALL_DOUBLE(EIGENOP, AOCLOP) \
|
|
||||||
template <typename DstXprType, typename LhsXprNested, typename RhsXprNested> \
|
|
||||||
struct Assignment< \
|
|
||||||
DstXprType, \
|
|
||||||
CwiseBinaryOp<scalar_##EIGENOP##_op<double, double>, LhsXprNested, \
|
|
||||||
RhsXprNested>, \
|
|
||||||
assign_op<double, double>, Dense2Dense, \
|
|
||||||
std::enable_if_t<aocl_assign_binary_traits< \
|
|
||||||
DstXprType, LhsXprNested, RhsXprNested>::EnableAoclVML>> { \
|
|
||||||
typedef CwiseBinaryOp<scalar_##EIGENOP##_op<double, double>, LhsXprNested, \
|
|
||||||
RhsXprNested> \
|
|
||||||
SrcXprType; \
|
|
||||||
static void run(DstXprType &dst, const SrcXprType &src, \
|
|
||||||
const assign_op<double, double> &) { \
|
|
||||||
eigen_assert(dst.rows() == src.rows() && dst.cols() == src.cols()); \
|
|
||||||
Eigen::Index n = dst.size(); \
|
|
||||||
eigen_assert(n <= INT_MAX && "AOCL does not support arrays larger than INT_MAX"); \
|
|
||||||
if (n <= 0) \
|
|
||||||
return; \
|
|
||||||
const double *lhs = reinterpret_cast<const double *>(src.lhs().data()); \
|
|
||||||
const double *rhs = reinterpret_cast<const double *>(src.rhs().data()); \
|
|
||||||
double *output = reinterpret_cast<double *>(dst.data()); \
|
|
||||||
int aocl_n = internal::convert_index<int>(n); \
|
|
||||||
AOCLOP(aocl_n, const_cast<double *>(lhs), const_cast<double *>(rhs), output); \
|
|
||||||
} \
|
|
||||||
};
|
|
||||||
|
|
||||||
// Instantiate binary calls for float (scalar).
|
|
||||||
// EIGEN_AOCL_VML_BINARY_CALL_FLOAT(sum, std::plus<float>) // Using
|
|
||||||
// scalar_sum_op for addition EIGEN_AOCL_VML_BINARY_CALL_FLOAT(pow, std::pow)
|
|
||||||
|
|
||||||
// Instantiate binary calls for double (AOCL vectorized).
|
|
||||||
EIGEN_AOCL_VML_BINARY_CALL_DOUBLE(sum, amd_vrda_add) // Using scalar_sum_op for addition
|
|
||||||
EIGEN_AOCL_VML_BINARY_CALL_DOUBLE(pow, amd_vrda_pow)
|
|
||||||
EIGEN_AOCL_VML_BINARY_CALL_DOUBLE(max, amd_vrda_fmax)
|
|
||||||
EIGEN_AOCL_VML_BINARY_CALL_DOUBLE(min, amd_vrda_fmin)
|
|
||||||
|
|
||||||
} // namespace internal
|
|
||||||
} // namespace Eigen
|
|
||||||
|
|
||||||
#endif // EIGEN_ASSIGN_AOCL_H
|
|
||||||
231
Eigen/src/Core/Assign_MKL.h
Normal file → Executable file
231
Eigen/src/Core/Assign_MKL.h
Normal file → Executable file
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2011, Intel Corporation. All rights reserved.
|
Copyright (c) 2011, Intel Corporation. All rights reserved.
|
||||||
Copyright (C) 2015 Gael Guennebaud <gael.guennebaud@inria.fr>
|
Copyright (C) 2015 Gael Guennebaud <gael.guennebaud@inria.fr>
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
Redistribution and use in source and binary forms, with or without modification,
|
||||||
are permitted provided that the following conditions are met:
|
are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
@@ -34,41 +34,40 @@
|
|||||||
#ifndef EIGEN_ASSIGN_VML_H
|
#ifndef EIGEN_ASSIGN_VML_H
|
||||||
#define EIGEN_ASSIGN_VML_H
|
#define EIGEN_ASSIGN_VML_H
|
||||||
|
|
||||||
// IWYU pragma: private
|
namespace Eigen {
|
||||||
#include "./InternalHeaderCheck.h"
|
|
||||||
|
|
||||||
namespace Eigen {
|
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
template <typename Dst, typename Src>
|
template<typename Dst, typename Src>
|
||||||
class vml_assign_traits {
|
class vml_assign_traits
|
||||||
private:
|
{
|
||||||
enum {
|
private:
|
||||||
DstHasDirectAccess = Dst::Flags & DirectAccessBit,
|
enum {
|
||||||
SrcHasDirectAccess = Src::Flags & DirectAccessBit,
|
DstHasDirectAccess = Dst::Flags & DirectAccessBit,
|
||||||
StorageOrdersAgree = (int(Dst::IsRowMajor) == int(Src::IsRowMajor)),
|
SrcHasDirectAccess = Src::Flags & DirectAccessBit,
|
||||||
InnerSize = int(Dst::IsVectorAtCompileTime) ? int(Dst::SizeAtCompileTime)
|
StorageOrdersAgree = (int(Dst::IsRowMajor) == int(Src::IsRowMajor)),
|
||||||
: int(Dst::Flags) & RowMajorBit ? int(Dst::ColsAtCompileTime)
|
InnerSize = int(Dst::IsVectorAtCompileTime) ? int(Dst::SizeAtCompileTime)
|
||||||
: int(Dst::RowsAtCompileTime),
|
: int(Dst::Flags)&RowMajorBit ? int(Dst::ColsAtCompileTime)
|
||||||
InnerMaxSize = int(Dst::IsVectorAtCompileTime) ? int(Dst::MaxSizeAtCompileTime)
|
: int(Dst::RowsAtCompileTime),
|
||||||
: int(Dst::Flags) & RowMajorBit ? int(Dst::MaxColsAtCompileTime)
|
InnerMaxSize = int(Dst::IsVectorAtCompileTime) ? int(Dst::MaxSizeAtCompileTime)
|
||||||
: int(Dst::MaxRowsAtCompileTime),
|
: int(Dst::Flags)&RowMajorBit ? int(Dst::MaxColsAtCompileTime)
|
||||||
MaxSizeAtCompileTime = Dst::SizeAtCompileTime,
|
: int(Dst::MaxRowsAtCompileTime),
|
||||||
|
MaxSizeAtCompileTime = Dst::SizeAtCompileTime,
|
||||||
|
|
||||||
MightEnableVml = bool(StorageOrdersAgree) && bool(DstHasDirectAccess) && bool(SrcHasDirectAccess) &&
|
MightEnableVml = StorageOrdersAgree && DstHasDirectAccess && SrcHasDirectAccess && Src::InnerStrideAtCompileTime==1 && Dst::InnerStrideAtCompileTime==1,
|
||||||
Src::InnerStrideAtCompileTime == 1 && Dst::InnerStrideAtCompileTime == 1,
|
MightLinearize = MightEnableVml && (int(Dst::Flags) & int(Src::Flags) & LinearAccessBit),
|
||||||
MightLinearize = bool(MightEnableVml) && (int(Dst::Flags) & int(Src::Flags) & LinearAccessBit),
|
VmlSize = MightLinearize ? MaxSizeAtCompileTime : InnerMaxSize,
|
||||||
VmlSize = bool(MightLinearize) ? MaxSizeAtCompileTime : InnerMaxSize,
|
LargeEnough = VmlSize==Dynamic || VmlSize>=EIGEN_MKL_VML_THRESHOLD
|
||||||
LargeEnough = (VmlSize == Dynamic) || VmlSize >= EIGEN_MKL_VML_THRESHOLD
|
};
|
||||||
};
|
public:
|
||||||
|
enum {
|
||||||
public:
|
EnableVml = MightEnableVml && LargeEnough,
|
||||||
enum { EnableVml = MightEnableVml && LargeEnough, Traversal = MightLinearize ? LinearTraversal : DefaultTraversal };
|
Traversal = MightLinearize ? LinearTraversal : DefaultTraversal
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
#define EIGEN_PP_EXPAND(ARG) ARG
|
#define EIGEN_PP_EXPAND(ARG) ARG
|
||||||
#if !defined(EIGEN_FAST_MATH) || (EIGEN_FAST_MATH != 1)
|
#if !defined (EIGEN_FAST_MATH) || (EIGEN_FAST_MATH != 1)
|
||||||
#define EIGEN_VMLMODE_EXPAND_xLA , VML_HA
|
#define EIGEN_VMLMODE_EXPAND_xLA , VML_HA
|
||||||
#else
|
#else
|
||||||
#define EIGEN_VMLMODE_EXPAND_xLA , VML_LA
|
#define EIGEN_VMLMODE_EXPAND_xLA , VML_LA
|
||||||
@@ -77,107 +76,103 @@ class vml_assign_traits {
|
|||||||
#define EIGEN_VMLMODE_EXPAND_x_
|
#define EIGEN_VMLMODE_EXPAND_x_
|
||||||
|
|
||||||
#define EIGEN_VMLMODE_PREFIX_xLA vm
|
#define EIGEN_VMLMODE_PREFIX_xLA vm
|
||||||
#define EIGEN_VMLMODE_PREFIX_x_ v
|
#define EIGEN_VMLMODE_PREFIX_x_ v
|
||||||
#define EIGEN_VMLMODE_PREFIX(VMLMODE) EIGEN_CAT(EIGEN_VMLMODE_PREFIX_x, VMLMODE)
|
#define EIGEN_VMLMODE_PREFIX(VMLMODE) EIGEN_CAT(EIGEN_VMLMODE_PREFIX_x,VMLMODE)
|
||||||
|
|
||||||
#define EIGEN_MKL_VML_DECLARE_UNARY_CALL(EIGENOP, VMLOP, EIGENTYPE, VMLTYPE, VMLMODE) \
|
#define EIGEN_MKL_VML_DECLARE_UNARY_CALL(EIGENOP, VMLOP, EIGENTYPE, VMLTYPE, VMLMODE) \
|
||||||
template <typename DstXprType, typename SrcXprNested> \
|
template< typename DstXprType, typename SrcXprNested> \
|
||||||
struct Assignment<DstXprType, CwiseUnaryOp<scalar_##EIGENOP##_op<EIGENTYPE>, SrcXprNested>, \
|
struct Assignment<DstXprType, CwiseUnaryOp<scalar_##EIGENOP##_op<EIGENTYPE>, SrcXprNested>, assign_op<EIGENTYPE,EIGENTYPE>, \
|
||||||
assign_op<EIGENTYPE, EIGENTYPE>, Dense2Dense, \
|
Dense2Dense, typename enable_if<vml_assign_traits<DstXprType,SrcXprNested>::EnableVml>::type> { \
|
||||||
std::enable_if_t<vml_assign_traits<DstXprType, SrcXprNested>::EnableVml>> { \
|
typedef CwiseUnaryOp<scalar_##EIGENOP##_op<EIGENTYPE>, SrcXprNested> SrcXprType; \
|
||||||
typedef CwiseUnaryOp<scalar_##EIGENOP##_op<EIGENTYPE>, SrcXprNested> SrcXprType; \
|
static void run(DstXprType &dst, const SrcXprType &src, const assign_op<EIGENTYPE,EIGENTYPE> &func) { \
|
||||||
static void run(DstXprType &dst, const SrcXprType &src, const assign_op<EIGENTYPE, EIGENTYPE> &func) { \
|
resize_if_allowed(dst, src, func); \
|
||||||
resize_if_allowed(dst, src, func); \
|
eigen_assert(dst.rows() == src.rows() && dst.cols() == src.cols()); \
|
||||||
eigen_assert(dst.rows() == src.rows() && dst.cols() == src.cols()); \
|
if(vml_assign_traits<DstXprType,SrcXprNested>::Traversal==LinearTraversal) { \
|
||||||
if (vml_assign_traits<DstXprType, SrcXprNested>::Traversal == (int)LinearTraversal) { \
|
VMLOP(dst.size(), (const VMLTYPE*)src.nestedExpression().data(), \
|
||||||
VMLOP(dst.size(), (const VMLTYPE *)src.nestedExpression().data(), \
|
(VMLTYPE*)dst.data() EIGEN_PP_EXPAND(EIGEN_VMLMODE_EXPAND_x##VMLMODE) ); \
|
||||||
(VMLTYPE *)dst.data() EIGEN_PP_EXPAND(EIGEN_VMLMODE_EXPAND_x##VMLMODE)); \
|
} else { \
|
||||||
} else { \
|
const Index outerSize = dst.outerSize(); \
|
||||||
const Index outerSize = dst.outerSize(); \
|
for(Index outer = 0; outer < outerSize; ++outer) { \
|
||||||
for (Index outer = 0; outer < outerSize; ++outer) { \
|
const EIGENTYPE *src_ptr = src.IsRowMajor ? &(src.nestedExpression().coeffRef(outer,0)) : \
|
||||||
const EIGENTYPE *src_ptr = src.IsRowMajor ? &(src.nestedExpression().coeffRef(outer, 0)) \
|
&(src.nestedExpression().coeffRef(0, outer)); \
|
||||||
: &(src.nestedExpression().coeffRef(0, outer)); \
|
EIGENTYPE *dst_ptr = dst.IsRowMajor ? &(dst.coeffRef(outer,0)) : &(dst.coeffRef(0, outer)); \
|
||||||
EIGENTYPE *dst_ptr = dst.IsRowMajor ? &(dst.coeffRef(outer, 0)) : &(dst.coeffRef(0, outer)); \
|
VMLOP( dst.innerSize(), (const VMLTYPE*)src_ptr, \
|
||||||
VMLOP(dst.innerSize(), (const VMLTYPE *)src_ptr, \
|
(VMLTYPE*)dst_ptr EIGEN_PP_EXPAND(EIGEN_VMLMODE_EXPAND_x##VMLMODE)); \
|
||||||
(VMLTYPE *)dst_ptr EIGEN_PP_EXPAND(EIGEN_VMLMODE_EXPAND_x##VMLMODE)); \
|
} \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
} \
|
}; \
|
||||||
};
|
|
||||||
|
|
||||||
#define EIGEN_MKL_VML_DECLARE_UNARY_CALLS_REAL(EIGENOP, VMLOP, VMLMODE) \
|
|
||||||
EIGEN_MKL_VML_DECLARE_UNARY_CALL(EIGENOP, EIGEN_CAT(EIGEN_VMLMODE_PREFIX(VMLMODE), s##VMLOP), float, float, VMLMODE) \
|
|
||||||
EIGEN_MKL_VML_DECLARE_UNARY_CALL(EIGENOP, EIGEN_CAT(EIGEN_VMLMODE_PREFIX(VMLMODE), d##VMLOP), double, double, VMLMODE)
|
|
||||||
|
|
||||||
#define EIGEN_MKL_VML_DECLARE_UNARY_CALLS_CPLX(EIGENOP, VMLOP, VMLMODE) \
|
#define EIGEN_MKL_VML_DECLARE_UNARY_CALLS_REAL(EIGENOP, VMLOP, VMLMODE) \
|
||||||
EIGEN_MKL_VML_DECLARE_UNARY_CALL(EIGENOP, EIGEN_CAT(EIGEN_VMLMODE_PREFIX(VMLMODE), c##VMLOP), scomplex, \
|
EIGEN_MKL_VML_DECLARE_UNARY_CALL(EIGENOP, EIGEN_CAT(EIGEN_VMLMODE_PREFIX(VMLMODE),s##VMLOP), float, float, VMLMODE) \
|
||||||
MKL_Complex8, VMLMODE) \
|
EIGEN_MKL_VML_DECLARE_UNARY_CALL(EIGENOP, EIGEN_CAT(EIGEN_VMLMODE_PREFIX(VMLMODE),d##VMLOP), double, double, VMLMODE)
|
||||||
EIGEN_MKL_VML_DECLARE_UNARY_CALL(EIGENOP, EIGEN_CAT(EIGEN_VMLMODE_PREFIX(VMLMODE), z##VMLOP), dcomplex, \
|
|
||||||
MKL_Complex16, VMLMODE)
|
|
||||||
|
|
||||||
#define EIGEN_MKL_VML_DECLARE_UNARY_CALLS(EIGENOP, VMLOP, VMLMODE) \
|
#define EIGEN_MKL_VML_DECLARE_UNARY_CALLS_CPLX(EIGENOP, VMLOP, VMLMODE) \
|
||||||
EIGEN_MKL_VML_DECLARE_UNARY_CALLS_REAL(EIGENOP, VMLOP, VMLMODE) \
|
EIGEN_MKL_VML_DECLARE_UNARY_CALL(EIGENOP, EIGEN_CAT(EIGEN_VMLMODE_PREFIX(VMLMODE),c##VMLOP), scomplex, MKL_Complex8, VMLMODE) \
|
||||||
|
EIGEN_MKL_VML_DECLARE_UNARY_CALL(EIGENOP, EIGEN_CAT(EIGEN_VMLMODE_PREFIX(VMLMODE),z##VMLOP), dcomplex, MKL_Complex16, VMLMODE)
|
||||||
|
|
||||||
|
#define EIGEN_MKL_VML_DECLARE_UNARY_CALLS(EIGENOP, VMLOP, VMLMODE) \
|
||||||
|
EIGEN_MKL_VML_DECLARE_UNARY_CALLS_REAL(EIGENOP, VMLOP, VMLMODE) \
|
||||||
EIGEN_MKL_VML_DECLARE_UNARY_CALLS_CPLX(EIGENOP, VMLOP, VMLMODE)
|
EIGEN_MKL_VML_DECLARE_UNARY_CALLS_CPLX(EIGENOP, VMLOP, VMLMODE)
|
||||||
|
|
||||||
EIGEN_MKL_VML_DECLARE_UNARY_CALLS(sin, Sin, LA)
|
|
||||||
EIGEN_MKL_VML_DECLARE_UNARY_CALLS(asin, Asin, LA)
|
EIGEN_MKL_VML_DECLARE_UNARY_CALLS(sin, Sin, LA)
|
||||||
EIGEN_MKL_VML_DECLARE_UNARY_CALLS(sinh, Sinh, LA)
|
EIGEN_MKL_VML_DECLARE_UNARY_CALLS(asin, Asin, LA)
|
||||||
EIGEN_MKL_VML_DECLARE_UNARY_CALLS(cos, Cos, LA)
|
EIGEN_MKL_VML_DECLARE_UNARY_CALLS(sinh, Sinh, LA)
|
||||||
EIGEN_MKL_VML_DECLARE_UNARY_CALLS(acos, Acos, LA)
|
EIGEN_MKL_VML_DECLARE_UNARY_CALLS(cos, Cos, LA)
|
||||||
EIGEN_MKL_VML_DECLARE_UNARY_CALLS(cosh, Cosh, LA)
|
EIGEN_MKL_VML_DECLARE_UNARY_CALLS(acos, Acos, LA)
|
||||||
EIGEN_MKL_VML_DECLARE_UNARY_CALLS(tan, Tan, LA)
|
EIGEN_MKL_VML_DECLARE_UNARY_CALLS(cosh, Cosh, LA)
|
||||||
EIGEN_MKL_VML_DECLARE_UNARY_CALLS(atan, Atan, LA)
|
EIGEN_MKL_VML_DECLARE_UNARY_CALLS(tan, Tan, LA)
|
||||||
EIGEN_MKL_VML_DECLARE_UNARY_CALLS(tanh, Tanh, LA)
|
EIGEN_MKL_VML_DECLARE_UNARY_CALLS(atan, Atan, LA)
|
||||||
|
EIGEN_MKL_VML_DECLARE_UNARY_CALLS(tanh, Tanh, LA)
|
||||||
// EIGEN_MKL_VML_DECLARE_UNARY_CALLS(abs, Abs, _)
|
// EIGEN_MKL_VML_DECLARE_UNARY_CALLS(abs, Abs, _)
|
||||||
EIGEN_MKL_VML_DECLARE_UNARY_CALLS(exp, Exp, LA)
|
EIGEN_MKL_VML_DECLARE_UNARY_CALLS(exp, Exp, LA)
|
||||||
EIGEN_MKL_VML_DECLARE_UNARY_CALLS(log, Ln, LA)
|
EIGEN_MKL_VML_DECLARE_UNARY_CALLS(log, Ln, LA)
|
||||||
EIGEN_MKL_VML_DECLARE_UNARY_CALLS(log10, Log10, LA)
|
EIGEN_MKL_VML_DECLARE_UNARY_CALLS(log10, Log10, LA)
|
||||||
EIGEN_MKL_VML_DECLARE_UNARY_CALLS(sqrt, Sqrt, _)
|
EIGEN_MKL_VML_DECLARE_UNARY_CALLS(sqrt, Sqrt, _)
|
||||||
|
|
||||||
EIGEN_MKL_VML_DECLARE_UNARY_CALLS_REAL(square, Sqr, _)
|
EIGEN_MKL_VML_DECLARE_UNARY_CALLS_REAL(square, Sqr, _)
|
||||||
EIGEN_MKL_VML_DECLARE_UNARY_CALLS_CPLX(arg, Arg, _)
|
EIGEN_MKL_VML_DECLARE_UNARY_CALLS_CPLX(arg, Arg, _)
|
||||||
EIGEN_MKL_VML_DECLARE_UNARY_CALLS_REAL(round, Round, _)
|
EIGEN_MKL_VML_DECLARE_UNARY_CALLS_REAL(round, Round, _)
|
||||||
EIGEN_MKL_VML_DECLARE_UNARY_CALLS_REAL(floor, Floor, _)
|
EIGEN_MKL_VML_DECLARE_UNARY_CALLS_REAL(floor, Floor, _)
|
||||||
EIGEN_MKL_VML_DECLARE_UNARY_CALLS_REAL(ceil, Ceil, _)
|
EIGEN_MKL_VML_DECLARE_UNARY_CALLS_REAL(ceil, Ceil, _)
|
||||||
EIGEN_MKL_VML_DECLARE_UNARY_CALLS_REAL(cbrt, Cbrt, _)
|
|
||||||
|
|
||||||
#define EIGEN_MKL_VML_DECLARE_POW_CALL(EIGENOP, VMLOP, EIGENTYPE, VMLTYPE, VMLMODE) \
|
#define EIGEN_MKL_VML_DECLARE_POW_CALL(EIGENOP, VMLOP, EIGENTYPE, VMLTYPE, VMLMODE) \
|
||||||
template <typename DstXprType, typename SrcXprNested, typename Plain> \
|
template< typename DstXprType, typename SrcXprNested, typename Plain> \
|
||||||
struct Assignment<DstXprType, \
|
struct Assignment<DstXprType, CwiseBinaryOp<scalar_##EIGENOP##_op<EIGENTYPE,EIGENTYPE>, SrcXprNested, \
|
||||||
CwiseBinaryOp<scalar_##EIGENOP##_op<EIGENTYPE, EIGENTYPE>, SrcXprNested, \
|
const CwiseNullaryOp<internal::scalar_constant_op<EIGENTYPE>,Plain> >, assign_op<EIGENTYPE,EIGENTYPE>, \
|
||||||
const CwiseNullaryOp<internal::scalar_constant_op<EIGENTYPE>, Plain>>, \
|
Dense2Dense, typename enable_if<vml_assign_traits<DstXprType,SrcXprNested>::EnableVml>::type> { \
|
||||||
assign_op<EIGENTYPE, EIGENTYPE>, Dense2Dense, \
|
typedef CwiseBinaryOp<scalar_##EIGENOP##_op<EIGENTYPE,EIGENTYPE>, SrcXprNested, \
|
||||||
std::enable_if_t<vml_assign_traits<DstXprType, SrcXprNested>::EnableVml>> { \
|
const CwiseNullaryOp<internal::scalar_constant_op<EIGENTYPE>,Plain> > SrcXprType; \
|
||||||
typedef CwiseBinaryOp<scalar_##EIGENOP##_op<EIGENTYPE, EIGENTYPE>, SrcXprNested, \
|
static void run(DstXprType &dst, const SrcXprType &src, const assign_op<EIGENTYPE,EIGENTYPE> &func) { \
|
||||||
const CwiseNullaryOp<internal::scalar_constant_op<EIGENTYPE>, Plain>> \
|
resize_if_allowed(dst, src, func); \
|
||||||
SrcXprType; \
|
eigen_assert(dst.rows() == src.rows() && dst.cols() == src.cols()); \
|
||||||
static void run(DstXprType &dst, const SrcXprType &src, const assign_op<EIGENTYPE, EIGENTYPE> &func) { \
|
VMLTYPE exponent = reinterpret_cast<const VMLTYPE&>(src.rhs().functor().m_other); \
|
||||||
resize_if_allowed(dst, src, func); \
|
if(vml_assign_traits<DstXprType,SrcXprNested>::Traversal==LinearTraversal) \
|
||||||
eigen_assert(dst.rows() == src.rows() && dst.cols() == src.cols()); \
|
{ \
|
||||||
VMLTYPE exponent = reinterpret_cast<const VMLTYPE &>(src.rhs().functor().m_other); \
|
VMLOP( dst.size(), (const VMLTYPE*)src.lhs().data(), exponent, \
|
||||||
if (vml_assign_traits<DstXprType, SrcXprNested>::Traversal == LinearTraversal) { \
|
(VMLTYPE*)dst.data() EIGEN_PP_EXPAND(EIGEN_VMLMODE_EXPAND_x##VMLMODE) ); \
|
||||||
VMLOP(dst.size(), (const VMLTYPE *)src.lhs().data(), exponent, \
|
} else { \
|
||||||
(VMLTYPE *)dst.data() EIGEN_PP_EXPAND(EIGEN_VMLMODE_EXPAND_x##VMLMODE)); \
|
const Index outerSize = dst.outerSize(); \
|
||||||
} else { \
|
for(Index outer = 0; outer < outerSize; ++outer) { \
|
||||||
const Index outerSize = dst.outerSize(); \
|
const EIGENTYPE *src_ptr = src.IsRowMajor ? &(src.lhs().coeffRef(outer,0)) : \
|
||||||
for (Index outer = 0; outer < outerSize; ++outer) { \
|
&(src.lhs().coeffRef(0, outer)); \
|
||||||
const EIGENTYPE *src_ptr = \
|
EIGENTYPE *dst_ptr = dst.IsRowMajor ? &(dst.coeffRef(outer,0)) : &(dst.coeffRef(0, outer)); \
|
||||||
src.IsRowMajor ? &(src.lhs().coeffRef(outer, 0)) : &(src.lhs().coeffRef(0, outer)); \
|
VMLOP( dst.innerSize(), (const VMLTYPE*)src_ptr, exponent, \
|
||||||
EIGENTYPE *dst_ptr = dst.IsRowMajor ? &(dst.coeffRef(outer, 0)) : &(dst.coeffRef(0, outer)); \
|
(VMLTYPE*)dst_ptr EIGEN_PP_EXPAND(EIGEN_VMLMODE_EXPAND_x##VMLMODE)); \
|
||||||
VMLOP(dst.innerSize(), (const VMLTYPE *)src_ptr, exponent, \
|
} \
|
||||||
(VMLTYPE *)dst_ptr EIGEN_PP_EXPAND(EIGEN_VMLMODE_EXPAND_x##VMLMODE)); \
|
} \
|
||||||
} \
|
} \
|
||||||
} \
|
|
||||||
} \
|
|
||||||
};
|
};
|
||||||
|
|
||||||
EIGEN_MKL_VML_DECLARE_POW_CALL(pow, vmsPowx, float, float, LA)
|
EIGEN_MKL_VML_DECLARE_POW_CALL(pow, vmsPowx, float, float, LA)
|
||||||
EIGEN_MKL_VML_DECLARE_POW_CALL(pow, vmdPowx, double, double, LA)
|
EIGEN_MKL_VML_DECLARE_POW_CALL(pow, vmdPowx, double, double, LA)
|
||||||
EIGEN_MKL_VML_DECLARE_POW_CALL(pow, vmcPowx, scomplex, MKL_Complex8, LA)
|
EIGEN_MKL_VML_DECLARE_POW_CALL(pow, vmcPowx, scomplex, MKL_Complex8, LA)
|
||||||
EIGEN_MKL_VML_DECLARE_POW_CALL(pow, vmzPowx, dcomplex, MKL_Complex16, LA)
|
EIGEN_MKL_VML_DECLARE_POW_CALL(pow, vmzPowx, dcomplex, MKL_Complex16, LA)
|
||||||
|
|
||||||
} // end namespace internal
|
} // end namespace internal
|
||||||
|
|
||||||
} // end namespace Eigen
|
} // end namespace Eigen
|
||||||
|
|
||||||
#endif // EIGEN_ASSIGN_VML_H
|
#endif // EIGEN_ASSIGN_VML_H
|
||||||
|
|||||||
@@ -10,329 +10,344 @@
|
|||||||
#ifndef EIGEN_BANDMATRIX_H
|
#ifndef EIGEN_BANDMATRIX_H
|
||||||
#define EIGEN_BANDMATRIX_H
|
#define EIGEN_BANDMATRIX_H
|
||||||
|
|
||||||
// IWYU pragma: private
|
|
||||||
#include "./InternalHeaderCheck.h"
|
|
||||||
|
|
||||||
namespace Eigen {
|
namespace Eigen {
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
template <typename Derived>
|
template<typename Derived>
|
||||||
class BandMatrixBase : public EigenBase<Derived> {
|
class BandMatrixBase : public EigenBase<Derived>
|
||||||
public:
|
{
|
||||||
enum {
|
public:
|
||||||
Flags = internal::traits<Derived>::Flags,
|
|
||||||
CoeffReadCost = internal::traits<Derived>::CoeffReadCost,
|
|
||||||
RowsAtCompileTime = internal::traits<Derived>::RowsAtCompileTime,
|
|
||||||
ColsAtCompileTime = internal::traits<Derived>::ColsAtCompileTime,
|
|
||||||
MaxRowsAtCompileTime = internal::traits<Derived>::MaxRowsAtCompileTime,
|
|
||||||
MaxColsAtCompileTime = internal::traits<Derived>::MaxColsAtCompileTime,
|
|
||||||
Supers = internal::traits<Derived>::Supers,
|
|
||||||
Subs = internal::traits<Derived>::Subs,
|
|
||||||
Options = internal::traits<Derived>::Options
|
|
||||||
};
|
|
||||||
typedef typename internal::traits<Derived>::Scalar Scalar;
|
|
||||||
typedef Matrix<Scalar, RowsAtCompileTime, ColsAtCompileTime> DenseMatrixType;
|
|
||||||
typedef typename DenseMatrixType::StorageIndex StorageIndex;
|
|
||||||
typedef typename internal::traits<Derived>::CoefficientsType CoefficientsType;
|
|
||||||
typedef EigenBase<Derived> Base;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
enum {
|
|
||||||
DataRowsAtCompileTime = ((Supers != Dynamic) && (Subs != Dynamic)) ? 1 + Supers + Subs : Dynamic,
|
|
||||||
SizeAtCompileTime = min_size_prefer_dynamic(RowsAtCompileTime, ColsAtCompileTime)
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
|
||||||
using Base::cols;
|
|
||||||
using Base::derived;
|
|
||||||
using Base::rows;
|
|
||||||
|
|
||||||
/** \returns the number of super diagonals */
|
|
||||||
inline Index supers() const { return derived().supers(); }
|
|
||||||
|
|
||||||
/** \returns the number of sub diagonals */
|
|
||||||
inline Index subs() const { return derived().subs(); }
|
|
||||||
|
|
||||||
/** \returns an expression of the underlying coefficient matrix */
|
|
||||||
inline const CoefficientsType& coeffs() const { return derived().coeffs(); }
|
|
||||||
|
|
||||||
/** \returns an expression of the underlying coefficient matrix */
|
|
||||||
inline CoefficientsType& coeffs() { return derived().coeffs(); }
|
|
||||||
|
|
||||||
/** \returns a vector expression of the \a i -th column,
|
|
||||||
* only the meaningful part is returned.
|
|
||||||
* \warning the internal storage must be column major. */
|
|
||||||
inline Block<CoefficientsType, Dynamic, 1> col(Index i) {
|
|
||||||
EIGEN_STATIC_ASSERT((int(Options) & int(RowMajor)) == 0, THIS_METHOD_IS_ONLY_FOR_COLUMN_MAJOR_MATRICES);
|
|
||||||
Index start = 0;
|
|
||||||
Index len = coeffs().rows();
|
|
||||||
if (i <= supers()) {
|
|
||||||
start = supers() - i;
|
|
||||||
len = (std::min)(rows(), std::max<Index>(0, coeffs().rows() - (supers() - i)));
|
|
||||||
} else if (i >= rows() - subs())
|
|
||||||
len = std::max<Index>(0, coeffs().rows() - (i + 1 - rows() + subs()));
|
|
||||||
return Block<CoefficientsType, Dynamic, 1>(coeffs(), start, i, len, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** \returns a vector expression of the main diagonal */
|
|
||||||
inline Block<CoefficientsType, 1, SizeAtCompileTime> diagonal() {
|
|
||||||
return Block<CoefficientsType, 1, SizeAtCompileTime>(coeffs(), supers(), 0, 1, (std::min)(rows(), cols()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** \returns a vector expression of the main diagonal (const version) */
|
|
||||||
inline const Block<const CoefficientsType, 1, SizeAtCompileTime> diagonal() const {
|
|
||||||
return Block<const CoefficientsType, 1, SizeAtCompileTime>(coeffs(), supers(), 0, 1, (std::min)(rows(), cols()));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <int Index>
|
|
||||||
struct DiagonalIntReturnType {
|
|
||||||
enum {
|
enum {
|
||||||
ReturnOpposite =
|
Flags = internal::traits<Derived>::Flags,
|
||||||
(int(Options) & int(SelfAdjoint)) && (((Index) > 0 && Supers == 0) || ((Index) < 0 && Subs == 0)),
|
CoeffReadCost = internal::traits<Derived>::CoeffReadCost,
|
||||||
Conjugate = ReturnOpposite && NumTraits<Scalar>::IsComplex,
|
RowsAtCompileTime = internal::traits<Derived>::RowsAtCompileTime,
|
||||||
ActualIndex = ReturnOpposite ? -Index : Index,
|
ColsAtCompileTime = internal::traits<Derived>::ColsAtCompileTime,
|
||||||
DiagonalSize =
|
MaxRowsAtCompileTime = internal::traits<Derived>::MaxRowsAtCompileTime,
|
||||||
(RowsAtCompileTime == Dynamic || ColsAtCompileTime == Dynamic)
|
MaxColsAtCompileTime = internal::traits<Derived>::MaxColsAtCompileTime,
|
||||||
? Dynamic
|
Supers = internal::traits<Derived>::Supers,
|
||||||
: (ActualIndex < 0 ? min_size_prefer_dynamic(ColsAtCompileTime, RowsAtCompileTime + ActualIndex)
|
Subs = internal::traits<Derived>::Subs,
|
||||||
: min_size_prefer_dynamic(RowsAtCompileTime, ColsAtCompileTime - ActualIndex))
|
Options = internal::traits<Derived>::Options
|
||||||
};
|
};
|
||||||
typedef Block<CoefficientsType, 1, DiagonalSize> BuildType;
|
typedef typename internal::traits<Derived>::Scalar Scalar;
|
||||||
typedef std::conditional_t<Conjugate, CwiseUnaryOp<internal::scalar_conjugate_op<Scalar>, BuildType>, BuildType>
|
typedef Matrix<Scalar,RowsAtCompileTime,ColsAtCompileTime> DenseMatrixType;
|
||||||
Type;
|
typedef typename DenseMatrixType::StorageIndex StorageIndex;
|
||||||
};
|
typedef typename internal::traits<Derived>::CoefficientsType CoefficientsType;
|
||||||
|
typedef EigenBase<Derived> Base;
|
||||||
|
|
||||||
/** \returns a vector expression of the \a N -th sub or super diagonal */
|
protected:
|
||||||
template <int N>
|
enum {
|
||||||
inline typename DiagonalIntReturnType<N>::Type diagonal() {
|
DataRowsAtCompileTime = ((Supers!=Dynamic) && (Subs!=Dynamic))
|
||||||
return typename DiagonalIntReturnType<N>::BuildType(coeffs(), supers() - N, (std::max)(0, N), 1, diagonalLength(N));
|
? 1 + Supers + Subs
|
||||||
}
|
: Dynamic,
|
||||||
|
SizeAtCompileTime = EIGEN_SIZE_MIN_PREFER_DYNAMIC(RowsAtCompileTime,ColsAtCompileTime)
|
||||||
|
};
|
||||||
|
|
||||||
/** \returns a vector expression of the \a N -th sub or super diagonal */
|
public:
|
||||||
template <int N>
|
|
||||||
inline const typename DiagonalIntReturnType<N>::Type diagonal() const {
|
|
||||||
return typename DiagonalIntReturnType<N>::BuildType(coeffs(), supers() - N, (std::max)(0, N), 1, diagonalLength(N));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** \returns a vector expression of the \a i -th sub or super diagonal */
|
using Base::derived;
|
||||||
inline Block<CoefficientsType, 1, Dynamic> diagonal(Index i) {
|
using Base::rows;
|
||||||
eigen_assert((i < 0 && -i <= subs()) || (i >= 0 && i <= supers()));
|
using Base::cols;
|
||||||
return Block<CoefficientsType, 1, Dynamic>(coeffs(), supers() - i, std::max<Index>(0, i), 1, diagonalLength(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** \returns a vector expression of the \a i -th sub or super diagonal */
|
/** \returns the number of super diagonals */
|
||||||
inline const Block<const CoefficientsType, 1, Dynamic> diagonal(Index i) const {
|
inline Index supers() const { return derived().supers(); }
|
||||||
eigen_assert((i < 0 && -i <= subs()) || (i >= 0 && i <= supers()));
|
|
||||||
return Block<const CoefficientsType, 1, Dynamic>(coeffs(), supers() - i, std::max<Index>(0, i), 1,
|
|
||||||
diagonalLength(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Dest>
|
/** \returns the number of sub diagonals */
|
||||||
inline void evalTo(Dest& dst) const {
|
inline Index subs() const { return derived().subs(); }
|
||||||
dst.resize(rows(), cols());
|
|
||||||
dst.setZero();
|
|
||||||
dst.diagonal() = diagonal();
|
|
||||||
for (Index i = 1; i <= supers(); ++i) dst.diagonal(i) = diagonal(i);
|
|
||||||
for (Index i = 1; i <= subs(); ++i) dst.diagonal(-i) = diagonal(-i);
|
|
||||||
}
|
|
||||||
|
|
||||||
DenseMatrixType toDenseMatrix() const {
|
/** \returns an expression of the underlying coefficient matrix */
|
||||||
DenseMatrixType res(rows(), cols());
|
inline const CoefficientsType& coeffs() const { return derived().coeffs(); }
|
||||||
evalTo(res);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
/** \returns an expression of the underlying coefficient matrix */
|
||||||
inline Index diagonalLength(Index i) const {
|
inline CoefficientsType& coeffs() { return derived().coeffs(); }
|
||||||
return i < 0 ? (std::min)(cols(), rows() + i) : (std::min)(rows(), cols() - i);
|
|
||||||
}
|
/** \returns a vector expression of the \a i -th column,
|
||||||
|
* only the meaningful part is returned.
|
||||||
|
* \warning the internal storage must be column major. */
|
||||||
|
inline Block<CoefficientsType,Dynamic,1> col(Index i)
|
||||||
|
{
|
||||||
|
EIGEN_STATIC_ASSERT((int(Options) & int(RowMajor)) == 0, THIS_METHOD_IS_ONLY_FOR_COLUMN_MAJOR_MATRICES);
|
||||||
|
Index start = 0;
|
||||||
|
Index len = coeffs().rows();
|
||||||
|
if (i<=supers())
|
||||||
|
{
|
||||||
|
start = supers()-i;
|
||||||
|
len = (std::min)(rows(),std::max<Index>(0,coeffs().rows() - (supers()-i)));
|
||||||
|
}
|
||||||
|
else if (i>=rows()-subs())
|
||||||
|
len = std::max<Index>(0,coeffs().rows() - (i + 1 - rows() + subs()));
|
||||||
|
return Block<CoefficientsType,Dynamic,1>(coeffs(), start, i, len, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** \returns a vector expression of the main diagonal */
|
||||||
|
inline Block<CoefficientsType,1,SizeAtCompileTime> diagonal()
|
||||||
|
{ return Block<CoefficientsType,1,SizeAtCompileTime>(coeffs(),supers(),0,1,(std::min)(rows(),cols())); }
|
||||||
|
|
||||||
|
/** \returns a vector expression of the main diagonal (const version) */
|
||||||
|
inline const Block<const CoefficientsType,1,SizeAtCompileTime> diagonal() const
|
||||||
|
{ return Block<const CoefficientsType,1,SizeAtCompileTime>(coeffs(),supers(),0,1,(std::min)(rows(),cols())); }
|
||||||
|
|
||||||
|
template<int Index> struct DiagonalIntReturnType {
|
||||||
|
enum {
|
||||||
|
ReturnOpposite = (int(Options) & int(SelfAdjoint)) && (((Index) > 0 && Supers == 0) || ((Index) < 0 && Subs == 0)),
|
||||||
|
Conjugate = ReturnOpposite && NumTraits<Scalar>::IsComplex,
|
||||||
|
ActualIndex = ReturnOpposite ? -Index : Index,
|
||||||
|
DiagonalSize = (RowsAtCompileTime==Dynamic || ColsAtCompileTime==Dynamic)
|
||||||
|
? Dynamic
|
||||||
|
: (ActualIndex<0
|
||||||
|
? EIGEN_SIZE_MIN_PREFER_DYNAMIC(ColsAtCompileTime, RowsAtCompileTime + ActualIndex)
|
||||||
|
: EIGEN_SIZE_MIN_PREFER_DYNAMIC(RowsAtCompileTime, ColsAtCompileTime - ActualIndex))
|
||||||
|
};
|
||||||
|
typedef Block<CoefficientsType,1, DiagonalSize> BuildType;
|
||||||
|
typedef typename internal::conditional<Conjugate,
|
||||||
|
CwiseUnaryOp<internal::scalar_conjugate_op<Scalar>,BuildType >,
|
||||||
|
BuildType>::type Type;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** \returns a vector expression of the \a N -th sub or super diagonal */
|
||||||
|
template<int N> inline typename DiagonalIntReturnType<N>::Type diagonal()
|
||||||
|
{
|
||||||
|
return typename DiagonalIntReturnType<N>::BuildType(coeffs(), supers()-N, (std::max)(0,N), 1, diagonalLength(N));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** \returns a vector expression of the \a N -th sub or super diagonal */
|
||||||
|
template<int N> inline const typename DiagonalIntReturnType<N>::Type diagonal() const
|
||||||
|
{
|
||||||
|
return typename DiagonalIntReturnType<N>::BuildType(coeffs(), supers()-N, (std::max)(0,N), 1, diagonalLength(N));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** \returns a vector expression of the \a i -th sub or super diagonal */
|
||||||
|
inline Block<CoefficientsType,1,Dynamic> diagonal(Index i)
|
||||||
|
{
|
||||||
|
eigen_assert((i<0 && -i<=subs()) || (i>=0 && i<=supers()));
|
||||||
|
return Block<CoefficientsType,1,Dynamic>(coeffs(), supers()-i, std::max<Index>(0,i), 1, diagonalLength(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** \returns a vector expression of the \a i -th sub or super diagonal */
|
||||||
|
inline const Block<const CoefficientsType,1,Dynamic> diagonal(Index i) const
|
||||||
|
{
|
||||||
|
eigen_assert((i<0 && -i<=subs()) || (i>=0 && i<=supers()));
|
||||||
|
return Block<const CoefficientsType,1,Dynamic>(coeffs(), supers()-i, std::max<Index>(0,i), 1, diagonalLength(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename Dest> inline void evalTo(Dest& dst) const
|
||||||
|
{
|
||||||
|
dst.resize(rows(),cols());
|
||||||
|
dst.setZero();
|
||||||
|
dst.diagonal() = diagonal();
|
||||||
|
for (Index i=1; i<=supers();++i)
|
||||||
|
dst.diagonal(i) = diagonal(i);
|
||||||
|
for (Index i=1; i<=subs();++i)
|
||||||
|
dst.diagonal(-i) = diagonal(-i);
|
||||||
|
}
|
||||||
|
|
||||||
|
DenseMatrixType toDenseMatrix() const
|
||||||
|
{
|
||||||
|
DenseMatrixType res(rows(),cols());
|
||||||
|
evalTo(res);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
inline Index diagonalLength(Index i) const
|
||||||
|
{ return i<0 ? (std::min)(cols(),rows()+i) : (std::min)(rows(),cols()-i); }
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \class BandMatrix
|
* \class BandMatrix
|
||||||
* \ingroup Core_Module
|
* \ingroup Core_Module
|
||||||
*
|
*
|
||||||
* \brief Represents a rectangular matrix with a banded storage
|
* \brief Represents a rectangular matrix with a banded storage
|
||||||
*
|
*
|
||||||
* \tparam Scalar_ Numeric type, i.e. float, double, int
|
* \tparam _Scalar Numeric type, i.e. float, double, int
|
||||||
* \tparam Rows_ Number of rows, or \b Dynamic
|
* \tparam _Rows Number of rows, or \b Dynamic
|
||||||
* \tparam Cols_ Number of columns, or \b Dynamic
|
* \tparam _Cols Number of columns, or \b Dynamic
|
||||||
* \tparam Supers_ Number of super diagonal
|
* \tparam _Supers Number of super diagonal
|
||||||
* \tparam Subs_ Number of sub diagonal
|
* \tparam _Subs Number of sub diagonal
|
||||||
* \tparam Options_ A combination of either \b #RowMajor or \b #ColMajor, and of \b #SelfAdjoint
|
* \tparam _Options A combination of either \b #RowMajor or \b #ColMajor, and of \b #SelfAdjoint
|
||||||
* The former controls \ref TopicStorageOrders "storage order", and defaults to
|
* The former controls \ref TopicStorageOrders "storage order", and defaults to
|
||||||
* column-major. The latter controls whether the matrix represents a selfadjoint
|
* column-major. The latter controls whether the matrix represents a selfadjoint
|
||||||
* matrix in which case either Supers of Subs have to be null.
|
* matrix in which case either Supers of Subs have to be null.
|
||||||
*
|
*
|
||||||
* \sa class TridiagonalMatrix
|
* \sa class TridiagonalMatrix
|
||||||
*/
|
*/
|
||||||
|
|
||||||
template <typename Scalar_, int Rows_, int Cols_, int Supers_, int Subs_, int Options_>
|
template<typename _Scalar, int _Rows, int _Cols, int _Supers, int _Subs, int _Options>
|
||||||
struct traits<BandMatrix<Scalar_, Rows_, Cols_, Supers_, Subs_, Options_> > {
|
struct traits<BandMatrix<_Scalar,_Rows,_Cols,_Supers,_Subs,_Options> >
|
||||||
typedef Scalar_ Scalar;
|
{
|
||||||
|
typedef _Scalar Scalar;
|
||||||
typedef Dense StorageKind;
|
typedef Dense StorageKind;
|
||||||
typedef Eigen::Index StorageIndex;
|
typedef Eigen::Index StorageIndex;
|
||||||
enum {
|
enum {
|
||||||
CoeffReadCost = NumTraits<Scalar>::ReadCost,
|
CoeffReadCost = NumTraits<Scalar>::ReadCost,
|
||||||
RowsAtCompileTime = Rows_,
|
RowsAtCompileTime = _Rows,
|
||||||
ColsAtCompileTime = Cols_,
|
ColsAtCompileTime = _Cols,
|
||||||
MaxRowsAtCompileTime = Rows_,
|
MaxRowsAtCompileTime = _Rows,
|
||||||
MaxColsAtCompileTime = Cols_,
|
MaxColsAtCompileTime = _Cols,
|
||||||
Flags = LvalueBit,
|
Flags = LvalueBit,
|
||||||
Supers = Supers_,
|
Supers = _Supers,
|
||||||
Subs = Subs_,
|
Subs = _Subs,
|
||||||
Options = Options_,
|
Options = _Options,
|
||||||
DataRowsAtCompileTime = ((Supers != Dynamic) && (Subs != Dynamic)) ? 1 + Supers + Subs : Dynamic
|
DataRowsAtCompileTime = ((Supers!=Dynamic) && (Subs!=Dynamic)) ? 1 + Supers + Subs : Dynamic
|
||||||
};
|
};
|
||||||
typedef Matrix<Scalar, DataRowsAtCompileTime, ColsAtCompileTime, int(Options) & int(RowMajor) ? RowMajor : ColMajor>
|
typedef Matrix<Scalar, DataRowsAtCompileTime, ColsAtCompileTime, int(Options) & int(RowMajor) ? RowMajor : ColMajor> CoefficientsType;
|
||||||
CoefficientsType;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Scalar_, int Rows, int Cols, int Supers, int Subs, int Options>
|
template<typename _Scalar, int Rows, int Cols, int Supers, int Subs, int Options>
|
||||||
class BandMatrix : public BandMatrixBase<BandMatrix<Scalar_, Rows, Cols, Supers, Subs, Options> > {
|
class BandMatrix : public BandMatrixBase<BandMatrix<_Scalar,Rows,Cols,Supers,Subs,Options> >
|
||||||
public:
|
{
|
||||||
typedef typename internal::traits<BandMatrix>::Scalar Scalar;
|
public:
|
||||||
typedef typename internal::traits<BandMatrix>::StorageIndex StorageIndex;
|
|
||||||
typedef typename internal::traits<BandMatrix>::CoefficientsType CoefficientsType;
|
|
||||||
|
|
||||||
explicit inline BandMatrix(Index rows = Rows, Index cols = Cols, Index supers = Supers, Index subs = Subs)
|
typedef typename internal::traits<BandMatrix>::Scalar Scalar;
|
||||||
: m_coeffs(1 + supers + subs, cols), m_rows(rows), m_supers(supers), m_subs(subs) {}
|
typedef typename internal::traits<BandMatrix>::StorageIndex StorageIndex;
|
||||||
|
typedef typename internal::traits<BandMatrix>::CoefficientsType CoefficientsType;
|
||||||
|
|
||||||
/** \returns the number of columns */
|
explicit inline BandMatrix(Index rows=Rows, Index cols=Cols, Index supers=Supers, Index subs=Subs)
|
||||||
constexpr Index rows() const { return m_rows.value(); }
|
: m_coeffs(1+supers+subs,cols),
|
||||||
|
m_rows(rows), m_supers(supers), m_subs(subs)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/** \returns the number of rows */
|
/** \returns the number of columns */
|
||||||
constexpr Index cols() const { return m_coeffs.cols(); }
|
inline EIGEN_CONSTEXPR Index rows() const { return m_rows.value(); }
|
||||||
|
|
||||||
/** \returns the number of super diagonals */
|
/** \returns the number of rows */
|
||||||
constexpr Index supers() const { return m_supers.value(); }
|
inline EIGEN_CONSTEXPR Index cols() const { return m_coeffs.cols(); }
|
||||||
|
|
||||||
/** \returns the number of sub diagonals */
|
/** \returns the number of super diagonals */
|
||||||
constexpr Index subs() const { return m_subs.value(); }
|
inline EIGEN_CONSTEXPR Index supers() const { return m_supers.value(); }
|
||||||
|
|
||||||
inline const CoefficientsType& coeffs() const { return m_coeffs; }
|
/** \returns the number of sub diagonals */
|
||||||
inline CoefficientsType& coeffs() { return m_coeffs; }
|
inline EIGEN_CONSTEXPR Index subs() const { return m_subs.value(); }
|
||||||
|
|
||||||
protected:
|
inline const CoefficientsType& coeffs() const { return m_coeffs; }
|
||||||
CoefficientsType m_coeffs;
|
inline CoefficientsType& coeffs() { return m_coeffs; }
|
||||||
internal::variable_if_dynamic<Index, Rows> m_rows;
|
|
||||||
internal::variable_if_dynamic<Index, Supers> m_supers;
|
protected:
|
||||||
internal::variable_if_dynamic<Index, Subs> m_subs;
|
|
||||||
|
CoefficientsType m_coeffs;
|
||||||
|
internal::variable_if_dynamic<Index, Rows> m_rows;
|
||||||
|
internal::variable_if_dynamic<Index, Supers> m_supers;
|
||||||
|
internal::variable_if_dynamic<Index, Subs> m_subs;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename CoefficientsType_, int Rows_, int Cols_, int Supers_, int Subs_, int Options_>
|
template<typename _CoefficientsType,int _Rows, int _Cols, int _Supers, int _Subs,int _Options>
|
||||||
class BandMatrixWrapper;
|
class BandMatrixWrapper;
|
||||||
|
|
||||||
template <typename CoefficientsType_, int Rows_, int Cols_, int Supers_, int Subs_, int Options_>
|
template<typename _CoefficientsType,int _Rows, int _Cols, int _Supers, int _Subs,int _Options>
|
||||||
struct traits<BandMatrixWrapper<CoefficientsType_, Rows_, Cols_, Supers_, Subs_, Options_> > {
|
struct traits<BandMatrixWrapper<_CoefficientsType,_Rows,_Cols,_Supers,_Subs,_Options> >
|
||||||
typedef typename CoefficientsType_::Scalar Scalar;
|
{
|
||||||
typedef typename CoefficientsType_::StorageKind StorageKind;
|
typedef typename _CoefficientsType::Scalar Scalar;
|
||||||
typedef typename CoefficientsType_::StorageIndex StorageIndex;
|
typedef typename _CoefficientsType::StorageKind StorageKind;
|
||||||
|
typedef typename _CoefficientsType::StorageIndex StorageIndex;
|
||||||
enum {
|
enum {
|
||||||
CoeffReadCost = internal::traits<CoefficientsType_>::CoeffReadCost,
|
CoeffReadCost = internal::traits<_CoefficientsType>::CoeffReadCost,
|
||||||
RowsAtCompileTime = Rows_,
|
RowsAtCompileTime = _Rows,
|
||||||
ColsAtCompileTime = Cols_,
|
ColsAtCompileTime = _Cols,
|
||||||
MaxRowsAtCompileTime = Rows_,
|
MaxRowsAtCompileTime = _Rows,
|
||||||
MaxColsAtCompileTime = Cols_,
|
MaxColsAtCompileTime = _Cols,
|
||||||
Flags = LvalueBit,
|
Flags = LvalueBit,
|
||||||
Supers = Supers_,
|
Supers = _Supers,
|
||||||
Subs = Subs_,
|
Subs = _Subs,
|
||||||
Options = Options_,
|
Options = _Options,
|
||||||
DataRowsAtCompileTime = ((Supers != Dynamic) && (Subs != Dynamic)) ? 1 + Supers + Subs : Dynamic
|
DataRowsAtCompileTime = ((Supers!=Dynamic) && (Subs!=Dynamic)) ? 1 + Supers + Subs : Dynamic
|
||||||
};
|
};
|
||||||
typedef CoefficientsType_ CoefficientsType;
|
typedef _CoefficientsType CoefficientsType;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename CoefficientsType_, int Rows_, int Cols_, int Supers_, int Subs_, int Options_>
|
template<typename _CoefficientsType,int _Rows, int _Cols, int _Supers, int _Subs,int _Options>
|
||||||
class BandMatrixWrapper
|
class BandMatrixWrapper : public BandMatrixBase<BandMatrixWrapper<_CoefficientsType,_Rows,_Cols,_Supers,_Subs,_Options> >
|
||||||
: public BandMatrixBase<BandMatrixWrapper<CoefficientsType_, Rows_, Cols_, Supers_, Subs_, Options_> > {
|
{
|
||||||
public:
|
public:
|
||||||
typedef typename internal::traits<BandMatrixWrapper>::Scalar Scalar;
|
|
||||||
typedef typename internal::traits<BandMatrixWrapper>::CoefficientsType CoefficientsType;
|
|
||||||
typedef typename internal::traits<BandMatrixWrapper>::StorageIndex StorageIndex;
|
|
||||||
|
|
||||||
explicit inline BandMatrixWrapper(const CoefficientsType& coeffs, Index rows = Rows_, Index cols = Cols_,
|
typedef typename internal::traits<BandMatrixWrapper>::Scalar Scalar;
|
||||||
Index supers = Supers_, Index subs = Subs_)
|
typedef typename internal::traits<BandMatrixWrapper>::CoefficientsType CoefficientsType;
|
||||||
: m_coeffs(coeffs), m_rows(rows), m_supers(supers), m_subs(subs) {
|
typedef typename internal::traits<BandMatrixWrapper>::StorageIndex StorageIndex;
|
||||||
EIGEN_UNUSED_VARIABLE(cols);
|
|
||||||
// eigen_assert(coeffs.cols()==cols() && (supers()+subs()+1)==coeffs.rows());
|
|
||||||
}
|
|
||||||
|
|
||||||
/** \returns the number of columns */
|
explicit inline BandMatrixWrapper(const CoefficientsType& coeffs, Index rows=_Rows, Index cols=_Cols, Index supers=_Supers, Index subs=_Subs)
|
||||||
constexpr Index rows() const { return m_rows.value(); }
|
: m_coeffs(coeffs),
|
||||||
|
m_rows(rows), m_supers(supers), m_subs(subs)
|
||||||
|
{
|
||||||
|
EIGEN_UNUSED_VARIABLE(cols);
|
||||||
|
//internal::assert(coeffs.cols()==cols() && (supers()+subs()+1)==coeffs.rows());
|
||||||
|
}
|
||||||
|
|
||||||
/** \returns the number of rows */
|
/** \returns the number of columns */
|
||||||
constexpr Index cols() const { return m_coeffs.cols(); }
|
inline EIGEN_CONSTEXPR Index rows() const { return m_rows.value(); }
|
||||||
|
|
||||||
/** \returns the number of super diagonals */
|
/** \returns the number of rows */
|
||||||
constexpr Index supers() const { return m_supers.value(); }
|
inline EIGEN_CONSTEXPR Index cols() const { return m_coeffs.cols(); }
|
||||||
|
|
||||||
/** \returns the number of sub diagonals */
|
/** \returns the number of super diagonals */
|
||||||
constexpr Index subs() const { return m_subs.value(); }
|
inline EIGEN_CONSTEXPR Index supers() const { return m_supers.value(); }
|
||||||
|
|
||||||
inline const CoefficientsType& coeffs() const { return m_coeffs; }
|
/** \returns the number of sub diagonals */
|
||||||
|
inline EIGEN_CONSTEXPR Index subs() const { return m_subs.value(); }
|
||||||
|
|
||||||
protected:
|
inline const CoefficientsType& coeffs() const { return m_coeffs; }
|
||||||
const CoefficientsType& m_coeffs;
|
|
||||||
internal::variable_if_dynamic<Index, Rows_> m_rows;
|
protected:
|
||||||
internal::variable_if_dynamic<Index, Supers_> m_supers;
|
|
||||||
internal::variable_if_dynamic<Index, Subs_> m_subs;
|
const CoefficientsType& m_coeffs;
|
||||||
|
internal::variable_if_dynamic<Index, _Rows> m_rows;
|
||||||
|
internal::variable_if_dynamic<Index, _Supers> m_supers;
|
||||||
|
internal::variable_if_dynamic<Index, _Subs> m_subs;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \class TridiagonalMatrix
|
* \class TridiagonalMatrix
|
||||||
* \ingroup Core_Module
|
* \ingroup Core_Module
|
||||||
*
|
*
|
||||||
* \brief Represents a tridiagonal matrix with a compact banded storage
|
* \brief Represents a tridiagonal matrix with a compact banded storage
|
||||||
*
|
*
|
||||||
* \tparam Scalar Numeric type, i.e. float, double, int
|
* \tparam Scalar Numeric type, i.e. float, double, int
|
||||||
* \tparam Size Number of rows and cols, or \b Dynamic
|
* \tparam Size Number of rows and cols, or \b Dynamic
|
||||||
* \tparam Options Can be 0 or \b SelfAdjoint
|
* \tparam Options Can be 0 or \b SelfAdjoint
|
||||||
*
|
*
|
||||||
* \sa class BandMatrix
|
* \sa class BandMatrix
|
||||||
*/
|
*/
|
||||||
template <typename Scalar, int Size, int Options>
|
template<typename Scalar, int Size, int Options>
|
||||||
class TridiagonalMatrix : public BandMatrix<Scalar, Size, Size, Options & SelfAdjoint ? 0 : 1, 1, Options | RowMajor> {
|
class TridiagonalMatrix : public BandMatrix<Scalar,Size,Size,Options&SelfAdjoint?0:1,1,Options|RowMajor>
|
||||||
typedef BandMatrix<Scalar, Size, Size, Options & SelfAdjoint ? 0 : 1, 1, Options | RowMajor> Base;
|
{
|
||||||
typedef typename Base::StorageIndex StorageIndex;
|
typedef BandMatrix<Scalar,Size,Size,Options&SelfAdjoint?0:1,1,Options|RowMajor> Base;
|
||||||
|
typedef typename Base::StorageIndex StorageIndex;
|
||||||
|
public:
|
||||||
|
explicit TridiagonalMatrix(Index size = Size) : Base(size,size,Options&SelfAdjoint?0:1,1) {}
|
||||||
|
|
||||||
public:
|
inline typename Base::template DiagonalIntReturnType<1>::Type super()
|
||||||
explicit TridiagonalMatrix(Index size = Size) : Base(size, size, Options & SelfAdjoint ? 0 : 1, 1) {}
|
{ return Base::template diagonal<1>(); }
|
||||||
|
inline const typename Base::template DiagonalIntReturnType<1>::Type super() const
|
||||||
inline typename Base::template DiagonalIntReturnType<1>::Type super() { return Base::template diagonal<1>(); }
|
{ return Base::template diagonal<1>(); }
|
||||||
inline const typename Base::template DiagonalIntReturnType<1>::Type super() const {
|
inline typename Base::template DiagonalIntReturnType<-1>::Type sub()
|
||||||
return Base::template diagonal<1>();
|
{ return Base::template diagonal<-1>(); }
|
||||||
}
|
inline const typename Base::template DiagonalIntReturnType<-1>::Type sub() const
|
||||||
inline typename Base::template DiagonalIntReturnType<-1>::Type sub() { return Base::template diagonal<-1>(); }
|
{ return Base::template diagonal<-1>(); }
|
||||||
inline const typename Base::template DiagonalIntReturnType<-1>::Type sub() const {
|
protected:
|
||||||
return Base::template diagonal<-1>();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct BandShape {};
|
struct BandShape {};
|
||||||
|
|
||||||
template <typename Scalar_, int Rows_, int Cols_, int Supers_, int Subs_, int Options_>
|
template<typename _Scalar, int _Rows, int _Cols, int _Supers, int _Subs, int _Options>
|
||||||
struct evaluator_traits<BandMatrix<Scalar_, Rows_, Cols_, Supers_, Subs_, Options_> >
|
struct evaluator_traits<BandMatrix<_Scalar,_Rows,_Cols,_Supers,_Subs,_Options> >
|
||||||
: public evaluator_traits_base<BandMatrix<Scalar_, Rows_, Cols_, Supers_, Subs_, Options_> > {
|
: public evaluator_traits_base<BandMatrix<_Scalar,_Rows,_Cols,_Supers,_Subs,_Options> >
|
||||||
|
{
|
||||||
typedef BandShape Shape;
|
typedef BandShape Shape;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename CoefficientsType_, int Rows_, int Cols_, int Supers_, int Subs_, int Options_>
|
template<typename _CoefficientsType,int _Rows, int _Cols, int _Supers, int _Subs,int _Options>
|
||||||
struct evaluator_traits<BandMatrixWrapper<CoefficientsType_, Rows_, Cols_, Supers_, Subs_, Options_> >
|
struct evaluator_traits<BandMatrixWrapper<_CoefficientsType,_Rows,_Cols,_Supers,_Subs,_Options> >
|
||||||
: public evaluator_traits_base<BandMatrixWrapper<CoefficientsType_, Rows_, Cols_, Supers_, Subs_, Options_> > {
|
: public evaluator_traits_base<BandMatrixWrapper<_CoefficientsType,_Rows,_Cols,_Supers,_Subs,_Options> >
|
||||||
|
{
|
||||||
typedef BandShape Shape;
|
typedef BandShape Shape;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template<> struct AssignmentKind<DenseShape,BandShape> { typedef EigenBase2EigenBase Kind; };
|
||||||
struct AssignmentKind<DenseShape, BandShape> {
|
|
||||||
typedef EigenBase2EigenBase Kind;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // end namespace internal
|
} // end namespace internal
|
||||||
|
|
||||||
} // end namespace Eigen
|
} // end namespace Eigen
|
||||||
|
|
||||||
#endif // EIGEN_BANDMATRIX_H
|
#endif // EIGEN_BANDMATRIX_H
|
||||||
|
|||||||
@@ -11,417 +11,453 @@
|
|||||||
#ifndef EIGEN_BLOCK_H
|
#ifndef EIGEN_BLOCK_H
|
||||||
#define EIGEN_BLOCK_H
|
#define EIGEN_BLOCK_H
|
||||||
|
|
||||||
// IWYU pragma: private
|
|
||||||
#include "./InternalHeaderCheck.h"
|
|
||||||
|
|
||||||
namespace Eigen {
|
namespace Eigen {
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
template <typename XprType_, int BlockRows, int BlockCols, bool InnerPanel_>
|
template<typename XprType, int BlockRows, int BlockCols, bool InnerPanel>
|
||||||
struct traits<Block<XprType_, BlockRows, BlockCols, InnerPanel_>> : traits<XprType_> {
|
struct traits<Block<XprType, BlockRows, BlockCols, InnerPanel> > : traits<XprType>
|
||||||
typedef typename traits<XprType_>::Scalar Scalar;
|
{
|
||||||
typedef typename traits<XprType_>::StorageKind StorageKind;
|
typedef typename traits<XprType>::Scalar Scalar;
|
||||||
typedef typename traits<XprType_>::XprKind XprKind;
|
typedef typename traits<XprType>::StorageKind StorageKind;
|
||||||
typedef typename ref_selector<XprType_>::type XprTypeNested;
|
typedef typename traits<XprType>::XprKind XprKind;
|
||||||
typedef std::remove_reference_t<XprTypeNested> XprTypeNested_;
|
typedef typename ref_selector<XprType>::type XprTypeNested;
|
||||||
enum {
|
typedef typename remove_reference<XprTypeNested>::type _XprTypeNested;
|
||||||
MatrixRows = traits<XprType_>::RowsAtCompileTime,
|
enum{
|
||||||
MatrixCols = traits<XprType_>::ColsAtCompileTime,
|
MatrixRows = traits<XprType>::RowsAtCompileTime,
|
||||||
|
MatrixCols = traits<XprType>::ColsAtCompileTime,
|
||||||
RowsAtCompileTime = MatrixRows == 0 ? 0 : BlockRows,
|
RowsAtCompileTime = MatrixRows == 0 ? 0 : BlockRows,
|
||||||
ColsAtCompileTime = MatrixCols == 0 ? 0 : BlockCols,
|
ColsAtCompileTime = MatrixCols == 0 ? 0 : BlockCols,
|
||||||
MaxRowsAtCompileTime = BlockRows == 0 ? 0
|
MaxRowsAtCompileTime = BlockRows==0 ? 0
|
||||||
: RowsAtCompileTime != Dynamic ? int(RowsAtCompileTime)
|
: RowsAtCompileTime != Dynamic ? int(RowsAtCompileTime)
|
||||||
: int(traits<XprType_>::MaxRowsAtCompileTime),
|
: int(traits<XprType>::MaxRowsAtCompileTime),
|
||||||
MaxColsAtCompileTime = BlockCols == 0 ? 0
|
MaxColsAtCompileTime = BlockCols==0 ? 0
|
||||||
: ColsAtCompileTime != Dynamic ? int(ColsAtCompileTime)
|
: ColsAtCompileTime != Dynamic ? int(ColsAtCompileTime)
|
||||||
: int(traits<XprType_>::MaxColsAtCompileTime),
|
: int(traits<XprType>::MaxColsAtCompileTime),
|
||||||
|
|
||||||
XprTypeIsRowMajor = (int(traits<XprType_>::Flags) & RowMajorBit) != 0,
|
XprTypeIsRowMajor = (int(traits<XprType>::Flags)&RowMajorBit) != 0,
|
||||||
IsRowMajor = (MaxRowsAtCompileTime == 1 && MaxColsAtCompileTime != 1) ? 1
|
IsRowMajor = (MaxRowsAtCompileTime==1&&MaxColsAtCompileTime!=1) ? 1
|
||||||
: (MaxColsAtCompileTime == 1 && MaxRowsAtCompileTime != 1) ? 0
|
: (MaxColsAtCompileTime==1&&MaxRowsAtCompileTime!=1) ? 0
|
||||||
: XprTypeIsRowMajor,
|
: XprTypeIsRowMajor,
|
||||||
HasSameStorageOrderAsXprType = (IsRowMajor == XprTypeIsRowMajor),
|
HasSameStorageOrderAsXprType = (IsRowMajor == XprTypeIsRowMajor),
|
||||||
InnerSize = IsRowMajor ? int(ColsAtCompileTime) : int(RowsAtCompileTime),
|
InnerSize = IsRowMajor ? int(ColsAtCompileTime) : int(RowsAtCompileTime),
|
||||||
InnerStrideAtCompileTime = HasSameStorageOrderAsXprType ? int(inner_stride_at_compile_time<XprType_>::ret)
|
InnerStrideAtCompileTime = HasSameStorageOrderAsXprType
|
||||||
: int(outer_stride_at_compile_time<XprType_>::ret),
|
? int(inner_stride_at_compile_time<XprType>::ret)
|
||||||
OuterStrideAtCompileTime = HasSameStorageOrderAsXprType ? int(outer_stride_at_compile_time<XprType_>::ret)
|
: int(outer_stride_at_compile_time<XprType>::ret),
|
||||||
: int(inner_stride_at_compile_time<XprType_>::ret),
|
OuterStrideAtCompileTime = HasSameStorageOrderAsXprType
|
||||||
|
? int(outer_stride_at_compile_time<XprType>::ret)
|
||||||
|
: int(inner_stride_at_compile_time<XprType>::ret),
|
||||||
|
|
||||||
// FIXME, this traits is rather specialized for dense object and it needs to be cleaned further
|
// FIXME, this traits is rather specialized for dense object and it needs to be cleaned further
|
||||||
FlagsLvalueBit = is_lvalue<XprType_>::value ? LvalueBit : 0,
|
FlagsLvalueBit = is_lvalue<XprType>::value ? LvalueBit : 0,
|
||||||
FlagsRowMajorBit = IsRowMajor ? RowMajorBit : 0,
|
FlagsRowMajorBit = IsRowMajor ? RowMajorBit : 0,
|
||||||
Flags = (traits<XprType_>::Flags & (DirectAccessBit | (InnerPanel_ ? CompressedAccessBit : 0))) | FlagsLvalueBit |
|
Flags = (traits<XprType>::Flags & (DirectAccessBit | (InnerPanel?CompressedAccessBit:0))) | FlagsLvalueBit | FlagsRowMajorBit,
|
||||||
FlagsRowMajorBit,
|
|
||||||
// FIXME DirectAccessBit should not be handled by expressions
|
// FIXME DirectAccessBit should not be handled by expressions
|
||||||
//
|
//
|
||||||
// Alignment is needed by MapBase's assertions
|
// Alignment is needed by MapBase's assertions
|
||||||
// We can sefely set it to false here. Internal alignment errors will be detected by an eigen_internal_assert in the
|
// We can sefely set it to false here. Internal alignment errors will be detected by an eigen_internal_assert in the respective evaluator
|
||||||
// respective evaluator
|
Alignment = 0
|
||||||
Alignment = 0,
|
|
||||||
InnerPanel = InnerPanel_ ? 1 : 0
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename XprType, int BlockRows = Dynamic, int BlockCols = Dynamic, bool InnerPanel = false,
|
template<typename XprType, int BlockRows=Dynamic, int BlockCols=Dynamic, bool InnerPanel = false,
|
||||||
bool HasDirectAccess = internal::has_direct_access<XprType>::ret>
|
bool HasDirectAccess = internal::has_direct_access<XprType>::ret> class BlockImpl_dense;
|
||||||
class BlockImpl_dense;
|
|
||||||
|
|
||||||
} // end namespace internal
|
} // end namespace internal
|
||||||
|
|
||||||
template <typename XprType, int BlockRows, int BlockCols, bool InnerPanel, typename StorageKind>
|
template<typename XprType, int BlockRows, int BlockCols, bool InnerPanel, typename StorageKind> class BlockImpl;
|
||||||
class BlockImpl;
|
|
||||||
|
|
||||||
/** \class Block
|
/** \class Block
|
||||||
* \ingroup Core_Module
|
* \ingroup Core_Module
|
||||||
*
|
*
|
||||||
* \brief Expression of a fixed-size or dynamic-size block
|
* \brief Expression of a fixed-size or dynamic-size block
|
||||||
*
|
*
|
||||||
* \tparam XprType the type of the expression in which we are taking a block
|
* \tparam XprType the type of the expression in which we are taking a block
|
||||||
* \tparam BlockRows the number of rows of the block we are taking at compile time (optional)
|
* \tparam BlockRows the number of rows of the block we are taking at compile time (optional)
|
||||||
* \tparam BlockCols the number of columns of the block we are taking at compile time (optional)
|
* \tparam BlockCols the number of columns of the block we are taking at compile time (optional)
|
||||||
* \tparam InnerPanel is true, if the block maps to a set of rows of a row major matrix or
|
* \tparam InnerPanel is true, if the block maps to a set of rows of a row major matrix or
|
||||||
* to set of columns of a column major matrix (optional). The parameter allows to determine
|
* to set of columns of a column major matrix (optional). The parameter allows to determine
|
||||||
* at compile time whether aligned access is possible on the block expression.
|
* at compile time whether aligned access is possible on the block expression.
|
||||||
*
|
*
|
||||||
* This class represents an expression of either a fixed-size or dynamic-size block. It is the return
|
* This class represents an expression of either a fixed-size or dynamic-size block. It is the return
|
||||||
* type of DenseBase::block(Index,Index,Index,Index) and DenseBase::block<int,int>(Index,Index) and
|
* type of DenseBase::block(Index,Index,Index,Index) and DenseBase::block<int,int>(Index,Index) and
|
||||||
* most of the time this is the only way it is used.
|
* most of the time this is the only way it is used.
|
||||||
*
|
*
|
||||||
* However, if you want to directly manipulate block expressions,
|
* However, if you want to directly maniputate block expressions,
|
||||||
* for instance if you want to write a function returning such an expression, you
|
* for instance if you want to write a function returning such an expression, you
|
||||||
* will need to use this class.
|
* will need to use this class.
|
||||||
*
|
*
|
||||||
* Here is an example illustrating the dynamic case:
|
* Here is an example illustrating the dynamic case:
|
||||||
* \include class_Block.cpp
|
* \include class_Block.cpp
|
||||||
* Output: \verbinclude class_Block.out
|
* Output: \verbinclude class_Block.out
|
||||||
*
|
*
|
||||||
* \note Even though this expression has dynamic size, in the case where \a XprType
|
* \note Even though this expression has dynamic size, in the case where \a XprType
|
||||||
* has fixed size, this expression inherits a fixed maximal size which means that evaluating
|
* has fixed size, this expression inherits a fixed maximal size which means that evaluating
|
||||||
* it does not cause a dynamic memory allocation.
|
* it does not cause a dynamic memory allocation.
|
||||||
*
|
*
|
||||||
* Here is an example illustrating the fixed-size case:
|
* Here is an example illustrating the fixed-size case:
|
||||||
* \include class_FixedBlock.cpp
|
* \include class_FixedBlock.cpp
|
||||||
* Output: \verbinclude class_FixedBlock.out
|
* Output: \verbinclude class_FixedBlock.out
|
||||||
*
|
*
|
||||||
* \sa DenseBase::block(Index,Index,Index,Index), DenseBase::block(Index,Index), class VectorBlock
|
* \sa DenseBase::block(Index,Index,Index,Index), DenseBase::block(Index,Index), class VectorBlock
|
||||||
*/
|
*/
|
||||||
template <typename XprType, int BlockRows, int BlockCols, bool InnerPanel>
|
template<typename XprType, int BlockRows, int BlockCols, bool InnerPanel> class Block
|
||||||
class Block
|
: public BlockImpl<XprType, BlockRows, BlockCols, InnerPanel, typename internal::traits<XprType>::StorageKind>
|
||||||
: public BlockImpl<XprType, BlockRows, BlockCols, InnerPanel, typename internal::traits<XprType>::StorageKind> {
|
{
|
||||||
typedef BlockImpl<XprType, BlockRows, BlockCols, InnerPanel, typename internal::traits<XprType>::StorageKind> Impl;
|
typedef BlockImpl<XprType, BlockRows, BlockCols, InnerPanel, typename internal::traits<XprType>::StorageKind> Impl;
|
||||||
using BlockHelper = internal::block_xpr_helper<Block>;
|
public:
|
||||||
|
//typedef typename Impl::Base Base;
|
||||||
|
typedef Impl Base;
|
||||||
|
EIGEN_GENERIC_PUBLIC_INTERFACE(Block)
|
||||||
|
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Block)
|
||||||
|
|
||||||
public:
|
typedef typename internal::remove_all<XprType>::type NestedExpression;
|
||||||
// typedef typename Impl::Base Base;
|
|
||||||
typedef Impl Base;
|
|
||||||
EIGEN_GENERIC_PUBLIC_INTERFACE(Block)
|
|
||||||
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Block)
|
|
||||||
|
|
||||||
typedef internal::remove_all_t<XprType> NestedExpression;
|
/** Column or Row constructor
|
||||||
|
*/
|
||||||
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||||
|
Block(XprType& xpr, Index i) : Impl(xpr,i)
|
||||||
|
{
|
||||||
|
eigen_assert( (i>=0) && (
|
||||||
|
((BlockRows==1) && (BlockCols==XprType::ColsAtCompileTime) && i<xpr.rows())
|
||||||
|
||((BlockRows==XprType::RowsAtCompileTime) && (BlockCols==1) && i<xpr.cols())));
|
||||||
|
}
|
||||||
|
|
||||||
/** Column or Row constructor
|
/** Fixed-size constructor
|
||||||
*/
|
*/
|
||||||
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Block(XprType& xpr, Index i) : Impl(xpr, i) {
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||||
eigen_assert((i >= 0) && (((BlockRows == 1) && (BlockCols == XprType::ColsAtCompileTime) && i < xpr.rows()) ||
|
Block(XprType& xpr, Index startRow, Index startCol)
|
||||||
((BlockRows == XprType::RowsAtCompileTime) && (BlockCols == 1) && i < xpr.cols())));
|
: Impl(xpr, startRow, startCol)
|
||||||
}
|
{
|
||||||
|
EIGEN_STATIC_ASSERT(RowsAtCompileTime!=Dynamic && ColsAtCompileTime!=Dynamic,THIS_METHOD_IS_ONLY_FOR_FIXED_SIZE)
|
||||||
|
eigen_assert(startRow >= 0 && BlockRows >= 0 && startRow + BlockRows <= xpr.rows()
|
||||||
|
&& startCol >= 0 && BlockCols >= 0 && startCol + BlockCols <= xpr.cols());
|
||||||
|
}
|
||||||
|
|
||||||
/** Fixed-size constructor
|
/** Dynamic-size constructor
|
||||||
*/
|
*/
|
||||||
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Block(XprType& xpr, Index startRow, Index startCol)
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||||
: Impl(xpr, startRow, startCol) {
|
Block(XprType& xpr,
|
||||||
EIGEN_STATIC_ASSERT(RowsAtCompileTime != Dynamic && ColsAtCompileTime != Dynamic,
|
Index startRow, Index startCol,
|
||||||
THIS_METHOD_IS_ONLY_FOR_FIXED_SIZE)
|
Index blockRows, Index blockCols)
|
||||||
eigen_assert(startRow >= 0 && BlockRows >= 0 && startRow + BlockRows <= xpr.rows() && startCol >= 0 &&
|
: Impl(xpr, startRow, startCol, blockRows, blockCols)
|
||||||
BlockCols >= 0 && startCol + BlockCols <= xpr.cols());
|
{
|
||||||
}
|
eigen_assert((RowsAtCompileTime==Dynamic || RowsAtCompileTime==blockRows)
|
||||||
|
&& (ColsAtCompileTime==Dynamic || ColsAtCompileTime==blockCols));
|
||||||
/** Dynamic-size constructor
|
eigen_assert(startRow >= 0 && blockRows >= 0 && startRow <= xpr.rows() - blockRows
|
||||||
*/
|
&& startCol >= 0 && blockCols >= 0 && startCol <= xpr.cols() - blockCols);
|
||||||
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Block(XprType& xpr, Index startRow, Index startCol, Index blockRows,
|
}
|
||||||
Index blockCols)
|
|
||||||
: Impl(xpr, startRow, startCol, blockRows, blockCols) {
|
|
||||||
eigen_assert((RowsAtCompileTime == Dynamic || RowsAtCompileTime == blockRows) &&
|
|
||||||
(ColsAtCompileTime == Dynamic || ColsAtCompileTime == blockCols));
|
|
||||||
eigen_assert(startRow >= 0 && blockRows >= 0 && startRow <= xpr.rows() - blockRows && startCol >= 0 &&
|
|
||||||
blockCols >= 0 && startCol <= xpr.cols() - blockCols);
|
|
||||||
}
|
|
||||||
|
|
||||||
// convert nested blocks (e.g. Block<Block<MatrixType>>) to a simple block expression (Block<MatrixType>)
|
|
||||||
|
|
||||||
using ConstUnwindReturnType = Block<const typename BlockHelper::BaseType, BlockRows, BlockCols, InnerPanel>;
|
|
||||||
using UnwindReturnType = Block<typename BlockHelper::BaseType, BlockRows, BlockCols, InnerPanel>;
|
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ConstUnwindReturnType unwind() const {
|
|
||||||
return ConstUnwindReturnType(BlockHelper::base(*this), BlockHelper::row(*this, 0), BlockHelper::col(*this, 0),
|
|
||||||
this->rows(), this->cols());
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T = Block, typename EnableIf = std::enable_if_t<!std::is_const<T>::value>>
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE UnwindReturnType unwind() {
|
|
||||||
return UnwindReturnType(BlockHelper::base(*this), BlockHelper::row(*this, 0), BlockHelper::col(*this, 0),
|
|
||||||
this->rows(), this->cols());
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// The generic default implementation for dense block simply forward to the internal::BlockImpl_dense
|
// The generic default implementation for dense block simplu forward to the internal::BlockImpl_dense
|
||||||
// that must be specialized for direct and non-direct access...
|
// that must be specialized for direct and non-direct access...
|
||||||
template <typename XprType, int BlockRows, int BlockCols, bool InnerPanel>
|
template<typename XprType, int BlockRows, int BlockCols, bool InnerPanel>
|
||||||
class BlockImpl<XprType, BlockRows, BlockCols, InnerPanel, Dense>
|
class BlockImpl<XprType, BlockRows, BlockCols, InnerPanel, Dense>
|
||||||
: public internal::BlockImpl_dense<XprType, BlockRows, BlockCols, InnerPanel> {
|
: public internal::BlockImpl_dense<XprType, BlockRows, BlockCols, InnerPanel>
|
||||||
typedef internal::BlockImpl_dense<XprType, BlockRows, BlockCols, InnerPanel> Impl;
|
{
|
||||||
typedef typename XprType::StorageIndex StorageIndex;
|
typedef internal::BlockImpl_dense<XprType, BlockRows, BlockCols, InnerPanel> Impl;
|
||||||
|
typedef typename XprType::StorageIndex StorageIndex;
|
||||||
public:
|
public:
|
||||||
typedef Impl Base;
|
typedef Impl Base;
|
||||||
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(BlockImpl)
|
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(BlockImpl)
|
||||||
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE BlockImpl(XprType& xpr, Index i) : Impl(xpr, i) {}
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE BlockImpl(XprType& xpr, Index i) : Impl(xpr,i) {}
|
||||||
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE BlockImpl(XprType& xpr, Index startRow, Index startCol)
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE BlockImpl(XprType& xpr, Index startRow, Index startCol) : Impl(xpr, startRow, startCol) {}
|
||||||
: Impl(xpr, startRow, startCol) {}
|
EIGEN_DEVICE_FUNC
|
||||||
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE BlockImpl(XprType& xpr, Index startRow, Index startCol,
|
EIGEN_STRONG_INLINE BlockImpl(XprType& xpr, Index startRow, Index startCol, Index blockRows, Index blockCols)
|
||||||
Index blockRows, Index blockCols)
|
|
||||||
: Impl(xpr, startRow, startCol, blockRows, blockCols) {}
|
: Impl(xpr, startRow, startCol, blockRows, blockCols) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
/** \internal Internal implementation of dense Blocks in the general case. */
|
/** \internal Internal implementation of dense Blocks in the general case. */
|
||||||
template <typename XprType, int BlockRows, int BlockCols, bool InnerPanel, bool HasDirectAccess>
|
template<typename XprType, int BlockRows, int BlockCols, bool InnerPanel, bool HasDirectAccess> class BlockImpl_dense
|
||||||
class BlockImpl_dense : public internal::dense_xpr_base<Block<XprType, BlockRows, BlockCols, InnerPanel>>::type {
|
: public internal::dense_xpr_base<Block<XprType, BlockRows, BlockCols, InnerPanel> >::type
|
||||||
typedef Block<XprType, BlockRows, BlockCols, InnerPanel> BlockType;
|
{
|
||||||
typedef typename internal::ref_selector<XprType>::non_const_type XprTypeNested;
|
typedef Block<XprType, BlockRows, BlockCols, InnerPanel> BlockType;
|
||||||
|
typedef typename internal::ref_selector<XprType>::non_const_type XprTypeNested;
|
||||||
|
public:
|
||||||
|
|
||||||
public:
|
typedef typename internal::dense_xpr_base<BlockType>::type Base;
|
||||||
typedef typename internal::dense_xpr_base<BlockType>::type Base;
|
EIGEN_DENSE_PUBLIC_INTERFACE(BlockType)
|
||||||
EIGEN_DENSE_PUBLIC_INTERFACE(BlockType)
|
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(BlockImpl_dense)
|
||||||
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(BlockImpl_dense)
|
|
||||||
|
|
||||||
/** Column or Row constructor
|
// class InnerIterator; // FIXME apparently never used
|
||||||
*/
|
|
||||||
EIGEN_DEVICE_FUNC constexpr BlockImpl_dense(XprType& xpr, Index i)
|
/** Column or Row constructor
|
||||||
|
*/
|
||||||
|
EIGEN_DEVICE_FUNC
|
||||||
|
inline BlockImpl_dense(XprType& xpr, Index i)
|
||||||
: m_xpr(xpr),
|
: m_xpr(xpr),
|
||||||
// It is a row if and only if BlockRows==1 and BlockCols==XprType::ColsAtCompileTime,
|
// It is a row if and only if BlockRows==1 and BlockCols==XprType::ColsAtCompileTime,
|
||||||
// and it is a column if and only if BlockRows==XprType::RowsAtCompileTime and BlockCols==1,
|
// and it is a column if and only if BlockRows==XprType::RowsAtCompileTime and BlockCols==1,
|
||||||
// all other cases are invalid.
|
// all other cases are invalid.
|
||||||
// The case a 1x1 matrix seems ambiguous, but the result is the same anyway.
|
// The case a 1x1 matrix seems ambiguous, but the result is the same anyway.
|
||||||
m_startRow((BlockRows == 1) && (BlockCols == XprType::ColsAtCompileTime) ? i : 0),
|
m_startRow( (BlockRows==1) && (BlockCols==XprType::ColsAtCompileTime) ? i : 0),
|
||||||
m_startCol((BlockRows == XprType::RowsAtCompileTime) && (BlockCols == 1) ? i : 0),
|
m_startCol( (BlockRows==XprType::RowsAtCompileTime) && (BlockCols==1) ? i : 0),
|
||||||
m_blockRows(BlockRows == 1 ? 1 : xpr.rows()),
|
m_blockRows(BlockRows==1 ? 1 : xpr.rows()),
|
||||||
m_blockCols(BlockCols == 1 ? 1 : xpr.cols()) {}
|
m_blockCols(BlockCols==1 ? 1 : xpr.cols())
|
||||||
|
{}
|
||||||
|
|
||||||
/** Fixed-size constructor
|
/** Fixed-size constructor
|
||||||
*/
|
*/
|
||||||
EIGEN_DEVICE_FUNC constexpr BlockImpl_dense(XprType& xpr, Index startRow, Index startCol)
|
EIGEN_DEVICE_FUNC
|
||||||
: m_xpr(xpr), m_startRow(startRow), m_startCol(startCol), m_blockRows(BlockRows), m_blockCols(BlockCols) {}
|
inline BlockImpl_dense(XprType& xpr, Index startRow, Index startCol)
|
||||||
|
: m_xpr(xpr), m_startRow(startRow), m_startCol(startCol),
|
||||||
|
m_blockRows(BlockRows), m_blockCols(BlockCols)
|
||||||
|
{}
|
||||||
|
|
||||||
/** Dynamic-size constructor
|
/** Dynamic-size constructor
|
||||||
*/
|
*/
|
||||||
EIGEN_DEVICE_FUNC constexpr BlockImpl_dense(XprType& xpr, Index startRow, Index startCol, Index blockRows,
|
EIGEN_DEVICE_FUNC
|
||||||
Index blockCols)
|
inline BlockImpl_dense(XprType& xpr,
|
||||||
: m_xpr(xpr), m_startRow(startRow), m_startCol(startCol), m_blockRows(blockRows), m_blockCols(blockCols) {}
|
Index startRow, Index startCol,
|
||||||
|
Index blockRows, Index blockCols)
|
||||||
|
: m_xpr(xpr), m_startRow(startRow), m_startCol(startCol),
|
||||||
|
m_blockRows(blockRows), m_blockCols(blockCols)
|
||||||
|
{}
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC constexpr Index rows() const { return m_blockRows.value(); }
|
EIGEN_DEVICE_FUNC inline Index rows() const { return m_blockRows.value(); }
|
||||||
EIGEN_DEVICE_FUNC constexpr Index cols() const { return m_blockCols.value(); }
|
EIGEN_DEVICE_FUNC inline Index cols() const { return m_blockCols.value(); }
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC inline Scalar& coeffRef(Index rowId, Index colId) {
|
EIGEN_DEVICE_FUNC
|
||||||
EIGEN_STATIC_ASSERT_LVALUE(XprType)
|
inline Scalar& coeffRef(Index rowId, Index colId)
|
||||||
return m_xpr.coeffRef(rowId + m_startRow.value(), colId + m_startCol.value());
|
{
|
||||||
}
|
EIGEN_STATIC_ASSERT_LVALUE(XprType)
|
||||||
|
return m_xpr.coeffRef(rowId + m_startRow.value(), colId + m_startCol.value());
|
||||||
|
}
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC inline const Scalar& coeffRef(Index rowId, Index colId) const {
|
EIGEN_DEVICE_FUNC
|
||||||
return m_xpr.derived().coeffRef(rowId + m_startRow.value(), colId + m_startCol.value());
|
inline const Scalar& coeffRef(Index rowId, Index colId) const
|
||||||
}
|
{
|
||||||
|
return m_xpr.derived().coeffRef(rowId + m_startRow.value(), colId + m_startCol.value());
|
||||||
|
}
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CoeffReturnType coeff(Index rowId, Index colId) const {
|
EIGEN_DEVICE_FUNC
|
||||||
return m_xpr.coeff(rowId + m_startRow.value(), colId + m_startCol.value());
|
EIGEN_STRONG_INLINE const CoeffReturnType coeff(Index rowId, Index colId) const
|
||||||
}
|
{
|
||||||
|
return m_xpr.coeff(rowId + m_startRow.value(), colId + m_startCol.value());
|
||||||
|
}
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC inline Scalar& coeffRef(Index index) {
|
EIGEN_DEVICE_FUNC
|
||||||
EIGEN_STATIC_ASSERT_LVALUE(XprType)
|
inline Scalar& coeffRef(Index index)
|
||||||
return m_xpr.coeffRef(m_startRow.value() + (RowsAtCompileTime == 1 ? 0 : index),
|
{
|
||||||
m_startCol.value() + (RowsAtCompileTime == 1 ? index : 0));
|
EIGEN_STATIC_ASSERT_LVALUE(XprType)
|
||||||
}
|
return m_xpr.coeffRef(m_startRow.value() + (RowsAtCompileTime == 1 ? 0 : index),
|
||||||
|
m_startCol.value() + (RowsAtCompileTime == 1 ? index : 0));
|
||||||
|
}
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC inline const Scalar& coeffRef(Index index) const {
|
EIGEN_DEVICE_FUNC
|
||||||
return m_xpr.coeffRef(m_startRow.value() + (RowsAtCompileTime == 1 ? 0 : index),
|
inline const Scalar& coeffRef(Index index) const
|
||||||
m_startCol.value() + (RowsAtCompileTime == 1 ? index : 0));
|
{
|
||||||
}
|
return m_xpr.coeffRef(m_startRow.value() + (RowsAtCompileTime == 1 ? 0 : index),
|
||||||
|
m_startCol.value() + (RowsAtCompileTime == 1 ? index : 0));
|
||||||
|
}
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC inline const CoeffReturnType coeff(Index index) const {
|
EIGEN_DEVICE_FUNC
|
||||||
return m_xpr.coeff(m_startRow.value() + (RowsAtCompileTime == 1 ? 0 : index),
|
inline const CoeffReturnType coeff(Index index) const
|
||||||
m_startCol.value() + (RowsAtCompileTime == 1 ? index : 0));
|
{
|
||||||
}
|
return m_xpr.coeff(m_startRow.value() + (RowsAtCompileTime == 1 ? 0 : index),
|
||||||
|
m_startCol.value() + (RowsAtCompileTime == 1 ? index : 0));
|
||||||
|
}
|
||||||
|
|
||||||
template <int LoadMode>
|
template<int LoadMode>
|
||||||
EIGEN_DEVICE_FUNC inline PacketScalar packet(Index rowId, Index colId) const {
|
EIGEN_DEVICE_FUNC inline PacketScalar packet(Index rowId, Index colId) const
|
||||||
return m_xpr.template packet<Unaligned>(rowId + m_startRow.value(), colId + m_startCol.value());
|
{
|
||||||
}
|
return m_xpr.template packet<Unaligned>(rowId + m_startRow.value(), colId + m_startCol.value());
|
||||||
|
}
|
||||||
|
|
||||||
template <int LoadMode>
|
template<int LoadMode>
|
||||||
EIGEN_DEVICE_FUNC inline void writePacket(Index rowId, Index colId, const PacketScalar& val) {
|
EIGEN_DEVICE_FUNC inline void writePacket(Index rowId, Index colId, const PacketScalar& val)
|
||||||
m_xpr.template writePacket<Unaligned>(rowId + m_startRow.value(), colId + m_startCol.value(), val);
|
{
|
||||||
}
|
m_xpr.template writePacket<Unaligned>(rowId + m_startRow.value(), colId + m_startCol.value(), val);
|
||||||
|
}
|
||||||
|
|
||||||
template <int LoadMode>
|
template<int LoadMode>
|
||||||
EIGEN_DEVICE_FUNC inline PacketScalar packet(Index index) const {
|
EIGEN_DEVICE_FUNC inline PacketScalar packet(Index index) const
|
||||||
return m_xpr.template packet<Unaligned>(m_startRow.value() + (RowsAtCompileTime == 1 ? 0 : index),
|
{
|
||||||
m_startCol.value() + (RowsAtCompileTime == 1 ? index : 0));
|
return m_xpr.template packet<Unaligned>
|
||||||
}
|
(m_startRow.value() + (RowsAtCompileTime == 1 ? 0 : index),
|
||||||
|
m_startCol.value() + (RowsAtCompileTime == 1 ? index : 0));
|
||||||
|
}
|
||||||
|
|
||||||
template <int LoadMode>
|
template<int LoadMode>
|
||||||
EIGEN_DEVICE_FUNC inline void writePacket(Index index, const PacketScalar& val) {
|
EIGEN_DEVICE_FUNC inline void writePacket(Index index, const PacketScalar& val)
|
||||||
m_xpr.template writePacket<Unaligned>(m_startRow.value() + (RowsAtCompileTime == 1 ? 0 : index),
|
{
|
||||||
m_startCol.value() + (RowsAtCompileTime == 1 ? index : 0), val);
|
m_xpr.template writePacket<Unaligned>
|
||||||
}
|
(m_startRow.value() + (RowsAtCompileTime == 1 ? 0 : index),
|
||||||
|
m_startCol.value() + (RowsAtCompileTime == 1 ? index : 0), val);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef EIGEN_PARSED_BY_DOXYGEN
|
#ifdef EIGEN_PARSED_BY_DOXYGEN
|
||||||
/** \sa MapBase::data() */
|
/** \sa MapBase::data() */
|
||||||
EIGEN_DEVICE_FUNC constexpr const Scalar* data() const;
|
EIGEN_DEVICE_FUNC inline const Scalar* data() const;
|
||||||
EIGEN_DEVICE_FUNC inline Index innerStride() const;
|
EIGEN_DEVICE_FUNC inline Index innerStride() const;
|
||||||
EIGEN_DEVICE_FUNC inline Index outerStride() const;
|
EIGEN_DEVICE_FUNC inline Index outerStride() const;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const internal::remove_all_t<XprTypeNested>& nestedExpression() const {
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||||
return m_xpr;
|
const typename internal::remove_all<XprTypeNested>::type& nestedExpression() const
|
||||||
}
|
{
|
||||||
|
return m_xpr;
|
||||||
|
}
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE XprType& nestedExpression() { return m_xpr; }
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||||
|
XprType& nestedExpression() { return m_xpr; }
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC constexpr StorageIndex startRow() const noexcept { return m_startRow.value(); }
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR
|
||||||
|
StorageIndex startRow() const EIGEN_NOEXCEPT
|
||||||
|
{
|
||||||
|
return m_startRow.value();
|
||||||
|
}
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC constexpr StorageIndex startCol() const noexcept { return m_startCol.value(); }
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR
|
||||||
|
StorageIndex startCol() const EIGEN_NOEXCEPT
|
||||||
|
{
|
||||||
|
return m_startCol.value();
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
XprTypeNested m_xpr;
|
|
||||||
const internal::variable_if_dynamic<StorageIndex, (XprType::RowsAtCompileTime == 1 && BlockRows == 1) ? 0 : Dynamic>
|
XprTypeNested m_xpr;
|
||||||
m_startRow;
|
const internal::variable_if_dynamic<StorageIndex, (XprType::RowsAtCompileTime == 1 && BlockRows==1) ? 0 : Dynamic> m_startRow;
|
||||||
const internal::variable_if_dynamic<StorageIndex, (XprType::ColsAtCompileTime == 1 && BlockCols == 1) ? 0 : Dynamic>
|
const internal::variable_if_dynamic<StorageIndex, (XprType::ColsAtCompileTime == 1 && BlockCols==1) ? 0 : Dynamic> m_startCol;
|
||||||
m_startCol;
|
const internal::variable_if_dynamic<StorageIndex, RowsAtCompileTime> m_blockRows;
|
||||||
const internal::variable_if_dynamic<StorageIndex, RowsAtCompileTime> m_blockRows;
|
const internal::variable_if_dynamic<StorageIndex, ColsAtCompileTime> m_blockCols;
|
||||||
const internal::variable_if_dynamic<StorageIndex, ColsAtCompileTime> m_blockCols;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/** \internal Internal implementation of dense Blocks in the direct access case.*/
|
/** \internal Internal implementation of dense Blocks in the direct access case.*/
|
||||||
template <typename XprType, int BlockRows, int BlockCols, bool InnerPanel>
|
template<typename XprType, int BlockRows, int BlockCols, bool InnerPanel>
|
||||||
class BlockImpl_dense<XprType, BlockRows, BlockCols, InnerPanel, true>
|
class BlockImpl_dense<XprType,BlockRows,BlockCols, InnerPanel,true>
|
||||||
: public MapBase<Block<XprType, BlockRows, BlockCols, InnerPanel>> {
|
: public MapBase<Block<XprType, BlockRows, BlockCols, InnerPanel> >
|
||||||
typedef Block<XprType, BlockRows, BlockCols, InnerPanel> BlockType;
|
{
|
||||||
typedef typename internal::ref_selector<XprType>::non_const_type XprTypeNested;
|
typedef Block<XprType, BlockRows, BlockCols, InnerPanel> BlockType;
|
||||||
enum { XprTypeIsRowMajor = (int(traits<XprType>::Flags) & RowMajorBit) != 0 };
|
typedef typename internal::ref_selector<XprType>::non_const_type XprTypeNested;
|
||||||
|
enum {
|
||||||
|
XprTypeIsRowMajor = (int(traits<XprType>::Flags)&RowMajorBit) != 0
|
||||||
|
};
|
||||||
|
|
||||||
/** \internal Returns base+offset (unless base is null, in which case returns null).
|
/** \internal Returns base+offset (unless base is null, in which case returns null).
|
||||||
* Adding an offset to nullptr is undefined behavior, so we must avoid it.
|
* Adding an offset to nullptr is undefined behavior, so we must avoid it.
|
||||||
*/
|
*/
|
||||||
template <typename Scalar>
|
template <typename Scalar>
|
||||||
EIGEN_DEVICE_FUNC constexpr EIGEN_ALWAYS_INLINE static Scalar* add_to_nullable_pointer(Scalar* base, Index offset) {
|
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR EIGEN_ALWAYS_INLINE
|
||||||
return base != nullptr ? base + offset : nullptr;
|
static Scalar* add_to_nullable_pointer(Scalar* base, Index offset)
|
||||||
}
|
{
|
||||||
|
return base != NULL ? base+offset : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef MapBase<BlockType> Base;
|
|
||||||
EIGEN_DENSE_PUBLIC_INTERFACE(BlockType)
|
|
||||||
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(BlockImpl_dense)
|
|
||||||
|
|
||||||
/** Column or Row constructor
|
typedef MapBase<BlockType> Base;
|
||||||
*/
|
EIGEN_DENSE_PUBLIC_INTERFACE(BlockType)
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE BlockImpl_dense(XprType& xpr, Index i)
|
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(BlockImpl_dense)
|
||||||
: Base((BlockRows == 0 || BlockCols == 0)
|
|
||||||
? nullptr
|
/** Column or Row constructor
|
||||||
: add_to_nullable_pointer(
|
*/
|
||||||
xpr.data(),
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||||
i * (((BlockRows == 1) && (BlockCols == XprType::ColsAtCompileTime) && (!XprTypeIsRowMajor)) ||
|
BlockImpl_dense(XprType& xpr, Index i)
|
||||||
((BlockRows == XprType::RowsAtCompileTime) && (BlockCols == 1) &&
|
: Base((BlockRows == 0 || BlockCols == 0) ? NULL : add_to_nullable_pointer(xpr.data(),
|
||||||
(XprTypeIsRowMajor))
|
i * ( ((BlockRows==1) && (BlockCols==XprType::ColsAtCompileTime) && (!XprTypeIsRowMajor))
|
||||||
? xpr.innerStride()
|
|| ((BlockRows==XprType::RowsAtCompileTime) && (BlockCols==1) && ( XprTypeIsRowMajor)) ? xpr.innerStride() : xpr.outerStride())),
|
||||||
: xpr.outerStride())),
|
BlockRows==1 ? 1 : xpr.rows(),
|
||||||
BlockRows == 1 ? 1 : xpr.rows(), BlockCols == 1 ? 1 : xpr.cols()),
|
BlockCols==1 ? 1 : xpr.cols()),
|
||||||
m_xpr(xpr),
|
m_xpr(xpr),
|
||||||
m_startRow((BlockRows == 1) && (BlockCols == XprType::ColsAtCompileTime) ? i : 0),
|
m_startRow( (BlockRows==1) && (BlockCols==XprType::ColsAtCompileTime) ? i : 0),
|
||||||
m_startCol((BlockRows == XprType::RowsAtCompileTime) && (BlockCols == 1) ? i : 0) {
|
m_startCol( (BlockRows==XprType::RowsAtCompileTime) && (BlockCols==1) ? i : 0)
|
||||||
init();
|
{
|
||||||
}
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
/** Fixed-size constructor
|
/** Fixed-size constructor
|
||||||
*/
|
*/
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE BlockImpl_dense(XprType& xpr, Index startRow, Index startCol)
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||||
: Base((BlockRows == 0 || BlockCols == 0)
|
BlockImpl_dense(XprType& xpr, Index startRow, Index startCol)
|
||||||
? nullptr
|
: Base((BlockRows == 0 || BlockCols == 0) ? NULL : add_to_nullable_pointer(xpr.data(),
|
||||||
: add_to_nullable_pointer(xpr.data(),
|
xpr.innerStride()*(XprTypeIsRowMajor?startCol:startRow) + xpr.outerStride()*(XprTypeIsRowMajor?startRow:startCol))),
|
||||||
xpr.innerStride() * (XprTypeIsRowMajor ? startCol : startRow) +
|
m_xpr(xpr), m_startRow(startRow), m_startCol(startCol)
|
||||||
xpr.outerStride() * (XprTypeIsRowMajor ? startRow : startCol))),
|
{
|
||||||
m_xpr(xpr),
|
init();
|
||||||
m_startRow(startRow),
|
}
|
||||||
m_startCol(startCol) {
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Dynamic-size constructor
|
/** Dynamic-size constructor
|
||||||
*/
|
*/
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE BlockImpl_dense(XprType& xpr, Index startRow, Index startCol, Index blockRows,
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||||
Index blockCols)
|
BlockImpl_dense(XprType& xpr,
|
||||||
: Base((blockRows == 0 || blockCols == 0)
|
Index startRow, Index startCol,
|
||||||
? nullptr
|
Index blockRows, Index blockCols)
|
||||||
: add_to_nullable_pointer(xpr.data(),
|
: Base((blockRows == 0 || blockCols == 0) ? NULL : add_to_nullable_pointer(xpr.data(),
|
||||||
xpr.innerStride() * (XprTypeIsRowMajor ? startCol : startRow) +
|
xpr.innerStride()*(XprTypeIsRowMajor?startCol:startRow) + xpr.outerStride()*(XprTypeIsRowMajor?startRow:startCol)),
|
||||||
xpr.outerStride() * (XprTypeIsRowMajor ? startRow : startCol)),
|
|
||||||
blockRows, blockCols),
|
blockRows, blockCols),
|
||||||
m_xpr(xpr),
|
m_xpr(xpr), m_startRow(startRow), m_startCol(startCol)
|
||||||
m_startRow(startRow),
|
{
|
||||||
m_startCol(startCol) {
|
init();
|
||||||
init();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const internal::remove_all_t<XprTypeNested>& nestedExpression() const noexcept {
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||||
return m_xpr;
|
const typename internal::remove_all<XprTypeNested>::type& nestedExpression() const EIGEN_NOEXCEPT
|
||||||
}
|
{
|
||||||
|
return m_xpr;
|
||||||
|
}
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE XprType& nestedExpression() { return m_xpr; }
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||||
|
XprType& nestedExpression() { return m_xpr; }
|
||||||
|
|
||||||
/** \sa MapBase::innerStride() */
|
/** \sa MapBase::innerStride() */
|
||||||
EIGEN_DEVICE_FUNC constexpr Index innerStride() const noexcept {
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR
|
||||||
return internal::traits<BlockType>::HasSameStorageOrderAsXprType ? m_xpr.innerStride() : m_xpr.outerStride();
|
Index innerStride() const EIGEN_NOEXCEPT
|
||||||
}
|
{
|
||||||
|
return internal::traits<BlockType>::HasSameStorageOrderAsXprType
|
||||||
|
? m_xpr.innerStride()
|
||||||
|
: m_xpr.outerStride();
|
||||||
|
}
|
||||||
|
|
||||||
/** \sa MapBase::outerStride() */
|
/** \sa MapBase::outerStride() */
|
||||||
EIGEN_DEVICE_FUNC constexpr Index outerStride() const noexcept {
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR
|
||||||
return internal::traits<BlockType>::HasSameStorageOrderAsXprType ? m_xpr.outerStride() : m_xpr.innerStride();
|
Index outerStride() const EIGEN_NOEXCEPT
|
||||||
}
|
{
|
||||||
|
return internal::traits<BlockType>::HasSameStorageOrderAsXprType
|
||||||
|
? m_xpr.outerStride()
|
||||||
|
: m_xpr.innerStride();
|
||||||
|
}
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC constexpr StorageIndex startRow() const noexcept { return m_startRow.value(); }
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR
|
||||||
|
StorageIndex startRow() const EIGEN_NOEXCEPT { return m_startRow.value(); }
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC constexpr StorageIndex startCol() const noexcept { return m_startCol.value(); }
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR
|
||||||
|
StorageIndex startCol() const EIGEN_NOEXCEPT { return m_startCol.value(); }
|
||||||
|
|
||||||
#ifndef __SUNPRO_CC
|
#ifndef __SUNPRO_CC
|
||||||
// FIXME sunstudio is not friendly with the above friend...
|
// FIXME sunstudio is not friendly with the above friend...
|
||||||
// META-FIXME there is no 'friend' keyword around here. Is this obsolete?
|
// META-FIXME there is no 'friend' keyword around here. Is this obsolete?
|
||||||
protected:
|
protected:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
||||||
/** \internal used by allowAligned() */
|
/** \internal used by allowAligned() */
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE BlockImpl_dense(XprType& xpr, const Scalar* data, Index blockRows,
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||||
Index blockCols)
|
BlockImpl_dense(XprType& xpr, const Scalar* data, Index blockRows, Index blockCols)
|
||||||
: Base(data, blockRows, blockCols), m_xpr(xpr) {
|
: Base(data, blockRows, blockCols), m_xpr(xpr)
|
||||||
init();
|
{
|
||||||
}
|
init();
|
||||||
#endif
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void init() {
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||||
m_outerStride =
|
void init()
|
||||||
internal::traits<BlockType>::HasSameStorageOrderAsXprType ? m_xpr.outerStride() : m_xpr.innerStride();
|
{
|
||||||
}
|
m_outerStride = internal::traits<BlockType>::HasSameStorageOrderAsXprType
|
||||||
|
? m_xpr.outerStride()
|
||||||
|
: m_xpr.innerStride();
|
||||||
|
}
|
||||||
|
|
||||||
XprTypeNested m_xpr;
|
XprTypeNested m_xpr;
|
||||||
const internal::variable_if_dynamic<StorageIndex, (XprType::RowsAtCompileTime == 1 && BlockRows == 1) ? 0 : Dynamic>
|
const internal::variable_if_dynamic<StorageIndex, (XprType::RowsAtCompileTime == 1 && BlockRows==1) ? 0 : Dynamic> m_startRow;
|
||||||
m_startRow;
|
const internal::variable_if_dynamic<StorageIndex, (XprType::ColsAtCompileTime == 1 && BlockCols==1) ? 0 : Dynamic> m_startCol;
|
||||||
const internal::variable_if_dynamic<StorageIndex, (XprType::ColsAtCompileTime == 1 && BlockCols == 1) ? 0 : Dynamic>
|
Index m_outerStride;
|
||||||
m_startCol;
|
|
||||||
Index m_outerStride;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace internal
|
} // end namespace internal
|
||||||
|
|
||||||
} // end namespace Eigen
|
} // end namespace Eigen
|
||||||
|
|
||||||
#endif // EIGEN_BLOCK_H
|
#endif // EIGEN_BLOCK_H
|
||||||
|
|||||||
164
Eigen/src/Core/BooleanRedux.h
Normal file
164
Eigen/src/Core/BooleanRedux.h
Normal file
@@ -0,0 +1,164 @@
|
|||||||
|
// This file is part of Eigen, a lightweight C++ template library
|
||||||
|
// for linear algebra.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
|
||||||
|
//
|
||||||
|
// This Source Code Form is subject to the terms of the Mozilla
|
||||||
|
// Public License v. 2.0. If a copy of the MPL was not distributed
|
||||||
|
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
#ifndef EIGEN_ALLANDANY_H
|
||||||
|
#define EIGEN_ALLANDANY_H
|
||||||
|
|
||||||
|
namespace Eigen {
|
||||||
|
|
||||||
|
namespace internal {
|
||||||
|
|
||||||
|
template<typename Derived, int UnrollCount, int InnerSize>
|
||||||
|
struct all_unroller
|
||||||
|
{
|
||||||
|
enum {
|
||||||
|
IsRowMajor = (int(Derived::Flags) & int(RowMajor)),
|
||||||
|
i = (UnrollCount-1) / InnerSize,
|
||||||
|
j = (UnrollCount-1) % InnerSize
|
||||||
|
};
|
||||||
|
|
||||||
|
EIGEN_DEVICE_FUNC static inline bool run(const Derived &mat)
|
||||||
|
{
|
||||||
|
return all_unroller<Derived, UnrollCount-1, InnerSize>::run(mat) && mat.coeff(IsRowMajor ? i : j, IsRowMajor ? j : i);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename Derived, int InnerSize>
|
||||||
|
struct all_unroller<Derived, 0, InnerSize>
|
||||||
|
{
|
||||||
|
EIGEN_DEVICE_FUNC static inline bool run(const Derived &/*mat*/) { return true; }
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename Derived, int InnerSize>
|
||||||
|
struct all_unroller<Derived, Dynamic, InnerSize>
|
||||||
|
{
|
||||||
|
EIGEN_DEVICE_FUNC static inline bool run(const Derived &) { return false; }
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename Derived, int UnrollCount, int InnerSize>
|
||||||
|
struct any_unroller
|
||||||
|
{
|
||||||
|
enum {
|
||||||
|
IsRowMajor = (int(Derived::Flags) & int(RowMajor)),
|
||||||
|
i = (UnrollCount-1) / InnerSize,
|
||||||
|
j = (UnrollCount-1) % InnerSize
|
||||||
|
};
|
||||||
|
|
||||||
|
EIGEN_DEVICE_FUNC static inline bool run(const Derived &mat)
|
||||||
|
{
|
||||||
|
return any_unroller<Derived, UnrollCount-1, InnerSize>::run(mat) || mat.coeff(IsRowMajor ? i : j, IsRowMajor ? j : i);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename Derived, int InnerSize>
|
||||||
|
struct any_unroller<Derived, 0, InnerSize>
|
||||||
|
{
|
||||||
|
EIGEN_DEVICE_FUNC static inline bool run(const Derived & /*mat*/) { return false; }
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename Derived, int InnerSize>
|
||||||
|
struct any_unroller<Derived, Dynamic, InnerSize>
|
||||||
|
{
|
||||||
|
EIGEN_DEVICE_FUNC static inline bool run(const Derived &) { return false; }
|
||||||
|
};
|
||||||
|
|
||||||
|
} // end namespace internal
|
||||||
|
|
||||||
|
/** \returns true if all coefficients are true
|
||||||
|
*
|
||||||
|
* Example: \include MatrixBase_all.cpp
|
||||||
|
* Output: \verbinclude MatrixBase_all.out
|
||||||
|
*
|
||||||
|
* \sa any(), Cwise::operator<()
|
||||||
|
*/
|
||||||
|
template<typename Derived>
|
||||||
|
EIGEN_DEVICE_FUNC inline bool DenseBase<Derived>::all() const
|
||||||
|
{
|
||||||
|
typedef internal::evaluator<Derived> Evaluator;
|
||||||
|
enum {
|
||||||
|
unroll = SizeAtCompileTime != Dynamic
|
||||||
|
&& SizeAtCompileTime * (int(Evaluator::CoeffReadCost) + int(NumTraits<Scalar>::AddCost)) <= EIGEN_UNROLLING_LIMIT
|
||||||
|
};
|
||||||
|
Evaluator evaluator(derived());
|
||||||
|
if(unroll)
|
||||||
|
return internal::all_unroller<Evaluator, unroll ? int(SizeAtCompileTime) : Dynamic, InnerSizeAtCompileTime>::run(evaluator);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for(Index i = 0; i < derived().outerSize(); ++i)
|
||||||
|
for(Index j = 0; j < derived().innerSize(); ++j)
|
||||||
|
if (!evaluator.coeff(IsRowMajor ? i : j, IsRowMajor ? j : i)) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** \returns true if at least one coefficient is true
|
||||||
|
*
|
||||||
|
* \sa all()
|
||||||
|
*/
|
||||||
|
template<typename Derived>
|
||||||
|
EIGEN_DEVICE_FUNC inline bool DenseBase<Derived>::any() const
|
||||||
|
{
|
||||||
|
typedef internal::evaluator<Derived> Evaluator;
|
||||||
|
enum {
|
||||||
|
unroll = SizeAtCompileTime != Dynamic
|
||||||
|
&& SizeAtCompileTime * (int(Evaluator::CoeffReadCost) + int(NumTraits<Scalar>::AddCost)) <= EIGEN_UNROLLING_LIMIT
|
||||||
|
};
|
||||||
|
Evaluator evaluator(derived());
|
||||||
|
if(unroll)
|
||||||
|
return internal::any_unroller<Evaluator, unroll ? int(SizeAtCompileTime) : Dynamic, InnerSizeAtCompileTime>::run(evaluator);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for(Index i = 0; i < derived().outerSize(); ++i)
|
||||||
|
for(Index j = 0; j < derived().innerSize(); ++j)
|
||||||
|
if (evaluator.coeff(IsRowMajor ? i : j, IsRowMajor ? j : i)) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** \returns the number of coefficients which evaluate to true
|
||||||
|
*
|
||||||
|
* \sa all(), any()
|
||||||
|
*/
|
||||||
|
template<typename Derived>
|
||||||
|
EIGEN_DEVICE_FUNC inline Eigen::Index DenseBase<Derived>::count() const
|
||||||
|
{
|
||||||
|
return derived().template cast<bool>().template cast<Index>().sum();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** \returns true is \c *this contains at least one Not A Number (NaN).
|
||||||
|
*
|
||||||
|
* \sa allFinite()
|
||||||
|
*/
|
||||||
|
template<typename Derived>
|
||||||
|
inline bool DenseBase<Derived>::hasNaN() const
|
||||||
|
{
|
||||||
|
#if EIGEN_COMP_MSVC || (defined __FAST_MATH__)
|
||||||
|
return derived().array().isNaN().any();
|
||||||
|
#else
|
||||||
|
return !((derived().array()==derived().array()).all());
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/** \returns true if \c *this contains only finite numbers, i.e., no NaN and no +/-INF values.
|
||||||
|
*
|
||||||
|
* \sa hasNaN()
|
||||||
|
*/
|
||||||
|
template<typename Derived>
|
||||||
|
inline bool DenseBase<Derived>::allFinite() const
|
||||||
|
{
|
||||||
|
#if EIGEN_COMP_MSVC || (defined __FAST_MATH__)
|
||||||
|
return derived().array().isFinite().all();
|
||||||
|
#else
|
||||||
|
return !((derived()-derived()).hasNaN());
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
} // end namespace Eigen
|
||||||
|
|
||||||
|
#endif // EIGEN_ALLANDANY_H
|
||||||
@@ -11,45 +11,49 @@
|
|||||||
#ifndef EIGEN_COMMAINITIALIZER_H
|
#ifndef EIGEN_COMMAINITIALIZER_H
|
||||||
#define EIGEN_COMMAINITIALIZER_H
|
#define EIGEN_COMMAINITIALIZER_H
|
||||||
|
|
||||||
// IWYU pragma: private
|
namespace Eigen {
|
||||||
#include "./InternalHeaderCheck.h"
|
|
||||||
|
|
||||||
namespace Eigen {
|
|
||||||
|
|
||||||
/** \class CommaInitializer
|
/** \class CommaInitializer
|
||||||
* \ingroup Core_Module
|
* \ingroup Core_Module
|
||||||
*
|
*
|
||||||
* \brief Helper class used by the comma initializer operator
|
* \brief Helper class used by the comma initializer operator
|
||||||
*
|
*
|
||||||
* This class is internally used to implement the comma initializer feature. It is
|
* This class is internally used to implement the comma initializer feature. It is
|
||||||
* the return type of MatrixBase::operator<<, and most of the time this is the only
|
* the return type of MatrixBase::operator<<, and most of the time this is the only
|
||||||
* way it is used.
|
* way it is used.
|
||||||
*
|
*
|
||||||
* \sa \blank \ref MatrixBaseCommaInitRef "MatrixBase::operator<<", CommaInitializer::finished()
|
* \sa \blank \ref MatrixBaseCommaInitRef "MatrixBase::operator<<", CommaInitializer::finished()
|
||||||
*/
|
*/
|
||||||
template <typename XprType>
|
template<typename XprType>
|
||||||
struct CommaInitializer {
|
struct CommaInitializer
|
||||||
|
{
|
||||||
typedef typename XprType::Scalar Scalar;
|
typedef typename XprType::Scalar Scalar;
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC constexpr CommaInitializer(XprType& xpr, const Scalar& s)
|
EIGEN_DEVICE_FUNC
|
||||||
: m_xpr(xpr), m_row(0), m_col(1), m_currentBlockRows(1) {
|
inline CommaInitializer(XprType& xpr, const Scalar& s)
|
||||||
eigen_assert(m_xpr.rows() > 0 && m_xpr.cols() > 0 && "Cannot comma-initialize a 0x0 matrix (operator<<)");
|
: m_xpr(xpr), m_row(0), m_col(1), m_currentBlockRows(1)
|
||||||
m_xpr.coeffRef(0, 0) = s;
|
{
|
||||||
|
eigen_assert(m_xpr.rows() > 0 && m_xpr.cols() > 0
|
||||||
|
&& "Cannot comma-initialize a 0x0 matrix (operator<<)");
|
||||||
|
m_xpr.coeffRef(0,0) = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
EIGEN_DEVICE_FUNC inline CommaInitializer(XprType& xpr, const DenseBase<OtherDerived>& other)
|
EIGEN_DEVICE_FUNC
|
||||||
: m_xpr(xpr), m_row(0), m_col(other.cols()), m_currentBlockRows(other.rows()) {
|
inline CommaInitializer(XprType& xpr, const DenseBase<OtherDerived>& other)
|
||||||
eigen_assert(m_xpr.rows() >= other.rows() && m_xpr.cols() >= other.cols() &&
|
: m_xpr(xpr), m_row(0), m_col(other.cols()), m_currentBlockRows(other.rows())
|
||||||
"Cannot comma-initialize a 0x0 matrix (operator<<)");
|
{
|
||||||
m_xpr.template block<OtherDerived::RowsAtCompileTime, OtherDerived::ColsAtCompileTime>(0, 0, other.rows(),
|
eigen_assert(m_xpr.rows() >= other.rows() && m_xpr.cols() >= other.cols()
|
||||||
other.cols()) = other;
|
&& "Cannot comma-initialize a 0x0 matrix (operator<<)");
|
||||||
|
m_xpr.block(0, 0, other.rows(), other.cols()) = other;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Copy/Move constructor which transfers ownership. This is crucial in
|
/* Copy/Move constructor which transfers ownership. This is crucial in
|
||||||
* absence of return value optimization to avoid assertions during destruction. */
|
* absence of return value optimization to avoid assertions during destruction. */
|
||||||
EIGEN_DEVICE_FUNC inline CommaInitializer(const CommaInitializer& o)
|
// FIXME in C++11 mode this could be replaced by a proper RValue constructor
|
||||||
: m_xpr(o.m_xpr), m_row(o.m_row), m_col(o.m_col), m_currentBlockRows(o.m_currentBlockRows) {
|
EIGEN_DEVICE_FUNC
|
||||||
|
inline CommaInitializer(const CommaInitializer& o)
|
||||||
|
: m_xpr(o.m_xpr), m_row(o.m_row), m_col(o.m_col), m_currentBlockRows(o.m_currentBlockRows) {
|
||||||
// Mark original object as finished. In absence of R-value references we need to const_cast:
|
// Mark original object as finished. In absence of R-value references we need to const_cast:
|
||||||
const_cast<CommaInitializer&>(o).m_row = m_xpr.rows();
|
const_cast<CommaInitializer&>(o).m_row = m_xpr.rows();
|
||||||
const_cast<CommaInitializer&>(o).m_col = m_xpr.cols();
|
const_cast<CommaInitializer&>(o).m_col = m_xpr.cols();
|
||||||
@@ -57,92 +61,104 @@ struct CommaInitializer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* inserts a scalar value in the target matrix */
|
/* inserts a scalar value in the target matrix */
|
||||||
EIGEN_DEVICE_FUNC CommaInitializer &operator,(const Scalar& s) {
|
EIGEN_DEVICE_FUNC
|
||||||
if (m_col == m_xpr.cols()) {
|
CommaInitializer& operator,(const Scalar& s)
|
||||||
m_row += m_currentBlockRows;
|
{
|
||||||
|
if (m_col==m_xpr.cols())
|
||||||
|
{
|
||||||
|
m_row+=m_currentBlockRows;
|
||||||
m_col = 0;
|
m_col = 0;
|
||||||
m_currentBlockRows = 1;
|
m_currentBlockRows = 1;
|
||||||
eigen_assert(m_row < m_xpr.rows() && "Too many rows passed to comma initializer (operator<<)");
|
eigen_assert(m_row<m_xpr.rows()
|
||||||
|
&& "Too many rows passed to comma initializer (operator<<)");
|
||||||
}
|
}
|
||||||
eigen_assert(m_col < m_xpr.cols() && "Too many coefficients passed to comma initializer (operator<<)");
|
eigen_assert(m_col<m_xpr.cols()
|
||||||
eigen_assert(m_currentBlockRows == 1);
|
&& "Too many coefficients passed to comma initializer (operator<<)");
|
||||||
|
eigen_assert(m_currentBlockRows==1);
|
||||||
m_xpr.coeffRef(m_row, m_col++) = s;
|
m_xpr.coeffRef(m_row, m_col++) = s;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* inserts a matrix expression in the target matrix */
|
/* inserts a matrix expression in the target matrix */
|
||||||
template <typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
EIGEN_DEVICE_FUNC CommaInitializer &operator,(const DenseBase<OtherDerived>& other) {
|
EIGEN_DEVICE_FUNC
|
||||||
if (m_col == m_xpr.cols() && (other.cols() != 0 || other.rows() != m_currentBlockRows)) {
|
CommaInitializer& operator,(const DenseBase<OtherDerived>& other)
|
||||||
m_row += m_currentBlockRows;
|
{
|
||||||
|
if (m_col==m_xpr.cols() && (other.cols()!=0 || other.rows()!=m_currentBlockRows))
|
||||||
|
{
|
||||||
|
m_row+=m_currentBlockRows;
|
||||||
m_col = 0;
|
m_col = 0;
|
||||||
m_currentBlockRows = other.rows();
|
m_currentBlockRows = other.rows();
|
||||||
eigen_assert(m_row + m_currentBlockRows <= m_xpr.rows() &&
|
eigen_assert(m_row+m_currentBlockRows<=m_xpr.rows()
|
||||||
"Too many rows passed to comma initializer (operator<<)");
|
&& "Too many rows passed to comma initializer (operator<<)");
|
||||||
}
|
}
|
||||||
eigen_assert((m_col + other.cols() <= m_xpr.cols()) &&
|
eigen_assert((m_col + other.cols() <= m_xpr.cols())
|
||||||
"Too many coefficients passed to comma initializer (operator<<)");
|
&& "Too many coefficients passed to comma initializer (operator<<)");
|
||||||
eigen_assert(m_currentBlockRows == other.rows());
|
eigen_assert(m_currentBlockRows==other.rows());
|
||||||
m_xpr.template block<OtherDerived::RowsAtCompileTime, OtherDerived::ColsAtCompileTime>(m_row, m_col, other.rows(),
|
m_xpr.template block<OtherDerived::RowsAtCompileTime, OtherDerived::ColsAtCompileTime>
|
||||||
other.cols()) = other;
|
(m_row, m_col, other.rows(), other.cols()) = other;
|
||||||
m_col += other.cols();
|
m_col += other.cols();
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC inline ~CommaInitializer()
|
EIGEN_DEVICE_FUNC
|
||||||
|
inline ~CommaInitializer()
|
||||||
#if defined VERIFY_RAISES_ASSERT && (!defined EIGEN_NO_ASSERTION_CHECKING) && defined EIGEN_EXCEPTIONS
|
#if defined VERIFY_RAISES_ASSERT && (!defined EIGEN_NO_ASSERTION_CHECKING) && defined EIGEN_EXCEPTIONS
|
||||||
noexcept(false) // Eigen::eigen_assert_exception
|
EIGEN_EXCEPTION_SPEC(Eigen::eigen_assert_exception)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
finished();
|
finished();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \returns the built matrix once all its coefficients have been set.
|
/** \returns the built matrix once all its coefficients have been set.
|
||||||
* Calling finished is 100% optional. Its purpose is to write expressions
|
* Calling finished is 100% optional. Its purpose is to write expressions
|
||||||
* like this:
|
* like this:
|
||||||
* \code
|
* \code
|
||||||
* quaternion.fromRotationMatrix((Matrix3f() << axis0, axis1, axis2).finished());
|
* quaternion.fromRotationMatrix((Matrix3f() << axis0, axis1, axis2).finished());
|
||||||
* \endcode
|
* \endcode
|
||||||
*/
|
*/
|
||||||
EIGEN_DEVICE_FUNC inline XprType& finished() {
|
EIGEN_DEVICE_FUNC
|
||||||
eigen_assert(((m_row + m_currentBlockRows) == m_xpr.rows() || m_xpr.cols() == 0) && m_col == m_xpr.cols() &&
|
inline XprType& finished() {
|
||||||
"Too few coefficients passed to comma initializer (operator<<)");
|
eigen_assert(((m_row+m_currentBlockRows) == m_xpr.rows() || m_xpr.cols() == 0)
|
||||||
return m_xpr;
|
&& m_col == m_xpr.cols()
|
||||||
|
&& "Too few coefficients passed to comma initializer (operator<<)");
|
||||||
|
return m_xpr;
|
||||||
}
|
}
|
||||||
|
|
||||||
XprType& m_xpr; // target expression
|
XprType& m_xpr; // target expression
|
||||||
Index m_row; // current row id
|
Index m_row; // current row id
|
||||||
Index m_col; // current col id
|
Index m_col; // current col id
|
||||||
Index m_currentBlockRows; // current block height
|
Index m_currentBlockRows; // current block height
|
||||||
};
|
};
|
||||||
|
|
||||||
/** \anchor MatrixBaseCommaInitRef
|
/** \anchor MatrixBaseCommaInitRef
|
||||||
* Convenient operator to set the coefficients of a matrix.
|
* Convenient operator to set the coefficients of a matrix.
|
||||||
*
|
*
|
||||||
* The coefficients must be provided in a row major order and exactly match
|
* The coefficients must be provided in a row major order and exactly match
|
||||||
* the size of the matrix. Otherwise an assertion is raised.
|
* the size of the matrix. Otherwise an assertion is raised.
|
||||||
*
|
*
|
||||||
* Example: \include MatrixBase_set.cpp
|
* Example: \include MatrixBase_set.cpp
|
||||||
* Output: \verbinclude MatrixBase_set.out
|
* Output: \verbinclude MatrixBase_set.out
|
||||||
*
|
*
|
||||||
* \note According the c++ standard, the argument expressions of this comma initializer are evaluated in arbitrary
|
* \note According the c++ standard, the argument expressions of this comma initializer are evaluated in arbitrary order.
|
||||||
* order.
|
*
|
||||||
*
|
* \sa CommaInitializer::finished(), class CommaInitializer
|
||||||
* \sa CommaInitializer::finished(), class CommaInitializer
|
*/
|
||||||
*/
|
template<typename Derived>
|
||||||
template <typename Derived>
|
EIGEN_DEVICE_FUNC inline CommaInitializer<Derived> DenseBase<Derived>::operator<< (const Scalar& s)
|
||||||
EIGEN_DEVICE_FUNC inline CommaInitializer<Derived> DenseBase<Derived>::operator<<(const Scalar& s) {
|
{
|
||||||
return CommaInitializer<Derived>(*static_cast<Derived*>(this), s);
|
return CommaInitializer<Derived>(*static_cast<Derived*>(this), s);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \sa operator<<(const Scalar&) */
|
/** \sa operator<<(const Scalar&) */
|
||||||
template <typename Derived>
|
template<typename Derived>
|
||||||
template <typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
EIGEN_DEVICE_FUNC inline CommaInitializer<Derived> DenseBase<Derived>::operator<<(
|
EIGEN_DEVICE_FUNC inline CommaInitializer<Derived>
|
||||||
const DenseBase<OtherDerived>& other) {
|
DenseBase<Derived>::operator<<(const DenseBase<OtherDerived>& other)
|
||||||
return CommaInitializer<Derived>(*static_cast<Derived*>(this), other);
|
{
|
||||||
|
return CommaInitializer<Derived>(*static_cast<Derived *>(this), other);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end namespace Eigen
|
} // end namespace Eigen
|
||||||
|
|
||||||
#endif // EIGEN_COMMAINITIALIZER_H
|
#endif // EIGEN_COMMAINITIALIZER_H
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// This file is part of Eigen, a lightweight C++ template library
|
// This file is part of Eigen, a lightweight C++ template library
|
||||||
// for linear algebra.
|
// for linear algebra.
|
||||||
//
|
//
|
||||||
// Copyright (C) 2016 Rasmus Munk Larsen (rmlarsen@gmail.com)
|
// Copyright (C) 2016 Rasmus Munk Larsen (rmlarsen@google.com)
|
||||||
//
|
//
|
||||||
// This Source Code Form is subject to the terms of the Mozilla
|
// This Source Code Form is subject to the terms of the Mozilla
|
||||||
// Public License v. 2.0. If a copy of the MPL was not distributed
|
// Public License v. 2.0. If a copy of the MPL was not distributed
|
||||||
@@ -10,9 +10,6 @@
|
|||||||
#ifndef EIGEN_CONDITIONESTIMATOR_H
|
#ifndef EIGEN_CONDITIONESTIMATOR_H
|
||||||
#define EIGEN_CONDITIONESTIMATOR_H
|
#define EIGEN_CONDITIONESTIMATOR_H
|
||||||
|
|
||||||
// IWYU pragma: private
|
|
||||||
#include "./InternalHeaderCheck.h"
|
|
||||||
|
|
||||||
namespace Eigen {
|
namespace Eigen {
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
@@ -22,7 +19,7 @@ struct rcond_compute_sign {
|
|||||||
static inline Vector run(const Vector& v) {
|
static inline Vector run(const Vector& v) {
|
||||||
const RealVector v_abs = v.cwiseAbs();
|
const RealVector v_abs = v.cwiseAbs();
|
||||||
return (v_abs.array() == static_cast<typename Vector::RealScalar>(0))
|
return (v_abs.array() == static_cast<typename Vector::RealScalar>(0))
|
||||||
.select(Vector::Ones(v.size()), v.cwiseQuotient(v_abs));
|
.select(Vector::Ones(v.size()), v.cwiseQuotient(v_abs));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -31,31 +28,33 @@ template <typename Vector>
|
|||||||
struct rcond_compute_sign<Vector, Vector, false> {
|
struct rcond_compute_sign<Vector, Vector, false> {
|
||||||
static inline Vector run(const Vector& v) {
|
static inline Vector run(const Vector& v) {
|
||||||
return (v.array() < static_cast<typename Vector::RealScalar>(0))
|
return (v.array() < static_cast<typename Vector::RealScalar>(0))
|
||||||
.select(-Vector::Ones(v.size()), Vector::Ones(v.size()));
|
.select(-Vector::Ones(v.size()), Vector::Ones(v.size()));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \returns an estimate of ||inv(matrix)||_1 given a decomposition of
|
* \returns an estimate of ||inv(matrix)||_1 given a decomposition of
|
||||||
* \a matrix that implements .solve() and .adjoint().solve() methods.
|
* \a matrix that implements .solve() and .adjoint().solve() methods.
|
||||||
*
|
*
|
||||||
* This function implements Algorithms 4.1 and 5.1 from
|
* This function implements Algorithms 4.1 and 5.1 from
|
||||||
* Higham, "Experience with a Matrix Norm Estimator",
|
* http://www.maths.manchester.ac.uk/~higham/narep/narep135.pdf
|
||||||
* SIAM J. Sci. Stat. Comput., 11(4):804-809, 1990.
|
* which also forms the basis for the condition number estimators in
|
||||||
* with Higham's alternating-sign safety-net estimate from
|
* LAPACK. Since at most 10 calls to the solve method of dec are
|
||||||
* Higham and Tisseur, "A Block Algorithm for Matrix 1-Norm Estimation,
|
* performed, the total cost is O(dims^2), as opposed to O(dims^3)
|
||||||
* with an Application to 1-Norm Pseudospectra", SIAM J. Matrix Anal. Appl.,
|
* needed to compute the inverse matrix explicitly.
|
||||||
* 21(4):1185-1201, 2000.
|
*
|
||||||
*
|
* The most common usage is in estimating the condition number
|
||||||
* The Hager/Higham gradient ascent uses at most 5 iterations of 2 solves
|
* ||matrix||_1 * ||inv(matrix)||_1. The first term ||matrix||_1 can be
|
||||||
* each, giving a total cost of O(n^2).
|
* computed directly in O(n^2) operations.
|
||||||
*
|
*
|
||||||
* Supports the following decompositions: FullPivLU, PartialPivLU, LDLT, LLT.
|
* Supports the following decompositions: FullPivLU, PartialPivLU, LDLT, and
|
||||||
*
|
* LLT.
|
||||||
* \sa FullPivLU, PartialPivLU, LDLT, LLT.
|
*
|
||||||
*/
|
* \sa FullPivLU, PartialPivLU, LDLT, LLT.
|
||||||
|
*/
|
||||||
template <typename Decomposition>
|
template <typename Decomposition>
|
||||||
typename Decomposition::RealScalar rcond_invmatrix_L1_norm_estimate(const Decomposition& dec) {
|
typename Decomposition::RealScalar rcond_invmatrix_L1_norm_estimate(const Decomposition& dec)
|
||||||
|
{
|
||||||
typedef typename Decomposition::MatrixType MatrixType;
|
typedef typename Decomposition::MatrixType MatrixType;
|
||||||
typedef typename Decomposition::Scalar Scalar;
|
typedef typename Decomposition::Scalar Scalar;
|
||||||
typedef typename Decomposition::RealScalar RealScalar;
|
typedef typename Decomposition::RealScalar RealScalar;
|
||||||
@@ -65,49 +64,54 @@ typename Decomposition::RealScalar rcond_invmatrix_L1_norm_estimate(const Decomp
|
|||||||
|
|
||||||
eigen_assert(dec.rows() == dec.cols());
|
eigen_assert(dec.rows() == dec.cols());
|
||||||
const Index n = dec.rows();
|
const Index n = dec.rows();
|
||||||
if (n == 0) return RealScalar(0);
|
if (n == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
// Disable Index to float conversion warning
|
// Disable Index to float conversion warning
|
||||||
#ifdef __INTEL_COMPILER
|
#ifdef __INTEL_COMPILER
|
||||||
#pragma warning push
|
#pragma warning push
|
||||||
#pragma warning(disable : 2259)
|
#pragma warning ( disable : 2259 )
|
||||||
#endif
|
#endif
|
||||||
Vector v = dec.solve(Vector::Ones(n) / Scalar(n));
|
Vector v = dec.solve(Vector::Ones(n) / Scalar(n));
|
||||||
#ifdef __INTEL_COMPILER
|
#ifdef __INTEL_COMPILER
|
||||||
#pragma warning pop
|
#pragma warning pop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// lower_bound is a lower bound on
|
// lower_bound is a lower bound on
|
||||||
// ||inv(matrix)||_1 = sup_v ||inv(matrix) v||_1 / ||v||_1
|
// ||inv(matrix)||_1 = sup_v ||inv(matrix) v||_1 / ||v||_1
|
||||||
// and is the objective maximized by the supergradient ascent algorithm below.
|
// and is the objective maximized by the ("super-") gradient ascent
|
||||||
|
// algorithm below.
|
||||||
RealScalar lower_bound = v.template lpNorm<1>();
|
RealScalar lower_bound = v.template lpNorm<1>();
|
||||||
if (n == 1) return lower_bound;
|
if (n == 1)
|
||||||
|
return lower_bound;
|
||||||
|
|
||||||
// Gradient ascent: the optimum is achieved at a unit vector e_j. Each
|
// Gradient ascent algorithm follows: We know that the optimum is achieved at
|
||||||
// iteration follows the supergradient to find which unit vector to probe next.
|
// one of the simplices v = e_i, so in each iteration we follow a
|
||||||
|
// super-gradient to move towards the optimal one.
|
||||||
RealScalar old_lower_bound = lower_bound;
|
RealScalar old_lower_bound = lower_bound;
|
||||||
Vector sign_vector(n);
|
Vector sign_vector(n);
|
||||||
Vector old_sign_vector;
|
Vector old_sign_vector;
|
||||||
Index v_max_abs_index = -1;
|
Index v_max_abs_index = -1;
|
||||||
Index old_v_max_abs_index = v_max_abs_index;
|
Index old_v_max_abs_index = v_max_abs_index;
|
||||||
for (int k = 0; k < 4; ++k) {
|
for (int k = 0; k < 4; ++k)
|
||||||
|
{
|
||||||
sign_vector = internal::rcond_compute_sign<Vector, RealVector, is_complex>::run(v);
|
sign_vector = internal::rcond_compute_sign<Vector, RealVector, is_complex>::run(v);
|
||||||
if (k > 0 && !is_complex && sign_vector == old_sign_vector) {
|
if (k > 0 && !is_complex && sign_vector == old_sign_vector) {
|
||||||
// Break if the sign vector stagnated.
|
// Break if the solution stagnated.
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Supergradient: z = A^{-T} * sign(v), pick argmax |z_i|.
|
// v_max_abs_index = argmax |real( inv(matrix)^T * sign_vector )|
|
||||||
v = dec.adjoint().solve(sign_vector);
|
v = dec.adjoint().solve(sign_vector);
|
||||||
v.real().cwiseAbs().maxCoeff(&v_max_abs_index);
|
v.real().cwiseAbs().maxCoeff(&v_max_abs_index);
|
||||||
if (v_max_abs_index == old_v_max_abs_index) {
|
if (v_max_abs_index == old_v_max_abs_index) {
|
||||||
// Optimality: supergradient points to the same unit vector.
|
// Break if the solution stagnated.
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Probe the best unit vector: v = A^{-1} * e_j.
|
// Move to the new simplex e_j, where j = v_max_abs_index.
|
||||||
v = dec.solve(Vector::Unit(n, v_max_abs_index));
|
v = dec.solve(Vector::Unit(n, v_max_abs_index)); // v = inv(matrix) * e_j.
|
||||||
lower_bound = v.template lpNorm<1>();
|
lower_bound = v.template lpNorm<1>();
|
||||||
if (lower_bound <= old_lower_bound) {
|
if (lower_bound <= old_lower_bound) {
|
||||||
// No improvement from the gradient step.
|
// Break if the gradient step did not increase the lower_bound.
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!is_complex) {
|
if (!is_complex) {
|
||||||
@@ -116,45 +120,52 @@ typename Decomposition::RealScalar rcond_invmatrix_L1_norm_estimate(const Decomp
|
|||||||
old_v_max_abs_index = v_max_abs_index;
|
old_v_max_abs_index = v_max_abs_index;
|
||||||
old_lower_bound = lower_bound;
|
old_lower_bound = lower_bound;
|
||||||
}
|
}
|
||||||
// Higham's alternating-sign estimate: an independent safety-net that catches
|
// The following calculates an independent estimate of ||matrix||_1 by
|
||||||
// cases where the gradient ascent converges to a local maximum due to exact
|
// multiplying matrix by a vector with entries of slowly increasing
|
||||||
// cancellation patterns (especially with permutations and backsubstitutions).
|
// magnitude and alternating sign:
|
||||||
// v_i = (-1)^i * (1 + i/(n-1)), then estimate = 2*||A^{-1}*v||_1 / (3*n).
|
// v_i = (-1)^{i} (1 + (i / (dim-1))), i = 0,...,dim-1.
|
||||||
|
// This improvement to Hager's algorithm above is due to Higham. It was
|
||||||
|
// added to make the algorithm more robust in certain corner cases where
|
||||||
|
// large elements in the matrix might otherwise escape detection due to
|
||||||
|
// exact cancellation (especially when op and op_adjoint correspond to a
|
||||||
|
// sequence of backsubstitutions and permutations), which could cause
|
||||||
|
// Hager's algorithm to vastly underestimate ||matrix||_1.
|
||||||
Scalar alternating_sign(RealScalar(1));
|
Scalar alternating_sign(RealScalar(1));
|
||||||
for (Index i = 0; i < n; ++i) {
|
for (Index i = 0; i < n; ++i) {
|
||||||
// The static_cast is needed when Scalar is complex and RealScalar uses expression templates.
|
// The static_cast is needed when Scalar is a complex and RealScalar implements expression templates
|
||||||
v[i] = alternating_sign * static_cast<RealScalar>(RealScalar(1) + (RealScalar(i) / (RealScalar(n - 1))));
|
v[i] = alternating_sign * static_cast<RealScalar>(RealScalar(1) + (RealScalar(i) / (RealScalar(n - 1))));
|
||||||
alternating_sign = -alternating_sign;
|
alternating_sign = -alternating_sign;
|
||||||
}
|
}
|
||||||
v = dec.solve(v);
|
v = dec.solve(v);
|
||||||
const RealScalar alt_est = (RealScalar(2) * v.template lpNorm<1>()) / (RealScalar(3) * RealScalar(n));
|
const RealScalar alternate_lower_bound = (2 * v.template lpNorm<1>()) / (3 * RealScalar(n));
|
||||||
return numext::maxi(lower_bound, alt_est);
|
return numext::maxi(lower_bound, alternate_lower_bound);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \brief Reciprocal condition number estimator.
|
/** \brief Reciprocal condition number estimator.
|
||||||
*
|
*
|
||||||
* Computing a decomposition of a dense matrix takes O(n^3) operations, while
|
* Computing a decomposition of a dense matrix takes O(n^3) operations, while
|
||||||
* this method estimates the condition number quickly and reliably in O(n^2)
|
* this method estimates the condition number quickly and reliably in O(n^2)
|
||||||
* operations.
|
* operations.
|
||||||
*
|
*
|
||||||
* \returns an estimate of the reciprocal condition number
|
* \returns an estimate of the reciprocal condition number
|
||||||
* (1 / (||matrix||_1 * ||inv(matrix)||_1)) of matrix, given ||matrix||_1 and
|
* (1 / (||matrix||_1 * ||inv(matrix)||_1)) of matrix, given ||matrix||_1 and
|
||||||
* its decomposition. Supports the following decompositions: FullPivLU,
|
* its decomposition. Supports the following decompositions: FullPivLU,
|
||||||
* PartialPivLU, LDLT, and LLT.
|
* PartialPivLU, LDLT, and LLT.
|
||||||
*
|
*
|
||||||
* \sa FullPivLU, PartialPivLU, LDLT, LLT.
|
* \sa FullPivLU, PartialPivLU, LDLT, LLT.
|
||||||
*/
|
*/
|
||||||
template <typename Decomposition>
|
template <typename Decomposition>
|
||||||
typename Decomposition::RealScalar rcond_estimate_helper(typename Decomposition::RealScalar matrix_norm,
|
typename Decomposition::RealScalar
|
||||||
const Decomposition& dec) {
|
rcond_estimate_helper(typename Decomposition::RealScalar matrix_norm, const Decomposition& dec)
|
||||||
|
{
|
||||||
typedef typename Decomposition::RealScalar RealScalar;
|
typedef typename Decomposition::RealScalar RealScalar;
|
||||||
eigen_assert(dec.rows() == dec.cols());
|
eigen_assert(dec.rows() == dec.cols());
|
||||||
if (dec.rows() == 0) return NumTraits<RealScalar>::infinity();
|
if (dec.rows() == 0) return NumTraits<RealScalar>::infinity();
|
||||||
if (numext::is_exactly_zero(matrix_norm)) return RealScalar(0);
|
if (matrix_norm == RealScalar(0)) return RealScalar(0);
|
||||||
if (dec.rows() == 1) return RealScalar(1);
|
if (dec.rows() == 1) return RealScalar(1);
|
||||||
const RealScalar inverse_matrix_norm = rcond_invmatrix_L1_norm_estimate(dec);
|
const RealScalar inverse_matrix_norm = rcond_invmatrix_L1_norm_estimate(dec);
|
||||||
return (numext::is_exactly_zero(inverse_matrix_norm) ? RealScalar(0)
|
return (inverse_matrix_norm == RealScalar(0) ? RealScalar(0)
|
||||||
: (RealScalar(1) / inverse_matrix_norm) / matrix_norm);
|
: (RealScalar(1) / inverse_matrix_norm) / matrix_norm);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -10,111 +10,100 @@
|
|||||||
#ifndef EIGEN_COREITERATORS_H
|
#ifndef EIGEN_COREITERATORS_H
|
||||||
#define EIGEN_COREITERATORS_H
|
#define EIGEN_COREITERATORS_H
|
||||||
|
|
||||||
// IWYU pragma: private
|
namespace Eigen {
|
||||||
#include "./InternalHeaderCheck.h"
|
|
||||||
|
|
||||||
namespace Eigen {
|
|
||||||
|
|
||||||
/* This file contains the respective InnerIterator definition of the expressions defined in Eigen/Core
|
/* This file contains the respective InnerIterator definition of the expressions defined in Eigen/Core
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
template <typename XprType, typename EvaluatorKind>
|
template<typename XprType, typename EvaluatorKind>
|
||||||
class inner_iterator_selector;
|
class inner_iterator_selector;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \class InnerIterator
|
/** \class InnerIterator
|
||||||
* \brief An InnerIterator allows to loop over the element of any matrix expression.
|
* \brief An InnerIterator allows to loop over the element of any matrix expression.
|
||||||
*
|
*
|
||||||
* \warning To be used with care because an evaluator is constructed every time an InnerIterator iterator is
|
* \warning To be used with care because an evaluator is constructed every time an InnerIterator iterator is constructed.
|
||||||
* constructed.
|
*
|
||||||
*
|
* TODO: add a usage example
|
||||||
* TODO: add a usage example
|
*/
|
||||||
*/
|
template<typename XprType>
|
||||||
template <typename XprType>
|
class InnerIterator
|
||||||
class InnerIterator {
|
{
|
||||||
protected:
|
protected:
|
||||||
typedef internal::inner_iterator_selector<XprType, typename internal::evaluator_traits<XprType>::Kind> IteratorType;
|
typedef internal::inner_iterator_selector<XprType, typename internal::evaluator_traits<XprType>::Kind> IteratorType;
|
||||||
typedef internal::evaluator<XprType> EvaluatorType;
|
typedef internal::evaluator<XprType> EvaluatorType;
|
||||||
typedef typename internal::traits<XprType>::Scalar Scalar;
|
typedef typename internal::traits<XprType>::Scalar Scalar;
|
||||||
|
public:
|
||||||
public:
|
|
||||||
/** Construct an iterator over the \a outerId -th row or column of \a xpr */
|
/** Construct an iterator over the \a outerId -th row or column of \a xpr */
|
||||||
InnerIterator(const XprType &xpr, const Index &outerId) : m_eval(xpr), m_iter(m_eval, outerId, xpr.innerSize()) {}
|
InnerIterator(const XprType &xpr, const Index &outerId)
|
||||||
|
: m_eval(xpr), m_iter(m_eval, outerId, xpr.innerSize())
|
||||||
|
{}
|
||||||
|
|
||||||
/// \returns the value of the current coefficient.
|
/// \returns the value of the current coefficient.
|
||||||
EIGEN_STRONG_INLINE Scalar value() const { return m_iter.value(); }
|
EIGEN_STRONG_INLINE Scalar value() const { return m_iter.value(); }
|
||||||
/** Increment the iterator \c *this to the next non-zero coefficient.
|
/** Increment the iterator \c *this to the next non-zero coefficient.
|
||||||
* Explicit zeros are not skipped over. To skip explicit zeros, see class SparseView
|
* Explicit zeros are not skipped over. To skip explicit zeros, see class SparseView
|
||||||
*/
|
*/
|
||||||
EIGEN_STRONG_INLINE InnerIterator &operator++() {
|
EIGEN_STRONG_INLINE InnerIterator& operator++() { m_iter.operator++(); return *this; }
|
||||||
m_iter.operator++();
|
EIGEN_STRONG_INLINE InnerIterator& operator+=(Index i) { m_iter.operator+=(i); return *this; }
|
||||||
return *this;
|
EIGEN_STRONG_INLINE InnerIterator operator+(Index i)
|
||||||
}
|
{ InnerIterator result(*this); result+=i; return result; }
|
||||||
EIGEN_STRONG_INLINE InnerIterator &operator+=(Index i) {
|
|
||||||
m_iter.operator+=(i);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
EIGEN_STRONG_INLINE InnerIterator operator+(Index i) const {
|
|
||||||
InnerIterator result(*this);
|
|
||||||
result += i;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// \returns the column or row index of the current coefficient.
|
/// \returns the column or row index of the current coefficient.
|
||||||
EIGEN_STRONG_INLINE Index index() const { return m_iter.index(); }
|
EIGEN_STRONG_INLINE Index index() const { return m_iter.index(); }
|
||||||
/// \returns the row index of the current coefficient.
|
/// \returns the row index of the current coefficient.
|
||||||
EIGEN_STRONG_INLINE Index row() const { return m_iter.row(); }
|
EIGEN_STRONG_INLINE Index row() const { return m_iter.row(); }
|
||||||
/// \returns the column index of the current coefficient.
|
/// \returns the column index of the current coefficient.
|
||||||
EIGEN_STRONG_INLINE Index col() const { return m_iter.col(); }
|
EIGEN_STRONG_INLINE Index col() const { return m_iter.col(); }
|
||||||
/// \returns \c true if the iterator \c *this still references a valid coefficient.
|
/// \returns \c true if the iterator \c *this still references a valid coefficient.
|
||||||
EIGEN_STRONG_INLINE operator bool() const { return m_iter; }
|
EIGEN_STRONG_INLINE operator bool() const { return m_iter; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
EvaluatorType m_eval;
|
EvaluatorType m_eval;
|
||||||
IteratorType m_iter;
|
IteratorType m_iter;
|
||||||
|
private:
|
||||||
private:
|
|
||||||
// If you get here, then you're not using the right InnerIterator type, e.g.:
|
// If you get here, then you're not using the right InnerIterator type, e.g.:
|
||||||
// SparseMatrix<double,RowMajor> A;
|
// SparseMatrix<double,RowMajor> A;
|
||||||
// SparseMatrix<double>::InnerIterator it(A,0);
|
// SparseMatrix<double>::InnerIterator it(A,0);
|
||||||
template <typename T>
|
template<typename T> InnerIterator(const EigenBase<T>&,Index outer);
|
||||||
InnerIterator(const EigenBase<T> &, Index outer);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
// Generic inner iterator implementation for dense objects
|
// Generic inner iterator implementation for dense objects
|
||||||
template <typename XprType>
|
template<typename XprType>
|
||||||
class inner_iterator_selector<XprType, IndexBased> {
|
class inner_iterator_selector<XprType, IndexBased>
|
||||||
protected:
|
{
|
||||||
|
protected:
|
||||||
typedef evaluator<XprType> EvaluatorType;
|
typedef evaluator<XprType> EvaluatorType;
|
||||||
typedef typename traits<XprType>::Scalar Scalar;
|
typedef typename traits<XprType>::Scalar Scalar;
|
||||||
enum { IsRowMajor = (XprType::Flags & RowMajorBit) == RowMajorBit };
|
enum { IsRowMajor = (XprType::Flags&RowMajorBit)==RowMajorBit };
|
||||||
|
|
||||||
public:
|
public:
|
||||||
EIGEN_STRONG_INLINE inner_iterator_selector(const EvaluatorType &eval, const Index &outerId, const Index &innerSize)
|
EIGEN_STRONG_INLINE inner_iterator_selector(const EvaluatorType &eval, const Index &outerId, const Index &innerSize)
|
||||||
: m_eval(eval), m_inner(0), m_outer(outerId), m_end(innerSize) {}
|
: m_eval(eval), m_inner(0), m_outer(outerId), m_end(innerSize)
|
||||||
|
{}
|
||||||
|
|
||||||
EIGEN_STRONG_INLINE Scalar value() const {
|
EIGEN_STRONG_INLINE Scalar value() const
|
||||||
return (IsRowMajor) ? m_eval.coeff(m_outer, m_inner) : m_eval.coeff(m_inner, m_outer);
|
{
|
||||||
|
return (IsRowMajor) ? m_eval.coeff(m_outer, m_inner)
|
||||||
|
: m_eval.coeff(m_inner, m_outer);
|
||||||
}
|
}
|
||||||
|
|
||||||
EIGEN_STRONG_INLINE inner_iterator_selector &operator++() {
|
EIGEN_STRONG_INLINE inner_iterator_selector& operator++() { m_inner++; return *this; }
|
||||||
m_inner++;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
EIGEN_STRONG_INLINE Index index() const { return m_inner; }
|
EIGEN_STRONG_INLINE Index index() const { return m_inner; }
|
||||||
inline Index row() const { return IsRowMajor ? m_outer : index(); }
|
inline Index row() const { return IsRowMajor ? m_outer : index(); }
|
||||||
inline Index col() const { return IsRowMajor ? index() : m_outer; }
|
inline Index col() const { return IsRowMajor ? index() : m_outer; }
|
||||||
|
|
||||||
EIGEN_STRONG_INLINE operator bool() const { return m_inner < m_end && m_inner >= 0; }
|
EIGEN_STRONG_INLINE operator bool() const { return m_inner < m_end && m_inner>=0; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const EvaluatorType &m_eval;
|
const EvaluatorType& m_eval;
|
||||||
Index m_inner;
|
Index m_inner;
|
||||||
const Index m_outer;
|
const Index m_outer;
|
||||||
const Index m_end;
|
const Index m_end;
|
||||||
@@ -122,20 +111,22 @@ class inner_iterator_selector<XprType, IndexBased> {
|
|||||||
|
|
||||||
// For iterator-based evaluator, inner-iterator is already implemented as
|
// For iterator-based evaluator, inner-iterator is already implemented as
|
||||||
// evaluator<>::InnerIterator
|
// evaluator<>::InnerIterator
|
||||||
template <typename XprType>
|
template<typename XprType>
|
||||||
class inner_iterator_selector<XprType, IteratorBased> : public evaluator<XprType>::InnerIterator {
|
class inner_iterator_selector<XprType, IteratorBased>
|
||||||
protected:
|
: public evaluator<XprType>::InnerIterator
|
||||||
|
{
|
||||||
|
protected:
|
||||||
typedef typename evaluator<XprType>::InnerIterator Base;
|
typedef typename evaluator<XprType>::InnerIterator Base;
|
||||||
typedef evaluator<XprType> EvaluatorType;
|
typedef evaluator<XprType> EvaluatorType;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
EIGEN_STRONG_INLINE inner_iterator_selector(const EvaluatorType &eval, const Index &outerId,
|
EIGEN_STRONG_INLINE inner_iterator_selector(const EvaluatorType &eval, const Index &outerId, const Index &/*innerSize*/)
|
||||||
const Index & /*innerSize*/)
|
: Base(eval, outerId)
|
||||||
: Base(eval, outerId) {}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace internal
|
} // end namespace internal
|
||||||
|
|
||||||
} // end namespace Eigen
|
} // end namespace Eigen
|
||||||
|
|
||||||
#endif // EIGEN_COREITERATORS_H
|
#endif // EIGEN_COREITERATORS_H
|
||||||
|
|||||||
@@ -11,17 +11,15 @@
|
|||||||
#ifndef EIGEN_CWISE_BINARY_OP_H
|
#ifndef EIGEN_CWISE_BINARY_OP_H
|
||||||
#define EIGEN_CWISE_BINARY_OP_H
|
#define EIGEN_CWISE_BINARY_OP_H
|
||||||
|
|
||||||
// IWYU pragma: private
|
|
||||||
#include "./InternalHeaderCheck.h"
|
|
||||||
|
|
||||||
namespace Eigen {
|
namespace Eigen {
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
template <typename BinaryOp, typename Lhs, typename Rhs>
|
template<typename BinaryOp, typename Lhs, typename Rhs>
|
||||||
struct traits<CwiseBinaryOp<BinaryOp, Lhs, Rhs>> {
|
struct traits<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >
|
||||||
|
{
|
||||||
// we must not inherit from traits<Lhs> since it has
|
// we must not inherit from traits<Lhs> since it has
|
||||||
// the potential to cause problems with MSVC
|
// the potential to cause problems with MSVC
|
||||||
typedef remove_all_t<Lhs> Ancestor;
|
typedef typename remove_all<Lhs>::type Ancestor;
|
||||||
typedef typename traits<Ancestor>::XprKind XprKind;
|
typedef typename traits<Ancestor>::XprKind XprKind;
|
||||||
enum {
|
enum {
|
||||||
RowsAtCompileTime = traits<Ancestor>::RowsAtCompileTime,
|
RowsAtCompileTime = traits<Ancestor>::RowsAtCompileTime,
|
||||||
@@ -32,135 +30,154 @@ struct traits<CwiseBinaryOp<BinaryOp, Lhs, Rhs>> {
|
|||||||
|
|
||||||
// even though we require Lhs and Rhs to have the same scalar type (see CwiseBinaryOp constructor),
|
// even though we require Lhs and Rhs to have the same scalar type (see CwiseBinaryOp constructor),
|
||||||
// we still want to handle the case when the result type is different.
|
// we still want to handle the case when the result type is different.
|
||||||
typedef typename result_of<BinaryOp(const typename Lhs::Scalar&, const typename Rhs::Scalar&)>::type Scalar;
|
typedef typename result_of<
|
||||||
typedef typename cwise_promote_storage_type<typename traits<Lhs>::StorageKind, typename traits<Rhs>::StorageKind,
|
BinaryOp(
|
||||||
|
const typename Lhs::Scalar&,
|
||||||
|
const typename Rhs::Scalar&
|
||||||
|
)
|
||||||
|
>::type Scalar;
|
||||||
|
typedef typename cwise_promote_storage_type<typename traits<Lhs>::StorageKind,
|
||||||
|
typename traits<Rhs>::StorageKind,
|
||||||
BinaryOp>::ret StorageKind;
|
BinaryOp>::ret StorageKind;
|
||||||
typedef typename promote_index_type<typename traits<Lhs>::StorageIndex, typename traits<Rhs>::StorageIndex>::type
|
typedef typename promote_index_type<typename traits<Lhs>::StorageIndex,
|
||||||
StorageIndex;
|
typename traits<Rhs>::StorageIndex>::type StorageIndex;
|
||||||
typedef typename Lhs::Nested LhsNested;
|
typedef typename Lhs::Nested LhsNested;
|
||||||
typedef typename Rhs::Nested RhsNested;
|
typedef typename Rhs::Nested RhsNested;
|
||||||
typedef std::remove_reference_t<LhsNested> LhsNested_;
|
typedef typename remove_reference<LhsNested>::type _LhsNested;
|
||||||
typedef std::remove_reference_t<RhsNested> RhsNested_;
|
typedef typename remove_reference<RhsNested>::type _RhsNested;
|
||||||
enum {
|
enum {
|
||||||
Flags = cwise_promote_storage_order<typename traits<Lhs>::StorageKind, typename traits<Rhs>::StorageKind,
|
Flags = cwise_promote_storage_order<typename traits<Lhs>::StorageKind,typename traits<Rhs>::StorageKind,_LhsNested::Flags & RowMajorBit,_RhsNested::Flags & RowMajorBit>::value
|
||||||
LhsNested_::Flags & RowMajorBit, RhsNested_::Flags & RowMajorBit>::value
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
} // end namespace internal
|
} // end namespace internal
|
||||||
|
|
||||||
template <typename BinaryOp, typename Lhs, typename Rhs, typename StorageKind>
|
template<typename BinaryOp, typename Lhs, typename Rhs, typename StorageKind>
|
||||||
class CwiseBinaryOpImpl;
|
class CwiseBinaryOpImpl;
|
||||||
|
|
||||||
/** \class CwiseBinaryOp
|
/** \class CwiseBinaryOp
|
||||||
* \ingroup Core_Module
|
* \ingroup Core_Module
|
||||||
*
|
*
|
||||||
* \brief Generic expression where a coefficient-wise binary operator is applied to two expressions
|
* \brief Generic expression where a coefficient-wise binary operator is applied to two expressions
|
||||||
*
|
*
|
||||||
* \tparam BinaryOp template functor implementing the operator
|
* \tparam BinaryOp template functor implementing the operator
|
||||||
* \tparam LhsType the type of the left-hand side
|
* \tparam LhsType the type of the left-hand side
|
||||||
* \tparam RhsType the type of the right-hand side
|
* \tparam RhsType the type of the right-hand side
|
||||||
*
|
*
|
||||||
* This class represents an expression where a coefficient-wise binary operator is applied to two expressions.
|
* This class represents an expression where a coefficient-wise binary operator is applied to two expressions.
|
||||||
* It is the return type of binary operators, by which we mean only those binary operators where
|
* It is the return type of binary operators, by which we mean only those binary operators where
|
||||||
* both the left-hand side and the right-hand side are Eigen expressions.
|
* both the left-hand side and the right-hand side are Eigen expressions.
|
||||||
* For example, the return type of matrix1+matrix2 is a CwiseBinaryOp.
|
* For example, the return type of matrix1+matrix2 is a CwiseBinaryOp.
|
||||||
*
|
*
|
||||||
* Most of the time, this is the only way that it is used, so you typically don't have to name
|
* Most of the time, this is the only way that it is used, so you typically don't have to name
|
||||||
* CwiseBinaryOp types explicitly.
|
* CwiseBinaryOp types explicitly.
|
||||||
*
|
*
|
||||||
* \sa MatrixBase::binaryExpr(const MatrixBase<OtherDerived> &,const CustomBinaryOp &) const, class CwiseUnaryOp, class
|
* \sa MatrixBase::binaryExpr(const MatrixBase<OtherDerived> &,const CustomBinaryOp &) const, class CwiseUnaryOp, class CwiseNullaryOp
|
||||||
* CwiseNullaryOp
|
*/
|
||||||
*/
|
template<typename BinaryOp, typename LhsType, typename RhsType>
|
||||||
template <typename BinaryOp, typename LhsType, typename RhsType>
|
class CwiseBinaryOp :
|
||||||
class CwiseBinaryOp : public CwiseBinaryOpImpl<BinaryOp, LhsType, RhsType,
|
public CwiseBinaryOpImpl<
|
||||||
typename internal::cwise_promote_storage_type<
|
BinaryOp, LhsType, RhsType,
|
||||||
typename internal::traits<LhsType>::StorageKind,
|
typename internal::cwise_promote_storage_type<typename internal::traits<LhsType>::StorageKind,
|
||||||
typename internal::traits<RhsType>::StorageKind, BinaryOp>::ret>,
|
typename internal::traits<RhsType>::StorageKind,
|
||||||
internal::no_assignment_operator {
|
BinaryOp>::ret>,
|
||||||
public:
|
internal::no_assignment_operator
|
||||||
typedef internal::remove_all_t<BinaryOp> Functor;
|
{
|
||||||
typedef internal::remove_all_t<LhsType> Lhs;
|
public:
|
||||||
typedef internal::remove_all_t<RhsType> Rhs;
|
|
||||||
|
|
||||||
typedef typename CwiseBinaryOpImpl<
|
typedef typename internal::remove_all<BinaryOp>::type Functor;
|
||||||
BinaryOp, LhsType, RhsType,
|
typedef typename internal::remove_all<LhsType>::type Lhs;
|
||||||
typename internal::cwise_promote_storage_type<typename internal::traits<LhsType>::StorageKind,
|
typedef typename internal::remove_all<RhsType>::type Rhs;
|
||||||
typename internal::traits<Rhs>::StorageKind, BinaryOp>::ret>::Base
|
|
||||||
Base;
|
|
||||||
EIGEN_GENERIC_PUBLIC_INTERFACE(CwiseBinaryOp)
|
|
||||||
|
|
||||||
EIGEN_CHECK_BINARY_COMPATIBILIY(BinaryOp, typename Lhs::Scalar, typename Rhs::Scalar)
|
typedef typename CwiseBinaryOpImpl<
|
||||||
EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Lhs, Rhs)
|
BinaryOp, LhsType, RhsType,
|
||||||
|
typename internal::cwise_promote_storage_type<typename internal::traits<LhsType>::StorageKind,
|
||||||
|
typename internal::traits<Rhs>::StorageKind,
|
||||||
|
BinaryOp>::ret>::Base Base;
|
||||||
|
EIGEN_GENERIC_PUBLIC_INTERFACE(CwiseBinaryOp)
|
||||||
|
|
||||||
typedef typename internal::ref_selector<LhsType>::type LhsNested;
|
typedef typename internal::ref_selector<LhsType>::type LhsNested;
|
||||||
typedef typename internal::ref_selector<RhsType>::type RhsNested;
|
typedef typename internal::ref_selector<RhsType>::type RhsNested;
|
||||||
typedef std::remove_reference_t<LhsNested> LhsNested_;
|
typedef typename internal::remove_reference<LhsNested>::type _LhsNested;
|
||||||
typedef std::remove_reference_t<RhsNested> RhsNested_;
|
typedef typename internal::remove_reference<RhsNested>::type _RhsNested;
|
||||||
|
|
||||||
#if EIGEN_COMP_MSVC
|
#if EIGEN_COMP_MSVC && EIGEN_HAS_CXX11
|
||||||
// Required for Visual Studio, which may fail to inline the copy constructor otherwise.
|
//Required for Visual Studio or the Copy constructor will probably not get inlined!
|
||||||
EIGEN_STRONG_INLINE CwiseBinaryOp(const CwiseBinaryOp<BinaryOp, LhsType, RhsType>&) = default;
|
EIGEN_STRONG_INLINE
|
||||||
|
CwiseBinaryOp(const CwiseBinaryOp<BinaryOp,LhsType,RhsType>&) = default;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE CwiseBinaryOp(const Lhs& aLhs, const Rhs& aRhs,
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||||
const BinaryOp& func = BinaryOp())
|
CwiseBinaryOp(const Lhs& aLhs, const Rhs& aRhs, const BinaryOp& func = BinaryOp())
|
||||||
: m_lhs(aLhs), m_rhs(aRhs), m_functor(func) {
|
: m_lhs(aLhs), m_rhs(aRhs), m_functor(func)
|
||||||
eigen_assert(aLhs.rows() == aRhs.rows() && aLhs.cols() == aRhs.cols());
|
{
|
||||||
}
|
EIGEN_CHECK_BINARY_COMPATIBILIY(BinaryOp,typename Lhs::Scalar,typename Rhs::Scalar);
|
||||||
|
// require the sizes to match
|
||||||
|
EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Lhs, Rhs)
|
||||||
|
eigen_assert(aLhs.rows() == aRhs.rows() && aLhs.cols() == aRhs.cols());
|
||||||
|
}
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC constexpr Index rows() const noexcept {
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR
|
||||||
// return the fixed size type if available to enable compile time optimizations
|
Index rows() const EIGEN_NOEXCEPT {
|
||||||
return internal::traits<internal::remove_all_t<LhsNested>>::RowsAtCompileTime == Dynamic ? m_rhs.rows()
|
// return the fixed size type if available to enable compile time optimizations
|
||||||
: m_lhs.rows();
|
return internal::traits<typename internal::remove_all<LhsNested>::type>::RowsAtCompileTime==Dynamic ? m_rhs.rows() : m_lhs.rows();
|
||||||
}
|
}
|
||||||
EIGEN_DEVICE_FUNC constexpr Index cols() const noexcept {
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR
|
||||||
// return the fixed size type if available to enable compile time optimizations
|
Index cols() const EIGEN_NOEXCEPT {
|
||||||
return internal::traits<internal::remove_all_t<LhsNested>>::ColsAtCompileTime == Dynamic ? m_rhs.cols()
|
// return the fixed size type if available to enable compile time optimizations
|
||||||
: m_lhs.cols();
|
return internal::traits<typename internal::remove_all<LhsNested>::type>::ColsAtCompileTime==Dynamic ? m_rhs.cols() : m_lhs.cols();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \returns the left hand side nested expression */
|
/** \returns the left hand side nested expression */
|
||||||
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const LhsNested_& lhs() const { return m_lhs; }
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||||
/** \returns the right hand side nested expression */
|
const _LhsNested& lhs() const { return m_lhs; }
|
||||||
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const RhsNested_& rhs() const { return m_rhs; }
|
/** \returns the right hand side nested expression */
|
||||||
/** \returns the functor representing the binary operation */
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||||
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const BinaryOp& functor() const { return m_functor; }
|
const _RhsNested& rhs() const { return m_rhs; }
|
||||||
|
/** \returns the functor representing the binary operation */
|
||||||
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||||
|
const BinaryOp& functor() const { return m_functor; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
LhsNested m_lhs;
|
LhsNested m_lhs;
|
||||||
RhsNested m_rhs;
|
RhsNested m_rhs;
|
||||||
const BinaryOp m_functor;
|
const BinaryOp m_functor;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Generic API dispatcher
|
// Generic API dispatcher
|
||||||
template <typename BinaryOp, typename Lhs, typename Rhs, typename StorageKind>
|
template<typename BinaryOp, typename Lhs, typename Rhs, typename StorageKind>
|
||||||
class CwiseBinaryOpImpl : public internal::generic_xpr_base<CwiseBinaryOp<BinaryOp, Lhs, Rhs>>::type {
|
class CwiseBinaryOpImpl
|
||||||
public:
|
: public internal::generic_xpr_base<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >::type
|
||||||
typedef typename internal::generic_xpr_base<CwiseBinaryOp<BinaryOp, Lhs, Rhs>>::type Base;
|
{
|
||||||
|
public:
|
||||||
|
typedef typename internal::generic_xpr_base<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >::type Base;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** replaces \c *this by \c *this - \a other.
|
/** replaces \c *this by \c *this - \a other.
|
||||||
*
|
*
|
||||||
* \returns a reference to \c *this
|
* \returns a reference to \c *this
|
||||||
*/
|
*/
|
||||||
template <typename Derived>
|
template<typename Derived>
|
||||||
template <typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Derived& MatrixBase<Derived>::operator-=(const MatrixBase<OtherDerived>& other) {
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived &
|
||||||
call_assignment(derived(), other.derived(), internal::sub_assign_op<Scalar, typename OtherDerived::Scalar>());
|
MatrixBase<Derived>::operator-=(const MatrixBase<OtherDerived> &other)
|
||||||
|
{
|
||||||
|
call_assignment(derived(), other.derived(), internal::sub_assign_op<Scalar,typename OtherDerived::Scalar>());
|
||||||
return derived();
|
return derived();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** replaces \c *this by \c *this + \a other.
|
/** replaces \c *this by \c *this + \a other.
|
||||||
*
|
*
|
||||||
* \returns a reference to \c *this
|
* \returns a reference to \c *this
|
||||||
*/
|
*/
|
||||||
template <typename Derived>
|
template<typename Derived>
|
||||||
template <typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Derived& MatrixBase<Derived>::operator+=(const MatrixBase<OtherDerived>& other) {
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived &
|
||||||
call_assignment(derived(), other.derived(), internal::add_assign_op<Scalar, typename OtherDerived::Scalar>());
|
MatrixBase<Derived>::operator+=(const MatrixBase<OtherDerived>& other)
|
||||||
|
{
|
||||||
|
call_assignment(derived(), other.derived(), internal::add_assign_op<Scalar,typename OtherDerived::Scalar>());
|
||||||
return derived();
|
return derived();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end namespace Eigen
|
} // end namespace Eigen
|
||||||
|
|
||||||
#endif // EIGEN_CWISE_BINARY_OP_H
|
#endif // EIGEN_CWISE_BINARY_OP_H
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -12,17 +12,14 @@
|
|||||||
#ifndef EIGEN_CWISE_TERNARY_OP_H
|
#ifndef EIGEN_CWISE_TERNARY_OP_H
|
||||||
#define EIGEN_CWISE_TERNARY_OP_H
|
#define EIGEN_CWISE_TERNARY_OP_H
|
||||||
|
|
||||||
// IWYU pragma: private
|
|
||||||
#include "./InternalHeaderCheck.h"
|
|
||||||
|
|
||||||
namespace Eigen {
|
namespace Eigen {
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
template <typename TernaryOp, typename Arg1, typename Arg2, typename Arg3>
|
template <typename TernaryOp, typename Arg1, typename Arg2, typename Arg3>
|
||||||
struct traits<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3>> {
|
struct traits<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3> > {
|
||||||
// we must not inherit from traits<Arg1> since it has
|
// we must not inherit from traits<Arg1> since it has
|
||||||
// the potential to cause problems with MSVC
|
// the potential to cause problems with MSVC
|
||||||
typedef remove_all_t<Arg1> Ancestor;
|
typedef typename remove_all<Arg1>::type Ancestor;
|
||||||
typedef typename traits<Ancestor>::XprKind XprKind;
|
typedef typename traits<Ancestor>::XprKind XprKind;
|
||||||
enum {
|
enum {
|
||||||
RowsAtCompileTime = traits<Ancestor>::RowsAtCompileTime,
|
RowsAtCompileTime = traits<Ancestor>::RowsAtCompileTime,
|
||||||
@@ -34,8 +31,9 @@ struct traits<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3>> {
|
|||||||
// even though we require Arg1, Arg2, and Arg3 to have the same scalar type
|
// even though we require Arg1, Arg2, and Arg3 to have the same scalar type
|
||||||
// (see CwiseTernaryOp constructor),
|
// (see CwiseTernaryOp constructor),
|
||||||
// we still want to handle the case when the result type is different.
|
// we still want to handle the case when the result type is different.
|
||||||
typedef typename result_of<TernaryOp(const typename Arg1::Scalar&, const typename Arg2::Scalar&,
|
typedef typename result_of<TernaryOp(
|
||||||
const typename Arg3::Scalar&)>::type Scalar;
|
const typename Arg1::Scalar&, const typename Arg2::Scalar&,
|
||||||
|
const typename Arg3::Scalar&)>::type Scalar;
|
||||||
|
|
||||||
typedef typename internal::traits<Arg1>::StorageKind StorageKind;
|
typedef typename internal::traits<Arg1>::StorageKind StorageKind;
|
||||||
typedef typename internal::traits<Arg1>::StorageIndex StorageIndex;
|
typedef typename internal::traits<Arg1>::StorageIndex StorageIndex;
|
||||||
@@ -43,114 +41,138 @@ struct traits<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3>> {
|
|||||||
typedef typename Arg1::Nested Arg1Nested;
|
typedef typename Arg1::Nested Arg1Nested;
|
||||||
typedef typename Arg2::Nested Arg2Nested;
|
typedef typename Arg2::Nested Arg2Nested;
|
||||||
typedef typename Arg3::Nested Arg3Nested;
|
typedef typename Arg3::Nested Arg3Nested;
|
||||||
typedef std::remove_reference_t<Arg1Nested> Arg1Nested_;
|
typedef typename remove_reference<Arg1Nested>::type _Arg1Nested;
|
||||||
typedef std::remove_reference_t<Arg2Nested> Arg2Nested_;
|
typedef typename remove_reference<Arg2Nested>::type _Arg2Nested;
|
||||||
typedef std::remove_reference_t<Arg3Nested> Arg3Nested_;
|
typedef typename remove_reference<Arg3Nested>::type _Arg3Nested;
|
||||||
enum { Flags = Arg1Nested_::Flags & RowMajorBit };
|
enum { Flags = _Arg1Nested::Flags & RowMajorBit };
|
||||||
};
|
};
|
||||||
} // end namespace internal
|
} // end namespace internal
|
||||||
|
|
||||||
template <typename TernaryOp, typename Arg1, typename Arg2, typename Arg3, typename StorageKind>
|
template <typename TernaryOp, typename Arg1, typename Arg2, typename Arg3,
|
||||||
|
typename StorageKind>
|
||||||
class CwiseTernaryOpImpl;
|
class CwiseTernaryOpImpl;
|
||||||
|
|
||||||
/** \class CwiseTernaryOp
|
/** \class CwiseTernaryOp
|
||||||
* \ingroup Core_Module
|
* \ingroup Core_Module
|
||||||
*
|
*
|
||||||
* \brief Generic expression where a coefficient-wise ternary operator is
|
* \brief Generic expression where a coefficient-wise ternary operator is
|
||||||
* applied to two expressions
|
* applied to two expressions
|
||||||
*
|
*
|
||||||
* \tparam TernaryOp template functor implementing the operator
|
* \tparam TernaryOp template functor implementing the operator
|
||||||
* \tparam Arg1Type the type of the first argument
|
* \tparam Arg1Type the type of the first argument
|
||||||
* \tparam Arg2Type the type of the second argument
|
* \tparam Arg2Type the type of the second argument
|
||||||
* \tparam Arg3Type the type of the third argument
|
* \tparam Arg3Type the type of the third argument
|
||||||
*
|
*
|
||||||
* This class represents an expression where a coefficient-wise ternary
|
* This class represents an expression where a coefficient-wise ternary
|
||||||
* operator is applied to three expressions.
|
* operator is applied to three expressions.
|
||||||
* It is the return type of ternary operators, by which we mean only those
|
* It is the return type of ternary operators, by which we mean only those
|
||||||
* ternary operators where
|
* ternary operators where
|
||||||
* all three arguments are Eigen expressions.
|
* all three arguments are Eigen expressions.
|
||||||
* For example, the return type of betainc(matrix1, matrix2, matrix3) is a
|
* For example, the return type of betainc(matrix1, matrix2, matrix3) is a
|
||||||
* CwiseTernaryOp.
|
* CwiseTernaryOp.
|
||||||
*
|
*
|
||||||
* Most of the time, this is the only way that it is used, so you typically
|
* Most of the time, this is the only way that it is used, so you typically
|
||||||
* don't have to name
|
* don't have to name
|
||||||
* CwiseTernaryOp types explicitly.
|
* CwiseTernaryOp types explicitly.
|
||||||
*
|
*
|
||||||
* \sa MatrixBase::ternaryExpr(const MatrixBase<Argument2> &, const
|
* \sa MatrixBase::ternaryExpr(const MatrixBase<Argument2> &, const
|
||||||
* MatrixBase<Argument3> &, const CustomTernaryOp &) const, class CwiseBinaryOp,
|
* MatrixBase<Argument3> &, const CustomTernaryOp &) const, class CwiseBinaryOp,
|
||||||
* class CwiseUnaryOp, class CwiseNullaryOp
|
* class CwiseUnaryOp, class CwiseNullaryOp
|
||||||
*/
|
*/
|
||||||
template <typename TernaryOp, typename Arg1Type, typename Arg2Type, typename Arg3Type>
|
template <typename TernaryOp, typename Arg1Type, typename Arg2Type,
|
||||||
class CwiseTernaryOp : public CwiseTernaryOpImpl<TernaryOp, Arg1Type, Arg2Type, Arg3Type,
|
typename Arg3Type>
|
||||||
typename internal::traits<Arg1Type>::StorageKind>,
|
class CwiseTernaryOp : public CwiseTernaryOpImpl<
|
||||||
internal::no_assignment_operator {
|
TernaryOp, Arg1Type, Arg2Type, Arg3Type,
|
||||||
|
typename internal::traits<Arg1Type>::StorageKind>,
|
||||||
|
internal::no_assignment_operator
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
typedef internal::remove_all_t<Arg1Type> Arg1;
|
typedef typename internal::remove_all<Arg1Type>::type Arg1;
|
||||||
typedef internal::remove_all_t<Arg2Type> Arg2;
|
typedef typename internal::remove_all<Arg2Type>::type Arg2;
|
||||||
typedef internal::remove_all_t<Arg3Type> Arg3;
|
typedef typename internal::remove_all<Arg3Type>::type Arg3;
|
||||||
|
|
||||||
// require the sizes to match
|
typedef typename CwiseTernaryOpImpl<
|
||||||
EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Arg1, Arg2)
|
TernaryOp, Arg1Type, Arg2Type, Arg3Type,
|
||||||
EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Arg1, Arg3)
|
typename internal::traits<Arg1Type>::StorageKind>::Base Base;
|
||||||
|
|
||||||
// The index types should match
|
|
||||||
EIGEN_STATIC_ASSERT((internal::is_same<typename internal::traits<Arg1Type>::StorageKind,
|
|
||||||
typename internal::traits<Arg2Type>::StorageKind>::value),
|
|
||||||
STORAGE_KIND_MUST_MATCH)
|
|
||||||
EIGEN_STATIC_ASSERT((internal::is_same<typename internal::traits<Arg1Type>::StorageKind,
|
|
||||||
typename internal::traits<Arg3Type>::StorageKind>::value),
|
|
||||||
STORAGE_KIND_MUST_MATCH)
|
|
||||||
|
|
||||||
typedef typename CwiseTernaryOpImpl<TernaryOp, Arg1Type, Arg2Type, Arg3Type,
|
|
||||||
typename internal::traits<Arg1Type>::StorageKind>::Base Base;
|
|
||||||
EIGEN_GENERIC_PUBLIC_INTERFACE(CwiseTernaryOp)
|
EIGEN_GENERIC_PUBLIC_INTERFACE(CwiseTernaryOp)
|
||||||
|
|
||||||
typedef typename internal::ref_selector<Arg1Type>::type Arg1Nested;
|
typedef typename internal::ref_selector<Arg1Type>::type Arg1Nested;
|
||||||
typedef typename internal::ref_selector<Arg2Type>::type Arg2Nested;
|
typedef typename internal::ref_selector<Arg2Type>::type Arg2Nested;
|
||||||
typedef typename internal::ref_selector<Arg3Type>::type Arg3Nested;
|
typedef typename internal::ref_selector<Arg3Type>::type Arg3Nested;
|
||||||
typedef std::remove_reference_t<Arg1Nested> Arg1Nested_;
|
typedef typename internal::remove_reference<Arg1Nested>::type _Arg1Nested;
|
||||||
typedef std::remove_reference_t<Arg2Nested> Arg2Nested_;
|
typedef typename internal::remove_reference<Arg2Nested>::type _Arg2Nested;
|
||||||
typedef std::remove_reference_t<Arg3Nested> Arg3Nested_;
|
typedef typename internal::remove_reference<Arg3Nested>::type _Arg3Nested;
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CwiseTernaryOp(const Arg1& a1, const Arg2& a2, const Arg3& a3,
|
EIGEN_DEVICE_FUNC
|
||||||
const TernaryOp& func = TernaryOp())
|
EIGEN_STRONG_INLINE CwiseTernaryOp(const Arg1& a1, const Arg2& a2,
|
||||||
|
const Arg3& a3,
|
||||||
|
const TernaryOp& func = TernaryOp())
|
||||||
: m_arg1(a1), m_arg2(a2), m_arg3(a3), m_functor(func) {
|
: m_arg1(a1), m_arg2(a2), m_arg3(a3), m_functor(func) {
|
||||||
eigen_assert(a1.rows() == a2.rows() && a1.cols() == a2.cols() && a1.rows() == a3.rows() && a1.cols() == a3.cols());
|
// require the sizes to match
|
||||||
|
EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Arg1, Arg2)
|
||||||
|
EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Arg1, Arg3)
|
||||||
|
|
||||||
|
// The index types should match
|
||||||
|
EIGEN_STATIC_ASSERT((internal::is_same<
|
||||||
|
typename internal::traits<Arg1Type>::StorageKind,
|
||||||
|
typename internal::traits<Arg2Type>::StorageKind>::value),
|
||||||
|
STORAGE_KIND_MUST_MATCH)
|
||||||
|
EIGEN_STATIC_ASSERT((internal::is_same<
|
||||||
|
typename internal::traits<Arg1Type>::StorageKind,
|
||||||
|
typename internal::traits<Arg3Type>::StorageKind>::value),
|
||||||
|
STORAGE_KIND_MUST_MATCH)
|
||||||
|
|
||||||
|
eigen_assert(a1.rows() == a2.rows() && a1.cols() == a2.cols() &&
|
||||||
|
a1.rows() == a3.rows() && a1.cols() == a3.cols());
|
||||||
}
|
}
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Index rows() const {
|
EIGEN_DEVICE_FUNC
|
||||||
|
EIGEN_STRONG_INLINE Index rows() const {
|
||||||
// return the fixed size type if available to enable compile time
|
// return the fixed size type if available to enable compile time
|
||||||
// optimizations
|
// optimizations
|
||||||
if (internal::traits<internal::remove_all_t<Arg1Nested>>::RowsAtCompileTime == Dynamic &&
|
if (internal::traits<typename internal::remove_all<Arg1Nested>::type>::
|
||||||
internal::traits<internal::remove_all_t<Arg2Nested>>::RowsAtCompileTime == Dynamic)
|
RowsAtCompileTime == Dynamic &&
|
||||||
|
internal::traits<typename internal::remove_all<Arg2Nested>::type>::
|
||||||
|
RowsAtCompileTime == Dynamic)
|
||||||
return m_arg3.rows();
|
return m_arg3.rows();
|
||||||
else if (internal::traits<internal::remove_all_t<Arg1Nested>>::RowsAtCompileTime == Dynamic &&
|
else if (internal::traits<typename internal::remove_all<Arg1Nested>::type>::
|
||||||
internal::traits<internal::remove_all_t<Arg3Nested>>::RowsAtCompileTime == Dynamic)
|
RowsAtCompileTime == Dynamic &&
|
||||||
|
internal::traits<typename internal::remove_all<Arg3Nested>::type>::
|
||||||
|
RowsAtCompileTime == Dynamic)
|
||||||
return m_arg2.rows();
|
return m_arg2.rows();
|
||||||
else
|
else
|
||||||
return m_arg1.rows();
|
return m_arg1.rows();
|
||||||
}
|
}
|
||||||
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Index cols() const {
|
EIGEN_DEVICE_FUNC
|
||||||
|
EIGEN_STRONG_INLINE Index cols() const {
|
||||||
// return the fixed size type if available to enable compile time
|
// return the fixed size type if available to enable compile time
|
||||||
// optimizations
|
// optimizations
|
||||||
if (internal::traits<internal::remove_all_t<Arg1Nested>>::ColsAtCompileTime == Dynamic &&
|
if (internal::traits<typename internal::remove_all<Arg1Nested>::type>::
|
||||||
internal::traits<internal::remove_all_t<Arg2Nested>>::ColsAtCompileTime == Dynamic)
|
ColsAtCompileTime == Dynamic &&
|
||||||
|
internal::traits<typename internal::remove_all<Arg2Nested>::type>::
|
||||||
|
ColsAtCompileTime == Dynamic)
|
||||||
return m_arg3.cols();
|
return m_arg3.cols();
|
||||||
else if (internal::traits<internal::remove_all_t<Arg1Nested>>::ColsAtCompileTime == Dynamic &&
|
else if (internal::traits<typename internal::remove_all<Arg1Nested>::type>::
|
||||||
internal::traits<internal::remove_all_t<Arg3Nested>>::ColsAtCompileTime == Dynamic)
|
ColsAtCompileTime == Dynamic &&
|
||||||
|
internal::traits<typename internal::remove_all<Arg3Nested>::type>::
|
||||||
|
ColsAtCompileTime == Dynamic)
|
||||||
return m_arg2.cols();
|
return m_arg2.cols();
|
||||||
else
|
else
|
||||||
return m_arg1.cols();
|
return m_arg1.cols();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \returns the first argument nested expression */
|
/** \returns the first argument nested expression */
|
||||||
EIGEN_DEVICE_FUNC constexpr const Arg1Nested_& arg1() const { return m_arg1; }
|
EIGEN_DEVICE_FUNC
|
||||||
|
const _Arg1Nested& arg1() const { return m_arg1; }
|
||||||
/** \returns the first argument nested expression */
|
/** \returns the first argument nested expression */
|
||||||
EIGEN_DEVICE_FUNC constexpr const Arg2Nested_& arg2() const { return m_arg2; }
|
EIGEN_DEVICE_FUNC
|
||||||
|
const _Arg2Nested& arg2() const { return m_arg2; }
|
||||||
/** \returns the third argument nested expression */
|
/** \returns the third argument nested expression */
|
||||||
EIGEN_DEVICE_FUNC constexpr const Arg3Nested_& arg3() const { return m_arg3; }
|
EIGEN_DEVICE_FUNC
|
||||||
|
const _Arg3Nested& arg3() const { return m_arg3; }
|
||||||
/** \returns the functor representing the ternary operation */
|
/** \returns the functor representing the ternary operation */
|
||||||
EIGEN_DEVICE_FUNC constexpr const TernaryOp& functor() const { return m_functor; }
|
EIGEN_DEVICE_FUNC
|
||||||
|
const TernaryOp& functor() const { return m_functor; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Arg1Nested m_arg1;
|
Arg1Nested m_arg1;
|
||||||
@@ -160,10 +182,14 @@ class CwiseTernaryOp : public CwiseTernaryOpImpl<TernaryOp, Arg1Type, Arg2Type,
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Generic API dispatcher
|
// Generic API dispatcher
|
||||||
template <typename TernaryOp, typename Arg1, typename Arg2, typename Arg3, typename StorageKind>
|
template <typename TernaryOp, typename Arg1, typename Arg2, typename Arg3,
|
||||||
class CwiseTernaryOpImpl : public internal::generic_xpr_base<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3>>::type {
|
typename StorageKind>
|
||||||
|
class CwiseTernaryOpImpl
|
||||||
|
: public internal::generic_xpr_base<
|
||||||
|
CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3> >::type {
|
||||||
public:
|
public:
|
||||||
typedef typename internal::generic_xpr_base<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3>>::type Base;
|
typedef typename internal::generic_xpr_base<
|
||||||
|
CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3> >::type Base;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace Eigen
|
} // end namespace Eigen
|
||||||
|
|||||||
@@ -11,85 +11,93 @@
|
|||||||
#ifndef EIGEN_CWISE_UNARY_OP_H
|
#ifndef EIGEN_CWISE_UNARY_OP_H
|
||||||
#define EIGEN_CWISE_UNARY_OP_H
|
#define EIGEN_CWISE_UNARY_OP_H
|
||||||
|
|
||||||
// IWYU pragma: private
|
|
||||||
#include "./InternalHeaderCheck.h"
|
|
||||||
|
|
||||||
namespace Eigen {
|
namespace Eigen {
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
template <typename UnaryOp, typename XprType>
|
template<typename UnaryOp, typename XprType>
|
||||||
struct traits<CwiseUnaryOp<UnaryOp, XprType> > : traits<XprType> {
|
struct traits<CwiseUnaryOp<UnaryOp, XprType> >
|
||||||
typedef typename result_of<UnaryOp(const typename XprType::Scalar&)>::type Scalar;
|
: traits<XprType>
|
||||||
|
{
|
||||||
|
typedef typename result_of<
|
||||||
|
UnaryOp(const typename XprType::Scalar&)
|
||||||
|
>::type Scalar;
|
||||||
typedef typename XprType::Nested XprTypeNested;
|
typedef typename XprType::Nested XprTypeNested;
|
||||||
typedef std::remove_reference_t<XprTypeNested> XprTypeNested_;
|
typedef typename remove_reference<XprTypeNested>::type _XprTypeNested;
|
||||||
enum { Flags = XprTypeNested_::Flags & RowMajorBit };
|
enum {
|
||||||
|
Flags = _XprTypeNested::Flags & RowMajorBit
|
||||||
|
};
|
||||||
};
|
};
|
||||||
} // namespace internal
|
}
|
||||||
|
|
||||||
template <typename UnaryOp, typename XprType, typename StorageKind>
|
template<typename UnaryOp, typename XprType, typename StorageKind>
|
||||||
class CwiseUnaryOpImpl;
|
class CwiseUnaryOpImpl;
|
||||||
|
|
||||||
/** \class CwiseUnaryOp
|
/** \class CwiseUnaryOp
|
||||||
* \ingroup Core_Module
|
* \ingroup Core_Module
|
||||||
*
|
*
|
||||||
* \brief Generic expression where a coefficient-wise unary operator is applied to an expression
|
* \brief Generic expression where a coefficient-wise unary operator is applied to an expression
|
||||||
*
|
*
|
||||||
* \tparam UnaryOp template functor implementing the operator
|
* \tparam UnaryOp template functor implementing the operator
|
||||||
* \tparam XprType the type of the expression to which we are applying the unary operator
|
* \tparam XprType the type of the expression to which we are applying the unary operator
|
||||||
*
|
*
|
||||||
* This class represents an expression where a unary operator is applied to an expression.
|
* This class represents an expression where a unary operator is applied to an expression.
|
||||||
* It is the return type of all operations taking exactly 1 input expression, regardless of the
|
* It is the return type of all operations taking exactly 1 input expression, regardless of the
|
||||||
* presence of other inputs such as scalars. For example, the operator* in the expression 3*matrix
|
* presence of other inputs such as scalars. For example, the operator* in the expression 3*matrix
|
||||||
* is considered unary, because only the right-hand side is an expression, and its
|
* is considered unary, because only the right-hand side is an expression, and its
|
||||||
* return type is a specialization of CwiseUnaryOp.
|
* return type is a specialization of CwiseUnaryOp.
|
||||||
*
|
*
|
||||||
* Most of the time, this is the only way that it is used, so you typically don't have to name
|
* Most of the time, this is the only way that it is used, so you typically don't have to name
|
||||||
* CwiseUnaryOp types explicitly.
|
* CwiseUnaryOp types explicitly.
|
||||||
*
|
*
|
||||||
* \sa MatrixBase::unaryExpr(const CustomUnaryOp &) const, class CwiseBinaryOp, class CwiseNullaryOp
|
* \sa MatrixBase::unaryExpr(const CustomUnaryOp &) const, class CwiseBinaryOp, class CwiseNullaryOp
|
||||||
*/
|
*/
|
||||||
template <typename UnaryOp, typename XprType>
|
template<typename UnaryOp, typename XprType>
|
||||||
class CwiseUnaryOp : public CwiseUnaryOpImpl<UnaryOp, XprType, typename internal::traits<XprType>::StorageKind>,
|
class CwiseUnaryOp : public CwiseUnaryOpImpl<UnaryOp, XprType, typename internal::traits<XprType>::StorageKind>, internal::no_assignment_operator
|
||||||
internal::no_assignment_operator {
|
{
|
||||||
public:
|
public:
|
||||||
typedef typename CwiseUnaryOpImpl<UnaryOp, XprType, typename internal::traits<XprType>::StorageKind>::Base Base;
|
|
||||||
EIGEN_GENERIC_PUBLIC_INTERFACE(CwiseUnaryOp)
|
|
||||||
typedef typename internal::ref_selector<XprType>::type XprTypeNested;
|
|
||||||
typedef internal::remove_all_t<XprType> NestedExpression;
|
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE explicit CwiseUnaryOp(const XprType& xpr,
|
typedef typename CwiseUnaryOpImpl<UnaryOp, XprType,typename internal::traits<XprType>::StorageKind>::Base Base;
|
||||||
const UnaryOp& func = UnaryOp())
|
EIGEN_GENERIC_PUBLIC_INTERFACE(CwiseUnaryOp)
|
||||||
|
typedef typename internal::ref_selector<XprType>::type XprTypeNested;
|
||||||
|
typedef typename internal::remove_all<XprType>::type NestedExpression;
|
||||||
|
|
||||||
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||||
|
explicit CwiseUnaryOp(const XprType& xpr, const UnaryOp& func = UnaryOp())
|
||||||
: m_xpr(xpr), m_functor(func) {}
|
: m_xpr(xpr), m_functor(func) {}
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC constexpr Index rows() const noexcept { return m_xpr.rows(); }
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR
|
||||||
EIGEN_DEVICE_FUNC constexpr Index cols() const noexcept { return m_xpr.cols(); }
|
Index rows() const EIGEN_NOEXCEPT { return m_xpr.rows(); }
|
||||||
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR
|
||||||
|
Index cols() const EIGEN_NOEXCEPT { return m_xpr.cols(); }
|
||||||
|
|
||||||
/** \returns the functor representing the unary operation */
|
/** \returns the functor representing the unary operation */
|
||||||
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const UnaryOp& functor() const { return m_functor; }
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||||
|
const UnaryOp& functor() const { return m_functor; }
|
||||||
|
|
||||||
/** \returns the nested expression */
|
/** \returns the nested expression */
|
||||||
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const internal::remove_all_t<XprTypeNested>& nestedExpression()
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||||
const {
|
const typename internal::remove_all<XprTypeNested>::type&
|
||||||
return m_xpr;
|
nestedExpression() const { return m_xpr; }
|
||||||
}
|
|
||||||
|
|
||||||
/** \returns the nested expression */
|
/** \returns the nested expression */
|
||||||
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE internal::remove_all_t<XprTypeNested>& nestedExpression() {
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||||
return m_xpr;
|
typename internal::remove_all<XprTypeNested>::type&
|
||||||
}
|
nestedExpression() { return m_xpr; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
XprTypeNested m_xpr;
|
XprTypeNested m_xpr;
|
||||||
const UnaryOp m_functor;
|
const UnaryOp m_functor;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Generic API dispatcher
|
// Generic API dispatcher
|
||||||
template <typename UnaryOp, typename XprType, typename StorageKind>
|
template<typename UnaryOp, typename XprType, typename StorageKind>
|
||||||
class CwiseUnaryOpImpl : public internal::generic_xpr_base<CwiseUnaryOp<UnaryOp, XprType> >::type {
|
class CwiseUnaryOpImpl
|
||||||
public:
|
: public internal::generic_xpr_base<CwiseUnaryOp<UnaryOp, XprType> >::type
|
||||||
|
{
|
||||||
|
public:
|
||||||
typedef typename internal::generic_xpr_base<CwiseUnaryOp<UnaryOp, XprType> >::type Base;
|
typedef typename internal::generic_xpr_base<CwiseUnaryOp<UnaryOp, XprType> >::type Base;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace Eigen
|
} // end namespace Eigen
|
||||||
|
|
||||||
#endif // EIGEN_CWISE_UNARY_OP_H
|
#endif // EIGEN_CWISE_UNARY_OP_H
|
||||||
|
|||||||
@@ -10,160 +10,123 @@
|
|||||||
#ifndef EIGEN_CWISE_UNARY_VIEW_H
|
#ifndef EIGEN_CWISE_UNARY_VIEW_H
|
||||||
#define EIGEN_CWISE_UNARY_VIEW_H
|
#define EIGEN_CWISE_UNARY_VIEW_H
|
||||||
|
|
||||||
// IWYU pragma: private
|
|
||||||
#include "./InternalHeaderCheck.h"
|
|
||||||
|
|
||||||
namespace Eigen {
|
namespace Eigen {
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
template <typename ViewOp, typename MatrixType, typename StrideType>
|
template<typename ViewOp, typename MatrixType>
|
||||||
struct traits<CwiseUnaryView<ViewOp, MatrixType, StrideType> > : traits<MatrixType> {
|
struct traits<CwiseUnaryView<ViewOp, MatrixType> >
|
||||||
typedef typename result_of<ViewOp(typename traits<MatrixType>::Scalar&)>::type1 ScalarRef;
|
: traits<MatrixType>
|
||||||
static_assert(std::is_reference<ScalarRef>::value, "Views must return a reference type.");
|
{
|
||||||
typedef remove_all_t<ScalarRef> Scalar;
|
typedef typename result_of<
|
||||||
|
ViewOp(const typename traits<MatrixType>::Scalar&)
|
||||||
|
>::type Scalar;
|
||||||
typedef typename MatrixType::Nested MatrixTypeNested;
|
typedef typename MatrixType::Nested MatrixTypeNested;
|
||||||
typedef remove_all_t<MatrixTypeNested> MatrixTypeNested_;
|
typedef typename remove_all<MatrixTypeNested>::type _MatrixTypeNested;
|
||||||
enum {
|
enum {
|
||||||
FlagsLvalueBit = is_lvalue<MatrixType>::value ? LvalueBit : 0,
|
FlagsLvalueBit = is_lvalue<MatrixType>::value ? LvalueBit : 0,
|
||||||
Flags =
|
Flags = traits<_MatrixTypeNested>::Flags & (RowMajorBit | FlagsLvalueBit | DirectAccessBit), // FIXME DirectAccessBit should not be handled by expressions
|
||||||
traits<MatrixTypeNested_>::Flags &
|
MatrixTypeInnerStride = inner_stride_at_compile_time<MatrixType>::ret,
|
||||||
(RowMajorBit | FlagsLvalueBit | DirectAccessBit), // FIXME DirectAccessBit should not be handled by expressions
|
|
||||||
MatrixTypeInnerStride = inner_stride_at_compile_time<MatrixType>::ret,
|
|
||||||
// need to cast the sizeof's from size_t to int explicitly, otherwise:
|
// need to cast the sizeof's from size_t to int explicitly, otherwise:
|
||||||
// "error: no integral type can represent all of the enumerator values
|
// "error: no integral type can represent all of the enumerator values
|
||||||
InnerStrideAtCompileTime =
|
InnerStrideAtCompileTime = MatrixTypeInnerStride == Dynamic
|
||||||
StrideType::InnerStrideAtCompileTime == 0
|
? int(Dynamic)
|
||||||
? (MatrixTypeInnerStride == Dynamic
|
: int(MatrixTypeInnerStride) * int(sizeof(typename traits<MatrixType>::Scalar) / sizeof(Scalar)),
|
||||||
? int(Dynamic)
|
OuterStrideAtCompileTime = outer_stride_at_compile_time<MatrixType>::ret == Dynamic
|
||||||
: int(MatrixTypeInnerStride) * int(sizeof(typename traits<MatrixType>::Scalar) / sizeof(Scalar)))
|
? int(Dynamic)
|
||||||
: int(StrideType::InnerStrideAtCompileTime),
|
: outer_stride_at_compile_time<MatrixType>::ret * int(sizeof(typename traits<MatrixType>::Scalar) / sizeof(Scalar))
|
||||||
|
|
||||||
OuterStrideAtCompileTime = StrideType::OuterStrideAtCompileTime == 0
|
|
||||||
? (outer_stride_at_compile_time<MatrixType>::ret == Dynamic
|
|
||||||
? int(Dynamic)
|
|
||||||
: outer_stride_at_compile_time<MatrixType>::ret *
|
|
||||||
int(sizeof(typename traits<MatrixType>::Scalar) / sizeof(Scalar)))
|
|
||||||
: int(StrideType::OuterStrideAtCompileTime)
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename ViewOp, typename MatrixType, typename StorageKind>
|
||||||
|
class CwiseUnaryViewImpl;
|
||||||
|
|
||||||
|
/** \class CwiseUnaryView
|
||||||
|
* \ingroup Core_Module
|
||||||
|
*
|
||||||
|
* \brief Generic lvalue expression of a coefficient-wise unary operator of a matrix or a vector
|
||||||
|
*
|
||||||
|
* \tparam ViewOp template functor implementing the view
|
||||||
|
* \tparam MatrixType the type of the matrix we are applying the unary operator
|
||||||
|
*
|
||||||
|
* This class represents a lvalue expression of a generic unary view operator of a matrix or a vector.
|
||||||
|
* It is the return type of real() and imag(), and most of the time this is the only way it is used.
|
||||||
|
*
|
||||||
|
* \sa MatrixBase::unaryViewExpr(const CustomUnaryOp &) const, class CwiseUnaryOp
|
||||||
|
*/
|
||||||
|
template<typename ViewOp, typename MatrixType>
|
||||||
|
class CwiseUnaryView : public CwiseUnaryViewImpl<ViewOp, MatrixType, typename internal::traits<MatrixType>::StorageKind>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
typedef typename CwiseUnaryViewImpl<ViewOp, MatrixType,typename internal::traits<MatrixType>::StorageKind>::Base Base;
|
||||||
|
EIGEN_GENERIC_PUBLIC_INTERFACE(CwiseUnaryView)
|
||||||
|
typedef typename internal::ref_selector<MatrixType>::non_const_type MatrixTypeNested;
|
||||||
|
typedef typename internal::remove_all<MatrixType>::type NestedExpression;
|
||||||
|
|
||||||
|
explicit EIGEN_DEVICE_FUNC inline CwiseUnaryView(MatrixType& mat, const ViewOp& func = ViewOp())
|
||||||
|
: m_matrix(mat), m_functor(func) {}
|
||||||
|
|
||||||
|
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(CwiseUnaryView)
|
||||||
|
|
||||||
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR
|
||||||
|
Index rows() const EIGEN_NOEXCEPT { return m_matrix.rows(); }
|
||||||
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR
|
||||||
|
Index cols() const EIGEN_NOEXCEPT { return m_matrix.cols(); }
|
||||||
|
|
||||||
|
/** \returns the functor representing unary operation */
|
||||||
|
EIGEN_DEVICE_FUNC const ViewOp& functor() const { return m_functor; }
|
||||||
|
|
||||||
|
/** \returns the nested expression */
|
||||||
|
EIGEN_DEVICE_FUNC const typename internal::remove_all<MatrixTypeNested>::type&
|
||||||
|
nestedExpression() const { return m_matrix; }
|
||||||
|
|
||||||
|
/** \returns the nested expression */
|
||||||
|
EIGEN_DEVICE_FUNC typename internal::remove_reference<MatrixTypeNested>::type&
|
||||||
|
nestedExpression() { return m_matrix; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
MatrixTypeNested m_matrix;
|
||||||
|
ViewOp m_functor;
|
||||||
|
};
|
||||||
|
|
||||||
// Generic API dispatcher
|
// Generic API dispatcher
|
||||||
template <typename ViewOp, typename XprType, typename StrideType, typename StorageKind,
|
template<typename ViewOp, typename XprType, typename StorageKind>
|
||||||
bool Mutable = !std::is_const<XprType>::value>
|
class CwiseUnaryViewImpl
|
||||||
class CwiseUnaryViewImpl : public generic_xpr_base<CwiseUnaryView<ViewOp, XprType, StrideType> >::type {
|
: public internal::generic_xpr_base<CwiseUnaryView<ViewOp, XprType> >::type
|
||||||
public:
|
{
|
||||||
typedef typename generic_xpr_base<CwiseUnaryView<ViewOp, XprType, StrideType> >::type Base;
|
public:
|
||||||
|
typedef typename internal::generic_xpr_base<CwiseUnaryView<ViewOp, XprType> >::type Base;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename ViewOp, typename MatrixType, typename StrideType>
|
template<typename ViewOp, typename MatrixType>
|
||||||
class CwiseUnaryViewImpl<ViewOp, MatrixType, StrideType, Dense, false>
|
class CwiseUnaryViewImpl<ViewOp,MatrixType,Dense>
|
||||||
: public dense_xpr_base<CwiseUnaryView<ViewOp, MatrixType, StrideType> >::type {
|
: public internal::dense_xpr_base< CwiseUnaryView<ViewOp, MatrixType> >::type
|
||||||
public:
|
{
|
||||||
typedef CwiseUnaryView<ViewOp, MatrixType, StrideType> Derived;
|
public:
|
||||||
typedef typename dense_xpr_base<CwiseUnaryView<ViewOp, MatrixType, StrideType> >::type Base;
|
|
||||||
EIGEN_DENSE_PUBLIC_INTERFACE(Derived)
|
|
||||||
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(CwiseUnaryViewImpl)
|
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC inline const Scalar* data() const { return &(this->coeffRef(0)); }
|
typedef CwiseUnaryView<ViewOp, MatrixType> Derived;
|
||||||
|
typedef typename internal::dense_xpr_base< CwiseUnaryView<ViewOp, MatrixType> >::type Base;
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC constexpr Index innerStride() const {
|
EIGEN_DENSE_PUBLIC_INTERFACE(Derived)
|
||||||
return StrideType::InnerStrideAtCompileTime != 0 ? int(StrideType::InnerStrideAtCompileTime)
|
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(CwiseUnaryViewImpl)
|
||||||
: derived().nestedExpression().innerStride() *
|
|
||||||
sizeof(typename traits<MatrixType>::Scalar) / sizeof(Scalar);
|
|
||||||
}
|
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC constexpr Index outerStride() const {
|
EIGEN_DEVICE_FUNC inline Scalar* data() { return &(this->coeffRef(0)); }
|
||||||
return StrideType::OuterStrideAtCompileTime != 0 ? int(StrideType::OuterStrideAtCompileTime)
|
EIGEN_DEVICE_FUNC inline const Scalar* data() const { return &(this->coeff(0)); }
|
||||||
: derived().nestedExpression().outerStride() *
|
|
||||||
sizeof(typename traits<MatrixType>::Scalar) / sizeof(Scalar);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR inline Index innerStride() const
|
||||||
EIGEN_DEFAULT_EMPTY_CONSTRUCTOR_AND_DESTRUCTOR(CwiseUnaryViewImpl)
|
{
|
||||||
|
return derived().nestedExpression().innerStride() * sizeof(typename internal::traits<MatrixType>::Scalar) / sizeof(Scalar);
|
||||||
|
}
|
||||||
|
|
||||||
// Allow const access to coeffRef for the case of direct access being enabled.
|
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR inline Index outerStride() const
|
||||||
EIGEN_DEVICE_FUNC inline const Scalar& coeffRef(Index index) const {
|
{
|
||||||
return internal::evaluator<Derived>(derived()).coeffRef(index);
|
return derived().nestedExpression().outerStride() * sizeof(typename internal::traits<MatrixType>::Scalar) / sizeof(Scalar);
|
||||||
}
|
}
|
||||||
|
protected:
|
||||||
EIGEN_DEVICE_FUNC inline const Scalar& coeffRef(Index row, Index col) const {
|
EIGEN_DEFAULT_EMPTY_CONSTRUCTOR_AND_DESTRUCTOR(CwiseUnaryViewImpl)
|
||||||
return internal::evaluator<Derived>(derived()).coeffRef(row, col);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename ViewOp, typename MatrixType, typename StrideType>
|
} // end namespace Eigen
|
||||||
class CwiseUnaryViewImpl<ViewOp, MatrixType, StrideType, Dense, true>
|
|
||||||
: public CwiseUnaryViewImpl<ViewOp, MatrixType, StrideType, Dense, false> {
|
|
||||||
public:
|
|
||||||
typedef CwiseUnaryViewImpl<ViewOp, MatrixType, StrideType, Dense, false> Base;
|
|
||||||
typedef CwiseUnaryView<ViewOp, MatrixType, StrideType> Derived;
|
|
||||||
EIGEN_DENSE_PUBLIC_INTERFACE(Derived)
|
|
||||||
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(CwiseUnaryViewImpl)
|
|
||||||
|
|
||||||
using Base::data;
|
#endif // EIGEN_CWISE_UNARY_VIEW_H
|
||||||
EIGEN_DEVICE_FUNC inline Scalar* data() { return &(this->coeffRef(0)); }
|
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& coeffRef(Index row, Index col) {
|
|
||||||
return internal::evaluator<Derived>(derived()).coeffRef(row, col);
|
|
||||||
}
|
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& coeffRef(Index index) {
|
|
||||||
return internal::evaluator<Derived>(derived()).coeffRef(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
EIGEN_DEFAULT_EMPTY_CONSTRUCTOR_AND_DESTRUCTOR(CwiseUnaryViewImpl)
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace internal
|
|
||||||
|
|
||||||
/** \class CwiseUnaryView
|
|
||||||
* \ingroup Core_Module
|
|
||||||
*
|
|
||||||
* \brief Generic lvalue expression of a coefficient-wise unary operator of a matrix or a vector
|
|
||||||
*
|
|
||||||
* \tparam ViewOp template functor implementing the view
|
|
||||||
* \tparam MatrixType the type of the matrix we are applying the unary operator
|
|
||||||
*
|
|
||||||
* This class represents a lvalue expression of a generic unary view operator of a matrix or a vector.
|
|
||||||
* It is the return type of real() and imag(), and most of the time this is the only way it is used.
|
|
||||||
*
|
|
||||||
* \sa MatrixBase::unaryViewExpr(const CustomUnaryOp &) const, class CwiseUnaryOp
|
|
||||||
*/
|
|
||||||
template <typename ViewOp, typename MatrixType, typename StrideType>
|
|
||||||
class CwiseUnaryView : public internal::CwiseUnaryViewImpl<ViewOp, MatrixType, StrideType,
|
|
||||||
typename internal::traits<MatrixType>::StorageKind> {
|
|
||||||
public:
|
|
||||||
typedef typename internal::CwiseUnaryViewImpl<ViewOp, MatrixType, StrideType,
|
|
||||||
typename internal::traits<MatrixType>::StorageKind>::Base Base;
|
|
||||||
EIGEN_GENERIC_PUBLIC_INTERFACE(CwiseUnaryView)
|
|
||||||
typedef typename internal::ref_selector<MatrixType>::non_const_type MatrixTypeNested;
|
|
||||||
typedef internal::remove_all_t<MatrixType> NestedExpression;
|
|
||||||
|
|
||||||
explicit EIGEN_DEVICE_FUNC constexpr inline CwiseUnaryView(MatrixType& mat, const ViewOp& func = ViewOp())
|
|
||||||
: m_matrix(mat), m_functor(func) {}
|
|
||||||
|
|
||||||
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(CwiseUnaryView)
|
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC constexpr Index rows() const noexcept { return m_matrix.rows(); }
|
|
||||||
EIGEN_DEVICE_FUNC constexpr Index cols() const noexcept { return m_matrix.cols(); }
|
|
||||||
|
|
||||||
/** \returns the functor representing unary operation */
|
|
||||||
EIGEN_DEVICE_FUNC constexpr const ViewOp& functor() const { return m_functor; }
|
|
||||||
|
|
||||||
/** \returns the nested expression */
|
|
||||||
EIGEN_DEVICE_FUNC constexpr const internal::remove_all_t<MatrixTypeNested>& nestedExpression() const {
|
|
||||||
return m_matrix;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** \returns the nested expression */
|
|
||||||
EIGEN_DEVICE_FUNC constexpr std::remove_reference_t<MatrixTypeNested>& nestedExpression() { return m_matrix; }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
MatrixTypeNested m_matrix;
|
|
||||||
ViewOp m_functor;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Eigen
|
|
||||||
|
|
||||||
#endif // EIGEN_CWISE_UNARY_VIEW_H
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,153 +0,0 @@
|
|||||||
// This file is part of Eigen, a lightweight C++ template library
|
|
||||||
// for linear algebra.
|
|
||||||
//
|
|
||||||
// Copyright (C) 2023 Charlie Schlosser <cs.schlosser@gmail.com>
|
|
||||||
//
|
|
||||||
// This Source Code Form is subject to the terms of the Mozilla
|
|
||||||
// Public License v. 2.0. If a copy of the MPL was not distributed
|
|
||||||
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
#ifndef EIGEN_DEVICEWRAPPER_H
|
|
||||||
#define EIGEN_DEVICEWRAPPER_H
|
|
||||||
|
|
||||||
namespace Eigen {
|
|
||||||
template <typename Derived, typename Device>
|
|
||||||
struct DeviceWrapper {
|
|
||||||
using Base = EigenBase<internal::remove_all_t<Derived>>;
|
|
||||||
using Scalar = typename Derived::Scalar;
|
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC DeviceWrapper(Base& xpr, Device& device) : m_xpr(xpr.derived()), m_device(device) {}
|
|
||||||
EIGEN_DEVICE_FUNC DeviceWrapper(const Base& xpr, Device& device) : m_xpr(xpr.derived()), m_device(device) {}
|
|
||||||
|
|
||||||
template <typename OtherDerived>
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator=(const EigenBase<OtherDerived>& other) {
|
|
||||||
using AssignOp = internal::assign_op<Scalar, typename OtherDerived::Scalar>;
|
|
||||||
internal::call_assignment(*this, other.derived(), AssignOp());
|
|
||||||
return m_xpr;
|
|
||||||
}
|
|
||||||
template <typename OtherDerived>
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator+=(const EigenBase<OtherDerived>& other) {
|
|
||||||
using AddAssignOp = internal::add_assign_op<Scalar, typename OtherDerived::Scalar>;
|
|
||||||
internal::call_assignment(*this, other.derived(), AddAssignOp());
|
|
||||||
return m_xpr;
|
|
||||||
}
|
|
||||||
template <typename OtherDerived>
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator-=(const EigenBase<OtherDerived>& other) {
|
|
||||||
using SubAssignOp = internal::sub_assign_op<Scalar, typename OtherDerived::Scalar>;
|
|
||||||
internal::call_assignment(*this, other.derived(), SubAssignOp());
|
|
||||||
return m_xpr;
|
|
||||||
}
|
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& derived() { return m_xpr; }
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Device& device() { return m_device; }
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE NoAlias<DeviceWrapper, EigenBase> noalias() {
|
|
||||||
return NoAlias<DeviceWrapper, EigenBase>(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
Derived& m_xpr;
|
|
||||||
Device& m_device;
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace internal {
|
|
||||||
|
|
||||||
// this is where we differentiate between lazy assignment and specialized kernels (e.g. matrix products)
|
|
||||||
template <typename DstXprType, typename SrcXprType, typename Functor, typename Device,
|
|
||||||
typename Kind = typename AssignmentKind<typename evaluator_traits<DstXprType>::Shape,
|
|
||||||
typename evaluator_traits<SrcXprType>::Shape>::Kind,
|
|
||||||
typename EnableIf = void>
|
|
||||||
struct AssignmentWithDevice;
|
|
||||||
|
|
||||||
// unless otherwise specified, use the default product implementation
|
|
||||||
template <typename DstXprType, typename Lhs, typename Rhs, int Options, typename Functor, typename Device,
|
|
||||||
typename Weak>
|
|
||||||
struct AssignmentWithDevice<DstXprType, Product<Lhs, Rhs, Options>, Functor, Device, Dense2Dense, Weak> {
|
|
||||||
using SrcXprType = Product<Lhs, Rhs, Options>;
|
|
||||||
using Base = Assignment<DstXprType, SrcXprType, Functor>;
|
|
||||||
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void run(DstXprType& dst, const SrcXprType& src, const Functor& func,
|
|
||||||
Device&) {
|
|
||||||
Base::run(dst, src, func);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// specialization for coeffcient-wise assignment
|
|
||||||
template <typename DstXprType, typename SrcXprType, typename Functor, typename Device, typename Weak>
|
|
||||||
struct AssignmentWithDevice<DstXprType, SrcXprType, Functor, Device, Dense2Dense, Weak> {
|
|
||||||
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void run(DstXprType& dst, const SrcXprType& src, const Functor& func,
|
|
||||||
Device& device) {
|
|
||||||
#ifndef EIGEN_NO_DEBUG
|
|
||||||
internal::check_for_aliasing(dst, src);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
call_dense_assignment_loop(dst, src, func, device);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// this allows us to use the default evaluation scheme if it is not specialized for the device
|
|
||||||
template <typename Kernel, typename Device, int Traversal = Kernel::AssignmentTraits::Traversal,
|
|
||||||
int Unrolling = Kernel::AssignmentTraits::Unrolling>
|
|
||||||
struct dense_assignment_loop_with_device {
|
|
||||||
using Base = dense_assignment_loop<Kernel, Traversal, Unrolling>;
|
|
||||||
static EIGEN_DEVICE_FUNC constexpr void run(Kernel& kernel, Device&) { Base::run(kernel); }
|
|
||||||
};
|
|
||||||
|
|
||||||
// entry point for a generic expression with device
|
|
||||||
template <typename Dst, typename Src, typename Func, typename Device>
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr void call_assignment_no_alias(DeviceWrapper<Dst, Device> dst,
|
|
||||||
const Src& src, const Func& func) {
|
|
||||||
enum {
|
|
||||||
NeedToTranspose = ((int(Dst::RowsAtCompileTime) == 1 && int(Src::ColsAtCompileTime) == 1) ||
|
|
||||||
(int(Dst::ColsAtCompileTime) == 1 && int(Src::RowsAtCompileTime) == 1)) &&
|
|
||||||
int(Dst::SizeAtCompileTime) != 1
|
|
||||||
};
|
|
||||||
|
|
||||||
using ActualDstTypeCleaned = std::conditional_t<NeedToTranspose, Transpose<Dst>, Dst>;
|
|
||||||
using ActualDstType = std::conditional_t<NeedToTranspose, Transpose<Dst>, Dst&>;
|
|
||||||
ActualDstType actualDst(dst.derived());
|
|
||||||
|
|
||||||
// TODO: check whether this is the right place to perform these checks:
|
|
||||||
EIGEN_STATIC_ASSERT_LVALUE(Dst)
|
|
||||||
EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(ActualDstTypeCleaned, Src)
|
|
||||||
EIGEN_CHECK_BINARY_COMPATIBILIY(Func, typename ActualDstTypeCleaned::Scalar, typename Src::Scalar);
|
|
||||||
|
|
||||||
// this provides a mechanism for specializing simple assignments, matrix products, etc
|
|
||||||
AssignmentWithDevice<ActualDstTypeCleaned, Src, Func, Device>::run(actualDst, src, func, dst.device());
|
|
||||||
}
|
|
||||||
|
|
||||||
// copy and pasted from AssignEvaluator except forward device to kernel
|
|
||||||
template <typename DstXprType, typename SrcXprType, typename Functor, typename Device>
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr void call_dense_assignment_loop(DstXprType& dst, const SrcXprType& src,
|
|
||||||
const Functor& func, Device& device) {
|
|
||||||
using DstEvaluatorType = evaluator<DstXprType>;
|
|
||||||
using SrcEvaluatorType = evaluator<SrcXprType>;
|
|
||||||
|
|
||||||
SrcEvaluatorType srcEvaluator(src);
|
|
||||||
|
|
||||||
// NOTE To properly handle A = (A*A.transpose())/s with A rectangular,
|
|
||||||
// we need to resize the destination after the source evaluator has been created.
|
|
||||||
resize_if_allowed(dst, src, func);
|
|
||||||
|
|
||||||
DstEvaluatorType dstEvaluator(dst);
|
|
||||||
|
|
||||||
using Kernel = generic_dense_assignment_kernel<DstEvaluatorType, SrcEvaluatorType, Functor>;
|
|
||||||
|
|
||||||
Kernel kernel(dstEvaluator, srcEvaluator, func, dst.const_cast_derived());
|
|
||||||
|
|
||||||
dense_assignment_loop_with_device<Kernel, Device>::run(kernel, device);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace internal
|
|
||||||
|
|
||||||
template <typename Derived>
|
|
||||||
template <typename Device>
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DeviceWrapper<Derived, Device> EigenBase<Derived>::device(Device& device) {
|
|
||||||
return DeviceWrapper<Derived, Device>(derived(), device);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Derived>
|
|
||||||
template <typename Device>
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DeviceWrapper<const Derived, Device> EigenBase<Derived>::device(
|
|
||||||
Device& device) const {
|
|
||||||
return DeviceWrapper<const Derived, Device>(derived(), device);
|
|
||||||
}
|
|
||||||
} // namespace Eigen
|
|
||||||
#endif
|
|
||||||
@@ -11,211 +11,249 @@
|
|||||||
#ifndef EIGEN_DIAGONAL_H
|
#ifndef EIGEN_DIAGONAL_H
|
||||||
#define EIGEN_DIAGONAL_H
|
#define EIGEN_DIAGONAL_H
|
||||||
|
|
||||||
// IWYU pragma: private
|
|
||||||
#include "./InternalHeaderCheck.h"
|
|
||||||
|
|
||||||
namespace Eigen {
|
namespace Eigen {
|
||||||
|
|
||||||
/** \class Diagonal
|
/** \class Diagonal
|
||||||
* \ingroup Core_Module
|
* \ingroup Core_Module
|
||||||
*
|
*
|
||||||
* \brief Expression of a diagonal/subdiagonal/superdiagonal in a matrix
|
* \brief Expression of a diagonal/subdiagonal/superdiagonal in a matrix
|
||||||
*
|
*
|
||||||
* \tparam MatrixType the type of the object in which we are taking a sub/main/super diagonal
|
* \param MatrixType the type of the object in which we are taking a sub/main/super diagonal
|
||||||
* \tparam DiagIndex the index of the sub/super diagonal. The default is 0 and it means the main diagonal.
|
* \param DiagIndex the index of the sub/super diagonal. The default is 0 and it means the main diagonal.
|
||||||
* A positive value means a superdiagonal, a negative value means a subdiagonal.
|
* A positive value means a superdiagonal, a negative value means a subdiagonal.
|
||||||
* You can also use DynamicIndex so the index can be set at runtime.
|
* You can also use DynamicIndex so the index can be set at runtime.
|
||||||
*
|
*
|
||||||
* The matrix is not required to be square.
|
* The matrix is not required to be square.
|
||||||
*
|
*
|
||||||
* This class represents an expression of the main diagonal, or any sub/super diagonal
|
* This class represents an expression of the main diagonal, or any sub/super diagonal
|
||||||
* of a square matrix. It is the return type of MatrixBase::diagonal() and MatrixBase::diagonal(Index) and most of the
|
* of a square matrix. It is the return type of MatrixBase::diagonal() and MatrixBase::diagonal(Index) and most of the
|
||||||
* time this is the only way it is used.
|
* time this is the only way it is used.
|
||||||
*
|
*
|
||||||
* \sa MatrixBase::diagonal(), MatrixBase::diagonal(Index)
|
* \sa MatrixBase::diagonal(), MatrixBase::diagonal(Index)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
template <typename MatrixType, int DiagIndex>
|
template<typename MatrixType, int DiagIndex>
|
||||||
struct traits<Diagonal<MatrixType, DiagIndex> > : traits<MatrixType> {
|
struct traits<Diagonal<MatrixType,DiagIndex> >
|
||||||
|
: traits<MatrixType>
|
||||||
|
{
|
||||||
typedef typename ref_selector<MatrixType>::type MatrixTypeNested;
|
typedef typename ref_selector<MatrixType>::type MatrixTypeNested;
|
||||||
typedef std::remove_reference_t<MatrixTypeNested> MatrixTypeNested_;
|
typedef typename remove_reference<MatrixTypeNested>::type _MatrixTypeNested;
|
||||||
typedef typename MatrixType::StorageKind StorageKind;
|
typedef typename MatrixType::StorageKind StorageKind;
|
||||||
enum {
|
enum {
|
||||||
RowsAtCompileTime = (int(DiagIndex) == DynamicIndex || int(MatrixType::SizeAtCompileTime) == Dynamic)
|
RowsAtCompileTime = (int(DiagIndex) == DynamicIndex || int(MatrixType::SizeAtCompileTime) == Dynamic) ? Dynamic
|
||||||
? Dynamic
|
: (EIGEN_PLAIN_ENUM_MIN(MatrixType::RowsAtCompileTime - EIGEN_PLAIN_ENUM_MAX(-DiagIndex, 0),
|
||||||
: (plain_enum_min(MatrixType::RowsAtCompileTime - plain_enum_max(-DiagIndex, 0),
|
MatrixType::ColsAtCompileTime - EIGEN_PLAIN_ENUM_MAX( DiagIndex, 0))),
|
||||||
MatrixType::ColsAtCompileTime - plain_enum_max(DiagIndex, 0))),
|
|
||||||
ColsAtCompileTime = 1,
|
ColsAtCompileTime = 1,
|
||||||
MaxRowsAtCompileTime =
|
MaxRowsAtCompileTime = int(MatrixType::MaxSizeAtCompileTime) == Dynamic ? Dynamic
|
||||||
int(MatrixType::MaxSizeAtCompileTime) == Dynamic ? Dynamic
|
: DiagIndex == DynamicIndex ? EIGEN_SIZE_MIN_PREFER_FIXED(MatrixType::MaxRowsAtCompileTime,
|
||||||
: DiagIndex == DynamicIndex
|
MatrixType::MaxColsAtCompileTime)
|
||||||
? min_size_prefer_fixed(MatrixType::MaxRowsAtCompileTime, MatrixType::MaxColsAtCompileTime)
|
: (EIGEN_PLAIN_ENUM_MIN(MatrixType::MaxRowsAtCompileTime - EIGEN_PLAIN_ENUM_MAX(-DiagIndex, 0),
|
||||||
: (plain_enum_min(MatrixType::MaxRowsAtCompileTime - plain_enum_max(-DiagIndex, 0),
|
MatrixType::MaxColsAtCompileTime - EIGEN_PLAIN_ENUM_MAX( DiagIndex, 0))),
|
||||||
MatrixType::MaxColsAtCompileTime - plain_enum_max(DiagIndex, 0))),
|
|
||||||
MaxColsAtCompileTime = 1,
|
MaxColsAtCompileTime = 1,
|
||||||
MaskLvalueBit = is_lvalue<MatrixType>::value ? LvalueBit : 0,
|
MaskLvalueBit = is_lvalue<MatrixType>::value ? LvalueBit : 0,
|
||||||
Flags = (unsigned int)MatrixTypeNested_::Flags & (RowMajorBit | MaskLvalueBit | DirectAccessBit) &
|
Flags = (unsigned int)_MatrixTypeNested::Flags & (RowMajorBit | MaskLvalueBit | DirectAccessBit) & ~RowMajorBit, // FIXME DirectAccessBit should not be handled by expressions
|
||||||
~RowMajorBit, // FIXME DirectAccessBit should not be handled by expressions
|
|
||||||
MatrixTypeOuterStride = outer_stride_at_compile_time<MatrixType>::ret,
|
MatrixTypeOuterStride = outer_stride_at_compile_time<MatrixType>::ret,
|
||||||
InnerStrideAtCompileTime = MatrixTypeOuterStride == Dynamic ? Dynamic : MatrixTypeOuterStride + 1,
|
InnerStrideAtCompileTime = MatrixTypeOuterStride == Dynamic ? Dynamic : MatrixTypeOuterStride+1,
|
||||||
OuterStrideAtCompileTime = 0
|
OuterStrideAtCompileTime = 0
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
} // namespace internal
|
}
|
||||||
|
|
||||||
template <typename MatrixType, int DiagIndex_>
|
template<typename MatrixType, int _DiagIndex> class Diagonal
|
||||||
class Diagonal : public internal::dense_xpr_base<Diagonal<MatrixType, DiagIndex_> >::type {
|
: public internal::dense_xpr_base< Diagonal<MatrixType,_DiagIndex> >::type
|
||||||
public:
|
{
|
||||||
enum { DiagIndex = DiagIndex_ };
|
public:
|
||||||
typedef typename internal::dense_xpr_base<Diagonal>::type Base;
|
|
||||||
EIGEN_DENSE_PUBLIC_INTERFACE(Diagonal)
|
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC constexpr explicit inline Diagonal(MatrixType& matrix, Index a_index = DiagIndex)
|
enum { DiagIndex = _DiagIndex };
|
||||||
: m_matrix(matrix), m_index(a_index) {
|
typedef typename internal::dense_xpr_base<Diagonal>::type Base;
|
||||||
eigen_assert(a_index <= m_matrix.cols() && -a_index <= m_matrix.rows());
|
EIGEN_DENSE_PUBLIC_INTERFACE(Diagonal)
|
||||||
}
|
|
||||||
|
|
||||||
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Diagonal)
|
EIGEN_DEVICE_FUNC
|
||||||
|
explicit inline Diagonal(MatrixType& matrix, Index a_index = DiagIndex) : m_matrix(matrix), m_index(a_index)
|
||||||
|
{
|
||||||
|
eigen_assert( a_index <= m_matrix.cols() && -a_index <= m_matrix.rows() );
|
||||||
|
}
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC constexpr inline Index rows() const {
|
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Diagonal)
|
||||||
return m_index.value() < 0 ? numext::mini<Index>(m_matrix.cols(), m_matrix.rows() + m_index.value())
|
|
||||||
: numext::mini<Index>(m_matrix.rows(), m_matrix.cols() - m_index.value());
|
|
||||||
}
|
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC constexpr Index cols() const noexcept { return 1; }
|
EIGEN_DEVICE_FUNC
|
||||||
|
inline Index rows() const
|
||||||
|
{
|
||||||
|
return m_index.value()<0 ? numext::mini<Index>(m_matrix.cols(),m_matrix.rows()+m_index.value())
|
||||||
|
: numext::mini<Index>(m_matrix.rows(),m_matrix.cols()-m_index.value());
|
||||||
|
}
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC constexpr Index innerStride() const noexcept { return m_matrix.outerStride() + 1; }
|
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
|
||||||
|
inline Index cols() const EIGEN_NOEXCEPT { return 1; }
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC constexpr Index outerStride() const noexcept { return 0; }
|
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
|
||||||
|
inline Index innerStride() const EIGEN_NOEXCEPT {
|
||||||
|
return m_matrix.outerStride() + 1;
|
||||||
|
}
|
||||||
|
|
||||||
typedef std::conditional_t<internal::is_lvalue<MatrixType>::value, Scalar, const Scalar> ScalarWithConstIfNotLvalue;
|
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
|
||||||
|
inline Index outerStride() const EIGEN_NOEXCEPT { return 0; }
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC inline ScalarWithConstIfNotLvalue* data() {
|
typedef typename internal::conditional<
|
||||||
return rows() > 0 ? &(m_matrix.coeffRef(rowOffset(), colOffset())) : nullptr;
|
internal::is_lvalue<MatrixType>::value,
|
||||||
}
|
Scalar,
|
||||||
EIGEN_DEVICE_FUNC inline const Scalar* data() const {
|
const Scalar
|
||||||
return rows() > 0 ? &(m_matrix.coeffRef(rowOffset(), colOffset())) : nullptr;
|
>::type ScalarWithConstIfNotLvalue;
|
||||||
}
|
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC inline Scalar& coeffRef(Index row, Index) {
|
EIGEN_DEVICE_FUNC
|
||||||
EIGEN_STATIC_ASSERT_LVALUE(MatrixType)
|
inline ScalarWithConstIfNotLvalue* data() { return &(m_matrix.coeffRef(rowOffset(), colOffset())); }
|
||||||
return m_matrix.coeffRef(row + rowOffset(), row + colOffset());
|
EIGEN_DEVICE_FUNC
|
||||||
}
|
inline const Scalar* data() const { return &(m_matrix.coeffRef(rowOffset(), colOffset())); }
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC inline const Scalar& coeffRef(Index row, Index) const {
|
EIGEN_DEVICE_FUNC
|
||||||
return m_matrix.coeffRef(row + rowOffset(), row + colOffset());
|
inline Scalar& coeffRef(Index row, Index)
|
||||||
}
|
{
|
||||||
|
EIGEN_STATIC_ASSERT_LVALUE(MatrixType)
|
||||||
|
return m_matrix.coeffRef(row+rowOffset(), row+colOffset());
|
||||||
|
}
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC inline CoeffReturnType coeff(Index row, Index) const {
|
EIGEN_DEVICE_FUNC
|
||||||
return m_matrix.coeff(row + rowOffset(), row + colOffset());
|
inline const Scalar& coeffRef(Index row, Index) const
|
||||||
}
|
{
|
||||||
|
return m_matrix.coeffRef(row+rowOffset(), row+colOffset());
|
||||||
|
}
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC inline Scalar& coeffRef(Index idx) {
|
EIGEN_DEVICE_FUNC
|
||||||
EIGEN_STATIC_ASSERT_LVALUE(MatrixType)
|
inline CoeffReturnType coeff(Index row, Index) const
|
||||||
return m_matrix.coeffRef(idx + rowOffset(), idx + colOffset());
|
{
|
||||||
}
|
return m_matrix.coeff(row+rowOffset(), row+colOffset());
|
||||||
|
}
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC inline const Scalar& coeffRef(Index idx) const {
|
EIGEN_DEVICE_FUNC
|
||||||
return m_matrix.coeffRef(idx + rowOffset(), idx + colOffset());
|
inline Scalar& coeffRef(Index idx)
|
||||||
}
|
{
|
||||||
|
EIGEN_STATIC_ASSERT_LVALUE(MatrixType)
|
||||||
|
return m_matrix.coeffRef(idx+rowOffset(), idx+colOffset());
|
||||||
|
}
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC inline CoeffReturnType coeff(Index idx) const {
|
EIGEN_DEVICE_FUNC
|
||||||
return m_matrix.coeff(idx + rowOffset(), idx + colOffset());
|
inline const Scalar& coeffRef(Index idx) const
|
||||||
}
|
{
|
||||||
|
return m_matrix.coeffRef(idx+rowOffset(), idx+colOffset());
|
||||||
|
}
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC constexpr inline const internal::remove_all_t<typename MatrixType::Nested>& nestedExpression()
|
EIGEN_DEVICE_FUNC
|
||||||
const {
|
inline CoeffReturnType coeff(Index idx) const
|
||||||
return m_matrix;
|
{
|
||||||
}
|
return m_matrix.coeff(idx+rowOffset(), idx+colOffset());
|
||||||
|
}
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC constexpr inline Index index() const { return m_index.value(); }
|
EIGEN_DEVICE_FUNC
|
||||||
|
inline const typename internal::remove_all<typename MatrixType::Nested>::type&
|
||||||
|
nestedExpression() const
|
||||||
|
{
|
||||||
|
return m_matrix;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
EIGEN_DEVICE_FUNC
|
||||||
typename internal::ref_selector<MatrixType>::non_const_type m_matrix;
|
inline Index index() const
|
||||||
const internal::variable_if_dynamicindex<Index, DiagIndex> m_index;
|
{
|
||||||
|
return m_index.value();
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
// some compilers may fail to optimize std::max etc in case of compile-time constants...
|
typename internal::ref_selector<MatrixType>::non_const_type m_matrix;
|
||||||
EIGEN_DEVICE_FUNC constexpr Index absDiagIndex() const noexcept {
|
const internal::variable_if_dynamicindex<Index, DiagIndex> m_index;
|
||||||
return m_index.value() > 0 ? m_index.value() : -m_index.value();
|
|
||||||
}
|
private:
|
||||||
EIGEN_DEVICE_FUNC constexpr Index rowOffset() const noexcept { return m_index.value() > 0 ? 0 : -m_index.value(); }
|
// some compilers may fail to optimize std::max etc in case of compile-time constants...
|
||||||
EIGEN_DEVICE_FUNC constexpr Index colOffset() const noexcept { return m_index.value() > 0 ? m_index.value() : 0; }
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR
|
||||||
// trigger a compile-time error if someone try to call packet
|
Index absDiagIndex() const EIGEN_NOEXCEPT { return m_index.value()>0 ? m_index.value() : -m_index.value(); }
|
||||||
template <int LoadMode>
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR
|
||||||
typename MatrixType::PacketReturnType packet(Index) const;
|
Index rowOffset() const EIGEN_NOEXCEPT { return m_index.value()>0 ? 0 : -m_index.value(); }
|
||||||
template <int LoadMode>
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR
|
||||||
typename MatrixType::PacketReturnType packet(Index, Index) const;
|
Index colOffset() const EIGEN_NOEXCEPT { return m_index.value()>0 ? m_index.value() : 0; }
|
||||||
|
// trigger a compile-time error if someone try to call packet
|
||||||
|
template<int LoadMode> typename MatrixType::PacketReturnType packet(Index) const;
|
||||||
|
template<int LoadMode> typename MatrixType::PacketReturnType packet(Index,Index) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** \returns an expression of the main diagonal of the matrix \c *this
|
/** \returns an expression of the main diagonal of the matrix \c *this
|
||||||
*
|
*
|
||||||
* \c *this is not required to be square.
|
* \c *this is not required to be square.
|
||||||
*
|
*
|
||||||
* Example: \include MatrixBase_diagonal.cpp
|
* Example: \include MatrixBase_diagonal.cpp
|
||||||
* Output: \verbinclude MatrixBase_diagonal.out
|
* Output: \verbinclude MatrixBase_diagonal.out
|
||||||
*
|
*
|
||||||
* \sa class Diagonal */
|
* \sa class Diagonal */
|
||||||
template <typename Derived>
|
template<typename Derived>
|
||||||
EIGEN_DEVICE_FUNC constexpr typename MatrixBase<Derived>::DiagonalReturnType MatrixBase<Derived>::diagonal() {
|
EIGEN_DEVICE_FUNC inline typename MatrixBase<Derived>::DiagonalReturnType
|
||||||
|
MatrixBase<Derived>::diagonal()
|
||||||
|
{
|
||||||
return DiagonalReturnType(derived());
|
return DiagonalReturnType(derived());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This is the const version of diagonal(). */
|
/** This is the const version of diagonal(). */
|
||||||
template <typename Derived>
|
template<typename Derived>
|
||||||
EIGEN_DEVICE_FUNC constexpr const typename MatrixBase<Derived>::ConstDiagonalReturnType MatrixBase<Derived>::diagonal()
|
EIGEN_DEVICE_FUNC inline
|
||||||
const {
|
const typename MatrixBase<Derived>::ConstDiagonalReturnType
|
||||||
|
MatrixBase<Derived>::diagonal() const
|
||||||
|
{
|
||||||
return ConstDiagonalReturnType(derived());
|
return ConstDiagonalReturnType(derived());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \returns an expression of the \a DiagIndex-th sub or super diagonal of the matrix \c *this
|
/** \returns an expression of the \a DiagIndex-th sub or super diagonal of the matrix \c *this
|
||||||
*
|
*
|
||||||
* \c *this is not required to be square.
|
* \c *this is not required to be square.
|
||||||
*
|
*
|
||||||
* The template parameter \a DiagIndex represent a super diagonal if \a DiagIndex > 0
|
* The template parameter \a DiagIndex represent a super diagonal if \a DiagIndex > 0
|
||||||
* and a sub diagonal otherwise. \a DiagIndex == 0 is equivalent to the main diagonal.
|
* and a sub diagonal otherwise. \a DiagIndex == 0 is equivalent to the main diagonal.
|
||||||
*
|
*
|
||||||
* Example: \include MatrixBase_diagonal_int.cpp
|
* Example: \include MatrixBase_diagonal_int.cpp
|
||||||
* Output: \verbinclude MatrixBase_diagonal_int.out
|
* Output: \verbinclude MatrixBase_diagonal_int.out
|
||||||
*
|
*
|
||||||
* \sa MatrixBase::diagonal(), class Diagonal */
|
* \sa MatrixBase::diagonal(), class Diagonal */
|
||||||
template <typename Derived>
|
template<typename Derived>
|
||||||
EIGEN_DEVICE_FUNC constexpr Diagonal<Derived, DynamicIndex> MatrixBase<Derived>::diagonal(Index index) {
|
EIGEN_DEVICE_FUNC inline Diagonal<Derived, DynamicIndex>
|
||||||
|
MatrixBase<Derived>::diagonal(Index index)
|
||||||
|
{
|
||||||
return Diagonal<Derived, DynamicIndex>(derived(), index);
|
return Diagonal<Derived, DynamicIndex>(derived(), index);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This is the const version of diagonal(Index). */
|
/** This is the const version of diagonal(Index). */
|
||||||
template <typename Derived>
|
template<typename Derived>
|
||||||
EIGEN_DEVICE_FUNC constexpr const Diagonal<const Derived, DynamicIndex> MatrixBase<Derived>::diagonal(
|
EIGEN_DEVICE_FUNC inline const Diagonal<const Derived, DynamicIndex>
|
||||||
Index index) const {
|
MatrixBase<Derived>::diagonal(Index index) const
|
||||||
|
{
|
||||||
return Diagonal<const Derived, DynamicIndex>(derived(), index);
|
return Diagonal<const Derived, DynamicIndex>(derived(), index);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \returns an expression of the \a DiagIndex-th sub or super diagonal of the matrix \c *this
|
/** \returns an expression of the \a DiagIndex-th sub or super diagonal of the matrix \c *this
|
||||||
*
|
*
|
||||||
* \c *this is not required to be square.
|
* \c *this is not required to be square.
|
||||||
*
|
*
|
||||||
* The template parameter \a DiagIndex represent a super diagonal if \a DiagIndex > 0
|
* The template parameter \a DiagIndex represent a super diagonal if \a DiagIndex > 0
|
||||||
* and a sub diagonal otherwise. \a DiagIndex == 0 is equivalent to the main diagonal.
|
* and a sub diagonal otherwise. \a DiagIndex == 0 is equivalent to the main diagonal.
|
||||||
*
|
*
|
||||||
* Example: \include MatrixBase_diagonal_template_int.cpp
|
* Example: \include MatrixBase_diagonal_template_int.cpp
|
||||||
* Output: \verbinclude MatrixBase_diagonal_template_int.out
|
* Output: \verbinclude MatrixBase_diagonal_template_int.out
|
||||||
*
|
*
|
||||||
* \sa MatrixBase::diagonal(), class Diagonal */
|
* \sa MatrixBase::diagonal(), class Diagonal */
|
||||||
template <typename Derived>
|
template<typename Derived>
|
||||||
template <int Index_>
|
template<int Index_>
|
||||||
EIGEN_DEVICE_FUNC constexpr Diagonal<Derived, Index_> MatrixBase<Derived>::diagonal() {
|
EIGEN_DEVICE_FUNC
|
||||||
|
inline Diagonal<Derived, Index_>
|
||||||
|
MatrixBase<Derived>::diagonal()
|
||||||
|
{
|
||||||
return Diagonal<Derived, Index_>(derived());
|
return Diagonal<Derived, Index_>(derived());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This is the const version of diagonal<int>(). */
|
/** This is the const version of diagonal<int>(). */
|
||||||
template <typename Derived>
|
template<typename Derived>
|
||||||
template <int Index_>
|
template<int Index_>
|
||||||
EIGEN_DEVICE_FUNC constexpr const Diagonal<const Derived, Index_> MatrixBase<Derived>::diagonal() const {
|
EIGEN_DEVICE_FUNC
|
||||||
return Diagonal<const Derived, Index_>(derived());
|
inline const Diagonal<const Derived, Index_>
|
||||||
|
MatrixBase<Derived>::diagonal() const
|
||||||
|
{
|
||||||
|
return Diagonal<const Derived, Index_>(derived());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end namespace Eigen
|
} // end namespace Eigen
|
||||||
|
|
||||||
#endif // EIGEN_DIAGONAL_H
|
#endif // EIGEN_DIAGONAL_H
|
||||||
|
|||||||
@@ -11,300 +11,270 @@
|
|||||||
#ifndef EIGEN_DIAGONALMATRIX_H
|
#ifndef EIGEN_DIAGONALMATRIX_H
|
||||||
#define EIGEN_DIAGONALMATRIX_H
|
#define EIGEN_DIAGONALMATRIX_H
|
||||||
|
|
||||||
// IWYU pragma: private
|
namespace Eigen {
|
||||||
#include "./InternalHeaderCheck.h"
|
|
||||||
|
|
||||||
namespace Eigen {
|
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
||||||
|
template<typename Derived>
|
||||||
|
class DiagonalBase : public EigenBase<Derived>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef typename internal::traits<Derived>::DiagonalVectorType DiagonalVectorType;
|
||||||
|
typedef typename DiagonalVectorType::Scalar Scalar;
|
||||||
|
typedef typename DiagonalVectorType::RealScalar RealScalar;
|
||||||
|
typedef typename internal::traits<Derived>::StorageKind StorageKind;
|
||||||
|
typedef typename internal::traits<Derived>::StorageIndex StorageIndex;
|
||||||
|
|
||||||
/** \class DiagonalBase
|
enum {
|
||||||
* \ingroup Core_Module
|
RowsAtCompileTime = DiagonalVectorType::SizeAtCompileTime,
|
||||||
*
|
ColsAtCompileTime = DiagonalVectorType::SizeAtCompileTime,
|
||||||
* \brief Base class for diagonal matrices and expressions
|
MaxRowsAtCompileTime = DiagonalVectorType::MaxSizeAtCompileTime,
|
||||||
*
|
MaxColsAtCompileTime = DiagonalVectorType::MaxSizeAtCompileTime,
|
||||||
* This is the base class that is inherited by diagonal matrix and related expression
|
IsVectorAtCompileTime = 0,
|
||||||
* types, which internally use a vector for storing the diagonal entries. Diagonal
|
Flags = NoPreferredStorageOrderBit
|
||||||
* types always represent square matrices.
|
};
|
||||||
*
|
|
||||||
* \tparam Derived is the derived type, a DiagonalMatrix or DiagonalWrapper.
|
|
||||||
*
|
|
||||||
* \sa class DiagonalMatrix, class DiagonalWrapper
|
|
||||||
*/
|
|
||||||
template <typename Derived>
|
|
||||||
class DiagonalBase : public EigenBase<Derived> {
|
|
||||||
public:
|
|
||||||
typedef typename internal::traits<Derived>::DiagonalVectorType DiagonalVectorType;
|
|
||||||
typedef typename DiagonalVectorType::Scalar Scalar;
|
|
||||||
typedef typename DiagonalVectorType::RealScalar RealScalar;
|
|
||||||
typedef typename internal::traits<Derived>::StorageKind StorageKind;
|
|
||||||
typedef typename internal::traits<Derived>::StorageIndex StorageIndex;
|
|
||||||
|
|
||||||
enum {
|
typedef Matrix<Scalar, RowsAtCompileTime, ColsAtCompileTime, 0, MaxRowsAtCompileTime, MaxColsAtCompileTime> DenseMatrixType;
|
||||||
RowsAtCompileTime = DiagonalVectorType::SizeAtCompileTime,
|
typedef DenseMatrixType DenseType;
|
||||||
ColsAtCompileTime = DiagonalVectorType::SizeAtCompileTime,
|
typedef DiagonalMatrix<Scalar,DiagonalVectorType::SizeAtCompileTime,DiagonalVectorType::MaxSizeAtCompileTime> PlainObject;
|
||||||
MaxRowsAtCompileTime = DiagonalVectorType::MaxSizeAtCompileTime,
|
|
||||||
MaxColsAtCompileTime = DiagonalVectorType::MaxSizeAtCompileTime,
|
|
||||||
IsVectorAtCompileTime = 0,
|
|
||||||
Flags = NoPreferredStorageOrderBit
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef Matrix<Scalar, RowsAtCompileTime, ColsAtCompileTime, 0, MaxRowsAtCompileTime, MaxColsAtCompileTime>
|
EIGEN_DEVICE_FUNC
|
||||||
DenseMatrixType;
|
inline const Derived& derived() const { return *static_cast<const Derived*>(this); }
|
||||||
typedef DenseMatrixType DenseType;
|
EIGEN_DEVICE_FUNC
|
||||||
typedef DiagonalMatrix<Scalar, DiagonalVectorType::SizeAtCompileTime, DiagonalVectorType::MaxSizeAtCompileTime>
|
inline Derived& derived() { return *static_cast<Derived*>(this); }
|
||||||
PlainObject;
|
|
||||||
|
|
||||||
/** \returns a reference to the derived object. */
|
EIGEN_DEVICE_FUNC
|
||||||
EIGEN_DEVICE_FUNC inline const Derived& derived() const { return *static_cast<const Derived*>(this); }
|
DenseMatrixType toDenseMatrix() const { return derived(); }
|
||||||
/** \returns a const reference to the derived object. */
|
|
||||||
EIGEN_DEVICE_FUNC inline Derived& derived() { return *static_cast<Derived*>(this); }
|
|
||||||
|
|
||||||
/**
|
EIGEN_DEVICE_FUNC
|
||||||
* Constructs a dense matrix from \c *this. Note, this directly returns a dense matrix type,
|
inline const DiagonalVectorType& diagonal() const { return derived().diagonal(); }
|
||||||
* not an expression.
|
EIGEN_DEVICE_FUNC
|
||||||
* \returns A dense matrix, with its diagonal entries set from the derived object. */
|
inline DiagonalVectorType& diagonal() { return derived().diagonal(); }
|
||||||
EIGEN_DEVICE_FUNC DenseMatrixType toDenseMatrix() const { return derived(); }
|
|
||||||
|
|
||||||
/** \returns a reference to the derived object's vector of diagonal coefficients. */
|
EIGEN_DEVICE_FUNC
|
||||||
EIGEN_DEVICE_FUNC inline const DiagonalVectorType& diagonal() const { return derived().diagonal(); }
|
inline Index rows() const { return diagonal().size(); }
|
||||||
/** \returns a const reference to the derived object's vector of diagonal coefficients. */
|
EIGEN_DEVICE_FUNC
|
||||||
EIGEN_DEVICE_FUNC inline DiagonalVectorType& diagonal() { return derived().diagonal(); }
|
inline Index cols() const { return diagonal().size(); }
|
||||||
|
|
||||||
/** \returns the value of the coefficient as if \c *this was a dense matrix. */
|
template<typename MatrixDerived>
|
||||||
EIGEN_DEVICE_FUNC inline Scalar coeff(Index row, Index col) const {
|
EIGEN_DEVICE_FUNC
|
||||||
eigen_assert(row >= 0 && col >= 0 && row < rows() && col <= cols());
|
const Product<Derived,MatrixDerived,LazyProduct>
|
||||||
return row == col ? diagonal().coeff(row) : Scalar(0);
|
operator*(const MatrixBase<MatrixDerived> &matrix) const
|
||||||
}
|
{
|
||||||
|
return Product<Derived, MatrixDerived, LazyProduct>(derived(),matrix.derived());
|
||||||
|
}
|
||||||
|
|
||||||
/** \returns the number of rows. */
|
typedef DiagonalWrapper<const CwiseUnaryOp<internal::scalar_inverse_op<Scalar>, const DiagonalVectorType> > InverseReturnType;
|
||||||
EIGEN_DEVICE_FUNC constexpr Index rows() const { return diagonal().size(); }
|
EIGEN_DEVICE_FUNC
|
||||||
/** \returns the number of columns. */
|
inline const InverseReturnType
|
||||||
EIGEN_DEVICE_FUNC constexpr Index cols() const { return diagonal().size(); }
|
inverse() const
|
||||||
|
{
|
||||||
|
return InverseReturnType(diagonal().cwiseInverse());
|
||||||
|
}
|
||||||
|
|
||||||
|
EIGEN_DEVICE_FUNC
|
||||||
|
inline const DiagonalWrapper<const EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(DiagonalVectorType,Scalar,product) >
|
||||||
|
operator*(const Scalar& scalar) const
|
||||||
|
{
|
||||||
|
return DiagonalWrapper<const EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(DiagonalVectorType,Scalar,product) >(diagonal() * scalar);
|
||||||
|
}
|
||||||
|
EIGEN_DEVICE_FUNC
|
||||||
|
friend inline const DiagonalWrapper<const EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(Scalar,DiagonalVectorType,product) >
|
||||||
|
operator*(const Scalar& scalar, const DiagonalBase& other)
|
||||||
|
{
|
||||||
|
return DiagonalWrapper<const EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(Scalar,DiagonalVectorType,product) >(scalar * other.diagonal());
|
||||||
|
}
|
||||||
|
|
||||||
/** \returns the diagonal matrix product of \c *this by the dense matrix, \a matrix */
|
template<typename OtherDerived>
|
||||||
template <typename MatrixDerived>
|
EIGEN_DEVICE_FUNC
|
||||||
EIGEN_DEVICE_FUNC const Product<Derived, MatrixDerived, LazyProduct> operator*(
|
#ifdef EIGEN_PARSED_BY_DOXYGEN
|
||||||
const MatrixBase<MatrixDerived>& matrix) const {
|
inline unspecified_expression_type
|
||||||
return Product<Derived, MatrixDerived, LazyProduct>(derived(), matrix.derived());
|
#else
|
||||||
}
|
inline const DiagonalWrapper<const EIGEN_CWISE_BINARY_RETURN_TYPE(DiagonalVectorType,typename OtherDerived::DiagonalVectorType,sum) >
|
||||||
|
#endif
|
||||||
|
operator+(const DiagonalBase<OtherDerived>& other) const
|
||||||
|
{
|
||||||
|
return (diagonal() + other.diagonal()).asDiagonal();
|
||||||
|
}
|
||||||
|
|
||||||
template <typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
using DiagonalProductReturnType = DiagonalWrapper<const EIGEN_CWISE_BINARY_RETURN_TYPE(
|
EIGEN_DEVICE_FUNC
|
||||||
DiagonalVectorType, typename OtherDerived::DiagonalVectorType, product)>;
|
#ifdef EIGEN_PARSED_BY_DOXYGEN
|
||||||
|
inline unspecified_expression_type
|
||||||
/** \returns the diagonal matrix product of \c *this by the diagonal matrix \a other */
|
#else
|
||||||
template <typename OtherDerived>
|
inline const DiagonalWrapper<const EIGEN_CWISE_BINARY_RETURN_TYPE(DiagonalVectorType,typename OtherDerived::DiagonalVectorType,difference) >
|
||||||
EIGEN_DEVICE_FUNC const DiagonalProductReturnType<OtherDerived> operator*(
|
#endif
|
||||||
const DiagonalBase<OtherDerived>& other) const {
|
operator-(const DiagonalBase<OtherDerived>& other) const
|
||||||
return diagonal().cwiseProduct(other.diagonal()).asDiagonal();
|
{
|
||||||
}
|
return (diagonal() - other.diagonal()).asDiagonal();
|
||||||
|
}
|
||||||
using DiagonalInverseReturnType =
|
|
||||||
DiagonalWrapper<const CwiseUnaryOp<internal::scalar_inverse_op<Scalar>, const DiagonalVectorType>>;
|
|
||||||
|
|
||||||
/** \returns the inverse \c *this. Computed as the coefficient-wise inverse of the diagonal. */
|
|
||||||
EIGEN_DEVICE_FUNC inline const DiagonalInverseReturnType inverse() const {
|
|
||||||
return diagonal().cwiseInverse().asDiagonal();
|
|
||||||
}
|
|
||||||
|
|
||||||
using DiagonalScaleReturnType =
|
|
||||||
DiagonalWrapper<const EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(DiagonalVectorType, Scalar, product)>;
|
|
||||||
|
|
||||||
/** \returns the product of \c *this by the scalar \a scalar */
|
|
||||||
EIGEN_DEVICE_FUNC inline const DiagonalScaleReturnType operator*(const Scalar& scalar) const {
|
|
||||||
return (diagonal() * scalar).asDiagonal();
|
|
||||||
}
|
|
||||||
|
|
||||||
using ScaleDiagonalReturnType =
|
|
||||||
DiagonalWrapper<const EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(Scalar, DiagonalVectorType, product)>;
|
|
||||||
|
|
||||||
/** \returns the product of a scalar and the diagonal matrix \a other */
|
|
||||||
EIGEN_DEVICE_FUNC friend inline const ScaleDiagonalReturnType operator*(const Scalar& scalar,
|
|
||||||
const DiagonalBase& other) {
|
|
||||||
return (scalar * other.diagonal()).asDiagonal();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename OtherDerived>
|
|
||||||
using DiagonalSumReturnType = DiagonalWrapper<const EIGEN_CWISE_BINARY_RETURN_TYPE(
|
|
||||||
DiagonalVectorType, typename OtherDerived::DiagonalVectorType, sum)>;
|
|
||||||
|
|
||||||
/** \returns the sum of \c *this and the diagonal matrix \a other */
|
|
||||||
template <typename OtherDerived>
|
|
||||||
EIGEN_DEVICE_FUNC inline const DiagonalSumReturnType<OtherDerived> operator+(
|
|
||||||
const DiagonalBase<OtherDerived>& other) const {
|
|
||||||
return (diagonal() + other.diagonal()).asDiagonal();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename OtherDerived>
|
|
||||||
using DiagonalDifferenceReturnType = DiagonalWrapper<const EIGEN_CWISE_BINARY_RETURN_TYPE(
|
|
||||||
DiagonalVectorType, typename OtherDerived::DiagonalVectorType, difference)>;
|
|
||||||
|
|
||||||
/** \returns the difference of \c *this and the diagonal matrix \a other */
|
|
||||||
template <typename OtherDerived>
|
|
||||||
EIGEN_DEVICE_FUNC inline const DiagonalDifferenceReturnType<OtherDerived> operator-(
|
|
||||||
const DiagonalBase<OtherDerived>& other) const {
|
|
||||||
return (diagonal() - other.diagonal()).asDiagonal();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
/** \class DiagonalMatrix
|
/** \class DiagonalMatrix
|
||||||
* \ingroup Core_Module
|
* \ingroup Core_Module
|
||||||
*
|
*
|
||||||
* \brief Represents a diagonal matrix with its storage
|
* \brief Represents a diagonal matrix with its storage
|
||||||
*
|
*
|
||||||
* \tparam Scalar_ the type of coefficients
|
* \param _Scalar the type of coefficients
|
||||||
* \tparam SizeAtCompileTime the dimension of the matrix, or Dynamic
|
* \param SizeAtCompileTime the dimension of the matrix, or Dynamic
|
||||||
* \tparam MaxSizeAtCompileTime the dimension of the matrix, or Dynamic. This parameter is optional and defaults
|
* \param MaxSizeAtCompileTime the dimension of the matrix, or Dynamic. This parameter is optional and defaults
|
||||||
* to SizeAtCompileTime. Most of the time, you do not need to specify it.
|
* to SizeAtCompileTime. Most of the time, you do not need to specify it.
|
||||||
*
|
*
|
||||||
* \sa class DiagonalBase, class DiagonalWrapper
|
* \sa class DiagonalWrapper
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
template <typename Scalar_, int SizeAtCompileTime, int MaxSizeAtCompileTime>
|
template<typename _Scalar, int SizeAtCompileTime, int MaxSizeAtCompileTime>
|
||||||
struct traits<DiagonalMatrix<Scalar_, SizeAtCompileTime, MaxSizeAtCompileTime>>
|
struct traits<DiagonalMatrix<_Scalar,SizeAtCompileTime,MaxSizeAtCompileTime> >
|
||||||
: traits<Matrix<Scalar_, SizeAtCompileTime, SizeAtCompileTime, 0, MaxSizeAtCompileTime, MaxSizeAtCompileTime>> {
|
: traits<Matrix<_Scalar,SizeAtCompileTime,SizeAtCompileTime,0,MaxSizeAtCompileTime,MaxSizeAtCompileTime> >
|
||||||
typedef Matrix<Scalar_, SizeAtCompileTime, 1, 0, MaxSizeAtCompileTime, 1> DiagonalVectorType;
|
{
|
||||||
|
typedef Matrix<_Scalar,SizeAtCompileTime,1,0,MaxSizeAtCompileTime,1> DiagonalVectorType;
|
||||||
typedef DiagonalShape StorageKind;
|
typedef DiagonalShape StorageKind;
|
||||||
enum { Flags = LvalueBit | NoPreferredStorageOrderBit | NestByRefBit };
|
enum {
|
||||||
|
Flags = LvalueBit | NoPreferredStorageOrderBit
|
||||||
|
};
|
||||||
};
|
};
|
||||||
} // namespace internal
|
}
|
||||||
template <typename Scalar_, int SizeAtCompileTime, int MaxSizeAtCompileTime>
|
template<typename _Scalar, int SizeAtCompileTime, int MaxSizeAtCompileTime>
|
||||||
class DiagonalMatrix : public DiagonalBase<DiagonalMatrix<Scalar_, SizeAtCompileTime, MaxSizeAtCompileTime>> {
|
class DiagonalMatrix
|
||||||
public:
|
: public DiagonalBase<DiagonalMatrix<_Scalar,SizeAtCompileTime,MaxSizeAtCompileTime> >
|
||||||
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
{
|
||||||
typedef typename internal::traits<DiagonalMatrix>::DiagonalVectorType DiagonalVectorType;
|
public:
|
||||||
typedef const DiagonalMatrix& Nested;
|
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
||||||
typedef Scalar_ Scalar;
|
typedef typename internal::traits<DiagonalMatrix>::DiagonalVectorType DiagonalVectorType;
|
||||||
typedef typename internal::traits<DiagonalMatrix>::StorageKind StorageKind;
|
typedef const DiagonalMatrix& Nested;
|
||||||
typedef typename internal::traits<DiagonalMatrix>::StorageIndex StorageIndex;
|
typedef _Scalar Scalar;
|
||||||
#endif
|
typedef typename internal::traits<DiagonalMatrix>::StorageKind StorageKind;
|
||||||
|
typedef typename internal::traits<DiagonalMatrix>::StorageIndex StorageIndex;
|
||||||
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
DiagonalVectorType m_diagonal;
|
|
||||||
|
|
||||||
public:
|
DiagonalVectorType m_diagonal;
|
||||||
/** const version of diagonal(). */
|
|
||||||
EIGEN_DEVICE_FUNC constexpr inline const DiagonalVectorType& diagonal() const { return m_diagonal; }
|
|
||||||
/** \returns a reference to the stored vector of diagonal coefficients. */
|
|
||||||
EIGEN_DEVICE_FUNC constexpr inline DiagonalVectorType& diagonal() { return m_diagonal; }
|
|
||||||
|
|
||||||
/** Default constructor without initialization */
|
public:
|
||||||
EIGEN_DEVICE_FUNC constexpr inline DiagonalMatrix() {}
|
|
||||||
|
|
||||||
/** Constructs a diagonal matrix with given dimension */
|
/** const version of diagonal(). */
|
||||||
EIGEN_DEVICE_FUNC constexpr explicit inline DiagonalMatrix(Index dim) : m_diagonal(dim) {}
|
EIGEN_DEVICE_FUNC
|
||||||
|
inline const DiagonalVectorType& diagonal() const { return m_diagonal; }
|
||||||
|
/** \returns a reference to the stored vector of diagonal coefficients. */
|
||||||
|
EIGEN_DEVICE_FUNC
|
||||||
|
inline DiagonalVectorType& diagonal() { return m_diagonal; }
|
||||||
|
|
||||||
/** 2D constructor. */
|
/** Default constructor without initialization */
|
||||||
EIGEN_DEVICE_FUNC constexpr inline DiagonalMatrix(const Scalar& x, const Scalar& y) : m_diagonal(x, y) {}
|
EIGEN_DEVICE_FUNC
|
||||||
|
inline DiagonalMatrix() {}
|
||||||
|
|
||||||
/** 3D constructor. */
|
/** Constructs a diagonal matrix with given dimension */
|
||||||
EIGEN_DEVICE_FUNC constexpr inline DiagonalMatrix(const Scalar& x, const Scalar& y, const Scalar& z)
|
EIGEN_DEVICE_FUNC
|
||||||
: m_diagonal(x, y, z) {}
|
explicit inline DiagonalMatrix(Index dim) : m_diagonal(dim) {}
|
||||||
|
|
||||||
/** \brief Construct a diagonal matrix with fixed size from an arbitrary number of coefficients.
|
/** 2D constructor. */
|
||||||
*
|
EIGEN_DEVICE_FUNC
|
||||||
* \warning To construct a diagonal matrix of fixed size, the number of values passed to this
|
inline DiagonalMatrix(const Scalar& x, const Scalar& y) : m_diagonal(x,y) {}
|
||||||
* constructor must match the fixed dimension of \c *this.
|
|
||||||
*
|
/** 3D constructor. */
|
||||||
* \sa DiagonalMatrix(const Scalar&, const Scalar&)
|
EIGEN_DEVICE_FUNC
|
||||||
* \sa DiagonalMatrix(const Scalar&, const Scalar&, const Scalar&)
|
inline DiagonalMatrix(const Scalar& x, const Scalar& y, const Scalar& z) : m_diagonal(x,y,z) {}
|
||||||
*/
|
|
||||||
template <typename... ArgTypes>
|
#if EIGEN_HAS_CXX11
|
||||||
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE DiagonalMatrix(const Scalar& a0, const Scalar& a1, const Scalar& a2,
|
/** \brief Construct a diagonal matrix with fixed size from an arbitrary number of coefficients. \cpp11
|
||||||
const ArgTypes&... args)
|
*
|
||||||
|
* There exists C++98 anologue constructors for fixed-size diagonal matrices having 2 or 3 coefficients.
|
||||||
|
*
|
||||||
|
* \warning To construct a diagonal matrix of fixed size, the number of values passed to this
|
||||||
|
* constructor must match the fixed dimension of \c *this.
|
||||||
|
*
|
||||||
|
* \sa DiagonalMatrix(const Scalar&, const Scalar&)
|
||||||
|
* \sa DiagonalMatrix(const Scalar&, const Scalar&, const Scalar&)
|
||||||
|
*/
|
||||||
|
template <typename... ArgTypes>
|
||||||
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||||
|
DiagonalMatrix(const Scalar& a0, const Scalar& a1, const Scalar& a2, const ArgTypes&... args)
|
||||||
: m_diagonal(a0, a1, a2, args...) {}
|
: m_diagonal(a0, a1, a2, args...) {}
|
||||||
|
|
||||||
/** \brief Constructs a DiagonalMatrix and initializes it by elements given by an initializer list of initializer
|
/** \brief Constructs a DiagonalMatrix and initializes it by elements given by an initializer list of initializer
|
||||||
* lists \cpp11
|
* lists \cpp11
|
||||||
*/
|
*/
|
||||||
EIGEN_DEVICE_FUNC explicit EIGEN_STRONG_INLINE DiagonalMatrix(
|
EIGEN_DEVICE_FUNC
|
||||||
const std::initializer_list<std::initializer_list<Scalar>>& list)
|
explicit EIGEN_STRONG_INLINE DiagonalMatrix(const std::initializer_list<std::initializer_list<Scalar>>& list)
|
||||||
: m_diagonal(list) {}
|
: m_diagonal(list) {}
|
||||||
|
#endif // EIGEN_HAS_CXX11
|
||||||
|
|
||||||
/** \brief Constructs a DiagonalMatrix from an r-value diagonal vector type */
|
/** Copy constructor. */
|
||||||
EIGEN_DEVICE_FUNC constexpr explicit inline DiagonalMatrix(DiagonalVectorType&& diag) : m_diagonal(std::move(diag)) {}
|
template<typename OtherDerived>
|
||||||
|
EIGEN_DEVICE_FUNC
|
||||||
|
inline DiagonalMatrix(const DiagonalBase<OtherDerived>& other) : m_diagonal(other.diagonal()) {}
|
||||||
|
|
||||||
/** Copy constructor. */
|
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
||||||
template <typename OtherDerived>
|
/** copy constructor. prevent a default copy constructor from hiding the other templated constructor */
|
||||||
EIGEN_DEVICE_FUNC constexpr inline DiagonalMatrix(const DiagonalBase<OtherDerived>& other)
|
inline DiagonalMatrix(const DiagonalMatrix& other) : m_diagonal(other.diagonal()) {}
|
||||||
: m_diagonal(other.diagonal()) {}
|
#endif
|
||||||
|
|
||||||
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
/** generic constructor from expression of the diagonal coefficients */
|
||||||
/** copy constructor. prevent a default copy constructor from hiding the other templated constructor */
|
template<typename OtherDerived>
|
||||||
inline DiagonalMatrix(const DiagonalMatrix& other) : m_diagonal(other.diagonal()) {}
|
EIGEN_DEVICE_FUNC
|
||||||
#endif
|
explicit inline DiagonalMatrix(const MatrixBase<OtherDerived>& other) : m_diagonal(other)
|
||||||
|
{}
|
||||||
|
|
||||||
/** generic constructor from expression of the diagonal coefficients */
|
/** Copy operator. */
|
||||||
template <typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
EIGEN_DEVICE_FUNC constexpr explicit inline DiagonalMatrix(const MatrixBase<OtherDerived>& other)
|
EIGEN_DEVICE_FUNC
|
||||||
: m_diagonal(other) {}
|
DiagonalMatrix& operator=(const DiagonalBase<OtherDerived>& other)
|
||||||
|
{
|
||||||
|
m_diagonal = other.diagonal();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
/** Copy operator. */
|
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
||||||
template <typename OtherDerived>
|
/** This is a special case of the templated operator=. Its purpose is to
|
||||||
EIGEN_DEVICE_FUNC DiagonalMatrix& operator=(const DiagonalBase<OtherDerived>& other) {
|
* prevent a default operator= from hiding the templated operator=.
|
||||||
m_diagonal = other.diagonal();
|
*/
|
||||||
return *this;
|
EIGEN_DEVICE_FUNC
|
||||||
}
|
DiagonalMatrix& operator=(const DiagonalMatrix& other)
|
||||||
|
{
|
||||||
|
m_diagonal = other.diagonal();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
/** Resizes to given size. */
|
||||||
/** This is a special case of the templated operator=. Its purpose is to
|
EIGEN_DEVICE_FUNC
|
||||||
* prevent a default operator= from hiding the templated operator=.
|
inline void resize(Index size) { m_diagonal.resize(size); }
|
||||||
*/
|
/** Sets all coefficients to zero. */
|
||||||
EIGEN_DEVICE_FUNC DiagonalMatrix& operator=(const DiagonalMatrix& other) {
|
EIGEN_DEVICE_FUNC
|
||||||
m_diagonal = other.diagonal();
|
inline void setZero() { m_diagonal.setZero(); }
|
||||||
return *this;
|
/** Resizes and sets all coefficients to zero. */
|
||||||
}
|
EIGEN_DEVICE_FUNC
|
||||||
#endif
|
inline void setZero(Index size) { m_diagonal.setZero(size); }
|
||||||
|
/** Sets this matrix to be the identity matrix of the current size. */
|
||||||
typedef DiagonalWrapper<const CwiseNullaryOp<internal::scalar_constant_op<Scalar>, DiagonalVectorType>>
|
EIGEN_DEVICE_FUNC
|
||||||
InitializeReturnType;
|
inline void setIdentity() { m_diagonal.setOnes(); }
|
||||||
|
/** Sets this matrix to be the identity matrix of the given size. */
|
||||||
typedef DiagonalWrapper<const CwiseNullaryOp<internal::scalar_zero_op<Scalar>, DiagonalVectorType>>
|
EIGEN_DEVICE_FUNC
|
||||||
ZeroInitializeReturnType;
|
inline void setIdentity(Index size) { m_diagonal.setOnes(size); }
|
||||||
|
|
||||||
/** Initializes a diagonal matrix of size SizeAtCompileTime with coefficients set to zero */
|
|
||||||
EIGEN_DEVICE_FUNC static const ZeroInitializeReturnType Zero() { return DiagonalVectorType::Zero().asDiagonal(); }
|
|
||||||
/** Initializes a diagonal matrix of size dim with coefficients set to zero */
|
|
||||||
EIGEN_DEVICE_FUNC static const ZeroInitializeReturnType Zero(Index size) {
|
|
||||||
return DiagonalVectorType::Zero(size).asDiagonal();
|
|
||||||
}
|
|
||||||
/** Initializes a identity matrix of size SizeAtCompileTime */
|
|
||||||
EIGEN_DEVICE_FUNC static const InitializeReturnType Identity() { return DiagonalVectorType::Ones().asDiagonal(); }
|
|
||||||
/** Initializes a identity matrix of size dim */
|
|
||||||
EIGEN_DEVICE_FUNC static const InitializeReturnType Identity(Index size) {
|
|
||||||
return DiagonalVectorType::Ones(size).asDiagonal();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Resizes to given size. */
|
|
||||||
EIGEN_DEVICE_FUNC inline void resize(Index size) { m_diagonal.resize(size); }
|
|
||||||
/** Sets all coefficients to zero. */
|
|
||||||
EIGEN_DEVICE_FUNC inline void setZero() { m_diagonal.setZero(); }
|
|
||||||
/** Resizes and sets all coefficients to zero. */
|
|
||||||
EIGEN_DEVICE_FUNC inline void setZero(Index size) { m_diagonal.setZero(size); }
|
|
||||||
/** Sets this matrix to be the identity matrix of the current size. */
|
|
||||||
EIGEN_DEVICE_FUNC inline void setIdentity() { m_diagonal.setOnes(); }
|
|
||||||
/** Sets this matrix to be the identity matrix of the given size. */
|
|
||||||
EIGEN_DEVICE_FUNC inline void setIdentity(Index size) { m_diagonal.setOnes(size); }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/** \class DiagonalWrapper
|
/** \class DiagonalWrapper
|
||||||
* \ingroup Core_Module
|
* \ingroup Core_Module
|
||||||
*
|
*
|
||||||
* \brief Expression of a diagonal matrix
|
* \brief Expression of a diagonal matrix
|
||||||
*
|
*
|
||||||
* \tparam DiagonalVectorType_ the type of the vector of diagonal coefficients
|
* \param _DiagonalVectorType the type of the vector of diagonal coefficients
|
||||||
*
|
*
|
||||||
* This class is an expression of a diagonal matrix, but not storing its own vector of diagonal coefficients,
|
* This class is an expression of a diagonal matrix, but not storing its own vector of diagonal coefficients,
|
||||||
* instead wrapping an existing vector expression. It is the return type of MatrixBase::asDiagonal()
|
* instead wrapping an existing vector expression. It is the return type of MatrixBase::asDiagonal()
|
||||||
* and most of the time this is the only way that it is used.
|
* and most of the time this is the only way that it is used.
|
||||||
*
|
*
|
||||||
* \sa class DiagonalMatrix, class DiagonalBase, MatrixBase::asDiagonal()
|
* \sa class DiagonalMatrix, class DiagonalBase, MatrixBase::asDiagonal()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
template <typename DiagonalVectorType_>
|
template<typename _DiagonalVectorType>
|
||||||
struct traits<DiagonalWrapper<DiagonalVectorType_>> {
|
struct traits<DiagonalWrapper<_DiagonalVectorType> >
|
||||||
typedef DiagonalVectorType_ DiagonalVectorType;
|
{
|
||||||
|
typedef _DiagonalVectorType DiagonalVectorType;
|
||||||
typedef typename DiagonalVectorType::Scalar Scalar;
|
typedef typename DiagonalVectorType::Scalar Scalar;
|
||||||
typedef typename DiagonalVectorType::StorageIndex StorageIndex;
|
typedef typename DiagonalVectorType::StorageIndex StorageIndex;
|
||||||
typedef DiagonalShape StorageKind;
|
typedef DiagonalShape StorageKind;
|
||||||
@@ -314,160 +284,108 @@ struct traits<DiagonalWrapper<DiagonalVectorType_>> {
|
|||||||
ColsAtCompileTime = DiagonalVectorType::SizeAtCompileTime,
|
ColsAtCompileTime = DiagonalVectorType::SizeAtCompileTime,
|
||||||
MaxRowsAtCompileTime = DiagonalVectorType::MaxSizeAtCompileTime,
|
MaxRowsAtCompileTime = DiagonalVectorType::MaxSizeAtCompileTime,
|
||||||
MaxColsAtCompileTime = DiagonalVectorType::MaxSizeAtCompileTime,
|
MaxColsAtCompileTime = DiagonalVectorType::MaxSizeAtCompileTime,
|
||||||
Flags = (traits<DiagonalVectorType>::Flags & LvalueBit) | NoPreferredStorageOrderBit
|
Flags = (traits<DiagonalVectorType>::Flags & LvalueBit) | NoPreferredStorageOrderBit
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
} // namespace internal
|
}
|
||||||
|
|
||||||
template <typename DiagonalVectorType_>
|
template<typename _DiagonalVectorType>
|
||||||
class DiagonalWrapper : public DiagonalBase<DiagonalWrapper<DiagonalVectorType_>>, internal::no_assignment_operator {
|
class DiagonalWrapper
|
||||||
public:
|
: public DiagonalBase<DiagonalWrapper<_DiagonalVectorType> >, internal::no_assignment_operator
|
||||||
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
{
|
||||||
typedef DiagonalVectorType_ DiagonalVectorType;
|
public:
|
||||||
typedef DiagonalWrapper Nested;
|
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
||||||
#endif
|
typedef _DiagonalVectorType DiagonalVectorType;
|
||||||
|
typedef DiagonalWrapper Nested;
|
||||||
|
#endif
|
||||||
|
|
||||||
/** Constructor from expression of diagonal coefficients to wrap. */
|
/** Constructor from expression of diagonal coefficients to wrap. */
|
||||||
EIGEN_DEVICE_FUNC constexpr explicit inline DiagonalWrapper(DiagonalVectorType& a_diagonal)
|
EIGEN_DEVICE_FUNC
|
||||||
: m_diagonal(a_diagonal) {}
|
explicit inline DiagonalWrapper(DiagonalVectorType& a_diagonal) : m_diagonal(a_diagonal) {}
|
||||||
|
|
||||||
/** \returns a const reference to the wrapped expression of diagonal coefficients. */
|
/** \returns a const reference to the wrapped expression of diagonal coefficients. */
|
||||||
EIGEN_DEVICE_FUNC constexpr const DiagonalVectorType& diagonal() const { return m_diagonal; }
|
EIGEN_DEVICE_FUNC
|
||||||
|
const DiagonalVectorType& diagonal() const { return m_diagonal; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
typename DiagonalVectorType::Nested m_diagonal;
|
typename DiagonalVectorType::Nested m_diagonal;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** \returns a pseudo-expression of a diagonal matrix with *this as vector of diagonal coefficients
|
/** \returns a pseudo-expression of a diagonal matrix with *this as vector of diagonal coefficients
|
||||||
*
|
*
|
||||||
* \only_for_vectors
|
* \only_for_vectors
|
||||||
*
|
*
|
||||||
* Example: \include MatrixBase_asDiagonal.cpp
|
* Example: \include MatrixBase_asDiagonal.cpp
|
||||||
* Output: \verbinclude MatrixBase_asDiagonal.out
|
* Output: \verbinclude MatrixBase_asDiagonal.out
|
||||||
*
|
*
|
||||||
* \sa class DiagonalWrapper, class DiagonalMatrix, diagonal(), isDiagonal()
|
* \sa class DiagonalWrapper, class DiagonalMatrix, diagonal(), isDiagonal()
|
||||||
**/
|
**/
|
||||||
template <typename Derived>
|
template<typename Derived>
|
||||||
EIGEN_DEVICE_FUNC constexpr const DiagonalWrapper<const Derived> MatrixBase<Derived>::asDiagonal() const {
|
EIGEN_DEVICE_FUNC inline const DiagonalWrapper<const Derived>
|
||||||
|
MatrixBase<Derived>::asDiagonal() const
|
||||||
|
{
|
||||||
return DiagonalWrapper<const Derived>(derived());
|
return DiagonalWrapper<const Derived>(derived());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \returns true if *this is approximately equal to a diagonal matrix,
|
/** \returns true if *this is approximately equal to a diagonal matrix,
|
||||||
* within the precision given by \a prec.
|
* within the precision given by \a prec.
|
||||||
*
|
*
|
||||||
* Example: \include MatrixBase_isDiagonal.cpp
|
* Example: \include MatrixBase_isDiagonal.cpp
|
||||||
* Output: \verbinclude MatrixBase_isDiagonal.out
|
* Output: \verbinclude MatrixBase_isDiagonal.out
|
||||||
*
|
*
|
||||||
* \sa asDiagonal()
|
* \sa asDiagonal()
|
||||||
*/
|
*/
|
||||||
template <typename Derived>
|
template<typename Derived>
|
||||||
bool MatrixBase<Derived>::isDiagonal(const RealScalar& prec) const {
|
bool MatrixBase<Derived>::isDiagonal(const RealScalar& prec) const
|
||||||
if (cols() != rows()) return false;
|
{
|
||||||
|
if(cols() != rows()) return false;
|
||||||
RealScalar maxAbsOnDiagonal = static_cast<RealScalar>(-1);
|
RealScalar maxAbsOnDiagonal = static_cast<RealScalar>(-1);
|
||||||
for (Index j = 0; j < cols(); ++j) {
|
for(Index j = 0; j < cols(); ++j)
|
||||||
RealScalar absOnDiagonal = numext::abs(coeff(j, j));
|
{
|
||||||
if (absOnDiagonal > maxAbsOnDiagonal) maxAbsOnDiagonal = absOnDiagonal;
|
RealScalar absOnDiagonal = numext::abs(coeff(j,j));
|
||||||
|
if(absOnDiagonal > maxAbsOnDiagonal) maxAbsOnDiagonal = absOnDiagonal;
|
||||||
}
|
}
|
||||||
for (Index j = 0; j < cols(); ++j)
|
for(Index j = 0; j < cols(); ++j)
|
||||||
for (Index i = 0; i < j; ++i) {
|
for(Index i = 0; i < j; ++i)
|
||||||
if (!internal::isMuchSmallerThan(coeff(i, j), maxAbsOnDiagonal, prec)) return false;
|
{
|
||||||
if (!internal::isMuchSmallerThan(coeff(j, i), maxAbsOnDiagonal, prec)) return false;
|
if(!internal::isMuchSmallerThan(coeff(i, j), maxAbsOnDiagonal, prec)) return false;
|
||||||
|
if(!internal::isMuchSmallerThan(coeff(j, i), maxAbsOnDiagonal, prec)) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \returns DiagonalWrapper.
|
|
||||||
*
|
|
||||||
* Example: \include MatrixBase_diagonalView.cpp
|
|
||||||
* Output: \verbinclude MatrixBase_diagonalView.out
|
|
||||||
*
|
|
||||||
* \sa diagonalView()
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** This is the non-const version of diagonalView() with DiagIndex_ . */
|
|
||||||
template <typename Derived>
|
|
||||||
template <int DiagIndex_>
|
|
||||||
EIGEN_DEVICE_FUNC constexpr DiagonalWrapper<Diagonal<Derived, DiagIndex_>> MatrixBase<Derived>::diagonalView() {
|
|
||||||
typedef Diagonal<Derived, DiagIndex_> DiagType;
|
|
||||||
typedef DiagonalWrapper<DiagType> ReturnType;
|
|
||||||
DiagType diag(this->derived());
|
|
||||||
return ReturnType(diag);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** This is the const version of diagonalView() with DiagIndex_ . */
|
|
||||||
template <typename Derived>
|
|
||||||
template <int DiagIndex_>
|
|
||||||
EIGEN_DEVICE_FUNC constexpr DiagonalWrapper<Diagonal<const Derived, DiagIndex_>> MatrixBase<Derived>::diagonalView()
|
|
||||||
const {
|
|
||||||
typedef Diagonal<const Derived, DiagIndex_> DiagType;
|
|
||||||
typedef DiagonalWrapper<DiagType> ReturnType;
|
|
||||||
DiagType diag(this->derived());
|
|
||||||
return ReturnType(diag);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** This is the non-const version of diagonalView() with dynamic index. */
|
|
||||||
template <typename Derived>
|
|
||||||
EIGEN_DEVICE_FUNC constexpr DiagonalWrapper<Diagonal<Derived, DynamicIndex>> MatrixBase<Derived>::diagonalView(
|
|
||||||
Index index) {
|
|
||||||
typedef Diagonal<Derived, DynamicIndex> DiagType;
|
|
||||||
typedef DiagonalWrapper<DiagType> ReturnType;
|
|
||||||
DiagType diag(this->derived(), index);
|
|
||||||
return ReturnType(diag);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** This is the const version of diagonalView() with dynamic index. */
|
|
||||||
template <typename Derived>
|
|
||||||
EIGEN_DEVICE_FUNC constexpr DiagonalWrapper<Diagonal<const Derived, DynamicIndex>> MatrixBase<Derived>::diagonalView(
|
|
||||||
Index index) const {
|
|
||||||
typedef Diagonal<const Derived, DynamicIndex> DiagType;
|
|
||||||
typedef DiagonalWrapper<DiagType> ReturnType;
|
|
||||||
DiagType diag(this->derived(), index);
|
|
||||||
return ReturnType(diag);
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
template <>
|
template<> struct storage_kind_to_shape<DiagonalShape> { typedef DiagonalShape Shape; };
|
||||||
struct storage_kind_to_shape<DiagonalShape> {
|
|
||||||
typedef DiagonalShape Shape;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Diagonal2Dense {};
|
struct Diagonal2Dense {};
|
||||||
|
|
||||||
template <>
|
template<> struct AssignmentKind<DenseShape,DiagonalShape> { typedef Diagonal2Dense Kind; };
|
||||||
struct AssignmentKind<DenseShape, DiagonalShape> {
|
|
||||||
typedef Diagonal2Dense Kind;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Diagonal matrix to Dense assignment
|
// Diagonal matrix to Dense assignment
|
||||||
template <typename DstXprType, typename SrcXprType, typename Functor>
|
template< typename DstXprType, typename SrcXprType, typename Functor>
|
||||||
struct Assignment<DstXprType, SrcXprType, Functor, Diagonal2Dense> {
|
struct Assignment<DstXprType, SrcXprType, Functor, Diagonal2Dense>
|
||||||
static EIGEN_DEVICE_FUNC void run(
|
{
|
||||||
DstXprType& dst, const SrcXprType& src,
|
static void run(DstXprType &dst, const SrcXprType &src, const internal::assign_op<typename DstXprType::Scalar,typename SrcXprType::Scalar> &/*func*/)
|
||||||
const internal::assign_op<typename DstXprType::Scalar, typename SrcXprType::Scalar>& /*func*/) {
|
{
|
||||||
Index dstRows = src.rows();
|
Index dstRows = src.rows();
|
||||||
Index dstCols = src.cols();
|
Index dstCols = src.cols();
|
||||||
if ((dst.rows() != dstRows) || (dst.cols() != dstCols)) dst.resize(dstRows, dstCols);
|
if((dst.rows()!=dstRows) || (dst.cols()!=dstCols))
|
||||||
|
dst.resize(dstRows, dstCols);
|
||||||
|
|
||||||
dst.setZero();
|
dst.setZero();
|
||||||
dst.diagonal() = src.diagonal();
|
dst.diagonal() = src.diagonal();
|
||||||
}
|
}
|
||||||
|
|
||||||
static EIGEN_DEVICE_FUNC void run(
|
static void run(DstXprType &dst, const SrcXprType &src, const internal::add_assign_op<typename DstXprType::Scalar,typename SrcXprType::Scalar> &/*func*/)
|
||||||
DstXprType& dst, const SrcXprType& src,
|
{ dst.diagonal() += src.diagonal(); }
|
||||||
const internal::add_assign_op<typename DstXprType::Scalar, typename SrcXprType::Scalar>& /*func*/) {
|
|
||||||
dst.diagonal() += src.diagonal();
|
static void run(DstXprType &dst, const SrcXprType &src, const internal::sub_assign_op<typename DstXprType::Scalar,typename SrcXprType::Scalar> &/*func*/)
|
||||||
}
|
{ dst.diagonal() -= src.diagonal(); }
|
||||||
|
|
||||||
static EIGEN_DEVICE_FUNC void run(
|
|
||||||
DstXprType& dst, const SrcXprType& src,
|
|
||||||
const internal::sub_assign_op<typename DstXprType::Scalar, typename SrcXprType::Scalar>& /*func*/) {
|
|
||||||
dst.diagonal() -= src.diagonal();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
|
||||||
} // end namespace Eigen
|
} // end namespace Eigen
|
||||||
|
|
||||||
#endif // EIGEN_DIAGONALMATRIX_H
|
#endif // EIGEN_DIAGONALMATRIX_H
|
||||||
|
|||||||
@@ -11,20 +11,18 @@
|
|||||||
#ifndef EIGEN_DIAGONALPRODUCT_H
|
#ifndef EIGEN_DIAGONALPRODUCT_H
|
||||||
#define EIGEN_DIAGONALPRODUCT_H
|
#define EIGEN_DIAGONALPRODUCT_H
|
||||||
|
|
||||||
// IWYU pragma: private
|
namespace Eigen {
|
||||||
#include "./InternalHeaderCheck.h"
|
|
||||||
|
|
||||||
namespace Eigen {
|
|
||||||
|
|
||||||
/** \returns the diagonal matrix product of \c *this by the diagonal matrix \a diagonal.
|
/** \returns the diagonal matrix product of \c *this by the diagonal matrix \a diagonal.
|
||||||
*/
|
*/
|
||||||
template <typename Derived>
|
template<typename Derived>
|
||||||
template <typename DiagonalDerived>
|
template<typename DiagonalDerived>
|
||||||
EIGEN_DEVICE_FUNC inline const Product<Derived, DiagonalDerived, LazyProduct> MatrixBase<Derived>::operator*(
|
EIGEN_DEVICE_FUNC inline const Product<Derived, DiagonalDerived, LazyProduct>
|
||||||
const DiagonalBase<DiagonalDerived> &a_diagonal) const {
|
MatrixBase<Derived>::operator*(const DiagonalBase<DiagonalDerived> &a_diagonal) const
|
||||||
return Product<Derived, DiagonalDerived, LazyProduct>(derived(), a_diagonal.derived());
|
{
|
||||||
|
return Product<Derived, DiagonalDerived, LazyProduct>(derived(),a_diagonal.derived());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end namespace Eigen
|
} // end namespace Eigen
|
||||||
|
|
||||||
#endif // EIGEN_DIAGONALPRODUCT_H
|
#endif // EIGEN_DIAGONALPRODUCT_H
|
||||||
|
|||||||
@@ -10,258 +10,304 @@
|
|||||||
#ifndef EIGEN_DOT_H
|
#ifndef EIGEN_DOT_H
|
||||||
#define EIGEN_DOT_H
|
#define EIGEN_DOT_H
|
||||||
|
|
||||||
// IWYU pragma: private
|
namespace Eigen {
|
||||||
#include "./InternalHeaderCheck.h"
|
|
||||||
|
|
||||||
namespace Eigen {
|
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
template <typename Derived, typename Scalar = typename traits<Derived>::Scalar>
|
// helper function for dot(). The problem is that if we put that in the body of dot(), then upon calling dot
|
||||||
struct squared_norm_impl {
|
// with mismatched types, the compiler emits errors about failing to instantiate cwiseProduct BEFORE
|
||||||
using Real = typename NumTraits<Scalar>::Real;
|
// looking at the static assertions. Thus this is a trick to get better compile errors.
|
||||||
static EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Real run(const Derived& a) {
|
template<typename T, typename U,
|
||||||
return a.realView().cwiseAbs2().sum();
|
bool NeedToTranspose = T::IsVectorAtCompileTime && U::IsVectorAtCompileTime &&
|
||||||
|
((int(T::RowsAtCompileTime) == 1 && int(U::ColsAtCompileTime) == 1) ||
|
||||||
|
(int(T::ColsAtCompileTime) == 1 && int(U::RowsAtCompileTime) == 1))>
|
||||||
|
struct dot_nocheck
|
||||||
|
{
|
||||||
|
typedef scalar_conj_product_op<typename traits<T>::Scalar,typename traits<U>::Scalar> conj_prod;
|
||||||
|
typedef typename conj_prod::result_type ResScalar;
|
||||||
|
EIGEN_DEVICE_FUNC
|
||||||
|
EIGEN_STRONG_INLINE
|
||||||
|
static ResScalar run(const MatrixBase<T>& a, const MatrixBase<U>& b)
|
||||||
|
{
|
||||||
|
return a.template binaryExpr<conj_prod>(b).sum();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Derived>
|
template<typename T, typename U>
|
||||||
struct squared_norm_impl<Derived, bool> {
|
struct dot_nocheck<T, U, true>
|
||||||
static EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE bool run(const Derived& a) { return a.any(); }
|
{
|
||||||
|
typedef scalar_conj_product_op<typename traits<T>::Scalar,typename traits<U>::Scalar> conj_prod;
|
||||||
|
typedef typename conj_prod::result_type ResScalar;
|
||||||
|
EIGEN_DEVICE_FUNC
|
||||||
|
EIGEN_STRONG_INLINE
|
||||||
|
static ResScalar run(const MatrixBase<T>& a, const MatrixBase<U>& b)
|
||||||
|
{
|
||||||
|
return a.transpose().template binaryExpr<conj_prod>(b).sum();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace internal
|
} // end namespace internal
|
||||||
|
|
||||||
/** \fn MatrixBase::dot
|
/** \fn MatrixBase::dot
|
||||||
* \returns the dot product of *this with other.
|
* \returns the dot product of *this with other.
|
||||||
*
|
*
|
||||||
* \only_for_vectors
|
* \only_for_vectors
|
||||||
*
|
*
|
||||||
* \note If the scalar type is complex numbers, then this function returns the hermitian
|
* \note If the scalar type is complex numbers, then this function returns the hermitian
|
||||||
* (sesquilinear) dot product, conjugate-linear in the first variable and linear in the
|
* (sesquilinear) dot product, conjugate-linear in the first variable and linear in the
|
||||||
* second variable.
|
* second variable.
|
||||||
*
|
*
|
||||||
* \sa squaredNorm(), norm()
|
* \sa squaredNorm(), norm()
|
||||||
*/
|
*/
|
||||||
template <typename Derived>
|
template<typename Derived>
|
||||||
template <typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE
|
EIGEN_DEVICE_FUNC
|
||||||
typename ScalarBinaryOpTraits<typename internal::traits<Derived>::Scalar,
|
EIGEN_STRONG_INLINE
|
||||||
typename internal::traits<OtherDerived>::Scalar>::ReturnType
|
typename ScalarBinaryOpTraits<typename internal::traits<Derived>::Scalar,typename internal::traits<OtherDerived>::Scalar>::ReturnType
|
||||||
MatrixBase<Derived>::dot(const MatrixBase<OtherDerived>& other) const {
|
MatrixBase<Derived>::dot(const MatrixBase<OtherDerived>& other) const
|
||||||
return internal::dot_impl<Derived, OtherDerived>::run(derived(), other.derived());
|
{
|
||||||
|
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
|
||||||
|
EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
|
||||||
|
EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(Derived,OtherDerived)
|
||||||
|
#if !(defined(EIGEN_NO_STATIC_ASSERT) && defined(EIGEN_NO_DEBUG))
|
||||||
|
typedef internal::scalar_conj_product_op<Scalar,typename OtherDerived::Scalar> func;
|
||||||
|
EIGEN_CHECK_BINARY_COMPATIBILIY(func,Scalar,typename OtherDerived::Scalar);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
eigen_assert(size() == other.size());
|
||||||
|
|
||||||
|
return internal::dot_nocheck<Derived,OtherDerived>::run(*this, other);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------- implementation of L2 norm and related functions ----------
|
//---------- implementation of L2 norm and related functions ----------
|
||||||
|
|
||||||
/** \returns, for vectors, the squared \em l2 norm of \c *this, and for matrices the squared Frobenius norm.
|
/** \returns, for vectors, the squared \em l2 norm of \c *this, and for matrices the squared Frobenius norm.
|
||||||
* In both cases, it consists in the sum of the square of all the matrix entries.
|
* In both cases, it consists in the sum of the square of all the matrix entries.
|
||||||
* For vectors, this is also equal to the dot product of \c *this with itself.
|
* For vectors, this is also equals to the dot product of \c *this with itself.
|
||||||
*
|
*
|
||||||
* \sa dot(), norm(), lpNorm()
|
* \sa dot(), norm(), lpNorm()
|
||||||
*/
|
*/
|
||||||
template <typename Derived>
|
template<typename Derived>
|
||||||
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE typename NumTraits<typename internal::traits<Derived>::Scalar>::Real
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename NumTraits<typename internal::traits<Derived>::Scalar>::Real MatrixBase<Derived>::squaredNorm() const
|
||||||
MatrixBase<Derived>::squaredNorm() const {
|
{
|
||||||
return internal::squared_norm_impl<Derived>::run(derived());
|
return numext::real((*this).cwiseAbs2().sum());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \returns, for vectors, the \em l2 norm of \c *this, and for matrices the Frobenius norm.
|
/** \returns, for vectors, the \em l2 norm of \c *this, and for matrices the Frobenius norm.
|
||||||
* In both cases, it consists in the square root of the sum of the square of all the matrix entries.
|
* In both cases, it consists in the square root of the sum of the square of all the matrix entries.
|
||||||
* For vectors, this is also equal to the square root of the dot product of \c *this with itself.
|
* For vectors, this is also equals to the square root of the dot product of \c *this with itself.
|
||||||
*
|
*
|
||||||
* \sa lpNorm(), dot(), squaredNorm()
|
* \sa lpNorm(), dot(), squaredNorm()
|
||||||
*/
|
*/
|
||||||
template <typename Derived>
|
template<typename Derived>
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename NumTraits<typename internal::traits<Derived>::Scalar>::Real
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename NumTraits<typename internal::traits<Derived>::Scalar>::Real MatrixBase<Derived>::norm() const
|
||||||
MatrixBase<Derived>::norm() const {
|
{
|
||||||
return numext::sqrt(squaredNorm());
|
return numext::sqrt(squaredNorm());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \returns an expression of the quotient of \c *this by its own norm.
|
/** \returns an expression of the quotient of \c *this by its own norm.
|
||||||
*
|
*
|
||||||
* \warning If the input vector is too small (i.e., this->norm()==0),
|
* \warning If the input vector is too small (i.e., this->norm()==0),
|
||||||
* then this function returns a copy of the input.
|
* then this function returns a copy of the input.
|
||||||
*
|
*
|
||||||
* \only_for_vectors
|
* \only_for_vectors
|
||||||
*
|
*
|
||||||
* \sa norm(), normalize()
|
* \sa norm(), normalize()
|
||||||
*/
|
*/
|
||||||
template <typename Derived>
|
template<typename Derived>
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::PlainObject MatrixBase<Derived>::normalized()
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::PlainObject
|
||||||
const {
|
MatrixBase<Derived>::normalized() const
|
||||||
typedef typename internal::nested_eval<Derived, 2>::type Nested_;
|
{
|
||||||
Nested_ n(derived());
|
typedef typename internal::nested_eval<Derived,2>::type _Nested;
|
||||||
|
_Nested n(derived());
|
||||||
RealScalar z = n.squaredNorm();
|
RealScalar z = n.squaredNorm();
|
||||||
// NOTE: after extensive benchmarking, this conditional does not impact performance, at least on recent x86 CPU
|
// NOTE: after extensive benchmarking, this conditional does not impact performance, at least on recent x86 CPU
|
||||||
if (z > RealScalar(0))
|
if(z>RealScalar(0))
|
||||||
return n / numext::sqrt(z);
|
return n / numext::sqrt(z);
|
||||||
else
|
else
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Normalizes the vector, i.e. divides it by its own norm.
|
/** Normalizes the vector, i.e. divides it by its own norm.
|
||||||
*
|
*
|
||||||
* \only_for_vectors
|
* \only_for_vectors
|
||||||
*
|
*
|
||||||
* \warning If the input vector is too small (i.e., this->norm()==0), then \c *this is left unchanged.
|
* \warning If the input vector is too small (i.e., this->norm()==0), then \c *this is left unchanged.
|
||||||
*
|
*
|
||||||
* \sa norm(), normalized()
|
* \sa norm(), normalized()
|
||||||
*/
|
*/
|
||||||
template <typename Derived>
|
template<typename Derived>
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void MatrixBase<Derived>::normalize() {
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void MatrixBase<Derived>::normalize()
|
||||||
|
{
|
||||||
RealScalar z = squaredNorm();
|
RealScalar z = squaredNorm();
|
||||||
// NOTE: after extensive benchmarking, this conditional does not impact performance, at least on recent x86 CPU
|
// NOTE: after extensive benchmarking, this conditional does not impact performance, at least on recent x86 CPU
|
||||||
if (z > RealScalar(0)) derived() /= numext::sqrt(z);
|
if(z>RealScalar(0))
|
||||||
|
derived() /= numext::sqrt(z);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \returns an expression of the quotient of \c *this by its own norm while avoiding underflow and overflow.
|
/** \returns an expression of the quotient of \c *this by its own norm while avoiding underflow and overflow.
|
||||||
*
|
*
|
||||||
* \only_for_vectors
|
* \only_for_vectors
|
||||||
*
|
*
|
||||||
* This method is analogue to the normalized() method, but it reduces the risk of
|
* This method is analogue to the normalized() method, but it reduces the risk of
|
||||||
* underflow and overflow when computing the norm.
|
* underflow and overflow when computing the norm.
|
||||||
*
|
*
|
||||||
* \warning If the input vector is too small (i.e., this->norm()==0),
|
* \warning If the input vector is too small (i.e., this->norm()==0),
|
||||||
* then this function returns a copy of the input.
|
* then this function returns a copy of the input.
|
||||||
*
|
*
|
||||||
* \sa stableNorm(), stableNormalize(), normalized()
|
* \sa stableNorm(), stableNormalize(), normalized()
|
||||||
*/
|
*/
|
||||||
template <typename Derived>
|
template<typename Derived>
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::PlainObject
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::PlainObject
|
||||||
MatrixBase<Derived>::stableNormalized() const {
|
MatrixBase<Derived>::stableNormalized() const
|
||||||
typedef typename internal::nested_eval<Derived, 3>::type Nested_;
|
{
|
||||||
Nested_ n(derived());
|
typedef typename internal::nested_eval<Derived,3>::type _Nested;
|
||||||
|
_Nested n(derived());
|
||||||
RealScalar w = n.cwiseAbs().maxCoeff();
|
RealScalar w = n.cwiseAbs().maxCoeff();
|
||||||
RealScalar z = (n / w).squaredNorm();
|
RealScalar z = (n/w).squaredNorm();
|
||||||
if (z > RealScalar(0))
|
if(z>RealScalar(0))
|
||||||
return n / (numext::sqrt(z) * w);
|
return n / (numext::sqrt(z)*w);
|
||||||
else
|
else
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Normalizes the vector while avoid underflow and overflow
|
/** Normalizes the vector while avoid underflow and overflow
|
||||||
*
|
*
|
||||||
* \only_for_vectors
|
* \only_for_vectors
|
||||||
*
|
*
|
||||||
* This method is analogue to the normalize() method, but it reduces the risk of
|
* This method is analogue to the normalize() method, but it reduces the risk of
|
||||||
* underflow and overflow when computing the norm.
|
* underflow and overflow when computing the norm.
|
||||||
*
|
*
|
||||||
* \warning If the input vector is too small (i.e., this->norm()==0), then \c *this is left unchanged.
|
* \warning If the input vector is too small (i.e., this->norm()==0), then \c *this is left unchanged.
|
||||||
*
|
*
|
||||||
* \sa stableNorm(), stableNormalized(), normalize()
|
* \sa stableNorm(), stableNormalized(), normalize()
|
||||||
*/
|
*/
|
||||||
template <typename Derived>
|
template<typename Derived>
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void MatrixBase<Derived>::stableNormalize() {
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void MatrixBase<Derived>::stableNormalize()
|
||||||
|
{
|
||||||
RealScalar w = cwiseAbs().maxCoeff();
|
RealScalar w = cwiseAbs().maxCoeff();
|
||||||
RealScalar z = (derived() / w).squaredNorm();
|
RealScalar z = (derived()/w).squaredNorm();
|
||||||
if (z > RealScalar(0)) derived() /= numext::sqrt(z) * w;
|
if(z>RealScalar(0))
|
||||||
|
derived() /= numext::sqrt(z)*w;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------- implementation of other norms ----------
|
//---------- implementation of other norms ----------
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
template <typename Derived, int p>
|
template<typename Derived, int p>
|
||||||
struct lpNorm_selector {
|
struct lpNorm_selector
|
||||||
|
{
|
||||||
typedef typename NumTraits<typename traits<Derived>::Scalar>::Real RealScalar;
|
typedef typename NumTraits<typename traits<Derived>::Scalar>::Real RealScalar;
|
||||||
EIGEN_DEVICE_FUNC static inline RealScalar run(const MatrixBase<Derived>& m) {
|
EIGEN_DEVICE_FUNC
|
||||||
|
static inline RealScalar run(const MatrixBase<Derived>& m)
|
||||||
|
{
|
||||||
EIGEN_USING_STD(pow)
|
EIGEN_USING_STD(pow)
|
||||||
return pow(m.cwiseAbs().array().pow(p).sum(), RealScalar(1) / p);
|
return pow(m.cwiseAbs().array().pow(p).sum(), RealScalar(1)/p);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Derived>
|
template<typename Derived>
|
||||||
struct lpNorm_selector<Derived, 1> {
|
struct lpNorm_selector<Derived, 1>
|
||||||
EIGEN_DEVICE_FUNC static inline typename NumTraits<typename traits<Derived>::Scalar>::Real run(
|
{
|
||||||
const MatrixBase<Derived>& m) {
|
EIGEN_DEVICE_FUNC
|
||||||
|
static inline typename NumTraits<typename traits<Derived>::Scalar>::Real run(const MatrixBase<Derived>& m)
|
||||||
|
{
|
||||||
return m.cwiseAbs().sum();
|
return m.cwiseAbs().sum();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Derived>
|
template<typename Derived>
|
||||||
struct lpNorm_selector<Derived, 2> {
|
struct lpNorm_selector<Derived, 2>
|
||||||
EIGEN_DEVICE_FUNC static inline typename NumTraits<typename traits<Derived>::Scalar>::Real run(
|
{
|
||||||
const MatrixBase<Derived>& m) {
|
EIGEN_DEVICE_FUNC
|
||||||
|
static inline typename NumTraits<typename traits<Derived>::Scalar>::Real run(const MatrixBase<Derived>& m)
|
||||||
|
{
|
||||||
return m.norm();
|
return m.norm();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Derived>
|
template<typename Derived>
|
||||||
struct lpNorm_selector<Derived, Infinity> {
|
struct lpNorm_selector<Derived, Infinity>
|
||||||
|
{
|
||||||
typedef typename NumTraits<typename traits<Derived>::Scalar>::Real RealScalar;
|
typedef typename NumTraits<typename traits<Derived>::Scalar>::Real RealScalar;
|
||||||
EIGEN_DEVICE_FUNC static inline RealScalar run(const MatrixBase<Derived>& m) {
|
EIGEN_DEVICE_FUNC
|
||||||
if (Derived::SizeAtCompileTime == 0 || (Derived::SizeAtCompileTime == Dynamic && m.size() == 0))
|
static inline RealScalar run(const MatrixBase<Derived>& m)
|
||||||
|
{
|
||||||
|
if(Derived::SizeAtCompileTime==0 || (Derived::SizeAtCompileTime==Dynamic && m.size()==0))
|
||||||
return RealScalar(0);
|
return RealScalar(0);
|
||||||
return m.cwiseAbs().maxCoeff();
|
return m.cwiseAbs().maxCoeff();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace internal
|
} // end namespace internal
|
||||||
|
|
||||||
/** \returns the \b coefficient-wise \f$ \ell^p \f$ norm of \c *this, that is, returns the p-th root of the sum of the
|
/** \returns the \b coefficient-wise \f$ \ell^p \f$ norm of \c *this, that is, returns the p-th root of the sum of the p-th powers of the absolute values
|
||||||
* p-th powers of the absolute values of the coefficients of \c *this. If \a p is the special value \a Eigen::Infinity,
|
* of the coefficients of \c *this. If \a p is the special value \a Eigen::Infinity, this function returns the \f$ \ell^\infty \f$
|
||||||
* this function returns the \f$ \ell^\infty \f$ norm, that is the maximum of the absolute values of the coefficients of
|
* norm, that is the maximum of the absolute values of the coefficients of \c *this.
|
||||||
* \c *this.
|
*
|
||||||
*
|
* In all cases, if \c *this is empty, then the value 0 is returned.
|
||||||
* In all cases, if \c *this is empty, then the value 0 is returned.
|
*
|
||||||
*
|
* \note For matrices, this function does not compute the <a href="https://en.wikipedia.org/wiki/Operator_norm">operator-norm</a>. That is, if \c *this is a matrix, then its coefficients are interpreted as a 1D vector. Nonetheless, you can easily compute the 1-norm and \f$\infty\f$-norm matrix operator norms using \link TutorialReductionsVisitorsBroadcastingReductionsNorm partial reductions \endlink.
|
||||||
* \note For matrices, this function does not compute the <a
|
*
|
||||||
* href="https://en.wikipedia.org/wiki/Operator_norm">operator-norm</a>. That is, if \c *this is a matrix, then its
|
* \sa norm()
|
||||||
* coefficients are interpreted as a 1D vector. Nonetheless, you can easily compute the 1-norm and \f$\infty\f$-norm
|
*/
|
||||||
* matrix operator norms using \link TutorialReductionsVisitorsBroadcastingReductionsNorm partial reductions \endlink.
|
template<typename Derived>
|
||||||
*
|
template<int p>
|
||||||
* \sa norm()
|
|
||||||
*/
|
|
||||||
template <typename Derived>
|
|
||||||
template <int p>
|
|
||||||
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
||||||
EIGEN_DEVICE_FUNC inline typename NumTraits<typename internal::traits<Derived>::Scalar>::Real
|
EIGEN_DEVICE_FUNC inline typename NumTraits<typename internal::traits<Derived>::Scalar>::Real
|
||||||
#else
|
#else
|
||||||
EIGEN_DEVICE_FUNC MatrixBase<Derived>::RealScalar
|
EIGEN_DEVICE_FUNC MatrixBase<Derived>::RealScalar
|
||||||
#endif
|
#endif
|
||||||
MatrixBase<Derived>::lpNorm() const {
|
MatrixBase<Derived>::lpNorm() const
|
||||||
|
{
|
||||||
return internal::lpNorm_selector<Derived, p>::run(*this);
|
return internal::lpNorm_selector<Derived, p>::run(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------- implementation of isOrthogonal / isUnitary ----------
|
//---------- implementation of isOrthogonal / isUnitary ----------
|
||||||
|
|
||||||
/** \returns true if *this is approximately orthogonal to \a other,
|
/** \returns true if *this is approximately orthogonal to \a other,
|
||||||
* within the precision given by \a prec.
|
* within the precision given by \a prec.
|
||||||
*
|
*
|
||||||
* Example: \include MatrixBase_isOrthogonal.cpp
|
* Example: \include MatrixBase_isOrthogonal.cpp
|
||||||
* Output: \verbinclude MatrixBase_isOrthogonal.out
|
* Output: \verbinclude MatrixBase_isOrthogonal.out
|
||||||
*/
|
*/
|
||||||
template <typename Derived>
|
template<typename Derived>
|
||||||
template <typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
bool MatrixBase<Derived>::isOrthogonal(const MatrixBase<OtherDerived>& other, const RealScalar& prec) const {
|
bool MatrixBase<Derived>::isOrthogonal
|
||||||
typename internal::nested_eval<Derived, 2>::type nested(derived());
|
(const MatrixBase<OtherDerived>& other, const RealScalar& prec) const
|
||||||
typename internal::nested_eval<OtherDerived, 2>::type otherNested(other.derived());
|
{
|
||||||
|
typename internal::nested_eval<Derived,2>::type nested(derived());
|
||||||
|
typename internal::nested_eval<OtherDerived,2>::type otherNested(other.derived());
|
||||||
return numext::abs2(nested.dot(otherNested)) <= prec * prec * nested.squaredNorm() * otherNested.squaredNorm();
|
return numext::abs2(nested.dot(otherNested)) <= prec * prec * nested.squaredNorm() * otherNested.squaredNorm();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \returns true if *this is approximately an unitary matrix,
|
/** \returns true if *this is approximately an unitary matrix,
|
||||||
* within the precision given by \a prec. In the case where the \a Scalar
|
* within the precision given by \a prec. In the case where the \a Scalar
|
||||||
* type is real numbers, a unitary matrix is an orthogonal matrix, whence the name.
|
* type is real numbers, a unitary matrix is an orthogonal matrix, whence the name.
|
||||||
*
|
*
|
||||||
* \note This can be used to check whether a family of vectors forms an orthonormal basis.
|
* \note This can be used to check whether a family of vectors forms an orthonormal basis.
|
||||||
* Indeed, \c m.isUnitary() returns true if and only if the columns (equivalently, the rows) of m form an
|
* Indeed, \c m.isUnitary() returns true if and only if the columns (equivalently, the rows) of m form an
|
||||||
* orthonormal basis.
|
* orthonormal basis.
|
||||||
*
|
*
|
||||||
* Example: \include MatrixBase_isUnitary.cpp
|
* Example: \include MatrixBase_isUnitary.cpp
|
||||||
* Output: \verbinclude MatrixBase_isUnitary.out
|
* Output: \verbinclude MatrixBase_isUnitary.out
|
||||||
*/
|
*/
|
||||||
template <typename Derived>
|
template<typename Derived>
|
||||||
bool MatrixBase<Derived>::isUnitary(const RealScalar& prec) const {
|
bool MatrixBase<Derived>::isUnitary(const RealScalar& prec) const
|
||||||
typename internal::nested_eval<Derived, 1>::type self(derived());
|
{
|
||||||
for (Index i = 0; i < cols(); ++i) {
|
typename internal::nested_eval<Derived,1>::type self(derived());
|
||||||
if (!internal::isApprox(self.col(i).squaredNorm(), static_cast<RealScalar>(1), prec)) return false;
|
for(Index i = 0; i < cols(); ++i)
|
||||||
for (Index j = 0; j < i; ++j)
|
{
|
||||||
if (!internal::isMuchSmallerThan(self.col(i).dot(self.col(j)), static_cast<Scalar>(1), prec)) return false;
|
if(!internal::isApprox(self.col(i).squaredNorm(), static_cast<RealScalar>(1), prec))
|
||||||
|
return false;
|
||||||
|
for(Index j = 0; j < i; ++j)
|
||||||
|
if(!internal::isMuchSmallerThan(self.col(i).dot(self.col(j)), static_cast<Scalar>(1), prec))
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end namespace Eigen
|
} // end namespace Eigen
|
||||||
|
|
||||||
#endif // EIGEN_DOT_H
|
#endif // EIGEN_DOT_H
|
||||||
|
|||||||
@@ -11,139 +11,150 @@
|
|||||||
#ifndef EIGEN_EIGENBASE_H
|
#ifndef EIGEN_EIGENBASE_H
|
||||||
#define EIGEN_EIGENBASE_H
|
#define EIGEN_EIGENBASE_H
|
||||||
|
|
||||||
// IWYU pragma: private
|
|
||||||
#include "./InternalHeaderCheck.h"
|
|
||||||
|
|
||||||
namespace Eigen {
|
namespace Eigen {
|
||||||
|
|
||||||
/** \class EigenBase
|
/** \class EigenBase
|
||||||
* \ingroup Core_Module
|
* \ingroup Core_Module
|
||||||
*
|
*
|
||||||
* Common base class for all classes T such that MatrixBase has an operator=(T) and a constructor MatrixBase(T).
|
* Common base class for all classes T such that MatrixBase has an operator=(T) and a constructor MatrixBase(T).
|
||||||
*
|
*
|
||||||
* In other words, an EigenBase object is an object that can be copied into a MatrixBase.
|
* In other words, an EigenBase object is an object that can be copied into a MatrixBase.
|
||||||
*
|
*
|
||||||
* Besides MatrixBase-derived classes, this also includes special matrix classes such as diagonal matrices, etc.
|
* Besides MatrixBase-derived classes, this also includes special matrix classes such as diagonal matrices, etc.
|
||||||
*
|
*
|
||||||
* Notice that this class is trivial, it is only used to disambiguate overloaded functions.
|
* Notice that this class is trivial, it is only used to disambiguate overloaded functions.
|
||||||
*
|
*
|
||||||
* \sa \blank \ref TopicClassHierarchy
|
* \sa \blank \ref TopicClassHierarchy
|
||||||
*/
|
*/
|
||||||
template <typename Derived>
|
template<typename Derived> struct EigenBase
|
||||||
struct EigenBase {
|
{
|
||||||
// typedef typename internal::plain_matrix_type<Derived>::type PlainObject;
|
// typedef typename internal::plain_matrix_type<Derived>::type PlainObject;
|
||||||
|
|
||||||
/** \brief The interface type of indices
|
/** \brief The interface type of indices
|
||||||
* \details To change this, \c \#define the preprocessor symbol \c EIGEN_DEFAULT_DENSE_INDEX_TYPE.
|
* \details To change this, \c \#define the preprocessor symbol \c EIGEN_DEFAULT_DENSE_INDEX_TYPE.
|
||||||
* \sa StorageIndex, \ref TopicPreprocessorDirectives.
|
* \sa StorageIndex, \ref TopicPreprocessorDirectives.
|
||||||
* DEPRECATED: Since Eigen 3.3, its usage is deprecated. Use Eigen::Index instead.
|
* DEPRECATED: Since Eigen 3.3, its usage is deprecated. Use Eigen::Index instead.
|
||||||
* Deprecation is not marked with a doxygen comment because there are too many existing usages to add the deprecation
|
* Deprecation is not marked with a doxygen comment because there are too many existing usages to add the deprecation attribute.
|
||||||
* attribute.
|
*/
|
||||||
*/
|
|
||||||
typedef Eigen::Index Index;
|
typedef Eigen::Index Index;
|
||||||
|
|
||||||
// FIXME is it needed?
|
// FIXME is it needed?
|
||||||
typedef typename internal::traits<Derived>::StorageKind StorageKind;
|
typedef typename internal::traits<Derived>::StorageKind StorageKind;
|
||||||
|
|
||||||
/** \returns a reference to the derived object */
|
/** \returns a reference to the derived object */
|
||||||
EIGEN_DEVICE_FUNC constexpr Derived& derived() { return *static_cast<Derived*>(this); }
|
EIGEN_DEVICE_FUNC
|
||||||
|
Derived& derived() { return *static_cast<Derived*>(this); }
|
||||||
/** \returns a const reference to the derived object */
|
/** \returns a const reference to the derived object */
|
||||||
EIGEN_DEVICE_FUNC constexpr const Derived& derived() const { return *static_cast<const Derived*>(this); }
|
EIGEN_DEVICE_FUNC
|
||||||
|
const Derived& derived() const { return *static_cast<const Derived*>(this); }
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC inline constexpr Derived& const_cast_derived() const {
|
EIGEN_DEVICE_FUNC
|
||||||
return *static_cast<Derived*>(const_cast<EigenBase*>(this));
|
inline Derived& const_cast_derived() const
|
||||||
}
|
{ return *static_cast<Derived*>(const_cast<EigenBase*>(this)); }
|
||||||
EIGEN_DEVICE_FUNC constexpr inline const Derived& const_derived() const { return *static_cast<const Derived*>(this); }
|
EIGEN_DEVICE_FUNC
|
||||||
|
inline const Derived& const_derived() const
|
||||||
|
{ return *static_cast<const Derived*>(this); }
|
||||||
|
|
||||||
/** \returns the number of rows. \sa cols(), RowsAtCompileTime */
|
/** \returns the number of rows. \sa cols(), RowsAtCompileTime */
|
||||||
EIGEN_DEVICE_FUNC constexpr Index rows() const noexcept { return derived().rows(); }
|
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
|
||||||
|
inline Index rows() const EIGEN_NOEXCEPT { return derived().rows(); }
|
||||||
/** \returns the number of columns. \sa rows(), ColsAtCompileTime*/
|
/** \returns the number of columns. \sa rows(), ColsAtCompileTime*/
|
||||||
EIGEN_DEVICE_FUNC constexpr Index cols() const noexcept { return derived().cols(); }
|
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
|
||||||
|
inline Index cols() const EIGEN_NOEXCEPT { return derived().cols(); }
|
||||||
/** \returns the number of coefficients, which is rows()*cols().
|
/** \returns the number of coefficients, which is rows()*cols().
|
||||||
* \sa rows(), cols(), SizeAtCompileTime. */
|
* \sa rows(), cols(), SizeAtCompileTime. */
|
||||||
EIGEN_DEVICE_FUNC constexpr Index size() const noexcept { return rows() * cols(); }
|
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
|
||||||
|
inline Index size() const EIGEN_NOEXCEPT { return rows() * cols(); }
|
||||||
|
|
||||||
/** \internal Don't use it, but do the equivalent: \code dst = *this; \endcode */
|
/** \internal Don't use it, but do the equivalent: \code dst = *this; \endcode */
|
||||||
template <typename Dest>
|
template<typename Dest>
|
||||||
EIGEN_DEVICE_FUNC constexpr inline void evalTo(Dest& dst) const {
|
EIGEN_DEVICE_FUNC
|
||||||
derived().evalTo(dst);
|
inline void evalTo(Dest& dst) const
|
||||||
}
|
{ derived().evalTo(dst); }
|
||||||
|
|
||||||
/** \internal Don't use it, but do the equivalent: \code dst += *this; \endcode */
|
/** \internal Don't use it, but do the equivalent: \code dst += *this; \endcode */
|
||||||
template <typename Dest>
|
template<typename Dest>
|
||||||
EIGEN_DEVICE_FUNC constexpr inline void addTo(Dest& dst) const {
|
EIGEN_DEVICE_FUNC
|
||||||
|
inline void addTo(Dest& dst) const
|
||||||
|
{
|
||||||
// This is the default implementation,
|
// This is the default implementation,
|
||||||
// derived class can reimplement it in a more optimized way.
|
// derived class can reimplement it in a more optimized way.
|
||||||
typename Dest::PlainObject res(rows(), cols());
|
typename Dest::PlainObject res(rows(),cols());
|
||||||
evalTo(res);
|
evalTo(res);
|
||||||
dst += res;
|
dst += res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \internal Don't use it, but do the equivalent: \code dst -= *this; \endcode */
|
/** \internal Don't use it, but do the equivalent: \code dst -= *this; \endcode */
|
||||||
template <typename Dest>
|
template<typename Dest>
|
||||||
EIGEN_DEVICE_FUNC constexpr inline void subTo(Dest& dst) const {
|
EIGEN_DEVICE_FUNC
|
||||||
|
inline void subTo(Dest& dst) const
|
||||||
|
{
|
||||||
// This is the default implementation,
|
// This is the default implementation,
|
||||||
// derived class can reimplement it in a more optimized way.
|
// derived class can reimplement it in a more optimized way.
|
||||||
typename Dest::PlainObject res(rows(), cols());
|
typename Dest::PlainObject res(rows(),cols());
|
||||||
evalTo(res);
|
evalTo(res);
|
||||||
dst -= res;
|
dst -= res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \internal Don't use it, but do the equivalent: \code dst.applyOnTheRight(*this); \endcode */
|
/** \internal Don't use it, but do the equivalent: \code dst.applyOnTheRight(*this); \endcode */
|
||||||
template <typename Dest>
|
template<typename Dest>
|
||||||
EIGEN_DEVICE_FUNC constexpr inline void applyThisOnTheRight(Dest& dst) const {
|
EIGEN_DEVICE_FUNC inline void applyThisOnTheRight(Dest& dst) const
|
||||||
|
{
|
||||||
// This is the default implementation,
|
// This is the default implementation,
|
||||||
// derived class can reimplement it in a more optimized way.
|
// derived class can reimplement it in a more optimized way.
|
||||||
dst = dst * this->derived();
|
dst = dst * this->derived();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \internal Don't use it, but do the equivalent: \code dst.applyOnTheLeft(*this); \endcode */
|
/** \internal Don't use it, but do the equivalent: \code dst.applyOnTheLeft(*this); \endcode */
|
||||||
template <typename Dest>
|
template<typename Dest>
|
||||||
EIGEN_DEVICE_FUNC constexpr inline void applyThisOnTheLeft(Dest& dst) const {
|
EIGEN_DEVICE_FUNC inline void applyThisOnTheLeft(Dest& dst) const
|
||||||
|
{
|
||||||
// This is the default implementation,
|
// This is the default implementation,
|
||||||
// derived class can reimplement it in a more optimized way.
|
// derived class can reimplement it in a more optimized way.
|
||||||
dst = this->derived() * dst;
|
dst = this->derived() * dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Device>
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DeviceWrapper<Derived, Device> device(Device& device);
|
|
||||||
template <typename Device>
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DeviceWrapper<const Derived, Device> device(Device& device) const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* Implementation of matrix base methods
|
* Implementation of matrix base methods
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
/** \brief Copies the generic expression \a other into *this.
|
/** \brief Copies the generic expression \a other into *this.
|
||||||
*
|
*
|
||||||
* \details The expression must provide a (templated) evalTo(Derived& dst) const
|
* \details The expression must provide a (templated) evalTo(Derived& dst) const
|
||||||
* function which does the actual job. In practice, this allows any user to write
|
* function which does the actual job. In practice, this allows any user to write
|
||||||
* its own special matrix without having to modify MatrixBase
|
* its own special matrix without having to modify MatrixBase
|
||||||
*
|
*
|
||||||
* \returns a reference to *this.
|
* \returns a reference to *this.
|
||||||
*/
|
*/
|
||||||
template <typename Derived>
|
template<typename Derived>
|
||||||
template <typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
EIGEN_DEVICE_FUNC constexpr Derived& DenseBase<Derived>::operator=(const EigenBase<OtherDerived>& other) {
|
EIGEN_DEVICE_FUNC
|
||||||
|
Derived& DenseBase<Derived>::operator=(const EigenBase<OtherDerived> &other)
|
||||||
|
{
|
||||||
call_assignment(derived(), other.derived());
|
call_assignment(derived(), other.derived());
|
||||||
return derived();
|
return derived();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Derived>
|
template<typename Derived>
|
||||||
template <typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
EIGEN_DEVICE_FUNC constexpr Derived& DenseBase<Derived>::operator+=(const EigenBase<OtherDerived>& other) {
|
EIGEN_DEVICE_FUNC
|
||||||
call_assignment(derived(), other.derived(), internal::add_assign_op<Scalar, typename OtherDerived::Scalar>());
|
Derived& DenseBase<Derived>::operator+=(const EigenBase<OtherDerived> &other)
|
||||||
|
{
|
||||||
|
call_assignment(derived(), other.derived(), internal::add_assign_op<Scalar,typename OtherDerived::Scalar>());
|
||||||
return derived();
|
return derived();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Derived>
|
template<typename Derived>
|
||||||
template <typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
EIGEN_DEVICE_FUNC constexpr Derived& DenseBase<Derived>::operator-=(const EigenBase<OtherDerived>& other) {
|
EIGEN_DEVICE_FUNC
|
||||||
call_assignment(derived(), other.derived(), internal::sub_assign_op<Scalar, typename OtherDerived::Scalar>());
|
Derived& DenseBase<Derived>::operator-=(const EigenBase<OtherDerived> &other)
|
||||||
|
{
|
||||||
|
call_assignment(derived(), other.derived(), internal::sub_assign_op<Scalar,typename OtherDerived::Scalar>());
|
||||||
return derived();
|
return derived();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end namespace Eigen
|
} // end namespace Eigen
|
||||||
|
|
||||||
#endif // EIGEN_EIGENBASE_H
|
#endif // EIGEN_EIGENBASE_H
|
||||||
|
|||||||
@@ -1,143 +0,0 @@
|
|||||||
// This file is part of Eigen, a lightweight C++ template library
|
|
||||||
// for linear algebra.
|
|
||||||
//
|
|
||||||
// Copyright (C) 2024 Charles Schlosser <cs.schlosser@gmail.com>
|
|
||||||
//
|
|
||||||
// This Source Code Form is subject to the terms of the Mozilla
|
|
||||||
// Public License v. 2.0. If a copy of the MPL was not distributed
|
|
||||||
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
#ifndef EIGEN_FILL_H
|
|
||||||
#define EIGEN_FILL_H
|
|
||||||
|
|
||||||
// IWYU pragma: private
|
|
||||||
#include "./InternalHeaderCheck.h"
|
|
||||||
|
|
||||||
namespace Eigen {
|
|
||||||
|
|
||||||
namespace internal {
|
|
||||||
|
|
||||||
template <typename Xpr>
|
|
||||||
struct eigen_fill_helper : std::false_type {};
|
|
||||||
|
|
||||||
// Only enable std::fill_n for trivially copyable scalars. GCC's libstdc++
|
|
||||||
// fill_n pessimizes non-trivially-copyable types (extra moves per iteration),
|
|
||||||
// causing measurable regressions for types like AutoDiffScalar (issue #2956).
|
|
||||||
template <typename Scalar, int Rows, int Cols, int Options, int MaxRows, int MaxCols>
|
|
||||||
struct eigen_fill_helper<Matrix<Scalar, Rows, Cols, Options, MaxRows, MaxCols>> : std::is_trivially_copyable<Scalar> {};
|
|
||||||
|
|
||||||
template <typename Scalar, int Rows, int Cols, int Options, int MaxRows, int MaxCols>
|
|
||||||
struct eigen_fill_helper<Array<Scalar, Rows, Cols, Options, MaxRows, MaxCols>> : std::is_trivially_copyable<Scalar> {};
|
|
||||||
|
|
||||||
template <typename Xpr, int BlockRows, int BlockCols>
|
|
||||||
struct eigen_fill_helper<Block<Xpr, BlockRows, BlockCols, /*InnerPanel*/ true>> : eigen_fill_helper<Xpr> {};
|
|
||||||
|
|
||||||
template <typename Xpr, int BlockRows, int BlockCols>
|
|
||||||
struct eigen_fill_helper<Block<Xpr, BlockRows, BlockCols, /*InnerPanel*/ false>>
|
|
||||||
: std::integral_constant<bool, eigen_fill_helper<Xpr>::value &&
|
|
||||||
(Xpr::IsRowMajor ? (BlockRows == 1) : (BlockCols == 1))> {};
|
|
||||||
|
|
||||||
template <typename Xpr, int Options>
|
|
||||||
struct eigen_fill_helper<Map<Xpr, Options, Stride<0, 0>>> : eigen_fill_helper<Xpr> {};
|
|
||||||
|
|
||||||
template <typename Xpr, int Options, int OuterStride_>
|
|
||||||
struct eigen_fill_helper<Map<Xpr, Options, Stride<OuterStride_, 0>>>
|
|
||||||
: std::integral_constant<bool, eigen_fill_helper<Xpr>::value &&
|
|
||||||
enum_eq_not_dynamic(OuterStride_, Xpr::InnerSizeAtCompileTime)> {};
|
|
||||||
|
|
||||||
template <typename Xpr, int Options, int OuterStride_>
|
|
||||||
struct eigen_fill_helper<Map<Xpr, Options, Stride<OuterStride_, 1>>>
|
|
||||||
: eigen_fill_helper<Map<Xpr, Options, Stride<OuterStride_, 0>>> {};
|
|
||||||
|
|
||||||
template <typename Xpr, int Options, int InnerStride_>
|
|
||||||
struct eigen_fill_helper<Map<Xpr, Options, InnerStride<InnerStride_>>>
|
|
||||||
: eigen_fill_helper<Map<Xpr, Options, Stride<0, InnerStride_>>> {};
|
|
||||||
|
|
||||||
template <typename Xpr, int Options, int OuterStride_>
|
|
||||||
struct eigen_fill_helper<Map<Xpr, Options, OuterStride<OuterStride_>>>
|
|
||||||
: eigen_fill_helper<Map<Xpr, Options, Stride<OuterStride_, 0>>> {};
|
|
||||||
|
|
||||||
template <typename Xpr>
|
|
||||||
struct eigen_fill_impl<Xpr, /*use_fill*/ false> {
|
|
||||||
using Scalar = typename Xpr::Scalar;
|
|
||||||
using Func = scalar_constant_op<Scalar>;
|
|
||||||
using PlainObject = typename Xpr::PlainObject;
|
|
||||||
using Constant = typename PlainObject::ConstantReturnType;
|
|
||||||
static EIGEN_DEVICE_FUNC constexpr void run(Xpr& dst, const Scalar& val) {
|
|
||||||
const Constant src(dst.rows(), dst.cols(), val);
|
|
||||||
run(dst, src);
|
|
||||||
}
|
|
||||||
template <typename SrcXpr>
|
|
||||||
static EIGEN_DEVICE_FUNC constexpr void run(Xpr& dst, const SrcXpr& src) {
|
|
||||||
call_dense_assignment_loop(dst, src, assign_op<Scalar, Scalar>());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#if EIGEN_COMP_MSVC || defined(EIGEN_GPU_COMPILE_PHASE)
|
|
||||||
template <typename Xpr>
|
|
||||||
struct eigen_fill_impl<Xpr, /*use_fill*/ true> : eigen_fill_impl<Xpr, /*use_fill*/ false> {};
|
|
||||||
#else
|
|
||||||
template <typename Xpr>
|
|
||||||
struct eigen_fill_impl<Xpr, /*use_fill*/ true> {
|
|
||||||
using Scalar = typename Xpr::Scalar;
|
|
||||||
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void run(Xpr& dst, const Scalar& val) {
|
|
||||||
const Scalar val_copy = val;
|
|
||||||
using std::fill_n;
|
|
||||||
fill_n(dst.data(), dst.size(), val_copy);
|
|
||||||
}
|
|
||||||
template <typename SrcXpr>
|
|
||||||
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void run(Xpr& dst, const SrcXpr& src) {
|
|
||||||
resize_if_allowed(dst, src, assign_op<Scalar, Scalar>());
|
|
||||||
const Scalar& val = src.functor()();
|
|
||||||
run(dst, val);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template <typename Xpr>
|
|
||||||
struct eigen_memset_helper {
|
|
||||||
using Scalar = typename Xpr::Scalar;
|
|
||||||
static constexpr bool value = std::is_trivially_copyable<Scalar>::value &&
|
|
||||||
!static_cast<bool>(NumTraits<Scalar>::RequireInitialization) &&
|
|
||||||
eigen_fill_helper<Xpr>::value;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Xpr>
|
|
||||||
struct eigen_zero_impl<Xpr, /*use_memset*/ false> {
|
|
||||||
using Scalar = typename Xpr::Scalar;
|
|
||||||
using PlainObject = typename Xpr::PlainObject;
|
|
||||||
using Zero = typename PlainObject::ZeroReturnType;
|
|
||||||
static EIGEN_DEVICE_FUNC constexpr void run(Xpr& dst) {
|
|
||||||
const Zero src(dst.rows(), dst.cols());
|
|
||||||
run(dst, src);
|
|
||||||
}
|
|
||||||
template <typename SrcXpr>
|
|
||||||
static EIGEN_DEVICE_FUNC constexpr void run(Xpr& dst, const SrcXpr& src) {
|
|
||||||
call_dense_assignment_loop(dst, src, assign_op<Scalar, Scalar>());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Xpr>
|
|
||||||
struct eigen_zero_impl<Xpr, /*use_memset*/ true> {
|
|
||||||
using Scalar = typename Xpr::Scalar;
|
|
||||||
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void run(Xpr& dst) {
|
|
||||||
const std::ptrdiff_t num_bytes = dst.size() * static_cast<std::ptrdiff_t>(sizeof(Scalar));
|
|
||||||
if (num_bytes <= 0) return;
|
|
||||||
void* dst_ptr = static_cast<void*>(dst.data());
|
|
||||||
#ifndef EIGEN_NO_DEBUG
|
|
||||||
eigen_assert((dst_ptr != nullptr) && "null pointer dereference error!");
|
|
||||||
#endif
|
|
||||||
EIGEN_USING_STD(memset);
|
|
||||||
memset(dst_ptr, 0, static_cast<std::size_t>(num_bytes));
|
|
||||||
}
|
|
||||||
template <typename SrcXpr>
|
|
||||||
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void run(Xpr& dst, const SrcXpr& src) {
|
|
||||||
resize_if_allowed(dst, src, assign_op<Scalar, Scalar>());
|
|
||||||
run(dst);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace internal
|
|
||||||
} // namespace Eigen
|
|
||||||
|
|
||||||
#endif // EIGEN_FILL_H
|
|
||||||
@@ -1,464 +0,0 @@
|
|||||||
// This file is part of Eigen, a lightweight C++ template library
|
|
||||||
// for linear algebra.
|
|
||||||
//
|
|
||||||
// Copyright (C) 2025 Charlie Schlosser <cs.schlosser@gmail.com>
|
|
||||||
//
|
|
||||||
// This Source Code Form is subject to the terms of the Mozilla
|
|
||||||
// Public License v. 2.0. If a copy of the MPL was not distributed
|
|
||||||
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
#ifndef EIGEN_FIND_COEFF_H
|
|
||||||
#define EIGEN_FIND_COEFF_H
|
|
||||||
|
|
||||||
// IWYU pragma: private
|
|
||||||
#include "./InternalHeaderCheck.h"
|
|
||||||
|
|
||||||
namespace Eigen {
|
|
||||||
|
|
||||||
namespace internal {
|
|
||||||
|
|
||||||
template <typename Scalar, int NaNPropagation, bool IsInteger = NumTraits<Scalar>::IsInteger>
|
|
||||||
struct max_coeff_functor {
|
|
||||||
EIGEN_DEVICE_FUNC inline bool compareCoeff(const Scalar& incumbent, const Scalar& candidate) const {
|
|
||||||
return candidate > incumbent;
|
|
||||||
}
|
|
||||||
template <typename Packet>
|
|
||||||
EIGEN_DEVICE_FUNC inline Packet comparePacket(const Packet& incumbent, const Packet& candidate) const {
|
|
||||||
return pcmp_lt(incumbent, candidate);
|
|
||||||
}
|
|
||||||
template <typename Packet>
|
|
||||||
EIGEN_DEVICE_FUNC inline Scalar predux(const Packet& a) const {
|
|
||||||
return predux_max(a);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Scalar>
|
|
||||||
struct max_coeff_functor<Scalar, PropagateNaN, false> {
|
|
||||||
EIGEN_DEVICE_FUNC inline Scalar compareCoeff(const Scalar& incumbent, const Scalar& candidate) const {
|
|
||||||
return (candidate > incumbent) || ((candidate != candidate) && (incumbent == incumbent));
|
|
||||||
}
|
|
||||||
template <typename Packet>
|
|
||||||
EIGEN_DEVICE_FUNC inline Packet comparePacket(const Packet& incumbent, const Packet& candidate) const {
|
|
||||||
return pandnot(pcmp_lt_or_nan(incumbent, candidate), pisnan(incumbent));
|
|
||||||
}
|
|
||||||
template <typename Packet>
|
|
||||||
EIGEN_DEVICE_FUNC inline Scalar predux(const Packet& a) const {
|
|
||||||
return predux_max<PropagateNaN>(a);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Scalar>
|
|
||||||
struct max_coeff_functor<Scalar, PropagateNumbers, false> {
|
|
||||||
EIGEN_DEVICE_FUNC inline bool compareCoeff(const Scalar& incumbent, const Scalar& candidate) const {
|
|
||||||
return (candidate > incumbent) || ((candidate == candidate) && (incumbent != incumbent));
|
|
||||||
}
|
|
||||||
template <typename Packet>
|
|
||||||
EIGEN_DEVICE_FUNC inline Packet comparePacket(const Packet& incumbent, const Packet& candidate) const {
|
|
||||||
return pandnot(pcmp_lt_or_nan(incumbent, candidate), pisnan(candidate));
|
|
||||||
}
|
|
||||||
template <typename Packet>
|
|
||||||
EIGEN_DEVICE_FUNC inline Scalar predux(const Packet& a) const {
|
|
||||||
return predux_max<PropagateNumbers>(a);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Scalar, int NaNPropagation, bool IsInteger = NumTraits<Scalar>::IsInteger>
|
|
||||||
struct min_coeff_functor {
|
|
||||||
EIGEN_DEVICE_FUNC inline bool compareCoeff(const Scalar& incumbent, const Scalar& candidate) const {
|
|
||||||
return candidate < incumbent;
|
|
||||||
}
|
|
||||||
template <typename Packet>
|
|
||||||
EIGEN_DEVICE_FUNC inline Packet comparePacket(const Packet& incumbent, const Packet& candidate) const {
|
|
||||||
return pcmp_lt(candidate, incumbent);
|
|
||||||
}
|
|
||||||
template <typename Packet>
|
|
||||||
EIGEN_DEVICE_FUNC inline Scalar predux(const Packet& a) const {
|
|
||||||
return predux_min(a);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Scalar>
|
|
||||||
struct min_coeff_functor<Scalar, PropagateNaN, false> {
|
|
||||||
EIGEN_DEVICE_FUNC inline Scalar compareCoeff(const Scalar& incumbent, const Scalar& candidate) const {
|
|
||||||
return (candidate < incumbent) || ((candidate != candidate) && (incumbent == incumbent));
|
|
||||||
}
|
|
||||||
template <typename Packet>
|
|
||||||
EIGEN_DEVICE_FUNC inline Packet comparePacket(const Packet& incumbent, const Packet& candidate) const {
|
|
||||||
return pandnot(pcmp_lt_or_nan(candidate, incumbent), pisnan(incumbent));
|
|
||||||
}
|
|
||||||
template <typename Packet>
|
|
||||||
EIGEN_DEVICE_FUNC inline Scalar predux(const Packet& a) const {
|
|
||||||
return predux_min<PropagateNaN>(a);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Scalar>
|
|
||||||
struct min_coeff_functor<Scalar, PropagateNumbers, false> {
|
|
||||||
EIGEN_DEVICE_FUNC inline bool compareCoeff(const Scalar& incumbent, const Scalar& candidate) const {
|
|
||||||
return (candidate < incumbent) || ((candidate == candidate) && (incumbent != incumbent));
|
|
||||||
}
|
|
||||||
template <typename Packet>
|
|
||||||
EIGEN_DEVICE_FUNC inline Packet comparePacket(const Packet& incumbent, const Packet& candidate) const {
|
|
||||||
return pandnot(pcmp_lt_or_nan(candidate, incumbent), pisnan(candidate));
|
|
||||||
}
|
|
||||||
template <typename Packet>
|
|
||||||
EIGEN_DEVICE_FUNC inline Scalar predux(const Packet& a) const {
|
|
||||||
return predux_min<PropagateNumbers>(a);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Scalar>
|
|
||||||
struct min_max_traits {
|
|
||||||
static constexpr bool PacketAccess = packet_traits<Scalar>::Vectorizable;
|
|
||||||
};
|
|
||||||
template <typename Scalar, int NaNPropagation>
|
|
||||||
struct functor_traits<max_coeff_functor<Scalar, NaNPropagation>> : min_max_traits<Scalar> {};
|
|
||||||
template <typename Scalar, int NaNPropagation>
|
|
||||||
struct functor_traits<min_coeff_functor<Scalar, NaNPropagation>> : min_max_traits<Scalar> {};
|
|
||||||
|
|
||||||
template <typename Evaluator, typename Func, bool Linear, bool Vectorize>
|
|
||||||
struct find_coeff_loop;
|
|
||||||
template <typename Evaluator, typename Func>
|
|
||||||
struct find_coeff_loop<Evaluator, Func, /*Linear*/ false, /*Vectorize*/ false> {
|
|
||||||
using Scalar = typename Evaluator::Scalar;
|
|
||||||
static EIGEN_DEVICE_FUNC inline void run(const Evaluator& eval, Func& func, Scalar& res, Index& outer, Index& inner) {
|
|
||||||
Index outerSize = eval.outerSize();
|
|
||||||
Index innerSize = eval.innerSize();
|
|
||||||
|
|
||||||
/* initialization performed in calling function */
|
|
||||||
/* result = eval.coeff(0, 0); */
|
|
||||||
/* outer = 0; */
|
|
||||||
/* inner = 0; */
|
|
||||||
|
|
||||||
for (Index j = 0; j < outerSize; j++) {
|
|
||||||
for (Index i = 0; i < innerSize; i++) {
|
|
||||||
Scalar xprCoeff = eval.coeffByOuterInner(j, i);
|
|
||||||
bool newRes = func.compareCoeff(res, xprCoeff);
|
|
||||||
if (newRes) {
|
|
||||||
outer = j;
|
|
||||||
inner = i;
|
|
||||||
res = xprCoeff;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
template <typename Evaluator, typename Func>
|
|
||||||
struct find_coeff_loop<Evaluator, Func, /*Linear*/ true, /*Vectorize*/ false> {
|
|
||||||
using Scalar = typename Evaluator::Scalar;
|
|
||||||
static EIGEN_DEVICE_FUNC inline void run(const Evaluator& eval, Func& func, Scalar& res, Index& index) {
|
|
||||||
Index size = eval.size();
|
|
||||||
|
|
||||||
/* initialization performed in calling function */
|
|
||||||
/* result = eval.coeff(0); */
|
|
||||||
/* index = 0; */
|
|
||||||
|
|
||||||
for (Index k = 0; k < size; k++) {
|
|
||||||
Scalar xprCoeff = eval.coeff(k);
|
|
||||||
bool newRes = func.compareCoeff(res, xprCoeff);
|
|
||||||
if (newRes) {
|
|
||||||
index = k;
|
|
||||||
res = xprCoeff;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
template <typename Evaluator, typename Func>
|
|
||||||
struct find_coeff_loop<Evaluator, Func, /*Linear*/ false, /*Vectorize*/ true> {
|
|
||||||
using ScalarImpl = find_coeff_loop<Evaluator, Func, false, false>;
|
|
||||||
using Scalar = typename Evaluator::Scalar;
|
|
||||||
using Packet = typename Evaluator::Packet;
|
|
||||||
static constexpr int PacketSize = unpacket_traits<Packet>::size;
|
|
||||||
static EIGEN_DEVICE_FUNC inline void run(const Evaluator& eval, Func& func, Scalar& result, Index& outer,
|
|
||||||
Index& inner) {
|
|
||||||
Index outerSize = eval.outerSize();
|
|
||||||
Index innerSize = eval.innerSize();
|
|
||||||
Index packetEnd = numext::round_down(innerSize, PacketSize);
|
|
||||||
|
|
||||||
/* initialization performed in calling function */
|
|
||||||
/* result = eval.coeff(0, 0); */
|
|
||||||
/* outer = 0; */
|
|
||||||
/* inner = 0; */
|
|
||||||
|
|
||||||
bool checkPacket = false;
|
|
||||||
|
|
||||||
for (Index j = 0; j < outerSize; j++) {
|
|
||||||
Packet resultPacket = pset1<Packet>(result);
|
|
||||||
for (Index i = 0; i < packetEnd; i += PacketSize) {
|
|
||||||
Packet xprPacket = eval.template packetByOuterInner<Unaligned, Packet>(j, i);
|
|
||||||
if (predux_any(func.comparePacket(resultPacket, xprPacket))) {
|
|
||||||
outer = j;
|
|
||||||
inner = i;
|
|
||||||
result = func.predux(xprPacket);
|
|
||||||
resultPacket = pset1<Packet>(result);
|
|
||||||
checkPacket = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Index i = packetEnd; i < innerSize; i++) {
|
|
||||||
Scalar xprCoeff = eval.coeffByOuterInner(j, i);
|
|
||||||
if (func.compareCoeff(result, xprCoeff)) {
|
|
||||||
outer = j;
|
|
||||||
inner = i;
|
|
||||||
result = xprCoeff;
|
|
||||||
checkPacket = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (checkPacket) {
|
|
||||||
result = eval.coeffByOuterInner(outer, inner);
|
|
||||||
Index i_end = inner + PacketSize;
|
|
||||||
for (Index i = inner; i < i_end; i++) {
|
|
||||||
Scalar xprCoeff = eval.coeffByOuterInner(outer, i);
|
|
||||||
if (func.compareCoeff(result, xprCoeff)) {
|
|
||||||
inner = i;
|
|
||||||
result = xprCoeff;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
template <typename Evaluator, typename Func>
|
|
||||||
struct find_coeff_loop<Evaluator, Func, /*Linear*/ true, /*Vectorize*/ true> {
|
|
||||||
using ScalarImpl = find_coeff_loop<Evaluator, Func, true, false>;
|
|
||||||
using Scalar = typename Evaluator::Scalar;
|
|
||||||
using Packet = typename Evaluator::Packet;
|
|
||||||
static constexpr int PacketSize = unpacket_traits<Packet>::size;
|
|
||||||
static constexpr int Alignment = Evaluator::Alignment;
|
|
||||||
|
|
||||||
static EIGEN_DEVICE_FUNC inline void run(const Evaluator& eval, Func& func, Scalar& result, Index& index) {
|
|
||||||
Index size = eval.size();
|
|
||||||
Index packetEnd = numext::round_down(size, PacketSize);
|
|
||||||
|
|
||||||
/* initialization performed in calling function */
|
|
||||||
/* result = eval.coeff(0); */
|
|
||||||
/* index = 0; */
|
|
||||||
|
|
||||||
Packet resultPacket = pset1<Packet>(result);
|
|
||||||
bool checkPacket = false;
|
|
||||||
|
|
||||||
for (Index k = 0; k < packetEnd; k += PacketSize) {
|
|
||||||
Packet xprPacket = eval.template packet<Alignment, Packet>(k);
|
|
||||||
if (predux_any(func.comparePacket(resultPacket, xprPacket))) {
|
|
||||||
index = k;
|
|
||||||
result = func.predux(xprPacket);
|
|
||||||
resultPacket = pset1<Packet>(result);
|
|
||||||
checkPacket = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Index k = packetEnd; k < size; k++) {
|
|
||||||
Scalar xprCoeff = eval.coeff(k);
|
|
||||||
if (func.compareCoeff(result, xprCoeff)) {
|
|
||||||
index = k;
|
|
||||||
result = xprCoeff;
|
|
||||||
checkPacket = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (checkPacket) {
|
|
||||||
result = eval.coeff(index);
|
|
||||||
Index k_end = index + PacketSize;
|
|
||||||
for (Index k = index; k < k_end; k++) {
|
|
||||||
Scalar xprCoeff = eval.coeff(k);
|
|
||||||
if (func.compareCoeff(result, xprCoeff)) {
|
|
||||||
index = k;
|
|
||||||
result = xprCoeff;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Derived>
|
|
||||||
struct find_coeff_evaluator : public evaluator<Derived> {
|
|
||||||
using Base = evaluator<Derived>;
|
|
||||||
using Scalar = typename Derived::Scalar;
|
|
||||||
using Packet = typename packet_traits<Scalar>::type;
|
|
||||||
static constexpr int Flags = Base::Flags;
|
|
||||||
static constexpr bool IsRowMajor = bool(Flags & RowMajorBit);
|
|
||||||
EIGEN_DEVICE_FUNC inline find_coeff_evaluator(const Derived& xpr) : Base(xpr), m_xpr(xpr) {}
|
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC inline Scalar coeffByOuterInner(Index outer, Index inner) const {
|
|
||||||
Index row = IsRowMajor ? outer : inner;
|
|
||||||
Index col = IsRowMajor ? inner : outer;
|
|
||||||
return Base::coeff(row, col);
|
|
||||||
}
|
|
||||||
template <int LoadMode, typename PacketType>
|
|
||||||
EIGEN_DEVICE_FUNC inline PacketType packetByOuterInner(Index outer, Index inner) const {
|
|
||||||
Index row = IsRowMajor ? outer : inner;
|
|
||||||
Index col = IsRowMajor ? inner : outer;
|
|
||||||
return Base::template packet<LoadMode, PacketType>(row, col);
|
|
||||||
}
|
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC inline Index innerSize() const { return m_xpr.innerSize(); }
|
|
||||||
EIGEN_DEVICE_FUNC inline Index outerSize() const { return m_xpr.outerSize(); }
|
|
||||||
EIGEN_DEVICE_FUNC inline Index size() const { return m_xpr.size(); }
|
|
||||||
|
|
||||||
const Derived& m_xpr;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Derived, typename Func>
|
|
||||||
struct find_coeff_impl {
|
|
||||||
using Evaluator = find_coeff_evaluator<Derived>;
|
|
||||||
static constexpr int Flags = Evaluator::Flags;
|
|
||||||
static constexpr int Alignment = Evaluator::Alignment;
|
|
||||||
static constexpr bool IsRowMajor = Derived::IsRowMajor;
|
|
||||||
static constexpr int MaxInnerSizeAtCompileTime =
|
|
||||||
IsRowMajor ? Derived::MaxColsAtCompileTime : Derived::MaxRowsAtCompileTime;
|
|
||||||
static constexpr int MaxSizeAtCompileTime = Derived::MaxSizeAtCompileTime;
|
|
||||||
|
|
||||||
using Scalar = typename Derived::Scalar;
|
|
||||||
using Packet = typename Evaluator::Packet;
|
|
||||||
|
|
||||||
static constexpr int PacketSize = unpacket_traits<Packet>::size;
|
|
||||||
static constexpr bool Linearize = bool(Flags & LinearAccessBit);
|
|
||||||
static constexpr bool DontVectorize =
|
|
||||||
enum_lt_not_dynamic(Linearize ? MaxSizeAtCompileTime : MaxInnerSizeAtCompileTime, PacketSize);
|
|
||||||
static constexpr bool Vectorize =
|
|
||||||
!DontVectorize && bool(Flags & PacketAccessBit) && functor_traits<Func>::PacketAccess;
|
|
||||||
|
|
||||||
using Loop = find_coeff_loop<Evaluator, Func, Linearize, Vectorize>;
|
|
||||||
|
|
||||||
template <bool ForwardLinearAccess = Linearize, std::enable_if_t<!ForwardLinearAccess, bool> = true>
|
|
||||||
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void run(const Derived& xpr, Func& func, Scalar& res, Index& outer,
|
|
||||||
Index& inner) {
|
|
||||||
Evaluator eval(xpr);
|
|
||||||
Loop::run(eval, func, res, outer, inner);
|
|
||||||
}
|
|
||||||
template <bool ForwardLinearAccess = Linearize, std::enable_if_t<ForwardLinearAccess, bool> = true>
|
|
||||||
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void run(const Derived& xpr, Func& func, Scalar& res, Index& outer,
|
|
||||||
Index& inner) {
|
|
||||||
// where possible, use the linear loop and back-calculate the outer and inner indices
|
|
||||||
Index index = 0;
|
|
||||||
run(xpr, func, res, index);
|
|
||||||
outer = index / xpr.innerSize();
|
|
||||||
inner = index % xpr.innerSize();
|
|
||||||
}
|
|
||||||
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void run(const Derived& xpr, Func& func, Scalar& res, Index& index) {
|
|
||||||
Evaluator eval(xpr);
|
|
||||||
Loop::run(eval, func, res, index);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Derived, typename IndexType, typename Func>
|
|
||||||
EIGEN_DEVICE_FUNC typename internal::traits<Derived>::Scalar findCoeff(const DenseBase<Derived>& mat, Func& func,
|
|
||||||
IndexType* rowPtr, IndexType* colPtr) {
|
|
||||||
eigen_assert(mat.rows() > 0 && mat.cols() > 0 && "you are using an empty matrix");
|
|
||||||
using Scalar = typename DenseBase<Derived>::Scalar;
|
|
||||||
using FindCoeffImpl = internal::find_coeff_impl<Derived, Func>;
|
|
||||||
Index outer = 0;
|
|
||||||
Index inner = 0;
|
|
||||||
Scalar res = mat.coeff(0, 0);
|
|
||||||
FindCoeffImpl::run(mat.derived(), func, res, outer, inner);
|
|
||||||
*rowPtr = internal::convert_index<IndexType>(Derived::IsRowMajor ? outer : inner);
|
|
||||||
if (colPtr) *colPtr = internal::convert_index<IndexType>(Derived::IsRowMajor ? inner : outer);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Derived, typename IndexType, typename Func>
|
|
||||||
EIGEN_DEVICE_FUNC typename internal::traits<Derived>::Scalar findCoeff(const DenseBase<Derived>& mat, Func& func,
|
|
||||||
IndexType* indexPtr) {
|
|
||||||
eigen_assert(mat.size() > 0 && "you are using an empty matrix");
|
|
||||||
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
|
|
||||||
using Scalar = typename DenseBase<Derived>::Scalar;
|
|
||||||
using FindCoeffImpl = internal::find_coeff_impl<Derived, Func>;
|
|
||||||
Index index = 0;
|
|
||||||
Scalar res = mat.coeff(0);
|
|
||||||
FindCoeffImpl::run(mat.derived(), func, res, index);
|
|
||||||
*indexPtr = internal::convert_index<IndexType>(index);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace internal
|
|
||||||
|
|
||||||
/** \fn DenseBase<Derived>::minCoeff(IndexType* rowId, IndexType* colId) const
|
|
||||||
* \returns the minimum of all coefficients of *this and puts in *row and *col its location.
|
|
||||||
*
|
|
||||||
* If there are multiple coefficients with the same extreme value, the location of the first instance is returned.
|
|
||||||
*
|
|
||||||
* In case \c *this contains NaN, NaNPropagation determines the behavior:
|
|
||||||
* NaNPropagation == PropagateFast : undefined
|
|
||||||
* NaNPropagation == PropagateNaN : result is NaN
|
|
||||||
* NaNPropagation == PropagateNumbers : result is maximum of elements that are not NaN
|
|
||||||
* \warning the matrix must be not empty, otherwise an assertion is triggered.
|
|
||||||
*
|
|
||||||
* \sa DenseBase::minCoeff(Index*), DenseBase::maxCoeff(Index*,Index*), DenseBase::visit(), DenseBase::minCoeff()
|
|
||||||
*/
|
|
||||||
template <typename Derived>
|
|
||||||
template <int NaNPropagation, typename IndexType>
|
|
||||||
EIGEN_DEVICE_FUNC typename internal::traits<Derived>::Scalar DenseBase<Derived>::minCoeff(IndexType* rowPtr,
|
|
||||||
IndexType* colPtr) const {
|
|
||||||
using Func = internal::min_coeff_functor<Scalar, NaNPropagation>;
|
|
||||||
Func func;
|
|
||||||
return internal::findCoeff(derived(), func, rowPtr, colPtr);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** \returns the minimum of all coefficients of *this and puts in *index its location.
|
|
||||||
*
|
|
||||||
* If there are multiple coefficients with the same extreme value, the location of the first instance is returned.
|
|
||||||
*
|
|
||||||
* In case \c *this contains NaN, NaNPropagation determines the behavior:
|
|
||||||
* NaNPropagation == PropagateFast : undefined
|
|
||||||
* NaNPropagation == PropagateNaN : result is NaN
|
|
||||||
* NaNPropagation == PropagateNumbers : result is maximum of elements that are not NaN
|
|
||||||
* \warning the matrix must be not empty, otherwise an assertion is triggered.
|
|
||||||
*
|
|
||||||
* \sa DenseBase::minCoeff(IndexType*,IndexType*), DenseBase::maxCoeff(IndexType*,IndexType*), DenseBase::visit(),
|
|
||||||
* DenseBase::minCoeff()
|
|
||||||
*/
|
|
||||||
template <typename Derived>
|
|
||||||
template <int NaNPropagation, typename IndexType>
|
|
||||||
EIGEN_DEVICE_FUNC typename internal::traits<Derived>::Scalar DenseBase<Derived>::minCoeff(IndexType* indexPtr) const {
|
|
||||||
using Func = internal::min_coeff_functor<Scalar, NaNPropagation>;
|
|
||||||
Func func;
|
|
||||||
return internal::findCoeff(derived(), func, indexPtr);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** \fn DenseBase<Derived>::maxCoeff(IndexType* rowId, IndexType* colId) const
|
|
||||||
* \returns the maximum of all coefficients of *this and puts in *row and *col its location.
|
|
||||||
*
|
|
||||||
* If there are multiple coefficients with the same extreme value, the location of the first instance is returned.
|
|
||||||
*
|
|
||||||
* In case \c *this contains NaN, NaNPropagation determines the behavior:
|
|
||||||
* NaNPropagation == PropagateFast : undefined
|
|
||||||
* NaNPropagation == PropagateNaN : result is NaN
|
|
||||||
* NaNPropagation == PropagateNumbers : result is maximum of elements that are not NaN
|
|
||||||
* \warning the matrix must be not empty, otherwise an assertion is triggered.
|
|
||||||
*
|
|
||||||
* \sa DenseBase::minCoeff(IndexType*,IndexType*), DenseBase::visit(), DenseBase::maxCoeff()
|
|
||||||
*/
|
|
||||||
template <typename Derived>
|
|
||||||
template <int NaNPropagation, typename IndexType>
|
|
||||||
EIGEN_DEVICE_FUNC typename internal::traits<Derived>::Scalar DenseBase<Derived>::maxCoeff(IndexType* rowPtr,
|
|
||||||
IndexType* colPtr) const {
|
|
||||||
using Func = internal::max_coeff_functor<Scalar, NaNPropagation>;
|
|
||||||
Func func;
|
|
||||||
return internal::findCoeff(derived(), func, rowPtr, colPtr);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** \returns the maximum of all coefficients of *this and puts in *index its location.
|
|
||||||
*
|
|
||||||
* If there are multiple coefficients with the same extreme value, the location of the first instance is returned.
|
|
||||||
*
|
|
||||||
* In case \c *this contains NaN, NaNPropagation determines the behavior:
|
|
||||||
* NaNPropagation == PropagateFast : undefined
|
|
||||||
* NaNPropagation == PropagateNaN : result is NaN
|
|
||||||
* NaNPropagation == PropagateNumbers : result is maximum of elements that are not NaN
|
|
||||||
* \warning the matrix must be not empty, otherwise an assertion is triggered.
|
|
||||||
*
|
|
||||||
* \sa DenseBase::maxCoeff(IndexType*,IndexType*), DenseBase::minCoeff(IndexType*,IndexType*), DenseBase::visitor(),
|
|
||||||
* DenseBase::maxCoeff()
|
|
||||||
*/
|
|
||||||
template <typename Derived>
|
|
||||||
template <int NaNPropagation, typename IndexType>
|
|
||||||
EIGEN_DEVICE_FUNC typename internal::traits<Derived>::Scalar DenseBase<Derived>::maxCoeff(IndexType* indexPtr) const {
|
|
||||||
using Func = internal::max_coeff_functor<Scalar, NaNPropagation>;
|
|
||||||
Func func;
|
|
||||||
return internal::findCoeff(derived(), func, indexPtr);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Eigen
|
|
||||||
|
|
||||||
#endif // EIGEN_FIND_COEFF_H
|
|
||||||
@@ -10,99 +10,141 @@
|
|||||||
#ifndef EIGEN_FORCEALIGNEDACCESS_H
|
#ifndef EIGEN_FORCEALIGNEDACCESS_H
|
||||||
#define EIGEN_FORCEALIGNEDACCESS_H
|
#define EIGEN_FORCEALIGNEDACCESS_H
|
||||||
|
|
||||||
// IWYU pragma: private
|
|
||||||
#include "./InternalHeaderCheck.h"
|
|
||||||
|
|
||||||
namespace Eigen {
|
namespace Eigen {
|
||||||
|
|
||||||
/** \class ForceAlignedAccess
|
/** \class ForceAlignedAccess
|
||||||
* \ingroup Core_Module
|
* \ingroup Core_Module
|
||||||
*
|
*
|
||||||
* \brief Enforce aligned packet loads and stores regardless of what is requested
|
* \brief Enforce aligned packet loads and stores regardless of what is requested
|
||||||
*
|
*
|
||||||
* \param ExpressionType the type of the object of which we are forcing aligned packet access
|
* \param ExpressionType the type of the object of which we are forcing aligned packet access
|
||||||
*
|
*
|
||||||
* This class is the return type of MatrixBase::forceAlignedAccess()
|
* This class is the return type of MatrixBase::forceAlignedAccess()
|
||||||
* and most of the time this is the only way it is used.
|
* and most of the time this is the only way it is used.
|
||||||
*
|
*
|
||||||
* \sa MatrixBase::forceAlignedAccess()
|
* \sa MatrixBase::forceAlignedAccess()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
template <typename ExpressionType>
|
template<typename ExpressionType>
|
||||||
struct traits<ForceAlignedAccess<ExpressionType>> : public traits<ExpressionType> {};
|
struct traits<ForceAlignedAccess<ExpressionType> > : public traits<ExpressionType>
|
||||||
} // namespace internal
|
{};
|
||||||
|
}
|
||||||
|
|
||||||
template <typename ExpressionType>
|
template<typename ExpressionType> class ForceAlignedAccess
|
||||||
class ForceAlignedAccess : public internal::dense_xpr_base<ForceAlignedAccess<ExpressionType>>::type {
|
: public internal::dense_xpr_base< ForceAlignedAccess<ExpressionType> >::type
|
||||||
public:
|
{
|
||||||
typedef typename internal::dense_xpr_base<ForceAlignedAccess>::type Base;
|
public:
|
||||||
EIGEN_DENSE_PUBLIC_INTERFACE(ForceAlignedAccess)
|
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC explicit constexpr ForceAlignedAccess(const ExpressionType& matrix) : m_expression(matrix) {}
|
typedef typename internal::dense_xpr_base<ForceAlignedAccess>::type Base;
|
||||||
|
EIGEN_DENSE_PUBLIC_INTERFACE(ForceAlignedAccess)
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC constexpr Index rows() const noexcept { return m_expression.rows(); }
|
EIGEN_DEVICE_FUNC explicit inline ForceAlignedAccess(const ExpressionType& matrix) : m_expression(matrix) {}
|
||||||
EIGEN_DEVICE_FUNC constexpr Index cols() const noexcept { return m_expression.cols(); }
|
|
||||||
EIGEN_DEVICE_FUNC constexpr Index outerStride() const noexcept { return m_expression.outerStride(); }
|
|
||||||
EIGEN_DEVICE_FUNC constexpr Index innerStride() const noexcept { return m_expression.innerStride(); }
|
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC inline const CoeffReturnType coeff(Index row, Index col) const {
|
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
|
||||||
return m_expression.coeff(row, col);
|
inline Index rows() const EIGEN_NOEXCEPT { return m_expression.rows(); }
|
||||||
}
|
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
|
||||||
|
inline Index cols() const EIGEN_NOEXCEPT { return m_expression.cols(); }
|
||||||
|
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
|
||||||
|
inline Index outerStride() const EIGEN_NOEXCEPT { return m_expression.outerStride(); }
|
||||||
|
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
|
||||||
|
inline Index innerStride() const EIGEN_NOEXCEPT { return m_expression.innerStride(); }
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC inline Scalar& coeffRef(Index row, Index col) {
|
EIGEN_DEVICE_FUNC inline const CoeffReturnType coeff(Index row, Index col) const
|
||||||
return m_expression.const_cast_derived().coeffRef(row, col);
|
{
|
||||||
}
|
return m_expression.coeff(row, col);
|
||||||
|
}
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC inline const CoeffReturnType coeff(Index index) const { return m_expression.coeff(index); }
|
EIGEN_DEVICE_FUNC inline Scalar& coeffRef(Index row, Index col)
|
||||||
|
{
|
||||||
|
return m_expression.const_cast_derived().coeffRef(row, col);
|
||||||
|
}
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC inline Scalar& coeffRef(Index index) { return m_expression.const_cast_derived().coeffRef(index); }
|
EIGEN_DEVICE_FUNC inline const CoeffReturnType coeff(Index index) const
|
||||||
|
{
|
||||||
|
return m_expression.coeff(index);
|
||||||
|
}
|
||||||
|
|
||||||
template <int LoadMode>
|
EIGEN_DEVICE_FUNC inline Scalar& coeffRef(Index index)
|
||||||
inline const PacketScalar packet(Index row, Index col) const {
|
{
|
||||||
return m_expression.template packet<Aligned>(row, col);
|
return m_expression.const_cast_derived().coeffRef(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int LoadMode>
|
template<int LoadMode>
|
||||||
inline void writePacket(Index row, Index col, const PacketScalar& x) {
|
inline const PacketScalar packet(Index row, Index col) const
|
||||||
m_expression.const_cast_derived().template writePacket<Aligned>(row, col, x);
|
{
|
||||||
}
|
return m_expression.template packet<Aligned>(row, col);
|
||||||
|
}
|
||||||
|
|
||||||
template <int LoadMode>
|
template<int LoadMode>
|
||||||
inline const PacketScalar packet(Index index) const {
|
inline void writePacket(Index row, Index col, const PacketScalar& x)
|
||||||
return m_expression.template packet<Aligned>(index);
|
{
|
||||||
}
|
m_expression.const_cast_derived().template writePacket<Aligned>(row, col, x);
|
||||||
|
}
|
||||||
|
|
||||||
template <int LoadMode>
|
template<int LoadMode>
|
||||||
inline void writePacket(Index index, const PacketScalar& x) {
|
inline const PacketScalar packet(Index index) const
|
||||||
m_expression.const_cast_derived().template writePacket<Aligned>(index, x);
|
{
|
||||||
}
|
return m_expression.template packet<Aligned>(index);
|
||||||
|
}
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC operator const ExpressionType&() const { return m_expression; }
|
template<int LoadMode>
|
||||||
|
inline void writePacket(Index index, const PacketScalar& x)
|
||||||
|
{
|
||||||
|
m_expression.const_cast_derived().template writePacket<Aligned>(index, x);
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
EIGEN_DEVICE_FUNC operator const ExpressionType&() const { return m_expression; }
|
||||||
const ExpressionType& m_expression;
|
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
ForceAlignedAccess& operator=(const ForceAlignedAccess&);
|
const ExpressionType& m_expression;
|
||||||
|
|
||||||
|
private:
|
||||||
|
ForceAlignedAccess& operator=(const ForceAlignedAccess&);
|
||||||
};
|
};
|
||||||
|
|
||||||
/** \returns an expression of *this with forced aligned access
|
/** \returns an expression of *this with forced aligned access
|
||||||
* \sa forceAlignedAccessIf(),class ForceAlignedAccess
|
* \sa forceAlignedAccessIf(),class ForceAlignedAccess
|
||||||
*/
|
*/
|
||||||
template <typename Derived>
|
template<typename Derived>
|
||||||
inline const ForceAlignedAccess<Derived> MatrixBase<Derived>::forceAlignedAccess() const {
|
inline const ForceAlignedAccess<Derived>
|
||||||
|
MatrixBase<Derived>::forceAlignedAccess() const
|
||||||
|
{
|
||||||
return ForceAlignedAccess<Derived>(derived());
|
return ForceAlignedAccess<Derived>(derived());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \returns an expression of *this with forced aligned access
|
/** \returns an expression of *this with forced aligned access
|
||||||
* \sa forceAlignedAccessIf(), class ForceAlignedAccess
|
* \sa forceAlignedAccessIf(), class ForceAlignedAccess
|
||||||
*/
|
*/
|
||||||
template <typename Derived>
|
template<typename Derived>
|
||||||
inline ForceAlignedAccess<Derived> MatrixBase<Derived>::forceAlignedAccess() {
|
inline ForceAlignedAccess<Derived>
|
||||||
|
MatrixBase<Derived>::forceAlignedAccess()
|
||||||
|
{
|
||||||
return ForceAlignedAccess<Derived>(derived());
|
return ForceAlignedAccess<Derived>(derived());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end namespace Eigen
|
/** \returns an expression of *this with forced aligned access if \a Enable is true.
|
||||||
|
* \sa forceAlignedAccess(), class ForceAlignedAccess
|
||||||
|
*/
|
||||||
|
template<typename Derived>
|
||||||
|
template<bool Enable>
|
||||||
|
inline typename internal::add_const_on_value_type<typename internal::conditional<Enable,ForceAlignedAccess<Derived>,Derived&>::type>::type
|
||||||
|
MatrixBase<Derived>::forceAlignedAccessIf() const
|
||||||
|
{
|
||||||
|
return derived(); // FIXME This should not work but apparently is never used
|
||||||
|
}
|
||||||
|
|
||||||
#endif // EIGEN_FORCEALIGNEDACCESS_H
|
/** \returns an expression of *this with forced aligned access if \a Enable is true.
|
||||||
|
* \sa forceAlignedAccess(), class ForceAlignedAccess
|
||||||
|
*/
|
||||||
|
template<typename Derived>
|
||||||
|
template<bool Enable>
|
||||||
|
inline typename internal::conditional<Enable,ForceAlignedAccess<Derived>,Derived&>::type
|
||||||
|
MatrixBase<Derived>::forceAlignedAccessIf()
|
||||||
|
{
|
||||||
|
return derived(); // FIXME This should not work but apparently is never used
|
||||||
|
}
|
||||||
|
|
||||||
|
} // end namespace Eigen
|
||||||
|
|
||||||
|
#endif // EIGEN_FORCEALIGNEDACCESS_H
|
||||||
|
|||||||
@@ -11,122 +11,145 @@
|
|||||||
#ifndef EIGEN_FUZZY_H
|
#ifndef EIGEN_FUZZY_H
|
||||||
#define EIGEN_FUZZY_H
|
#define EIGEN_FUZZY_H
|
||||||
|
|
||||||
// IWYU pragma: private
|
namespace Eigen {
|
||||||
#include "./InternalHeaderCheck.h"
|
|
||||||
|
|
||||||
namespace Eigen {
|
namespace internal
|
||||||
|
{
|
||||||
|
|
||||||
namespace internal {
|
template<typename Derived, typename OtherDerived, bool is_integer = NumTraits<typename Derived::Scalar>::IsInteger>
|
||||||
|
struct isApprox_selector
|
||||||
template <typename Derived, typename OtherDerived, bool is_integer = NumTraits<typename Derived::Scalar>::IsInteger>
|
{
|
||||||
struct isApprox_selector {
|
EIGEN_DEVICE_FUNC
|
||||||
EIGEN_DEVICE_FUNC static bool run(const Derived& x, const OtherDerived& y, const typename Derived::RealScalar& prec) {
|
static bool run(const Derived& x, const OtherDerived& y, const typename Derived::RealScalar& prec)
|
||||||
typename internal::nested_eval<Derived, 2>::type nested(x);
|
{
|
||||||
typename internal::nested_eval<OtherDerived, 2>::type otherNested(y);
|
typename internal::nested_eval<Derived,2>::type nested(x);
|
||||||
return (nested.matrix() - otherNested.matrix()).cwiseAbs2().sum() <=
|
typename internal::nested_eval<OtherDerived,2>::type otherNested(y);
|
||||||
prec * prec * numext::mini(nested.cwiseAbs2().sum(), otherNested.cwiseAbs2().sum());
|
return (nested - otherNested).cwiseAbs2().sum() <= prec * prec * numext::mini(nested.cwiseAbs2().sum(), otherNested.cwiseAbs2().sum());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Derived, typename OtherDerived>
|
template<typename Derived, typename OtherDerived>
|
||||||
struct isApprox_selector<Derived, OtherDerived, true> {
|
struct isApprox_selector<Derived, OtherDerived, true>
|
||||||
EIGEN_DEVICE_FUNC static bool run(const Derived& x, const OtherDerived& y, const typename Derived::RealScalar&) {
|
{
|
||||||
|
EIGEN_DEVICE_FUNC
|
||||||
|
static bool run(const Derived& x, const OtherDerived& y, const typename Derived::RealScalar&)
|
||||||
|
{
|
||||||
return x.matrix() == y.matrix();
|
return x.matrix() == y.matrix();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Derived, typename OtherDerived, bool is_integer = NumTraits<typename Derived::Scalar>::IsInteger>
|
template<typename Derived, typename OtherDerived, bool is_integer = NumTraits<typename Derived::Scalar>::IsInteger>
|
||||||
struct isMuchSmallerThan_object_selector {
|
struct isMuchSmallerThan_object_selector
|
||||||
EIGEN_DEVICE_FUNC static bool run(const Derived& x, const OtherDerived& y, const typename Derived::RealScalar& prec) {
|
{
|
||||||
|
EIGEN_DEVICE_FUNC
|
||||||
|
static bool run(const Derived& x, const OtherDerived& y, const typename Derived::RealScalar& prec)
|
||||||
|
{
|
||||||
return x.cwiseAbs2().sum() <= numext::abs2(prec) * y.cwiseAbs2().sum();
|
return x.cwiseAbs2().sum() <= numext::abs2(prec) * y.cwiseAbs2().sum();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Derived, typename OtherDerived>
|
template<typename Derived, typename OtherDerived>
|
||||||
struct isMuchSmallerThan_object_selector<Derived, OtherDerived, true> {
|
struct isMuchSmallerThan_object_selector<Derived, OtherDerived, true>
|
||||||
EIGEN_DEVICE_FUNC static bool run(const Derived& x, const OtherDerived&, const typename Derived::RealScalar&) {
|
{
|
||||||
|
EIGEN_DEVICE_FUNC
|
||||||
|
static bool run(const Derived& x, const OtherDerived&, const typename Derived::RealScalar&)
|
||||||
|
{
|
||||||
return x.matrix() == Derived::Zero(x.rows(), x.cols()).matrix();
|
return x.matrix() == Derived::Zero(x.rows(), x.cols()).matrix();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Derived, bool is_integer = NumTraits<typename Derived::Scalar>::IsInteger>
|
template<typename Derived, bool is_integer = NumTraits<typename Derived::Scalar>::IsInteger>
|
||||||
struct isMuchSmallerThan_scalar_selector {
|
struct isMuchSmallerThan_scalar_selector
|
||||||
EIGEN_DEVICE_FUNC static bool run(const Derived& x, const typename Derived::RealScalar& y,
|
{
|
||||||
const typename Derived::RealScalar& prec) {
|
EIGEN_DEVICE_FUNC
|
||||||
|
static bool run(const Derived& x, const typename Derived::RealScalar& y, const typename Derived::RealScalar& prec)
|
||||||
|
{
|
||||||
return x.cwiseAbs2().sum() <= numext::abs2(prec * y);
|
return x.cwiseAbs2().sum() <= numext::abs2(prec * y);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Derived>
|
template<typename Derived>
|
||||||
struct isMuchSmallerThan_scalar_selector<Derived, true> {
|
struct isMuchSmallerThan_scalar_selector<Derived, true>
|
||||||
EIGEN_DEVICE_FUNC static bool run(const Derived& x, const typename Derived::RealScalar&,
|
{
|
||||||
const typename Derived::RealScalar&) {
|
EIGEN_DEVICE_FUNC
|
||||||
|
static bool run(const Derived& x, const typename Derived::RealScalar&, const typename Derived::RealScalar&)
|
||||||
|
{
|
||||||
return x.matrix() == Derived::Zero(x.rows(), x.cols()).matrix();
|
return x.matrix() == Derived::Zero(x.rows(), x.cols()).matrix();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace internal
|
} // end namespace internal
|
||||||
|
|
||||||
|
|
||||||
/** \returns \c true if \c *this is approximately equal to \a other, within the precision
|
/** \returns \c true if \c *this is approximately equal to \a other, within the precision
|
||||||
* determined by \a prec.
|
* determined by \a prec.
|
||||||
*
|
*
|
||||||
* \note The fuzzy compares are done multiplicatively. Two vectors \f$ v \f$ and \f$ w \f$
|
* \note The fuzzy compares are done multiplicatively. Two vectors \f$ v \f$ and \f$ w \f$
|
||||||
* are considered to be approximately equal within precision \f$ p \f$ if
|
* are considered to be approximately equal within precision \f$ p \f$ if
|
||||||
* \f[ \Vert v - w \Vert \leqslant p\,\min(\Vert v\Vert, \Vert w\Vert). \f]
|
* \f[ \Vert v - w \Vert \leqslant p\,\min(\Vert v\Vert, \Vert w\Vert). \f]
|
||||||
* For matrices, the comparison is done using the Hilbert-Schmidt norm (aka Frobenius norm
|
* For matrices, the comparison is done using the Hilbert-Schmidt norm (aka Frobenius norm
|
||||||
* L2 norm).
|
* L2 norm).
|
||||||
*
|
*
|
||||||
* \note Because of the multiplicativeness of this comparison, one can't use this function
|
* \note Because of the multiplicativeness of this comparison, one can't use this function
|
||||||
* to check whether \c *this is approximately equal to the zero matrix or vector.
|
* to check whether \c *this is approximately equal to the zero matrix or vector.
|
||||||
* Indeed, \c isApprox(zero) returns false unless \c *this itself is exactly the zero matrix
|
* Indeed, \c isApprox(zero) returns false unless \c *this itself is exactly the zero matrix
|
||||||
* or vector. If you want to test whether \c *this is zero, use internal::isMuchSmallerThan(const
|
* or vector. If you want to test whether \c *this is zero, use internal::isMuchSmallerThan(const
|
||||||
* RealScalar&, RealScalar) instead.
|
* RealScalar&, RealScalar) instead.
|
||||||
*
|
*
|
||||||
* \sa internal::isMuchSmallerThan(const RealScalar&, RealScalar) const
|
* \sa internal::isMuchSmallerThan(const RealScalar&, RealScalar) const
|
||||||
*/
|
*/
|
||||||
template <typename Derived>
|
template<typename Derived>
|
||||||
template <typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
EIGEN_DEVICE_FUNC constexpr bool DenseBase<Derived>::isApprox(const DenseBase<OtherDerived>& other,
|
EIGEN_DEVICE_FUNC bool DenseBase<Derived>::isApprox(
|
||||||
const RealScalar& prec) const {
|
const DenseBase<OtherDerived>& other,
|
||||||
|
const RealScalar& prec
|
||||||
|
) const
|
||||||
|
{
|
||||||
return internal::isApprox_selector<Derived, OtherDerived>::run(derived(), other.derived(), prec);
|
return internal::isApprox_selector<Derived, OtherDerived>::run(derived(), other.derived(), prec);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \returns \c true if the norm of \c *this is much smaller than \a other,
|
/** \returns \c true if the norm of \c *this is much smaller than \a other,
|
||||||
* within the precision determined by \a prec.
|
* within the precision determined by \a prec.
|
||||||
*
|
*
|
||||||
* \note The fuzzy compares are done multiplicatively. A vector \f$ v \f$ is
|
* \note The fuzzy compares are done multiplicatively. A vector \f$ v \f$ is
|
||||||
* considered to be much smaller than \f$ x \f$ within precision \f$ p \f$ if
|
* considered to be much smaller than \f$ x \f$ within precision \f$ p \f$ if
|
||||||
* \f[ \Vert v \Vert \leqslant p\,\vert x\vert. \f]
|
* \f[ \Vert v \Vert \leqslant p\,\vert x\vert. \f]
|
||||||
*
|
*
|
||||||
* For matrices, the comparison is done using the Hilbert-Schmidt norm. For this reason,
|
* For matrices, the comparison is done using the Hilbert-Schmidt norm. For this reason,
|
||||||
* the value of the reference scalar \a other should come from the Hilbert-Schmidt norm
|
* the value of the reference scalar \a other should come from the Hilbert-Schmidt norm
|
||||||
* of a reference matrix of same dimensions.
|
* of a reference matrix of same dimensions.
|
||||||
*
|
*
|
||||||
* \sa isApprox(), isMuchSmallerThan(const DenseBase<OtherDerived>&, RealScalar) const
|
* \sa isApprox(), isMuchSmallerThan(const DenseBase<OtherDerived>&, RealScalar) const
|
||||||
*/
|
*/
|
||||||
template <typename Derived>
|
template<typename Derived>
|
||||||
EIGEN_DEVICE_FUNC constexpr bool DenseBase<Derived>::isMuchSmallerThan(const typename NumTraits<Scalar>::Real& other,
|
EIGEN_DEVICE_FUNC bool DenseBase<Derived>::isMuchSmallerThan(
|
||||||
const RealScalar& prec) const {
|
const typename NumTraits<Scalar>::Real& other,
|
||||||
|
const RealScalar& prec
|
||||||
|
) const
|
||||||
|
{
|
||||||
return internal::isMuchSmallerThan_scalar_selector<Derived>::run(derived(), other, prec);
|
return internal::isMuchSmallerThan_scalar_selector<Derived>::run(derived(), other, prec);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \returns \c true if the norm of \c *this is much smaller than the norm of \a other,
|
/** \returns \c true if the norm of \c *this is much smaller than the norm of \a other,
|
||||||
* within the precision determined by \a prec.
|
* within the precision determined by \a prec.
|
||||||
*
|
*
|
||||||
* \note The fuzzy compares are done multiplicatively. A vector \f$ v \f$ is
|
* \note The fuzzy compares are done multiplicatively. A vector \f$ v \f$ is
|
||||||
* considered to be much smaller than a vector \f$ w \f$ within precision \f$ p \f$ if
|
* considered to be much smaller than a vector \f$ w \f$ within precision \f$ p \f$ if
|
||||||
* \f[ \Vert v \Vert \leqslant p\,\Vert w\Vert. \f]
|
* \f[ \Vert v \Vert \leqslant p\,\Vert w\Vert. \f]
|
||||||
* For matrices, the comparison is done using the Hilbert-Schmidt norm.
|
* For matrices, the comparison is done using the Hilbert-Schmidt norm.
|
||||||
*
|
*
|
||||||
* \sa isApprox(), isMuchSmallerThan(const RealScalar&, RealScalar) const
|
* \sa isApprox(), isMuchSmallerThan(const RealScalar&, RealScalar) const
|
||||||
*/
|
*/
|
||||||
template <typename Derived>
|
template<typename Derived>
|
||||||
template <typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
EIGEN_DEVICE_FUNC constexpr bool DenseBase<Derived>::isMuchSmallerThan(const DenseBase<OtherDerived>& other,
|
EIGEN_DEVICE_FUNC bool DenseBase<Derived>::isMuchSmallerThan(
|
||||||
const RealScalar& prec) const {
|
const DenseBase<OtherDerived>& other,
|
||||||
|
const RealScalar& prec
|
||||||
|
) const
|
||||||
|
{
|
||||||
return internal::isMuchSmallerThan_object_selector<Derived, OtherDerived>::run(derived(), other.derived(), prec);
|
return internal::isMuchSmallerThan_object_selector<Derived, OtherDerived>::run(derived(), other.derived(), prec);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end namespace Eigen
|
} // end namespace Eigen
|
||||||
|
|
||||||
#endif // EIGEN_FUZZY_H
|
#endif // EIGEN_FUZZY_H
|
||||||
|
|||||||
@@ -11,12 +11,12 @@
|
|||||||
#ifndef EIGEN_GENERAL_PRODUCT_H
|
#ifndef EIGEN_GENERAL_PRODUCT_H
|
||||||
#define EIGEN_GENERAL_PRODUCT_H
|
#define EIGEN_GENERAL_PRODUCT_H
|
||||||
|
|
||||||
// IWYU pragma: private
|
|
||||||
#include "./InternalHeaderCheck.h"
|
|
||||||
|
|
||||||
namespace Eigen {
|
namespace Eigen {
|
||||||
|
|
||||||
enum { Large = 2, Small = 3 };
|
enum {
|
||||||
|
Large = 2,
|
||||||
|
Small = 3
|
||||||
|
};
|
||||||
|
|
||||||
// Define the threshold value to fallback from the generic matrix-matrix product
|
// Define the threshold value to fallback from the generic matrix-matrix product
|
||||||
// implementation (heavy) to the lightweight coeff-based product one.
|
// implementation (heavy) to the lightweight coeff-based product one.
|
||||||
@@ -30,58 +30,64 @@ enum { Large = 2, Small = 3 };
|
|||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
template <int Rows, int Cols, int Depth>
|
template<int Rows, int Cols, int Depth> struct product_type_selector;
|
||||||
struct product_type_selector;
|
|
||||||
|
|
||||||
template <int Size, int MaxSize>
|
template<int Size, int MaxSize> struct product_size_category
|
||||||
struct product_size_category {
|
{
|
||||||
enum {
|
enum {
|
||||||
#ifndef EIGEN_GPU_COMPILE_PHASE
|
#ifndef EIGEN_GPU_COMPILE_PHASE
|
||||||
is_large = MaxSize == Dynamic || Size >= EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD ||
|
is_large = MaxSize == Dynamic ||
|
||||||
(Size == Dynamic && MaxSize >= EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD),
|
Size >= EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD ||
|
||||||
#else
|
(Size==Dynamic && MaxSize>=EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD),
|
||||||
|
#else
|
||||||
is_large = 0,
|
is_large = 0,
|
||||||
#endif
|
#endif
|
||||||
value = is_large ? Large
|
value = is_large ? Large
|
||||||
: Size == 1 ? 1
|
: Size == 1 ? 1
|
||||||
: Small
|
: Small
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Lhs, typename Rhs>
|
template<typename Lhs, typename Rhs> struct product_type
|
||||||
struct product_type {
|
{
|
||||||
typedef remove_all_t<Lhs> Lhs_;
|
typedef typename remove_all<Lhs>::type _Lhs;
|
||||||
typedef remove_all_t<Rhs> Rhs_;
|
typedef typename remove_all<Rhs>::type _Rhs;
|
||||||
enum {
|
enum {
|
||||||
MaxRows = traits<Lhs_>::MaxRowsAtCompileTime,
|
MaxRows = traits<_Lhs>::MaxRowsAtCompileTime,
|
||||||
Rows = traits<Lhs_>::RowsAtCompileTime,
|
Rows = traits<_Lhs>::RowsAtCompileTime,
|
||||||
MaxCols = traits<Rhs_>::MaxColsAtCompileTime,
|
MaxCols = traits<_Rhs>::MaxColsAtCompileTime,
|
||||||
Cols = traits<Rhs_>::ColsAtCompileTime,
|
Cols = traits<_Rhs>::ColsAtCompileTime,
|
||||||
MaxDepth = min_size_prefer_fixed(traits<Lhs_>::MaxColsAtCompileTime, traits<Rhs_>::MaxRowsAtCompileTime),
|
MaxDepth = EIGEN_SIZE_MIN_PREFER_FIXED(traits<_Lhs>::MaxColsAtCompileTime,
|
||||||
Depth = min_size_prefer_fixed(traits<Lhs_>::ColsAtCompileTime, traits<Rhs_>::RowsAtCompileTime)
|
traits<_Rhs>::MaxRowsAtCompileTime),
|
||||||
|
Depth = EIGEN_SIZE_MIN_PREFER_FIXED(traits<_Lhs>::ColsAtCompileTime,
|
||||||
|
traits<_Rhs>::RowsAtCompileTime)
|
||||||
};
|
};
|
||||||
|
|
||||||
// the splitting into different lines of code here, introducing the _select enums and the typedef below,
|
// the splitting into different lines of code here, introducing the _select enums and the typedef below,
|
||||||
// is to work around an internal compiler error with gcc 4.1 and 4.2.
|
// is to work around an internal compiler error with gcc 4.1 and 4.2.
|
||||||
private:
|
private:
|
||||||
enum {
|
enum {
|
||||||
rows_select = product_size_category<Rows, MaxRows>::value,
|
rows_select = product_size_category<Rows,MaxRows>::value,
|
||||||
cols_select = product_size_category<Cols, MaxCols>::value,
|
cols_select = product_size_category<Cols,MaxCols>::value,
|
||||||
depth_select = product_size_category<Depth, MaxDepth>::value
|
depth_select = product_size_category<Depth,MaxDepth>::value
|
||||||
};
|
};
|
||||||
typedef product_type_selector<rows_select, cols_select, depth_select> selector;
|
typedef product_type_selector<rows_select, cols_select, depth_select> selector;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum { value = selector::ret, ret = selector::ret };
|
enum {
|
||||||
|
value = selector::ret,
|
||||||
|
ret = selector::ret
|
||||||
|
};
|
||||||
#ifdef EIGEN_DEBUG_PRODUCT
|
#ifdef EIGEN_DEBUG_PRODUCT
|
||||||
static void debug() {
|
static void debug()
|
||||||
EIGEN_DEBUG_VAR(Rows);
|
{
|
||||||
EIGEN_DEBUG_VAR(Cols);
|
EIGEN_DEBUG_VAR(Rows);
|
||||||
EIGEN_DEBUG_VAR(Depth);
|
EIGEN_DEBUG_VAR(Cols);
|
||||||
EIGEN_DEBUG_VAR(rows_select);
|
EIGEN_DEBUG_VAR(Depth);
|
||||||
EIGEN_DEBUG_VAR(cols_select);
|
EIGEN_DEBUG_VAR(rows_select);
|
||||||
EIGEN_DEBUG_VAR(depth_select);
|
EIGEN_DEBUG_VAR(cols_select);
|
||||||
EIGEN_DEBUG_VAR(value);
|
EIGEN_DEBUG_VAR(depth_select);
|
||||||
|
EIGEN_DEBUG_VAR(value);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
@@ -89,125 +95,54 @@ struct product_type {
|
|||||||
/* The following allows to select the kind of product at compile time
|
/* The following allows to select the kind of product at compile time
|
||||||
* based on the three dimensions of the product.
|
* based on the three dimensions of the product.
|
||||||
* This is a compile time mapping from {1,Small,Large}^3 -> {product types} */
|
* This is a compile time mapping from {1,Small,Large}^3 -> {product types} */
|
||||||
// FIXME: the current compile-time product-type mapping may not be optimal.
|
// FIXME I'm not sure the current mapping is the ideal one.
|
||||||
template <int M, int N>
|
template<int M, int N> struct product_type_selector<M,N,1> { enum { ret = OuterProduct }; };
|
||||||
struct product_type_selector<M, N, 1> {
|
template<int M> struct product_type_selector<M, 1, 1> { enum { ret = LazyCoeffBasedProductMode }; };
|
||||||
enum { ret = OuterProduct };
|
template<int N> struct product_type_selector<1, N, 1> { enum { ret = LazyCoeffBasedProductMode }; };
|
||||||
};
|
template<int Depth> struct product_type_selector<1, 1, Depth> { enum { ret = InnerProduct }; };
|
||||||
template <int M>
|
template<> struct product_type_selector<1, 1, 1> { enum { ret = InnerProduct }; };
|
||||||
struct product_type_selector<M, 1, 1> {
|
template<> struct product_type_selector<Small,1, Small> { enum { ret = CoeffBasedProductMode }; };
|
||||||
enum { ret = LazyCoeffBasedProductMode };
|
template<> struct product_type_selector<1, Small,Small> { enum { ret = CoeffBasedProductMode }; };
|
||||||
};
|
template<> struct product_type_selector<Small,Small,Small> { enum { ret = CoeffBasedProductMode }; };
|
||||||
template <int N>
|
template<> struct product_type_selector<Small, Small, 1> { enum { ret = LazyCoeffBasedProductMode }; };
|
||||||
struct product_type_selector<1, N, 1> {
|
template<> struct product_type_selector<Small, Large, 1> { enum { ret = LazyCoeffBasedProductMode }; };
|
||||||
enum { ret = LazyCoeffBasedProductMode };
|
template<> struct product_type_selector<Large, Small, 1> { enum { ret = LazyCoeffBasedProductMode }; };
|
||||||
};
|
template<> struct product_type_selector<1, Large,Small> { enum { ret = CoeffBasedProductMode }; };
|
||||||
template <int Depth>
|
template<> struct product_type_selector<1, Large,Large> { enum { ret = GemvProduct }; };
|
||||||
struct product_type_selector<1, 1, Depth> {
|
template<> struct product_type_selector<1, Small,Large> { enum { ret = CoeffBasedProductMode }; };
|
||||||
enum { ret = InnerProduct };
|
template<> struct product_type_selector<Large,1, Small> { enum { ret = CoeffBasedProductMode }; };
|
||||||
};
|
template<> struct product_type_selector<Large,1, Large> { enum { ret = GemvProduct }; };
|
||||||
template <>
|
template<> struct product_type_selector<Small,1, Large> { enum { ret = CoeffBasedProductMode }; };
|
||||||
struct product_type_selector<1, 1, 1> {
|
template<> struct product_type_selector<Small,Small,Large> { enum { ret = GemmProduct }; };
|
||||||
enum { ret = InnerProduct };
|
template<> struct product_type_selector<Large,Small,Large> { enum { ret = GemmProduct }; };
|
||||||
};
|
template<> struct product_type_selector<Small,Large,Large> { enum { ret = GemmProduct }; };
|
||||||
template <>
|
template<> struct product_type_selector<Large,Large,Large> { enum { ret = GemmProduct }; };
|
||||||
struct product_type_selector<Small, 1, Small> {
|
template<> struct product_type_selector<Large,Small,Small> { enum { ret = CoeffBasedProductMode }; };
|
||||||
enum { ret = CoeffBasedProductMode };
|
template<> struct product_type_selector<Small,Large,Small> { enum { ret = CoeffBasedProductMode }; };
|
||||||
};
|
template<> struct product_type_selector<Large,Large,Small> { enum { ret = GemmProduct }; };
|
||||||
template <>
|
|
||||||
struct product_type_selector<1, Small, Small> {
|
|
||||||
enum { ret = CoeffBasedProductMode };
|
|
||||||
};
|
|
||||||
template <>
|
|
||||||
struct product_type_selector<Small, Small, Small> {
|
|
||||||
enum { ret = CoeffBasedProductMode };
|
|
||||||
};
|
|
||||||
template <>
|
|
||||||
struct product_type_selector<Small, Small, 1> {
|
|
||||||
enum { ret = LazyCoeffBasedProductMode };
|
|
||||||
};
|
|
||||||
template <>
|
|
||||||
struct product_type_selector<Small, Large, 1> {
|
|
||||||
enum { ret = LazyCoeffBasedProductMode };
|
|
||||||
};
|
|
||||||
template <>
|
|
||||||
struct product_type_selector<Large, Small, 1> {
|
|
||||||
enum { ret = LazyCoeffBasedProductMode };
|
|
||||||
};
|
|
||||||
template <>
|
|
||||||
struct product_type_selector<1, Large, Small> {
|
|
||||||
enum { ret = CoeffBasedProductMode };
|
|
||||||
};
|
|
||||||
template <>
|
|
||||||
struct product_type_selector<1, Large, Large> {
|
|
||||||
enum { ret = GemvProduct };
|
|
||||||
};
|
|
||||||
template <>
|
|
||||||
struct product_type_selector<1, Small, Large> {
|
|
||||||
enum { ret = CoeffBasedProductMode };
|
|
||||||
};
|
|
||||||
template <>
|
|
||||||
struct product_type_selector<Large, 1, Small> {
|
|
||||||
enum { ret = CoeffBasedProductMode };
|
|
||||||
};
|
|
||||||
template <>
|
|
||||||
struct product_type_selector<Large, 1, Large> {
|
|
||||||
enum { ret = GemvProduct };
|
|
||||||
};
|
|
||||||
template <>
|
|
||||||
struct product_type_selector<Small, 1, Large> {
|
|
||||||
enum { ret = CoeffBasedProductMode };
|
|
||||||
};
|
|
||||||
template <>
|
|
||||||
struct product_type_selector<Small, Small, Large> {
|
|
||||||
enum { ret = GemmProduct };
|
|
||||||
};
|
|
||||||
template <>
|
|
||||||
struct product_type_selector<Large, Small, Large> {
|
|
||||||
enum { ret = GemmProduct };
|
|
||||||
};
|
|
||||||
template <>
|
|
||||||
struct product_type_selector<Small, Large, Large> {
|
|
||||||
enum { ret = GemmProduct };
|
|
||||||
};
|
|
||||||
template <>
|
|
||||||
struct product_type_selector<Large, Large, Large> {
|
|
||||||
enum { ret = GemmProduct };
|
|
||||||
};
|
|
||||||
template <>
|
|
||||||
struct product_type_selector<Large, Small, Small> {
|
|
||||||
enum { ret = CoeffBasedProductMode };
|
|
||||||
};
|
|
||||||
template <>
|
|
||||||
struct product_type_selector<Small, Large, Small> {
|
|
||||||
enum { ret = CoeffBasedProductMode };
|
|
||||||
};
|
|
||||||
template <>
|
|
||||||
struct product_type_selector<Large, Large, Small> {
|
|
||||||
enum { ret = GemmProduct };
|
|
||||||
};
|
|
||||||
|
|
||||||
} // end namespace internal
|
} // end namespace internal
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* Implementation of Inner Vector Vector Product
|
* Implementation of Inner Vector Vector Product
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
// FIXME: consider returning a Scalar instead of a 1x1 matrix for inner products.
|
// FIXME : maybe the "inner product" could return a Scalar
|
||||||
// Pro: more natural for the user.
|
// instead of a 1x1 matrix ??
|
||||||
// Con: in a meta-unrolled algorithm a matrix-matrix product may reduce to a
|
// Pro: more natural for the user
|
||||||
// row-vector times column-vector product. To handle this, we could specialize
|
// Cons: this could be a problem if in a meta unrolled algorithm a matrix-matrix
|
||||||
// Block<MatrixType,1,1> with operator=(Scalar x).
|
// product ends up to a row-vector times col-vector product... To tackle this use
|
||||||
|
// case, we could have a specialization for Block<MatrixType,1,1> with: operator=(Scalar x);
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* Implementation of Outer Vector Vector Product
|
* Implementation of Outer Vector Vector Product
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* Implementation of General Matrix Vector Product
|
* Implementation of General Matrix Vector Product
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
/* According to the shape/flags of the matrix we have to distinguish 3 different cases:
|
/* According to the shape/flags of the matrix we have to distinghish 3 different cases:
|
||||||
* 1 - the matrix is col-major, BLAS compatible and M is large => call fast BLAS-like colmajor routine
|
* 1 - the matrix is col-major, BLAS compatible and M is large => call fast BLAS-like colmajor routine
|
||||||
* 2 - the matrix is row-major, BLAS compatible and N is large => call fast BLAS-like rowmajor routine
|
* 2 - the matrix is row-major, BLAS compatible and N is large => call fast BLAS-like rowmajor routine
|
||||||
* 3 - all other cases are handled using a simple loop along the outer-storage direction.
|
* 3 - all other cases are handled using a simple loop along the outer-storage direction.
|
||||||
@@ -216,72 +151,79 @@ struct product_type_selector<Large, Large, Small> {
|
|||||||
*/
|
*/
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
template <int Side, int StorageOrder, bool BlasCompatible>
|
template<int Side, int StorageOrder, bool BlasCompatible>
|
||||||
struct gemv_dense_selector;
|
struct gemv_dense_selector;
|
||||||
|
|
||||||
} // end namespace internal
|
} // end namespace internal
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
template <typename Scalar, int Size, int MaxSize, bool Cond>
|
template<typename Scalar,int Size,int MaxSize,bool Cond> struct gemv_static_vector_if;
|
||||||
struct gemv_static_vector_if;
|
|
||||||
|
|
||||||
template <typename Scalar, int Size, int MaxSize>
|
template<typename Scalar,int Size,int MaxSize>
|
||||||
struct gemv_static_vector_if<Scalar, Size, MaxSize, false> {
|
struct gemv_static_vector_if<Scalar,Size,MaxSize,false>
|
||||||
EIGEN_DEVICE_FUNC constexpr Scalar* data() {
|
{
|
||||||
eigen_internal_assert(false && "should never be called");
|
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Scalar* data() { eigen_internal_assert(false && "should never be called"); return 0; }
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Scalar, int Size>
|
template<typename Scalar,int Size>
|
||||||
struct gemv_static_vector_if<Scalar, Size, Dynamic, true> {
|
struct gemv_static_vector_if<Scalar,Size,Dynamic,true>
|
||||||
EIGEN_DEVICE_FUNC constexpr Scalar* data() { return 0; }
|
{
|
||||||
|
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Scalar* data() { return 0; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Scalar, int Size, int MaxSize>
|
template<typename Scalar,int Size,int MaxSize>
|
||||||
struct gemv_static_vector_if<Scalar, Size, MaxSize, true> {
|
struct gemv_static_vector_if<Scalar,Size,MaxSize,true>
|
||||||
#if EIGEN_MAX_STATIC_ALIGN_BYTES != 0
|
{
|
||||||
internal::plain_array<Scalar, internal::min_size_prefer_fixed(Size, MaxSize), 0, AlignedMax> m_data;
|
enum {
|
||||||
constexpr Scalar* data() { return m_data.array; }
|
ForceAlignment = internal::packet_traits<Scalar>::Vectorizable,
|
||||||
#else
|
PacketSize = internal::packet_traits<Scalar>::size
|
||||||
|
};
|
||||||
|
#if EIGEN_MAX_STATIC_ALIGN_BYTES!=0
|
||||||
|
internal::plain_array<Scalar,EIGEN_SIZE_MIN_PREFER_FIXED(Size,MaxSize),0,EIGEN_PLAIN_ENUM_MIN(AlignedMax,PacketSize)> m_data;
|
||||||
|
EIGEN_STRONG_INLINE Scalar* data() { return m_data.array; }
|
||||||
|
#else
|
||||||
// Some architectures cannot align on the stack,
|
// Some architectures cannot align on the stack,
|
||||||
// => let's manually enforce alignment by allocating more data and return the address of the first aligned element.
|
// => let's manually enforce alignment by allocating more data and return the address of the first aligned element.
|
||||||
internal::plain_array<Scalar, internal::min_size_prefer_fixed(Size, MaxSize) + EIGEN_MAX_ALIGN_BYTES, 0> m_data;
|
internal::plain_array<Scalar,EIGEN_SIZE_MIN_PREFER_FIXED(Size,MaxSize)+(ForceAlignment?EIGEN_MAX_ALIGN_BYTES:0),0> m_data;
|
||||||
constexpr Scalar* data() {
|
EIGEN_STRONG_INLINE Scalar* data() {
|
||||||
return reinterpret_cast<Scalar*>((std::uintptr_t(m_data.array) & ~(std::size_t(EIGEN_MAX_ALIGN_BYTES - 1))) +
|
return ForceAlignment
|
||||||
EIGEN_MAX_ALIGN_BYTES);
|
? reinterpret_cast<Scalar*>((internal::UIntPtr(m_data.array) & ~(std::size_t(EIGEN_MAX_ALIGN_BYTES-1))) + EIGEN_MAX_ALIGN_BYTES)
|
||||||
|
: m_data.array;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
// The vector is on the left => transposition
|
// The vector is on the left => transposition
|
||||||
template <int StorageOrder, bool BlasCompatible>
|
template<int StorageOrder, bool BlasCompatible>
|
||||||
struct gemv_dense_selector<OnTheLeft, StorageOrder, BlasCompatible> {
|
struct gemv_dense_selector<OnTheLeft,StorageOrder,BlasCompatible>
|
||||||
template <typename Lhs, typename Rhs, typename Dest>
|
{
|
||||||
static void run(const Lhs& lhs, const Rhs& rhs, Dest& dest, const typename Dest::Scalar& alpha) {
|
template<typename Lhs, typename Rhs, typename Dest>
|
||||||
|
static void run(const Lhs &lhs, const Rhs &rhs, Dest& dest, const typename Dest::Scalar& alpha)
|
||||||
|
{
|
||||||
Transpose<Dest> destT(dest);
|
Transpose<Dest> destT(dest);
|
||||||
enum { OtherStorageOrder = StorageOrder == RowMajor ? ColMajor : RowMajor };
|
enum { OtherStorageOrder = StorageOrder == RowMajor ? ColMajor : RowMajor };
|
||||||
gemv_dense_selector<OnTheRight, OtherStorageOrder, BlasCompatible>::run(rhs.transpose(), lhs.transpose(), destT,
|
gemv_dense_selector<OnTheRight,OtherStorageOrder,BlasCompatible>
|
||||||
alpha);
|
::run(rhs.transpose(), lhs.transpose(), destT, alpha);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template<> struct gemv_dense_selector<OnTheRight,ColMajor,true>
|
||||||
struct gemv_dense_selector<OnTheRight, ColMajor, true> {
|
{
|
||||||
template <typename Lhs, typename Rhs, typename Dest>
|
template<typename Lhs, typename Rhs, typename Dest>
|
||||||
static inline void run(const Lhs& lhs, const Rhs& rhs, Dest& dest, const typename Dest::Scalar& alpha) {
|
static inline void run(const Lhs &lhs, const Rhs &rhs, Dest& dest, const typename Dest::Scalar& alpha)
|
||||||
typedef typename Lhs::Scalar LhsScalar;
|
{
|
||||||
typedef typename Rhs::Scalar RhsScalar;
|
typedef typename Lhs::Scalar LhsScalar;
|
||||||
typedef typename Dest::Scalar ResScalar;
|
typedef typename Rhs::Scalar RhsScalar;
|
||||||
|
typedef typename Dest::Scalar ResScalar;
|
||||||
|
typedef typename Dest::RealScalar RealScalar;
|
||||||
|
|
||||||
typedef internal::blas_traits<Lhs> LhsBlasTraits;
|
typedef internal::blas_traits<Lhs> LhsBlasTraits;
|
||||||
typedef typename LhsBlasTraits::DirectLinearAccessType ActualLhsType;
|
typedef typename LhsBlasTraits::DirectLinearAccessType ActualLhsType;
|
||||||
typedef internal::blas_traits<Rhs> RhsBlasTraits;
|
typedef internal::blas_traits<Rhs> RhsBlasTraits;
|
||||||
typedef typename RhsBlasTraits::DirectLinearAccessType ActualRhsType;
|
typedef typename RhsBlasTraits::DirectLinearAccessType ActualRhsType;
|
||||||
|
|
||||||
typedef Map<Matrix<ResScalar, Dynamic, 1>, plain_enum_min(AlignedMax, internal::packet_traits<ResScalar>::size)>
|
typedef Map<Matrix<ResScalar,Dynamic,1>, EIGEN_PLAIN_ENUM_MIN(AlignedMax,internal::packet_traits<ResScalar>::size)> MappedDest;
|
||||||
MappedDest;
|
|
||||||
|
|
||||||
ActualLhsType actualLhs = LhsBlasTraits::extract(lhs);
|
ActualLhsType actualLhs = LhsBlasTraits::extract(lhs);
|
||||||
ActualRhsType actualRhs = RhsBlasTraits::extract(rhs);
|
ActualRhsType actualRhs = RhsBlasTraits::extract(rhs);
|
||||||
@@ -289,64 +231,68 @@ struct gemv_dense_selector<OnTheRight, ColMajor, true> {
|
|||||||
ResScalar actualAlpha = combine_scalar_factors(alpha, lhs, rhs);
|
ResScalar actualAlpha = combine_scalar_factors(alpha, lhs, rhs);
|
||||||
|
|
||||||
// make sure Dest is a compile-time vector type (bug 1166)
|
// make sure Dest is a compile-time vector type (bug 1166)
|
||||||
typedef std::conditional_t<Dest::IsVectorAtCompileTime, Dest, typename Dest::ColXpr> ActualDest;
|
typedef typename conditional<Dest::IsVectorAtCompileTime, Dest, typename Dest::ColXpr>::type ActualDest;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
// FIXME: find a way to allow an inner stride on the result if packet_traits<Scalar>::size==1
|
// FIXME find a way to allow an inner stride on the result if packet_traits<Scalar>::size==1
|
||||||
// on, the other hand it is good for the cache to pack the vector anyways...
|
// on, the other hand it is good for the cache to pack the vector anyways...
|
||||||
EvalToDestAtCompileTime = (ActualDest::InnerStrideAtCompileTime == 1),
|
EvalToDestAtCompileTime = (ActualDest::InnerStrideAtCompileTime==1),
|
||||||
ComplexByReal = (NumTraits<LhsScalar>::IsComplex) && (!NumTraits<RhsScalar>::IsComplex),
|
ComplexByReal = (NumTraits<LhsScalar>::IsComplex) && (!NumTraits<RhsScalar>::IsComplex),
|
||||||
MightCannotUseDest = ((!EvalToDestAtCompileTime) || ComplexByReal) && (ActualDest::MaxSizeAtCompileTime != 0)
|
MightCannotUseDest = ((!EvalToDestAtCompileTime) || ComplexByReal) && (ActualDest::MaxSizeAtCompileTime!=0)
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef const_blas_data_mapper<LhsScalar, Index, ColMajor> LhsMapper;
|
typedef const_blas_data_mapper<LhsScalar,Index,ColMajor> LhsMapper;
|
||||||
typedef const_blas_data_mapper<RhsScalar, Index, RowMajor> RhsMapper;
|
typedef const_blas_data_mapper<RhsScalar,Index,RowMajor> RhsMapper;
|
||||||
RhsScalar compatibleAlpha = get_factor<ResScalar, RhsScalar>::run(actualAlpha);
|
RhsScalar compatibleAlpha = get_factor<ResScalar,RhsScalar>::run(actualAlpha);
|
||||||
|
|
||||||
if (!MightCannotUseDest) {
|
if(!MightCannotUseDest)
|
||||||
|
{
|
||||||
// shortcut if we are sure to be able to use dest directly,
|
// shortcut if we are sure to be able to use dest directly,
|
||||||
// this ease the compiler to generate cleaner and more optimzized code for most common cases
|
// this ease the compiler to generate cleaner and more optimzized code for most common cases
|
||||||
general_matrix_vector_product<Index, LhsScalar, LhsMapper, ColMajor, LhsBlasTraits::NeedToConjugate, RhsScalar,
|
general_matrix_vector_product
|
||||||
RhsMapper, RhsBlasTraits::NeedToConjugate>::run(actualLhs.rows(), actualLhs.cols(),
|
<Index,LhsScalar,LhsMapper,ColMajor,LhsBlasTraits::NeedToConjugate,RhsScalar,RhsMapper,RhsBlasTraits::NeedToConjugate>::run(
|
||||||
LhsMapper(actualLhs.data(),
|
actualLhs.rows(), actualLhs.cols(),
|
||||||
actualLhs.outerStride()),
|
LhsMapper(actualLhs.data(), actualLhs.outerStride()),
|
||||||
RhsMapper(actualRhs.data(),
|
RhsMapper(actualRhs.data(), actualRhs.innerStride()),
|
||||||
actualRhs.innerStride()),
|
dest.data(), 1,
|
||||||
dest.data(), 1, compatibleAlpha);
|
compatibleAlpha);
|
||||||
} else {
|
}
|
||||||
gemv_static_vector_if<ResScalar, ActualDest::SizeAtCompileTime, ActualDest::MaxSizeAtCompileTime,
|
else
|
||||||
MightCannotUseDest>
|
{
|
||||||
static_dest;
|
gemv_static_vector_if<ResScalar,ActualDest::SizeAtCompileTime,ActualDest::MaxSizeAtCompileTime,MightCannotUseDest> static_dest;
|
||||||
|
|
||||||
const bool alphaIsCompatible = (!ComplexByReal) || (numext::is_exactly_zero(numext::imag(actualAlpha)));
|
const bool alphaIsCompatible = (!ComplexByReal) || (numext::imag(actualAlpha)==RealScalar(0));
|
||||||
const bool evalToDest = EvalToDestAtCompileTime && alphaIsCompatible;
|
const bool evalToDest = EvalToDestAtCompileTime && alphaIsCompatible;
|
||||||
|
|
||||||
ei_declare_aligned_stack_constructed_variable(ResScalar, actualDestPtr, dest.size(),
|
ei_declare_aligned_stack_constructed_variable(ResScalar,actualDestPtr,dest.size(),
|
||||||
evalToDest ? dest.data() : static_dest.data());
|
evalToDest ? dest.data() : static_dest.data());
|
||||||
|
|
||||||
if (!evalToDest) {
|
if(!evalToDest)
|
||||||
#ifdef EIGEN_DENSE_STORAGE_CTOR_PLUGIN
|
{
|
||||||
constexpr int Size = Dest::SizeAtCompileTime;
|
#ifdef EIGEN_DENSE_STORAGE_CTOR_PLUGIN
|
||||||
Index size = dest.size();
|
Index size = dest.size();
|
||||||
EIGEN_DENSE_STORAGE_CTOR_PLUGIN
|
EIGEN_DENSE_STORAGE_CTOR_PLUGIN
|
||||||
#endif
|
#endif
|
||||||
if (!alphaIsCompatible) {
|
if(!alphaIsCompatible)
|
||||||
|
{
|
||||||
MappedDest(actualDestPtr, dest.size()).setZero();
|
MappedDest(actualDestPtr, dest.size()).setZero();
|
||||||
compatibleAlpha = RhsScalar(1);
|
compatibleAlpha = RhsScalar(1);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
MappedDest(actualDestPtr, dest.size()) = dest;
|
MappedDest(actualDestPtr, dest.size()) = dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
general_matrix_vector_product<Index, LhsScalar, LhsMapper, ColMajor, LhsBlasTraits::NeedToConjugate, RhsScalar,
|
general_matrix_vector_product
|
||||||
RhsMapper, RhsBlasTraits::NeedToConjugate>::run(actualLhs.rows(), actualLhs.cols(),
|
<Index,LhsScalar,LhsMapper,ColMajor,LhsBlasTraits::NeedToConjugate,RhsScalar,RhsMapper,RhsBlasTraits::NeedToConjugate>::run(
|
||||||
LhsMapper(actualLhs.data(),
|
actualLhs.rows(), actualLhs.cols(),
|
||||||
actualLhs.outerStride()),
|
LhsMapper(actualLhs.data(), actualLhs.outerStride()),
|
||||||
RhsMapper(actualRhs.data(),
|
RhsMapper(actualRhs.data(), actualRhs.innerStride()),
|
||||||
actualRhs.innerStride()),
|
actualDestPtr, 1,
|
||||||
actualDestPtr, 1, compatibleAlpha);
|
compatibleAlpha);
|
||||||
|
|
||||||
if (!evalToDest) {
|
if (!evalToDest)
|
||||||
if (!alphaIsCompatible)
|
{
|
||||||
|
if(!alphaIsCompatible)
|
||||||
dest.matrix() += actualAlpha * MappedDest(actualDestPtr, dest.size());
|
dest.matrix() += actualAlpha * MappedDest(actualDestPtr, dest.size());
|
||||||
else
|
else
|
||||||
dest = MappedDest(actualDestPtr, dest.size());
|
dest = MappedDest(actualDestPtr, dest.size());
|
||||||
@@ -355,164 +301,165 @@ struct gemv_dense_selector<OnTheRight, ColMajor, true> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template<> struct gemv_dense_selector<OnTheRight,RowMajor,true>
|
||||||
struct gemv_dense_selector<OnTheRight, RowMajor, true> {
|
{
|
||||||
template <typename Lhs, typename Rhs, typename Dest>
|
template<typename Lhs, typename Rhs, typename Dest>
|
||||||
static void run(const Lhs& lhs, const Rhs& rhs, Dest& dest, const typename Dest::Scalar& alpha) {
|
static void run(const Lhs &lhs, const Rhs &rhs, Dest& dest, const typename Dest::Scalar& alpha)
|
||||||
typedef typename Lhs::Scalar LhsScalar;
|
{
|
||||||
typedef typename Rhs::Scalar RhsScalar;
|
typedef typename Lhs::Scalar LhsScalar;
|
||||||
typedef typename Dest::Scalar ResScalar;
|
typedef typename Rhs::Scalar RhsScalar;
|
||||||
|
typedef typename Dest::Scalar ResScalar;
|
||||||
|
|
||||||
typedef internal::blas_traits<Lhs> LhsBlasTraits;
|
typedef internal::blas_traits<Lhs> LhsBlasTraits;
|
||||||
typedef typename LhsBlasTraits::DirectLinearAccessType ActualLhsType;
|
typedef typename LhsBlasTraits::DirectLinearAccessType ActualLhsType;
|
||||||
typedef internal::blas_traits<Rhs> RhsBlasTraits;
|
typedef internal::blas_traits<Rhs> RhsBlasTraits;
|
||||||
typedef typename RhsBlasTraits::DirectLinearAccessType ActualRhsType;
|
typedef typename RhsBlasTraits::DirectLinearAccessType ActualRhsType;
|
||||||
typedef internal::remove_all_t<ActualRhsType> ActualRhsTypeCleaned;
|
typedef typename internal::remove_all<ActualRhsType>::type ActualRhsTypeCleaned;
|
||||||
|
|
||||||
std::add_const_t<ActualLhsType> actualLhs = LhsBlasTraits::extract(lhs);
|
typename add_const<ActualLhsType>::type actualLhs = LhsBlasTraits::extract(lhs);
|
||||||
std::add_const_t<ActualRhsType> actualRhs = RhsBlasTraits::extract(rhs);
|
typename add_const<ActualRhsType>::type actualRhs = RhsBlasTraits::extract(rhs);
|
||||||
|
|
||||||
ResScalar actualAlpha = combine_scalar_factors(alpha, lhs, rhs);
|
ResScalar actualAlpha = combine_scalar_factors(alpha, lhs, rhs);
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
// FIXME: find a way to allow an inner stride on the result if packet_traits<Scalar>::size==1
|
// FIXME find a way to allow an inner stride on the result if packet_traits<Scalar>::size==1
|
||||||
// on, the other hand it is good for the cache to pack the vector anyways...
|
// on, the other hand it is good for the cache to pack the vector anyways...
|
||||||
DirectlyUseRhs =
|
DirectlyUseRhs = ActualRhsTypeCleaned::InnerStrideAtCompileTime==1 || ActualRhsTypeCleaned::MaxSizeAtCompileTime==0
|
||||||
ActualRhsTypeCleaned::InnerStrideAtCompileTime == 1 || ActualRhsTypeCleaned::MaxSizeAtCompileTime == 0
|
|
||||||
};
|
};
|
||||||
|
|
||||||
gemv_static_vector_if<RhsScalar, ActualRhsTypeCleaned::SizeAtCompileTime,
|
gemv_static_vector_if<RhsScalar,ActualRhsTypeCleaned::SizeAtCompileTime,ActualRhsTypeCleaned::MaxSizeAtCompileTime,!DirectlyUseRhs> static_rhs;
|
||||||
ActualRhsTypeCleaned::MaxSizeAtCompileTime, !DirectlyUseRhs>
|
|
||||||
static_rhs;
|
|
||||||
|
|
||||||
ei_declare_aligned_stack_constructed_variable(
|
ei_declare_aligned_stack_constructed_variable(RhsScalar,actualRhsPtr,actualRhs.size(),
|
||||||
RhsScalar, actualRhsPtr, actualRhs.size(),
|
|
||||||
DirectlyUseRhs ? const_cast<RhsScalar*>(actualRhs.data()) : static_rhs.data());
|
DirectlyUseRhs ? const_cast<RhsScalar*>(actualRhs.data()) : static_rhs.data());
|
||||||
|
|
||||||
if (!DirectlyUseRhs) {
|
if(!DirectlyUseRhs)
|
||||||
#ifdef EIGEN_DENSE_STORAGE_CTOR_PLUGIN
|
{
|
||||||
constexpr int Size = ActualRhsTypeCleaned::SizeAtCompileTime;
|
#ifdef EIGEN_DENSE_STORAGE_CTOR_PLUGIN
|
||||||
Index size = actualRhs.size();
|
Index size = actualRhs.size();
|
||||||
EIGEN_DENSE_STORAGE_CTOR_PLUGIN
|
EIGEN_DENSE_STORAGE_CTOR_PLUGIN
|
||||||
#endif
|
#endif
|
||||||
Map<typename ActualRhsTypeCleaned::PlainObject>(actualRhsPtr, actualRhs.size()) = actualRhs;
|
Map<typename ActualRhsTypeCleaned::PlainObject>(actualRhsPtr, actualRhs.size()) = actualRhs;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef const_blas_data_mapper<LhsScalar, Index, RowMajor> LhsMapper;
|
typedef const_blas_data_mapper<LhsScalar,Index,RowMajor> LhsMapper;
|
||||||
typedef const_blas_data_mapper<RhsScalar, Index, ColMajor> RhsMapper;
|
typedef const_blas_data_mapper<RhsScalar,Index,ColMajor> RhsMapper;
|
||||||
general_matrix_vector_product<Index, LhsScalar, LhsMapper, RowMajor, LhsBlasTraits::NeedToConjugate, RhsScalar,
|
general_matrix_vector_product
|
||||||
RhsMapper, RhsBlasTraits::NeedToConjugate>::
|
<Index,LhsScalar,LhsMapper,RowMajor,LhsBlasTraits::NeedToConjugate,RhsScalar,RhsMapper,RhsBlasTraits::NeedToConjugate>::run(
|
||||||
run(actualLhs.rows(), actualLhs.cols(), LhsMapper(actualLhs.data(), actualLhs.outerStride()),
|
actualLhs.rows(), actualLhs.cols(),
|
||||||
RhsMapper(actualRhsPtr, 1), dest.data(),
|
LhsMapper(actualLhs.data(), actualLhs.outerStride()),
|
||||||
dest.col(0).innerStride(), // NOTE if dest is not a vector at compile-time, then dest.innerStride() might
|
RhsMapper(actualRhsPtr, 1),
|
||||||
// be wrong. (bug 1166)
|
dest.data(), dest.col(0).innerStride(), //NOTE if dest is not a vector at compile-time, then dest.innerStride() might be wrong. (bug 1166)
|
||||||
actualAlpha);
|
actualAlpha);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template<> struct gemv_dense_selector<OnTheRight,ColMajor,false>
|
||||||
struct gemv_dense_selector<OnTheRight, ColMajor, false> {
|
{
|
||||||
template <typename Lhs, typename Rhs, typename Dest>
|
template<typename Lhs, typename Rhs, typename Dest>
|
||||||
static void run(const Lhs& lhs, const Rhs& rhs, Dest& dest, const typename Dest::Scalar& alpha) {
|
static void run(const Lhs &lhs, const Rhs &rhs, Dest& dest, const typename Dest::Scalar& alpha)
|
||||||
EIGEN_STATIC_ASSERT((!nested_eval<Lhs, 1>::Evaluate),
|
{
|
||||||
EIGEN_INTERNAL_COMPILATION_ERROR_OR_YOU_MADE_A_PROGRAMMING_MISTAKE);
|
EIGEN_STATIC_ASSERT((!nested_eval<Lhs,1>::Evaluate),EIGEN_INTERNAL_COMPILATION_ERROR_OR_YOU_MADE_A_PROGRAMMING_MISTAKE);
|
||||||
// TODO: if rhs is large enough it might be beneficial to make sure that dest is sequentially stored in memory,
|
// TODO if rhs is large enough it might be beneficial to make sure that dest is sequentially stored in memory, otherwise use a temp
|
||||||
// otherwise use a temp
|
typename nested_eval<Rhs,1>::type actual_rhs(rhs);
|
||||||
typename nested_eval<Rhs, 1>::type actual_rhs(rhs);
|
|
||||||
const Index size = rhs.rows();
|
const Index size = rhs.rows();
|
||||||
for (Index k = 0; k < size; ++k) dest += (alpha * actual_rhs.coeff(k)) * lhs.col(k);
|
for(Index k=0; k<size; ++k)
|
||||||
|
dest += (alpha*actual_rhs.coeff(k)) * lhs.col(k);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template<> struct gemv_dense_selector<OnTheRight,RowMajor,false>
|
||||||
struct gemv_dense_selector<OnTheRight, RowMajor, false> {
|
{
|
||||||
template <typename Lhs, typename Rhs, typename Dest>
|
template<typename Lhs, typename Rhs, typename Dest>
|
||||||
static void run(const Lhs& lhs, const Rhs& rhs, Dest& dest, const typename Dest::Scalar& alpha) {
|
static void run(const Lhs &lhs, const Rhs &rhs, Dest& dest, const typename Dest::Scalar& alpha)
|
||||||
EIGEN_STATIC_ASSERT((!nested_eval<Lhs, 1>::Evaluate),
|
{
|
||||||
EIGEN_INTERNAL_COMPILATION_ERROR_OR_YOU_MADE_A_PROGRAMMING_MISTAKE);
|
EIGEN_STATIC_ASSERT((!nested_eval<Lhs,1>::Evaluate),EIGEN_INTERNAL_COMPILATION_ERROR_OR_YOU_MADE_A_PROGRAMMING_MISTAKE);
|
||||||
typename nested_eval<Rhs, Lhs::RowsAtCompileTime>::type actual_rhs(rhs);
|
typename nested_eval<Rhs,Lhs::RowsAtCompileTime>::type actual_rhs(rhs);
|
||||||
const Index rows = dest.rows();
|
const Index rows = dest.rows();
|
||||||
for (Index i = 0; i < rows; ++i)
|
for(Index i=0; i<rows; ++i)
|
||||||
dest.coeffRef(i) += alpha * (lhs.row(i).cwiseProduct(actual_rhs.transpose())).sum();
|
dest.coeffRef(i) += alpha * (lhs.row(i).cwiseProduct(actual_rhs.transpose())).sum();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace internal
|
} // end namespace internal
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* Implementation of matrix base methods
|
* Implementation of matrix base methods
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
/** \returns the matrix product of \c *this and \a other.
|
/** \returns the matrix product of \c *this and \a other.
|
||||||
*
|
*
|
||||||
* \note If instead of the matrix product you want the coefficient-wise product, see Cwise::operator*().
|
* \note If instead of the matrix product you want the coefficient-wise product, see Cwise::operator*().
|
||||||
*
|
*
|
||||||
* \sa lazyProduct(), operator*=(const MatrixBase&), Cwise::operator*()
|
* \sa lazyProduct(), operator*=(const MatrixBase&), Cwise::operator*()
|
||||||
*/
|
*/
|
||||||
template <typename Derived>
|
template<typename Derived>
|
||||||
template <typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Product<Derived, OtherDerived> MatrixBase<Derived>::operator*(
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||||
const MatrixBase<OtherDerived>& other) const {
|
const Product<Derived, OtherDerived>
|
||||||
|
MatrixBase<Derived>::operator*(const MatrixBase<OtherDerived> &other) const
|
||||||
|
{
|
||||||
// A note regarding the function declaration: In MSVC, this function will sometimes
|
// A note regarding the function declaration: In MSVC, this function will sometimes
|
||||||
// not be inlined since DenseStorage is an unwindable object for dynamic
|
// not be inlined since DenseStorage is an unwindable object for dynamic
|
||||||
// matrices and product types are holding a member to store the result.
|
// matrices and product types are holding a member to store the result.
|
||||||
// Thus it does not help tagging this function with EIGEN_STRONG_INLINE.
|
// Thus it does not help tagging this function with EIGEN_STRONG_INLINE.
|
||||||
enum {
|
enum {
|
||||||
ProductIsValid = Derived::ColsAtCompileTime == Dynamic || OtherDerived::RowsAtCompileTime == Dynamic ||
|
ProductIsValid = Derived::ColsAtCompileTime==Dynamic
|
||||||
int(Derived::ColsAtCompileTime) == int(OtherDerived::RowsAtCompileTime),
|
|| OtherDerived::RowsAtCompileTime==Dynamic
|
||||||
|
|| int(Derived::ColsAtCompileTime)==int(OtherDerived::RowsAtCompileTime),
|
||||||
AreVectors = Derived::IsVectorAtCompileTime && OtherDerived::IsVectorAtCompileTime,
|
AreVectors = Derived::IsVectorAtCompileTime && OtherDerived::IsVectorAtCompileTime,
|
||||||
SameSizes = EIGEN_PREDICATE_SAME_MATRIX_SIZE(Derived, OtherDerived)
|
SameSizes = EIGEN_PREDICATE_SAME_MATRIX_SIZE(Derived,OtherDerived)
|
||||||
};
|
};
|
||||||
// note to the lost user:
|
// note to the lost user:
|
||||||
// * for a dot product use: v1.dot(v2)
|
// * for a dot product use: v1.dot(v2)
|
||||||
// * for a coeff-wise product use: v1.cwiseProduct(v2)
|
// * for a coeff-wise product use: v1.cwiseProduct(v2)
|
||||||
EIGEN_STATIC_ASSERT(
|
EIGEN_STATIC_ASSERT(ProductIsValid || !(AreVectors && SameSizes),
|
||||||
ProductIsValid || !(AreVectors && SameSizes),
|
INVALID_VECTOR_VECTOR_PRODUCT__IF_YOU_WANTED_A_DOT_OR_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTIONS)
|
||||||
INVALID_VECTOR_VECTOR_PRODUCT__IF_YOU_WANTED_A_DOT_OR_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTIONS)
|
|
||||||
EIGEN_STATIC_ASSERT(ProductIsValid || !(SameSizes && !AreVectors),
|
EIGEN_STATIC_ASSERT(ProductIsValid || !(SameSizes && !AreVectors),
|
||||||
INVALID_MATRIX_PRODUCT__IF_YOU_WANTED_A_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTION)
|
INVALID_MATRIX_PRODUCT__IF_YOU_WANTED_A_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTION)
|
||||||
EIGEN_STATIC_ASSERT(ProductIsValid || SameSizes, INVALID_MATRIX_PRODUCT)
|
EIGEN_STATIC_ASSERT(ProductIsValid || SameSizes, INVALID_MATRIX_PRODUCT)
|
||||||
#ifdef EIGEN_DEBUG_PRODUCT
|
#ifdef EIGEN_DEBUG_PRODUCT
|
||||||
internal::product_type<Derived, OtherDerived>::debug();
|
internal::product_type<Derived,OtherDerived>::debug();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return Product<Derived, OtherDerived>(derived(), other.derived());
|
return Product<Derived, OtherDerived>(derived(), other.derived());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \returns an expression of the matrix product of \c *this and \a other without implicit evaluation.
|
/** \returns an expression of the matrix product of \c *this and \a other without implicit evaluation.
|
||||||
*
|
*
|
||||||
* The returned product will behave like any other expressions: the coefficients of the product will be
|
* The returned product will behave like any other expressions: the coefficients of the product will be
|
||||||
* computed once at a time as requested. This might be useful in some extremely rare cases when only
|
* computed once at a time as requested. This might be useful in some extremely rare cases when only
|
||||||
* a small and no coherent fraction of the result's coefficients have to be computed.
|
* a small and no coherent fraction of the result's coefficients have to be computed.
|
||||||
*
|
*
|
||||||
* \warning This version of the matrix product can be much much slower. So use it only if you know
|
* \warning This version of the matrix product can be much much slower. So use it only if you know
|
||||||
* what you are doing and that you measured a true speed improvement.
|
* what you are doing and that you measured a true speed improvement.
|
||||||
*
|
*
|
||||||
* \sa operator*(const MatrixBase&)
|
* \sa operator*(const MatrixBase&)
|
||||||
*/
|
*/
|
||||||
template <typename Derived>
|
template<typename Derived>
|
||||||
template <typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Product<Derived, OtherDerived, LazyProduct>
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||||
MatrixBase<Derived>::lazyProduct(const MatrixBase<OtherDerived>& other) const {
|
const Product<Derived,OtherDerived,LazyProduct>
|
||||||
|
MatrixBase<Derived>::lazyProduct(const MatrixBase<OtherDerived> &other) const
|
||||||
|
{
|
||||||
enum {
|
enum {
|
||||||
ProductIsValid = Derived::ColsAtCompileTime == Dynamic || OtherDerived::RowsAtCompileTime == Dynamic ||
|
ProductIsValid = Derived::ColsAtCompileTime==Dynamic
|
||||||
int(Derived::ColsAtCompileTime) == int(OtherDerived::RowsAtCompileTime),
|
|| OtherDerived::RowsAtCompileTime==Dynamic
|
||||||
|
|| int(Derived::ColsAtCompileTime)==int(OtherDerived::RowsAtCompileTime),
|
||||||
AreVectors = Derived::IsVectorAtCompileTime && OtherDerived::IsVectorAtCompileTime,
|
AreVectors = Derived::IsVectorAtCompileTime && OtherDerived::IsVectorAtCompileTime,
|
||||||
SameSizes = EIGEN_PREDICATE_SAME_MATRIX_SIZE(Derived, OtherDerived)
|
SameSizes = EIGEN_PREDICATE_SAME_MATRIX_SIZE(Derived,OtherDerived)
|
||||||
};
|
};
|
||||||
// note to the lost user:
|
// note to the lost user:
|
||||||
// * for a dot product use: v1.dot(v2)
|
// * for a dot product use: v1.dot(v2)
|
||||||
// * for a coeff-wise product use: v1.cwiseProduct(v2)
|
// * for a coeff-wise product use: v1.cwiseProduct(v2)
|
||||||
EIGEN_STATIC_ASSERT(
|
EIGEN_STATIC_ASSERT(ProductIsValid || !(AreVectors && SameSizes),
|
||||||
ProductIsValid || !(AreVectors && SameSizes),
|
INVALID_VECTOR_VECTOR_PRODUCT__IF_YOU_WANTED_A_DOT_OR_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTIONS)
|
||||||
INVALID_VECTOR_VECTOR_PRODUCT__IF_YOU_WANTED_A_DOT_OR_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTIONS)
|
|
||||||
EIGEN_STATIC_ASSERT(ProductIsValid || !(SameSizes && !AreVectors),
|
EIGEN_STATIC_ASSERT(ProductIsValid || !(SameSizes && !AreVectors),
|
||||||
INVALID_MATRIX_PRODUCT__IF_YOU_WANTED_A_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTION)
|
INVALID_MATRIX_PRODUCT__IF_YOU_WANTED_A_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTION)
|
||||||
EIGEN_STATIC_ASSERT(ProductIsValid || SameSizes, INVALID_MATRIX_PRODUCT)
|
EIGEN_STATIC_ASSERT(ProductIsValid || SameSizes, INVALID_MATRIX_PRODUCT)
|
||||||
|
|
||||||
return Product<Derived, OtherDerived, LazyProduct>(derived(), other.derived());
|
return Product<Derived,OtherDerived,LazyProduct>(derived(), other.derived());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end namespace Eigen
|
} // end namespace Eigen
|
||||||
|
|
||||||
#endif // EIGEN_PRODUCT_H
|
#endif // EIGEN_PRODUCT_H
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -13,218 +13,182 @@
|
|||||||
|
|
||||||
#ifdef EIGEN_PARSED_BY_DOXYGEN
|
#ifdef EIGEN_PARSED_BY_DOXYGEN
|
||||||
|
|
||||||
#define EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(NAME, FUNCTOR, DOC_OP, DOC_DETAILS) \
|
#define EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(NAME,FUNCTOR,DOC_OP,DOC_DETAILS) \
|
||||||
/** \returns an expression of the coefficient-wise DOC_OP of \a x \
|
/** \returns an expression of the coefficient-wise DOC_OP of \a x
|
||||||
\ \
|
|
||||||
DOC_DETAILS \
|
DOC_DETAILS
|
||||||
\ \
|
|
||||||
\sa <a href="group__CoeffwiseMathFunctions.html#cwisetable_##NAME">Math functions</a>, class CwiseUnaryOp \
|
\sa <a href="group__CoeffwiseMathFunctions.html#cwisetable_##NAME">Math functions</a>, class CwiseUnaryOp
|
||||||
*/ \
|
*/ \
|
||||||
template <typename Derived> \
|
template<typename Derived> \
|
||||||
inline const Eigen::CwiseUnaryOp<Eigen::internal::FUNCTOR<typename Derived::Scalar>, const Derived> NAME( \
|
inline const Eigen::CwiseUnaryOp<Eigen::internal::FUNCTOR<typename Derived::Scalar>, const Derived> \
|
||||||
const Eigen::ArrayBase<Derived>& x);
|
NAME(const Eigen::ArrayBase<Derived>& x);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#define EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(NAME, FUNCTOR, DOC_OP, DOC_DETAILS) \
|
#define EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(NAME,FUNCTOR,DOC_OP,DOC_DETAILS) \
|
||||||
template <typename Derived> \
|
template<typename Derived> \
|
||||||
inline const Eigen::CwiseUnaryOp<Eigen::internal::FUNCTOR<typename Derived::Scalar>, const Derived>(NAME)( \
|
inline const Eigen::CwiseUnaryOp<Eigen::internal::FUNCTOR<typename Derived::Scalar>, const Derived> \
|
||||||
const Eigen::ArrayBase<Derived>& x) { \
|
(NAME)(const Eigen::ArrayBase<Derived>& x) { \
|
||||||
return Eigen::CwiseUnaryOp<Eigen::internal::FUNCTOR<typename Derived::Scalar>, const Derived>(x.derived()); \
|
return Eigen::CwiseUnaryOp<Eigen::internal::FUNCTOR<typename Derived::Scalar>, const Derived>(x.derived()); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // EIGEN_PARSED_BY_DOXYGEN
|
#endif // EIGEN_PARSED_BY_DOXYGEN
|
||||||
|
|
||||||
#define EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(NAME, FUNCTOR) \
|
#define EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(NAME,FUNCTOR) \
|
||||||
\
|
\
|
||||||
template <typename Derived> \
|
template<typename Derived> \
|
||||||
struct NAME##_retval<ArrayBase<Derived> > { \
|
struct NAME##_retval<ArrayBase<Derived> > \
|
||||||
|
{ \
|
||||||
typedef const Eigen::CwiseUnaryOp<Eigen::internal::FUNCTOR<typename Derived::Scalar>, const Derived> type; \
|
typedef const Eigen::CwiseUnaryOp<Eigen::internal::FUNCTOR<typename Derived::Scalar>, const Derived> type; \
|
||||||
}; \
|
}; \
|
||||||
template <typename Derived> \
|
template<typename Derived> \
|
||||||
struct NAME##_impl<ArrayBase<Derived> > { \
|
struct NAME##_impl<ArrayBase<Derived> > \
|
||||||
static inline typename NAME##_retval<ArrayBase<Derived> >::type run(const Eigen::ArrayBase<Derived>& x) { \
|
{ \
|
||||||
return typename NAME##_retval<ArrayBase<Derived> >::type(x.derived()); \
|
static inline typename NAME##_retval<ArrayBase<Derived> >::type run(const Eigen::ArrayBase<Derived>& x) \
|
||||||
} \
|
{ \
|
||||||
|
return typename NAME##_retval<ArrayBase<Derived> >::type(x.derived()); \
|
||||||
|
} \
|
||||||
};
|
};
|
||||||
|
|
||||||
// IWYU pragma: private
|
namespace Eigen
|
||||||
#include "./InternalHeaderCheck.h"
|
{
|
||||||
|
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(real,scalar_real_op,real part,\sa ArrayBase::real)
|
||||||
|
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(imag,scalar_imag_op,imaginary part,\sa ArrayBase::imag)
|
||||||
|
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(conj,scalar_conjugate_op,complex conjugate,\sa ArrayBase::conjugate)
|
||||||
|
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(inverse,scalar_inverse_op,inverse,\sa ArrayBase::inverse)
|
||||||
|
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(sin,scalar_sin_op,sine,\sa ArrayBase::sin)
|
||||||
|
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(cos,scalar_cos_op,cosine,\sa ArrayBase::cos)
|
||||||
|
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(tan,scalar_tan_op,tangent,\sa ArrayBase::tan)
|
||||||
|
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(atan,scalar_atan_op,arc-tangent,\sa ArrayBase::atan)
|
||||||
|
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(asin,scalar_asin_op,arc-sine,\sa ArrayBase::asin)
|
||||||
|
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(acos,scalar_acos_op,arc-consine,\sa ArrayBase::acos)
|
||||||
|
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(sinh,scalar_sinh_op,hyperbolic sine,\sa ArrayBase::sinh)
|
||||||
|
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(cosh,scalar_cosh_op,hyperbolic cosine,\sa ArrayBase::cosh)
|
||||||
|
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(tanh,scalar_tanh_op,hyperbolic tangent,\sa ArrayBase::tanh)
|
||||||
|
#if EIGEN_HAS_CXX11_MATH
|
||||||
|
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(asinh,scalar_asinh_op,inverse hyperbolic sine,\sa ArrayBase::asinh)
|
||||||
|
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(acosh,scalar_acosh_op,inverse hyperbolic cosine,\sa ArrayBase::acosh)
|
||||||
|
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(atanh,scalar_atanh_op,inverse hyperbolic tangent,\sa ArrayBase::atanh)
|
||||||
|
#endif
|
||||||
|
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(logistic,scalar_logistic_op,logistic function,\sa ArrayBase::logistic)
|
||||||
|
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(lgamma,scalar_lgamma_op,natural logarithm of the gamma function,\sa ArrayBase::lgamma)
|
||||||
|
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(digamma,scalar_digamma_op,derivative of lgamma,\sa ArrayBase::digamma)
|
||||||
|
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(erf,scalar_erf_op,error function,\sa ArrayBase::erf)
|
||||||
|
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(erfc,scalar_erfc_op,complement error function,\sa ArrayBase::erfc)
|
||||||
|
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(ndtri,scalar_ndtri_op,inverse normal distribution function,\sa ArrayBase::ndtri)
|
||||||
|
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(exp,scalar_exp_op,exponential,\sa ArrayBase::exp)
|
||||||
|
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(expm1,scalar_expm1_op,exponential of a value minus 1,\sa ArrayBase::expm1)
|
||||||
|
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(log,scalar_log_op,natural logarithm,\sa Eigen::log10 DOXCOMMA ArrayBase::log)
|
||||||
|
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(log1p,scalar_log1p_op,natural logarithm of 1 plus the value,\sa ArrayBase::log1p)
|
||||||
|
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(log10,scalar_log10_op,base 10 logarithm,\sa Eigen::log DOXCOMMA ArrayBase::log10)
|
||||||
|
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(log2,scalar_log2_op,base 2 logarithm,\sa Eigen::log DOXCOMMA ArrayBase::log2)
|
||||||
|
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(abs,scalar_abs_op,absolute value,\sa ArrayBase::abs DOXCOMMA MatrixBase::cwiseAbs)
|
||||||
|
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(abs2,scalar_abs2_op,squared absolute value,\sa ArrayBase::abs2 DOXCOMMA MatrixBase::cwiseAbs2)
|
||||||
|
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(arg,scalar_arg_op,complex argument,\sa ArrayBase::arg DOXCOMMA MatrixBase::cwiseArg)
|
||||||
|
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(sqrt,scalar_sqrt_op,square root,\sa ArrayBase::sqrt DOXCOMMA MatrixBase::cwiseSqrt)
|
||||||
|
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(rsqrt,scalar_rsqrt_op,reciprocal square root,\sa ArrayBase::rsqrt)
|
||||||
|
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(square,scalar_square_op,square (power 2),\sa Eigen::abs2 DOXCOMMA Eigen::pow DOXCOMMA ArrayBase::square)
|
||||||
|
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(cube,scalar_cube_op,cube (power 3),\sa Eigen::pow DOXCOMMA ArrayBase::cube)
|
||||||
|
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(rint,scalar_rint_op,nearest integer,\sa Eigen::floor DOXCOMMA Eigen::ceil DOXCOMMA ArrayBase::round)
|
||||||
|
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(round,scalar_round_op,nearest integer,\sa Eigen::floor DOXCOMMA Eigen::ceil DOXCOMMA ArrayBase::round)
|
||||||
|
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(floor,scalar_floor_op,nearest integer not greater than the giben value,\sa Eigen::ceil DOXCOMMA ArrayBase::floor)
|
||||||
|
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(ceil,scalar_ceil_op,nearest integer not less than the giben value,\sa Eigen::floor DOXCOMMA ArrayBase::ceil)
|
||||||
|
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(isnan,scalar_isnan_op,not-a-number test,\sa Eigen::isinf DOXCOMMA Eigen::isfinite DOXCOMMA ArrayBase::isnan)
|
||||||
|
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(isinf,scalar_isinf_op,infinite value test,\sa Eigen::isnan DOXCOMMA Eigen::isfinite DOXCOMMA ArrayBase::isinf)
|
||||||
|
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(isfinite,scalar_isfinite_op,finite value test,\sa Eigen::isinf DOXCOMMA Eigen::isnan DOXCOMMA ArrayBase::isfinite)
|
||||||
|
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(sign,scalar_sign_op,sign (or 0),\sa ArrayBase::sign)
|
||||||
|
|
||||||
namespace Eigen {
|
/** \returns an expression of the coefficient-wise power of \a x to the given constant \a exponent.
|
||||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(real, scalar_real_op, real part,\sa ArrayBase::real)
|
*
|
||||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(imag, scalar_imag_op, imaginary part,\sa ArrayBase::imag)
|
* \tparam ScalarExponent is the scalar type of \a exponent. It must be compatible with the scalar type of the given expression (\c Derived::Scalar).
|
||||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(conj, scalar_conjugate_op, complex conjugate,\sa ArrayBase::conjugate)
|
*
|
||||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(inverse, scalar_inverse_op, inverse,\sa ArrayBase::inverse)
|
* \sa ArrayBase::pow()
|
||||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(sin, scalar_sin_op, sine,\sa ArrayBase::sin)
|
*
|
||||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(cos, scalar_cos_op, cosine,\sa ArrayBase::cos)
|
* \relates ArrayBase
|
||||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(tan, scalar_tan_op, tangent,\sa ArrayBase::tan)
|
*/
|
||||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(atan, scalar_atan_op, arc - tangent,\sa ArrayBase::atan)
|
|
||||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(asin, scalar_asin_op, arc - sine,\sa ArrayBase::asin)
|
|
||||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(acos, scalar_acos_op, arc - consine,\sa ArrayBase::acos)
|
|
||||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(sinh, scalar_sinh_op, hyperbolic sine,\sa ArrayBase::sinh)
|
|
||||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(cosh, scalar_cosh_op, hyperbolic cosine,\sa ArrayBase::cosh)
|
|
||||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(tanh, scalar_tanh_op, hyperbolic tangent,\sa ArrayBase::tanh)
|
|
||||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(asinh, scalar_asinh_op, inverse hyperbolic sine,\sa ArrayBase::asinh)
|
|
||||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(acosh, scalar_acosh_op, inverse hyperbolic cosine,\sa ArrayBase::acosh)
|
|
||||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(atanh, scalar_atanh_op, inverse hyperbolic tangent,\sa ArrayBase::atanh)
|
|
||||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(logistic, scalar_logistic_op, logistic function,\sa ArrayBase::logistic)
|
|
||||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(lgamma, scalar_lgamma_op,
|
|
||||||
natural logarithm of the gamma function,\sa ArrayBase::lgamma)
|
|
||||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(digamma, scalar_digamma_op, derivative of lgamma,\sa ArrayBase::digamma)
|
|
||||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(erf, scalar_erf_op, error function,\sa ArrayBase::erf)
|
|
||||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(erfc, scalar_erfc_op, complement error function,\sa ArrayBase::erfc)
|
|
||||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(ndtri, scalar_ndtri_op, inverse normal distribution function,\sa ArrayBase::ndtri)
|
|
||||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(exp, scalar_exp_op, exponential,\sa ArrayBase::exp)
|
|
||||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(exp2, scalar_exp2_op, exponential,\sa ArrayBase::exp2)
|
|
||||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(expm1, scalar_expm1_op, exponential of a value minus 1,\sa ArrayBase::expm1)
|
|
||||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(log, scalar_log_op, natural logarithm,\sa Eigen::log10 DOXCOMMA ArrayBase::log)
|
|
||||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(log1p, scalar_log1p_op, natural logarithm of 1 plus the value,\sa ArrayBase::log1p)
|
|
||||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(log10, scalar_log10_op, base 10 logarithm,\sa Eigen::log DOXCOMMA ArrayBase::log10)
|
|
||||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(log2, scalar_log2_op, base 2 logarithm,\sa Eigen::log DOXCOMMA ArrayBase::log2)
|
|
||||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(abs, scalar_abs_op, absolute value,\sa ArrayBase::abs DOXCOMMA MatrixBase::cwiseAbs)
|
|
||||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(abs2, scalar_abs2_op,
|
|
||||||
squared absolute value,\sa ArrayBase::abs2 DOXCOMMA MatrixBase::cwiseAbs2)
|
|
||||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(arg, scalar_arg_op, complex argument,\sa ArrayBase::arg DOXCOMMA MatrixBase::cwiseArg)
|
|
||||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(carg, scalar_carg_op,
|
|
||||||
complex argument, \sa ArrayBase::carg DOXCOMMA MatrixBase::cwiseCArg)
|
|
||||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(sqrt, scalar_sqrt_op, square root,\sa ArrayBase::sqrt DOXCOMMA MatrixBase::cwiseSqrt)
|
|
||||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(cbrt, scalar_cbrt_op, cube root,\sa ArrayBase::cbrt DOXCOMMA MatrixBase::cwiseCbrt)
|
|
||||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(rsqrt, scalar_rsqrt_op, reciprocal square root,\sa ArrayBase::rsqrt)
|
|
||||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(square, scalar_square_op,
|
|
||||||
square(power 2),\sa Eigen::abs2 DOXCOMMA Eigen::pow DOXCOMMA ArrayBase::square)
|
|
||||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(cube, scalar_cube_op, cube(power 3),\sa Eigen::pow DOXCOMMA ArrayBase::cube)
|
|
||||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(rint, scalar_rint_op,
|
|
||||||
nearest integer,\sa Eigen::floor DOXCOMMA Eigen::ceil DOXCOMMA ArrayBase::round)
|
|
||||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(round, scalar_round_op,
|
|
||||||
nearest integer,\sa Eigen::floor DOXCOMMA Eigen::ceil DOXCOMMA ArrayBase::round)
|
|
||||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(
|
|
||||||
floor, scalar_floor_op, nearest integer not greater than the given value,\sa Eigen::ceil DOXCOMMA ArrayBase::floor)
|
|
||||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(
|
|
||||||
ceil, scalar_ceil_op, nearest integer not less than the given value,\sa Eigen::floor DOXCOMMA ArrayBase::ceil)
|
|
||||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(trunc, scalar_trunc_op,
|
|
||||||
nearest integer not greater in magnitude than the given value,\sa Eigen::trunc DOXCOMMA
|
|
||||||
ArrayBase::trunc)
|
|
||||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(
|
|
||||||
isnan, scalar_isnan_op, not -a - number test,\sa Eigen::isinf DOXCOMMA Eigen::isfinite DOXCOMMA ArrayBase::isnan)
|
|
||||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(
|
|
||||||
isinf, scalar_isinf_op, infinite value test,\sa Eigen::isnan DOXCOMMA Eigen::isfinite DOXCOMMA ArrayBase::isinf)
|
|
||||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(isfinite, scalar_isfinite_op,
|
|
||||||
finite value test,\sa Eigen::isinf DOXCOMMA Eigen::isnan DOXCOMMA ArrayBase::isfinite)
|
|
||||||
EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(sign, scalar_sign_op, sign(or 0),\sa ArrayBase::sign)
|
|
||||||
|
|
||||||
template <typename Derived, typename ScalarExponent>
|
|
||||||
using GlobalUnaryPowReturnType = std::enable_if_t<
|
|
||||||
!internal::is_arithmetic<typename NumTraits<Derived>::Real>::value &&
|
|
||||||
internal::is_arithmetic<typename NumTraits<ScalarExponent>::Real>::value,
|
|
||||||
CwiseUnaryOp<internal::scalar_unary_pow_op<typename Derived::Scalar, ScalarExponent>, const Derived> >;
|
|
||||||
|
|
||||||
/** \returns an expression of the coefficient-wise power of \a x to the given constant \a exponent.
|
|
||||||
*
|
|
||||||
* \tparam ScalarExponent is the scalar type of \a exponent. It must be compatible with the scalar type of the given
|
|
||||||
* expression (\c Derived::Scalar).
|
|
||||||
*
|
|
||||||
* \sa ArrayBase::pow()
|
|
||||||
*
|
|
||||||
* \relates ArrayBase
|
|
||||||
*/
|
|
||||||
#ifdef EIGEN_PARSED_BY_DOXYGEN
|
#ifdef EIGEN_PARSED_BY_DOXYGEN
|
||||||
template <typename Derived, typename ScalarExponent>
|
template<typename Derived,typename ScalarExponent>
|
||||||
EIGEN_DEVICE_FUNC constexpr inline const GlobalUnaryPowReturnType<Derived, ScalarExponent> pow(
|
inline const CwiseBinaryOp<internal::scalar_pow_op<Derived::Scalar,ScalarExponent>,Derived,Constant<ScalarExponent> >
|
||||||
const Eigen::ArrayBase<Derived>& x, const ScalarExponent& exponent);
|
pow(const Eigen::ArrayBase<Derived>& x, const ScalarExponent& exponent);
|
||||||
#else
|
#else
|
||||||
template <typename Derived, typename ScalarExponent>
|
template <typename Derived,typename ScalarExponent>
|
||||||
EIGEN_DEVICE_FUNC constexpr inline const GlobalUnaryPowReturnType<Derived, ScalarExponent> pow(
|
EIGEN_DEVICE_FUNC inline
|
||||||
const Eigen::ArrayBase<Derived>& x, const ScalarExponent& exponent) {
|
EIGEN_MSVC10_WORKAROUND_BINARYOP_RETURN_TYPE(
|
||||||
return GlobalUnaryPowReturnType<Derived, ScalarExponent>(
|
const EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(Derived,typename internal::promote_scalar_arg<typename Derived::Scalar
|
||||||
x.derived(), internal::scalar_unary_pow_op<typename Derived::Scalar, ScalarExponent>(exponent));
|
EIGEN_COMMA ScalarExponent EIGEN_COMMA
|
||||||
}
|
EIGEN_SCALAR_BINARY_SUPPORTED(pow,typename Derived::Scalar,ScalarExponent)>::type,pow))
|
||||||
|
pow(const Eigen::ArrayBase<Derived>& x, const ScalarExponent& exponent)
|
||||||
|
{
|
||||||
|
typedef typename internal::promote_scalar_arg<typename Derived::Scalar,ScalarExponent,
|
||||||
|
EIGEN_SCALAR_BINARY_SUPPORTED(pow,typename Derived::Scalar,ScalarExponent)>::type PromotedExponent;
|
||||||
|
return EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(Derived,PromotedExponent,pow)(x.derived(),
|
||||||
|
typename internal::plain_constant_type<Derived,PromotedExponent>::type(x.derived().rows(), x.derived().cols(), internal::scalar_constant_op<PromotedExponent>(exponent)));
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** \returns an expression of the coefficient-wise power of \a x to the given array of \a exponents.
|
/** \returns an expression of the coefficient-wise power of \a x to the given array of \a exponents.
|
||||||
*
|
*
|
||||||
* This function computes the coefficient-wise power.
|
* This function computes the coefficient-wise power.
|
||||||
*
|
*
|
||||||
* Example: \include Cwise_array_power_array.cpp
|
* Example: \include Cwise_array_power_array.cpp
|
||||||
* Output: \verbinclude Cwise_array_power_array.out
|
* Output: \verbinclude Cwise_array_power_array.out
|
||||||
*
|
*
|
||||||
* \sa ArrayBase::pow()
|
* \sa ArrayBase::pow()
|
||||||
*
|
*
|
||||||
* \relates ArrayBase
|
* \relates ArrayBase
|
||||||
*/
|
*/
|
||||||
template <typename Derived, typename ExponentDerived>
|
template<typename Derived,typename ExponentDerived>
|
||||||
inline const Eigen::CwiseBinaryOp<
|
inline const Eigen::CwiseBinaryOp<Eigen::internal::scalar_pow_op<typename Derived::Scalar, typename ExponentDerived::Scalar>, const Derived, const ExponentDerived>
|
||||||
Eigen::internal::scalar_pow_op<typename Derived::Scalar, typename ExponentDerived::Scalar>, const Derived,
|
pow(const Eigen::ArrayBase<Derived>& x, const Eigen::ArrayBase<ExponentDerived>& exponents)
|
||||||
const ExponentDerived>
|
{
|
||||||
pow(const Eigen::ArrayBase<Derived>& x, const Eigen::ArrayBase<ExponentDerived>& exponents) {
|
return Eigen::CwiseBinaryOp<Eigen::internal::scalar_pow_op<typename Derived::Scalar, typename ExponentDerived::Scalar>, const Derived, const ExponentDerived>(
|
||||||
return Eigen::CwiseBinaryOp<
|
x.derived(),
|
||||||
Eigen::internal::scalar_pow_op<typename Derived::Scalar, typename ExponentDerived::Scalar>, const Derived,
|
exponents.derived()
|
||||||
const ExponentDerived>(x.derived(), exponents.derived());
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \returns an expression of the coefficient-wise power of the scalar \a x to the given array of \a exponents.
|
/** \returns an expression of the coefficient-wise power of the scalar \a x to the given array of \a exponents.
|
||||||
*
|
*
|
||||||
* This function computes the coefficient-wise power between a scalar and an array of exponents.
|
* This function computes the coefficient-wise power between a scalar and an array of exponents.
|
||||||
*
|
*
|
||||||
* \tparam Scalar is the scalar type of \a x. It must be compatible with the scalar type of the given array expression
|
* \tparam Scalar is the scalar type of \a x. It must be compatible with the scalar type of the given array expression (\c Derived::Scalar).
|
||||||
* (\c Derived::Scalar).
|
*
|
||||||
*
|
* Example: \include Cwise_scalar_power_array.cpp
|
||||||
* Example: \include Cwise_scalar_power_array.cpp
|
* Output: \verbinclude Cwise_scalar_power_array.out
|
||||||
* Output: \verbinclude Cwise_scalar_power_array.out
|
*
|
||||||
*
|
* \sa ArrayBase::pow()
|
||||||
* \sa ArrayBase::pow()
|
*
|
||||||
*
|
* \relates ArrayBase
|
||||||
* \relates ArrayBase
|
*/
|
||||||
*/
|
|
||||||
#ifdef EIGEN_PARSED_BY_DOXYGEN
|
#ifdef EIGEN_PARSED_BY_DOXYGEN
|
||||||
template <typename Scalar, typename Derived>
|
template<typename Scalar,typename Derived>
|
||||||
inline const CwiseBinaryOp<internal::scalar_pow_op<Scalar, Derived::Scalar>, Constant<Scalar>, Derived> pow(
|
inline const CwiseBinaryOp<internal::scalar_pow_op<Scalar,Derived::Scalar>,Constant<Scalar>,Derived>
|
||||||
const Scalar& x, const Eigen::ArrayBase<Derived>& x);
|
pow(const Scalar& x,const Eigen::ArrayBase<Derived>& x);
|
||||||
#else
|
#else
|
||||||
template <typename Scalar, typename Derived>
|
template <typename Scalar, typename Derived>
|
||||||
EIGEN_DEVICE_FUNC inline const EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(
|
EIGEN_DEVICE_FUNC inline
|
||||||
typename internal::promote_scalar_arg<typename Derived::Scalar EIGEN_COMMA Scalar EIGEN_COMMA
|
EIGEN_MSVC10_WORKAROUND_BINARYOP_RETURN_TYPE(
|
||||||
EIGEN_SCALAR_BINARY_SUPPORTED(pow, Scalar,
|
const EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(typename internal::promote_scalar_arg<typename Derived::Scalar
|
||||||
typename Derived::Scalar)>::type,
|
EIGEN_COMMA Scalar EIGEN_COMMA
|
||||||
Derived, pow) pow(const Scalar& x, const Eigen::ArrayBase<Derived>& exponents) {
|
EIGEN_SCALAR_BINARY_SUPPORTED(pow,Scalar,typename Derived::Scalar)>::type,Derived,pow))
|
||||||
typedef
|
pow(const Scalar& x, const Eigen::ArrayBase<Derived>& exponents) {
|
||||||
typename internal::promote_scalar_arg<typename Derived::Scalar, Scalar,
|
typedef typename internal::promote_scalar_arg<typename Derived::Scalar,Scalar,
|
||||||
EIGEN_SCALAR_BINARY_SUPPORTED(pow, Scalar, typename Derived::Scalar)>::type
|
EIGEN_SCALAR_BINARY_SUPPORTED(pow,Scalar,typename Derived::Scalar)>::type PromotedScalar;
|
||||||
PromotedScalar;
|
return EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(PromotedScalar,Derived,pow)(
|
||||||
return EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(PromotedScalar, Derived, pow)(
|
typename internal::plain_constant_type<Derived,PromotedScalar>::type(exponents.derived().rows(), exponents.derived().cols(), internal::scalar_constant_op<PromotedScalar>(x)), exponents.derived());
|
||||||
typename internal::plain_constant_type<Derived, PromotedScalar>::type(
|
}
|
||||||
exponents.derived().rows(), exponents.derived().cols(), internal::scalar_constant_op<PromotedScalar>(x)),
|
|
||||||
exponents.derived());
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** \returns an expression of the coefficient-wise atan2(\a x, \a y). \a x and \a y must be of the same type.
|
|
||||||
*
|
namespace internal
|
||||||
* This function computes the coefficient-wise atan2().
|
{
|
||||||
*
|
EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(real,scalar_real_op)
|
||||||
* \sa ArrayBase::atan2()
|
EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(imag,scalar_imag_op)
|
||||||
*
|
EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(abs2,scalar_abs2_op)
|
||||||
* \relates ArrayBase
|
}
|
||||||
*/
|
|
||||||
template <typename LhsDerived, typename RhsDerived>
|
|
||||||
inline const std::enable_if_t<
|
|
||||||
std::is_same<typename LhsDerived::Scalar, typename RhsDerived::Scalar>::value,
|
|
||||||
Eigen::CwiseBinaryOp<Eigen::internal::scalar_atan2_op<typename LhsDerived::Scalar, typename RhsDerived::Scalar>,
|
|
||||||
const LhsDerived, const RhsDerived> >
|
|
||||||
atan2(const Eigen::ArrayBase<LhsDerived>& x, const Eigen::ArrayBase<RhsDerived>& exponents) {
|
|
||||||
return Eigen::CwiseBinaryOp<
|
|
||||||
Eigen::internal::scalar_atan2_op<typename LhsDerived::Scalar, typename RhsDerived::Scalar>, const LhsDerived,
|
|
||||||
const RhsDerived>(x.derived(), exponents.derived());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace internal {
|
// TODO: cleanly disable those functions that are not supported on Array (numext::real_ref, internal::random, internal::isApprox...)
|
||||||
EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(real, scalar_real_op)
|
|
||||||
EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(imag, scalar_imag_op)
|
|
||||||
EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(abs2, scalar_abs2_op)
|
|
||||||
} // namespace internal
|
|
||||||
} // namespace Eigen
|
|
||||||
|
|
||||||
// TODO: cleanly disable those functions that are not supported on Array (numext::real_ref, internal::random,
|
#endif // EIGEN_GLOBAL_FUNCTIONS_H
|
||||||
// internal::isApprox...)
|
|
||||||
|
|
||||||
#endif // EIGEN_GLOBAL_FUNCTIONS_H
|
|
||||||
|
|||||||
@@ -11,65 +11,60 @@
|
|||||||
#ifndef EIGEN_IO_H
|
#ifndef EIGEN_IO_H
|
||||||
#define EIGEN_IO_H
|
#define EIGEN_IO_H
|
||||||
|
|
||||||
// IWYU pragma: private
|
namespace Eigen {
|
||||||
#include "./InternalHeaderCheck.h"
|
|
||||||
|
|
||||||
namespace Eigen {
|
|
||||||
|
|
||||||
enum { DontAlignCols = 1 };
|
enum { DontAlignCols = 1 };
|
||||||
enum { StreamPrecision = -1, FullPrecision = -2 };
|
enum { StreamPrecision = -1,
|
||||||
|
FullPrecision = -2 };
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
template <typename Derived>
|
template<typename Derived>
|
||||||
std::ostream& print_matrix(std::ostream& s, const Derived& _m, const IOFormat& fmt);
|
std::ostream & print_matrix(std::ostream & s, const Derived& _m, const IOFormat& fmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \class IOFormat
|
/** \class IOFormat
|
||||||
* \ingroup Core_Module
|
* \ingroup Core_Module
|
||||||
*
|
*
|
||||||
* \brief Stores a set of parameters controlling the way matrices are printed
|
* \brief Stores a set of parameters controlling the way matrices are printed
|
||||||
*
|
*
|
||||||
* List of available parameters:
|
* List of available parameters:
|
||||||
* - \b precision number of digits for floating point values, or one of the special constants \c StreamPrecision and \c
|
* - \b precision number of digits for floating point values, or one of the special constants \c StreamPrecision and \c FullPrecision.
|
||||||
* FullPrecision. The default is the special value \c StreamPrecision which means to use the stream's own precision
|
* The default is the special value \c StreamPrecision which means to use the
|
||||||
* setting, as set for instance using \c cout.precision(3). The other special value \c FullPrecision means that the
|
* stream's own precision setting, as set for instance using \c cout.precision(3). The other special value
|
||||||
* number of digits will be computed to match the full precision of each floating-point type.
|
* \c FullPrecision means that the number of digits will be computed to match the full precision of each floating-point
|
||||||
* - \b flags an OR-ed combination of flags, the default value is 0, the only currently available flag is \c
|
* type.
|
||||||
* DontAlignCols which allows to disable the alignment of columns, resulting in faster code.
|
* - \b flags an OR-ed combination of flags, the default value is 0, the only currently available flag is \c DontAlignCols which
|
||||||
* - \b coeffSeparator string printed between two coefficients of the same row
|
* allows to disable the alignment of columns, resulting in faster code.
|
||||||
* - \b rowSeparator string printed between two rows
|
* - \b coeffSeparator string printed between two coefficients of the same row
|
||||||
* - \b rowPrefix string printed at the beginning of each row
|
* - \b rowSeparator string printed between two rows
|
||||||
* - \b rowSuffix string printed at the end of each row
|
* - \b rowPrefix string printed at the beginning of each row
|
||||||
* - \b matPrefix string printed at the beginning of the matrix
|
* - \b rowSuffix string printed at the end of each row
|
||||||
* - \b matSuffix string printed at the end of the matrix
|
* - \b matPrefix string printed at the beginning of the matrix
|
||||||
* - \b fill character printed to fill the empty space in aligned columns
|
* - \b matSuffix string printed at the end of the matrix
|
||||||
*
|
* - \b fill character printed to fill the empty space in aligned columns
|
||||||
* Example: \include IOFormat.cpp
|
*
|
||||||
* Output: \verbinclude IOFormat.out
|
* Example: \include IOFormat.cpp
|
||||||
*
|
* Output: \verbinclude IOFormat.out
|
||||||
* \sa DenseBase::format(), class WithFormat
|
*
|
||||||
*/
|
* \sa DenseBase::format(), class WithFormat
|
||||||
struct IOFormat {
|
*/
|
||||||
|
struct IOFormat
|
||||||
|
{
|
||||||
/** Default constructor, see class IOFormat for the meaning of the parameters */
|
/** Default constructor, see class IOFormat for the meaning of the parameters */
|
||||||
IOFormat(int _precision = StreamPrecision, int _flags = 0, const std::string& _coeffSeparator = " ",
|
IOFormat(int _precision = StreamPrecision, int _flags = 0,
|
||||||
const std::string& _rowSeparator = "\n", const std::string& _rowPrefix = "",
|
const std::string& _coeffSeparator = " ",
|
||||||
const std::string& _rowSuffix = "", const std::string& _matPrefix = "", const std::string& _matSuffix = "",
|
const std::string& _rowSeparator = "\n", const std::string& _rowPrefix="", const std::string& _rowSuffix="",
|
||||||
const char _fill = ' ')
|
const std::string& _matPrefix="", const std::string& _matSuffix="", const char _fill=' ')
|
||||||
: matPrefix(_matPrefix),
|
: matPrefix(_matPrefix), matSuffix(_matSuffix), rowPrefix(_rowPrefix), rowSuffix(_rowSuffix), rowSeparator(_rowSeparator),
|
||||||
matSuffix(_matSuffix),
|
rowSpacer(""), coeffSeparator(_coeffSeparator), fill(_fill), precision(_precision), flags(_flags)
|
||||||
rowPrefix(_rowPrefix),
|
{
|
||||||
rowSuffix(_rowSuffix),
|
// TODO check if rowPrefix, rowSuffix or rowSeparator contains a newline
|
||||||
rowSeparator(_rowSeparator),
|
|
||||||
rowSpacer(""),
|
|
||||||
coeffSeparator(_coeffSeparator),
|
|
||||||
fill(_fill),
|
|
||||||
precision(_precision),
|
|
||||||
flags(_flags) {
|
|
||||||
// TODO: check if rowPrefix, rowSuffix or rowSeparator contains a newline
|
|
||||||
// don't add rowSpacer if columns are not to be aligned
|
// don't add rowSpacer if columns are not to be aligned
|
||||||
if ((flags & DontAlignCols)) return;
|
if((flags & DontAlignCols))
|
||||||
int i = int(matPrefix.length()) - 1;
|
return;
|
||||||
while (i >= 0 && matPrefix[i] != '\n') {
|
int i = int(matSuffix.length())-1;
|
||||||
|
while (i>=0 && matSuffix[i]!='\n')
|
||||||
|
{
|
||||||
rowSpacer += ' ';
|
rowSpacer += ' ';
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
@@ -83,151 +78,181 @@ struct IOFormat {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/** \class WithFormat
|
/** \class WithFormat
|
||||||
* \ingroup Core_Module
|
* \ingroup Core_Module
|
||||||
*
|
*
|
||||||
* \brief Pseudo expression providing matrix output with given format
|
* \brief Pseudo expression providing matrix output with given format
|
||||||
*
|
*
|
||||||
* \tparam ExpressionType the type of the object on which IO stream operations are performed
|
* \tparam ExpressionType the type of the object on which IO stream operations are performed
|
||||||
*
|
*
|
||||||
* This class represents an expression with stream operators controlled by a given IOFormat.
|
* This class represents an expression with stream operators controlled by a given IOFormat.
|
||||||
* It is the return type of DenseBase::format()
|
* It is the return type of DenseBase::format()
|
||||||
* and most of the time this is the only way it is used.
|
* and most of the time this is the only way it is used.
|
||||||
*
|
*
|
||||||
* See class IOFormat for some examples.
|
* See class IOFormat for some examples.
|
||||||
*
|
*
|
||||||
* \sa DenseBase::format(), class IOFormat
|
* \sa DenseBase::format(), class IOFormat
|
||||||
*/
|
*/
|
||||||
template <typename ExpressionType>
|
template<typename ExpressionType>
|
||||||
class WithFormat {
|
class WithFormat
|
||||||
public:
|
{
|
||||||
WithFormat(const ExpressionType& matrix, const IOFormat& format) : m_matrix(matrix), m_format(format) {}
|
public:
|
||||||
|
|
||||||
friend std::ostream& operator<<(std::ostream& s, const WithFormat& wf) {
|
WithFormat(const ExpressionType& matrix, const IOFormat& format)
|
||||||
return internal::print_matrix(s, wf.m_matrix.eval(), wf.m_format);
|
: m_matrix(matrix), m_format(format)
|
||||||
}
|
{}
|
||||||
|
|
||||||
protected:
|
friend std::ostream & operator << (std::ostream & s, const WithFormat& wf)
|
||||||
typename ExpressionType::Nested m_matrix;
|
{
|
||||||
IOFormat m_format;
|
return internal::print_matrix(s, wf.m_matrix.eval(), wf.m_format);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
typename ExpressionType::Nested m_matrix;
|
||||||
|
IOFormat m_format;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
// NOTE: This helper is kept for backward compatibility with previous code specializing
|
// NOTE: This helper is kept for backward compatibility with previous code specializing
|
||||||
// this internal::significant_decimals_impl structure. In the future we should directly
|
// this internal::significant_decimals_impl structure. In the future we should directly
|
||||||
// call max_digits10().
|
// call digits10() which has been introduced in July 2016 in 3.3.
|
||||||
template <typename Scalar>
|
template<typename Scalar>
|
||||||
struct significant_decimals_impl {
|
struct significant_decimals_impl
|
||||||
static inline int run() { return NumTraits<Scalar>::max_digits10(); }
|
{
|
||||||
|
static inline int run()
|
||||||
|
{
|
||||||
|
return NumTraits<Scalar>::digits10();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** \internal
|
/** \internal
|
||||||
* print the matrix \a _m to the output stream \a s using the output format \a fmt */
|
* print the matrix \a _m to the output stream \a s using the output format \a fmt */
|
||||||
template <typename Derived>
|
template<typename Derived>
|
||||||
std::ostream& print_matrix(std::ostream& s, const Derived& _m, const IOFormat& fmt) {
|
std::ostream & print_matrix(std::ostream & s, const Derived& _m, const IOFormat& fmt)
|
||||||
|
{
|
||||||
using internal::is_same;
|
using internal::is_same;
|
||||||
|
using internal::conditional;
|
||||||
|
|
||||||
if (_m.size() == 0) {
|
if(_m.size() == 0)
|
||||||
|
{
|
||||||
s << fmt.matPrefix << fmt.matSuffix;
|
s << fmt.matPrefix << fmt.matSuffix;
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
typename Derived::Nested m = _m;
|
typename Derived::Nested m = _m;
|
||||||
typedef typename Derived::Scalar Scalar;
|
typedef typename Derived::Scalar Scalar;
|
||||||
typedef std::conditional_t<is_same<Scalar, char>::value || is_same<Scalar, unsigned char>::value ||
|
typedef typename
|
||||||
is_same<Scalar, numext::int8_t>::value || is_same<Scalar, numext::uint8_t>::value,
|
conditional<
|
||||||
int,
|
is_same<Scalar, char>::value ||
|
||||||
std::conditional_t<is_same<Scalar, std::complex<char> >::value ||
|
is_same<Scalar, unsigned char>::value ||
|
||||||
is_same<Scalar, std::complex<unsigned char> >::value ||
|
is_same<Scalar, numext::int8_t>::value ||
|
||||||
is_same<Scalar, std::complex<numext::int8_t> >::value ||
|
is_same<Scalar, numext::uint8_t>::value,
|
||||||
is_same<Scalar, std::complex<numext::uint8_t> >::value,
|
int,
|
||||||
std::complex<int>, const Scalar&> >
|
typename conditional<
|
||||||
PrintType;
|
is_same<Scalar, std::complex<char> >::value ||
|
||||||
|
is_same<Scalar, std::complex<unsigned char> >::value ||
|
||||||
|
is_same<Scalar, std::complex<numext::int8_t> >::value ||
|
||||||
|
is_same<Scalar, std::complex<numext::uint8_t> >::value,
|
||||||
|
std::complex<int>,
|
||||||
|
const Scalar&
|
||||||
|
>::type
|
||||||
|
>::type PrintType;
|
||||||
|
|
||||||
Index width = 0;
|
Index width = 0;
|
||||||
|
|
||||||
std::streamsize explicit_precision;
|
std::streamsize explicit_precision;
|
||||||
if (fmt.precision == StreamPrecision) {
|
if(fmt.precision == StreamPrecision)
|
||||||
|
{
|
||||||
explicit_precision = 0;
|
explicit_precision = 0;
|
||||||
} else if (fmt.precision == FullPrecision) {
|
}
|
||||||
if (NumTraits<Scalar>::IsInteger) {
|
else if(fmt.precision == FullPrecision)
|
||||||
|
{
|
||||||
|
if (NumTraits<Scalar>::IsInteger)
|
||||||
|
{
|
||||||
explicit_precision = 0;
|
explicit_precision = 0;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
explicit_precision = significant_decimals_impl<Scalar>::run();
|
explicit_precision = significant_decimals_impl<Scalar>::run();
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
explicit_precision = fmt.precision;
|
explicit_precision = fmt.precision;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::streamsize old_precision = 0;
|
std::streamsize old_precision = 0;
|
||||||
if (explicit_precision) old_precision = s.precision(explicit_precision);
|
if(explicit_precision) old_precision = s.precision(explicit_precision);
|
||||||
|
|
||||||
bool align_cols = !(fmt.flags & DontAlignCols);
|
bool align_cols = !(fmt.flags & DontAlignCols);
|
||||||
if (align_cols) {
|
if(align_cols)
|
||||||
|
{
|
||||||
// compute the largest width
|
// compute the largest width
|
||||||
for (Index j = 0; j < m.cols(); ++j)
|
for(Index j = 0; j < m.cols(); ++j)
|
||||||
for (Index i = 0; i < m.rows(); ++i) {
|
for(Index i = 0; i < m.rows(); ++i)
|
||||||
|
{
|
||||||
std::stringstream sstr;
|
std::stringstream sstr;
|
||||||
sstr.copyfmt(s);
|
sstr.copyfmt(s);
|
||||||
sstr << static_cast<PrintType>(m.coeff(i, j));
|
sstr << static_cast<PrintType>(m.coeff(i,j));
|
||||||
width = std::max<Index>(width, Index(sstr.str().length()));
|
width = std::max<Index>(width, Index(sstr.str().length()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::streamsize old_width = s.width();
|
std::streamsize old_width = s.width();
|
||||||
char old_fill_character = s.fill();
|
char old_fill_character = s.fill();
|
||||||
s << fmt.matPrefix;
|
s << fmt.matPrefix;
|
||||||
for (Index i = 0; i < m.rows(); ++i) {
|
for(Index i = 0; i < m.rows(); ++i)
|
||||||
if (i) s << fmt.rowSpacer;
|
{
|
||||||
|
if (i)
|
||||||
|
s << fmt.rowSpacer;
|
||||||
s << fmt.rowPrefix;
|
s << fmt.rowPrefix;
|
||||||
if (width) {
|
if(width) {
|
||||||
s.fill(fmt.fill);
|
s.fill(fmt.fill);
|
||||||
s.width(width);
|
s.width(width);
|
||||||
}
|
}
|
||||||
s << static_cast<PrintType>(m.coeff(i, 0));
|
s << static_cast<PrintType>(m.coeff(i, 0));
|
||||||
for (Index j = 1; j < m.cols(); ++j) {
|
for(Index j = 1; j < m.cols(); ++j)
|
||||||
|
{
|
||||||
s << fmt.coeffSeparator;
|
s << fmt.coeffSeparator;
|
||||||
if (width) {
|
if(width) {
|
||||||
s.fill(fmt.fill);
|
s.fill(fmt.fill);
|
||||||
s.width(width);
|
s.width(width);
|
||||||
}
|
}
|
||||||
s << static_cast<PrintType>(m.coeff(i, j));
|
s << static_cast<PrintType>(m.coeff(i, j));
|
||||||
}
|
}
|
||||||
s << fmt.rowSuffix;
|
s << fmt.rowSuffix;
|
||||||
if (i < m.rows() - 1) s << fmt.rowSeparator;
|
if( i < m.rows() - 1)
|
||||||
|
s << fmt.rowSeparator;
|
||||||
}
|
}
|
||||||
s << fmt.matSuffix;
|
s << fmt.matSuffix;
|
||||||
if (explicit_precision) s.precision(old_precision);
|
if(explicit_precision) s.precision(old_precision);
|
||||||
if (width) {
|
if(width) {
|
||||||
s.fill(old_fill_character);
|
s.fill(old_fill_character);
|
||||||
s.width(old_width);
|
s.width(old_width);
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end namespace internal
|
} // end namespace internal
|
||||||
|
|
||||||
/** \relates DenseBase
|
/** \relates DenseBase
|
||||||
*
|
*
|
||||||
* Outputs the matrix, to the given stream.
|
* Outputs the matrix, to the given stream.
|
||||||
*
|
*
|
||||||
* If you wish to print the matrix with a format different than the default, use DenseBase::format().
|
* If you wish to print the matrix with a format different than the default, use DenseBase::format().
|
||||||
*
|
*
|
||||||
* It is also possible to change the default format by defining EIGEN_DEFAULT_IO_FORMAT before including Eigen headers.
|
* It is also possible to change the default format by defining EIGEN_DEFAULT_IO_FORMAT before including Eigen headers.
|
||||||
* If not defined, this will automatically be defined to Eigen::IOFormat(), that is the Eigen::IOFormat with default
|
* If not defined, this will automatically be defined to Eigen::IOFormat(), that is the Eigen::IOFormat with default parameters.
|
||||||
* parameters.
|
*
|
||||||
*
|
* \sa DenseBase::format()
|
||||||
* \sa DenseBase::format()
|
*/
|
||||||
*/
|
template<typename Derived>
|
||||||
template <typename Derived>
|
std::ostream & operator <<
|
||||||
std::ostream& operator<<(std::ostream& s, const DenseBase<Derived>& m) {
|
(std::ostream & s,
|
||||||
|
const DenseBase<Derived> & m)
|
||||||
|
{
|
||||||
return internal::print_matrix(s, m.eval(), EIGEN_DEFAULT_IO_FORMAT);
|
return internal::print_matrix(s, m.eval(), EIGEN_DEFAULT_IO_FORMAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Derived>
|
} // end namespace Eigen
|
||||||
std::ostream& operator<<(std::ostream& s, const DiagonalBase<Derived>& m) {
|
|
||||||
return internal::print_matrix(s, m.derived(), EIGEN_DEFAULT_IO_FORMAT);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // end namespace Eigen
|
#endif // EIGEN_IO_H
|
||||||
|
|
||||||
#endif // EIGEN_IO_H
|
|
||||||
|
|||||||
@@ -10,158 +10,130 @@
|
|||||||
#ifndef EIGEN_INDEXED_VIEW_H
|
#ifndef EIGEN_INDEXED_VIEW_H
|
||||||
#define EIGEN_INDEXED_VIEW_H
|
#define EIGEN_INDEXED_VIEW_H
|
||||||
|
|
||||||
// IWYU pragma: private
|
|
||||||
#include "./InternalHeaderCheck.h"
|
|
||||||
|
|
||||||
namespace Eigen {
|
namespace Eigen {
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
template <typename XprType, typename RowIndices, typename ColIndices>
|
template<typename XprType, typename RowIndices, typename ColIndices>
|
||||||
struct traits<IndexedView<XprType, RowIndices, ColIndices>> : traits<XprType> {
|
struct traits<IndexedView<XprType, RowIndices, ColIndices> >
|
||||||
|
: traits<XprType>
|
||||||
|
{
|
||||||
enum {
|
enum {
|
||||||
RowsAtCompileTime = int(IndexedViewHelper<RowIndices>::SizeAtCompileTime),
|
RowsAtCompileTime = int(array_size<RowIndices>::value),
|
||||||
ColsAtCompileTime = int(IndexedViewHelper<ColIndices>::SizeAtCompileTime),
|
ColsAtCompileTime = int(array_size<ColIndices>::value),
|
||||||
MaxRowsAtCompileTime = RowsAtCompileTime,
|
MaxRowsAtCompileTime = RowsAtCompileTime != Dynamic ? int(RowsAtCompileTime) : Dynamic,
|
||||||
MaxColsAtCompileTime = ColsAtCompileTime,
|
MaxColsAtCompileTime = ColsAtCompileTime != Dynamic ? int(ColsAtCompileTime) : Dynamic,
|
||||||
|
|
||||||
XprTypeIsRowMajor = (int(traits<XprType>::Flags) & RowMajorBit) != 0,
|
XprTypeIsRowMajor = (int(traits<XprType>::Flags)&RowMajorBit) != 0,
|
||||||
IsRowMajor = (MaxRowsAtCompileTime == 1 && MaxColsAtCompileTime != 1) ? 1
|
IsRowMajor = (MaxRowsAtCompileTime==1&&MaxColsAtCompileTime!=1) ? 1
|
||||||
: (MaxColsAtCompileTime == 1 && MaxRowsAtCompileTime != 1) ? 0
|
: (MaxColsAtCompileTime==1&&MaxRowsAtCompileTime!=1) ? 0
|
||||||
: XprTypeIsRowMajor,
|
: XprTypeIsRowMajor,
|
||||||
|
|
||||||
RowIncr = int(IndexedViewHelper<RowIndices>::IncrAtCompileTime),
|
RowIncr = int(get_compile_time_incr<RowIndices>::value),
|
||||||
ColIncr = int(IndexedViewHelper<ColIndices>::IncrAtCompileTime),
|
ColIncr = int(get_compile_time_incr<ColIndices>::value),
|
||||||
InnerIncr = IsRowMajor ? ColIncr : RowIncr,
|
InnerIncr = IsRowMajor ? ColIncr : RowIncr,
|
||||||
OuterIncr = IsRowMajor ? RowIncr : ColIncr,
|
OuterIncr = IsRowMajor ? RowIncr : ColIncr,
|
||||||
|
|
||||||
HasSameStorageOrderAsXprType = (IsRowMajor == XprTypeIsRowMajor),
|
HasSameStorageOrderAsXprType = (IsRowMajor == XprTypeIsRowMajor),
|
||||||
XprInnerStride = HasSameStorageOrderAsXprType ? int(inner_stride_at_compile_time<XprType>::ret)
|
XprInnerStride = HasSameStorageOrderAsXprType ? int(inner_stride_at_compile_time<XprType>::ret) : int(outer_stride_at_compile_time<XprType>::ret),
|
||||||
: int(outer_stride_at_compile_time<XprType>::ret),
|
XprOuterstride = HasSameStorageOrderAsXprType ? int(outer_stride_at_compile_time<XprType>::ret) : int(inner_stride_at_compile_time<XprType>::ret),
|
||||||
XprOuterstride = HasSameStorageOrderAsXprType ? int(outer_stride_at_compile_time<XprType>::ret)
|
|
||||||
: int(inner_stride_at_compile_time<XprType>::ret),
|
|
||||||
|
|
||||||
InnerSize = XprTypeIsRowMajor ? ColsAtCompileTime : RowsAtCompileTime,
|
InnerSize = XprTypeIsRowMajor ? ColsAtCompileTime : RowsAtCompileTime,
|
||||||
IsBlockAlike = InnerIncr == 1 && OuterIncr == 1,
|
IsBlockAlike = InnerIncr==1 && OuterIncr==1,
|
||||||
IsInnerPannel = HasSameStorageOrderAsXprType &&
|
IsInnerPannel = HasSameStorageOrderAsXprType && is_same<AllRange<InnerSize>,typename conditional<XprTypeIsRowMajor,ColIndices,RowIndices>::type>::value,
|
||||||
is_same<AllRange<InnerSize>, std::conditional_t<XprTypeIsRowMajor, ColIndices, RowIndices>>::value,
|
|
||||||
|
|
||||||
InnerStrideAtCompileTime =
|
InnerStrideAtCompileTime = InnerIncr<0 || InnerIncr==DynamicIndex || XprInnerStride==Dynamic ? Dynamic : XprInnerStride * InnerIncr,
|
||||||
InnerIncr < 0 || InnerIncr == DynamicIndex || XprInnerStride == Dynamic || InnerIncr == Undefined
|
OuterStrideAtCompileTime = OuterIncr<0 || OuterIncr==DynamicIndex || XprOuterstride==Dynamic ? Dynamic : XprOuterstride * OuterIncr,
|
||||||
? Dynamic
|
|
||||||
: XprInnerStride * InnerIncr,
|
|
||||||
OuterStrideAtCompileTime =
|
|
||||||
OuterIncr < 0 || OuterIncr == DynamicIndex || XprOuterstride == Dynamic || OuterIncr == Undefined
|
|
||||||
? Dynamic
|
|
||||||
: XprOuterstride * OuterIncr,
|
|
||||||
|
|
||||||
ReturnAsScalar = is_single_range<RowIndices>::value && is_single_range<ColIndices>::value,
|
ReturnAsScalar = is_same<RowIndices,SingleRange>::value && is_same<ColIndices,SingleRange>::value,
|
||||||
ReturnAsBlock = (!ReturnAsScalar) && IsBlockAlike,
|
ReturnAsBlock = (!ReturnAsScalar) && IsBlockAlike,
|
||||||
ReturnAsIndexedView = (!ReturnAsScalar) && (!ReturnAsBlock),
|
ReturnAsIndexedView = (!ReturnAsScalar) && (!ReturnAsBlock),
|
||||||
|
|
||||||
// FIXME: we deal with compile-time strides if and only if we have DirectAccessBit flag,
|
// FIXME we deal with compile-time strides if and only if we have DirectAccessBit flag,
|
||||||
// but this is too strict regarding negative strides...
|
// but this is too strict regarding negative strides...
|
||||||
DirectAccessMask = (int(InnerIncr) != Undefined && int(OuterIncr) != Undefined && InnerIncr >= 0 && OuterIncr >= 0)
|
DirectAccessMask = (int(InnerIncr)!=UndefinedIncr && int(OuterIncr)!=UndefinedIncr && InnerIncr>=0 && OuterIncr>=0) ? DirectAccessBit : 0,
|
||||||
? DirectAccessBit
|
|
||||||
: 0,
|
|
||||||
FlagsRowMajorBit = IsRowMajor ? RowMajorBit : 0,
|
FlagsRowMajorBit = IsRowMajor ? RowMajorBit : 0,
|
||||||
FlagsLvalueBit = is_lvalue<XprType>::value ? LvalueBit : 0,
|
FlagsLvalueBit = is_lvalue<XprType>::value ? LvalueBit : 0,
|
||||||
FlagsLinearAccessBit = (RowsAtCompileTime == 1 || ColsAtCompileTime == 1) ? LinearAccessBit : 0,
|
FlagsLinearAccessBit = (RowsAtCompileTime == 1 || ColsAtCompileTime == 1) ? LinearAccessBit : 0,
|
||||||
Flags = (traits<XprType>::Flags & (HereditaryBits | DirectAccessMask)) | FlagsLvalueBit | FlagsRowMajorBit |
|
Flags = (traits<XprType>::Flags & (HereditaryBits | DirectAccessMask )) | FlagsLvalueBit | FlagsRowMajorBit | FlagsLinearAccessBit
|
||||||
FlagsLinearAccessBit
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef Block<XprType, RowsAtCompileTime, ColsAtCompileTime, IsInnerPannel> BlockType;
|
typedef Block<XprType,RowsAtCompileTime,ColsAtCompileTime,IsInnerPannel> BlockType;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename XprType, typename RowIndices, typename ColIndices, typename StorageKind, bool DirectAccess>
|
}
|
||||||
|
|
||||||
|
template<typename XprType, typename RowIndices, typename ColIndices, typename StorageKind>
|
||||||
class IndexedViewImpl;
|
class IndexedViewImpl;
|
||||||
|
|
||||||
} // namespace internal
|
|
||||||
|
|
||||||
/** \class IndexedView
|
/** \class IndexedView
|
||||||
* \ingroup Core_Module
|
* \ingroup Core_Module
|
||||||
*
|
*
|
||||||
* \brief Expression of a non-sequential sub-matrix defined by arbitrary sequences of row and column indices
|
* \brief Expression of a non-sequential sub-matrix defined by arbitrary sequences of row and column indices
|
||||||
*
|
*
|
||||||
* \tparam XprType the type of the expression in which we are taking the intersections of sub-rows and sub-columns
|
* \tparam XprType the type of the expression in which we are taking the intersections of sub-rows and sub-columns
|
||||||
* \tparam RowIndices the type of the object defining the sequence of row indices
|
* \tparam RowIndices the type of the object defining the sequence of row indices
|
||||||
* \tparam ColIndices the type of the object defining the sequence of column indices
|
* \tparam ColIndices the type of the object defining the sequence of column indices
|
||||||
*
|
*
|
||||||
* This class represents an expression of a sub-matrix (or sub-vector) defined as the intersection
|
* This class represents an expression of a sub-matrix (or sub-vector) defined as the intersection
|
||||||
* of sub-sets of rows and columns, that are themself defined by generic sequences of row indices \f$
|
* of sub-sets of rows and columns, that are themself defined by generic sequences of row indices \f$ \{r_0,r_1,..r_{m-1}\} \f$
|
||||||
* \{r_0,r_1,..r_{m-1}\} \f$ and column indices \f$ \{c_0,c_1,..c_{n-1} \}\f$. Let \f$ A \f$ be the nested matrix, then
|
* and column indices \f$ \{c_0,c_1,..c_{n-1} \}\f$. Let \f$ A \f$ be the nested matrix, then the resulting matrix \f$ B \f$ has \c m
|
||||||
* the resulting matrix \f$ B \f$ has \c m rows and \c n columns, and its entries are given by: \f$ B(i,j) = A(r_i,c_j)
|
* rows and \c n columns, and its entries are given by: \f$ B(i,j) = A(r_i,c_j) \f$.
|
||||||
* \f$.
|
*
|
||||||
*
|
* The \c RowIndices and \c ColIndices types must be compatible with the following API:
|
||||||
* The \c RowIndices and \c ColIndices types must be compatible with the following API:
|
* \code
|
||||||
* \code
|
* <integral type> operator[](Index) const;
|
||||||
* <integral type> operator[](Index) const;
|
* Index size() const;
|
||||||
* Index size() const;
|
* \endcode
|
||||||
* \endcode
|
*
|
||||||
*
|
* Typical supported types thus include:
|
||||||
* Typical supported types thus include:
|
* - std::vector<int>
|
||||||
* - std::vector<int>
|
* - std::valarray<int>
|
||||||
* - std::valarray<int>
|
* - std::array<int>
|
||||||
* - std::array<int>
|
* - Plain C arrays: int[N]
|
||||||
* - Eigen::ArrayXi
|
* - Eigen::ArrayXi
|
||||||
* - decltype(ArrayXi::LinSpaced(...))
|
* - decltype(ArrayXi::LinSpaced(...))
|
||||||
* - Any view/expressions of the previous types
|
* - Any view/expressions of the previous types
|
||||||
* - Eigen::ArithmeticSequence
|
* - Eigen::ArithmeticSequence
|
||||||
* - Eigen::internal::AllRange (helper for Eigen::placeholders::all)
|
* - Eigen::internal::AllRange (helper for Eigen::all)
|
||||||
* - Eigen::internal::SingleRange (helper for single index)
|
* - Eigen::internal::SingleRange (helper for single index)
|
||||||
* - etc.
|
* - etc.
|
||||||
*
|
*
|
||||||
* In typical usages of %Eigen, this class should never be used directly. It is the return type of
|
* In typical usages of %Eigen, this class should never be used directly. It is the return type of
|
||||||
* DenseBase::operator()(const RowIndices&, const ColIndices&).
|
* DenseBase::operator()(const RowIndices&, const ColIndices&).
|
||||||
*
|
*
|
||||||
* \sa class Block
|
* \sa class Block
|
||||||
*/
|
*/
|
||||||
template <typename XprType, typename RowIndices, typename ColIndices>
|
template<typename XprType, typename RowIndices, typename ColIndices>
|
||||||
class IndexedView
|
class IndexedView : public IndexedViewImpl<XprType, RowIndices, ColIndices, typename internal::traits<XprType>::StorageKind>
|
||||||
: public internal::IndexedViewImpl<XprType, RowIndices, ColIndices, typename internal::traits<XprType>::StorageKind,
|
{
|
||||||
(internal::traits<IndexedView<XprType, RowIndices, ColIndices>>::Flags &
|
public:
|
||||||
DirectAccessBit) != 0> {
|
typedef typename IndexedViewImpl<XprType, RowIndices, ColIndices, typename internal::traits<XprType>::StorageKind>::Base Base;
|
||||||
public:
|
|
||||||
typedef typename internal::IndexedViewImpl<
|
|
||||||
XprType, RowIndices, ColIndices, typename internal::traits<XprType>::StorageKind,
|
|
||||||
(internal::traits<IndexedView<XprType, RowIndices, ColIndices>>::Flags & DirectAccessBit) != 0>
|
|
||||||
Base;
|
|
||||||
EIGEN_GENERIC_PUBLIC_INTERFACE(IndexedView)
|
EIGEN_GENERIC_PUBLIC_INTERFACE(IndexedView)
|
||||||
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(IndexedView)
|
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(IndexedView)
|
||||||
|
|
||||||
template <typename T0, typename T1>
|
|
||||||
IndexedView(XprType& xpr, const T0& rowIndices, const T1& colIndices) : Base(xpr, rowIndices, colIndices) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace internal {
|
|
||||||
|
|
||||||
// Generic API dispatcher
|
|
||||||
template <typename XprType, typename RowIndices, typename ColIndices, typename StorageKind, bool DirectAccess>
|
|
||||||
class IndexedViewImpl : public internal::generic_xpr_base<IndexedView<XprType, RowIndices, ColIndices>>::type {
|
|
||||||
public:
|
|
||||||
typedef typename internal::generic_xpr_base<IndexedView<XprType, RowIndices, ColIndices>>::type Base;
|
|
||||||
typedef typename internal::ref_selector<XprType>::non_const_type MatrixTypeNested;
|
typedef typename internal::ref_selector<XprType>::non_const_type MatrixTypeNested;
|
||||||
typedef internal::remove_all_t<XprType> NestedExpression;
|
typedef typename internal::remove_all<XprType>::type NestedExpression;
|
||||||
typedef typename XprType::Scalar Scalar;
|
|
||||||
|
|
||||||
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(IndexedViewImpl)
|
template<typename T0, typename T1>
|
||||||
|
IndexedView(XprType& xpr, const T0& rowIndices, const T1& colIndices)
|
||||||
template <typename T0, typename T1>
|
: m_xpr(xpr), m_rowIndices(rowIndices), m_colIndices(colIndices)
|
||||||
IndexedViewImpl(XprType& xpr, const T0& rowIndices, const T1& colIndices)
|
{}
|
||||||
: m_xpr(xpr), m_rowIndices(rowIndices), m_colIndices(colIndices) {}
|
|
||||||
|
|
||||||
/** \returns number of rows */
|
/** \returns number of rows */
|
||||||
Index rows() const { return IndexedViewHelper<RowIndices>::size(m_rowIndices); }
|
Index rows() const { return internal::index_list_size(m_rowIndices); }
|
||||||
|
|
||||||
/** \returns number of columns */
|
/** \returns number of columns */
|
||||||
Index cols() const { return IndexedViewHelper<ColIndices>::size(m_colIndices); }
|
Index cols() const { return internal::index_list_size(m_colIndices); }
|
||||||
|
|
||||||
/** \returns the nested expression */
|
/** \returns the nested expression */
|
||||||
const internal::remove_all_t<XprType>& nestedExpression() const { return m_xpr; }
|
const typename internal::remove_all<XprType>::type&
|
||||||
|
nestedExpression() const { return m_xpr; }
|
||||||
|
|
||||||
/** \returns the nested expression */
|
/** \returns the nested expression */
|
||||||
std::remove_reference_t<XprType>& nestedExpression() { return m_xpr; }
|
typename internal::remove_reference<XprType>::type&
|
||||||
|
nestedExpression() { return m_xpr; }
|
||||||
|
|
||||||
/** \returns a const reference to the object storing/generating the row indices */
|
/** \returns a const reference to the object storing/generating the row indices */
|
||||||
const RowIndices& rowIndices() const { return m_rowIndices; }
|
const RowIndices& rowIndices() const { return m_rowIndices; }
|
||||||
@@ -169,152 +141,107 @@ class IndexedViewImpl : public internal::generic_xpr_base<IndexedView<XprType, R
|
|||||||
/** \returns a const reference to the object storing/generating the column indices */
|
/** \returns a const reference to the object storing/generating the column indices */
|
||||||
const ColIndices& colIndices() const { return m_colIndices; }
|
const ColIndices& colIndices() const { return m_colIndices; }
|
||||||
|
|
||||||
constexpr Scalar& coeffRef(Index rowId, Index colId) {
|
protected:
|
||||||
return nestedExpression().coeffRef(m_rowIndices[rowId], m_colIndices[colId]);
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr const Scalar& coeffRef(Index rowId, Index colId) const {
|
|
||||||
return nestedExpression().coeffRef(m_rowIndices[rowId], m_colIndices[colId]);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
MatrixTypeNested m_xpr;
|
MatrixTypeNested m_xpr;
|
||||||
RowIndices m_rowIndices;
|
RowIndices m_rowIndices;
|
||||||
ColIndices m_colIndices;
|
ColIndices m_colIndices;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename XprType, typename RowIndices, typename ColIndices, typename StorageKind>
|
|
||||||
class IndexedViewImpl<XprType, RowIndices, ColIndices, StorageKind, true>
|
|
||||||
: public IndexedViewImpl<XprType, RowIndices, ColIndices, StorageKind, false> {
|
|
||||||
public:
|
|
||||||
using Base = internal::IndexedViewImpl<XprType, RowIndices, ColIndices,
|
|
||||||
typename internal::traits<XprType>::StorageKind, false>;
|
|
||||||
using Derived = IndexedView<XprType, RowIndices, ColIndices>;
|
|
||||||
|
|
||||||
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(IndexedViewImpl)
|
// Generic API dispatcher
|
||||||
|
template<typename XprType, typename RowIndices, typename ColIndices, typename StorageKind>
|
||||||
template <typename T0, typename T1>
|
class IndexedViewImpl
|
||||||
IndexedViewImpl(XprType& xpr, const T0& rowIndices, const T1& colIndices) : Base(xpr, rowIndices, colIndices) {}
|
: public internal::generic_xpr_base<IndexedView<XprType, RowIndices, ColIndices> >::type
|
||||||
|
{
|
||||||
Index rowIncrement() const {
|
public:
|
||||||
if (traits<Derived>::RowIncr != DynamicIndex && traits<Derived>::RowIncr != Undefined) {
|
typedef typename internal::generic_xpr_base<IndexedView<XprType, RowIndices, ColIndices> >::type Base;
|
||||||
return traits<Derived>::RowIncr;
|
|
||||||
}
|
|
||||||
return IndexedViewHelper<RowIndices>::incr(this->rowIndices());
|
|
||||||
}
|
|
||||||
Index colIncrement() const {
|
|
||||||
if (traits<Derived>::ColIncr != DynamicIndex && traits<Derived>::ColIncr != Undefined) {
|
|
||||||
return traits<Derived>::ColIncr;
|
|
||||||
}
|
|
||||||
return IndexedViewHelper<ColIndices>::incr(this->colIndices());
|
|
||||||
}
|
|
||||||
|
|
||||||
Index innerIncrement() const { return traits<Derived>::IsRowMajor ? colIncrement() : rowIncrement(); }
|
|
||||||
|
|
||||||
Index outerIncrement() const { return traits<Derived>::IsRowMajor ? rowIncrement() : colIncrement(); }
|
|
||||||
|
|
||||||
std::decay_t<typename XprType::Scalar>* data() {
|
|
||||||
Index row_offset = this->rowIndices()[0] * this->nestedExpression().rowStride();
|
|
||||||
Index col_offset = this->colIndices()[0] * this->nestedExpression().colStride();
|
|
||||||
return this->nestedExpression().data() + row_offset + col_offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::decay_t<typename XprType::Scalar>* data() const {
|
|
||||||
Index row_offset = this->rowIndices()[0] * this->nestedExpression().rowStride();
|
|
||||||
Index col_offset = this->colIndices()[0] * this->nestedExpression().colStride();
|
|
||||||
return this->nestedExpression().data() + row_offset + col_offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC constexpr Index innerStride() const noexcept {
|
|
||||||
if (traits<Derived>::InnerStrideAtCompileTime != Dynamic) {
|
|
||||||
return traits<Derived>::InnerStrideAtCompileTime;
|
|
||||||
}
|
|
||||||
return innerIncrement() * this->nestedExpression().innerStride();
|
|
||||||
}
|
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC constexpr Index outerStride() const noexcept {
|
|
||||||
if (traits<Derived>::OuterStrideAtCompileTime != Dynamic) {
|
|
||||||
return traits<Derived>::OuterStrideAtCompileTime;
|
|
||||||
}
|
|
||||||
return outerIncrement() * this->nestedExpression().outerStride();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename ArgType, typename RowIndices, typename ColIndices>
|
namespace internal {
|
||||||
|
|
||||||
|
|
||||||
|
template<typename ArgType, typename RowIndices, typename ColIndices>
|
||||||
struct unary_evaluator<IndexedView<ArgType, RowIndices, ColIndices>, IndexBased>
|
struct unary_evaluator<IndexedView<ArgType, RowIndices, ColIndices>, IndexBased>
|
||||||
: evaluator_base<IndexedView<ArgType, RowIndices, ColIndices>> {
|
: evaluator_base<IndexedView<ArgType, RowIndices, ColIndices> >
|
||||||
|
{
|
||||||
typedef IndexedView<ArgType, RowIndices, ColIndices> XprType;
|
typedef IndexedView<ArgType, RowIndices, ColIndices> XprType;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
CoeffReadCost = evaluator<ArgType>::CoeffReadCost /* TODO + cost of row/col index */,
|
CoeffReadCost = evaluator<ArgType>::CoeffReadCost /* TODO + cost of row/col index */,
|
||||||
|
|
||||||
FlagsLinearAccessBit =
|
FlagsLinearAccessBit = (traits<XprType>::RowsAtCompileTime == 1 || traits<XprType>::ColsAtCompileTime == 1) ? LinearAccessBit : 0,
|
||||||
(traits<XprType>::RowsAtCompileTime == 1 || traits<XprType>::ColsAtCompileTime == 1) ? LinearAccessBit : 0,
|
|
||||||
|
|
||||||
FlagsRowMajorBit = traits<XprType>::FlagsRowMajorBit,
|
FlagsRowMajorBit = traits<XprType>::FlagsRowMajorBit,
|
||||||
|
|
||||||
Flags = (evaluator<ArgType>::Flags & (HereditaryBits & ~RowMajorBit /*| LinearAccessBit | DirectAccessBit*/)) |
|
Flags = (evaluator<ArgType>::Flags & (HereditaryBits & ~RowMajorBit /*| LinearAccessBit | DirectAccessBit*/)) | FlagsLinearAccessBit | FlagsRowMajorBit,
|
||||||
FlagsLinearAccessBit | FlagsRowMajorBit,
|
|
||||||
|
|
||||||
Alignment = 0
|
Alignment = 0
|
||||||
};
|
};
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC constexpr explicit unary_evaluator(const XprType& xpr)
|
EIGEN_DEVICE_FUNC explicit unary_evaluator(const XprType& xpr) : m_argImpl(xpr.nestedExpression()), m_xpr(xpr)
|
||||||
: m_argImpl(xpr.nestedExpression()), m_xpr(xpr) {
|
{
|
||||||
EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
|
EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef typename XprType::Scalar Scalar;
|
typedef typename XprType::Scalar Scalar;
|
||||||
typedef typename XprType::CoeffReturnType CoeffReturnType;
|
typedef typename XprType::CoeffReturnType CoeffReturnType;
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE CoeffReturnType coeff(Index row, Index col) const {
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||||
eigen_assert(m_xpr.rowIndices()[row] >= 0 && m_xpr.rowIndices()[row] < m_xpr.nestedExpression().rows() &&
|
CoeffReturnType coeff(Index row, Index col) const
|
||||||
m_xpr.colIndices()[col] >= 0 && m_xpr.colIndices()[col] < m_xpr.nestedExpression().cols());
|
{
|
||||||
|
eigen_assert(m_xpr.rowIndices()[row] >= 0 && m_xpr.rowIndices()[row] < m_xpr.nestedExpression().rows()
|
||||||
|
&& m_xpr.colIndices()[col] >= 0 && m_xpr.colIndices()[col] < m_xpr.nestedExpression().cols());
|
||||||
return m_argImpl.coeff(m_xpr.rowIndices()[row], m_xpr.colIndices()[col]);
|
return m_argImpl.coeff(m_xpr.rowIndices()[row], m_xpr.colIndices()[col]);
|
||||||
}
|
}
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar& coeffRef(Index row, Index col) {
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||||
eigen_assert(m_xpr.rowIndices()[row] >= 0 && m_xpr.rowIndices()[row] < m_xpr.nestedExpression().rows() &&
|
Scalar& coeffRef(Index row, Index col)
|
||||||
m_xpr.colIndices()[col] >= 0 && m_xpr.colIndices()[col] < m_xpr.nestedExpression().cols());
|
{
|
||||||
|
eigen_assert(m_xpr.rowIndices()[row] >= 0 && m_xpr.rowIndices()[row] < m_xpr.nestedExpression().rows()
|
||||||
|
&& m_xpr.colIndices()[col] >= 0 && m_xpr.colIndices()[col] < m_xpr.nestedExpression().cols());
|
||||||
return m_argImpl.coeffRef(m_xpr.rowIndices()[row], m_xpr.colIndices()[col]);
|
return m_argImpl.coeffRef(m_xpr.rowIndices()[row], m_xpr.colIndices()[col]);
|
||||||
}
|
}
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar& coeffRef(Index index) {
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||||
|
Scalar& coeffRef(Index index)
|
||||||
|
{
|
||||||
EIGEN_STATIC_ASSERT_LVALUE(XprType)
|
EIGEN_STATIC_ASSERT_LVALUE(XprType)
|
||||||
Index row = XprType::RowsAtCompileTime == 1 ? 0 : index;
|
Index row = XprType::RowsAtCompileTime == 1 ? 0 : index;
|
||||||
Index col = XprType::RowsAtCompileTime == 1 ? index : 0;
|
Index col = XprType::RowsAtCompileTime == 1 ? index : 0;
|
||||||
eigen_assert(m_xpr.rowIndices()[row] >= 0 && m_xpr.rowIndices()[row] < m_xpr.nestedExpression().rows() &&
|
eigen_assert(m_xpr.rowIndices()[row] >= 0 && m_xpr.rowIndices()[row] < m_xpr.nestedExpression().rows()
|
||||||
m_xpr.colIndices()[col] >= 0 && m_xpr.colIndices()[col] < m_xpr.nestedExpression().cols());
|
&& m_xpr.colIndices()[col] >= 0 && m_xpr.colIndices()[col] < m_xpr.nestedExpression().cols());
|
||||||
return m_argImpl.coeffRef(m_xpr.rowIndices()[row], m_xpr.colIndices()[col]);
|
return m_argImpl.coeffRef( m_xpr.rowIndices()[row], m_xpr.colIndices()[col]);
|
||||||
}
|
}
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const Scalar& coeffRef(Index index) const {
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||||
|
const Scalar& coeffRef(Index index) const
|
||||||
|
{
|
||||||
Index row = XprType::RowsAtCompileTime == 1 ? 0 : index;
|
Index row = XprType::RowsAtCompileTime == 1 ? 0 : index;
|
||||||
Index col = XprType::RowsAtCompileTime == 1 ? index : 0;
|
Index col = XprType::RowsAtCompileTime == 1 ? index : 0;
|
||||||
eigen_assert(m_xpr.rowIndices()[row] >= 0 && m_xpr.rowIndices()[row] < m_xpr.nestedExpression().rows() &&
|
eigen_assert(m_xpr.rowIndices()[row] >= 0 && m_xpr.rowIndices()[row] < m_xpr.nestedExpression().rows()
|
||||||
m_xpr.colIndices()[col] >= 0 && m_xpr.colIndices()[col] < m_xpr.nestedExpression().cols());
|
&& m_xpr.colIndices()[col] >= 0 && m_xpr.colIndices()[col] < m_xpr.nestedExpression().cols());
|
||||||
return m_argImpl.coeffRef(m_xpr.rowIndices()[row], m_xpr.colIndices()[col]);
|
return m_argImpl.coeffRef( m_xpr.rowIndices()[row], m_xpr.colIndices()[col]);
|
||||||
}
|
}
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const CoeffReturnType coeff(Index index) const {
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||||
|
const CoeffReturnType coeff(Index index) const
|
||||||
|
{
|
||||||
Index row = XprType::RowsAtCompileTime == 1 ? 0 : index;
|
Index row = XprType::RowsAtCompileTime == 1 ? 0 : index;
|
||||||
Index col = XprType::RowsAtCompileTime == 1 ? index : 0;
|
Index col = XprType::RowsAtCompileTime == 1 ? index : 0;
|
||||||
eigen_assert(m_xpr.rowIndices()[row] >= 0 && m_xpr.rowIndices()[row] < m_xpr.nestedExpression().rows() &&
|
eigen_assert(m_xpr.rowIndices()[row] >= 0 && m_xpr.rowIndices()[row] < m_xpr.nestedExpression().rows()
|
||||||
m_xpr.colIndices()[col] >= 0 && m_xpr.colIndices()[col] < m_xpr.nestedExpression().cols());
|
&& m_xpr.colIndices()[col] >= 0 && m_xpr.colIndices()[col] < m_xpr.nestedExpression().cols());
|
||||||
return m_argImpl.coeff(m_xpr.rowIndices()[row], m_xpr.colIndices()[col]);
|
return m_argImpl.coeff( m_xpr.rowIndices()[row], m_xpr.colIndices()[col]);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
evaluator<ArgType> m_argImpl;
|
evaluator<ArgType> m_argImpl;
|
||||||
const XprType& m_xpr;
|
const XprType& m_xpr;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Catch assignments to an IndexedView.
|
} // end namespace internal
|
||||||
template <typename ArgType, typename RowIndices, typename ColIndices>
|
|
||||||
struct evaluator_assume_aliasing<IndexedView<ArgType, RowIndices, ColIndices>> : std::true_type {};
|
|
||||||
|
|
||||||
} // end namespace internal
|
} // end namespace Eigen
|
||||||
|
|
||||||
} // end namespace Eigen
|
#endif // EIGEN_INDEXED_VIEW_H
|
||||||
|
|
||||||
#endif // EIGEN_INDEXED_VIEW_H
|
|
||||||
|
|||||||
@@ -1,265 +0,0 @@
|
|||||||
// This file is part of Eigen, a lightweight C++ template library
|
|
||||||
// for linear algebra.
|
|
||||||
//
|
|
||||||
// Copyright (C) 2024 Charlie Schlosser <cs.schlosser@gmail.com>
|
|
||||||
//
|
|
||||||
// This Source Code Form is subject to the terms of the Mozilla
|
|
||||||
// Public License v. 2.0. If a copy of the MPL was not distributed
|
|
||||||
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
#ifndef EIGEN_INNER_PRODUCT_EVAL_H
|
|
||||||
#define EIGEN_INNER_PRODUCT_EVAL_H
|
|
||||||
|
|
||||||
// IWYU pragma: private
|
|
||||||
#include "./InternalHeaderCheck.h"
|
|
||||||
|
|
||||||
namespace Eigen {
|
|
||||||
|
|
||||||
namespace internal {
|
|
||||||
|
|
||||||
// recursively searches for the largest simd type that does not exceed Size, or the smallest if no such type exists
|
|
||||||
template <typename Scalar, int Size, typename Packet = typename packet_traits<Scalar>::type,
|
|
||||||
bool Stop =
|
|
||||||
(unpacket_traits<Packet>::size <= Size) || is_same<Packet, typename unpacket_traits<Packet>::half>::value>
|
|
||||||
struct find_inner_product_packet_helper;
|
|
||||||
|
|
||||||
template <typename Scalar, int Size, typename Packet>
|
|
||||||
struct find_inner_product_packet_helper<Scalar, Size, Packet, false> {
|
|
||||||
using type = typename find_inner_product_packet_helper<Scalar, Size, typename unpacket_traits<Packet>::half>::type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Scalar, int Size, typename Packet>
|
|
||||||
struct find_inner_product_packet_helper<Scalar, Size, Packet, true> {
|
|
||||||
using type = Packet;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Scalar, int Size>
|
|
||||||
struct find_inner_product_packet : find_inner_product_packet_helper<Scalar, Size> {};
|
|
||||||
|
|
||||||
template <typename Scalar>
|
|
||||||
struct find_inner_product_packet<Scalar, Dynamic> {
|
|
||||||
using type = typename packet_traits<Scalar>::type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Lhs, typename Rhs>
|
|
||||||
struct inner_product_assert {
|
|
||||||
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Lhs)
|
|
||||||
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Rhs)
|
|
||||||
EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(Lhs, Rhs)
|
|
||||||
#ifndef EIGEN_NO_DEBUG
|
|
||||||
static EIGEN_DEVICE_FUNC void run(const Lhs& lhs, const Rhs& rhs) {
|
|
||||||
eigen_assert((lhs.size() == rhs.size()) && "Inner product: lhs and rhs vectors must have same size");
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
static EIGEN_DEVICE_FUNC void run(const Lhs&, const Rhs&) {}
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Func, typename Lhs, typename Rhs>
|
|
||||||
struct inner_product_evaluator {
|
|
||||||
static constexpr int LhsFlags = evaluator<Lhs>::Flags;
|
|
||||||
static constexpr int RhsFlags = evaluator<Rhs>::Flags;
|
|
||||||
static constexpr int SizeAtCompileTime = size_prefer_fixed(Lhs::SizeAtCompileTime, Rhs::SizeAtCompileTime);
|
|
||||||
static constexpr int MaxSizeAtCompileTime =
|
|
||||||
min_size_prefer_fixed(Lhs::MaxSizeAtCompileTime, Rhs::MaxSizeAtCompileTime);
|
|
||||||
static constexpr int LhsAlignment = evaluator<Lhs>::Alignment;
|
|
||||||
static constexpr int RhsAlignment = evaluator<Rhs>::Alignment;
|
|
||||||
|
|
||||||
using Scalar = typename Func::result_type;
|
|
||||||
using Packet = typename find_inner_product_packet<Scalar, SizeAtCompileTime>::type;
|
|
||||||
|
|
||||||
static constexpr bool Vectorize =
|
|
||||||
bool(LhsFlags & RhsFlags & PacketAccessBit) && Func::PacketAccess &&
|
|
||||||
((MaxSizeAtCompileTime == Dynamic) || (unpacket_traits<Packet>::size <= MaxSizeAtCompileTime));
|
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit inner_product_evaluator(const Lhs& lhs, const Rhs& rhs,
|
|
||||||
Func func = Func())
|
|
||||||
: m_func(func), m_lhs(lhs), m_rhs(rhs), m_size(lhs.size()) {
|
|
||||||
inner_product_assert<Lhs, Rhs>::run(lhs, rhs);
|
|
||||||
}
|
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index size() const { return m_size.value(); }
|
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar coeff(Index index) const {
|
|
||||||
return m_func.coeff(m_lhs.coeff(index), m_rhs.coeff(index));
|
|
||||||
}
|
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar coeff(const Scalar& value, Index index) const {
|
|
||||||
return m_func.coeff(value, m_lhs.coeff(index), m_rhs.coeff(index));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename PacketType, int LhsMode = LhsAlignment, int RhsMode = RhsAlignment>
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packet(Index index) const {
|
|
||||||
return m_func.packet(m_lhs.template packet<LhsMode, PacketType>(index),
|
|
||||||
m_rhs.template packet<RhsMode, PacketType>(index));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename PacketType, int LhsMode = LhsAlignment, int RhsMode = RhsAlignment>
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packet(const PacketType& value, Index index) const {
|
|
||||||
return m_func.packet(value, m_lhs.template packet<LhsMode, PacketType>(index),
|
|
||||||
m_rhs.template packet<RhsMode, PacketType>(index));
|
|
||||||
}
|
|
||||||
|
|
||||||
const Func m_func;
|
|
||||||
const evaluator<Lhs> m_lhs;
|
|
||||||
const evaluator<Rhs> m_rhs;
|
|
||||||
const variable_if_dynamic<Index, SizeAtCompileTime> m_size;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Evaluator, bool Vectorize = Evaluator::Vectorize>
|
|
||||||
struct inner_product_impl;
|
|
||||||
|
|
||||||
// scalar loop
|
|
||||||
template <typename Evaluator>
|
|
||||||
struct inner_product_impl<Evaluator, false> {
|
|
||||||
using Scalar = typename Evaluator::Scalar;
|
|
||||||
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar run(const Evaluator& eval) {
|
|
||||||
const Index size = eval.size();
|
|
||||||
if (size == 0) return Scalar(0);
|
|
||||||
|
|
||||||
Scalar result = eval.coeff(0);
|
|
||||||
for (Index k = 1; k < size; k++) {
|
|
||||||
result = eval.coeff(result, k);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// vector loop
|
|
||||||
template <typename Evaluator>
|
|
||||||
struct inner_product_impl<Evaluator, true> {
|
|
||||||
using UnsignedIndex = std::make_unsigned_t<Index>;
|
|
||||||
using Scalar = typename Evaluator::Scalar;
|
|
||||||
using Packet = typename Evaluator::Packet;
|
|
||||||
static constexpr int PacketSize = unpacket_traits<Packet>::size;
|
|
||||||
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar run(const Evaluator& eval) {
|
|
||||||
const UnsignedIndex size = static_cast<UnsignedIndex>(eval.size());
|
|
||||||
if (size < PacketSize) return inner_product_impl<Evaluator, false>::run(eval);
|
|
||||||
|
|
||||||
const UnsignedIndex packetEnd = numext::round_down(size, PacketSize);
|
|
||||||
const UnsignedIndex quadEnd = numext::round_down(size, 4 * PacketSize);
|
|
||||||
const UnsignedIndex numPackets = size / PacketSize;
|
|
||||||
const UnsignedIndex numRemPackets = (packetEnd - quadEnd) / PacketSize;
|
|
||||||
|
|
||||||
Packet presult0 = eval.template packet<Packet>(0 * PacketSize);
|
|
||||||
if (numPackets >= 2) {
|
|
||||||
Packet presult1 = eval.template packet<Packet>(1 * PacketSize);
|
|
||||||
if (numPackets >= 3) {
|
|
||||||
Packet presult2 = eval.template packet<Packet>(2 * PacketSize);
|
|
||||||
if (numPackets >= 4) {
|
|
||||||
Packet presult3 = eval.template packet<Packet>(3 * PacketSize);
|
|
||||||
|
|
||||||
for (UnsignedIndex k = 4 * PacketSize; k < quadEnd; k += 4 * PacketSize) {
|
|
||||||
presult0 = eval.packet(presult0, k + 0 * PacketSize);
|
|
||||||
presult1 = eval.packet(presult1, k + 1 * PacketSize);
|
|
||||||
presult2 = eval.packet(presult2, k + 2 * PacketSize);
|
|
||||||
presult3 = eval.packet(presult3, k + 3 * PacketSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (numRemPackets >= 1) {
|
|
||||||
presult0 = eval.packet(presult0, quadEnd + 0 * PacketSize);
|
|
||||||
if (numRemPackets >= 2) {
|
|
||||||
presult1 = eval.packet(presult1, quadEnd + 1 * PacketSize);
|
|
||||||
if (numRemPackets == 3) presult2 = eval.packet(presult2, quadEnd + 2 * PacketSize);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
presult2 = padd(presult2, presult3);
|
|
||||||
}
|
|
||||||
presult1 = padd(presult1, presult2);
|
|
||||||
}
|
|
||||||
presult0 = padd(presult0, presult1);
|
|
||||||
}
|
|
||||||
|
|
||||||
Scalar result = predux(presult0);
|
|
||||||
for (UnsignedIndex k = packetEnd; k < size; k++) {
|
|
||||||
result = eval.coeff(result, k);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Scalar, bool Conj>
|
|
||||||
struct conditional_conj;
|
|
||||||
|
|
||||||
template <typename Scalar>
|
|
||||||
struct conditional_conj<Scalar, true> {
|
|
||||||
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar coeff(const Scalar& a) { return numext::conj(a); }
|
|
||||||
template <typename Packet>
|
|
||||||
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet packet(const Packet& a) {
|
|
||||||
return pconj(a);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Scalar>
|
|
||||||
struct conditional_conj<Scalar, false> {
|
|
||||||
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar coeff(const Scalar& a) { return a; }
|
|
||||||
template <typename Packet>
|
|
||||||
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet packet(const Packet& a) {
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename LhsScalar, typename RhsScalar, bool Conj>
|
|
||||||
struct scalar_inner_product_op {
|
|
||||||
using result_type = typename ScalarBinaryOpTraits<LhsScalar, RhsScalar>::ReturnType;
|
|
||||||
using conj_helper = conditional_conj<LhsScalar, Conj>;
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE result_type coeff(const LhsScalar& a, const RhsScalar& b) const {
|
|
||||||
return (conj_helper::coeff(a) * b);
|
|
||||||
}
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE result_type coeff(const result_type& accum, const LhsScalar& a,
|
|
||||||
const RhsScalar& b) const {
|
|
||||||
return (conj_helper::coeff(a) * b) + accum;
|
|
||||||
}
|
|
||||||
static constexpr bool PacketAccess = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Partial specialization for packet access if and only if
|
|
||||||
// LhsScalar == RhsScalar == ScalarBinaryOpTraits<LhsScalar, RhsScalar>::ReturnType.
|
|
||||||
template <typename Scalar, bool Conj>
|
|
||||||
struct scalar_inner_product_op<
|
|
||||||
Scalar,
|
|
||||||
std::enable_if_t<internal::is_same<typename ScalarBinaryOpTraits<Scalar, Scalar>::ReturnType, Scalar>::value,
|
|
||||||
Scalar>,
|
|
||||||
Conj> {
|
|
||||||
using result_type = Scalar;
|
|
||||||
using conj_helper = conditional_conj<Scalar, Conj>;
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar coeff(const Scalar& a, const Scalar& b) const {
|
|
||||||
return pmul(conj_helper::coeff(a), b);
|
|
||||||
}
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar coeff(const Scalar& accum, const Scalar& a, const Scalar& b) const {
|
|
||||||
return pmadd(conj_helper::coeff(a), b, accum);
|
|
||||||
}
|
|
||||||
template <typename Packet>
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet packet(const Packet& a, const Packet& b) const {
|
|
||||||
return pmul(conj_helper::packet(a), b);
|
|
||||||
}
|
|
||||||
template <typename Packet>
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet packet(const Packet& accum, const Packet& a, const Packet& b) const {
|
|
||||||
return pmadd(conj_helper::packet(a), b, accum);
|
|
||||||
}
|
|
||||||
static constexpr bool PacketAccess = packet_traits<Scalar>::HasMul && packet_traits<Scalar>::HasAdd;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Lhs, typename Rhs, bool Conj>
|
|
||||||
struct default_inner_product_impl {
|
|
||||||
using LhsScalar = typename traits<Lhs>::Scalar;
|
|
||||||
using RhsScalar = typename traits<Rhs>::Scalar;
|
|
||||||
using Op = scalar_inner_product_op<LhsScalar, RhsScalar, Conj>;
|
|
||||||
using Evaluator = inner_product_evaluator<Op, Lhs, Rhs>;
|
|
||||||
using result_type = typename Evaluator::Scalar;
|
|
||||||
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE result_type run(const MatrixBase<Lhs>& a, const MatrixBase<Rhs>& b) {
|
|
||||||
Evaluator eval(a.derived(), b.derived(), Op());
|
|
||||||
return inner_product_impl<Evaluator>::run(eval);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Lhs, typename Rhs>
|
|
||||||
struct dot_impl : default_inner_product_impl<Lhs, Rhs, true> {};
|
|
||||||
|
|
||||||
} // namespace internal
|
|
||||||
} // namespace Eigen
|
|
||||||
|
|
||||||
#endif // EIGEN_INNER_PRODUCT_EVAL_H
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
#ifndef EIGEN_CORE_MODULE_H
|
|
||||||
#error "Please include Eigen/Core instead of including headers inside the src directory directly."
|
|
||||||
#endif
|
|
||||||
@@ -10,64 +10,69 @@
|
|||||||
#ifndef EIGEN_INVERSE_H
|
#ifndef EIGEN_INVERSE_H
|
||||||
#define EIGEN_INVERSE_H
|
#define EIGEN_INVERSE_H
|
||||||
|
|
||||||
// IWYU pragma: private
|
|
||||||
#include "./InternalHeaderCheck.h"
|
|
||||||
|
|
||||||
namespace Eigen {
|
namespace Eigen {
|
||||||
|
|
||||||
template <typename XprType, typename StorageKind>
|
template<typename XprType,typename StorageKind> class InverseImpl;
|
||||||
class InverseImpl;
|
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
template <typename XprType>
|
template<typename XprType>
|
||||||
struct traits<Inverse<XprType> > : traits<typename XprType::PlainObject> {
|
struct traits<Inverse<XprType> >
|
||||||
|
: traits<typename XprType::PlainObject>
|
||||||
|
{
|
||||||
typedef typename XprType::PlainObject PlainObject;
|
typedef typename XprType::PlainObject PlainObject;
|
||||||
typedef traits<PlainObject> BaseTraits;
|
typedef traits<PlainObject> BaseTraits;
|
||||||
enum { Flags = BaseTraits::Flags & RowMajorBit };
|
enum {
|
||||||
|
Flags = BaseTraits::Flags & RowMajorBit
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace internal
|
} // end namespace internal
|
||||||
|
|
||||||
/** \class Inverse
|
/** \class Inverse
|
||||||
*
|
*
|
||||||
* \brief Expression of the inverse of another expression
|
* \brief Expression of the inverse of another expression
|
||||||
*
|
*
|
||||||
* \tparam XprType the type of the expression we are taking the inverse
|
* \tparam XprType the type of the expression we are taking the inverse
|
||||||
*
|
*
|
||||||
* This class represents an abstract expression of A.inverse()
|
* This class represents an abstract expression of A.inverse()
|
||||||
* and most of the time this is the only way it is used.
|
* and most of the time this is the only way it is used.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
template <typename XprType>
|
template<typename XprType>
|
||||||
class Inverse : public InverseImpl<XprType, typename internal::traits<XprType>::StorageKind> {
|
class Inverse : public InverseImpl<XprType,typename internal::traits<XprType>::StorageKind>
|
||||||
public:
|
{
|
||||||
|
public:
|
||||||
typedef typename XprType::StorageIndex StorageIndex;
|
typedef typename XprType::StorageIndex StorageIndex;
|
||||||
typedef typename XprType::Scalar Scalar;
|
typedef typename XprType::Scalar Scalar;
|
||||||
typedef typename internal::ref_selector<XprType>::type XprTypeNested;
|
typedef typename internal::ref_selector<XprType>::type XprTypeNested;
|
||||||
typedef internal::remove_all_t<XprTypeNested> XprTypeNestedCleaned;
|
typedef typename internal::remove_all<XprTypeNested>::type XprTypeNestedCleaned;
|
||||||
typedef typename internal::ref_selector<Inverse>::type Nested;
|
typedef typename internal::ref_selector<Inverse>::type Nested;
|
||||||
typedef internal::remove_all_t<XprType> NestedExpression;
|
typedef typename internal::remove_all<XprType>::type NestedExpression;
|
||||||
|
|
||||||
explicit EIGEN_DEVICE_FUNC constexpr Inverse(const XprType& xpr) : m_xpr(xpr) {}
|
explicit EIGEN_DEVICE_FUNC Inverse(const XprType &xpr)
|
||||||
|
: m_xpr(xpr)
|
||||||
|
{}
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC constexpr Index rows() const noexcept { return m_xpr.cols(); }
|
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT { return m_xpr.cols(); }
|
||||||
EIGEN_DEVICE_FUNC constexpr Index cols() const noexcept { return m_xpr.rows(); }
|
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT { return m_xpr.rows(); }
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC constexpr const XprTypeNestedCleaned& nestedExpression() const { return m_xpr; }
|
EIGEN_DEVICE_FUNC const XprTypeNestedCleaned& nestedExpression() const { return m_xpr; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
XprTypeNested m_xpr;
|
XprTypeNested m_xpr;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Generic API dispatcher
|
// Generic API dispatcher
|
||||||
template <typename XprType, typename StorageKind>
|
template<typename XprType, typename StorageKind>
|
||||||
class InverseImpl : public internal::generic_xpr_base<Inverse<XprType> >::type {
|
class InverseImpl
|
||||||
public:
|
: public internal::generic_xpr_base<Inverse<XprType> >::type
|
||||||
|
{
|
||||||
|
public:
|
||||||
typedef typename internal::generic_xpr_base<Inverse<XprType> >::type Base;
|
typedef typename internal::generic_xpr_base<Inverse<XprType> >::type Base;
|
||||||
typedef typename XprType::Scalar Scalar;
|
typedef typename XprType::Scalar Scalar;
|
||||||
|
private:
|
||||||
|
|
||||||
private:
|
|
||||||
Scalar coeff(Index row, Index col) const;
|
Scalar coeff(Index row, Index col) const;
|
||||||
Scalar coeff(Index i) const;
|
Scalar coeff(Index i) const;
|
||||||
};
|
};
|
||||||
@@ -75,34 +80,38 @@ class InverseImpl : public internal::generic_xpr_base<Inverse<XprType> >::type {
|
|||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
/** \internal
|
/** \internal
|
||||||
* \brief Default evaluator for Inverse expression.
|
* \brief Default evaluator for Inverse expression.
|
||||||
*
|
*
|
||||||
* This default evaluator for Inverse expression simply evaluate the inverse into a temporary
|
* This default evaluator for Inverse expression simply evaluate the inverse into a temporary
|
||||||
* by a call to internal::call_assignment_no_alias.
|
* by a call to internal::call_assignment_no_alias.
|
||||||
* Therefore, inverse implementers only have to specialize Assignment<Dst,Inverse<...>, ...> for
|
* Therefore, inverse implementers only have to specialize Assignment<Dst,Inverse<...>, ...> for
|
||||||
* there own nested expression.
|
* there own nested expression.
|
||||||
*
|
*
|
||||||
* \sa class Inverse
|
* \sa class Inverse
|
||||||
*/
|
*/
|
||||||
template <typename ArgType>
|
template<typename ArgType>
|
||||||
struct unary_evaluator<Inverse<ArgType> > : public evaluator<typename Inverse<ArgType>::PlainObject> {
|
struct unary_evaluator<Inverse<ArgType> >
|
||||||
|
: public evaluator<typename Inverse<ArgType>::PlainObject>
|
||||||
|
{
|
||||||
typedef Inverse<ArgType> InverseType;
|
typedef Inverse<ArgType> InverseType;
|
||||||
typedef typename InverseType::PlainObject PlainObject;
|
typedef typename InverseType::PlainObject PlainObject;
|
||||||
typedef evaluator<PlainObject> Base;
|
typedef evaluator<PlainObject> Base;
|
||||||
|
|
||||||
enum { Flags = Base::Flags | EvalBeforeNestingBit };
|
enum { Flags = Base::Flags | EvalBeforeNestingBit };
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC unary_evaluator(const InverseType& inv_xpr) : m_result(inv_xpr.rows(), inv_xpr.cols()) {
|
unary_evaluator(const InverseType& inv_xpr)
|
||||||
internal::construct_at<Base>(this, m_result);
|
: m_result(inv_xpr.rows(), inv_xpr.cols())
|
||||||
|
{
|
||||||
|
::new (static_cast<Base*>(this)) Base(m_result);
|
||||||
internal::call_assignment_no_alias(m_result, inv_xpr);
|
internal::call_assignment_no_alias(m_result, inv_xpr);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
PlainObject m_result;
|
PlainObject m_result;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace internal
|
} // end namespace internal
|
||||||
|
|
||||||
} // end namespace Eigen
|
} // end namespace Eigen
|
||||||
|
|
||||||
#endif // EIGEN_INVERSE_H
|
#endif // EIGEN_INVERSE_H
|
||||||
|
|||||||
@@ -11,144 +11,161 @@
|
|||||||
#ifndef EIGEN_MAP_H
|
#ifndef EIGEN_MAP_H
|
||||||
#define EIGEN_MAP_H
|
#define EIGEN_MAP_H
|
||||||
|
|
||||||
// IWYU pragma: private
|
|
||||||
#include "./InternalHeaderCheck.h"
|
|
||||||
|
|
||||||
namespace Eigen {
|
namespace Eigen {
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
template <typename PlainObjectType, int MapOptions, typename StrideType>
|
template<typename PlainObjectType, int MapOptions, typename StrideType>
|
||||||
struct traits<Map<PlainObjectType, MapOptions, StrideType> > : public traits<PlainObjectType> {
|
struct traits<Map<PlainObjectType, MapOptions, StrideType> >
|
||||||
|
: public traits<PlainObjectType>
|
||||||
|
{
|
||||||
typedef traits<PlainObjectType> TraitsBase;
|
typedef traits<PlainObjectType> TraitsBase;
|
||||||
enum {
|
enum {
|
||||||
PlainObjectTypeInnerSize = ((traits<PlainObjectType>::Flags & RowMajorBit) == RowMajorBit)
|
PlainObjectTypeInnerSize = ((traits<PlainObjectType>::Flags&RowMajorBit)==RowMajorBit)
|
||||||
? PlainObjectType::ColsAtCompileTime
|
? PlainObjectType::ColsAtCompileTime
|
||||||
: PlainObjectType::RowsAtCompileTime,
|
: PlainObjectType::RowsAtCompileTime,
|
||||||
|
|
||||||
InnerStrideAtCompileTime = StrideType::InnerStrideAtCompileTime == 0
|
InnerStrideAtCompileTime = StrideType::InnerStrideAtCompileTime == 0
|
||||||
? int(PlainObjectType::InnerStrideAtCompileTime)
|
? int(PlainObjectType::InnerStrideAtCompileTime)
|
||||||
: int(StrideType::InnerStrideAtCompileTime),
|
: int(StrideType::InnerStrideAtCompileTime),
|
||||||
OuterStrideAtCompileTime = StrideType::OuterStrideAtCompileTime == 0
|
OuterStrideAtCompileTime = StrideType::OuterStrideAtCompileTime == 0
|
||||||
? (InnerStrideAtCompileTime == Dynamic || PlainObjectTypeInnerSize == Dynamic
|
? (InnerStrideAtCompileTime==Dynamic || PlainObjectTypeInnerSize==Dynamic
|
||||||
? Dynamic
|
? Dynamic
|
||||||
: int(InnerStrideAtCompileTime) * int(PlainObjectTypeInnerSize))
|
: int(InnerStrideAtCompileTime) * int(PlainObjectTypeInnerSize))
|
||||||
: int(StrideType::OuterStrideAtCompileTime),
|
: int(StrideType::OuterStrideAtCompileTime),
|
||||||
Alignment = int(MapOptions) & int(AlignedMask),
|
Alignment = int(MapOptions)&int(AlignedMask),
|
||||||
Flags0 = TraitsBase::Flags & (~NestByRefBit),
|
Flags0 = TraitsBase::Flags & (~NestByRefBit),
|
||||||
Flags = is_lvalue<PlainObjectType>::value ? int(Flags0) : (int(Flags0) & ~LvalueBit)
|
Flags = is_lvalue<PlainObjectType>::value ? int(Flags0) : (int(Flags0) & ~LvalueBit)
|
||||||
};
|
};
|
||||||
|
private:
|
||||||
private:
|
enum { Options }; // Expressions don't have Options
|
||||||
enum { Options }; // Expressions don't have Options
|
|
||||||
};
|
};
|
||||||
} // namespace internal
|
}
|
||||||
|
|
||||||
/** \class Map
|
/** \class Map
|
||||||
* \ingroup Core_Module
|
* \ingroup Core_Module
|
||||||
*
|
*
|
||||||
* \brief A matrix or vector expression mapping an existing array of data.
|
* \brief A matrix or vector expression mapping an existing array of data.
|
||||||
*
|
*
|
||||||
* \tparam PlainObjectType the equivalent matrix type of the mapped data
|
* \tparam PlainObjectType the equivalent matrix type of the mapped data
|
||||||
* \tparam MapOptions specifies the pointer alignment in bytes. It can be: \c #Aligned128, \c #Aligned64, \c #Aligned32,
|
* \tparam MapOptions specifies the pointer alignment in bytes. It can be: \c #Aligned128, \c #Aligned64, \c #Aligned32, \c #Aligned16, \c #Aligned8 or \c #Unaligned.
|
||||||
* \c #Aligned16, \c #Aligned8 or \c #Unaligned. The default is \c #Unaligned. \tparam StrideType optionally specifies
|
* The default is \c #Unaligned.
|
||||||
* strides. By default, Map assumes the memory layout of an ordinary, contiguous array. This can be overridden by
|
* \tparam StrideType optionally specifies strides. By default, Map assumes the memory layout
|
||||||
* specifying strides. The type passed here must be a specialization of the Stride template, see examples below.
|
* of an ordinary, contiguous array. This can be overridden by specifying strides.
|
||||||
*
|
* The type passed here must be a specialization of the Stride template, see examples below.
|
||||||
* This class represents a matrix or vector expression mapping an existing array of data.
|
*
|
||||||
* It can be used to let Eigen interface without any overhead with non-Eigen data structures,
|
* This class represents a matrix or vector expression mapping an existing array of data.
|
||||||
* such as plain C arrays or structures from other libraries. By default, it assumes that the
|
* It can be used to let Eigen interface without any overhead with non-Eigen data structures,
|
||||||
* data is laid out contiguously in memory. You can however override this by explicitly specifying
|
* such as plain C arrays or structures from other libraries. By default, it assumes that the
|
||||||
* inner and outer strides.
|
* data is laid out contiguously in memory. You can however override this by explicitly specifying
|
||||||
*
|
* inner and outer strides.
|
||||||
* Here's an example of simply mapping a contiguous array as a \ref TopicStorageOrders "column-major" matrix:
|
*
|
||||||
* \include Map_simple.cpp
|
* Here's an example of simply mapping a contiguous array as a \ref TopicStorageOrders "column-major" matrix:
|
||||||
* Output: \verbinclude Map_simple.out
|
* \include Map_simple.cpp
|
||||||
*
|
* Output: \verbinclude Map_simple.out
|
||||||
* If you need to map non-contiguous arrays, you can do so by specifying strides:
|
*
|
||||||
*
|
* If you need to map non-contiguous arrays, you can do so by specifying strides:
|
||||||
* Here's an example of mapping an array as a vector, specifying an inner stride, that is, the pointer
|
*
|
||||||
* increment between two consecutive coefficients. Here, we're specifying the inner stride as a compile-time
|
* Here's an example of mapping an array as a vector, specifying an inner stride, that is, the pointer
|
||||||
* fixed value.
|
* increment between two consecutive coefficients. Here, we're specifying the inner stride as a compile-time
|
||||||
* \include Map_inner_stride.cpp
|
* fixed value.
|
||||||
* Output: \verbinclude Map_inner_stride.out
|
* \include Map_inner_stride.cpp
|
||||||
*
|
* Output: \verbinclude Map_inner_stride.out
|
||||||
* Here's an example of mapping an array while specifying an outer stride. Here, since we're mapping
|
*
|
||||||
* as a column-major matrix, 'outer stride' means the pointer increment between two consecutive columns.
|
* Here's an example of mapping an array while specifying an outer stride. Here, since we're mapping
|
||||||
* Here, we're specifying the outer stride as a runtime parameter. Note that here \c OuterStride<> is
|
* as a column-major matrix, 'outer stride' means the pointer increment between two consecutive columns.
|
||||||
* a short version of \c OuterStride<Dynamic> because the default template parameter of OuterStride
|
* Here, we're specifying the outer stride as a runtime parameter. Note that here \c OuterStride<> is
|
||||||
* is \c Dynamic
|
* a short version of \c OuterStride<Dynamic> because the default template parameter of OuterStride
|
||||||
* \include Map_outer_stride.cpp
|
* is \c Dynamic
|
||||||
* Output: \verbinclude Map_outer_stride.out
|
* \include Map_outer_stride.cpp
|
||||||
*
|
* Output: \verbinclude Map_outer_stride.out
|
||||||
* For more details and for an example of specifying both an inner and an outer stride, see class Stride.
|
*
|
||||||
*
|
* For more details and for an example of specifying both an inner and an outer stride, see class Stride.
|
||||||
* \b Tip: to change the array of data mapped by a Map object, you can use the C++
|
*
|
||||||
* placement new syntax:
|
* \b Tip: to change the array of data mapped by a Map object, you can use the C++
|
||||||
*
|
* placement new syntax:
|
||||||
* Example: \include Map_placement_new.cpp
|
*
|
||||||
* Output: \verbinclude Map_placement_new.out
|
* Example: \include Map_placement_new.cpp
|
||||||
*
|
* Output: \verbinclude Map_placement_new.out
|
||||||
* This class is the return type of PlainObjectBase::Map() but can also be used directly.
|
*
|
||||||
*
|
* This class is the return type of PlainObjectBase::Map() but can also be used directly.
|
||||||
* \sa PlainObjectBase::Map(), \ref TopicStorageOrders
|
*
|
||||||
*/
|
* \sa PlainObjectBase::Map(), \ref TopicStorageOrders
|
||||||
template <typename PlainObjectType, int MapOptions, typename StrideType>
|
*/
|
||||||
class Map : public MapBase<Map<PlainObjectType, MapOptions, StrideType> > {
|
template<typename PlainObjectType, int MapOptions, typename StrideType> class Map
|
||||||
public:
|
: public MapBase<Map<PlainObjectType, MapOptions, StrideType> >
|
||||||
typedef MapBase<Map> Base;
|
{
|
||||||
EIGEN_DENSE_PUBLIC_INTERFACE(Map)
|
public:
|
||||||
|
|
||||||
typedef typename Base::PointerType PointerType;
|
typedef MapBase<Map> Base;
|
||||||
typedef PointerType PointerArgType;
|
EIGEN_DENSE_PUBLIC_INTERFACE(Map)
|
||||||
EIGEN_DEVICE_FUNC constexpr inline PointerType cast_to_pointer_type(PointerArgType ptr) const { return ptr; }
|
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC constexpr Index innerStride() const {
|
typedef typename Base::PointerType PointerType;
|
||||||
return StrideType::InnerStrideAtCompileTime != 0 ? m_stride.inner() : 1;
|
typedef PointerType PointerArgType;
|
||||||
}
|
EIGEN_DEVICE_FUNC
|
||||||
|
inline PointerType cast_to_pointer_type(PointerArgType ptr) { return ptr; }
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC constexpr Index outerStride() const {
|
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
|
||||||
return StrideType::OuterStrideAtCompileTime != 0 ? m_stride.outer()
|
inline Index innerStride() const
|
||||||
: internal::traits<Map>::OuterStrideAtCompileTime != Dynamic
|
{
|
||||||
? Index(internal::traits<Map>::OuterStrideAtCompileTime)
|
return StrideType::InnerStrideAtCompileTime != 0 ? m_stride.inner() : 1;
|
||||||
: IsVectorAtCompileTime ? (this->size() * innerStride())
|
}
|
||||||
: int(Flags) & RowMajorBit ? (this->cols() * innerStride())
|
|
||||||
: (this->rows() * innerStride());
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Constructor in the fixed-size case.
|
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
|
||||||
*
|
inline Index outerStride() const
|
||||||
* \param dataPtr pointer to the array to map
|
{
|
||||||
* \param stride optional Stride object, passing the strides.
|
return StrideType::OuterStrideAtCompileTime != 0 ? m_stride.outer()
|
||||||
*/
|
: internal::traits<Map>::OuterStrideAtCompileTime != Dynamic ? Index(internal::traits<Map>::OuterStrideAtCompileTime)
|
||||||
EIGEN_DEVICE_FUNC constexpr explicit inline Map(PointerArgType dataPtr, const StrideType& stride = StrideType())
|
: IsVectorAtCompileTime ? (this->size() * innerStride())
|
||||||
: Base(cast_to_pointer_type(dataPtr)), m_stride(stride) {}
|
: int(Flags)&RowMajorBit ? (this->cols() * innerStride())
|
||||||
|
: (this->rows() * innerStride());
|
||||||
|
}
|
||||||
|
|
||||||
/** Constructor in the dynamic-size vector case.
|
/** Constructor in the fixed-size case.
|
||||||
*
|
*
|
||||||
* \param dataPtr pointer to the array to map
|
* \param dataPtr pointer to the array to map
|
||||||
* \param size the size of the vector expression
|
* \param stride optional Stride object, passing the strides.
|
||||||
* \param stride optional Stride object, passing the strides.
|
*/
|
||||||
*/
|
EIGEN_DEVICE_FUNC
|
||||||
EIGEN_DEVICE_FUNC constexpr inline Map(PointerArgType dataPtr, Index size, const StrideType& stride = StrideType())
|
explicit inline Map(PointerArgType dataPtr, const StrideType& stride = StrideType())
|
||||||
: Base(cast_to_pointer_type(dataPtr), size), m_stride(stride) {}
|
: Base(cast_to_pointer_type(dataPtr)), m_stride(stride)
|
||||||
|
{
|
||||||
|
PlainObjectType::Base::_check_template_params();
|
||||||
|
}
|
||||||
|
|
||||||
/** Constructor in the dynamic-size matrix case.
|
/** Constructor in the dynamic-size vector case.
|
||||||
*
|
*
|
||||||
* \param dataPtr pointer to the array to map
|
* \param dataPtr pointer to the array to map
|
||||||
* \param rows the number of rows of the matrix expression
|
* \param size the size of the vector expression
|
||||||
* \param cols the number of columns of the matrix expression
|
* \param stride optional Stride object, passing the strides.
|
||||||
* \param stride optional Stride object, passing the strides.
|
*/
|
||||||
*/
|
EIGEN_DEVICE_FUNC
|
||||||
EIGEN_DEVICE_FUNC constexpr inline Map(PointerArgType dataPtr, Index rows, Index cols,
|
inline Map(PointerArgType dataPtr, Index size, const StrideType& stride = StrideType())
|
||||||
const StrideType& stride = StrideType())
|
: Base(cast_to_pointer_type(dataPtr), size), m_stride(stride)
|
||||||
: Base(cast_to_pointer_type(dataPtr), rows, cols), m_stride(stride) {}
|
{
|
||||||
|
PlainObjectType::Base::_check_template_params();
|
||||||
|
}
|
||||||
|
|
||||||
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Map)
|
/** Constructor in the dynamic-size matrix case.
|
||||||
|
*
|
||||||
|
* \param dataPtr pointer to the array to map
|
||||||
|
* \param rows the number of rows of the matrix expression
|
||||||
|
* \param cols the number of columns of the matrix expression
|
||||||
|
* \param stride optional Stride object, passing the strides.
|
||||||
|
*/
|
||||||
|
EIGEN_DEVICE_FUNC
|
||||||
|
inline Map(PointerArgType dataPtr, Index rows, Index cols, const StrideType& stride = StrideType())
|
||||||
|
: Base(cast_to_pointer_type(dataPtr), rows, cols), m_stride(stride)
|
||||||
|
{
|
||||||
|
PlainObjectType::Base::_check_template_params();
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Map)
|
||||||
StrideType m_stride;
|
|
||||||
|
protected:
|
||||||
|
StrideType m_stride;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace Eigen
|
|
||||||
|
|
||||||
#endif // EIGEN_MAP_H
|
} // end namespace Eigen
|
||||||
|
|
||||||
|
#endif // EIGEN_MAP_H
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user