mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-14 08:38:45 +00:00
Compare commits
1968 Commits
v3.5-DEV18
...
release_3.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bd224c8251 | ||
|
|
22f45f364f | ||
|
|
0286802d1c | ||
|
|
925445a215 | ||
|
|
511456bacd | ||
|
|
28f623b517 | ||
|
|
4931ad1bd7 | ||
|
|
7173437ab2 | ||
|
|
14cb588f55 | ||
|
|
2934bfe3bd | ||
|
|
dc3436dc65 | ||
|
|
190aca8a73 | ||
|
|
6ef1cb7b96 | ||
|
|
169c23ee58 | ||
|
|
7bf96285e7 | ||
|
|
067696aafd | ||
|
|
b07a7ef491 | ||
|
|
7a1d99fca9 | ||
|
|
8b3dbbca7b | ||
|
|
e0a198a164 | ||
|
|
f965345abc | ||
|
|
9b88abdeee | ||
|
|
a37e27770c | ||
|
|
228e2f24f9 | ||
|
|
93f8599070 | ||
|
|
7447af7053 | ||
|
|
922c5e6985 | ||
|
|
8a5bbc276f | ||
|
|
c97efc1e49 | ||
|
|
c01797b422 | ||
|
|
47688ba754 | ||
|
|
c97eac67a2 | ||
|
|
1a39471ad6 | ||
|
|
0bf39ec4dd | ||
|
|
103c87c600 | ||
|
|
a3873a30fe | ||
|
|
efe64d3a96 | ||
|
|
dbd33465c4 | ||
|
|
708d8744f6 | ||
|
|
c85dab80a8 | ||
|
|
1ecc6f9ec9 | ||
|
|
26bf31a3d6 | ||
|
|
97d5c896bd | ||
|
|
f0c9f12b44 | ||
|
|
ab337f165a | ||
|
|
1ae41e576a | ||
|
|
0767a98d0d | ||
|
|
00d09af489 | ||
|
|
e7b9275a36 | ||
|
|
fc10661541 | ||
|
|
536057bf66 | ||
|
|
fdb35bf74e | ||
|
|
e32eabc102 | ||
|
|
985710a828 | ||
|
|
1aa166bea1 | ||
|
|
884cfef788 | ||
|
|
02ad9767e2 | ||
|
|
574c8005c3 | ||
|
|
b907e7f0a6 | ||
|
|
29f59e3e24 | ||
|
|
36cb446810 | ||
|
|
6bf7781aea | ||
|
|
add0f301e9 | ||
|
|
c77b32efaa | ||
|
|
3aed45e96b | ||
|
|
392ec2a74a | ||
|
|
2fc0c1d9ca | ||
|
|
dae573c939 | ||
|
|
0f5ec45308 | ||
|
|
a808b68ad7 | ||
|
|
5c0eb9910b | ||
|
|
67136b3cdf | ||
|
|
42c43c7689 | ||
|
|
97570efdd2 | ||
|
|
9b10f73422 | ||
|
|
92963c8c83 | ||
|
|
0e8fe3f9c9 | ||
|
|
f2f519c44c | ||
|
|
5f759c0b31 | ||
|
|
64907a3d2b | ||
|
|
4e3e82655e | ||
|
|
528259db3e | ||
|
|
13167e021c | ||
|
|
0904ebe1e0 | ||
|
|
984f1f9d99 | ||
|
|
7c05a7f895 | ||
|
|
dda82c9a62 | ||
|
|
dd8f8ebdce | ||
|
|
ee65609143 | ||
|
|
84afd26262 | ||
|
|
7b7de8463b | ||
|
|
fb013c63e2 | ||
|
|
54d388c2a3 | ||
|
|
11decfc508 | ||
|
|
402edf51fc | ||
|
|
64386bc1ba | ||
|
|
b6fae05d48 | ||
|
|
9eb81385e8 | ||
|
|
0ddea94b7a | ||
|
|
88246a8b15 | ||
|
|
46bfab5c8b | ||
|
|
663bde04c5 | ||
|
|
30895b028d | ||
|
|
af21c35022 | ||
|
|
68c795440c | ||
|
|
dfe572c005 | ||
|
|
ef0eac8908 | ||
|
|
9531acf366 | ||
|
|
6f6d7c6a8f | ||
|
|
523d2d1909 | ||
|
|
bfa4b4b977 | ||
|
|
c65f313de5 | ||
|
|
b689d29653 | ||
|
|
e95d11671a | ||
|
|
3c3d2024ac | ||
|
|
cc5eaf4187 | ||
|
|
abb69b8fb5 | ||
|
|
841766effb | ||
|
|
afbb43edd1 | ||
|
|
33ba1c03ec | ||
|
|
bb972b7e8a | ||
|
|
018bd404e8 | ||
|
|
4f97bae97d | ||
|
|
dfeb8532a9 | ||
|
|
2a99c87620 | ||
|
|
0296693ddd | ||
|
|
8919eab5b2 | ||
|
|
7d0e6de0b1 | ||
|
|
1c5bbecf1c | ||
|
|
8e0b0a67a6 | ||
|
|
b08e662c9d | ||
|
|
5af234d6ad | ||
|
|
2c3eabdd8b | ||
|
|
9c7d1d4f31 | ||
|
|
53f8f5102c | ||
|
|
e477b05a98 | ||
|
|
3a16d1ecc2 | ||
|
|
63d13ba9e5 | ||
|
|
f947b6bd31 | ||
|
|
67962bfff8 | ||
|
|
5f22d12a61 | ||
|
|
996ee63cd5 | ||
|
|
a7ad1346e8 | ||
|
|
90172a4a62 | ||
|
|
68b70e0e4d | ||
|
|
434580ee81 | ||
|
|
cb23914a5f | ||
|
|
1941b9af7f | ||
|
|
67352f6dc2 | ||
|
|
fa8eb0b6da | ||
|
|
5a77180957 | ||
|
|
50a027ad70 | ||
|
|
a99cc3305e | ||
|
|
6f4da994a2 | ||
|
|
8946c53650 | ||
|
|
92ab04ac8a | ||
|
|
cfa767a854 | ||
|
|
9af08b7f3c | ||
|
|
523ffcc702 | ||
|
|
5c4f6e1f82 | ||
|
|
761e0527a2 | ||
|
|
fd3bab7e85 | ||
|
|
327150d659 | ||
|
|
d5905d92d0 | ||
|
|
10c2660f0b | ||
|
|
82e79fa898 | ||
|
|
8860d5da08 | ||
|
|
746cea2d26 | ||
|
|
edfc3ba642 | ||
|
|
a6338ee381 | ||
|
|
234bdb67e6 | ||
|
|
b43723e8ff | ||
|
|
6b15b7e50e | ||
|
|
7b64448912 | ||
|
|
925d5c3521 | ||
|
|
0185080f3f | ||
|
|
3b528f8a12 | ||
|
|
56500cf357 | ||
|
|
eca82afa4e | ||
|
|
abde31ecc3 | ||
|
|
1be14feb6d | ||
|
|
0d30d446f8 | ||
|
|
fbae10f103 | ||
|
|
cc6738bdf5 | ||
|
|
7d7ed5cfb3 | ||
|
|
300960f234 | ||
|
|
b02b5f1265 | ||
|
|
80b671f4aa | ||
|
|
ef23cb5d1c | ||
|
|
a212ff6408 | ||
|
|
efd9253352 | ||
|
|
aae3376135 | ||
|
|
c1bbe1b590 | ||
|
|
f8b6cc6c17 | ||
|
|
82df874e54 | ||
|
|
7b44eaa7a8 | ||
|
|
a31ce926dc | ||
|
|
481e11fffc | ||
|
|
0108a05f5a | ||
|
|
700f855ce1 | ||
|
|
1e8220237c | ||
|
|
6914832c24 | ||
|
|
07f672ff80 | ||
|
|
d58c539c00 | ||
|
|
a0a2b28629 | ||
|
|
3a34f7ce55 | ||
|
|
84eceebd00 | ||
|
|
853e248383 | ||
|
|
ce089de33e | ||
|
|
3180a166d8 | ||
|
|
f3b78338ac | ||
|
|
02cab3029b | ||
|
|
47355d17fe | ||
|
|
d8dc986c1e | ||
|
|
e3611455e4 | ||
|
|
d4f382e35d | ||
|
|
3bbd6ca334 | ||
|
|
d21ea7b26b | ||
|
|
4065534882 | ||
|
|
5e4189fa1a | ||
|
|
c0ec0aaa28 | ||
|
|
d35f7b22e5 | ||
|
|
be797ffb31 | ||
|
|
f015322040 | ||
|
|
09686a2cb7 | ||
|
|
9e13b73375 | ||
|
|
f82dd1b456 | ||
|
|
394309a7a6 | ||
|
|
dc470ecf74 | ||
|
|
c50cd4c0cc | ||
|
|
4ed7425d0c | ||
|
|
1b007014f1 | ||
|
|
76bf1bba21 | ||
|
|
a5d57cf3fa | ||
|
|
0a0c46b0e2 | ||
|
|
8dcd869084 | ||
|
|
0e22bd8d1a | ||
|
|
73e2e0709b | ||
|
|
c560f80245 | ||
|
|
83c145c270 | ||
|
|
e738b81c7c | ||
|
|
d282d1f5b2 | ||
|
|
34b028ae1a | ||
|
|
8fdc78b3fe | ||
|
|
774704c072 | ||
|
|
5ef4146971 | ||
|
|
eee2ee9be2 | ||
|
|
3b17371687 | ||
|
|
75800ce49f | ||
|
|
2674bf518b | ||
|
|
387873d9f0 | ||
|
|
9e99199553 | ||
|
|
0d979f9fb9 | ||
|
|
3b073b9168 | ||
|
|
8d8d1a0601 | ||
|
|
1967134418 | ||
|
|
ecfc23455a | ||
|
|
b96a31400b | ||
|
|
98a3a6984c | ||
|
|
05992c8c2f | ||
|
|
7e8f3a3228 | ||
|
|
d3fb4f1685 | ||
|
|
cb1e59f9dd | ||
|
|
086be52ad9 | ||
|
|
da01a8f39b | ||
|
|
6d4921ba09 | ||
|
|
48c8725507 | ||
|
|
ab055101e1 | ||
|
|
66275c6c21 | ||
|
|
e602ba4d31 | ||
|
|
4345c97960 | ||
|
|
9d2d8651ae | ||
|
|
f8b2a04b30 | ||
|
|
7fba9b1f5e | ||
|
|
cb7b2a07d8 | ||
|
|
5684b89c69 | ||
|
|
9d9ad753f3 | ||
|
|
dd5bc51604 | ||
|
|
c85054ed61 | ||
|
|
fcbe02e83e | ||
|
|
a5d64686d9 | ||
|
|
a63bee518d | ||
|
|
3e5fefa4ec | ||
|
|
f74b5aed6d | ||
|
|
aeb6630ede | ||
|
|
e97034fb7d | ||
|
|
9b29fb2f8d | ||
|
|
3a9620a3d9 | ||
|
|
be1af0f6d6 | ||
|
|
98c22dc185 | ||
|
|
4c975c7af2 | ||
|
|
345b70f38f | ||
|
|
12828cdce6 | ||
|
|
5251c5bbcc | ||
|
|
a0c2034fa9 | ||
|
|
93d0ac113a | ||
|
|
2e33c745c6 | ||
|
|
6b7121bdcb | ||
|
|
c0894805ac | ||
|
|
61afa38826 | ||
|
|
eb66524775 | ||
|
|
c8f9b75624 | ||
|
|
bf09243cba | ||
|
|
54e96060f3 | ||
|
|
328cd2a64d | ||
|
|
820a2f4b23 | ||
|
|
c2b82d1be7 | ||
|
|
a0dc39822f | ||
|
|
1c157a69a1 | ||
|
|
a04976fa41 | ||
|
|
1a285d1050 | ||
|
|
2373fc687a | ||
|
|
7a19fe4b95 | ||
|
|
f20d9ac85f | ||
|
|
65446397e2 | ||
|
|
041e426671 | ||
|
|
25307467c7 | ||
|
|
67294a61f3 | ||
|
|
4d7b56a942 | ||
|
|
789b1d90aa | ||
|
|
ba39715254 | ||
|
|
37cacd51ae | ||
|
|
9e41e22037 | ||
|
|
cd97b5b5f0 | ||
|
|
140621db42 | ||
|
|
e8829c66ec | ||
|
|
22a5930069 | ||
|
|
6b878c906b | ||
|
|
1dbbd26dec | ||
|
|
ec6d7838d1 | ||
|
|
f0b0d18e0e | ||
|
|
326e5ff46d | ||
|
|
edf0cd72ea | ||
|
|
2a1e4e52cc | ||
|
|
7c80da9832 | ||
|
|
d3c7f7abc4 | ||
|
|
7417e9cf1f | ||
|
|
f09e357993 | ||
|
|
150155ba84 | ||
|
|
919a418895 | ||
|
|
130abda5fe | ||
|
|
a13da9e917 | ||
|
|
3db1839471 | ||
|
|
5237b460f1 | ||
|
|
2f1194b0bd | ||
|
|
32b1f0f7d1 | ||
|
|
bef7e51d52 | ||
|
|
1b0e6059cf | ||
|
|
4812661c9c | ||
|
|
cd75224105 | ||
|
|
2b39ad28c8 | ||
|
|
0449988fb1 | ||
|
|
f906e8751c | ||
|
|
7230e28730 | ||
|
|
25dfe5bf3a | ||
|
|
309907b0ad | ||
|
|
f66b7e13a7 | ||
|
|
09b987e595 | ||
|
|
50f5efbfdb | ||
|
|
0e8702c3b0 | ||
|
|
f4630ea078 | ||
|
|
beed0b2023 | ||
|
|
214caf3389 | ||
|
|
346c84f8b7 | ||
|
|
8aa6818f2d | ||
|
|
a41935d8d2 | ||
|
|
ecb7910d40 | ||
|
|
066047354b | ||
|
|
db28dd9fdf | ||
|
|
13b026eb3a | ||
|
|
7e10b0524a | ||
|
|
b8beaf3946 | ||
|
|
6441a6faf8 | ||
|
|
35cebf4747 | ||
|
|
d7e9e305c5 | ||
|
|
3976a78977 | ||
|
|
806f012dea | ||
|
|
7b93b2a533 | ||
|
|
2554e033f0 | ||
|
|
ede006341f | ||
|
|
d2a1134dbc | ||
|
|
315d35dab1 | ||
|
|
f934ae2a5b | ||
|
|
a32d0a781b | ||
|
|
522844508e | ||
|
|
be8ae85dbd | ||
|
|
7fd2c98a20 | ||
|
|
c7d7972213 | ||
|
|
5704668007 | ||
|
|
71d9db909e | ||
|
|
4ae6dbea93 | ||
|
|
8b0af9abf5 | ||
|
|
48a3afc59e | ||
|
|
257d877d03 | ||
|
|
e0ec5ba2d1 | ||
|
|
006dbdf102 | ||
|
|
5c996e2317 | ||
|
|
ec67b66023 | ||
|
|
acd510d65f | ||
|
|
d6274c0fff | ||
|
|
d6d969f819 | ||
|
|
8dbaad3876 | ||
|
|
0762f0daaf | ||
|
|
f9b2b60b37 | ||
|
|
b27d3d42c8 | ||
|
|
c74a1e76a3 | ||
|
|
a8de13b7cf | ||
|
|
680f7b9665 | ||
|
|
79fd18ef55 | ||
|
|
77c9b8d645 | ||
|
|
8d3f580c0f | ||
|
|
20201c16a8 | ||
|
|
b12e1fa9b6 | ||
|
|
2f703594e9 | ||
|
|
32bd7955a8 | ||
|
|
6e7931508f | ||
|
|
552c44d847 | ||
|
|
0cfa1e7d49 | ||
|
|
7ca84ecd3e | ||
|
|
5a2e1cc3a8 | ||
|
|
595b38360e | ||
|
|
89dc137a52 | ||
|
|
655fb69b42 | ||
|
|
320cddb1e1 | ||
|
|
7a08f9e92c | ||
|
|
f04a20db21 | ||
|
|
0c4e5f3080 | ||
|
|
5225ef0f02 | ||
|
|
180af0ab04 | ||
|
|
a023e0efc0 | ||
|
|
16cc48f933 | ||
|
|
04b6334f59 | ||
|
|
7929944f73 | ||
|
|
e1ce93728d | ||
|
|
3096fb42a1 | ||
|
|
1ead8e0922 | ||
|
|
3f66fec5f7 | ||
|
|
6473ed76ce | ||
|
|
9c727a8770 | ||
|
|
5b838b4a0f | ||
|
|
ee3c30f527 | ||
|
|
d9b768514a | ||
|
|
970e44a913 | ||
|
|
007dc4b518 | ||
|
|
289962cd11 | ||
|
|
0e8d452956 | ||
|
|
a3f42c0746 | ||
|
|
9976746e49 | ||
|
|
c8c4666faa | ||
|
|
f43e6433e3 | ||
|
|
d2a7f5797a | ||
|
|
94ccac5e0f | ||
|
|
8f6d30d6d1 | ||
|
|
474edee78f | ||
|
|
ae8a8c0b4b | ||
|
|
6c0c56ab5b | ||
|
|
09e2ac95da | ||
|
|
fab0c1aae4 | ||
|
|
10317e4730 | ||
|
|
8330664467 | ||
|
|
4f30e98e50 | ||
|
|
272963b832 | ||
|
|
ff3d6b4a63 | ||
|
|
734d9c2739 | ||
|
|
d0bb437fc0 | ||
|
|
d7957363ff | ||
|
|
aecc1c970a | ||
|
|
7be34c1dcd | ||
|
|
70ed4e36e0 | ||
|
|
4f005d4491 | ||
|
|
5502d87af7 | ||
|
|
d56d52c01f | ||
|
|
d568dd0e06 | ||
|
|
dfdf0c5898 | ||
|
|
53ee8f358c | ||
|
|
4c720884b6 | ||
|
|
4c6c8e6d71 | ||
|
|
5fb2dfb73e | ||
|
|
1dc1cd678f | ||
|
|
a3c1f6d2fc | ||
|
|
fb76ecc33c | ||
|
|
8580a45c38 | ||
|
|
ca3a48c0bc | ||
|
|
e26ab4f957 | ||
|
|
d97adfe987 | ||
|
|
65853b095d | ||
|
|
c592de6af9 | ||
|
|
e0892371b7 | ||
|
|
6236611aee | ||
|
|
ea26efc44a | ||
|
|
60430fa97b | ||
|
|
437c38f959 | ||
|
|
08876a9065 | ||
|
|
4d9367ed20 | ||
|
|
dab1520e39 | ||
|
|
be5f0b3d22 | ||
|
|
bd64625c05 | ||
|
|
cb874b6793 | ||
|
|
2477096345 | ||
|
|
f6375f18f9 | ||
|
|
a6628eb447 | ||
|
|
e3e826a017 | ||
|
|
578a7fb263 | ||
|
|
41fbd9563a | ||
|
|
d953b44c00 | ||
|
|
32c7b68f43 | ||
|
|
4ddaa041a9 | ||
|
|
b5046f4be1 | ||
|
|
01beed8f46 | ||
|
|
d7c1b66b27 | ||
|
|
9b679a7d79 | ||
|
|
78850dabc3 | ||
|
|
494e01ba7a | ||
|
|
5e516aefca | ||
|
|
e31f05236c | ||
|
|
13dc1059bc | ||
|
|
ec46e545f5 | ||
|
|
1e480b6965 | ||
|
|
5e8e490e51 | ||
|
|
fa296f7c13 | ||
|
|
cc8b6b114d | ||
|
|
73d28661fa | ||
|
|
a4d928e4a0 | ||
|
|
7c944d6100 | ||
|
|
c973bd7d85 | ||
|
|
e02e19a979 | ||
|
|
fecaad5cbf | ||
|
|
1e18321da7 | ||
|
|
524dad3f4d | ||
|
|
2096342fe4 | ||
|
|
15595090e7 | ||
|
|
bf2a1735ed | ||
|
|
78a4532793 | ||
|
|
31f51dbdd5 | ||
|
|
f4a14b6ac9 | ||
|
|
33018aab77 | ||
|
|
81d59d4637 | ||
|
|
6d3ae32e61 | ||
|
|
5f548785ad | ||
|
|
1297d76ee4 | ||
|
|
f86bc6752e | ||
|
|
f8cdbf3e39 | ||
|
|
e1ed960714 | ||
|
|
39c135a29b | ||
|
|
efba58b509 | ||
|
|
ba3c0bf34e | ||
|
|
e10aac4de4 | ||
|
|
7cc2219293 | ||
|
|
29485aa327 | ||
|
|
f9fa6ca401 | ||
|
|
d57c3c9ce5 | ||
|
|
0d2310e76a | ||
|
|
d7ae5610cf | ||
|
|
eaa6120467 | ||
|
|
e464762f7f | ||
|
|
195514c30e | ||
|
|
5fd1a08419 | ||
|
|
2ea3080d24 | ||
|
|
fd546b4da1 | ||
|
|
2b30f9aa50 | ||
|
|
09de27b0d2 | ||
|
|
cc3f291113 | ||
|
|
dcd2a69951 | ||
|
|
c3bbd3a9ee | ||
|
|
d449933ab1 | ||
|
|
7b2bd79448 | ||
|
|
6e88ee4ca6 | ||
|
|
b893e702b3 | ||
|
|
18dbedc586 | ||
|
|
fcad1ed196 | ||
|
|
8375f539db | ||
|
|
cc0bb2e6d6 | ||
|
|
95cd28a279 | ||
|
|
39fc9e4537 | ||
|
|
1f77f08ae0 | ||
|
|
91f2c46c3e | ||
|
|
01e0d14757 | ||
|
|
29a76773a6 | ||
|
|
abdce42223 | ||
|
|
98466cc9cf | ||
|
|
924da10958 | ||
|
|
0f9b92f8cf | ||
|
|
171760097d | ||
|
|
db9623a201 | ||
|
|
62012f1990 | ||
|
|
b36bbdc3c0 | ||
|
|
00b50b47c3 | ||
|
|
1986df1c95 | ||
|
|
15bbe288a0 | ||
|
|
534a6a4ef1 | ||
|
|
d41e7dd1f6 | ||
|
|
a98ac12d0e | ||
|
|
49989f95b6 | ||
|
|
98e49c3228 | ||
|
|
171882dc9f | ||
|
|
bd864344bb | ||
|
|
72f91c31a8 | ||
|
|
155273232f | ||
|
|
a0f77fbf70 | ||
|
|
fd384d69ba | ||
|
|
7e998d965a | ||
|
|
f1045d1aed | ||
|
|
557a0a27ec | ||
|
|
e772e068d5 | ||
|
|
c91f6d89ac | ||
|
|
031b268270 | ||
|
|
b086b779cf | ||
|
|
c60f6f4bb6 | ||
|
|
173b1a754e | ||
|
|
0f432a7824 | ||
|
|
0ffca019ea | ||
|
|
360bc29d52 | ||
|
|
7f005935e5 | ||
|
|
b9fbcce56e | ||
|
|
a918a5c28e | ||
|
|
c89d15e067 | ||
|
|
86e6b4781c | ||
|
|
92e3438ef3 | ||
|
|
59a2f3841f | ||
|
|
a52a07de7a | ||
|
|
806e907584 | ||
|
|
0cc4a338d2 | ||
|
|
b6f1151990 | ||
|
|
85e5353990 | ||
|
|
456b06348f | ||
|
|
c502c9bbc0 | ||
|
|
e34a36f98a | ||
|
|
663b6af8fb | ||
|
|
1b38e556c3 | ||
|
|
3e21d6bd39 | ||
|
|
8e3863218d | ||
|
|
c29a776c21 | ||
|
|
566d562982 | ||
|
|
c78fcda1e3 | ||
|
|
61d00c161f | ||
|
|
bd49279553 | ||
|
|
73a354156d | ||
|
|
cb092b9d73 | ||
|
|
722588f1db | ||
|
|
9d6e08547f | ||
|
|
39a7e67085 | ||
|
|
c4d6ee065e | ||
|
|
b738038907 | ||
|
|
3bc1391cb1 | ||
|
|
73e174a982 | ||
|
|
20d34664e3 | ||
|
|
8c5144657c | ||
|
|
eadc3a78bf | ||
|
|
68e7fcacb4 | ||
|
|
4e570230a7 | ||
|
|
830317ef03 | ||
|
|
1335786957 | ||
|
|
271c0a979a | ||
|
|
1026145f9b | ||
|
|
fe2643eb65 | ||
|
|
6ecff9e2d1 | ||
|
|
9023014833 | ||
|
|
c7599be666 | ||
|
|
0dd9d045cd | ||
|
|
7540b69eea | ||
|
|
de3fadf8e7 | ||
|
|
a70231c4bb | ||
|
|
0262d5f968 | ||
|
|
6919ade54e | ||
|
|
0243aedded | ||
|
|
32a6089f50 | ||
|
|
58c5cc20d2 | ||
|
|
8753032170 | ||
|
|
e448aa1a8d | ||
|
|
58c8b98f47 | ||
|
|
586033c6a5 | ||
|
|
154077793e | ||
|
|
07d835e076 | ||
|
|
3888246b42 | ||
|
|
061cb9328c | ||
|
|
c3a1afa0a0 | ||
|
|
968bdc1d17 | ||
|
|
d17d3c59a3 | ||
|
|
99f73bdba5 | ||
|
|
df08c607d1 | ||
|
|
2b063c91c2 | ||
|
|
6e4dba86f0 | ||
|
|
316e62d27c | ||
|
|
a5043d1b59 | ||
|
|
0ba409a192 | ||
|
|
aed30180f6 | ||
|
|
773e5a21b0 | ||
|
|
0d0cf42918 | ||
|
|
5472b0b50b | ||
|
|
3a07cc52d7 | ||
|
|
380dc47ac7 | ||
|
|
815496a8d1 | ||
|
|
6486e89145 | ||
|
|
d83041282d | ||
|
|
176226545f | ||
|
|
df1d83c357 | ||
|
|
20a7d74c16 | ||
|
|
489c499ba7 | ||
|
|
95e5cb3bc4 | ||
|
|
9a0b6e0bc7 | ||
|
|
44f49c54d6 | ||
|
|
bee7d48ac2 | ||
|
|
d7e1747a2b | ||
|
|
9315b301d7 | ||
|
|
4d5841e4b1 | ||
|
|
e1ac00b860 | ||
|
|
3d07321b2f | ||
|
|
c4204231cc | ||
|
|
f279898bd5 | ||
|
|
6560194db4 | ||
|
|
aaa6bac5ed | ||
|
|
a4e9b52eeb | ||
|
|
ae2df3a271 | ||
|
|
ce920126f5 | ||
|
|
cebf46a99d | ||
|
|
f072a1ad6e | ||
|
|
f77f040ae7 | ||
|
|
07c532a588 | ||
|
|
6572bbb52a | ||
|
|
3e153f03ac | ||
|
|
ac606065aa | ||
|
|
0a03aac7e8 | ||
|
|
79f4bb2815 | ||
|
|
d932811c97 | ||
|
|
1e1ddfaaee | ||
|
|
3e6214624d | ||
|
|
88060faab6 | ||
|
|
6c2a435759 | ||
|
|
c9e01353a0 | ||
|
|
9ff6d6ab97 | ||
|
|
d27327d8c1 | ||
|
|
55e9cdb444 | ||
|
|
46be903027 | ||
|
|
6c960f11c3 | ||
|
|
96c8508da2 | ||
|
|
37c1ec4bd8 | ||
|
|
5540160d3f | ||
|
|
2536bafcb2 | ||
|
|
8de66b8f2b | ||
|
|
2cbf324a26 | ||
|
|
4c7bdc3963 | ||
|
|
133364e597 | ||
|
|
39d19e8c1a | ||
|
|
f0f1b13754 | ||
|
|
de10c10a50 | ||
|
|
5d666c8233 | ||
|
|
696a04e8a0 | ||
|
|
e261794992 | ||
|
|
465ec039a2 | ||
|
|
ea548695b6 | ||
|
|
0b3a883303 | ||
|
|
c474dae4b6 | ||
|
|
cb04baf734 | ||
|
|
e79b474ea8 | ||
|
|
c01b696551 | ||
|
|
5a1bd1a27e | ||
|
|
c15d1bc33b | ||
|
|
a0a9c31641 | ||
|
|
5f78616696 | ||
|
|
4ed2565b2f | ||
|
|
6e77d6bde8 | ||
|
|
df1b5fdcaa | ||
|
|
378cf95784 | ||
|
|
2a8678d416 | ||
|
|
e3fda3cc0d | ||
|
|
a2b95df762 | ||
|
|
3f476a8226 | ||
|
|
92f81ef711 | ||
|
|
e849b4fd81 | ||
|
|
239f66fa6f | ||
|
|
be3cb9d149 | ||
|
|
58617cb165 | ||
|
|
5c33ffb1d4 | ||
|
|
b9b6745da5 | ||
|
|
763235a573 | ||
|
|
e9abe68736 | ||
|
|
cabe078453 | ||
|
|
2be7a2c86e | ||
|
|
0fe28abe5a | ||
|
|
5714a74e88 | ||
|
|
44c6749d14 | ||
|
|
b79166fa59 | ||
|
|
fc9e302aef | ||
|
|
921e81fad8 | ||
|
|
3308372445 | ||
|
|
e6b302dd6c | ||
|
|
e1b8293f01 | ||
|
|
92d1244b68 | ||
|
|
c726325af6 | ||
|
|
209470bf8f | ||
|
|
bc9eaccde2 | ||
|
|
2d6cc255ec | ||
|
|
58f8d9394d | ||
|
|
06914d9446 | ||
|
|
453b05a188 | ||
|
|
ace6760fbb | ||
|
|
da75f0cc38 | ||
|
|
14b287109f | ||
|
|
b44be0897d | ||
|
|
cf31bffed2 | ||
|
|
d84d329a78 | ||
|
|
8d89ba4e67 | ||
|
|
276791edb9 | ||
|
|
2d64166acd | ||
|
|
cbe75fae47 | ||
|
|
537b6677d3 | ||
|
|
980c99cfae | ||
|
|
cdb117486a | ||
|
|
01b0e4767b | ||
|
|
0eb8d63d07 | ||
|
|
d59b7d43f4 | ||
|
|
d392984993 | ||
|
|
c72b81ea84 | ||
|
|
773b076606 | ||
|
|
5dc4ace31d | ||
|
|
0427042709 | ||
|
|
d76701285d | ||
|
|
97ce2989bf | ||
|
|
d8c21e4070 | ||
|
|
0d3a8c911a | ||
|
|
a298715bb5 | ||
|
|
1b18ec7eeb | ||
|
|
33a4cf517d | ||
|
|
105f15e3e0 | ||
|
|
d21a603fa1 | ||
|
|
5d510388cf | ||
|
|
0b7d817c2d | ||
|
|
2b6473da60 | ||
|
|
cefc2cb81c | ||
|
|
b29f72d19c | ||
|
|
75ba4c0e90 | ||
|
|
1d4e93350a | ||
|
|
1120704073 | ||
|
|
41456b5cc1 | ||
|
|
cf745c1200 | ||
|
|
89d99ccecf | ||
|
|
08ff66a7bd | ||
|
|
dfe4da61d8 | ||
|
|
3c5d53a5bb | ||
|
|
9b52cf6a6c | ||
|
|
944f0ba73d | ||
|
|
24203a01ad | ||
|
|
c6c5505610 | ||
|
|
f251e982ae | ||
|
|
d881a2b3be | ||
|
|
4e3a258a1c | ||
|
|
6f79286302 | ||
|
|
ea1aa13a9b | ||
|
|
c25e9f2749 | ||
|
|
5eb519a214 | ||
|
|
61b5fee924 | ||
|
|
ae318a43ba | ||
|
|
759c6593cf | ||
|
|
6f948346a4 | ||
|
|
e098816f2b | ||
|
|
055833eed9 | ||
|
|
f0d839c37b | ||
|
|
c373e65010 | ||
|
|
0d57f88ac2 | ||
|
|
d5b09a4c9c | ||
|
|
afb69d8edb | ||
|
|
603c8cd651 | ||
|
|
983874d599 | ||
|
|
906cffba8e | ||
|
|
af19f31b24 | ||
|
|
47cb560633 | ||
|
|
e24d25ff47 | ||
|
|
373f3b7a35 | ||
|
|
b887f69a1b | ||
|
|
80086ace46 | ||
|
|
53e19a006d | ||
|
|
2d1e36549c | ||
|
|
763458564c | ||
|
|
5f68d2dce0 | ||
|
|
3c639d3377 | ||
|
|
ec11d90160 | ||
|
|
c49fa4f4d5 | ||
|
|
8c01d6291e | ||
|
|
34526f2fe9 | ||
|
|
487ec866f5 | ||
|
|
36df458406 | ||
|
|
1b61f076ca | ||
|
|
cb37db2281 | ||
|
|
1957404d03 | ||
|
|
90acbedabb | ||
|
|
56532be1ea | ||
|
|
bed5f1e820 | ||
|
|
a42ca208b6 | ||
|
|
9ff48f067a | ||
|
|
70fa7c0a45 | ||
|
|
e874714f60 | ||
|
|
71f34634e3 | ||
|
|
afd6552b3b | ||
|
|
8e5a2b42d0 | ||
|
|
bf02c868ea | ||
|
|
25bb4beaa5 | ||
|
|
c187dbe686 | ||
|
|
44fd1885a1 | ||
|
|
197d320bf8 | ||
|
|
d17bba8ce1 | ||
|
|
fe4301a7e2 | ||
|
|
aaf6f282b0 | ||
|
|
f30dd0a9c5 | ||
|
|
d4aebbb441 | ||
|
|
f47c3003a7 | ||
|
|
a7b08c4abf | ||
|
|
a107a0203c | ||
|
|
aaa7889172 | ||
|
|
9e5980f82c | ||
|
|
45345679a6 | ||
|
|
c187d4325b | ||
|
|
7d32bb4446 | ||
|
|
bbc7a03178 | ||
|
|
cec7c4dd52 | ||
|
|
4273480bf4 | ||
|
|
a5252334ef | ||
|
|
e05cf52446 | ||
|
|
1345779cfc | ||
|
|
cfd456c798 | ||
|
|
4af953ee00 | ||
|
|
617ebc3d82 | ||
|
|
3e846a3d20 | ||
|
|
da8341f619 | ||
|
|
d3cafc4aed | ||
|
|
42b37ce017 | ||
|
|
fc9c116fa4 | ||
|
|
a2da081681 | ||
|
|
b6e3ae4c96 | ||
|
|
eb6f111a0d | ||
|
|
f5f38f54e9 | ||
|
|
6ed93a22a1 | ||
|
|
f4dd2f10bd | ||
|
|
2d446cc9c2 | ||
|
|
4c50c1fb53 | ||
|
|
83a50db2cb | ||
|
|
e77096df35 | ||
|
|
f51856a52a | ||
|
|
294bf71f96 | ||
|
|
4ab82e9755 | ||
|
|
b7a56a9dd9 | ||
|
|
cde4ec0194 | ||
|
|
ca191e3163 | ||
|
|
d2a530e19e | ||
|
|
4c62c52fc3 | ||
|
|
b2e90c0af6 | ||
|
|
52c1441e03 | ||
|
|
3d1f8ee5fa | ||
|
|
1023e599a0 | ||
|
|
586ead3638 | ||
|
|
d50e1a8552 | ||
|
|
8c30a6da4a | ||
|
|
a1087c9bb3 | ||
|
|
e363f57a74 | ||
|
|
c61a6d846e | ||
|
|
22ea3399fe | ||
|
|
16dfd234e2 | ||
|
|
4351c68770 | ||
|
|
c10b666b55 | ||
|
|
0dfa8f0e00 | ||
|
|
9264d112ef | ||
|
|
5fdf427f39 | ||
|
|
4c19365e8b | ||
|
|
28cbf3b943 | ||
|
|
410b28f4db | ||
|
|
73e175e0f3 | ||
|
|
8e84ed280d | ||
|
|
0d4c289b9e | ||
|
|
f358f335b0 | ||
|
|
1593576cff | ||
|
|
5066fa990d | ||
|
|
a418b601b1 | ||
|
|
01f1e0e9bd | ||
|
|
aeb0e142cd | ||
|
|
7cacf01e8d | ||
|
|
e95eb7b39d | ||
|
|
fc3de5f84a | ||
|
|
97f58096cb | ||
|
|
2fb044e653 | ||
|
|
de02184079 | ||
|
|
6164dd963f | ||
|
|
8c5b416b56 | ||
|
|
b2da0afb83 | ||
|
|
8b651b50dc | ||
|
|
b69daad663 | ||
|
|
0179c3b3d8 | ||
|
|
894d9e6e23 | ||
|
|
9e4fe431e4 | ||
|
|
c3f7cf1404 | ||
|
|
f1c6394305 | ||
|
|
0f40659052 | ||
|
|
16d5c82f21 | ||
|
|
96b4cacec9 | ||
|
|
1a184f925d | ||
|
|
84f706f370 | ||
|
|
42632c4d8d | ||
|
|
203c505f34 | ||
|
|
5ef8817107 | ||
|
|
46e07a7016 | ||
|
|
35606d321c | ||
|
|
fbd095a2d4 | ||
|
|
79071a2f3b | ||
|
|
80d7eed382 | ||
|
|
a0409e8cea | ||
|
|
6cdd5bbbe7 | ||
|
|
39feb5807c | ||
|
|
99fb4f551e | ||
|
|
6fcabd699a | ||
|
|
bdd6d2c219 | ||
|
|
90e20d79bd | ||
|
|
ebca2b846a | ||
|
|
2a43f11c72 | ||
|
|
6cdb848e9f | ||
|
|
2372b4cdbe | ||
|
|
2eed6f66dc | ||
|
|
3c6bbd5ec6 | ||
|
|
1eae9f4071 | ||
|
|
414cc630fd | ||
|
|
2ada830c5b | ||
|
|
80ba487153 | ||
|
|
9bb1f3434d | ||
|
|
64e83121ca | ||
|
|
97da9f9539 | ||
|
|
c52d260949 | ||
|
|
9a2d71dc5d | ||
|
|
1d9f570ed8 | ||
|
|
6bc48200e7 | ||
|
|
c886158c16 | ||
|
|
c49180460d | ||
|
|
7c90abf675 | ||
|
|
f0fd495a21 | ||
|
|
3f9892d130 | ||
|
|
8150d5b7ce | ||
|
|
edec952b86 | ||
|
|
7d9337fb23 | ||
|
|
7e3f141124 | ||
|
|
750f7fb258 | ||
|
|
08632206c3 | ||
|
|
51eb9e6c96 | ||
|
|
7189c6d759 | ||
|
|
5a27239e01 | ||
|
|
9a62573087 | ||
|
|
e2c6f2ea28 | ||
|
|
7a4be49492 | ||
|
|
11092bf436 | ||
|
|
c52a861a9a | ||
|
|
f01ed7c77c | ||
|
|
fa1e1d00ae | ||
|
|
1dde50f6e5 | ||
|
|
5d18b810a7 | ||
|
|
947393914f | ||
|
|
3bf2f13764 | ||
|
|
1f8bafb334 | ||
|
|
911b9bd966 | ||
|
|
ba5cf3ed1d | ||
|
|
c850a532f6 | ||
|
|
b9039e7767 | ||
|
|
2874bf6bfa | ||
|
|
4b93632b42 | ||
|
|
e885966195 | ||
|
|
1a5b7e1464 | ||
|
|
c98695cd34 | ||
|
|
f767b066df | ||
|
|
169bd9c4e0 | ||
|
|
5bd48dd4f6 | ||
|
|
9b2226d3ba | ||
|
|
b91c8395c0 | ||
|
|
cc27d6be84 | ||
|
|
a1d2fd8f41 | ||
|
|
a33a74923b | ||
|
|
c701c8a510 | ||
|
|
2e4fa9f406 | ||
|
|
9a72ab4269 | ||
|
|
98ff3aaf11 | ||
|
|
83b551deaf | ||
|
|
af94c6f8c5 | ||
|
|
6349e53232 | ||
|
|
eba028475a | ||
|
|
e3d11c27a8 | ||
|
|
0f73c15c0e | ||
|
|
20e0b4aeca | ||
|
|
b313cb4f37 | ||
|
|
64da909243 | ||
|
|
94c723f4a0 | ||
|
|
c16d4c4667 | ||
|
|
3b2aa33c6a | ||
|
|
e6938a38f8 | ||
|
|
5518ac98a8 | ||
|
|
88e6c4cbd2 | ||
|
|
b02a640d6e | ||
|
|
ec195656f7 | ||
|
|
d0dba1d8a1 | ||
|
|
1599546b68 | ||
|
|
709994c3e7 | ||
|
|
c2abdc2a5b | ||
|
|
cd2de5dc3d | ||
|
|
d9df2bb76b | ||
|
|
8ec6d513b8 | ||
|
|
0b5153a6a5 | ||
|
|
93259ce7e0 | ||
|
|
00b498c8b7 | ||
|
|
2162cb1374 | ||
|
|
13c91cf67d | ||
|
|
ac5ae5027b | ||
|
|
e90eaf281f | ||
|
|
5dd950c77b | ||
|
|
9bdbf22f7c | ||
|
|
a27065673c | ||
|
|
028e822aa4 | ||
|
|
fdf6d4e862 | ||
|
|
0e3766a504 | ||
|
|
3bfcfa57aa | ||
|
|
4d205bd742 | ||
|
|
8956f60826 | ||
|
|
0e1bec38aa | ||
|
|
225cf0c9d5 | ||
|
|
ad4d06faa8 | ||
|
|
5eafea682b | ||
|
|
c3145c5f04 | ||
|
|
0dc5fc2f6f | ||
|
|
984d28abf0 | ||
|
|
05e89e5c34 | ||
|
|
32884b1c6a | ||
|
|
e1086afc50 | ||
|
|
21c07be749 | ||
|
|
59f736bb50 | ||
|
|
a81c97c09b | ||
|
|
c72a14a023 | ||
|
|
903861bae9 | ||
|
|
dff682fd88 | ||
|
|
6637a45929 | ||
|
|
837a7c6154 | ||
|
|
e32e233d5f | ||
|
|
b66f65e129 | ||
|
|
9dbfc10e04 | ||
|
|
3be603a9ee | ||
|
|
e4ad4ab1a3 | ||
|
|
bf76bac59d | ||
|
|
c3463860d5 | ||
|
|
2034b8754a | ||
|
|
1c4c83af5e | ||
|
|
5c84f7f789 | ||
|
|
dbecc005b5 | ||
|
|
04b4d945fa | ||
|
|
74f3a213ac | ||
|
|
f3af493aba | ||
|
|
f6bcccb04c | ||
|
|
c1727623a8 | ||
|
|
757a01e876 | ||
|
|
20d8836708 | ||
|
|
775765b853 | ||
|
|
3982267e29 | ||
|
|
fc4b8f7cbc | ||
|
|
7274268f47 | ||
|
|
e1f9005cf5 | ||
|
|
16e00fde90 | ||
|
|
2418d3b95b | ||
|
|
df2d436a02 | ||
|
|
20c975e7df | ||
|
|
7d8c27fd54 | ||
|
|
b0a8c6edfa | ||
|
|
6163ece7d6 | ||
|
|
66fb3b2bde | ||
|
|
14e6fd5393 | ||
|
|
47d79bd872 | ||
|
|
6e8bad3d19 | ||
|
|
1ec634f043 | ||
|
|
2b54f68d50 | ||
|
|
410aaf6a93 | ||
|
|
60600948be | ||
|
|
3450f577d3 | ||
|
|
d55cd20639 | ||
|
|
56ecb3e538 | ||
|
|
365848b79e | ||
|
|
125a92514c | ||
|
|
0881250542 | ||
|
|
0286583d4b | ||
|
|
7cc6733df1 | ||
|
|
4447f8bffd | ||
|
|
ddcd2825a2 | ||
|
|
f24ee9be8a | ||
|
|
5194d09ec3 | ||
|
|
bc13092cd2 | ||
|
|
15b491409a | ||
|
|
92f3a237be | ||
|
|
a6ed25c7e4 | ||
|
|
45a628b4b9 | ||
|
|
b6ee709520 | ||
|
|
77bbca0a16 | ||
|
|
6ca1bd9a9c | ||
|
|
93ff6c36b4 | ||
|
|
6a3734971d | ||
|
|
f8f43eed4c | ||
|
|
8a1842a9ba | ||
|
|
2d3eed0a98 | ||
|
|
df160a10a1 | ||
|
|
a8473441ae | ||
|
|
f18b5470ec | ||
|
|
f51a6a6cb1 | ||
|
|
cc6fa1d02a | ||
|
|
0352e19e34 | ||
|
|
4f64b88f0f | ||
|
|
4348a6279c | ||
|
|
d52fb5a68f | ||
|
|
c179419feb | ||
|
|
b89019264e | ||
|
|
922ebf987b | ||
|
|
ca5504e486 | ||
|
|
369ffd2040 | ||
|
|
f4fcc93693 | ||
|
|
e8b1f69d63 | ||
|
|
6c31805981 | ||
|
|
f2d93cc2dc | ||
|
|
5a0b022188 | ||
|
|
1cb1beb09c | ||
|
|
47e67f4d37 | ||
|
|
5772f6fd2f | ||
|
|
d4a5eaa501 | ||
|
|
881e517b1a | ||
|
|
21415379af | ||
|
|
89b74816f6 | ||
|
|
f3e9ba3573 | ||
|
|
2b68037c72 | ||
|
|
71a81e7f01 | ||
|
|
f261a76b9e | ||
|
|
a94500f1c3 | ||
|
|
2c0ce8f5c5 | ||
|
|
4b4d86f413 | ||
|
|
670698fdef | ||
|
|
73f11db578 | ||
|
|
021ecda647 | ||
|
|
44475a03fb | ||
|
|
7ee6ef43c1 | ||
|
|
caaae923ad | ||
|
|
8627f26b2c | ||
|
|
f415dc38b0 | ||
|
|
3f92810240 | ||
|
|
fc00d28873 | ||
|
|
7daf2fa63e | ||
|
|
eec8d6616c | ||
|
|
9bd6cff3e3 | ||
|
|
d3c04e27fa | ||
|
|
fd0a5955ef | ||
|
|
4029c3a9aa | ||
|
|
c1edbcb00a | ||
|
|
fcc9660b64 | ||
|
|
532b29b9d1 | ||
|
|
c973328779 | ||
|
|
76d459a895 | ||
|
|
b6eabc63d1 | ||
|
|
e7aaebcd00 | ||
|
|
7d06cd5ad1 | ||
|
|
cc11f1fa2d | ||
|
|
4cd24bc09a | ||
|
|
a4dbfa69d3 | ||
|
|
d042ec591e | ||
|
|
211b9b23cd | ||
|
|
d6c16dd9de | ||
|
|
e1db9c832f | ||
|
|
05ee4f40da | ||
|
|
a0add0bdc9 | ||
|
|
a9ddef9667 | ||
|
|
d69fa7986f | ||
|
|
3ff380ce0f | ||
|
|
c0bed13cfa | ||
|
|
794efdaf06 | ||
|
|
5e54c994b7 | ||
|
|
0a1b0846ce | ||
|
|
28645ff7b0 | ||
|
|
ff433dcf76 | ||
|
|
429b5de44c | ||
|
|
0fab9b901a | ||
|
|
2e228ef52b | ||
|
|
13b80dfda6 | ||
|
|
09dea59996 | ||
|
|
4ae3d47d10 | ||
|
|
3aca25c681 | ||
|
|
0caa399e06 | ||
|
|
8fe784c8d2 | ||
|
|
ed33157945 | ||
|
|
75c3039358 | ||
|
|
d5fffcc8fa | ||
|
|
a853ce9e9d | ||
|
|
d399d1ce4c | ||
|
|
a82e1467b5 | ||
|
|
c6dd6a1f64 | ||
|
|
adc9fc84cd | ||
|
|
df268b7e6f | ||
|
|
95d0e330b0 | ||
|
|
0398bcdea3 | ||
|
|
0ed1ad86a7 | ||
|
|
521b507b18 | ||
|
|
ecc8c9b593 | ||
|
|
613ddbda81 | ||
|
|
2735d8969a | ||
|
|
7a0ed0792b | ||
|
|
1167cdd582 | ||
|
|
d8f68a93f0 | ||
|
|
368da6d075 | ||
|
|
0f2dae05bb | ||
|
|
33d5c1fe2b | ||
|
|
b97eca37ff | ||
|
|
29fcc6aafe | ||
|
|
562cde58f4 | ||
|
|
7e77dd552a | ||
|
|
e5b756b060 | ||
|
|
8c4758cc7a | ||
|
|
856de3e1e5 | ||
|
|
c31d5c703f | ||
|
|
4b3c36464e | ||
|
|
7eeb4f9179 | ||
|
|
ccc6345606 | ||
|
|
b051f30a7a | ||
|
|
c7515e040b | ||
|
|
587c631b82 | ||
|
|
28b242815b | ||
|
|
feacfefbf4 | ||
|
|
42fa49c50f | ||
|
|
f0315ccca5 | ||
|
|
c082ec50e9 | ||
|
|
39660ecc37 | ||
|
|
685c176eca | ||
|
|
77cf334f8a | ||
|
|
18922e1316 | ||
|
|
b3f35597d3 | ||
|
|
22c2cdd5d7 | ||
|
|
ecd6b13a26 | ||
|
|
f3e3209f32 | ||
|
|
c9bca752cc | ||
|
|
102b5dff15 | ||
|
|
eaf54b692e | ||
|
|
3c1adf90ef | ||
|
|
43150e7c17 | ||
|
|
4d1ef200bf | ||
|
|
afa5d01a31 | ||
|
|
52dc384447 | ||
|
|
bda728696f | ||
|
|
b24869e1a8 | ||
|
|
d32152f6dc | ||
|
|
8ee52edeee | ||
|
|
74c8fddb1a | ||
|
|
9282bd783e | ||
|
|
ce89389451 | ||
|
|
d36b39d31e | ||
|
|
987e79024f | ||
|
|
63ebd5fc7c | ||
|
|
3fab386fb2 | ||
|
|
fc02b8a38b | ||
|
|
71690f32a7 | ||
|
|
d3ba4b0f1e | ||
|
|
2a08c4c2b2 | ||
|
|
e2e9fe63cf | ||
|
|
917bbab173 | ||
|
|
a4727c8a46 | ||
|
|
323a97fb40 | ||
|
|
d7603b7fa6 | ||
|
|
95eca909c1 | ||
|
|
4912f3731d | ||
|
|
95365b647c | ||
|
|
0f5f44053f | ||
|
|
3f9774b2c2 | ||
|
|
cc462f49a3 | ||
|
|
207e20a369 | ||
|
|
1231f59b1a | ||
|
|
7f81ac76a9 | ||
|
|
48fbdbd542 | ||
|
|
7e0fcf32f9 | ||
|
|
3559395c83 | ||
|
|
0125e2aadf | ||
|
|
cc0108d48f | ||
|
|
2b58c20cc9 | ||
|
|
ef97cc84a0 | ||
|
|
b1c9f7071b | ||
|
|
87d1af5b13 | ||
|
|
694be2d111 | ||
|
|
c0869f5caf | ||
|
|
3461af38d5 | ||
|
|
1e9f8ee174 | ||
|
|
1740fd488b | ||
|
|
5ec95681f2 | ||
|
|
0676ce1d89 | ||
|
|
ab2c1048d1 | ||
|
|
66d1d47b1d | ||
|
|
96285c874c | ||
|
|
85fb985d2f | ||
|
|
44eded59b7 | ||
|
|
4ab6bd9809 | ||
|
|
c0893c052a | ||
|
|
98e224b10b | ||
|
|
70bef43ccd | ||
|
|
495dff77ca | ||
|
|
35a37ff846 | ||
|
|
9e7f843d43 | ||
|
|
b17c337979 | ||
|
|
40983afa7b | ||
|
|
b8a6fd40e3 | ||
|
|
67801f4ce7 | ||
|
|
4fd07e7688 | ||
|
|
20b00ea33b | ||
|
|
a7debe567b | ||
|
|
0f1224bb35 | ||
|
|
d913e75402 | ||
|
|
95c1d822a7 | ||
|
|
10ae17868d | ||
|
|
c0b057a48d | ||
|
|
876ce83c96 | ||
|
|
85cbbc3840 | ||
|
|
ce955e01a5 | ||
|
|
e83c9e8bb3 | ||
|
|
6ce905509f | ||
|
|
ec24536f65 | ||
|
|
c81576e311 | ||
|
|
73be187b15 | ||
|
|
85bdb48ab7 | ||
|
|
40195ab0ce | ||
|
|
0ecfa0e67e | ||
|
|
21d1e071bf | ||
|
|
f4d954c3ee | ||
|
|
426c28b961 | ||
|
|
da3e8212cf | ||
|
|
cee6f0329a | ||
|
|
37ebd06564 | ||
|
|
5ad1f1624d | ||
|
|
bbc0a1f0ea | ||
|
|
0da3142f6b | ||
|
|
16a5cb0c6f | ||
|
|
ad3024ac7f | ||
|
|
0035530f29 | ||
|
|
03acacbd7d | ||
|
|
635eccd001 | ||
|
|
6659262ae2 | ||
|
|
78e74ddaa9 | ||
|
|
78b94c9d8f | ||
|
|
fae2b935e1 | ||
|
|
5ecc2470aa | ||
|
|
0495cb786d | ||
|
|
706b79f8fc | ||
|
|
022d403f97 | ||
|
|
fe05d635e6 | ||
|
|
902c18078e | ||
|
|
6fb3baae95 | ||
|
|
6d3811f981 | ||
|
|
279919a747 | ||
|
|
2efe686c14 | ||
|
|
4c9f237c20 | ||
|
|
d755a3a892 | ||
|
|
226d704f1d | ||
|
|
b60bb0e6db | ||
|
|
0c3d748424 | ||
|
|
ab4601cc33 | ||
|
|
70e31235ed | ||
|
|
127166a0e9 | ||
|
|
48670ff566 | ||
|
|
1b3792d4a8 | ||
|
|
3cae9815c4 | ||
|
|
54dc089705 | ||
|
|
8f33ebdd3d | ||
|
|
125ecbb4bb | ||
|
|
d88a94fa7d | ||
|
|
b4eb1191fd | ||
|
|
d1e2f38e07 | ||
|
|
67384872d0 | ||
|
|
9018ad7a28 | ||
|
|
46514538b5 | ||
|
|
cf5d0d1f29 | ||
|
|
8ea4524630 | ||
|
|
2ef1f407b5 | ||
|
|
a0ed8d020f | ||
|
|
071cb35d15 | ||
|
|
2c0eb835d4 | ||
|
|
6e5fb42171 | ||
|
|
40d03c4402 | ||
|
|
e64b6fb557 | ||
|
|
8a94666e91 | ||
|
|
1bf8f43f0a | ||
|
|
835f7cff92 | ||
|
|
8c775e5d2f | ||
|
|
16fc7a192b | ||
|
|
432926f4b9 | ||
|
|
5c47bdb633 | ||
|
|
e90ba2e567 | ||
|
|
fca5d9eb20 | ||
|
|
2914f16e89 | ||
|
|
878b281ffc | ||
|
|
a92833f919 | ||
|
|
ba2213bb73 | ||
|
|
2c20561caa | ||
|
|
17541b373d | ||
|
|
c6691bf2d7 | ||
|
|
151c98d8cc | ||
|
|
21bf52c786 | ||
|
|
c42f06f727 | ||
|
|
46107635c2 | ||
|
|
435e8e9bd5 | ||
|
|
9df093cff6 | ||
|
|
a35e09fd0a | ||
|
|
cd9f130b4b | ||
|
|
a5b9409789 | ||
|
|
7cce47526f | ||
|
|
49bc592a56 | ||
|
|
3f177cae9e | ||
|
|
721cd2646b | ||
|
|
24fad147d0 | ||
|
|
db2de2be1f | ||
|
|
744f6c79d4 | ||
|
|
3728615c09 | ||
|
|
9e16d1dbf0 | ||
|
|
f385831d5e | ||
|
|
0887acdc89 | ||
|
|
8d6ea4fa72 | ||
|
|
4b53b24669 | ||
|
|
9524d56966 | ||
|
|
29d28c93f4 | ||
|
|
edb2340b35 | ||
|
|
5ee004f355 | ||
|
|
6eea504796 | ||
|
|
4eae552846 | ||
|
|
26723b2755 | ||
|
|
b0d3e08ef9 | ||
|
|
f0482bf00c | ||
|
|
9f1187390f | ||
|
|
a3e6ab8e09 | ||
|
|
e06c93ca0e | ||
|
|
edb53806d8 | ||
|
|
145d5ccae6 | ||
|
|
a2a94b3b41 | ||
|
|
5fa59d1cf8 | ||
|
|
c0889179da | ||
|
|
bc6ca7fee1 | ||
|
|
96b36aef0d | ||
|
|
03e8da2c92 | ||
|
|
5420d92cc1 | ||
|
|
d1e0e13ce1 | ||
|
|
c978d6eb80 | ||
|
|
5df46eebc7 | ||
|
|
2cb9bc113e | ||
|
|
0009c280a8 | ||
|
|
715dc15133 | ||
|
|
657bb70d23 | ||
|
|
feac0e86db | ||
|
|
c39b01279a | ||
|
|
9fec594d41 | ||
|
|
14ee925645 | ||
|
|
c2f3f2b8e2 | ||
|
|
b818486aac | ||
|
|
afdc860676 | ||
|
|
1e2ef61b89 | ||
|
|
0aa24acd3d | ||
|
|
43ab7d4afc | ||
|
|
5bd4404279 | ||
|
|
4ed6927626 | ||
|
|
fa9a59d60c | ||
|
|
c13b24251e | ||
|
|
b3a4b4a84e | ||
|
|
cc633a7802 | ||
|
|
2b291f28b7 | ||
|
|
2017d9162f | ||
|
|
6210d0a28d | ||
|
|
fa7684a88d | ||
|
|
675cbcbe58 | ||
|
|
54b756b0ec | ||
|
|
01490a64d1 | ||
|
|
5db9440adb | ||
|
|
6ca8e49a52 | ||
|
|
7606697512 | ||
|
|
5da74f1136 | ||
|
|
45e73f7d34 | ||
|
|
5383430b19 | ||
|
|
5cb0ed5b35 | ||
|
|
43cabb2567 | ||
|
|
5a4411f359 | ||
|
|
b4e82bb323 | ||
|
|
9536ed343b | ||
|
|
575a2b1c0b | ||
|
|
893f2a9b28 | ||
|
|
94eef9b6e0 | ||
|
|
f5bcea85f0 | ||
|
|
bef37ea49c | ||
|
|
32ae63a2b5 | ||
|
|
921765f9ef | ||
|
|
8e46c5d2b6 | ||
|
|
91d0ac1639 | ||
|
|
03516fb0cd | ||
|
|
bf9b42d517 | ||
|
|
64ad946a1c | ||
|
|
df4e1f2fd7 | ||
|
|
cc1ebdd827 | ||
|
|
ab18468a98 | ||
|
|
5c4f72da6c | ||
|
|
5cf76dd95c | ||
|
|
a6875c583a | ||
|
|
a68cc8d179 | ||
|
|
26b5218ff3 | ||
|
|
a3dc4bca2d | ||
|
|
b236c76976 | ||
|
|
5a93a2c62f | ||
|
|
43ed80d547 | ||
|
|
5bdad6199e | ||
|
|
77547bfe55 | ||
|
|
beac898601 | ||
|
|
f9694775d3 | ||
|
|
d01fdf55a7 | ||
|
|
a065d480cd | ||
|
|
0b0f99889e | ||
|
|
8b8ddccb5b | ||
|
|
322a2c5265 | ||
|
|
eff123e0e2 | ||
|
|
c284885f8b | ||
|
|
bb6d2552c0 | ||
|
|
1f4d6d1648 | ||
|
|
be43cde4e1 | ||
|
|
29db9ebde2 | ||
|
|
6f50bc74e3 | ||
|
|
b47ddd13d5 | ||
|
|
411e85843c | ||
|
|
1dfdf952dd | ||
|
|
7330e4326e | ||
|
|
a9bbe5dc5a | ||
|
|
3e99394d39 | ||
|
|
a3d1c624e4 | ||
|
|
f6559cd181 | ||
|
|
223cd82cdc | ||
|
|
600a9cfb43 | ||
|
|
1a5978ac36 | ||
|
|
1d6d66f960 | ||
|
|
937b70e596 | ||
|
|
39b01c2649 | ||
|
|
e68afa6aea | ||
|
|
ff0a75bbc6 | ||
|
|
895d0d1cb6 | ||
|
|
ea8f11ac86 | ||
|
|
85f471bd68 | ||
|
|
4b8f9cc8f0 | ||
|
|
fc20b9c4d8 | ||
|
|
84fbfc464c | ||
|
|
3987833102 | ||
|
|
2babb9f9de | ||
|
|
ee1d2b0ea6 | ||
|
|
e1ddeffd7f | ||
|
|
f83a367796 | ||
|
|
dd755386d3 | ||
|
|
b66a668669 | ||
|
|
e8a41b1228 | ||
|
|
7b659e69d8 | ||
|
|
236f782e66 | ||
|
|
a6b7993fa5 | ||
|
|
457a92a067 | ||
|
|
1e1dceef73 | ||
|
|
3a57fdb8a8 | ||
|
|
35db3a6f03 | ||
|
|
494422399f | ||
|
|
1dbe3c9be8 | ||
|
|
f334097f30 | ||
|
|
27e044f763 | ||
|
|
330b5cbe71 | ||
|
|
385d5234de | ||
|
|
6e175dfb91 | ||
|
|
70f465f914 | ||
|
|
a8ca30ccd7 | ||
|
|
44026a1838 | ||
|
|
8820817d0f | ||
|
|
08a704ec1b | ||
|
|
fbb6f68f81 | ||
|
|
eec18940ae | ||
|
|
d2c2085741 | ||
|
|
9c9d1e52e9 | ||
|
|
23049b4277 | ||
|
|
794e097f8f | ||
|
|
c02714ecc8 | ||
|
|
9a0f291057 | ||
|
|
91c9d2d770 | ||
|
|
3421523768 | ||
|
|
f7e318e959 | ||
|
|
75146af6fe | ||
|
|
3f4b7a64e3 | ||
|
|
7cb72490a8 | ||
|
|
09acc4700e | ||
|
|
439a7f6e12 | ||
|
|
3316f41502 | ||
|
|
c45bd52edd | ||
|
|
20d6d80ded | ||
|
|
523be2bc0a | ||
|
|
d27b4a639b | ||
|
|
73e5d0bd4d | ||
|
|
04d4403844 | ||
|
|
9796d9044f | ||
|
|
8c995a5339 | ||
|
|
4ca3cbcffe | ||
|
|
bff9cfe1d0 | ||
|
|
72ac997a84 | ||
|
|
7409c719b3 | ||
|
|
fa9d32dbf0 | ||
|
|
c5d57af45f | ||
|
|
0e08a7b8bc | ||
|
|
2987e110a2 | ||
|
|
d698dbd942 | ||
|
|
b743440246 | ||
|
|
b30497692a | ||
|
|
27c15f9d20 | ||
|
|
00aea878bd | ||
|
|
c00efb94e5 | ||
|
|
93ec3246cf | ||
|
|
8facce909a | ||
|
|
44d17a606b | ||
|
|
15e70f9e9d | ||
|
|
009d77aa22 | ||
|
|
ff0b32989f | ||
|
|
fc9fb7ba24 | ||
|
|
4083be3744 | ||
|
|
b8c2bd35b7 | ||
|
|
d20291031a | ||
|
|
a1f3a98f79 | ||
|
|
72bc73ceac | ||
|
|
41ac0dc1cd | ||
|
|
e1949c59f1 | ||
|
|
f817692659 | ||
|
|
cefb1b3f12 | ||
|
|
f77cf6d934 | ||
|
|
7e788aa50c | ||
|
|
cce26607ea | ||
|
|
74349879b7 | ||
|
|
81bf4a0b48 | ||
|
|
cea2c09ea6 | ||
|
|
5b6c1f5a5b | ||
|
|
f8d530db4c | ||
|
|
8e0c303759 | ||
|
|
c299a7237e | ||
|
|
681f87a432 | ||
|
|
d2a8951c93 | ||
|
|
95901aa1e2 | ||
|
|
cae7e0b6b6 | ||
|
|
9fb21af373 | ||
|
|
e2ff21e244 | ||
|
|
1c762c1d00 | ||
|
|
5b28c67fdf | ||
|
|
c9600248c6 | ||
|
|
629a5d9446 | ||
|
|
d93404fe77 | ||
|
|
30e0cec696 | ||
|
|
030a1bee02 | ||
|
|
7d2d7627ad | ||
|
|
1402f6ad6a | ||
|
|
356069339f | ||
|
|
68b42549e8 | ||
|
|
095344156c | ||
|
|
a4c78a769a | ||
|
|
20ffbb39f5 | ||
|
|
8836252cdf | ||
|
|
ba8946d8bc | ||
|
|
82aff2f40a | ||
|
|
cd9b03e484 | ||
|
|
63019965b7 | ||
|
|
9138a2890e | ||
|
|
04b6bab3e5 | ||
|
|
c0cf875f1b | ||
|
|
80e99d1159 | ||
|
|
3b33e65a6d | ||
|
|
867e86e185 | ||
|
|
4886a8dee1 | ||
|
|
e8fe5906c8 | ||
|
|
046840513f | ||
|
|
543c4a6dab | ||
|
|
021bbeb2fa | ||
|
|
993eec8946 | ||
|
|
fa4ce91b80 | ||
|
|
b5c9651357 | ||
|
|
60dbc5d2e6 | ||
|
|
b374ceb4dc | ||
|
|
5105669402 | ||
|
|
dff632f7fd | ||
|
|
1042f0f5b8 | ||
|
|
89068ede1e | ||
|
|
5a66c1342a | ||
|
|
fb83864f83 | ||
|
|
1148e3aa69 | ||
|
|
05a8c49053 | ||
|
|
1841faa596 | ||
|
|
a2fe09a65e | ||
|
|
68c5ded23c | ||
|
|
9b9b6f13fe | ||
|
|
25f13f4683 | ||
|
|
5022dba8f3 | ||
|
|
9871d1e53f | ||
|
|
a205e7bb73 | ||
|
|
5cc2e057c8 | ||
|
|
0fe714566a | ||
|
|
2aa4779df9 | ||
|
|
c9581079da | ||
|
|
971cd4df4b | ||
|
|
cdfff8f4ed | ||
|
|
ae3320d2ec | ||
|
|
a89607e8b5 | ||
|
|
efb1a648f6 | ||
|
|
46abc66484 | ||
|
|
b128bee62d | ||
|
|
807ea685d6 | ||
|
|
9bb0aebe46 | ||
|
|
49bc27b020 | ||
|
|
1ad52086e6 | ||
|
|
d4afe27f4e | ||
|
|
ef22b59064 | ||
|
|
679a9bd7c3 | ||
|
|
61dc7f59f8 | ||
|
|
8299011181 | ||
|
|
7cf678307e | ||
|
|
e91b4e998e | ||
|
|
ad46bf9b32 | ||
|
|
39e37073ad | ||
|
|
d1f255f73d | ||
|
|
ca9b5b27bb | ||
|
|
4eca780a57 | ||
|
|
cc22129ae6 | ||
|
|
3633a1e73e | ||
|
|
101b82597b | ||
|
|
feed0c7635 | ||
|
|
914531edf7 | ||
|
|
f681597a32 | ||
|
|
f7d2431e81 | ||
|
|
7073fb0d09 | ||
|
|
a64c6f06d6 | ||
|
|
d817541708 | ||
|
|
0b4d46666d | ||
|
|
1a5034514c | ||
|
|
ea5c07db0e | ||
|
|
0c668c0d0b | ||
|
|
aae62438d3 | ||
|
|
d51080ef42 | ||
|
|
3f8446b9cf | ||
|
|
5ed9890149 | ||
|
|
f6ebdeab8d | ||
|
|
ee5e93be43 | ||
|
|
a7844fb6ad | ||
|
|
5f3486ebe5 | ||
|
|
f60e28e801 | ||
|
|
5bec0878a3 | ||
|
|
83d4490031 | ||
|
|
6749574600 | ||
|
|
44ea4d4dc3 | ||
|
|
a854b9db24 | ||
|
|
edb0444b9f | ||
|
|
b5ed04b7c1 | ||
|
|
c5802596dc | ||
|
|
acad616d12 | ||
|
|
47cb7c91ef | ||
|
|
7a3d4f45e9 | ||
|
|
aead637786 | ||
|
|
af8e59eea4 | ||
|
|
9e8aa07521 | ||
|
|
50f77a3391 | ||
|
|
9fb73099a9 | ||
|
|
5c5b4e1856 | ||
|
|
4c870c7825 | ||
|
|
2787870c2c | ||
|
|
e032358e69 | ||
|
|
2707e3b402 | ||
|
|
3f95d11b98 | ||
|
|
aebc5dc388 | ||
|
|
6f59d09cb2 | ||
|
|
e264405302 | ||
|
|
475288d427 | ||
|
|
5ce7b3b054 | ||
|
|
f7f2ca1d65 | ||
|
|
2068221324 | ||
|
|
3c822fcc61 | ||
|
|
672a16d6fd | ||
|
|
61cf324fa7 | ||
|
|
1a8f4bd177 | ||
|
|
1b2ef12383 | ||
|
|
322b774387 | ||
|
|
332184fa92 | ||
|
|
3a31f5d131 | ||
|
|
e87d3b9dec | ||
|
|
143c10d9c0 | ||
|
|
74fe950fc2 | ||
|
|
dd4ff86da7 | ||
|
|
6e91261502 | ||
|
|
1191b8bd51 | ||
|
|
9588c9c00b | ||
|
|
2a6083071f | ||
|
|
9e5242a782 | ||
|
|
bb4a8606a6 | ||
|
|
1721064184 | ||
|
|
8b2473d715 | ||
|
|
ee966c0a76 | ||
|
|
6979d665d7 | ||
|
|
95fd240577 | ||
|
|
8a64b65ebb | ||
|
|
4f19f75ed1 | ||
|
|
39269cb5ca | ||
|
|
9208bfa617 | ||
|
|
5046fe689c | ||
|
|
c66a9d15f6 | ||
|
|
3384114bdc | ||
|
|
34c402a3d2 | ||
|
|
d9b12d63f7 | ||
|
|
7ff5a970df | ||
|
|
22ce1dc041 | ||
|
|
e07c8494f1 | ||
|
|
73366fd582 | ||
|
|
9cedf54cd5 | ||
|
|
5455714a47 | ||
|
|
3aab662642 | ||
|
|
778fa11b7b | ||
|
|
a1635f075c | ||
|
|
d4cb586850 | ||
|
|
c79565cbdd | ||
|
|
54b161261e | ||
|
|
beb5b376b8 | ||
|
|
1a7839d051 | ||
|
|
4437e94c9a | ||
|
|
061df5fc8d | ||
|
|
649d3ee014 | ||
|
|
a45fe546f9 | ||
|
|
0953c0d3dc | ||
|
|
bbe8056c45 | ||
|
|
4667bce7da | ||
|
|
600c416f06 | ||
|
|
5b4e754d0a | ||
|
|
55ec3973c3 | ||
|
|
e0a4330d30 | ||
|
|
28e5ef66d0 | ||
|
|
a86b0e9b74 | ||
|
|
555ec8116c | ||
|
|
e75cc607f1 | ||
|
|
cdd99da9c9 | ||
|
|
9e21ececff | ||
|
|
aad45092ae | ||
|
|
c8523a2716 | ||
|
|
4bda57919c | ||
|
|
2b64b663e1 | ||
|
|
3e417f8912 | ||
|
|
f5055aa0e3 | ||
|
|
73ef4ff03f | ||
|
|
ba9bab3993 | ||
|
|
b4a6690d6b | ||
|
|
973e38b782 | ||
|
|
191ca89cef | ||
|
|
b274aee402 | ||
|
|
5c9a233e96 | ||
|
|
efabcf84e3 | ||
|
|
3902405feb | ||
|
|
434c15ad50 | ||
|
|
e1da05d00f | ||
|
|
119b889cb4 | ||
|
|
ead2650f15 | ||
|
|
c9d3088aa1 | ||
|
|
17dbb48fc4 | ||
|
|
cba2d1122d | ||
|
|
bdf88cae98 | ||
|
|
4e3b8d0548 | ||
|
|
1e53e857aa | ||
|
|
d7613e9cc1 | ||
|
|
cf64c25d61 | ||
|
|
ce4d3eb108 | ||
|
|
5a065ca07c | ||
|
|
5ea8903edc | ||
|
|
ab3ce3b242 | ||
|
|
cf9de7354d | ||
|
|
1f094f5712 | ||
|
|
eb363c3fab | ||
|
|
8f0fef686b | ||
|
|
db6eec5029 | ||
|
|
55e9c5ed45 | ||
|
|
8b10ebc96e | ||
|
|
72a78e36ce | ||
|
|
43d264e3cb | ||
|
|
9751876703 | ||
|
|
1cc8f15dba | ||
|
|
8a9b775ff7 |
8
.gitignore
vendored
8
.gitignore
vendored
@@ -13,6 +13,7 @@ Makefile
|
||||
*.prl
|
||||
*.swp
|
||||
*.user
|
||||
*.AppImage
|
||||
|
||||
# osx noise
|
||||
.DS_Store
|
||||
@@ -35,6 +36,11 @@ plugins/
|
||||
resources/
|
||||
src/debug/
|
||||
src/release/
|
||||
doc/doxygen/latex
|
||||
doc/doxygen/html
|
||||
|
||||
# qt creator builds
|
||||
build-src*
|
||||
|
||||
qwt/src/debug/
|
||||
qwt/src/release/
|
||||
@@ -49,4 +55,6 @@ qwt/src/Makefile.Debug
|
||||
qwt/textengines/mathml/debug/
|
||||
qwt/textengines/mathml/release/
|
||||
build.pro.user
|
||||
build.pro.user.*
|
||||
doc/contrib/WASP Packet Protocol.pdf
|
||||
|
||||
|
||||
173
.travis.yml
173
.travis.yml
@@ -1,14 +1,24 @@
|
||||
if: commit_message =~ /\[publish binaries\]/
|
||||
|
||||
branches:
|
||||
- master
|
||||
language:
|
||||
- objective-c
|
||||
compiler:
|
||||
- clang
|
||||
- gcc
|
||||
only:
|
||||
- master
|
||||
- /^[vV]\d+\.\d+(\.\d+)?(-\S*)?$/
|
||||
|
||||
language: cpp
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/Library/Caches/Homebrew
|
||||
- qwt
|
||||
- D2XX
|
||||
- site-packages
|
||||
- VLC
|
||||
- src/GoldenCheetah.app
|
||||
|
||||
env:
|
||||
matrix:
|
||||
- BRANCH=master QT=qt5 QT_PATH=qt5 WEBKIT=0
|
||||
global:
|
||||
- BRANCH=master
|
||||
- secure: iqYW7f3//ZkMVzeCEarYn0S0DqKjFU9juBh0KF6WTlUsKX902Jtsk7dFoJlNDYBf63HLgV+wW2Hc6MxI9sGiUkom0gY9/To/aeGIJFGEX2sLm/e0Ok3qN521FA0Q/OiCFsD0RC6J+yrHxzI+rf8Z1rujceUsz2KgsrfAjYYv+BY=
|
||||
- secure: C6f58PXwvvHeVOjCLbyDRjgyF0tk+bXjCNUDur8VJLhJEGNdnrt+rH+d3azYaX0n348ZnQZ14as4M4rHjN1A/3DRbdUdOS7PQZrkj/n363ck1tvYOG/tzYqkEcVoQyjIJ7ZoTuBXDQry/VJmLxQjM0glTa2upNFHMOMwqZNkF+I=
|
||||
- secure: mgf181ok4rJTHxAdSaeIb/OzUx7PQc6UjJYfhJQcZDjN1Nou+Um6OHpnooMHeEq0CdGuLSiv2xVmuQnRjI5MfG5re/a3l39hSzi9tPLWi1y7uOLCtQFooJw3H+LhiKZcgAtEnkTmEhUCEu5uZ7cp4lWhrQZWCR5mCDNtJrGHjiw=
|
||||
@@ -23,119 +33,36 @@ env:
|
||||
- secure: QXyyyutxesRVae/WFi75dxlNw2qTyWc6WQ3vmRER9BFhlrNtt8lmE+M6ghMDOhxigzSXWxHcG9r66BLOw4DML7AXg4f3NIAIYuYQrpfsWQ1TKGC/vVvIPDlNBKL62zSOoNowjup1HfZpB575wl4JkmHjoMPDfQ4yM/JVR+MKmIM=
|
||||
- secure: lefpL3SB8yN0Vn1R2e0hAFpJgFnu4rJ/vn7DucSKQvJ61K7t3LrUHFXElDQGFZMbytx4OJDeYsJtrccrIHjcsSAEIyW8TTcwn5/JopnyeQ3ukV5AYpEoQusym09XKru9E7awqvnZrXz6mdoIum5JP7+H116mPN4vsvz5nkNWxeg=
|
||||
- secure: RAGPq/thN9x6STNueDbeJWGUN75OLNcUVUkLHI/eZwPrkMaiQPfxIaJ+8eO2PszDcBojw3eYVhzbRvLnLiXmHL3buwD6oXMTyYnxGzCZ61DeDQ2cQa8ynKmRim5JL3viKMqtdyasXVoGf/u0GqMsgaLcqN6e/vXuXMGu6kkUPEQ=
|
||||
before_install:
|
||||
## try early just to check, can delete later
|
||||
- date
|
||||
- brew update
|
||||
- sh travis/install-qt.sh
|
||||
##- brew install $QT
|
||||
- brew install libical
|
||||
##- brew install libusb libusb-compat # no longer needed?
|
||||
- brew install srmio
|
||||
- brew install libsamplerate
|
||||
- rm -rf '/usr/local/include/c++'
|
||||
- brew install r
|
||||
- brew install brewsci/science/lmfit
|
||||
## Disable KML for now
|
||||
##- brew install --HEAD travis/libkml.rb
|
||||
- sudo chmod -R +w /usr/local
|
||||
- curl -O http://www.ftdichip.com/Drivers/D2XX/MacOSX/D2XX1.2.2.dmg
|
||||
- git clone --branch 0.98 https://github.com/kypeli/kQOAuth.git kQOAuth-0.98
|
||||
- cd kQOAuth-0.98
|
||||
- CC=clang CXX=clang++ /usr/local/opt/$QT_PATH/bin/qmake -makefile -recursive QMAKE_CXXFLAGS_WARN_ON+="-Wno-unused-private-field -Wno-c++11-narrowing"
|
||||
- CC=clang CXX=clang++ make -j2 qmake_all
|
||||
- CC=clang CXX=clang++ sudo make install
|
||||
- cd ..
|
||||
- hdiutil mount D2XX1.2.2.dmg
|
||||
before_script:
|
||||
- mkdir D2XX
|
||||
- cp /Volumes/release/D2XX/Object/10.5-10.7/x86_64/libftd2xx.1.2.2.dylib D2XX
|
||||
- sudo cp /Volumes/release/D2XX/Object/10.5-10.7/x86_64/libftd2xx.1.2.2.dylib /usr/local/lib
|
||||
- cp /Volumes/release/D2XX/bin/*.h D2XX
|
||||
- sed -i "" "s|libftd2xx.dylib|@executable_path/../Frameworks/libftd2xx.1.2.2.dylib|"
|
||||
src/FileIO/D2XX.cpp
|
||||
- cp qwt/qwtconfig.pri.in qwt/qwtconfig.pri
|
||||
- cp src/gcconfig.pri.in src/gcconfig.pri
|
||||
- /usr/local/opt/$QT_PATH/bin/lupdate src/src.pro
|
||||
- if [[ "$WEBKIT" == "0" ]]; then echo DEFINES += NOWEBKIT >> src/gcconfig.pri; fi
|
||||
- sed -i "" "s|#\(CONFIG += release.*\)|\1 static |" src/gcconfig.pri
|
||||
- sed -i "" "s|#\(QMAKE_LRELEASE\).*|\1 += /usr/local/opt/$QT_PATH/bin/lrelease|"
|
||||
src/gcconfig.pri
|
||||
- sed -i "" "s|#\(QMAKE_CXXFLAGS\).*|\1_RELEASE += -mmacosx-version-min=10.7 -arch
|
||||
x86_64|" src/gcconfig.pri
|
||||
- sed -i "" "s|^#CloudDB|CloudDB|" src/gcconfig.pri
|
||||
- sed -i "" "s|^#LIBZ|LIBZ|" src/gcconfig.pri
|
||||
- sed -i "" "s|#\(SRMIO_INSTALL =.*\)|\1 /usr/local|" src/gcconfig.pri
|
||||
- sed -i "" "s|#\(D2XX_INCLUDE =.*\)|\1 ../D2XX|" src/gcconfig.pri
|
||||
- sed -i "" "s|#\(D2XX_LIBS =.*\)|\1 -L../D2XX -lftd2xx.1.2.2|" src/gcconfig.pri
|
||||
- sed -i "" "s|#\(KQOAUTH_INSTALL =.*\)|\1 /usr/local|" src/gcconfig.pri
|
||||
- sed -i "" "s|#\(KQOAUTH_INCLUDE =.*\)|\1 \$\$[QT_INSTALL_LIBS]/kqoauth.framework/Headers|"
|
||||
src/gcconfig.pri
|
||||
- sed -i "" "s|#\(KQOAUTH_LIBS =.*\)|\1 -F\$\$[QT_INSTALL_LIBS] -framework kqoauth|"
|
||||
src/gcconfig.pri
|
||||
## Disable KML for now
|
||||
#- sed -i "" "s|#\(KML_INSTALL =\).*|\1 /usr/local|" src/gcconfig.pri
|
||||
#- sed -i "" "s|#\(KML_LIBS =.*\)|\1 -L/usr/local/lib -lkmlxsd -lkmlregionator -lkmldom -lkmlconvenience -lkmlengine -lkmlbase -lexpect|" src/gcconfig.pri
|
||||
- sed -i "" "s|#\(ICAL_INSTALL =.*\)|\1 /usr/local|" src/gcconfig.pri
|
||||
- sed -i "" "s|#\(ICAL_LIBS =.*\)|\1 -L/usr/local/lib -lical|" src/gcconfig.pri
|
||||
- sed -i "" "s|#\(LIBUSB_INSTALL =\).*|\1 /usr/local|" src/gcconfig.pri
|
||||
- sed -i "" "s|#\(LIBUSB_LIBS =.*\)|\1 -L/usr/local/lib -lusb -lusb-1.0|" src/gcconfig.pri
|
||||
- sed -i "" "s|#\(SAMPLERATE_INSTALL =\).*|\1 /usr/local|" src/gcconfig.pri
|
||||
- sed -i "" "s|#\(SAMPLERATE_LIBS =\).*|\1 -L/usr/local/lib -lsamplerate|" src/gcconfig.pri
|
||||
- sed -i "" "s|#\(LMFIT_INSTALL =\).*|\1 /usr/local|" src/gcconfig.pri
|
||||
- sed -i "" "s|#\(DEFINES += GC_HAVE_LION*\)|\1|" src/gcconfig.pri
|
||||
- sed -i "" "s|#\(HTPATH = ../httpserver.*\)|\1 |" src/gcconfig.pri
|
||||
- sed -i "" "s|#\(DEFINES += GC_WANT_ROBOT.*\)|\1 |" src/gcconfig.pri
|
||||
##- sed -i "" "s|\(DEFINES += GC_VIDEO_NONE.*\)|#\1 |" src/gcconfig.pri ## we want this for now XXX till AVKit fixup
|
||||
##- sed -i "" "s|#\(DEFINES += GC_VIDEO_QUICKTIME.*\)|\1 |" src/gcconfig.pri ## QT is deprecated, don't build with it.
|
||||
##Issues with c++11 and stdlib on travis and dependencies
|
||||
- sed -i "" "s|#\(DEFINES += GC_WANT_R.*\)|\1 |" src/gcconfig.pri
|
||||
- echo "QMAKE_CFLAGS_RELEASE += -mmacosx-version-min=10.7 -arch x86_64" >> src/gcconfig.pri
|
||||
- sed -i "" "s/__GC_GOOGLE_CALENDAR_CLIENT_SECRET__/"$GC_GOOGLE_CALENDAR_CLIENT_SECRET"/" src/Core/Secrets.h
|
||||
- sed -i "" "s/__GC_STRAVA_CLIENT_SECRET__/"$GC_STRAVA_CLIENT_SECRET"/" src/Core/Secrets.h
|
||||
- sed -i "" "s/__GC_DROPBOX_CLIENT_SECRET__/"$GC_DROPBOX_CLIENT_SECRET"/" src/Core/Secrets.h
|
||||
- sed -i "" "s/__GC_CYCLINGANALYTICS_CLIENT_SECRET__/"$GC_CYCLINGANALYTICS_CLIENT_SECRET"/" src/Core/Secrets.h
|
||||
- sed -i "" "s/__GC_TWITTER_CONSUMER_SECRET__/"$GC_TWITTER_CONSUMER_SECRET"/" src/Core/Secrets.h
|
||||
- sed -i "" "s/__GC_DROPBOX_CLIENT_ID__/"$GC_DROPBOX_CLIENT_ID"/" src/Core/Secrets.h
|
||||
- sed -i "" "s/__GC_MAPQUESTAPI_KEY__/"$GC_MAPQUESTAPI_KEY"/" src/Core/Secrets.h
|
||||
- sed -i "" "s/__GC_CLOUD_DB_BASIC_AUTH__/"$GC_CLOUD_DB_BASIC_AUTH"/" src/Core/Secrets.h
|
||||
- sed -i "" "s/__GC_CLOUD_DB_APP_NAME__/"$GC_CLOUD_DB_APP_NAME"/" src/Core/Secrets.h
|
||||
- sed -i "" "s/__GC_GOOGLE_DRIVE_CLIENT_ID__/"$GC_GOOGLE_DRIVE_CLIENT_ID"/" src/Core/Secrets.h
|
||||
- sed -i "" "s/__GC_GOOGLE_DRIVE_CLIENT_SECRET__/"$GC_GOOGLE_DRIVE_CLIENT_SECRET"/" src/Core/Secrets.h
|
||||
- sed -i "" "s/__GC_GOOGLE_DRIVE_API_KEY__/"$GC_GOOGLE_DRIVE_API_KEY"/" src/Core/Secrets.h
|
||||
- sed -i "" "s/__GC_TODAYSPLAN_CLIENT_SECRET__/"$GC_TODAYSPLAN_CLIENT_SECRET"/" src/Core/Secrets.h
|
||||
- cat src/gcconfig.pri
|
||||
script:
|
||||
- CC=clang CXX=clang++ /usr/local/opt/$QT_PATH/bin/qmake -makefile -recursive QMAKE_CXXFLAGS_WARN_ON+="-Wno-unused-private-field -Wno-c++11-narrowing"
|
||||
- CC=clang CXX=clang++ make qmake_all
|
||||
- CC=clang CXX=clang++ make -j4 sub-qwt --silent
|
||||
- CC=clang CXX=clang++ make -j4 sub-src
|
||||
after_success:
|
||||
- cd src
|
||||
- echo "Checking GoldenCheetah.app can execute"
|
||||
- GoldenCheetah.app/Contents/MacOS/GoldenCheetah --help
|
||||
- echo "About to create dmg file and fix up"
|
||||
- /usr/local/opt/$QT_PATH/bin/macdeployqt GoldenCheetah.app -verbose=2 -dmg
|
||||
- python ../travis/macdeployqtfix.py GoldenCheetah.app /usr/local/opt/$QT_PATH
|
||||
- echo "Cleaning up installed QT libraries from $QT"
|
||||
- brew remove $QT
|
||||
- echo "Renaming dmg file to branch and build number ready for deploy"
|
||||
- export FINAL_NAME=dev-prerelease-branch-master-build-${TRAVIS_BUILD_NUMBER}.dmg
|
||||
- mv GoldenCheetah.dmg $FINAL_NAME
|
||||
- ls -l $FINAL_NAME
|
||||
- echo "Mounting dmg file and testing it can execute"
|
||||
- hdiutil mount $FINAL_NAME
|
||||
- cd /Volumes/GoldenCheetah
|
||||
- GoldenCheetah.app/Contents/MacOS/GoldenCheetah --help
|
||||
- echo "Make sure we are back in the Travis build directory"
|
||||
- cd $TRAVIS_BUILD_DIR
|
||||
deploy:
|
||||
provider: releases
|
||||
api_key:
|
||||
secure: KlfkRM8oGP02y5LhbdxetnhqUG3YzVylvyhT8BTYjdoJtkJr7YXYpdhj9byZ9aiy1gSWI/g7A1X6/P8/McqRtgt4dEYr4Zg8QO7Y7QdTpgNQEwu8ZrkyyG/7b/rSkfFHDjrOAHslLVXuBNwWgi8YW1aTn0rY2AqDbOri7u6tt9Q=
|
||||
file: src/$FINAL_NAME
|
||||
skip_cleanup: true
|
||||
on:
|
||||
tags: true
|
||||
repo: GoldenCheetah/GoldenCheetah
|
||||
- secure: Lydms45scczE9gZvkWze2fXVbEInKW48DOCIRJWziEzxKkvXUE7WPy74fLvfvL+0JW0LH/ZLZ9EbgHcJAYYs8CBrfAeOOtnyo2DZ0ouEO13RmomSZneEKSpJxRtErcPIu+B0LzcEGyAgf7bxPVevEte50CK0pZJ7z7bHMhU23pY=
|
||||
- secure: cc0pAJjkmFNw2bO3zVACmtyHTwINAHALrtUxi+nRD+FhOO9KxuxuuwvcKCZKfp9EUOjz5PrYWKV1ZH/zt/jMix8A4Gyue2mWX8WYih7aTmJBcJWsFNTCybnClreKBCh18kHdWWhkmhk8EMINDvlqxzJZGpcNO04gxhL9wuLLrNQ=
|
||||
- secure: em0xXIm69rMHsHXYQiizeJB7dEFBkX33PsWDHwBNrX6lFBued23eL96KJC4RVbk6A+AHFtXFATrreZ14D5JH/E/37CXhe3X2R93WqiPUSH0s7NI4fFA1BroKUNAlqO4bMqDBidtNmwMPaLTXjaOnOZyvbAG7z+QV3TKC8tOeZDU=
|
||||
- secure: VFaSERlgsjzjiDQhKw8XFvQrjdvFzHHL7V3NQg+RfELHoT6I1pAGFdl/+lRBIVOiVkbQ6XnpBA28nlf0QydPHElRZdqmh0azQV/bkUXD4ffPE8q0iSqeqhAZ+5L05K5K+Gby/y8TZE4FX6e/7trFL7oq+h9x0gq5RQO8rAcTV84=
|
||||
- secure: eTSJmS38EsTkI22yvDJLUrBxSyLDwd3pDRsyLQfZ3ThN0UJ9cQN2uB7aLy3OzNYadpi+Axlr46MgG0G5qGV1hHXkf+C4orGkURQWxHA7L5R/oE98TuYMO1bisZu9dJEVbmEM4cehCjbB7DExzxK4m6+oTJsWhVbIwlNh5Poq/v4=
|
||||
- secure: gUDTEErUOhzkSVofEvdw1jqHHsE/K+/SOqRBKDToaFPhi6XK+Tvu1LqPMjfPdjYLaCSiwc/R79fJrAEuK+7KSwdiLEnDv3RMpRS5g1UWyJ/ZYd5xNR+WiBqUvnY/S/CJokuNw7gBbGq7JCO4pmIGV5YB9FA4Na6MG/eHzTSOIig=
|
||||
- secure: Qk+gzBLwjrB8abUYzxap10dYSpIeKpB1gqhdoMbqS23G0r1lejnsjutIfReuJGK/efCmhisKN1xIX/InvJWD8z6GsLJFmf3F0oRj7aDJ/X5UIn9Upflje9xgHQafP1FJuzZBWtzandNfPE8EmEOgAQsJZ3c7xBE1SY/6xcJaQTc=
|
||||
- secure: m4+k3/QcYvqmMoRO8uq3ef2jAO1FWeRVDG/XtlbjBlgmB5OR/zW5c7c1Ywm6IM5yzsi1rRks8GFffZ6gYqXhML10EfGKVbnyBcZZ7HVylNtvxDF68W1BLacChzDs4mGYQSV8kJRGI3EaVNdyFJ5yln/HUZ6qBbQ473MtxprO6BI=
|
||||
- secure: GEyUuLuIc7D3F4noKhtTCbWbQAlm61Y7Vh2mOKBEgmyfoV1johwlEL0RaeRyr9MnU2MN+4jeFthvDjxm3LGP19zrpB46GTGHU6/H9BZBodDCJsFTqj32T+5QTcAF2RQ66ZgYpSyTf063/RLlfy7YjCb8KLiJ2asCaoYtQIjx3hA=
|
||||
|
||||
jobs:
|
||||
include:
|
||||
- os: osx
|
||||
osx_image: xcode11.3
|
||||
compiler: clang
|
||||
- os: linux
|
||||
dist: bionic
|
||||
compiler: gcc
|
||||
|
||||
before_install:
|
||||
- travis/$TRAVIS_OS_NAME/before_install.sh
|
||||
|
||||
before_script:
|
||||
- travis/$TRAVIS_OS_NAME/before_script.sh
|
||||
|
||||
script:
|
||||
- travis/$TRAVIS_OS_NAME/script.sh
|
||||
|
||||
before_cache:
|
||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew cleanup; fi
|
||||
|
||||
after_success:
|
||||
- travis/$TRAVIS_OS_NAME/after_success.sh
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#### **Do you have questions about how to use GoldenCheetah?**
|
||||
|
||||
* Ask any question about how to use GoldenCheetah on [golden-cheetah-users mailing list](https://github.com/GoldenCheetah/GoldenCheetah/wiki), ideally after watching the corresponding [tutorials](http://www.goldencheetah.org/#section-tutorials) and/or reading the relevant parts of the [documentation](https://github.com/GoldenCheetah/GoldenCheetah/wiki).
|
||||
* Ask any question about how to use GoldenCheetah on [golden-cheetah-users mailing list](https://groups.google.com/forum/#!forum/golden-cheetah-users), ideally after watching the corresponding [tutorials](https://www.goldencheetah.org/#section-tutorials) and/or reading the relevant parts of the [documentation](https://github.com/GoldenCheetah/GoldenCheetah/wiki).
|
||||
|
||||
#### **Do you have questions about the source code?**
|
||||
|
||||
|
||||
873
COPYING
873
COPYING
@@ -1,622 +1,281 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Copyright (C) 1989, 1991 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.
|
||||
|
||||
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
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) 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.
|
||||
this service 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.
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
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.
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. 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.
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
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.
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
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.
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
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
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute 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 and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
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 Program or any portion
|
||||
of it, thus forming a work based on the Program, 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) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
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 Program, 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 Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) 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; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, 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 executable. However, as a
|
||||
special exception, the source code 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.
|
||||
|
||||
If distribution of executable or 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 counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program 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.
|
||||
|
||||
5. 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 Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program 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 to
|
||||
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
|
||||
7. 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 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.
|
||||
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 Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program 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 Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
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.
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest 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
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program 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.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the 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.
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
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 Program does not specify a version number of
|
||||
this 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.
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, 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.
|
||||
|
||||
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.
|
||||
NO WARRANTY
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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.
|
||||
|
||||
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.
|
||||
12. 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 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.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
@@ -628,15 +287,15 @@ 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
|
||||
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 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
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
@@ -644,32 +303,38 @@ the "copyright" line and a pointer to where the full notice is found.
|
||||
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/>.
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; 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.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
If the program is interactive, 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'.
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision 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".
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
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/>.
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
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>.
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This 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.
|
||||
|
||||
|
||||
394
INSTALL-LINUX
394
INSTALL-LINUX
@@ -4,99 +4,79 @@
|
||||
|
||||
Mark Liversedge
|
||||
John Ehrlinger
|
||||
Ale Martinez
|
||||
|
||||
Jan 2015
|
||||
Version 1.2
|
||||
Jul 2022
|
||||
Version 3.6
|
||||
|
||||
A walkthrough of building GoldenCheetah from scratch on Ubuntu linux. This walkthrough
|
||||
should be largely the same for any Linux distro.
|
||||
A walkthrough of building GoldenCheetah from scratch on Ubuntu linux 18.04
|
||||
This walkthrough should be largely the same for any Debian derivative Linux
|
||||
distro, and very similar for others using their correspoing package manager.
|
||||
|
||||
CONTENTS
|
||||
|
||||
1. BASIC INSTALLATION WITH MANDATORY DEPENDENCIES
|
||||
- QT
|
||||
- git
|
||||
- flex
|
||||
- bison
|
||||
- QT
|
||||
- OpenGL
|
||||
- gsl
|
||||
|
||||
2. ADDING OPTIONAL DEPENDENCIES WHEN BUILDING VERSION 2
|
||||
2. ADDING OPTIONAL DEPENDENCIES
|
||||
- FTDI D2XX
|
||||
- SRMIO
|
||||
- liboauth
|
||||
- QwtPlot3d
|
||||
- libkml
|
||||
|
||||
3. ADDING OPTIONAL DEPENDENCIES WHEN BUILDING VERSION 3
|
||||
- checking out the release 3 branch & building with MANDATORY dependencies
|
||||
- flex
|
||||
- bison
|
||||
- libical - Diary window and CalDAV support (google/mobileme calendar integration)
|
||||
- libvlc - Video playback in training mode
|
||||
- libical - Diary window and CalDAV support (external calendar integration)
|
||||
- libusb - If you want support for using USB2 sticks in Train View
|
||||
- R - If you want R charts
|
||||
- Python - If you want Python charts, scripts and data processors
|
||||
|
||||
1. BASIC INSTALLATION WITH MANDATORY DEPENDENCIES
|
||||
=================================================
|
||||
|
||||
Installed Linux distribution of choice on platforms i386 or amd-64 (currently Debian-based distributions and Arch-based distributions are covered). You will not need to do this if you
|
||||
already have a Linux distribution installed. Left this step in to highlight the
|
||||
Linux distribution the commands below were executed on.
|
||||
Install the Linux distribution of choice on amd64 platform (Ubuntu 18.04 is used
|
||||
for this document). You will not need to do this if you already have a Linux
|
||||
distribution installed. Left this step in to highlight the Linux distribution
|
||||
the commands below were executed on.
|
||||
|
||||
login and open a terminal to get a shell prompt
|
||||
|
||||
Download MANDATORY DEPENDENCIES (browser)
|
||||
-----------------------------------------
|
||||
Install Qt
|
||||
----------
|
||||
Download and install the Qt SDK from http://qt-project.org/
|
||||
Once that is completed test qmake is ok with: qmake --version (should report 4.7.0 or higher)
|
||||
You can use a browser to download and run the interactive installer, be sure to
|
||||
select version 5.15.2 or higher Qt 5 version, including at least the following modules:
|
||||
- Desktop gcc 64-bit
|
||||
- Qt Charts
|
||||
- Qt WebEngine
|
||||
Once this step is completed add the bin directory to PATH and test qmake is ok:
|
||||
$ qmake --version
|
||||
|
||||
|
||||
DEBIAN-BASED DISTRIBUTION INSTRUCTIONS
|
||||
--------------------------------------
|
||||
|
||||
Install git with:
|
||||
Install git
|
||||
-----------
|
||||
$ sudo apt-get install git
|
||||
Said Y to prompt about all git files installed (git-gui et al)
|
||||
|
||||
Install FLEX and BISON
|
||||
----------------------
|
||||
|
||||
You will need flex v2.5.9 or later
|
||||
$ sudo apt-get install bison
|
||||
$ sudo apt-get install flex
|
||||
|
||||
Install Mesa OpenGL utility library
|
||||
-----------------------------------
|
||||
sudo apt-get install libglu1-mesa-dev
|
||||
|
||||
ARCH-BASED DISTRIBUTION INSTRUCTIONS
|
||||
------------------------------------
|
||||
Install GSL development libraries
|
||||
---------------------------------
|
||||
sudo apt-get -qq install libgsl-dev
|
||||
|
||||
Install git:
|
||||
$ sudo pacman -S git
|
||||
|
||||
INSTALL FLEX and BISON
|
||||
----------------------
|
||||
$ sudo pacman -S flex bison
|
||||
|
||||
NEXT STEPS
|
||||
----------
|
||||
$ vi gcconfig.pri
|
||||
|
||||
Ensure you have the following lines (which are now also in gcconfig.pri.in which has
|
||||
been updated to reflect the new dependencies in version 3)
|
||||
|
||||
QMAKE_LEX = flex
|
||||
QMAKE_YACC = bison
|
||||
win32 {
|
||||
QMAKE_YACC = bison --file-prefix=y -t
|
||||
QMAKE_MOVE = cmd /c move
|
||||
QMAKE_DEL_FILE = rm -f
|
||||
}
|
||||
|
||||
Build!
|
||||
------
|
||||
$ make clean
|
||||
$ qmake
|
||||
$ make
|
||||
|
||||
You will now have a release3 binary but with none of the release3 dependencies compiled in.
|
||||
Get latest GOLDEN CHEETAH source files
|
||||
--------------------------------------
|
||||
$ mkdir -p ~/Projects/Live
|
||||
$ cd ~/Projects/Live
|
||||
$ mkdir -p ~/Projects
|
||||
$ cd ~/Projects
|
||||
$ git clone git://github.com/GoldenCheetah/GoldenCheetah.git
|
||||
$ cd GoldenCheetah
|
||||
|
||||
@@ -108,11 +88,32 @@ $ cd ../src
|
||||
$ cp gcconfig.pri.in gcconfig.pri
|
||||
$ vi gcconfig.pri
|
||||
|
||||
Comment out the D2XX_INCLUDE and SRMIO_INSTALL lines for now (put # in first character of the line
|
||||
to comment out), we will install that in a moment, if we need to.
|
||||
Uncomment below and configure the location of the GNU scientific library, this is a mandatory dependency.
|
||||
|
||||
If you are building for your local host you may find that you get better performance if
|
||||
compiling with gcc -O3 (tree vectorization can have a significat impact) [or -Ofast]
|
||||
#GSL_INCLUDES = /usr/include
|
||||
#GSL_LIBS = -lgsl -lgslcblas -lm
|
||||
|
||||
Uncomment the following lines to use flex and bison:
|
||||
|
||||
#QMAKE_LEX = flex
|
||||
#QMAKE_YACC = bison
|
||||
|
||||
and if you are using bison 3.7 or higher, make sure to also uncomment:
|
||||
|
||||
#QMAKE_MOVE = cp
|
||||
|
||||
To compile translation you need the QT tool lrelease
|
||||
If it is not found using the defaults in src/src.pro then set the full path and
|
||||
filename in gcconfig.pri, s.t.
|
||||
QMAKE_LRELEASE = /usr/bin/lrelease
|
||||
|
||||
If your QT build doesn't include its own local compress libs then you should uncomment the lines below,
|
||||
and add the library path to LIBZ_INCLUDE =, you will need to have the compress libraries installed separately.
|
||||
#LIBZ_INCLUDE =
|
||||
#LIBZ_LIBS = -lz
|
||||
|
||||
compiling with gcc -O3 (tree vectorization can have a significat impact)
|
||||
[or -Ofast]
|
||||
|
||||
If so you might like to uncomment:
|
||||
|
||||
@@ -123,32 +124,43 @@ Save and exit
|
||||
$ cd ..
|
||||
|
||||
BUILD WITH BASIC CONFIGURATION
|
||||
------------------------------
|
||||
$ qmake -recursive
|
||||
$ make
|
||||
|
||||
Congratulations you have now build a basic GoldenCheetah and can run this safely. See below for
|
||||
optional dependencies you can install to support other features.
|
||||
When build first time you get number of error messages on .qm files missing:
|
||||
"RCC: Error in 'Resources/application.qrc': Cannot find file 'translations/gc_fr.qm'"
|
||||
You can ignore these messages for your build. The .qm files will be created
|
||||
during the build at a later point in time via the "lrelease" command you
|
||||
configured in gcconfig.pri
|
||||
|
||||
ADDING OPTIONAL DEPENDENCIES WHEN BUILDING VERSION 2
|
||||
====================================================
|
||||
Congratulations you have now build a basic GoldenCheetah and can run this
|
||||
safely from src folder.
|
||||
|
||||
See below for optional dependencies you can install to support other features.
|
||||
|
||||
|
||||
2. ADDING OPTIONAL DEPENDENCIES
|
||||
===============================
|
||||
|
||||
D2XX - For Powertap downloads via USB
|
||||
-------------------------------------
|
||||
|
||||
Download the FTDI drivers from http://www.ftdichip.com/Drivers/D2XX.htm (e.g. I used Linux
|
||||
64-bit drivers from http://www.ftdichip.com/Drivers/D2XX/Linux/libftd2xx1.0.4.tar.gz)
|
||||
Download the FTDI drivers from http://www.ftdichip.com/Drivers/D2XX.htm and
|
||||
extract:
|
||||
|
||||
Extract into your home directory (I put mine into ~/Projects/ with archive manager which
|
||||
created a sub-directory ~/Projects/libftd2xx1.0.4
|
||||
$ cd ~/Projects
|
||||
$ wget http://www.ftdichip.com/Drivers/D2XX/Linux/libftd2xx-x86_64-1.3.6.tgz
|
||||
$ tar xf libftd2xx-x86_64-1.3.6.tgz
|
||||
|
||||
$ cd src
|
||||
$ cd ~/Projects/GoldenCheetah/src
|
||||
$ vi gcconfig.pri
|
||||
|
||||
Uncomment the D2XX_INCLUDE entry and make it match (my home is /home/markl)
|
||||
D2XX_INCLUDE = /home/markl/libftd2xx1.0.4
|
||||
D2XX_INCLUDE = /home/markl/Projects/libftd2xx-x86_64-1.3.6
|
||||
|
||||
Make clean is needed if you have previouslt built, since source files examine #defines before
|
||||
including this feature. You can skip it if you know why ;)
|
||||
Make clean is needed if you have previouslt built, since source files examine
|
||||
#defines before including this feature. You can skip it if you know why ;)
|
||||
$ make clean
|
||||
$ qmake
|
||||
$ make
|
||||
@@ -173,122 +185,30 @@ $ make
|
||||
$ sudo make install
|
||||
|
||||
Lets go config GC and build with SRMIO
|
||||
$ cd ~/Projects/Live/GoldenCheetah/src
|
||||
$ cd ~/Projects/GoldenCheetah/src
|
||||
$ vi gcconfig.pri
|
||||
|
||||
Uncomment the SRMIO_INSTALL and replace with the target used from srmio install:
|
||||
SRMIO_INSTALL = /usr/local/
|
||||
|
||||
At the bottom of gcconfig.pri you will see the include directory should reference from
|
||||
the base install location (/usr/local) make sure it says:
|
||||
At the bottom of gcconfig.pri you will see the include directory should
|
||||
reference from the base install location (/usr/local) make sure it says:
|
||||
|
||||
SRMIO_INCLUDE = $${SRMIO_INSTALL}/include
|
||||
SRMIO_LIB = $${SRMIO_INSTALL}/lib/libsrmio.a
|
||||
|
||||
Make clean is needed if you have previouslt built, since source files examine #defines before
|
||||
including this feature. You can skip it if you know why ;)
|
||||
Make clean is needed if you have previouslt built, since source files examine
|
||||
#defines before including this feature. You can skip it if you know why ;)
|
||||
$ make clean
|
||||
$ qmake
|
||||
$ make
|
||||
|
||||
You now have SRM support built in.
|
||||
|
||||
OAUTH/CRYPT - For Tweet my ride (twitter) support
|
||||
-------------------------------------------------
|
||||
|
||||
You should be able to install liboauth and dependencies
|
||||
directly with:
|
||||
$ sudo apt-get install liboauth-dev
|
||||
|
||||
If this does not work then:
|
||||
|
||||
Download the source from: http://sourceforge.net/projects/liboauth/files/liboauth-0.9.4.tar.gz/download and
|
||||
unpack it into ~/Projects/liboauth-0.9.4 using archive manager
|
||||
|
||||
$ cd ~/Projects/liboauth-0.9.4
|
||||
|
||||
You may find that libcurl is not installed (which liboauth depends upon) so download it
|
||||
from http://curl.haxx.se/download/curl-7.21.6.tar.gz and unpack it into ~/Projects/curl-7.21.6
|
||||
using archive manager to drag and drop into your Projects folder
|
||||
|
||||
$ cd ~/Projects/curl-7.21.6
|
||||
$ ./configure
|
||||
$ make
|
||||
$ sudo make install
|
||||
|
||||
You should now have libcurl and friends installed in /usr/local
|
||||
|
||||
You may find that liboauth also requires the openssl libs installed, these are available
|
||||
pre-packaged thankfully so:
|
||||
$ sudo apt-get install libssl-dev
|
||||
|
||||
This will also install zlibg which liboauth also desires.
|
||||
|
||||
$ cd ~/Projects/liboauth-0.9.4
|
||||
$ ./configure
|
||||
$ make
|
||||
$ sudo make install
|
||||
|
||||
Now we have liboauth and libcurl in /usr/local and libssl in /usr/lib, so we can go back to
|
||||
GoldenCheetah and update the gcconfig.pri to point at the right places:
|
||||
|
||||
$ cd ~/Projects/Live/GoldenCheetah/src
|
||||
$ vi gcconfig.pri
|
||||
|
||||
Make sure the following are set:
|
||||
LIBOAUTH_INSTALL = /usr/local
|
||||
LIBCRYPTO_INSTALL = -lcrypto
|
||||
LIBCURL_INSTALL=-lcurl
|
||||
|
||||
Make clean is needed if you have previously built, since source files examine #defines before
|
||||
including this feature. You can skip it if you know why ;)
|
||||
$ make clean
|
||||
$ qmake
|
||||
$ make
|
||||
|
||||
You can now tweet your rides and amaze your friends, or alternatively tweet your rides but
|
||||
omit to mention average power to hide your weaknesses.
|
||||
|
||||
LIBQWTPLOT3D - For 3D plot
|
||||
--------------------------
|
||||
|
||||
Download the tarball from http://qwtplot3d.svn.sourceforge.net/viewvc/qwtplot3d/branches/maintain_0_2_x/qwtplot3d/?view=tar
|
||||
and unarchive it into your Projects directory using archive manager. There is no version number it just creates a
|
||||
subdirectory called qwtplot3d
|
||||
|
||||
You will need to install libgl and extensions, this can be done with;
|
||||
$ sudo apt-get install libgl1-mesa-dev
|
||||
$ sudo apt-get install libglu-dev
|
||||
|
||||
On Ubuntu 12.10 I also ran
|
||||
$ sudo apt-get install freeglut3 freeglut3-dev
|
||||
|
||||
$ cd ~/Projects/qwtplot3d
|
||||
Edit the qwtplot3d.pri and add
|
||||
CONFIG += staticlib
|
||||
|
||||
You will find that on modern Linuxes you also need to fix include/qwt3d_global.h by adding the line:
|
||||
#include <GL/glu.h>
|
||||
|
||||
then build
|
||||
$ qmake
|
||||
$ make
|
||||
|
||||
Then to let gc know where the qwtplot3d libs are you need to edit gcconfig.pri;
|
||||
$ cd ~/Projects/Live/GoldenCheetah/src
|
||||
$ vi gcconfig.pri
|
||||
|
||||
And uncomment the following line and set the install directory to where you build
|
||||
QWT3D_INSTALL = ~/Projects/qwtplot3d
|
||||
|
||||
|
||||
|
||||
LIBKML - For export to Google Earth
|
||||
-----------------------------------
|
||||
|
||||
You will need Google Earth 5.2 or later and therefore libkml that supports this. Unfortunately at the time of writing
|
||||
the officially packaged libkml is too old, so you will need to install from source, which means you will need to have
|
||||
subversion installed and expat. You may be able to use the currently packaged libkml with
|
||||
You will need Google Earth 5.2 or later and therefore libkml that supports this.
|
||||
|
||||
$ sudo apt-get install libkml-dev
|
||||
|
||||
@@ -297,7 +217,8 @@ if this does not work you will need to build from source:
|
||||
$ sudo apt-get install subversion
|
||||
$ sudo apt-get install expat libexpat1 libexpat1-dev
|
||||
|
||||
Once svn is installed you can grab the libkml source and configure build etc:
|
||||
Once svn is installed you can grab the libkml source, configure, build and
|
||||
install:
|
||||
$ cd ~/Projects
|
||||
$ svn checkout http://libkml.googlecode.com/svn/trunk/ libkml
|
||||
$ cd libkml
|
||||
@@ -314,55 +235,32 @@ if this does not work you will need to build from source:
|
||||
- examples/{engine,gpx,gx,hellonet,helloworld,regionator,xsd}/Makefile
|
||||
- and look for the flag -pedantic and remove it. I got this on Linux 64bit builds ymmv.
|
||||
|
||||
Once libkml is installed and built:
|
||||
Once libkml is installed:
|
||||
|
||||
$ cd ~/Projects/Live/GoldenCheetah/src
|
||||
$ cd ~/Projects/GoldenCheetah/src
|
||||
$ vi gcconfig.pri
|
||||
|
||||
Ensure KML_INSTALL=/usr/local
|
||||
|
||||
Make clean is needed if you have previously built, since source files examine #defines before
|
||||
including this feature. You can skip it if you know why ;)
|
||||
Make clean is needed if you have previously built, since source files examine
|
||||
#defines before including this feature. You can skip it if you know why ;)
|
||||
$ make clean
|
||||
$ qmake
|
||||
$ make
|
||||
|
||||
You can now export rides to Google Earth kml format.
|
||||
|
||||
ADDING OPTIONAL DEPENDENCIES WHEN BUILDING VERSION 3
|
||||
====================================================
|
||||
|
||||
|
||||
NOTE: When you run version 3 it will refresh ride metrics and CP files -- this only occurs the
|
||||
first time it runs (and will refresh only rides that change after that). I find it is best
|
||||
to import ride files once your build where you want it. i.e. don't import until you have
|
||||
got all your dependencies sorted.
|
||||
|
||||
NOTE: To reduce the dependencies on 'dormant' code there are a number of new pieces of source
|
||||
that are included in the release3 tree. Notably; qtsoap from qt-solutions, since they
|
||||
work but are likely to be archived and deprecated. If and when that happens we may well
|
||||
adopt whatever classes Trolltech introduce.
|
||||
|
||||
|
||||
LIBICAL - Diary integration with Google or MobileMe calendars
|
||||
-------------------------------------------------------------
|
||||
|
||||
$ cd ~/Projects/Live/GoldenCheetah/src
|
||||
|
||||
$ sudo apt-get install libical-dev
|
||||
|
||||
$ cd ~/Projects/GoldenCheetah/src
|
||||
$ vi gcconfig.pri
|
||||
|
||||
ICAL_INSTALL=/usr/include
|
||||
ICAL_LIBS=-lical
|
||||
|
||||
Since the src.pro wants ICAL installed in a different place we need to hack it, *** this will
|
||||
be fixed shortly ***
|
||||
|
||||
$ vi src.pro
|
||||
|
||||
Comment out the ICAL_LIBS entry:
|
||||
|
||||
#ICAL_LIBS = $${ICAL_INSTALL}/lib/libical.a
|
||||
ICAL_INSTALL = /usr
|
||||
ICAL_INCLUDE = /usr/include
|
||||
ICAL_LIBS = -lical
|
||||
|
||||
$ make clean
|
||||
$ qmake
|
||||
@@ -370,21 +268,89 @@ $ make
|
||||
|
||||
You should now have diary functions.
|
||||
|
||||
NOTE: That upload to MobileMe and Google requires a functioning https lib in QT. Depending
|
||||
upon the version installed this might not be the case and will need to be built and
|
||||
configured -- this is beyond the scope of this walkthough. Sorry.
|
||||
LIBVLC - Video playback in Realtime
|
||||
-----------------------------------
|
||||
|
||||
LIBVLC - Video playback in Realtime (Experimental)
|
||||
--------------------------------------------------
|
||||
You will need libvlc 3.0.8 or higher for better performance:
|
||||
|
||||
You will need libvlc 1.1.9 or higher (1.1.8 is ok but will segv on exit)
|
||||
$ sudo apt-get install libvlc-dev
|
||||
sudo add-apt-repository ppa:jonathonf/vlc-3
|
||||
sudo add-apt-repository ppa:jonathonf/ffmpeg-4
|
||||
sudo apt-get update
|
||||
sudo apt-get install vlc libvlc-dev libvlccore-dev
|
||||
|
||||
$ cd ~/Projects/GoldenCheetah/src
|
||||
$ vi gcconfig.pri
|
||||
|
||||
Comment out VLC_INSTALL and it should read:
|
||||
|
||||
VLC_INSTALL = /usr/include/vlc/
|
||||
VLC_INSTALL = /usr
|
||||
|
||||
$ make clean
|
||||
$ qmake
|
||||
$ make
|
||||
|
||||
LIBUSB - for using USB2 sticks in Train View on Linux or Windows
|
||||
----------------------------------------------------------------
|
||||
$ sudo apt-get install libusb-1.0-0-dev libudev-dev
|
||||
|
||||
$ cd ~/Projects/GoldenCheetah/src
|
||||
$ vi gcconfig.pri
|
||||
|
||||
Uncomment or add the following lines:
|
||||
|
||||
LIBUSB_USE_V_1 = true # don't use on Windows
|
||||
LIBUSB_INSTALL = /usr/local
|
||||
|
||||
$ make clean
|
||||
$ qmake
|
||||
$ make
|
||||
|
||||
R Embedding
|
||||
-----------
|
||||
|
||||
Install R 4.0
|
||||
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
|
||||
sudo add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran40/"
|
||||
sudo apt-get update
|
||||
sudo apt-get install r-base-dev
|
||||
R --version
|
||||
|
||||
$ cd ~/Projects/GoldenCheetah/src
|
||||
$ vi gcconfig.pri
|
||||
|
||||
Uncomment or add the following line:
|
||||
DEFINES += GC_WANT_R
|
||||
|
||||
$ make clean
|
||||
$ qmake
|
||||
$ make
|
||||
|
||||
Python Embedding
|
||||
----------------
|
||||
|
||||
Install Python 3.7
|
||||
|
||||
sudo add-apt-repository ppa:deadsnakes/ppa
|
||||
sudo apt-get update
|
||||
sudo apt-get install python3.7-dev
|
||||
python3.7 --version
|
||||
|
||||
Install SIP 4.19.8:
|
||||
cd ~/Projects
|
||||
wget https://sourceforge.net/projects/pyqt/files/sip/sip-4.19.8/sip-4.19.8.tar.gz
|
||||
tar xf sip-4.19.8.tar.gz
|
||||
cd sip-4.19.8
|
||||
python3.7 configure.py
|
||||
make
|
||||
sudo make install
|
||||
|
||||
$ cd ~/Projects/GoldenCheetah/src
|
||||
$ vi gcconfig.pri
|
||||
|
||||
Uncomment or add the following lines:
|
||||
DEFINES += GC_WANT_PYTHON
|
||||
PYTHONINCLUDES = -I/usr/include/python3.7/
|
||||
PYTHONLIBS = -L/usr/lib/python3.7/config-3.7m-x86_64-linux-gnu -lpython3.7m
|
||||
|
||||
$ make clean
|
||||
$ qmake
|
||||
|
||||
42
INSTALL-MAC
42
INSTALL-MAC
@@ -1,3 +1,13 @@
|
||||
Update Note: to build GoldenCheetah v3.6 we are using the Homebrew Package
|
||||
Manager to install dependencies, including Qt and GSL, on Travis-ci
|
||||
macOS Mojave build environment.
|
||||
You can check the travis/osx folder for the complete and updated build scripts,
|
||||
the minimum Qt version known to work is 5.13 with Qt WebEngine and Qt Charts.
|
||||
GSL - GNU Scientific Library is a mandatory dependency starting with v3.6 and
|
||||
minimum bison version is 2.7, both can be installed using Homebrew.
|
||||
|
||||
Ale Martinez - Oct, 2022
|
||||
|
||||
+++++++++++++++++++++++
|
||||
MAC OSX BUILD WALKTHROUGH
|
||||
+++++++++++++++++++++++
|
||||
@@ -20,8 +30,6 @@ CONTENTS
|
||||
2. ADDING OPTIONAL DEPENDENCIES
|
||||
- FTDI D2XX
|
||||
- SRMIO
|
||||
- kQOAuth
|
||||
- QwtPlot3d
|
||||
- libkml
|
||||
- libusb
|
||||
- libical
|
||||
@@ -210,6 +218,11 @@ $ cd .. #this should put you in the top level dir containing this file
|
||||
$ qmake -recursive
|
||||
$ make
|
||||
|
||||
When build first time you get number of error messages on .qm files missing:
|
||||
"RCC: Error in 'Resources/application.qrc': Cannot find file 'translations/gc_fr.qm'"
|
||||
You can ignore these messages for your build. The .qm files will be created during the
|
||||
build at a later point in time via the "lrelease" command you configured in gcconfig.pri)
|
||||
|
||||
If make fails to find a Makefile then qmake is configured, by default, to create
|
||||
an xcode project file. You will need to change the qmake command above to tell it
|
||||
to create a makefile with the following:
|
||||
@@ -238,8 +251,6 @@ $ open src/GoldenCheetah.app
|
||||
===============================
|
||||
|
||||
- SRMIO
|
||||
- kQOAuth
|
||||
- QwtPlot3d
|
||||
- libkml
|
||||
- libusb
|
||||
- libical
|
||||
@@ -255,24 +266,7 @@ should be taken into account.
|
||||
SRMIO (git)
|
||||
./configure CFLAGS="-isysroot /Developer/SDKs/MacOSX10.7.sdk -arch x86_64" CPPFLAGS=-I/usr/local/D2XX/ --disable-dependency-tracking
|
||||
|
||||
2.2 kQOAuth - For OAuth Authentication
|
||||
--------------------------------------
|
||||
|
||||
kQOauth (0.98)
|
||||
|
||||
qmake
|
||||
|
||||
|
||||
2.3 QwtPlot3d - For 3d plot support
|
||||
-----------------------------------
|
||||
|
||||
qwtplot3d (maintain_0_2_x)
|
||||
|
||||
Add the following to qwtplot3d.pro:
|
||||
CONFIG += x86_64 static
|
||||
QMAKE_MAC_SDK=/Developer/SDKs/MacOSX10.7.sdk
|
||||
|
||||
2.4 libkml - For export to Google Earth
|
||||
2.2 libkml - For export to Google Earth
|
||||
---------------------------------------
|
||||
|
||||
expat (2.0.1)
|
||||
@@ -284,7 +278,7 @@ libkml (pulled down from the svn repo)
|
||||
|
||||
note: the added CXXFLAGS helped clear the -Werror flag that stopped compilation.
|
||||
|
||||
2.5 libusb - For Garmin USB2 stick support
|
||||
2.3 libusb - For Garmin USB2 stick support
|
||||
------------------------------------------
|
||||
|
||||
libusb (0.1.12)
|
||||
@@ -301,7 +295,7 @@ make install
|
||||
|
||||
note: that the sed line updates some commands in libtool. not sure why the arch clags are not getting passed.
|
||||
|
||||
2.6 libical
|
||||
2.4 libical
|
||||
-----------
|
||||
|
||||
libical (0.46)
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
Update Note: to build GoldenCheetah v3.6 we are using Microsoft Visual C++ 2019,
|
||||
included in Microsoft Visual Studio 2019 AppVeyor image, with Qt5.15.2 and GSL 2.7
|
||||
insalled with vcpkg, on AppVeyor continuous integration platform.
|
||||
You can check the appveyor.yml for the complete and updated build script,
|
||||
the minimum Qt version known to work is 5.13 with Qt WebEngine and Qt Charts.
|
||||
GSL - GNU Scientific Library is a mandatory dependency starting with v3.6
|
||||
|
||||
Ale Martinez - Jul, 2022
|
||||
+++++++++++++++++++++++
|
||||
WIN32 BUILD WALKTHROUGH
|
||||
+++++++++++++++++++++++
|
||||
@@ -7,6 +14,7 @@
|
||||
|
||||
February 2017
|
||||
|
||||
|
||||
This instruction will guide you through a standard build of GoldenCheetah (without external
|
||||
dependencies or API based services included).
|
||||
|
||||
@@ -157,12 +165,6 @@ Info: I plan to provide a pre-compiled set of the dependencies for the Windows v
|
||||
The version currently used is: "CDM v2.10.00 WHQL Certified" - while there are more recent
|
||||
version available for download.
|
||||
|
||||
- Qt Oauth library - kQoAuth
|
||||
-- Is part of the official build as a .dll - build is done with Qt - the build uses Release 0.98
|
||||
|
||||
- Qt 3D plotting - qwtplot3d
|
||||
-- Is part of the official build as a static lib - build is done with Qt - the build uses Release 0.3.0
|
||||
|
||||
- Google Earth .kml files (export)
|
||||
-- Is part of the official build as a static lib - build is done with MSVC2015 - the build uses Release 1.2
|
||||
(path of source code has changed to https://github.com/google/libkml)
|
||||
@@ -185,7 +187,7 @@ Info: I plan to provide a pre-compiled set of the dependencies for the Windows v
|
||||
|
||||
Building with integration to external services (via APIs)
|
||||
|
||||
As of today a number of integrations with external services like Twitter, Strava, Cyclinganalytics,
|
||||
As of today a number of integrations with external services like Strava, Cyclinganalytics,
|
||||
Google Calendar, Dropbox, Today's Plan, Google Drive, CloudDB) exist in the official GoldenCheetah
|
||||
builds. The permission to use API's of such services requires a dedicated registration (in this case
|
||||
for "GoldenCheetah" as the consumer of the services) where in return the GoldenCheetah team get's
|
||||
@@ -205,10 +207,3 @@ to contribute is to provide a pull-request.
|
||||
|
||||
Cheers.
|
||||
Joern
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
10
ISSUE_TEMPLATE.md
Normal file
10
ISSUE_TEMPLATE.md
Normal file
@@ -0,0 +1,10 @@
|
||||
Issue tracker is **only** for Bugs and Features, please don't open issues for questions or technical support. Before to open a new issue please read the contributing guidelines (link below).
|
||||
|
||||
If you have questions, please read the FAQs and User's/Developer's Guide:
|
||||
* FAQs - https://github.com/GoldenCheetah/GoldenCheetah/wiki/FAQ
|
||||
* User's Guide - https://github.com/GoldenCheetah/GoldenCheetah/wiki/UG_Main-Page_Users-Guide
|
||||
* Developer's Guide - https://github.com/GoldenCheetah/GoldenCheetah/wiki/Developers-guide
|
||||
|
||||
If you need help or technical support please use the forums:
|
||||
* Users - https://groups.google.com/forum/#!forum/golden-cheetah-users
|
||||
* Developers - https://groups.google.com/forum/#!forum/golden-cheetah-developers
|
||||
42
README.md
42
README.md
@@ -1,21 +1,30 @@
|
||||
<img src="src/Resources/images/gc.png" height="25%" width="25%">
|
||||
|
||||
# GoldenCheetah
|
||||
|
||||
<img src="https://raw.githubusercontent.com/GoldenCheetah/GoldenCheetah/067696aafdad21c702672b2c9c41da03c076451c/doc/wiki/GoldenCheetah-Screenshot.png" width="100%">
|
||||
|
||||
## About
|
||||
|
||||
GoldenCheetah is an open-source data analysis tool primarily written in C++
|
||||
with Qt for cyclists and triathletes
|
||||
with support for training as well.
|
||||
GoldenCheetah is a desktop application for cyclists and triathletes and coaches
|
||||
* Analyse using summary metrics like BikeStress, TRIMP or RPE
|
||||
* Extract insight via models like Critical Power and W'bal
|
||||
* Track and predict performance using models like Banister and PMC
|
||||
* Optimise aerodynamics using Virtual Elevation
|
||||
* Train indoors with ANT and BTLE trainers
|
||||
* Upload and Download with many cloud services including Strava and Todays Plan
|
||||
* Import and export data to and from a wide range of bike computers and file formats
|
||||
|
||||
GoldenCheetah can connect with indoor trainers and cycling equipment such
|
||||
as cycling computers and power meters to import data.
|
||||
|
||||
In addition, GoldenCheetah can connect to cloud services.
|
||||
|
||||
It can then manipulate and view the data, as well as analyze it.
|
||||
GoldenCheetah provides tools for users to develop their own own metrics, models and charts
|
||||
* A high-performance and powerful built-in scripting language
|
||||
* Local Python runtime or embedding a user installed runtime
|
||||
* Embedded user installed R runtime
|
||||
|
||||
GoldenCheetah supports community sharing via the Cloud
|
||||
* Upload and download user developed metrics
|
||||
* Upload and download user, Python or R charts
|
||||
* Import indoor workouts from the ErgDB
|
||||
* Share anonymised data with researchers via the OpenData initiative
|
||||
|
||||
GoldenCheetah is free for everyone to use and modify, released under the GPL v2 open source license with pre-built binaries for Mac, Windows and Linux.
|
||||
|
||||
## Installing
|
||||
|
||||
@@ -26,15 +35,18 @@ INSTALL-WIN32 For building on Microsoft Windows
|
||||
|
||||
INSTALL-LINUX For building on Linux
|
||||
|
||||
INSTALL-MAC For building on Apple OS X
|
||||
INSTALL-MAC For building on Apple MacOS
|
||||
|
||||
|
||||
OSX: [](https://travis-ci.org/GoldenCheetah/GoldenCheetah)
|
||||
macOS and Linux: [](https://app.travis-ci.com/GoldenCheetah/GoldenCheetah)
|
||||
|
||||
Windows: [](https://ci.appveyor.com/project/Joern-R/goldencheetah-knhd8)
|
||||
|
||||
[](https://scan.coverity.com/projects/goldencheetah-goldencheetah)
|
||||
|
||||
Alternatively, official builds are available from http://www.goldencheetah.org
|
||||
Official release builds, snapshots and development builds are all available from http://www.goldencheetah.org
|
||||
|
||||
## NOTIO Fork
|
||||
|
||||
If you are looking for the NOTIO fork of GoldenCheetah it can be found here: https://github.com/notio-technologies/GCNotio
|
||||
|
||||
whilst the latest developer builds are available from https://github.com/GoldenCheetah/GoldenCheetah/releases
|
||||
|
||||
235
appveyor.yml
235
appveyor.yml
@@ -1,32 +1,233 @@
|
||||
version: ci.{build}
|
||||
image: Visual Studio 2015
|
||||
image: Visual Studio 2019
|
||||
clone_depth: 1
|
||||
|
||||
environment:
|
||||
GC_GOOGLE_CALENDAR_CLIENT_SECRET:
|
||||
secure: hwjHTrSAMEbKd9PA+5x/zI4x5Uk4KQm1hdfZzkwiu8k=
|
||||
GC_GOOGLE_DRIVE_CLIENT_ID:
|
||||
secure: mNqG+pqpMl21ZFVvAMKvhm2rfOdv42fFpnLwfrvX5QqpWVcHEeBuUFeJeUAZfTR0GQGfWfPOEmhb9CG0W1ZJ05TIyb+kTLrWF7iijCiVR6s=
|
||||
GC_GOOGLE_DRIVE_CLIENT_SECRET:
|
||||
secure: T+BaB/L7x4dPPf592e0kfw4sTlAslUXl10irJqiUjpY=
|
||||
GC_GOOGLE_DRIVE_API_KEY:
|
||||
secure: oxTAhK/kiLUsXdYvITAgzSqeB5FRcL+XANFuAYpoW5P/xBb7XaLbNnL2gyrmzQeG
|
||||
GC_CLOUD_OPENDATA_SECRET:
|
||||
secure: 6fPhBiHKvJeOMqXdHGqpkPS+NpUDMczEXjedx8GcjbHr82ISX+gwSuXfOUDLq/S9
|
||||
GC_WITHINGS_CONSUMER_SECRET:
|
||||
secure: 86xAkdoQB8mLXq964/lGCp3ElTSF4k3a27R3UUXt3618guWLyBfsEK5Q0+XSOI3Q38w80CTpmNdwejoISv8Ilg==
|
||||
GC_NOKIA_CLIENT_SECRET:
|
||||
secure: pvPWraDplrKeRNamt5MKga8fzDmI2+zgFx+y3lsQE6gmBadZU2xkTIc/xCaP7UPv2erNCmKivfMOh2NIcRmqvIHynDoifNVy2P61KyG5v3E=
|
||||
GC_DROPBOX_CLIENT_SECRET:
|
||||
secure: 7pCVnVEKKmSU4SZN6IFqUw==
|
||||
GC_STRAVA_CLIENT_SECRET:
|
||||
secure: n3cMS1yy709xhSnTeWABMsoAIkJzy5euh3Pw4ehv0BzszJKoWkypF0cyW8RXSm3M
|
||||
GC_TODAYSPLAN_CLIENT_SECRET:
|
||||
secure: 7PnFB8cfahFT6LyP64eB7N1vkbwVaULpB2ORmEkn+J75zNB1xxGClFNXSHZ7kXhB
|
||||
GC_CYCLINGANALYTICS_CLIENT_SECRET:
|
||||
secure: UY+m3YypNNLUzKyGdrLw8xdCvxuQWRZi9EHS3j1ubLC4qyRL7iEVW6ubumfdh6gT
|
||||
GC_CLOUD_DB_BASIC_AUTH:
|
||||
secure: OEBetrOnXjsY7wN8hYqmMj6482oDORmAmCq8PI7mfnfiWE6Z4jB676JvgdNlP98q
|
||||
GC_CLOUD_DB_APP_NAME:
|
||||
secure: bpkyuw/BsJw0OrpuBqQwZ46CHbhkbmcjcMttVtfJoZU=
|
||||
GC_POLARFLOW_CLIENT_SECRET:
|
||||
secure: h2JdlC1i4QOmwpkz+Xxbrw==
|
||||
GC_SPORTTRACKS_CLIENT_SECRET:
|
||||
secure: n6a8nJgqMyg+VsVeoIIR8TFzxyDFVi2w/ggetQk5agY=
|
||||
GC_RWGPS_API_KEY:
|
||||
secure: uUtCyF5ByZ1VYJOztUngIA==
|
||||
GC_NOLIO_CLIENT_ID:
|
||||
secure: /OFVjEBwU7o3SItIQVf/YlJ8XErxneXIT2N0JyPMSXR1tCbdZVWixMHpqKNWoNk4
|
||||
GC_NOLIO_SECRET:
|
||||
secure: mmMksvVnfBiXufBDn2gAhQY53n0J9BokSCtDY51uU918QJ/LL4XOojtJp5tMFn8T7ugyDhNASpqZXiK55vxSD53vm+tjufpfzppKEeh93Babvc/VrndLB1X/RZCRUQTR6rka05fYl4e0eBzP1H091A==
|
||||
GC_XERT_CLIENT_SECRET:
|
||||
secure: /1rVLT8LyJCZ4xNJ5W+NtAcZ1rtKaUjW9SYm/T3gHoc=
|
||||
GC_AZUM_CLIENT_SECRET:
|
||||
secure: 2ZpXsA3TQv1zftYVyZSF6f83ftCzza+K22ZX1doj7Yc/5dmGl1bnsSeVChJgJ8lQ2fRPYpdmun9cjqwcrtG/zXTTsYuTvYWegHz/4Y0u6Mg=
|
||||
|
||||
init:
|
||||
# Setup QT 5.9.4 - 64Bit
|
||||
|
||||
- set QTDIR=C:\Qt\5.9.4\msvc2015_64
|
||||
# Setup QT 5.15 - 64Bit
|
||||
- set QTDIR=C:\Qt\5.15\msvc2019_64
|
||||
- set PATH=%QTDIR%\bin;%PATH%
|
||||
- qmake --version
|
||||
|
||||
# Setup MSVC - VS 2015
|
||||
# Setup MSVC - VS 2019
|
||||
- call c:\"Program Files (x86)"\"Microsoft Visual Studio"\2019\Community\VC\Auxiliary\Build\vcvarsall.bat amd64
|
||||
|
||||
- CALL "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64
|
||||
# Setup NSIS
|
||||
- set PATH=%PATH%;C:\"Program Files (x86)"\NSIS
|
||||
|
||||
# Get the libraries
|
||||
|
||||
- ps: Start-FileDownload 'https://github.com/Joern-R/gc-ci-libs/releases/download/0.0.2/gc-ci-libs.zip' -Filename 'c:/gc-ci-libs.zip'
|
||||
- 7z x c:/gc-ci-libs.zip -oC:\libs
|
||||
cache:
|
||||
- gc-ci-libs.zip -> appveyor.yml
|
||||
- jom_1_1_3.zip
|
||||
- sip-4.19.8.zip
|
||||
- C:\R
|
||||
- C:\Python -> src\Python\requirements.txt
|
||||
- c:\tools\vcpkg\installed\
|
||||
- qwt
|
||||
|
||||
install:
|
||||
# choco install winflexbison
|
||||
# Get the libraries
|
||||
- if not exist gc-ci-libs.zip appveyor DownloadFile "https://github.com/GoldenCheetah/WindowsSDK/releases/download/v0.1.1/gc-ci-libs.zip"
|
||||
- 7z x -y gc-ci-libs.zip -oC:\libs
|
||||
# GSL
|
||||
- vcpkg install gsl:x64-windows
|
||||
|
||||
# Get config
|
||||
- copy qwt\qwtconfig.pri.in qwt\qwtconfig.pri
|
||||
- copy c:\libs\gcconfig64-Release.appveyor.pri src\gcconfig.pri
|
||||
|
||||
# Get jom
|
||||
- if not exist jom_1_1_3.zip appveyor DownloadFile "https://download.qt.io/official_releases/jom/jom_1_1_3.zip"
|
||||
- 7z x -y jom_1_1_3.zip -oc:\jom\
|
||||
- set PATH=%PATH%;c:\jom\;
|
||||
|
||||
# Get R and add to config
|
||||
- ps: >-
|
||||
if (-not (Test-Path 'C:\R')) {
|
||||
# Lets use 4.1 until 4.2 issues are fixed
|
||||
#$rurl = $(ConvertFrom-JSON $(Invoke-WebRequest https://rversions.r-pkg.org/r-release-win).Content).URL
|
||||
$rurl = "https://cran.r-project.org/bin/windows/base/old/4.1.3/R-4.1.3-win.exe"
|
||||
Start-FileDownload $rurl "R-win.exe"
|
||||
Start-Process -FilePath .\R-win.exe -ArgumentList "/VERYSILENT /DIR=C:\R" -NoNewWindow -Wait
|
||||
}
|
||||
- set PATH=%PATH%;c:\R\bin\;
|
||||
- R --version
|
||||
- echo DEFINES+=GC_WANT_R >> src\gcconfig.pri
|
||||
|
||||
# Get Python embeddable and install packages
|
||||
- ps: >-
|
||||
if (-not (Test-Path 'C:\Python')) {
|
||||
Start-FileDownload "https://www.python.org/ftp/python/3.7.9/python-3.7.9-embed-amd64.zip" Python.zip
|
||||
7z x Python.zip -oC:\Python\
|
||||
echo python37.zip . '' 'import site' | Out-File C:\Python\python37._pth -Encoding ascii
|
||||
mkdir C:\Python\lib\site-packages
|
||||
c:\python37-x64\python -m pip install --upgrade pip
|
||||
c:\python37-x64\python -m pip install -r src\Python\requirements.txt -t C:\Python\lib\site-packages
|
||||
}
|
||||
|
||||
# Get SIP and and install on Python
|
||||
- c:\python37-x64\python --version
|
||||
- if not exist sip-4.19.8.zip appveyor DownloadFile "https://sourceforge.net/projects/pyqt/files/sip/sip-4.19.8/sip-4.19.8.zip"
|
||||
- 7z x sip-4.19.8.zip
|
||||
- cd sip-4.19.8
|
||||
- c:\python37-x64\python configure.py
|
||||
- jom -j4
|
||||
- nmake install
|
||||
- cd ..
|
||||
|
||||
# Add Python (avoiding colision between GC Context.h and Python context.h)
|
||||
- echo DEFINES+=GC_WANT_PYTHON >> src\gcconfig.pri
|
||||
- echo PYTHONINCLUDES=-ICore -I\"c:\python37-x64\include\" >> src\gcconfig.pri
|
||||
- echo PYTHONLIBS=-L\"c:\python37-x64\libs\" -lpython37 >> src\gcconfig.pri
|
||||
|
||||
# GSL
|
||||
- echo GSL_INCLUDES=c:\tools\vcpkg\installed\x64-windows\include >> src\gcconfig.pri
|
||||
- echo GSL_LIBS=-Lc:\tools\vcpkg\installed\x64-windows\lib -lgsl -lgslcblas >> src\gcconfig.pri
|
||||
|
||||
before_build:
|
||||
# Define GC version string, only for tagged builds
|
||||
- if %APPVEYOR_REPO_TAG%==true echo DEFINES+=GC_VERSION=VERSION_STRING >> src\gcconfig.pri
|
||||
|
||||
# Enable CloudDB
|
||||
- echo CloudDB=active >> src\gcconfig.pri
|
||||
|
||||
# Add Train Robot
|
||||
- echo DEFINES+=GC_WANT_ROBOT >> src\gcconfig.pri
|
||||
|
||||
# Avoid macro redefinition warnings
|
||||
- echo DEFINES+=_MATH_DEFINES_DEFINED >> src\gcconfig.pri
|
||||
|
||||
# Add debug console
|
||||
#- echo CONFIG+=console >> src\gcconfig.pri
|
||||
|
||||
# Patch Secrets.h
|
||||
- ps: (Get-Content src\Core\Secrets.h) -replace '__GC_GOOGLE_CALENDAR_CLIENT_SECRET__', $env:GC_GOOGLE_CALENDAR_CLIENT_SECRET | Set-Content src\Core\Secrets.h
|
||||
- ps: (Get-Content src\Core\Secrets.h) -replace '__GC_GOOGLE_DRIVE_CLIENT_ID__', $env:GC_GOOGLE_DRIVE_CLIENT_ID | Set-Content src\Core\Secrets.h
|
||||
- ps: (Get-Content src\Core\Secrets.h) -replace '__GC_GOOGLE_DRIVE_CLIENT_SECRET__', $env:GC_GOOGLE_DRIVE_CLIENT_SECRET | Set-Content src\Core\Secrets.h
|
||||
- ps: (Get-Content src\Core\Secrets.h) -replace '__GC_GOOGLE_DRIVE_API_KEY__', $env:GC_GOOGLE_DRIVE_API_KEY | Set-Content src\Core\Secrets.h
|
||||
- ps: (Get-Content src\Core\Secrets.h) -replace 'OPENDATA_DISABLE', 'OPENDATA_ENABLE' | Set-Content src\Core\Secrets.h
|
||||
- ps: (Get-Content src\Core\Secrets.h) -replace '__GC_CLOUD_OPENDATA_SECRET__', $env:GC_CLOUD_OPENDATA_SECRET | Set-Content src\Core\Secrets.h
|
||||
- ps: (Get-Content src\Core\Secrets.h) -replace '__GC_WITHINGS_CONSUMER_SECRET__', $env:GC_WITHINGS_CONSUMER_SECRET | Set-Content src\Core\Secrets.h
|
||||
- ps: (Get-Content src\Core\Secrets.h) -replace '__GC_NOKIA_CLIENT_SECRET__', $env:GC_NOKIA_CLIENT_SECRET | Set-Content src\Core\Secrets.h
|
||||
- ps: (Get-Content src\Core\Secrets.h) -replace '__GC_DROPBOX_CLIENT_SECRET__', $env:GC_DROPBOX_CLIENT_SECRET | Set-Content src\Core\Secrets.h
|
||||
- ps: (Get-Content src\Core\Secrets.h) -replace '__GC_STRAVA_CLIENT_SECRET__', $env:GC_STRAVA_CLIENT_SECRET | Set-Content src\Core\Secrets.h
|
||||
- ps: (Get-Content src\Core\Secrets.h) -replace '__GC_TODAYSPLAN_CLIENT_SECRET__', $env:GC_TODAYSPLAN_CLIENT_SECRET | Set-Content src\Core\Secrets.h
|
||||
- ps: (Get-Content src\Core\Secrets.h) -replace '__GC_CYCLINGANALYTICS_CLIENT_SECRET__', $env:GC_CYCLINGANALYTICS_CLIENT_SECRET | Set-Content src\Core\Secrets.h
|
||||
- ps: (Get-Content src\Core\Secrets.h) -replace '__GC_CLOUD_DB_BASIC_AUTH__', $env:GC_CLOUD_DB_BASIC_AUTH | Set-Content src\Core\Secrets.h
|
||||
- ps: (Get-Content src\Core\Secrets.h) -replace '__GC_CLOUD_DB_APP_NAME__', $env:GC_CLOUD_DB_APP_NAME | Set-Content src\Core\Secrets.h
|
||||
- ps: (Get-Content src\Core\Secrets.h) -replace '__GC_POLARFLOW_CLIENT_SECRET__', $env:GC_POLARFLOW_CLIENT_SECRET | Set-Content src\Core\Secrets.h
|
||||
- ps: (Get-Content src\Core\Secrets.h) -replace '__GC_SPORTTRACKS_CLIENT_SECRET__', $env:GC_SPORTTRACKS_CLIENT_SECRET | Set-Content src\Core\Secrets.h
|
||||
- ps: (Get-Content src\Core\Secrets.h) -replace '__GC_RWGPS_API_KEY__', $env:GC_RWGPS_API_KEY | Set-Content src\Core\Secrets.h
|
||||
- ps: (Get-Content src\Core\Secrets.h) -replace '__GC_NOLIO_CLIENT_ID__', $env:GC_NOLIO_CLIENT_ID | Set-Content src\Core\Secrets.h
|
||||
- ps: (Get-Content src\Core\Secrets.h) -replace '__GC_NOLIO_SECRET__', $env:GC_NOLIO_SECRET | Set-Content src\Core\Secrets.h
|
||||
- ps: (Get-Content src\Core\Secrets.h) -replace '__GC_XERT_CLIENT_SECRET__', $env:GC_XERT_CLIENT_SECRET | Set-Content src\Core\Secrets.h
|
||||
- ps: (Get-Content src\Core\Secrets.h) -replace '__GC_AZUM_CLIENT_SECRET__', $env:GC_AZUM_CLIENT_SECRET | Set-Content src\Core\Secrets.h
|
||||
|
||||
build_script:
|
||||
- qmake.exe build.pro -r -spec win32-msvc
|
||||
- nmake
|
||||
- cd qwt\
|
||||
- jom -j1
|
||||
- cd ..
|
||||
- jom -j4
|
||||
|
||||
#notifications:
|
||||
#- provider: GitHubPullRequest
|
||||
# on_build_success: true
|
||||
# on_build_failure: true
|
||||
# on_build_status_changed: true
|
||||
after_build:
|
||||
- cd src\release
|
||||
|
||||
# copy dependencies
|
||||
- windeployqt --release GoldenCheetah.exe
|
||||
- copy c:\libs\10_Precompiled_DLL\usbexpress_3.5.1\USBXpress\USBXpress_API\Host\x64\SiUSBXp.dll
|
||||
- copy c:\libs\10_Precompiled_DLL\libsamplerate64\lib\libsamplerate-0.dll
|
||||
- copy c:\libs\10_Precompiled_DLL\VLC\win64\lib\libvlc*.dll
|
||||
- xcopy /s /i /e /q c:\libs\10_Precompiled_DLL\VLC\win64\plugins plugins
|
||||
- copy c:\OpenSSL-v111-Win64\bin\lib*.dll
|
||||
- copy c:\OpenSSL-v111-Win64\license.txt "OpenSSL License.txt"
|
||||
- xcopy /s /i /e /q C:\Python .
|
||||
- copy C:\Python\LICENSE.txt "PYTHON LICENSE.txt"
|
||||
- copy c:\tools\vcpkg\installed\x64-windows\bin\gsl*.dll
|
||||
|
||||
# ReadMe, license and icon files
|
||||
- copy ..\Resources\win32\ReadMe.txt
|
||||
- echo GoldenCheetah is licensed under the GNU General Public License v2 > license.txt
|
||||
- echo. >> license.txt
|
||||
- type ..\..\COPYING >> license.txt
|
||||
- copy ..\Resources\win32\gc.ico
|
||||
|
||||
# Installer script
|
||||
- copy ..\Resources\win32\GC3.6-Dev-Master-W64-QT5.nsi
|
||||
|
||||
# Build the installer
|
||||
- makensis GC3.6-Dev-Master-W64-QT5.nsi
|
||||
- move GoldenCheetah_v3.6-DEV_64bit_Windows.exe ..\..\GoldenCheetah_v3.6-DEV_x64.exe
|
||||
- cd ..\..
|
||||
- ps: Set-AppveyorBuildVariable -Name 'PUBLISH_BINARIES' -Value false
|
||||
- ps: if ($env:APPVEYOR_REPO_COMMIT_MESSAGE_EXTENDED -Match "\[publish binaries\]") { Set-AppveyorBuildVariable -Name 'PUBLISH_BINARIES' -Value true }
|
||||
|
||||
test_script:
|
||||
# minimum test
|
||||
- src\release\GoldenCheetah --version 2>GCversionWindows.txt
|
||||
- git log -1 >> GCversionWindows.txt
|
||||
- ps: CertUtil -hashfile GoldenCheetah_v3.6-DEV_x64.exe sha256 | Select-Object -First 2 | Add-Content GCversionWindows.txt
|
||||
- type GCversionWindows.txt
|
||||
|
||||
artifacts:
|
||||
- path: GoldenCheetah_v3.6-DEV_x64.exe
|
||||
name: GCinstaller
|
||||
- path: GCversionWindows.txt
|
||||
name: GCversionWindows
|
||||
|
||||
deploy:
|
||||
# deploy continuous builds to s3
|
||||
- provider: S3
|
||||
access_key_id:
|
||||
secure: RoEkfKfOnF7JHOiLZX5qfZM08X+bu4oaDzzSKgdooNM=
|
||||
secret_access_key:
|
||||
secure: GPAArawatirYwgpHJBthdrbvyFU5bBzPOdK7VYYPiG2YHYi/DNJZ5Q5qGK1A440p
|
||||
bucket: goldencheetah-binaries
|
||||
region: us-east-1
|
||||
remove_files: true
|
||||
set_public: true
|
||||
folder: Windows
|
||||
artifact: GCinstaller, GCversionWindows
|
||||
on:
|
||||
PUBLISH_BINARIES: true
|
||||
APPVEYOR_REPO_NAME: "GoldenCheetah/GoldenCheetah"
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
TEMPLATE = subdirs
|
||||
SUBDIRS = qwt
|
||||
unix:!macx {
|
||||
SUBDIRS += kqoauth
|
||||
}
|
||||
SUBDIRS += src
|
||||
CONFIG += ordered
|
||||
|
||||
4615
contrib/boost/GeometricTools_BSplineCurve.h
Normal file
4615
contrib/boost/GeometricTools_BSplineCurve.h
Normal file
File diff suppressed because it is too large
Load Diff
19
contrib/kmeans/INFO
Normal file
19
contrib/kmeans/INFO
Normal file
@@ -0,0 +1,19 @@
|
||||
NOTE
|
||||
|
||||
The sources in this sub-directory including the LICENSE and README files
|
||||
are imported with permission granted by the author (Greg Hamerly).
|
||||
|
||||
The original sources are available from Github here:
|
||||
https://github.com/ghamerly/fast-kmeans
|
||||
|
||||
Whilst the original source implements multiple algorithms we only kept
|
||||
the hamerly variant.
|
||||
|
||||
The source files have not been adapted to use Qt containers or to refactor
|
||||
any of the class inheritance. So updating to newer versions should be
|
||||
very straightforward (although the base functionality and performance is
|
||||
good enough).
|
||||
|
||||
Usage in Qt applications will likely use the Kmeans wrapper class
|
||||
|
||||
28/09/2021
|
||||
22
contrib/kmeans/LICENSE
Normal file
22
contrib/kmeans/LICENSE
Normal file
@@ -0,0 +1,22 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Greg Hamerly
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
15
contrib/kmeans/Makefile-testing
Normal file
15
contrib/kmeans/Makefile-testing
Normal file
@@ -0,0 +1,15 @@
|
||||
# doesn't work now since the source has been placed in a subdir
|
||||
# left for info and fairly trivial to fixup if you want to work
|
||||
# directly with the original sources
|
||||
|
||||
OBJECTS=kmeans_dataset.o \
|
||||
general_functions.o \
|
||||
hamerly_kmeans.o \
|
||||
kmeans.o \
|
||||
original_space_kmeans.o \
|
||||
triangle_inequality_base_kmeans.o \
|
||||
driver-standalone.o
|
||||
|
||||
driver-standalone: $(OBJECTS)
|
||||
gcc -o $@ $(OBJECTS) -lstdc++ -lm
|
||||
./driver-standalone hamerly smallDataset.txt 4 centers
|
||||
106
contrib/kmeans/README
Normal file
106
contrib/kmeans/README
Normal file
@@ -0,0 +1,106 @@
|
||||
===============================
|
||||
Fast K-means Clustering Toolkit
|
||||
===============================
|
||||
|
||||
----------------------
|
||||
Version 0.1 (Sat May 17 17:41:11 CDT 2014)
|
||||
- Initial release.
|
||||
|
||||
----------------------
|
||||
WHAT:
|
||||
This software is a testbed for comparing variants of Lloyd's k-means clustering
|
||||
algorithm. It includes implementations of several algorithms that accelerate
|
||||
the algorithm by avoiding unnecessary distance calculations.
|
||||
|
||||
----------------------
|
||||
WHO:
|
||||
Greg Hamerly (hamerly@cs.baylor.edu, primary contact) and Jonathan Drake
|
||||
(drakej@hp.com).
|
||||
|
||||
----------------------
|
||||
HOW TO BUILD THE SOFTWARE:
|
||||
type "make" (and hope for the best)
|
||||
|
||||
----------------------
|
||||
HOW TO RUN THE SOFTWARE:
|
||||
The driver is designed to take commands from standard input, usually a file
|
||||
that's been redirected as input:
|
||||
|
||||
./kmeans < commands.txt
|
||||
|
||||
You can read the source to find all the possible commands, but here is a
|
||||
summary:
|
||||
- threads T -- use T threads for clustering
|
||||
- maxiterations I -- use at most I iterations; default (or negative)
|
||||
indicates an unlimited number
|
||||
- dataset D -- use the given path name to a file as the dataset for
|
||||
clustering. The dataset should have a first line with the number of points
|
||||
n and dimension d. The next (nd) tokens are taken as the n vectors
|
||||
to cluster.
|
||||
- initialize k {kpp|random} -- use the given method (k-means++ or a random
|
||||
sample of the points) to initialize k centers
|
||||
- lloyd, hamerly, annulus, elkan, compare, sort, heap, adaptive -- perform
|
||||
k-means clustering with the given algorithm (requires first having
|
||||
initialized the centers). The adaptive algorithm is Drake's algorithm with
|
||||
a heuristic for choosing an initial B
|
||||
- drake B -- use Drake's algorithm with B lower bounds
|
||||
- kernel [gaussian T | linear | polynomial P] -- use kernelized k-means with
|
||||
the given kernel
|
||||
- elkan_kernel [gaussian T | linear | polynomial P] -- use kernelized
|
||||
k-means with the given kernel, and Elkan's accelerations
|
||||
- center -- give the previously-loaded dataset a mean of 0.
|
||||
- quit -- quit the program
|
||||
|
||||
Note that when a set of centers is initialized, that same set of centers is used
|
||||
from then on (until a new initialization occurs). So running a clustering
|
||||
algorithm multiple times will use the same initialization each time.
|
||||
|
||||
Here is an example of a simple set of commands:
|
||||
|
||||
dataset smallDataset.txt
|
||||
initialize 10 kpp
|
||||
|
||||
annulus
|
||||
hamerly
|
||||
adaptive
|
||||
heap
|
||||
elkan
|
||||
sort
|
||||
compare
|
||||
|
||||
|
||||
----------------------
|
||||
CAVEATS:
|
||||
- This software has been developed and tested on Linux. Other platforms may not
|
||||
work. Please let us know if you have difficulties, and if possible fixes for
|
||||
the code.
|
||||
|
||||
- This software uses a non-standard pthreads function called
|
||||
pthread_barrier_wait(), which is implemented on Linux but not on OSX.
|
||||
Therefore, multithreading doesn't currently work on OSX. To turn it off,
|
||||
comment out the lines in the Makefile that say:
|
||||
|
||||
CPPFLAGS += -DUSE_THREADS
|
||||
LDFLAGS += -lpthread
|
||||
|
||||
|
||||
----------------------
|
||||
REFERENCES:
|
||||
|
||||
Phillips, Steven J. "Acceleration of k-means and related clustering algorithms."
|
||||
In Algorithm Engineering and Experiments, pp. 166-177. Springer Berlin
|
||||
Heidelberg, 2002.
|
||||
|
||||
Elkan, Charles. "Using the triangle inequality to accelerate k-means." In ICML,
|
||||
vol. 3, pp. 147-153. 2003.
|
||||
|
||||
Hamerly, Greg. "Making k-means Even Faster." In SDM, pp. 130-140. 2010.
|
||||
|
||||
Drake, Jonathan, and Greg Hamerly. "Accelerated k-means with adaptive distance
|
||||
bounds." In 5th NIPS Workshop on Optimization for Machine Learning. 2012.
|
||||
|
||||
Drake, Jonathan. "Faster k-means clustering." MS thesis, 2013.
|
||||
|
||||
Hamerly, Greg, and Jonathan Drake. "Accelerating Lloyd's algorithm for k-means
|
||||
clustering." To appear in Partitional Clustering Algorithms, Springer, 2014.
|
||||
|
||||
70
contrib/kmeans/driver-standalone.cpp
Normal file
70
contrib/kmeans/driver-standalone.cpp
Normal file
@@ -0,0 +1,70 @@
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
#include "kmeans/general_functions.h"
|
||||
#include "kmeans/kmeans.h"
|
||||
|
||||
|
||||
#include "dataset.h"
|
||||
#include "hamerly_kmeans.h"
|
||||
|
||||
Dataset *load_dataset(std::string const &filename) {
|
||||
std::ifstream input(filename.c_str());
|
||||
|
||||
int n, d;
|
||||
input >> n >> d;
|
||||
Dataset *x = new Dataset(n, d);
|
||||
|
||||
for (int i = 0; i < n * d; ++i) input >> x->data[i];
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
Kmeans *get_algorithm(std::string const &name) {
|
||||
if (name == "hamerly") return new HamerlyKmeans();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
if (argc != 5) {
|
||||
std::cout << "usage: " << argv[0] << " algorithm dataset k [centers|assignment]\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::string algorithm_name(argv[1]);
|
||||
std::string filename(argv[2]);
|
||||
int k = std::stoi(argv[3]);
|
||||
std::string output(argv[4]);
|
||||
|
||||
Dataset *x = load_dataset(filename);
|
||||
Kmeans *algorithm = get_algorithm(algorithm_name);
|
||||
|
||||
Dataset *initialCenters = init_centers_kmeanspp_v2(*x, k);
|
||||
|
||||
unsigned short *assignment = new unsigned short[x->n];
|
||||
|
||||
assign(*x, *initialCenters, assignment);
|
||||
|
||||
algorithm->initialize(x, k, assignment, 1);
|
||||
|
||||
algorithm->run(10000);
|
||||
|
||||
Dataset const *finalCenters = algorithm->getCenters();
|
||||
if (output == "centers") {
|
||||
finalCenters->print();
|
||||
} else {
|
||||
assign(*x, *finalCenters, assignment);
|
||||
for (int i = 0; i < x->n; ++i) {
|
||||
std::cout << assignment[i] << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
delete x;
|
||||
delete algorithm;
|
||||
delete initialCenters;
|
||||
delete [] assignment;
|
||||
|
||||
return 0;
|
||||
}
|
||||
179
contrib/kmeans/hamerly_kmeans.cpp
Normal file
179
contrib/kmeans/hamerly_kmeans.cpp
Normal file
@@ -0,0 +1,179 @@
|
||||
/* Authors: Greg Hamerly and Jonathan Drake
|
||||
* Feedback: hamerly@cs.baylor.edu
|
||||
* See: http://cs.baylor.edu/~hamerly/software/kmeans.php
|
||||
* Copyright 2014
|
||||
*/
|
||||
|
||||
#include "hamerly_kmeans.h"
|
||||
#include "kmeans_general_functions.h"
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
|
||||
/* Hamerly's algorithm that is a 'simplification' of Elkan's, in that it keeps
|
||||
* the following bounds:
|
||||
* - One upper bound per clustered record on the distance between the record
|
||||
* and its closest center. It is always greater than or equal to the true
|
||||
* distance between the record and its closest center. This is the same as in
|
||||
* Elkan's algorithm.
|
||||
* - *One* lower bound per clustered record on the distance between the record
|
||||
* and its *second*-closest center. It is always less than or equal to the
|
||||
* true distance between the record and its second closest center. This is
|
||||
* different information than Elkan's algorithm -- his algorithm keeps k
|
||||
* lower bounds for each record, for a total of (n*k) lower bounds.
|
||||
*
|
||||
* The basic ideas are:
|
||||
* - when lower(x) <= upper(x), we need to recalculate the closest centers for
|
||||
* the record x, and reset lower(x) and upper(x) to their boundary values
|
||||
* - whenever a center moves
|
||||
* - calculate the distance it moves 'd'
|
||||
* - for each record x assigned to that center, update its upper bound
|
||||
* - upper(x) = upper(x) + d
|
||||
* - after each iteration
|
||||
* - find the center that has moved the most (with distance 'd')
|
||||
* - update the lower bound for all (?) records:
|
||||
* - lower(x) = lower(x) - d
|
||||
*
|
||||
* Parameters:
|
||||
* - threadId: the index of the thread that is running
|
||||
* - maxIterations: a bound on the number of iterations to perform
|
||||
*
|
||||
* Return value: the number of iterations performed (always at least 1)
|
||||
*/
|
||||
// this version only updates center locations when necessary
|
||||
int HamerlyKmeans::runThread(int threadId, int maxIterations) {
|
||||
int iterations = 0;
|
||||
|
||||
int startNdx = start(threadId);
|
||||
int endNdx = end(threadId);
|
||||
|
||||
while ((iterations < maxIterations) && ! converged) {
|
||||
++iterations;
|
||||
|
||||
// compute the inter-center distances, keeping only the closest distances
|
||||
update_s(threadId);
|
||||
synchronizeAllThreads();
|
||||
|
||||
// loop over all records
|
||||
for (int i = startNdx; i < endNdx; ++i) {
|
||||
unsigned short closest = assignment[i];
|
||||
|
||||
// if upper[i] is less than the greater of these two, then we can
|
||||
// ignore record i
|
||||
double upper_comparison_bound = std::max(s[closest], lower[i]);
|
||||
|
||||
// first check: if u(x) <= s(c(x)) or u(x) <= lower(x), then ignore
|
||||
// x, because its closest center must still be closest
|
||||
if (upper[i] <= upper_comparison_bound) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// otherwise, compute the real distance between this record and its
|
||||
// closest center, and update upper
|
||||
double u2 = pointCenterDist2(i, closest);
|
||||
upper[i] = sqrt(u2);
|
||||
|
||||
// if (u(x) <= s(c(x))) or (u(x) <= lower(x)), then ignore x
|
||||
if (upper[i] <= upper_comparison_bound) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// now update the lower bound by looking at all other centers
|
||||
double l2 = std::numeric_limits<double>::max(); // the squared lower bound
|
||||
for (int j = 0; j < k; ++j) {
|
||||
if (j == closest) { continue; }
|
||||
|
||||
double dist2 = pointCenterDist2(i, j);
|
||||
|
||||
if (dist2 < u2) {
|
||||
// another center is closer than the current assignment
|
||||
|
||||
// change the lower bound to be the current upper bound
|
||||
// (since the current upper bound is the distance to the
|
||||
// now-second-closest known center)
|
||||
l2 = u2;
|
||||
|
||||
// adjust the upper bound and the current assignment
|
||||
u2 = dist2;
|
||||
closest = j;
|
||||
} else if (dist2 < l2) {
|
||||
// we must reduce the lower bound on the distance to the
|
||||
// *second* closest center to x[i]
|
||||
l2 = dist2;
|
||||
}
|
||||
}
|
||||
|
||||
// we have been dealing in squared distances; need to convert
|
||||
lower[i] = sqrt(l2);
|
||||
|
||||
// if the assignment for i has changed, then adjust the counts and
|
||||
// locations of each center's accumulated mass
|
||||
if (assignment[i] != closest) {
|
||||
upper[i] = sqrt(u2);
|
||||
changeAssignment(i, closest, threadId);
|
||||
}
|
||||
}
|
||||
|
||||
verifyAssignment(iterations, startNdx, endNdx);
|
||||
|
||||
// ELKAN 4, 5, AND 6
|
||||
// calculate the new center locations
|
||||
synchronizeAllThreads();
|
||||
if (threadId == 0) {
|
||||
int furthestMovingCenter = move_centers();
|
||||
converged = (0.0 == centerMovement[furthestMovingCenter]);
|
||||
}
|
||||
|
||||
synchronizeAllThreads();
|
||||
|
||||
if (! converged) {
|
||||
update_bounds(startNdx, endNdx);
|
||||
}
|
||||
|
||||
synchronizeAllThreads();
|
||||
}
|
||||
|
||||
return iterations;
|
||||
}
|
||||
|
||||
|
||||
/* This method does the following:
|
||||
* - finds the furthest-moving center
|
||||
* - finds the distances moved by the two furthest-moving centers
|
||||
* - updates the upper/lower bounds for each record
|
||||
*
|
||||
* Parameters:
|
||||
* - startNdx: the first index of the dataset this thread is responsible for
|
||||
* - endNdx: one past the last index of the dataset this thread is responsible for
|
||||
*/
|
||||
void HamerlyKmeans::update_bounds(int startNdx, int endNdx) {
|
||||
double longest = centerMovement[0], secondLongest = (1 < k) ? centerMovement[1] : centerMovement[0];
|
||||
int furthestMovingCenter = 0;
|
||||
|
||||
if (longest < secondLongest) {
|
||||
furthestMovingCenter = 1;
|
||||
std::swap(longest, secondLongest);
|
||||
}
|
||||
|
||||
for (int j = 2; j < k; ++j) {
|
||||
if (longest < centerMovement[j]) {
|
||||
secondLongest = longest;
|
||||
longest = centerMovement[j];
|
||||
furthestMovingCenter = j;
|
||||
} else if (secondLongest < centerMovement[j]) {
|
||||
secondLongest = centerMovement[j];
|
||||
}
|
||||
}
|
||||
|
||||
// update upper/lower bounds
|
||||
for (int i = startNdx; i < endNdx; ++i) {
|
||||
// the upper bound increases by the amount that its center moved
|
||||
upper[i] += centerMovement[assignment[i]];
|
||||
|
||||
// The lower bound decreases by the maximum amount that any center
|
||||
// moved, unless the furthest-moving center is the one it's assigned
|
||||
// to. In the latter case, the lower bound decreases by the amount
|
||||
// of the second-furthest-moving center.
|
||||
lower[i] -= (assignment[i] == furthestMovingCenter) ? secondLongest : longest;
|
||||
}
|
||||
}
|
||||
|
||||
29
contrib/kmeans/hamerly_kmeans.h
Normal file
29
contrib/kmeans/hamerly_kmeans.h
Normal file
@@ -0,0 +1,29 @@
|
||||
#ifndef HAMERLY_KMEANS_H
|
||||
#define HAMERLY_KMEANS_H
|
||||
|
||||
/* Authors: Greg Hamerly and Jonathan Drake
|
||||
* Feedback: hamerly@cs.baylor.edu
|
||||
* See: http://cs.baylor.edu/~hamerly/software/kmeans.php
|
||||
* Copyright 2014
|
||||
*
|
||||
* HamerlyKmeans implements Hamerly's k-means algorithm that uses one lower
|
||||
* bound per point.
|
||||
*/
|
||||
|
||||
#include "triangle_inequality_base_kmeans.h"
|
||||
|
||||
class HamerlyKmeans : public TriangleInequalityBaseKmeans {
|
||||
public:
|
||||
HamerlyKmeans() { numLowerBounds = 1; }
|
||||
virtual ~HamerlyKmeans() { free(); }
|
||||
virtual std::string getName() const { return "hamerly"; }
|
||||
|
||||
protected:
|
||||
// Update the upper and lower bounds for the given range of points.
|
||||
void update_bounds(int startNdx, int endNdx);
|
||||
|
||||
virtual int runThread(int threadId, int maxIterations);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
165
contrib/kmeans/kmeans.cpp
Normal file
165
contrib/kmeans/kmeans.cpp
Normal file
@@ -0,0 +1,165 @@
|
||||
/* Authors: Greg Hamerly and Jonathan Drake
|
||||
* Feedback: hamerly@cs.baylor.edu
|
||||
* See: http://cs.baylor.edu/~hamerly/software/kmeans.php
|
||||
* Copyright 2014
|
||||
*/
|
||||
|
||||
#include "kmeans.h"
|
||||
#include "kmeans_general_functions.h"
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
|
||||
Kmeans::Kmeans() : x(NULL), n(0), k(0), d(0), numThreads(0), converged(false),
|
||||
clusterSize(NULL), centerMovement(NULL), assignment(NULL) {
|
||||
#ifdef COUNT_DISTANCES
|
||||
numDistances = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void Kmeans::free() {
|
||||
delete [] centerMovement;
|
||||
for (int t = 0; t < numThreads; ++t) {
|
||||
delete [] clusterSize[t];
|
||||
}
|
||||
delete [] clusterSize;
|
||||
centerMovement = NULL;
|
||||
clusterSize = NULL;
|
||||
assignment = NULL;
|
||||
n = k = d = numThreads = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Kmeans::initialize(Dataset const *aX, unsigned short aK, unsigned short *initialAssignment, int aNumThreads) {
|
||||
free();
|
||||
|
||||
converged = false;
|
||||
x = aX;
|
||||
n = x->n;
|
||||
d = x->d;
|
||||
k = aK;
|
||||
|
||||
#ifdef USE_THREADS
|
||||
numThreads = aNumThreads;
|
||||
pthread_barrier_init(&barrier, NULL, numThreads);
|
||||
#else
|
||||
numThreads = 1;
|
||||
#endif
|
||||
|
||||
assignment = initialAssignment;
|
||||
centerMovement = new double[k];
|
||||
clusterSize = new int *[numThreads];
|
||||
for (int t = 0; t < numThreads; ++t) {
|
||||
clusterSize[t] = new int[k];
|
||||
std::fill(clusterSize[t], clusterSize[t] + k, 0);
|
||||
for (int i = start(t); i < end(t); ++i) {
|
||||
assert(assignment[i] < k);
|
||||
++clusterSize[t][assignment[i]];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef COUNT_DISTANCES
|
||||
numDistances = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void Kmeans::changeAssignment(int xIndex, int closestCluster, int threadId) {
|
||||
--clusterSize[threadId][assignment[xIndex]];
|
||||
++clusterSize[threadId][closestCluster];
|
||||
assignment[xIndex] = closestCluster;
|
||||
}
|
||||
|
||||
#ifdef USE_THREADS
|
||||
struct ThreadInfo {
|
||||
public:
|
||||
ThreadInfo() : km(NULL), threadId(0), pthread_id(0) {}
|
||||
Kmeans *km;
|
||||
int threadId;
|
||||
pthread_t pthread_id;
|
||||
int numIterations;
|
||||
int maxIterations;
|
||||
};
|
||||
#endif
|
||||
|
||||
void *Kmeans::runner(void *args) {
|
||||
#ifdef USE_THREADS
|
||||
ThreadInfo *ti = (ThreadInfo *)args;
|
||||
ti->numIterations = ti->km->runThread(ti->threadId, ti->maxIterations);
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int Kmeans::run(int maxIterations) {
|
||||
int iterations = 0;
|
||||
#ifdef USE_THREADS
|
||||
{
|
||||
ThreadInfo *info = new ThreadInfo[numThreads];
|
||||
for (int t = 0; t < numThreads; ++t) {
|
||||
info[t].km = this;
|
||||
info[t].threadId = t;
|
||||
info[t].maxIterations = maxIterations;
|
||||
pthread_create(&info[t].pthread_id, NULL, Kmeans::runner, &info[t]);
|
||||
}
|
||||
// wait for everything to finish...
|
||||
for (int t = 0; t < numThreads; ++t) {
|
||||
pthread_join(info[t].pthread_id, NULL);
|
||||
}
|
||||
iterations = info[0].numIterations;
|
||||
delete [] info;
|
||||
}
|
||||
#else
|
||||
{
|
||||
iterations = runThread(0, maxIterations);
|
||||
}
|
||||
#endif
|
||||
|
||||
return iterations;
|
||||
}
|
||||
|
||||
double Kmeans::getSSE() const {
|
||||
double sse = 0.0;
|
||||
for (int i = 0; i < n; ++i) {
|
||||
sse += pointCenterDist2(i, assignment[i]);
|
||||
}
|
||||
return sse;
|
||||
}
|
||||
|
||||
void Kmeans::verifyAssignment(int iteration, int startNdx, int endNdx) const {
|
||||
#ifdef VERIFY_ASSIGNMENTS
|
||||
for (int i = startNdx; i < endNdx; ++i) {
|
||||
// keep track of the squared distance and identity of the closest-seen
|
||||
// cluster (so far)
|
||||
int closest = assignment[i];
|
||||
double closest_dist2 = pointCenterDist2(i, closest);
|
||||
double original_closest_dist2 = closest_dist2;
|
||||
// look at all centers
|
||||
for (int j = 0; j < k; ++j) {
|
||||
if (j == closest) {
|
||||
continue;
|
||||
}
|
||||
double d2 = pointCenterDist2(i, j);
|
||||
|
||||
// determine if we found a closer center
|
||||
if (d2 < closest_dist2) {
|
||||
closest = j;
|
||||
closest_dist2 = d2;
|
||||
}
|
||||
}
|
||||
|
||||
// if we have found a discrepancy, then print out information and crash
|
||||
// the program
|
||||
if (closest != assignment[i]) {
|
||||
std::cerr << "assignment error:" << std::endl;
|
||||
std::cerr << "iteration = " << iteration << std::endl;
|
||||
std::cerr << "point index = " << i << std::endl;
|
||||
std::cerr << "closest center = " << closest << std::endl;
|
||||
std::cerr << "closest center dist2 = " << closest_dist2 << std::endl;
|
||||
std::cerr << "assigned center = " << assignment[i] << std::endl;
|
||||
std::cerr << "assigned center dist2 = " << original_closest_dist2 << std::endl;
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
147
contrib/kmeans/kmeans.h
Normal file
147
contrib/kmeans/kmeans.h
Normal file
@@ -0,0 +1,147 @@
|
||||
#ifndef KMEANS_H
|
||||
#define KMEANS_H
|
||||
|
||||
/* Authors: Greg Hamerly and Jonathan Drake
|
||||
* Feedback: hamerly@cs.baylor.edu
|
||||
* See: http://cs.baylor.edu/~hamerly/software/kmeans.php
|
||||
* Copyright 2014
|
||||
*
|
||||
* Kmeans is an abstract base class for algorithms which implement Lloyd's
|
||||
* k-means algorithm. Subclasses provide functionality in the "runThread()"
|
||||
* method.
|
||||
*/
|
||||
|
||||
#include "kmeans_dataset.h"
|
||||
#include <limits>
|
||||
#include <string>
|
||||
#ifdef USE_THREADS
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
class Kmeans {
|
||||
public:
|
||||
// Construct a K-means object to operate on the given dataset
|
||||
Kmeans();
|
||||
virtual ~Kmeans() { free(); }
|
||||
|
||||
// This method kicks off the threads that do the clustering and run
|
||||
// until convergence (or until reaching maxIterations). It returns the
|
||||
// number of iterations performed.
|
||||
int run(int aMaxIterations = std::numeric_limits<int>::max());
|
||||
|
||||
// Get the cluster assignment for the given point index.
|
||||
int getAssignment(int xIndex) const { return assignment[xIndex]; }
|
||||
|
||||
// Initialize the algorithm at the beginning of the run(), with the
|
||||
// given data and initial assignment. The parameter initialAssignment
|
||||
// will be modified by this algorithm and will at the end contain the
|
||||
// final assignment of clusters.
|
||||
virtual void initialize(Dataset const *aX, unsigned short aK, unsigned short *initialAssignment, int aNumThreads);
|
||||
|
||||
// Free all memory being used by the object.
|
||||
virtual void free();
|
||||
|
||||
// This method verifies that the current assignment is correct, by
|
||||
// checking every point-center distance. For debugging.
|
||||
virtual void verifyAssignment(int iteration, int startNdx, int endNdx) const;
|
||||
|
||||
// Compute the sum of squared errors for the data on the centers (not
|
||||
// designed to be fast).
|
||||
virtual double getSSE() const;
|
||||
|
||||
// Get the name of this clustering algorithm (to be overridden by
|
||||
// subclasses).
|
||||
virtual std::string getName() const = 0;
|
||||
|
||||
// Virtual methods for computing inner products (depending on the kernel
|
||||
// being used, e.g.). For vanilla k-means these will be the standard dot
|
||||
// product; for more exotic applications these will be other kernel
|
||||
// functions.
|
||||
virtual double pointPointInnerProduct(int x1, int x2) const = 0;
|
||||
virtual double pointCenterInnerProduct(int xndx, unsigned short cndx) const = 0;
|
||||
virtual double centerCenterInnerProduct(unsigned short c1, unsigned short c2) const = 0;
|
||||
|
||||
// Use the inner products to compute squared distances between a point
|
||||
// and center.
|
||||
virtual double pointCenterDist2(int x1, unsigned short cndx) const {
|
||||
#ifdef COUNT_DISTANCES
|
||||
++numDistances;
|
||||
#endif
|
||||
return pointPointInnerProduct(x1, x1) - 2 * pointCenterInnerProduct(x1, cndx) + centerCenterInnerProduct(cndx, cndx);
|
||||
}
|
||||
|
||||
// Use the inner products to compute squared distances between two
|
||||
// centers.
|
||||
virtual double centerCenterDist2(unsigned short c1, unsigned short c2) const {
|
||||
#ifdef COUNT_DISTANCES
|
||||
++numDistances;
|
||||
#endif
|
||||
return centerCenterInnerProduct(c1, c1) - 2 * centerCenterInnerProduct(c1, c2) + centerCenterInnerProduct(c2, c2);
|
||||
}
|
||||
|
||||
#ifdef COUNT_DISTANCES
|
||||
#ifdef USE_THREADS
|
||||
// Note: numDistances is NOT thread-safe, but it is not meant to be
|
||||
// enabled in performant code.
|
||||
#error Counting distances and using multiple threads is not supported.
|
||||
#endif
|
||||
mutable long long numDistances;
|
||||
#endif
|
||||
|
||||
virtual Dataset const *getCenters() const { return NULL; }
|
||||
|
||||
protected:
|
||||
// The dataset to cluster.
|
||||
const Dataset *x;
|
||||
|
||||
// Local copies for convenience.
|
||||
int n, k, d;
|
||||
|
||||
// Pthread primitives for multithreading.
|
||||
int numThreads;
|
||||
#ifdef USE_THREADS
|
||||
pthread_barrier_t barrier;
|
||||
#endif
|
||||
|
||||
// To communicate (to all threads) that we have converged.
|
||||
bool converged;
|
||||
|
||||
// Keep track of how many points are in each cluster, divided over each
|
||||
// thread.
|
||||
int **clusterSize;
|
||||
|
||||
// centerMovement is computed in move_centers() and used to detect
|
||||
// convergence (if max(centerMovement) == 0.0) and update point-center
|
||||
// distance bounds (in subclasses that use them).
|
||||
double *centerMovement;
|
||||
|
||||
// For each point in x, keep which cluster it is assigned to. By using a
|
||||
// short, we assume a limited number of clusters (fewer than 2^16).
|
||||
unsigned short *assignment;
|
||||
|
||||
|
||||
// This is where each thread does its work.
|
||||
virtual int runThread(int threadId, int maxIterations) = 0;
|
||||
|
||||
// Static entry method for pthread_create().
|
||||
static void *runner(void *args);
|
||||
|
||||
// Assign point at xIndex to cluster newCluster, working within thread threadId.
|
||||
virtual void changeAssignment(int xIndex, int newCluster, int threadId);
|
||||
|
||||
// Over what range in [0, n) does this thread have ownership of the
|
||||
// points? end() returns one past the last owned point.
|
||||
int start(int threadId) const { return n * threadId / numThreads; }
|
||||
int end(int threadId) const { return start(threadId + 1); }
|
||||
int whichThread(int index) const { return index * numThreads / n; }
|
||||
|
||||
// Convenience method for causing all threads to synchronize.
|
||||
void synchronizeAllThreads() {
|
||||
#ifdef USE_THREADS
|
||||
pthread_barrier_wait(&barrier);
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
95
contrib/kmeans/kmeans_dataset.cpp
Normal file
95
contrib/kmeans/kmeans_dataset.cpp
Normal file
@@ -0,0 +1,95 @@
|
||||
/* Authors: Greg Hamerly and Jonathan Drake
|
||||
* Feedback: hamerly@cs.baylor.edu
|
||||
* See: http://cs.baylor.edu/~hamerly/software/kmeans.php
|
||||
* Copyright 2014
|
||||
*/
|
||||
|
||||
#include "kmeans_dataset.h"
|
||||
// #include <iostream>
|
||||
#include <iomanip>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
||||
// print the dataset to standard output (cout), using formatting to keep the
|
||||
// data in matrix format
|
||||
void Dataset::print(std::ostream &out) const {
|
||||
//std::ostream &out = std::cout;
|
||||
out.precision(6);
|
||||
int ndx = 0;
|
||||
for (int i = 0; i < n; ++i) {
|
||||
for (int j = 0; j < d; ++j) {
|
||||
out << std::setw(13) << data[ndx++] << " ";
|
||||
}
|
||||
out << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
// returns a (modifiable) reference to the value in dimension "dim" from record
|
||||
// "ndx"
|
||||
double &Dataset::operator()(int ndx, int dim) {
|
||||
# ifdef DEBUG
|
||||
assert(ndx < n);
|
||||
assert(dim < d);
|
||||
# endif
|
||||
return data[ndx * d + dim];
|
||||
}
|
||||
|
||||
// returns a (const) reference to the value in dimension "dim" from record "ndx"
|
||||
const double &Dataset::operator()(int ndx, int dim) const {
|
||||
# ifdef DEBUG
|
||||
assert(ndx < n);
|
||||
assert(dim < d);
|
||||
# endif
|
||||
return data[ndx * d + dim];
|
||||
}
|
||||
|
||||
// fill the entire dataset with value. Does NOT update sumDataSquared.
|
||||
void Dataset::fill(double value) {
|
||||
for (int i = 0; i < nd; ++i) {
|
||||
data[i] = value;
|
||||
}
|
||||
}
|
||||
|
||||
// copy constructor -- makes a deep copy of everything in x
|
||||
Dataset::Dataset(Dataset const &x) {
|
||||
n = d = nd = 0;
|
||||
data = sumDataSquared = NULL;
|
||||
*this = x;
|
||||
}
|
||||
|
||||
// operator= is the standard deep-copy assignment operator, which
|
||||
// returns a const reference to *this.
|
||||
Dataset const &Dataset::operator=(Dataset const &x) {
|
||||
if (this != &x) {
|
||||
|
||||
// reallocate sumDataSquared and data as necessary
|
||||
if (n != x.n) {
|
||||
delete [] sumDataSquared;
|
||||
sumDataSquared = x.sumDataSquared ? new double[x.n] : NULL;
|
||||
}
|
||||
|
||||
if (nd != x.nd) {
|
||||
delete [] data;
|
||||
data = x.data ? new double[x.nd] : NULL;
|
||||
}
|
||||
|
||||
// reflect the new sizes
|
||||
n = x.n;
|
||||
d = x.d;
|
||||
nd = x.nd;
|
||||
|
||||
// copy data as appropriate
|
||||
if (x.sumDataSquared) {
|
||||
memcpy(sumDataSquared, x.sumDataSquared, x.n * sizeof(double));
|
||||
}
|
||||
|
||||
if (x.data) {
|
||||
memcpy(data, x.data, x.nd * sizeof(double));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// return a reference for chaining assignments
|
||||
return *this;
|
||||
}
|
||||
|
||||
85
contrib/kmeans/kmeans_dataset.h
Normal file
85
contrib/kmeans/kmeans_dataset.h
Normal file
@@ -0,0 +1,85 @@
|
||||
#ifndef DATASET_H
|
||||
#define DATASET_H
|
||||
|
||||
/* Authors: Greg Hamerly and Jonathan Drake
|
||||
* Feedback: hamerly@cs.baylor.edu
|
||||
* See: http://cs.baylor.edu/~hamerly/software/kmeans.php
|
||||
* Copyright 2014
|
||||
*
|
||||
* A Dataset class represents a collection of multidimensional records, as is
|
||||
* typical in metric machine learning. Every record has the same number of
|
||||
* dimensions (values), and every value must be numeric. Undefined values are
|
||||
* not allowed.
|
||||
*
|
||||
* This particular implementation keeps all the data in a 1-dimensional array,
|
||||
* and also optionally keeps extra storage for the sum of the squared values of
|
||||
* each record. However, the Dataset class does NOT automatically populate or
|
||||
* update the sumDataSquared values.
|
||||
*/
|
||||
|
||||
#include <cstddef>
|
||||
#include <iostream>
|
||||
|
||||
class Dataset {
|
||||
public:
|
||||
// default constructor -- constructs a completely empty dataset with no
|
||||
// records
|
||||
Dataset() : n(0), d(0), nd(0), data(NULL), sumDataSquared(NULL) {}
|
||||
|
||||
// construct a dataset of a particular size, and determine whether to
|
||||
// keep the sumDataSquared
|
||||
Dataset(int aN, int aD, bool keepSDS = false) : n(aN), d(aD), nd(n * d),
|
||||
data(new double[nd]),
|
||||
sumDataSquared(keepSDS ? new double[n] : NULL) {}
|
||||
|
||||
// copy constructor -- makes a deep copy of everything in x
|
||||
Dataset(Dataset const &x);
|
||||
|
||||
// destroys the dataset safely
|
||||
~Dataset() {
|
||||
n = d = nd = 0;
|
||||
double *dp = data, *sdsp = sumDataSquared;
|
||||
data = sumDataSquared = NULL;
|
||||
delete [] dp;
|
||||
delete [] sdsp;
|
||||
}
|
||||
|
||||
// operator= is the standard deep-copy assignment operator, which
|
||||
// returns a const reference to *this.
|
||||
Dataset const &operator=(Dataset const &x);
|
||||
|
||||
// allows modification of the record ndx and dimension dim
|
||||
double &operator()(int ndx, int dim);
|
||||
|
||||
// allows const access to record ndx and dimension dim
|
||||
const double &operator()(int ndx, int dim) const;
|
||||
|
||||
// fill the entire dataset with value. Does NOT update sumDataSquared.
|
||||
void fill(double value);
|
||||
|
||||
// print the dataset to standard output (cout), using formatting to keep the
|
||||
// data in matrix format
|
||||
void print(std::ostream &out = std::cout) const;
|
||||
|
||||
// n represents the number of records
|
||||
// d represents the dimension
|
||||
// nd is a shortcut for the value n * d
|
||||
int n, d, nd;
|
||||
|
||||
// data is an array of length n*d that stores all of the records in
|
||||
// record-major (row-major) order. Thus data[0]...data[d-1] are the
|
||||
// values associated with the first record.
|
||||
double *data;
|
||||
|
||||
// sumDataSquared is an (optional) sum of squared values for every
|
||||
// record. Thus,
|
||||
// sumDataSquared[0] = data[0]^2 + data[1]^2 + ... + data[d-1]^2
|
||||
// sumDataSquared[1] = data[d]^2 + data[d+1]^2 + ... + data[2*d-1]^2
|
||||
// and so on. Note that this is the *intended* use of the sumDataSquared
|
||||
// field, but that the Dataset class does NOT automatically populate or
|
||||
// update the values in sumDataSquared.
|
||||
double *sumDataSquared;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
256
contrib/kmeans/kmeans_general_functions.cpp
Normal file
256
contrib/kmeans/kmeans_general_functions.cpp
Normal file
@@ -0,0 +1,256 @@
|
||||
/* Authors: Greg Hamerly and Jonathan Drake
|
||||
* Feedback: hamerly@cs.baylor.edu
|
||||
* See: http://cs.baylor.edu/~hamerly/software/kmeans.php
|
||||
* Copyright 2014
|
||||
*/
|
||||
|
||||
#include "kmeans_dataset.h"
|
||||
#include "kmeans.h"
|
||||
#include "kmeans_general_functions.h"
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
#include <numeric>
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
|
||||
void addVectors(double *a, double const *b, int d) {
|
||||
double const *end = a + d;
|
||||
while (a < end) {
|
||||
*(a++) += *(b++);
|
||||
}
|
||||
}
|
||||
|
||||
void subVectors(double *a, double const *b, int d) {
|
||||
double const *end = a + d;
|
||||
while (a < end) {
|
||||
*(a++) -= *(b++);
|
||||
}
|
||||
}
|
||||
|
||||
double distance2silent(double const *a, double const *b, int d) {
|
||||
double d2 = 0.0, diff;
|
||||
double const *end = a + d; // one past the last valid entry in a
|
||||
while (a < end) {
|
||||
diff = *(a++) - *(b++);
|
||||
d2 += diff * diff;
|
||||
}
|
||||
return d2;
|
||||
}
|
||||
|
||||
|
||||
void centerDataset(Dataset *x) {
|
||||
double *xCentroid = new double[x->d];
|
||||
|
||||
for (int d = 0; d < x->d; ++d) {
|
||||
xCentroid[d] = 0.0;
|
||||
}
|
||||
|
||||
for (int i = 0; i < x->n; ++i) {
|
||||
addVectors(xCentroid, x->data + i * x->d, x->d);
|
||||
}
|
||||
|
||||
// compute average (divide by n)
|
||||
for (int d = 0; d < x->d; ++d) {
|
||||
xCentroid[d] /= x->n;
|
||||
}
|
||||
|
||||
// re-center the dataset
|
||||
const double *xEnd = x->data + x->n * x->d;
|
||||
for (double *xp = x->data; xp != xEnd; xp += x->d) {
|
||||
subVectors(xp, xCentroid, x->d);
|
||||
}
|
||||
|
||||
delete [] xCentroid;
|
||||
}
|
||||
|
||||
Dataset *init_centers(Dataset const &x, unsigned short k) {
|
||||
int *chosen_pts = new int[k];
|
||||
Dataset *c = new Dataset(k, x.d);
|
||||
for (int i = 0; i < k; ++i) {
|
||||
bool acceptable = true;
|
||||
do {
|
||||
acceptable = true;
|
||||
chosen_pts[i] = rand() % x.n;
|
||||
for (int j = 0; j < i; ++j) {
|
||||
if (chosen_pts[i] == chosen_pts[j]) {
|
||||
acceptable = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} while (! acceptable);
|
||||
double *cdp = c->data + i * x.d;
|
||||
memcpy(cdp, x.data + chosen_pts[i] * x.d, sizeof(double) * x.d);
|
||||
if (c->sumDataSquared) {
|
||||
c->sumDataSquared[i] = std::inner_product(cdp, cdp + x.d, cdp, 0.0);
|
||||
}
|
||||
}
|
||||
|
||||
delete [] chosen_pts;
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
Dataset *init_centers_kmeanspp(Dataset const &x, unsigned short k) {
|
||||
int *chosen_pts = new int[k];
|
||||
std::pair<double, int> *dist2 = new std::pair<double, int>[x.n];
|
||||
double *distribution = new double[x.n];
|
||||
|
||||
// initialize dist2
|
||||
for (int i = 0; i < x.n; ++i) {
|
||||
dist2[i].first = std::numeric_limits<double>::max();
|
||||
dist2[i].second = i;
|
||||
}
|
||||
|
||||
// choose the first point randomly
|
||||
int ndx = 1;
|
||||
chosen_pts[ndx - 1] = rand() % x.n;
|
||||
|
||||
while (ndx < k) {
|
||||
double sum_distribution = 0.0;
|
||||
// look for the point that is furthest from any center
|
||||
for (int i = 0; i < x.n; ++i) {
|
||||
int example = dist2[i].second;
|
||||
double d2 = 0.0, diff;
|
||||
for (int j = 0; j < x.d; ++j) {
|
||||
diff = x(example,j) - x(chosen_pts[ndx - 1],j);
|
||||
d2 += diff * diff;
|
||||
}
|
||||
if (d2 < dist2[i].first) {
|
||||
dist2[i].first = d2;
|
||||
}
|
||||
|
||||
sum_distribution += dist2[i].first;
|
||||
}
|
||||
|
||||
// sort the examples by their distance from centers
|
||||
sort(dist2, dist2 + x.n);
|
||||
|
||||
// turn distribution into a CDF
|
||||
distribution[0] = dist2[0].first / sum_distribution;
|
||||
for (int i = 1; i < x.n; ++i) {
|
||||
distribution[i] = distribution[i - 1] + dist2[i].first / sum_distribution;
|
||||
}
|
||||
|
||||
// choose a random interval according to the new distribution
|
||||
double r = (double)rand() / (double)RAND_MAX;
|
||||
double *new_center_ptr = std::lower_bound(distribution, distribution + x.n, r);
|
||||
int distribution_ndx = (int)(new_center_ptr - distribution);
|
||||
chosen_pts[ndx] = dist2[distribution_ndx].second;
|
||||
/*
|
||||
cout << "chose " << distribution_ndx << " which is actually "
|
||||
<< chosen_pts[ndx] << " with distance "
|
||||
<< dist2[distribution_ndx].first << std::endl;
|
||||
*/
|
||||
|
||||
++ndx;
|
||||
}
|
||||
|
||||
Dataset *c = new Dataset(k, x.d);
|
||||
|
||||
for (int i = 0; i < k; ++i) {
|
||||
double *cdp = c->data + i * x.d;
|
||||
memcpy(cdp, x.data + chosen_pts[i] * x.d, sizeof(double) * x.d);
|
||||
if (c->sumDataSquared) {
|
||||
c->sumDataSquared[i] = std::inner_product(cdp, cdp + x.d, cdp, 0.0);
|
||||
}
|
||||
}
|
||||
|
||||
delete [] chosen_pts;
|
||||
delete [] dist2;
|
||||
delete [] distribution;
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
Dataset *init_centers_kmeanspp_v2(Dataset const &x, unsigned short k) {
|
||||
int *chosen_pts = new int[k];
|
||||
std::pair<double, int> *dist2 = new std::pair<double, int>[x.n];
|
||||
|
||||
// initialize dist2
|
||||
for (int i = 0; i < x.n; ++i) {
|
||||
dist2[i].first = std::numeric_limits<double>::max();
|
||||
dist2[i].second = i;
|
||||
}
|
||||
|
||||
// choose the first point randomly
|
||||
int ndx = 1;
|
||||
chosen_pts[ndx - 1] = rand() % x.n;
|
||||
|
||||
while (ndx < k) {
|
||||
double sum_distribution = 0.0;
|
||||
// look for the point that is furthest from any center
|
||||
double max_dist = 0.0;
|
||||
for (int i = 0; i < x.n; ++i) {
|
||||
int example = dist2[i].second;
|
||||
double d2 = 0.0, diff;
|
||||
for (int j = 0; j < x.d; ++j) {
|
||||
diff = x(example,j) - x(chosen_pts[ndx - 1],j);
|
||||
d2 += diff * diff;
|
||||
}
|
||||
if (d2 < dist2[i].first) {
|
||||
dist2[i].first = d2;
|
||||
}
|
||||
|
||||
if (dist2[i].first > max_dist) {
|
||||
max_dist = dist2[i].first;
|
||||
}
|
||||
|
||||
sum_distribution += dist2[i].first;
|
||||
}
|
||||
|
||||
bool unique = true;
|
||||
|
||||
do {
|
||||
// choose a random interval according to the new distribution
|
||||
double r = sum_distribution * (double)rand() / (double)RAND_MAX;
|
||||
double sum_cdf = dist2[0].first;
|
||||
int cdf_ndx = 0;
|
||||
while (sum_cdf < r) {
|
||||
sum_cdf += dist2[++cdf_ndx].first;
|
||||
}
|
||||
chosen_pts[ndx] = cdf_ndx;
|
||||
|
||||
for (int i = 0; i < ndx; ++i) {
|
||||
unique = unique && (chosen_pts[ndx] != chosen_pts[i]);
|
||||
}
|
||||
} while (! unique);
|
||||
|
||||
++ndx;
|
||||
}
|
||||
|
||||
Dataset *c = new Dataset(k, x.d);
|
||||
for (int i = 0; i < c->n; ++i) {
|
||||
double *cdp = c->data + i * x.d;
|
||||
memcpy(cdp, x.data + chosen_pts[i] * x.d, sizeof(double) * x.d);
|
||||
if (c->sumDataSquared) {
|
||||
c->sumDataSquared[i] = std::inner_product(cdp, cdp + x.d, cdp, 0.0);
|
||||
}
|
||||
}
|
||||
|
||||
delete [] chosen_pts;
|
||||
delete [] dist2;
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
void kmeans_assign(Dataset const &x, Dataset const &c, unsigned short *assignment) {
|
||||
for (int i = 0; i < x.n; ++i) {
|
||||
double shortestDist2 = std::numeric_limits<double>::max();
|
||||
int closest = 0;
|
||||
for (int j = 0; j < c.n; ++j) {
|
||||
double d2 = 0.0, *a = x.data + i * x.d, *b = c.data + j * x.d;
|
||||
for (; a != x.data + (i + 1) * x.d; ++a, ++b) {
|
||||
d2 += (*a - *b) * (*a - *b);
|
||||
}
|
||||
if (d2 < shortestDist2) {
|
||||
shortestDist2 = d2;
|
||||
closest = j;
|
||||
}
|
||||
}
|
||||
assignment[i] = closest;
|
||||
}
|
||||
}
|
||||
83
contrib/kmeans/kmeans_general_functions.h
Normal file
83
contrib/kmeans/kmeans_general_functions.h
Normal file
@@ -0,0 +1,83 @@
|
||||
#ifndef GENERAL_KMEANS_FUNCTIONS_H
|
||||
#define GENERAL_KMEANS_FUNCTIONS_H
|
||||
|
||||
/* Authors: Greg Hamerly and Jonathan Drake
|
||||
* Feedback: hamerly@cs.baylor.edu
|
||||
* See: http://cs.baylor.edu/~hamerly/software/kmeans.php
|
||||
* Copyright 2014
|
||||
*
|
||||
* Generally useful functions.
|
||||
*/
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include "kmeans_dataset.h"
|
||||
|
||||
/* Add together two vectors, and put the result in the first argument.
|
||||
* Calculates a = a + b
|
||||
*
|
||||
* Parameters:
|
||||
* a -- vector to add, and the result of the operation
|
||||
* b -- vector to add to a
|
||||
* d -- the dimension
|
||||
* Return value: none
|
||||
*/
|
||||
void addVectors(double *a, double const *b, int d);
|
||||
|
||||
/* Subtract two vectors, and put the result in the first argument. Calculates
|
||||
* a = a - b
|
||||
*
|
||||
* Parameters:
|
||||
* a -- vector to subtract from, and the result of the operation
|
||||
* b -- vector to subtract
|
||||
* d -- the dimension
|
||||
* Return value: none
|
||||
*/
|
||||
void subVectors(double *a, double const *b, int d);
|
||||
|
||||
/* Initialize the centers randomly. Choose random records from x as the initial
|
||||
* values for the centers. Assumes that c uses the sumDataSquared field.
|
||||
*
|
||||
* Parameters:
|
||||
* x -- records that are being clustered (n * d)
|
||||
* c -- centers to be initialized. Should be pre-allocated with the number of
|
||||
* centers desired, and dimension.
|
||||
* Return value: none
|
||||
*/
|
||||
Dataset *init_centers(Dataset const &x, unsigned short k);
|
||||
|
||||
/* Initialize the centers randomly using K-means++.
|
||||
*
|
||||
* Parameters:
|
||||
* x -- records that are being clustered (n * d)
|
||||
* c -- centers to be initialized. Should be pre-allocated with the number of
|
||||
* centers desired, and dimension.
|
||||
* Return value: none
|
||||
*/
|
||||
Dataset *init_centers_kmeanspp(Dataset const &x, unsigned short k);
|
||||
Dataset *init_centers_kmeanspp_v2(Dataset const &x, unsigned short k);
|
||||
|
||||
/* Print an array (templated). Convenience function.
|
||||
*
|
||||
* Parameters:
|
||||
* arr -- the array to print
|
||||
* length -- the length of the array
|
||||
* separator -- the string to put between each pair of printed elements
|
||||
* Return value: none
|
||||
*/
|
||||
template <class T>
|
||||
void printArray(T const *arr, int length, std::string separator) {
|
||||
for (int i = 0; i < length; ++i) {
|
||||
if (i > 0) {
|
||||
std::cout << separator;
|
||||
}
|
||||
std::cout << arr[i];
|
||||
}
|
||||
}
|
||||
|
||||
void centerDataset(Dataset *x);
|
||||
|
||||
void kmeans_assign(Dataset const &x, Dataset const &c, unsigned short *assignment);
|
||||
|
||||
#endif
|
||||
106
contrib/kmeans/original_space_kmeans.cpp
Normal file
106
contrib/kmeans/original_space_kmeans.cpp
Normal file
@@ -0,0 +1,106 @@
|
||||
/* Authors: Greg Hamerly and Jonathan Drake
|
||||
* Feedback: hamerly@cs.baylor.edu
|
||||
* See: http://cs.baylor.edu/~hamerly/software/kmeans.php
|
||||
* Copyright 2014
|
||||
*/
|
||||
|
||||
#include "original_space_kmeans.h"
|
||||
#include "kmeans_general_functions.h"
|
||||
#include <cmath>
|
||||
#include <cassert>
|
||||
#include <numeric>
|
||||
|
||||
OriginalSpaceKmeans::OriginalSpaceKmeans() : centers(NULL), sumNewCenters(NULL) { }
|
||||
|
||||
void OriginalSpaceKmeans::free() {
|
||||
for (int t = 0; t < numThreads; ++t) {
|
||||
delete sumNewCenters[t];
|
||||
}
|
||||
Kmeans::free();
|
||||
delete centers;
|
||||
delete [] sumNewCenters;
|
||||
centers = NULL;
|
||||
sumNewCenters = NULL;
|
||||
}
|
||||
|
||||
/* This method moves the newCenters to their new locations, based on the
|
||||
* sufficient statistics in sumNewCenters. It also computes the centerMovement
|
||||
* and the center that moved the furthest.
|
||||
*
|
||||
* Parameters: none
|
||||
*
|
||||
* Return value: index of the furthest-moving centers
|
||||
*/
|
||||
int OriginalSpaceKmeans::move_centers() {
|
||||
int furthestMovingCenter = 0;
|
||||
for (int j = 0; j < k; ++j) {
|
||||
centerMovement[j] = 0.0;
|
||||
int totalClusterSize = 0;
|
||||
for (int t = 0; t < numThreads; ++t) {
|
||||
totalClusterSize += clusterSize[t][j];
|
||||
}
|
||||
if (totalClusterSize > 0) {
|
||||
for (int dim = 0; dim < d; ++dim) {
|
||||
double z = 0.0;
|
||||
for (int t = 0; t < numThreads; ++t) {
|
||||
z += (*sumNewCenters[t])(j,dim);
|
||||
}
|
||||
z /= totalClusterSize;
|
||||
centerMovement[j] += (z - (*centers)(j, dim)) * (z - (*centers)(j, dim));
|
||||
(*centers)(j, dim) = z;
|
||||
}
|
||||
}
|
||||
centerMovement[j] = sqrt(centerMovement[j]);
|
||||
|
||||
if (centerMovement[furthestMovingCenter] < centerMovement[j]) {
|
||||
furthestMovingCenter = j;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef COUNT_DISTANCES
|
||||
numDistances += k;
|
||||
#endif
|
||||
|
||||
return furthestMovingCenter;
|
||||
}
|
||||
|
||||
void OriginalSpaceKmeans::initialize(Dataset const *aX, unsigned short aK, unsigned short *initialAssignment, int aNumThreads) {
|
||||
Kmeans::initialize(aX, aK, initialAssignment, aNumThreads);
|
||||
|
||||
centers = new Dataset(k, d);
|
||||
sumNewCenters = new Dataset *[numThreads];
|
||||
centers->fill(0.0);
|
||||
|
||||
for (int t = 0; t < numThreads; ++t) {
|
||||
sumNewCenters[t] = new Dataset(k, d, false);
|
||||
sumNewCenters[t]->fill(0.0);
|
||||
for (int i = start(t); i < end(t); ++i) {
|
||||
addVectors(sumNewCenters[t]->data + assignment[i] * d, x->data + i * d, d);
|
||||
}
|
||||
}
|
||||
|
||||
// put the centers at their initial locations, based on clusterSize and
|
||||
// sumNewCenters
|
||||
move_centers();
|
||||
}
|
||||
|
||||
void OriginalSpaceKmeans::changeAssignment(int xIndex, int closestCluster, int threadId) {
|
||||
unsigned short oldAssignment = assignment[xIndex];
|
||||
Kmeans::changeAssignment(xIndex, closestCluster, threadId);
|
||||
double *xp = x->data + xIndex * d;
|
||||
subVectors(sumNewCenters[threadId]->data + oldAssignment * d, xp, d);
|
||||
addVectors(sumNewCenters[threadId]->data + closestCluster * d, xp, d);
|
||||
}
|
||||
|
||||
double OriginalSpaceKmeans::pointPointInnerProduct(int x1, int x2) const {
|
||||
return std::inner_product(x->data + x1 * d, x->data + (x1 + 1) * d, x->data + x2 * d, 0.0);
|
||||
}
|
||||
|
||||
double OriginalSpaceKmeans::pointCenterInnerProduct(int xndx, unsigned short cndx) const {
|
||||
return std::inner_product(x->data + xndx * d, x->data + (xndx + 1) * d, centers->data + cndx * d, 0.0);
|
||||
}
|
||||
|
||||
double OriginalSpaceKmeans::centerCenterInnerProduct(unsigned short c1, unsigned short c2) const {
|
||||
return std::inner_product(centers->data + c1 * d, centers->data + (c1 + 1) * d, centers->data + c2 * d, 0.0);
|
||||
}
|
||||
|
||||
54
contrib/kmeans/original_space_kmeans.h
Normal file
54
contrib/kmeans/original_space_kmeans.h
Normal file
@@ -0,0 +1,54 @@
|
||||
#ifndef ORIGINAL_SPACE_KMEANS_H
|
||||
#define ORIGINAL_SPACE_KMEANS_H
|
||||
|
||||
/* Authors: Greg Hamerly and Jonathan Drake
|
||||
* Feedback: hamerly@cs.baylor.edu
|
||||
* See: http://cs.baylor.edu/~hamerly/software/kmeans.php
|
||||
* Copyright 2014
|
||||
*
|
||||
* OriginalSpaceKmeans is a base class for other algorithms that operate in the
|
||||
* same space as the data being clustered (as opposed to kernelized k-means
|
||||
* algorithms, which operate in kernel space).
|
||||
*/
|
||||
|
||||
#include "kmeans.h"
|
||||
|
||||
/* Cluster with the cluster centers living in the original space (with the
|
||||
* data). This is as opposed to a kernelized version of k-means, where the
|
||||
* center points might not be explicitly represented. This is also an abstract
|
||||
* class.
|
||||
*/
|
||||
class OriginalSpaceKmeans : public Kmeans {
|
||||
public:
|
||||
OriginalSpaceKmeans();
|
||||
virtual ~OriginalSpaceKmeans() { free(); }
|
||||
virtual void free();
|
||||
virtual void initialize(Dataset const *aX, unsigned short aK, unsigned short *initialAssignment, int aNumThreads);
|
||||
|
||||
virtual double pointPointInnerProduct(int x1ndx, int x2ndx) const;
|
||||
virtual double pointCenterInnerProduct(int xndx, unsigned short cndx) const;
|
||||
virtual double centerCenterInnerProduct(unsigned short c1ndx, unsigned short c2ndx) const;
|
||||
|
||||
virtual Dataset const *getCenters() const { return centers; }
|
||||
|
||||
protected:
|
||||
// Move the centers to the average of their current assigned points,
|
||||
// compute the distance moved by each center, and return the index of
|
||||
// the furthest-moving center.
|
||||
int move_centers();
|
||||
|
||||
virtual void changeAssignment(int xIndex, int closestCluster, int threadId);
|
||||
|
||||
// The set of centers we are operating on.
|
||||
Dataset *centers;
|
||||
|
||||
// sumNewCenters and centerCount provide sufficient statistics to
|
||||
// quickly calculate the changing locations of the centers. Whenever a
|
||||
// point changes cluster membership, we subtract (add) it from (to) the
|
||||
// row in sumNewCenters associated with its old (new) cluster. We also
|
||||
// decrement (increment) centerCount for the old (new) cluster.
|
||||
Dataset **sumNewCenters;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
1001
contrib/kmeans/smallDataset.txt
Normal file
1001
contrib/kmeans/smallDataset.txt
Normal file
File diff suppressed because it is too large
Load Diff
79
contrib/kmeans/triangle_inequality_base_kmeans.cpp
Normal file
79
contrib/kmeans/triangle_inequality_base_kmeans.cpp
Normal file
@@ -0,0 +1,79 @@
|
||||
/* Authors: Greg Hamerly and Jonathan Drake
|
||||
* Feedback: hamerly@cs.baylor.edu
|
||||
* See: http://cs.baylor.edu/~hamerly/software/kmeans.php
|
||||
* Copyright 2014
|
||||
*/
|
||||
|
||||
#include "triangle_inequality_base_kmeans.h"
|
||||
#include "kmeans_general_functions.h"
|
||||
#include <cassert>
|
||||
#include <limits>
|
||||
#include <cmath>
|
||||
|
||||
void TriangleInequalityBaseKmeans::free() {
|
||||
OriginalSpaceKmeans::free();
|
||||
delete [] s;
|
||||
delete [] upper;
|
||||
delete [] lower;
|
||||
s = NULL;
|
||||
upper = NULL;
|
||||
lower = NULL;
|
||||
}
|
||||
|
||||
/* This function computes the inter-center distances, keeping only the closest
|
||||
* distances, and updates "s". After this, s[j] will contain the distance
|
||||
* between center j and its closest other center, divided by two. The division
|
||||
* here saves repeated work later, since we always will need the distance / 2.
|
||||
*
|
||||
* Parameters: none
|
||||
*
|
||||
* Return value: none
|
||||
*/
|
||||
// TODO: parallelize this
|
||||
void TriangleInequalityBaseKmeans::update_s(int threadId) {
|
||||
// initialize
|
||||
for (int c1 = 0; c1 < k; ++c1) {
|
||||
if (c1 % numThreads == threadId) {
|
||||
s[c1] = std::numeric_limits<double>::max();
|
||||
}
|
||||
}
|
||||
// compute inter-center squared distances between all pairs
|
||||
for (int c1 = 0; c1 < k; ++c1) {
|
||||
if (c1 % numThreads == threadId) {
|
||||
for (int c2 = 0; c2 < k; ++c2) {
|
||||
if (c2 == c1) {
|
||||
continue;
|
||||
}
|
||||
double d2 = centerCenterDist2(c1, c2);
|
||||
if (d2 < s[c1]) { s[c1] = d2; }
|
||||
}
|
||||
// take the root and divide by two
|
||||
s[c1] = sqrt(s[c1]) / 2.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* This function initializes the upper/lower bounds, assignment, centerCounts,
|
||||
* and sumNewCenters. It sets the bounds to invalid values which will force the
|
||||
* first iteration of k-means to set them correctly. NB: subclasses should set
|
||||
* numLowerBounds appropriately before entering this function.
|
||||
*
|
||||
* Parameters: none
|
||||
*
|
||||
* Return value: none
|
||||
*/
|
||||
void TriangleInequalityBaseKmeans::initialize(Dataset const *aX, unsigned short aK, unsigned short *initialAssignment, int aNumThreads) {
|
||||
OriginalSpaceKmeans::initialize(aX, aK, initialAssignment, aNumThreads);
|
||||
|
||||
s = new double[k];
|
||||
upper = new double[n];
|
||||
lower = new double[n * numLowerBounds];
|
||||
|
||||
// start with invalid bounds and assignments which will force the first
|
||||
// iteration of k-means to do all its standard work
|
||||
std::fill(s, s + k, 0.0);
|
||||
std::fill(upper, upper + n, std::numeric_limits<double>::max());
|
||||
std::fill(lower, lower + n * numLowerBounds, 0.0);
|
||||
}
|
||||
|
||||
43
contrib/kmeans/triangle_inequality_base_kmeans.h
Normal file
43
contrib/kmeans/triangle_inequality_base_kmeans.h
Normal file
@@ -0,0 +1,43 @@
|
||||
#ifndef TRIANGLE_INEQUALITY_BASE_KMEANS_H
|
||||
#define TRIANGLE_INEQUALITY_BASE_KMEANS_H
|
||||
|
||||
/* Authors: Greg Hamerly and Jonathan Drake
|
||||
* Feedback: hamerly@cs.baylor.edu
|
||||
* See: http://cs.baylor.edu/~hamerly/software/kmeans.php
|
||||
* Copyright 2014
|
||||
*
|
||||
* This class is an abstract base class for several other algorithms that use
|
||||
* upper & lower bounds to avoid distance calculations in k-means.
|
||||
*/
|
||||
|
||||
#include "original_space_kmeans.h"
|
||||
|
||||
class TriangleInequalityBaseKmeans : public OriginalSpaceKmeans {
|
||||
public:
|
||||
TriangleInequalityBaseKmeans() : numLowerBounds(0), s(NULL), upper(NULL), lower(NULL) {}
|
||||
virtual ~TriangleInequalityBaseKmeans() { free(); }
|
||||
|
||||
virtual void initialize(Dataset const *aX, unsigned short aK, unsigned short *initialAssignment, int aNumThreads);
|
||||
virtual void free();
|
||||
|
||||
protected:
|
||||
void update_s(int threadId);
|
||||
|
||||
// The number of lower bounds being used by this algorithm.
|
||||
int numLowerBounds;
|
||||
|
||||
// Half the distance between each center and its closest other center.
|
||||
double *s;
|
||||
|
||||
// One upper bound for each point on the distance between that point and
|
||||
// its assigned (closest) center.
|
||||
double *upper;
|
||||
|
||||
// Lower bound(s) for each point on the distance between that point and
|
||||
// the centers being tracked for lower bounds, which may be 1 to k.
|
||||
// Actual size is n * numLowerBounds.
|
||||
double *lower;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
75
contrib/levmar/Axb.c
Normal file
75
contrib/levmar/Axb.c
Normal file
@@ -0,0 +1,75 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Solution of linear systems involved in the Levenberg - Marquardt
|
||||
// minimization algorithm
|
||||
// Copyright (C) 2004 Manolis Lourakis (lourakis at ics forth gr)
|
||||
// Institute of Computer Science, Foundation for Research & Technology - Hellas
|
||||
// Heraklion, Crete, Greece.
|
||||
//
|
||||
// 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 2 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/********************************************************************************
|
||||
* LAPACK-based implementations for various linear system solvers. The same core
|
||||
* code is used with appropriate #defines to derive single and double precision
|
||||
* solver versions, see also Axb_core.c
|
||||
********************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "levmar.h"
|
||||
#include "misc.h"
|
||||
|
||||
#if !defined(LM_DBL_PREC) && !defined(LM_SNGL_PREC)
|
||||
#error At least one of LM_DBL_PREC, LM_SNGL_PREC should be defined!
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef LM_DBL_PREC
|
||||
/* double precision definitions */
|
||||
#define LM_REAL double
|
||||
#define LM_PREFIX d
|
||||
#define LM_CNST(x) (x)
|
||||
#ifndef HAVE_LAPACK
|
||||
#include <float.h>
|
||||
#define LM_REAL_EPSILON DBL_EPSILON
|
||||
#endif
|
||||
|
||||
#include "Axb_core.c"
|
||||
|
||||
#undef LM_REAL
|
||||
#undef LM_PREFIX
|
||||
#undef LM_CNST
|
||||
#undef LM_REAL_EPSILON
|
||||
#endif /* LM_DBL_PREC */
|
||||
|
||||
#ifdef LM_SNGL_PREC
|
||||
/* single precision (float) definitions */
|
||||
#define LM_REAL float
|
||||
#define LM_PREFIX s
|
||||
#define __SUBCNST(x) x##F
|
||||
#define LM_CNST(x) __SUBCNST(x) // force substitution
|
||||
#ifndef HAVE_LAPACK
|
||||
#define LM_REAL_EPSILON FLT_EPSILON
|
||||
#endif
|
||||
|
||||
#include "Axb_core.c"
|
||||
|
||||
#undef LM_REAL
|
||||
#undef LM_PREFIX
|
||||
#undef __SUBCNST
|
||||
#undef LM_CNST
|
||||
#undef LM_REAL_EPSILON
|
||||
#endif /* LM_SNGL_PREC */
|
||||
1282
contrib/levmar/Axb_core.c
Normal file
1282
contrib/levmar/Axb_core.c
Normal file
File diff suppressed because it is too large
Load Diff
49
contrib/levmar/compiler.h
Normal file
49
contrib/levmar/compiler.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Levenberg - Marquardt non-linear minimization algorithm
|
||||
// Copyright (C) 2004 Manolis Lourakis (lourakis at ics forth gr)
|
||||
// Institute of Computer Science, Foundation for Research & Technology - Hellas
|
||||
// Heraklion, Crete, Greece.
|
||||
//
|
||||
// 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 2 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _COMPILER_H_
|
||||
#define _COMPILER_H_
|
||||
|
||||
/* note: intel's icc defines both __ICC & __INTEL_COMPILER.
|
||||
* Also, some compilers other than gcc define __GNUC__,
|
||||
* therefore gcc should be checked last
|
||||
*/
|
||||
#ifdef _MSC_VER
|
||||
#define inline __inline // MSVC
|
||||
#elif !defined(__ICC) && !defined(__INTEL_COMPILER) && !defined(__GNUC__)
|
||||
#define inline // other than MSVC, ICC, GCC: define empty
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define LM_FINITE _finite // MSVC
|
||||
#elif defined(__ICC) || defined(__INTEL_COMPILER) || defined(__GNUC__)
|
||||
#define LM_FINITE finite // ICC, GCC
|
||||
#else
|
||||
#define LM_FINITE finite // other than MSVC, ICC, GCC, let's hope this will work
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define LM_ISINF(x) (!_finite(x) && !_isnan(x)) // MSVC
|
||||
#elif defined(__ICC) || defined(__INTEL_COMPILER) || defined(__GNUC__)
|
||||
#define LM_ISINF(x) isinf(x) // ICC, GCC
|
||||
#else
|
||||
#define LM_ISINF(x) isinf(x) // other than MSVC, ICC, GCC, let's hope this will work
|
||||
#endif
|
||||
|
||||
#endif /* _COMPILER_H_ */
|
||||
398
contrib/levmar/levmar.h
Normal file
398
contrib/levmar/levmar.h
Normal file
@@ -0,0 +1,398 @@
|
||||
/*
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Prototypes and definitions for the Levenberg - Marquardt minimization algorithm
|
||||
// Copyright (C) 2004 Manolis Lourakis (lourakis at ics forth gr)
|
||||
// Institute of Computer Science, Foundation for Research & Technology - Hellas
|
||||
// Heraklion, Crete, Greece.
|
||||
//
|
||||
// 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 2 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.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
*/
|
||||
|
||||
#ifndef _LEVMAR_H_
|
||||
#define _LEVMAR_H_
|
||||
|
||||
/************************************* Start of configuration options *************************************/
|
||||
/* Note that when compiling with CMake, this configuration section is automatically generated
|
||||
* based on the user's input, see levmar.h.in
|
||||
*/
|
||||
|
||||
/* specifies whether to use LAPACK or not. Using LAPACK is strongly recommended */
|
||||
//#define HAVE_LAPACK
|
||||
|
||||
/* specifies whether the PLASMA parallel library for multicore CPUs is available */
|
||||
/* #undef HAVE_PLASMA */
|
||||
|
||||
/* to avoid the overhead of repeated mallocs(), routines in Axb.c can be instructed to
|
||||
* retain working memory between calls. Such a choice, however, renders these routines
|
||||
* non-reentrant and is not safe in a shared memory multiprocessing environment.
|
||||
* Bellow, an attempt is made to issue a warning if this option is turned on and OpenMP
|
||||
* is being used (note that this will work only if omp.h is included before levmar.h)
|
||||
*/
|
||||
#define LINSOLVERS_RETAIN_MEMORY
|
||||
#if (defined(_OPENMP))
|
||||
# ifdef LINSOLVERS_RETAIN_MEMORY
|
||||
# ifdef _MSC_VER
|
||||
# pragma message("LINSOLVERS_RETAIN_MEMORY is not safe in a multithreaded environment and should be turned off!")
|
||||
# else
|
||||
# warning LINSOLVERS_RETAIN_MEMORY is not safe in a multithreaded environment and should be turned off!
|
||||
# endif /* _MSC_VER */
|
||||
# endif /* LINSOLVERS_RETAIN_MEMORY */
|
||||
#endif /* _OPENMP */
|
||||
|
||||
/* specifies whether double precision routines will be compiled or not */
|
||||
#define LM_DBL_PREC
|
||||
/* specifies whether single precision routines will be compiled or not */
|
||||
#define LM_SNGL_PREC
|
||||
|
||||
/****************** End of configuration options, no changes necessary beyond this point ******************/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* work arrays size for ?levmar_der and ?levmar_dif functions.
|
||||
* should be multiplied by sizeof(double) or sizeof(float) to be converted to bytes
|
||||
*/
|
||||
#define LM_DER_WORKSZ(npar, nmeas) (2*(nmeas) + 4*(npar) + (nmeas)*(npar) + (npar)*(npar))
|
||||
#define LM_DIF_WORKSZ(npar, nmeas) (4*(nmeas) + 4*(npar) + (nmeas)*(npar) + (npar)*(npar))
|
||||
|
||||
/* work arrays size for ?levmar_bc_der and ?levmar_bc_dif functions.
|
||||
* should be multiplied by sizeof(double) or sizeof(float) to be converted to bytes
|
||||
*/
|
||||
#define LM_BC_DER_WORKSZ(npar, nmeas) (2*(nmeas) + 4*(npar) + (nmeas)*(npar) + (npar)*(npar))
|
||||
#define LM_BC_DIF_WORKSZ(npar, nmeas) LM_BC_DER_WORKSZ((npar), (nmeas)) /* LEVMAR_BC_DIF currently implemented using LEVMAR_BC_DER()! */
|
||||
|
||||
/* work arrays size for ?levmar_lec_der and ?levmar_lec_dif functions.
|
||||
* should be multiplied by sizeof(double) or sizeof(float) to be converted to bytes
|
||||
*/
|
||||
#define LM_LEC_DER_WORKSZ(npar, nmeas, nconstr) LM_DER_WORKSZ((npar)-(nconstr), (nmeas))
|
||||
#define LM_LEC_DIF_WORKSZ(npar, nmeas, nconstr) LM_DIF_WORKSZ((npar)-(nconstr), (nmeas))
|
||||
|
||||
/* work arrays size for ?levmar_blec_der and ?levmar_blec_dif functions.
|
||||
* should be multiplied by sizeof(double) or sizeof(float) to be converted to bytes
|
||||
*/
|
||||
#define LM_BLEC_DER_WORKSZ(npar, nmeas, nconstr) LM_LEC_DER_WORKSZ((npar), (nmeas)+(npar), (nconstr))
|
||||
#define LM_BLEC_DIF_WORKSZ(npar, nmeas, nconstr) LM_LEC_DIF_WORKSZ((npar), (nmeas)+(npar), (nconstr))
|
||||
|
||||
/* work arrays size for ?levmar_bleic_der and ?levmar_bleic_dif functions.
|
||||
* should be multiplied by sizeof(double) or sizeof(float) to be converted to bytes
|
||||
*/
|
||||
#define LM_BLEIC_DER_WORKSZ(npar, nmeas, nconstr1, nconstr2) LM_BLEC_DER_WORKSZ((npar)+(nconstr2), (nmeas)+(nconstr2), (nconstr1)+(nconstr2))
|
||||
#define LM_BLEIC_DIF_WORKSZ(npar, nmeas, nconstr1, nconstr2) LM_BLEC_DIF_WORKSZ((npar)+(nconstr2), (nmeas)+(nconstr2), (nconstr1)+(nconstr2))
|
||||
|
||||
#define LM_OPTS_SZ 5 /* max(4, 5) */
|
||||
#define LM_INFO_SZ 10
|
||||
#define LM_ERROR -1
|
||||
#define LM_INIT_MU 1E-03
|
||||
#define LM_STOP_THRESH 1E-17
|
||||
#define LM_DIFF_DELTA 1E-06
|
||||
#define LM_VERSION "2.6 (November 2011)"
|
||||
|
||||
#ifdef LM_DBL_PREC
|
||||
/* double precision LM, with & without Jacobian */
|
||||
/* unconstrained minimization */
|
||||
extern int dlevmar_der(
|
||||
void (*func)(double *p, double *hx, int m, int n, void *adata),
|
||||
void (*jacf)(double *p, double *j, int m, int n, void *adata),
|
||||
double *p, double *x, int m, int n, int itmax, double *opts,
|
||||
double *info, double *work, double *covar, void *adata);
|
||||
|
||||
extern int dlevmar_dif(
|
||||
void (*func)(double *p, double *hx, int m, int n, void *adata),
|
||||
double *p, double *x, int m, int n, int itmax, double *opts,
|
||||
double *info, double *work, double *covar, void *adata);
|
||||
|
||||
/* box-constrained minimization */
|
||||
extern int dlevmar_bc_der(
|
||||
void (*func)(double *p, double *hx, int m, int n, void *adata),
|
||||
void (*jacf)(double *p, double *j, int m, int n, void *adata),
|
||||
double *p, double *x, int m, int n, double *lb, double *ub, double *dscl,
|
||||
int itmax, double *opts, double *info, double *work, double *covar, void *adata);
|
||||
|
||||
extern int dlevmar_bc_dif(
|
||||
void (*func)(double *p, double *hx, int m, int n, void *adata),
|
||||
double *p, double *x, int m, int n, double *lb, double *ub, double *dscl,
|
||||
int itmax, double *opts, double *info, double *work, double *covar, void *adata);
|
||||
|
||||
#ifdef HAVE_LAPACK
|
||||
/* linear equation constrained minimization */
|
||||
extern int dlevmar_lec_der(
|
||||
void (*func)(double *p, double *hx, int m, int n, void *adata),
|
||||
void (*jacf)(double *p, double *j, int m, int n, void *adata),
|
||||
double *p, double *x, int m, int n, double *A, double *b, int k,
|
||||
int itmax, double *opts, double *info, double *work, double *covar, void *adata);
|
||||
|
||||
extern int dlevmar_lec_dif(
|
||||
void (*func)(double *p, double *hx, int m, int n, void *adata),
|
||||
double *p, double *x, int m, int n, double *A, double *b, int k,
|
||||
int itmax, double *opts, double *info, double *work, double *covar, void *adata);
|
||||
|
||||
/* box & linear equation constrained minimization */
|
||||
extern int dlevmar_blec_der(
|
||||
void (*func)(double *p, double *hx, int m, int n, void *adata),
|
||||
void (*jacf)(double *p, double *j, int m, int n, void *adata),
|
||||
double *p, double *x, int m, int n, double *lb, double *ub, double *A, double *b, int k, double *wghts,
|
||||
int itmax, double *opts, double *info, double *work, double *covar, void *adata);
|
||||
|
||||
extern int dlevmar_blec_dif(
|
||||
void (*func)(double *p, double *hx, int m, int n, void *adata),
|
||||
double *p, double *x, int m, int n, double *lb, double *ub, double *A, double *b, int k, double *wghts,
|
||||
int itmax, double *opts, double *info, double *work, double *covar, void *adata);
|
||||
|
||||
/* box, linear equations & inequalities constrained minimization */
|
||||
extern int dlevmar_bleic_der(
|
||||
void (*func)(double *p, double *hx, int m, int n, void *adata),
|
||||
void (*jacf)(double *p, double *j, int m, int n, void *adata),
|
||||
double *p, double *x, int m, int n, double *lb, double *ub,
|
||||
double *A, double *b, int k1, double *C, double *d, int k2,
|
||||
int itmax, double *opts, double *info, double *work, double *covar, void *adata);
|
||||
|
||||
extern int dlevmar_bleic_dif(
|
||||
void (*func)(double *p, double *hx, int m, int n, void *adata),
|
||||
double *p, double *x, int m, int n, double *lb, double *ub,
|
||||
double *A, double *b, int k1, double *C, double *d, int k2,
|
||||
int itmax, double *opts, double *info, double *work, double *covar, void *adata);
|
||||
|
||||
/* box & linear inequality constraints */
|
||||
extern int dlevmar_blic_der(
|
||||
void (*func)(double *p, double *hx, int m, int n, void *adata),
|
||||
void (*jacf)(double *p, double *j, int m, int n, void *adata),
|
||||
double *p, double *x, int m, int n, double *lb, double *ub, double *C, double *d, int k2,
|
||||
int itmax, double opts[4], double info[LM_INFO_SZ], double *work, double *covar, void *adata);
|
||||
|
||||
extern int dlevmar_blic_dif(
|
||||
void (*func)(double *p, double *hx, int m, int n, void *adata),
|
||||
double *p, double *x, int m, int n, double *lb, double *ub, double *C, double *d, int k2,
|
||||
int itmax, double opts[5], double info[LM_INFO_SZ], double *work, double *covar, void *adata);
|
||||
|
||||
/* linear equation & inequality constraints */
|
||||
extern int dlevmar_leic_der(
|
||||
void (*func)(double *p, double *hx, int m, int n, void *adata),
|
||||
void (*jacf)(double *p, double *j, int m, int n, void *adata),
|
||||
double *p, double *x, int m, int n, double *A, double *b, int k1, double *C, double *d, int k2,
|
||||
int itmax, double opts[4], double info[LM_INFO_SZ], double *work, double *covar, void *adata);
|
||||
|
||||
extern int dlevmar_leic_dif(
|
||||
void (*func)(double *p, double *hx, int m, int n, void *adata),
|
||||
double *p, double *x, int m, int n, double *A, double *b, int k1, double *C, double *d, int k2,
|
||||
int itmax, double opts[5], double info[LM_INFO_SZ], double *work, double *covar, void *adata);
|
||||
|
||||
/* linear inequality constraints */
|
||||
extern int dlevmar_lic_der(
|
||||
void (*func)(double *p, double *hx, int m, int n, void *adata),
|
||||
void (*jacf)(double *p, double *j, int m, int n, void *adata),
|
||||
double *p, double *x, int m, int n, double *C, double *d, int k2,
|
||||
int itmax, double opts[4], double info[LM_INFO_SZ], double *work, double *covar, void *adata);
|
||||
|
||||
extern int dlevmar_lic_dif(
|
||||
void (*func)(double *p, double *hx, int m, int n, void *adata),
|
||||
double *p, double *x, int m, int n, double *C, double *d, int k2,
|
||||
int itmax, double opts[5], double info[LM_INFO_SZ], double *work, double *covar, void *adata);
|
||||
#endif /* HAVE_LAPACK */
|
||||
|
||||
#endif /* LM_DBL_PREC */
|
||||
|
||||
|
||||
#ifdef LM_SNGL_PREC
|
||||
/* single precision LM, with & without Jacobian */
|
||||
/* unconstrained minimization */
|
||||
extern int slevmar_der(
|
||||
void (*func)(float *p, float *hx, int m, int n, void *adata),
|
||||
void (*jacf)(float *p, float *j, int m, int n, void *adata),
|
||||
float *p, float *x, int m, int n, int itmax, float *opts,
|
||||
float *info, float *work, float *covar, void *adata);
|
||||
|
||||
extern int slevmar_dif(
|
||||
void (*func)(float *p, float *hx, int m, int n, void *adata),
|
||||
float *p, float *x, int m, int n, int itmax, float *opts,
|
||||
float *info, float *work, float *covar, void *adata);
|
||||
|
||||
/* box-constrained minimization */
|
||||
extern int slevmar_bc_der(
|
||||
void (*func)(float *p, float *hx, int m, int n, void *adata),
|
||||
void (*jacf)(float *p, float *j, int m, int n, void *adata),
|
||||
float *p, float *x, int m, int n, float *lb, float *ub, float *dscl,
|
||||
int itmax, float *opts, float *info, float *work, float *covar, void *adata);
|
||||
|
||||
extern int slevmar_bc_dif(
|
||||
void (*func)(float *p, float *hx, int m, int n, void *adata),
|
||||
float *p, float *x, int m, int n, float *lb, float *ub, float *dscl,
|
||||
int itmax, float *opts, float *info, float *work, float *covar, void *adata);
|
||||
|
||||
#ifdef HAVE_LAPACK
|
||||
/* linear equation constrained minimization */
|
||||
extern int slevmar_lec_der(
|
||||
void (*func)(float *p, float *hx, int m, int n, void *adata),
|
||||
void (*jacf)(float *p, float *j, int m, int n, void *adata),
|
||||
float *p, float *x, int m, int n, float *A, float *b, int k,
|
||||
int itmax, float *opts, float *info, float *work, float *covar, void *adata);
|
||||
|
||||
extern int slevmar_lec_dif(
|
||||
void (*func)(float *p, float *hx, int m, int n, void *adata),
|
||||
float *p, float *x, int m, int n, float *A, float *b, int k,
|
||||
int itmax, float *opts, float *info, float *work, float *covar, void *adata);
|
||||
|
||||
/* box & linear equation constrained minimization */
|
||||
extern int slevmar_blec_der(
|
||||
void (*func)(float *p, float *hx, int m, int n, void *adata),
|
||||
void (*jacf)(float *p, float *j, int m, int n, void *adata),
|
||||
float *p, float *x, int m, int n, float *lb, float *ub, float *A, float *b, int k, float *wghts,
|
||||
int itmax, float *opts, float *info, float *work, float *covar, void *adata);
|
||||
|
||||
extern int slevmar_blec_dif(
|
||||
void (*func)(float *p, float *hx, int m, int n, void *adata),
|
||||
float *p, float *x, int m, int n, float *lb, float *ub, float *A, float *b, int k, float *wghts,
|
||||
int itmax, float *opts, float *info, float *work, float *covar, void *adata);
|
||||
|
||||
/* box, linear equations & inequalities constrained minimization */
|
||||
extern int slevmar_bleic_der(
|
||||
void (*func)(float *p, float *hx, int m, int n, void *adata),
|
||||
void (*jacf)(float *p, float *j, int m, int n, void *adata),
|
||||
float *p, float *x, int m, int n, float *lb, float *ub,
|
||||
float *A, float *b, int k1, float *C, float *d, int k2,
|
||||
int itmax, float *opts, float *info, float *work, float *covar, void *adata);
|
||||
|
||||
extern int slevmar_bleic_dif(
|
||||
void (*func)(float *p, float *hx, int m, int n, void *adata),
|
||||
float *p, float *x, int m, int n, float *lb, float *ub,
|
||||
float *A, float *b, int k1, float *C, float *d, int k2,
|
||||
int itmax, float *opts, float *info, float *work, float *covar, void *adata);
|
||||
|
||||
/* box & linear inequality constraints */
|
||||
extern int slevmar_blic_der(
|
||||
void (*func)(float *p, float *hx, int m, int n, void *adata),
|
||||
void (*jacf)(float *p, float *j, int m, int n, void *adata),
|
||||
float *p, float *x, int m, int n, float *lb, float *ub, float *C, float *d, int k2,
|
||||
int itmax, float opts[4], float info[LM_INFO_SZ], float *work, float *covar, void *adata);
|
||||
|
||||
extern int slevmar_blic_dif(
|
||||
void (*func)(float *p, float *hx, int m, int n, void *adata),
|
||||
float *p, float *x, int m, int n, float *lb, float *ub, float *C, float *d, int k2,
|
||||
int itmax, float opts[5], float info[LM_INFO_SZ], float *work, float *covar, void *adata);
|
||||
|
||||
/* linear equality & inequality constraints */
|
||||
extern int slevmar_leic_der(
|
||||
void (*func)(float *p, float *hx, int m, int n, void *adata),
|
||||
void (*jacf)(float *p, float *j, int m, int n, void *adata),
|
||||
float *p, float *x, int m, int n, float *A, float *b, int k1, float *C, float *d, int k2,
|
||||
int itmax, float opts[4], float info[LM_INFO_SZ], float *work, float *covar, void *adata);
|
||||
|
||||
extern int slevmar_leic_dif(
|
||||
void (*func)(float *p, float *hx, int m, int n, void *adata),
|
||||
float *p, float *x, int m, int n, float *A, float *b, int k1, float *C, float *d, int k2,
|
||||
int itmax, float opts[5], float info[LM_INFO_SZ], float *work, float *covar, void *adata);
|
||||
|
||||
/* linear inequality constraints */
|
||||
extern int slevmar_lic_der(
|
||||
void (*func)(float *p, float *hx, int m, int n, void *adata),
|
||||
void (*jacf)(float *p, float *j, int m, int n, void *adata),
|
||||
float *p, float *x, int m, int n, float *C, float *d, int k2,
|
||||
int itmax, float opts[4], float info[LM_INFO_SZ], float *work, float *covar, void *adata);
|
||||
|
||||
extern int slevmar_lic_dif(
|
||||
void (*func)(float *p, float *hx, int m, int n, void *adata),
|
||||
float *p, float *x, int m, int n, float *C, float *d, int k2,
|
||||
int itmax, float opts[5], float info[LM_INFO_SZ], float *work, float *covar, void *adata);
|
||||
#endif /* HAVE_LAPACK */
|
||||
|
||||
#endif /* LM_SNGL_PREC */
|
||||
|
||||
/* linear system solvers */
|
||||
#ifdef HAVE_LAPACK
|
||||
|
||||
#ifdef LM_DBL_PREC
|
||||
extern int dAx_eq_b_QR(double *A, double *B, double *x, int m);
|
||||
extern int dAx_eq_b_QRLS(double *A, double *B, double *x, int m, int n);
|
||||
extern int dAx_eq_b_Chol(double *A, double *B, double *x, int m);
|
||||
extern int dAx_eq_b_LU(double *A, double *B, double *x, int m);
|
||||
extern int dAx_eq_b_SVD(double *A, double *B, double *x, int m);
|
||||
extern int dAx_eq_b_BK(double *A, double *B, double *x, int m);
|
||||
#endif /* LM_DBL_PREC */
|
||||
|
||||
#ifdef LM_SNGL_PREC
|
||||
extern int sAx_eq_b_QR(float *A, float *B, float *x, int m);
|
||||
extern int sAx_eq_b_QRLS(float *A, float *B, float *x, int m, int n);
|
||||
extern int sAx_eq_b_Chol(float *A, float *B, float *x, int m);
|
||||
extern int sAx_eq_b_LU(float *A, float *B, float *x, int m);
|
||||
extern int sAx_eq_b_SVD(float *A, float *B, float *x, int m);
|
||||
extern int sAx_eq_b_BK(float *A, float *B, float *x, int m);
|
||||
#endif /* LM_SNGL_PREC */
|
||||
|
||||
#else /* no LAPACK */
|
||||
|
||||
#ifdef LM_DBL_PREC
|
||||
extern int dAx_eq_b_LU_noLapack(double *A, double *B, double *x, int n);
|
||||
#endif /* LM_DBL_PREC */
|
||||
|
||||
#ifdef LM_SNGL_PREC
|
||||
extern int sAx_eq_b_LU_noLapack(float *A, float *B, float *x, int n);
|
||||
#endif /* LM_SNGL_PREC */
|
||||
|
||||
#endif /* HAVE_LAPACK */
|
||||
|
||||
#ifdef HAVE_PLASMA
|
||||
#ifdef LM_DBL_PREC
|
||||
extern int dAx_eq_b_PLASMA_Chol(double *A, double *B, double *x, int m);
|
||||
#endif
|
||||
#ifdef LM_SNGL_PREC
|
||||
extern int sAx_eq_b_PLASMA_Chol(float *A, float *B, float *x, int m);
|
||||
#endif
|
||||
extern void levmar_PLASMA_setnbcores(int cores);
|
||||
#endif /* HAVE_PLASMA */
|
||||
|
||||
/* Jacobian verification, double & single precision */
|
||||
#ifdef LM_DBL_PREC
|
||||
extern void dlevmar_chkjac(
|
||||
void (*func)(double *p, double *hx, int m, int n, void *adata),
|
||||
void (*jacf)(double *p, double *j, int m, int n, void *adata),
|
||||
double *p, int m, int n, void *adata, double *err);
|
||||
#endif /* LM_DBL_PREC */
|
||||
|
||||
#ifdef LM_SNGL_PREC
|
||||
extern void slevmar_chkjac(
|
||||
void (*func)(float *p, float *hx, int m, int n, void *adata),
|
||||
void (*jacf)(float *p, float *j, int m, int n, void *adata),
|
||||
float *p, int m, int n, void *adata, float *err);
|
||||
#endif /* LM_SNGL_PREC */
|
||||
|
||||
/* miscellaneous: standard deviation, coefficient of determination (R2),
|
||||
* Pearson's correlation coefficient for best-fit parameters
|
||||
*/
|
||||
#ifdef LM_DBL_PREC
|
||||
extern double dlevmar_stddev( double *covar, int m, int i);
|
||||
extern double dlevmar_corcoef(double *covar, int m, int i, int j);
|
||||
extern double dlevmar_R2(void (*func)(double *p, double *hx, int m, int n, void *adata), double *p, double *x, int m, int n, void *adata);
|
||||
|
||||
#endif /* LM_DBL_PREC */
|
||||
|
||||
#ifdef LM_SNGL_PREC
|
||||
extern float slevmar_stddev( float *covar, int m, int i);
|
||||
extern float slevmar_corcoef(float *covar, int m, int i, int j);
|
||||
extern float slevmar_R2(void (*func)(float *p, float *hx, int m, int n, void *adata), float *p, float *x, int m, int n, void *adata);
|
||||
|
||||
extern void slevmar_locscale(
|
||||
void (*func)(float *p, float *hx, int m, int n, void *adata),
|
||||
float *p, float *x, int m, int n, void *adata,
|
||||
int howto, float locscl[2], float **residptr);
|
||||
|
||||
extern int slevmar_outlid(float *r, int n, float thresh, float ls[2], char *outlmap);
|
||||
|
||||
#endif /* LM_SNGL_PREC */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _LEVMAR_H_ */
|
||||
83
contrib/levmar/lm.c
Normal file
83
contrib/levmar/lm.c
Normal file
@@ -0,0 +1,83 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Levenberg - Marquardt non-linear minimization algorithm
|
||||
// Copyright (C) 2004 Manolis Lourakis (lourakis at ics forth gr)
|
||||
// Institute of Computer Science, Foundation for Research & Technology - Hellas
|
||||
// Heraklion, Crete, Greece.
|
||||
//
|
||||
// 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 2 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/********************************************************************************
|
||||
* Levenberg-Marquardt nonlinear minimization. The same core code is used with
|
||||
* appropriate #defines to derive single and double precision versions, see
|
||||
* also lm_core.c
|
||||
********************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
|
||||
#include "levmar.h"
|
||||
#include "compiler.h"
|
||||
#include "misc.h"
|
||||
|
||||
#define EPSILON 1E-12
|
||||
#define ONE_THIRD 0.3333333334 /* 1.0/3.0 */
|
||||
|
||||
#if !defined(LM_DBL_PREC) && !defined(LM_SNGL_PREC)
|
||||
#error At least one of LM_DBL_PREC, LM_SNGL_PREC should be defined!
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef LM_SNGL_PREC
|
||||
/* single precision (float) definitions */
|
||||
#define LM_REAL float
|
||||
#define LM_PREFIX s
|
||||
|
||||
#define LM_REAL_MAX FLT_MAX
|
||||
#define LM_REAL_MIN -FLT_MAX
|
||||
#define LM_REAL_EPSILON FLT_EPSILON
|
||||
#define __SUBCNST(x) x##F
|
||||
#define LM_CNST(x) __SUBCNST(x) // force substitution
|
||||
|
||||
#include "lm_core.c" // read in core code
|
||||
|
||||
#undef LM_REAL
|
||||
#undef LM_PREFIX
|
||||
#undef LM_REAL_MAX
|
||||
#undef LM_REAL_EPSILON
|
||||
#undef LM_REAL_MIN
|
||||
#undef __SUBCNST
|
||||
#undef LM_CNST
|
||||
#endif /* LM_SNGL_PREC */
|
||||
|
||||
#ifdef LM_DBL_PREC
|
||||
/* double precision definitions */
|
||||
#define LM_REAL double
|
||||
#define LM_PREFIX d
|
||||
|
||||
#define LM_REAL_MAX DBL_MAX
|
||||
#define LM_REAL_MIN -DBL_MAX
|
||||
#define LM_REAL_EPSILON DBL_EPSILON
|
||||
#define LM_CNST(x) (x)
|
||||
|
||||
#include "lm_core.c" // read in core code
|
||||
|
||||
#undef LM_REAL
|
||||
#undef LM_PREFIX
|
||||
#undef LM_REAL_MAX
|
||||
#undef LM_REAL_EPSILON
|
||||
#undef LM_REAL_MIN
|
||||
#undef LM_CNST
|
||||
#endif /* LM_DBL_PREC */
|
||||
11
contrib/levmar/lm.h
Normal file
11
contrib/levmar/lm.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#ifndef _DEPR_LM_H_
|
||||
#define _DEPR_LM_H_
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma message("lm.h is deprecated, please use levmar.h instead!")
|
||||
#else
|
||||
#error lm.h is deprecated, please use levmar.h instead!
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
#endif /* _DEPR_LM_H_ */
|
||||
|
||||
858
contrib/levmar/lm_core.c
Normal file
858
contrib/levmar/lm_core.c
Normal file
@@ -0,0 +1,858 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Levenberg - Marquardt non-linear minimization algorithm
|
||||
// Copyright (C) 2004 Manolis Lourakis (lourakis at ics forth gr)
|
||||
// Institute of Computer Science, Foundation for Research & Technology - Hellas
|
||||
// Heraklion, Crete, Greece.
|
||||
//
|
||||
// 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 2 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef LM_REAL // not included by lm.c
|
||||
#error This file should not be compiled directly!
|
||||
#endif
|
||||
|
||||
|
||||
/* precision-specific definitions */
|
||||
#define LEVMAR_DER LM_ADD_PREFIX(levmar_der)
|
||||
#define LEVMAR_DIF LM_ADD_PREFIX(levmar_dif)
|
||||
#define LEVMAR_FDIF_FORW_JAC_APPROX LM_ADD_PREFIX(levmar_fdif_forw_jac_approx)
|
||||
#define LEVMAR_FDIF_CENT_JAC_APPROX LM_ADD_PREFIX(levmar_fdif_cent_jac_approx)
|
||||
#define LEVMAR_TRANS_MAT_MAT_MULT LM_ADD_PREFIX(levmar_trans_mat_mat_mult)
|
||||
#define LEVMAR_L2NRMXMY LM_ADD_PREFIX(levmar_L2nrmxmy)
|
||||
#define LEVMAR_COVAR LM_ADD_PREFIX(levmar_covar)
|
||||
|
||||
#ifdef HAVE_LAPACK
|
||||
#define AX_EQ_B_LU LM_ADD_PREFIX(Ax_eq_b_LU)
|
||||
#define AX_EQ_B_CHOL LM_ADD_PREFIX(Ax_eq_b_Chol)
|
||||
#define AX_EQ_B_QR LM_ADD_PREFIX(Ax_eq_b_QR)
|
||||
#define AX_EQ_B_QRLS LM_ADD_PREFIX(Ax_eq_b_QRLS)
|
||||
#define AX_EQ_B_SVD LM_ADD_PREFIX(Ax_eq_b_SVD)
|
||||
#define AX_EQ_B_BK LM_ADD_PREFIX(Ax_eq_b_BK)
|
||||
#else
|
||||
#define AX_EQ_B_LU LM_ADD_PREFIX(Ax_eq_b_LU_noLapack)
|
||||
#endif /* HAVE_LAPACK */
|
||||
|
||||
#ifdef HAVE_PLASMA
|
||||
#define AX_EQ_B_PLASMA_CHOL LM_ADD_PREFIX(Ax_eq_b_PLASMA_Chol)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This function seeks the parameter vector p that best describes the measurements vector x.
|
||||
* More precisely, given a vector function func : R^m --> R^n with n>=m,
|
||||
* it finds p s.t. func(p) ~= x, i.e. the squared second order (i.e. L2) norm of
|
||||
* e=x-func(p) is minimized.
|
||||
*
|
||||
* This function requires an analytic Jacobian. In case the latter is unavailable,
|
||||
* use LEVMAR_DIF() bellow
|
||||
*
|
||||
* Returns the number of iterations (>=0) if successful, LM_ERROR if failed
|
||||
*
|
||||
* For more details, see K. Madsen, H.B. Nielsen and O. Tingleff's lecture notes on
|
||||
* non-linear least squares at http://www.imm.dtu.dk/pubdb/views/edoc_download.php/3215/pdf/imm3215.pdf
|
||||
*/
|
||||
|
||||
int LEVMAR_DER(
|
||||
void (*func)(LM_REAL *p, LM_REAL *hx, int m, int n, void *adata), /* functional relation describing measurements. A p \in R^m yields a \hat{x} \in R^n */
|
||||
void (*jacf)(LM_REAL *p, LM_REAL *j, int m, int n, void *adata), /* function to evaluate the Jacobian \part x / \part p */
|
||||
LM_REAL *p, /* I/O: initial parameter estimates. On output has the estimated solution */
|
||||
LM_REAL *x, /* I: measurement vector. NULL implies a zero vector */
|
||||
int m, /* I: parameter vector dimension (i.e. #unknowns) */
|
||||
int n, /* I: measurement vector dimension */
|
||||
int itmax, /* I: maximum number of iterations */
|
||||
LM_REAL opts[4], /* I: minim. options [\mu, \epsilon1, \epsilon2, \epsilon3]. Respectively the scale factor for initial \mu,
|
||||
* stopping thresholds for ||J^T e||_inf, ||Dp||_2 and ||e||_2. Set to NULL for defaults to be used
|
||||
*/
|
||||
LM_REAL info[LM_INFO_SZ],
|
||||
/* O: information regarding the minimization. Set to NULL if don't care
|
||||
* info[0]= ||e||_2 at initial p.
|
||||
* info[1-4]=[ ||e||_2, ||J^T e||_inf, ||Dp||_2, mu/max[J^T J]_ii ], all computed at estimated p.
|
||||
* info[5]= # iterations,
|
||||
* info[6]=reason for terminating: 1 - stopped by small gradient J^T e
|
||||
* 2 - stopped by small Dp
|
||||
* 3 - stopped by itmax
|
||||
* 4 - singular matrix. Restart from current p with increased mu
|
||||
* 5 - no further error reduction is possible. Restart with increased mu
|
||||
* 6 - stopped by small ||e||_2
|
||||
* 7 - stopped by invalid (i.e. NaN or Inf) "func" values. This is a user error
|
||||
* info[7]= # function evaluations
|
||||
* info[8]= # Jacobian evaluations
|
||||
* info[9]= # linear systems solved, i.e. # attempts for reducing error
|
||||
*/
|
||||
LM_REAL *work, /* working memory at least LM_DER_WORKSZ() reals large, allocated if NULL */
|
||||
LM_REAL *covar, /* O: Covariance matrix corresponding to LS solution; mxm. Set to NULL if not needed. */
|
||||
void *adata) /* pointer to possibly additional data, passed uninterpreted to func & jacf.
|
||||
* Set to NULL if not needed
|
||||
*/
|
||||
{
|
||||
register int i, j, k, l;
|
||||
int worksz, freework=0, issolved;
|
||||
/* temp work arrays */
|
||||
LM_REAL *e, /* nx1 */
|
||||
*hx, /* \hat{x}_i, nx1 */
|
||||
*jacTe, /* J^T e_i mx1 */
|
||||
*jac, /* nxm */
|
||||
*jacTjac, /* mxm */
|
||||
*Dp, /* mx1 */
|
||||
*diag_jacTjac, /* diagonal of J^T J, mx1 */
|
||||
*pDp; /* p + Dp, mx1 */
|
||||
|
||||
register LM_REAL mu, /* damping constant */
|
||||
tmp; /* mainly used in matrix & vector multiplications */
|
||||
LM_REAL p_eL2, jacTe_inf, pDp_eL2; /* ||e(p)||_2, ||J^T e||_inf, ||e(p+Dp)||_2 */
|
||||
LM_REAL p_L2, Dp_L2=LM_REAL_MAX, dF, dL;
|
||||
LM_REAL tau, eps1, eps2, eps2_sq, eps3;
|
||||
LM_REAL init_p_eL2;
|
||||
int nu=2, nu2, stop=0, nfev, njev=0, nlss=0;
|
||||
const int nm=n*m;
|
||||
int (*linsolver)(LM_REAL *A, LM_REAL *B, LM_REAL *x, int m)=NULL;
|
||||
|
||||
mu=jacTe_inf=0.0; /* -Wall */
|
||||
|
||||
if(n<m){
|
||||
fprintf(stderr, LCAT(LEVMAR_DER, "(): cannot solve a problem with fewer measurements [%d] than unknowns [%d]\n"), n, m);
|
||||
return LM_ERROR;
|
||||
}
|
||||
|
||||
if(!jacf){
|
||||
fprintf(stderr, RCAT("No function specified for computing the Jacobian in ", LEVMAR_DER)
|
||||
RCAT("().\nIf no such function is available, use ", LEVMAR_DIF) RCAT("() rather than ", LEVMAR_DER) "()\n");
|
||||
return LM_ERROR;
|
||||
}
|
||||
|
||||
if(opts){
|
||||
tau=opts[0];
|
||||
eps1=opts[1];
|
||||
eps2=opts[2];
|
||||
eps2_sq=opts[2]*opts[2];
|
||||
eps3=opts[3];
|
||||
}
|
||||
else{ // use default values
|
||||
tau=LM_CNST(LM_INIT_MU);
|
||||
eps1=LM_CNST(LM_STOP_THRESH);
|
||||
eps2=LM_CNST(LM_STOP_THRESH);
|
||||
eps2_sq=LM_CNST(LM_STOP_THRESH)*LM_CNST(LM_STOP_THRESH);
|
||||
eps3=LM_CNST(LM_STOP_THRESH);
|
||||
}
|
||||
|
||||
if(!work){
|
||||
worksz=LM_DER_WORKSZ(m, n); //2*n+4*m + n*m + m*m;
|
||||
work=(LM_REAL *)malloc(worksz*sizeof(LM_REAL)); /* allocate a big chunk in one step */
|
||||
if(!work){
|
||||
fprintf(stderr, LCAT(LEVMAR_DER, "(): memory allocation request failed\n"));
|
||||
return LM_ERROR;
|
||||
}
|
||||
freework=1;
|
||||
}
|
||||
|
||||
/* set up work arrays */
|
||||
e=work;
|
||||
hx=e + n;
|
||||
jacTe=hx + n;
|
||||
jac=jacTe + m;
|
||||
jacTjac=jac + nm;
|
||||
Dp=jacTjac + m*m;
|
||||
diag_jacTjac=Dp + m;
|
||||
pDp=diag_jacTjac + m;
|
||||
|
||||
/* compute e=x - f(p) and its L2 norm */
|
||||
(*func)(p, hx, m, n, adata); nfev=1;
|
||||
/* ### e=x-hx, p_eL2=||e|| */
|
||||
#if 1
|
||||
p_eL2=LEVMAR_L2NRMXMY(e, x, hx, n);
|
||||
#else
|
||||
for(i=0, p_eL2=0.0; i<n; ++i){
|
||||
e[i]=tmp=x[i]-hx[i];
|
||||
p_eL2+=tmp*tmp;
|
||||
}
|
||||
#endif
|
||||
init_p_eL2=p_eL2;
|
||||
if(!LM_FINITE(p_eL2)) stop=7;
|
||||
|
||||
for(k=0; k<itmax && !stop; ++k){
|
||||
/* Note that p and e have been updated at a previous iteration */
|
||||
|
||||
if(p_eL2<=eps3){ /* error is small */
|
||||
stop=6;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Compute the Jacobian J at p, J^T J, J^T e, ||J^T e||_inf and ||p||^2.
|
||||
* Since J^T J is symmetric, its computation can be sped up by computing
|
||||
* only its upper triangular part and copying it to the lower part
|
||||
*/
|
||||
|
||||
(*jacf)(p, jac, m, n, adata); ++njev;
|
||||
|
||||
/* J^T J, J^T e */
|
||||
if(nm<__BLOCKSZ__SQ){ // this is a small problem
|
||||
/* J^T*J_ij = \sum_l J^T_il * J_lj = \sum_l J_li * J_lj.
|
||||
* Thus, the product J^T J can be computed using an outer loop for
|
||||
* l that adds J_li*J_lj to each element ij of the result. Note that
|
||||
* with this scheme, the accesses to J and JtJ are always along rows,
|
||||
* therefore induces less cache misses compared to the straightforward
|
||||
* algorithm for computing the product (i.e., l loop is innermost one).
|
||||
* A similar scheme applies to the computation of J^T e.
|
||||
* However, for large minimization problems (i.e., involving a large number
|
||||
* of unknowns and measurements) for which J/J^T J rows are too large to
|
||||
* fit in the L1 cache, even this scheme incures many cache misses. In
|
||||
* such cases, a cache-efficient blocking scheme is preferable.
|
||||
*
|
||||
* Thanks to John Nitao of Lawrence Livermore Lab for pointing out this
|
||||
* performance problem.
|
||||
*
|
||||
* Note that the non-blocking algorithm is faster on small
|
||||
* problems since in this case it avoids the overheads of blocking.
|
||||
*/
|
||||
|
||||
/* looping downwards saves a few computations */
|
||||
register int l;
|
||||
register LM_REAL alpha, *jaclm, *jacTjacim;
|
||||
|
||||
for(i=m*m; i-->0; )
|
||||
jacTjac[i]=0.0;
|
||||
for(i=m; i-->0; )
|
||||
jacTe[i]=0.0;
|
||||
|
||||
for(l=n; l-->0; ){
|
||||
jaclm=jac+l*m;
|
||||
for(i=m; i-->0; ){
|
||||
jacTjacim=jacTjac+i*m;
|
||||
alpha=jaclm[i]; //jac[l*m+i];
|
||||
for(j=i+1; j-->0; ) /* j<=i computes lower triangular part only */
|
||||
jacTjacim[j]+=jaclm[j]*alpha; //jacTjac[i*m+j]+=jac[l*m+j]*alpha
|
||||
|
||||
/* J^T e */
|
||||
jacTe[i]+=alpha*e[l];
|
||||
}
|
||||
}
|
||||
|
||||
for(i=m; i-->0; ) /* copy to upper part */
|
||||
for(j=i+1; j<m; ++j)
|
||||
jacTjac[i*m+j]=jacTjac[j*m+i];
|
||||
|
||||
}
|
||||
else{ // this is a large problem
|
||||
/* Cache efficient computation of J^T J based on blocking
|
||||
*/
|
||||
LEVMAR_TRANS_MAT_MAT_MULT(jac, jacTjac, n, m);
|
||||
|
||||
/* cache efficient computation of J^T e */
|
||||
for(i=0; i<m; ++i)
|
||||
jacTe[i]=0.0;
|
||||
|
||||
for(i=0; i<n; ++i){
|
||||
register LM_REAL *jacrow;
|
||||
|
||||
for(l=0, jacrow=jac+i*m, tmp=e[i]; l<m; ++l)
|
||||
jacTe[l]+=jacrow[l]*tmp;
|
||||
}
|
||||
}
|
||||
|
||||
/* Compute ||J^T e||_inf and ||p||^2 */
|
||||
for(i=0, p_L2=jacTe_inf=0.0; i<m; ++i){
|
||||
if(jacTe_inf < (tmp=FABS(jacTe[i]))) jacTe_inf=tmp;
|
||||
|
||||
diag_jacTjac[i]=jacTjac[i*m+i]; /* save diagonal entries so that augmentation can be later canceled */
|
||||
p_L2+=p[i]*p[i];
|
||||
}
|
||||
//p_L2=sqrt(p_L2);
|
||||
|
||||
#if 0
|
||||
if(!(k%100)){
|
||||
printf("Current estimate: ");
|
||||
for(i=0; i<m; ++i)
|
||||
printf("%.9g ", p[i]);
|
||||
printf("-- errors %.9g %0.9g\n", jacTe_inf, p_eL2);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* check for convergence */
|
||||
if((jacTe_inf <= eps1)){
|
||||
Dp_L2=0.0; /* no increment for p in this case */
|
||||
stop=1;
|
||||
break;
|
||||
}
|
||||
|
||||
/* compute initial damping factor */
|
||||
if(k==0){
|
||||
for(i=0, tmp=LM_REAL_MIN; i<m; ++i)
|
||||
if(diag_jacTjac[i]>tmp) tmp=diag_jacTjac[i]; /* find max diagonal element */
|
||||
mu=tau*tmp;
|
||||
}
|
||||
|
||||
/* determine increment using adaptive damping */
|
||||
while(1){
|
||||
/* augment normal equations */
|
||||
for(i=0; i<m; ++i)
|
||||
jacTjac[i*m+i]+=mu;
|
||||
|
||||
/* solve augmented equations */
|
||||
#ifdef HAVE_LAPACK
|
||||
/* 7 alternatives are available: LU, Cholesky + Cholesky with PLASMA, LDLt, 2 variants of QR decomposition and SVD.
|
||||
* For matrices with dimensions of at least a few hundreds, the PLASMA implementation of Cholesky is the fastest.
|
||||
* From the serial solvers, Cholesky is the fastest but might occasionally be inapplicable due to numerical round-off;
|
||||
* QR is slower but more robust; SVD is the slowest but most robust; LU is quite robust but
|
||||
* slower than LDLt; LDLt offers a good tradeoff between robustness and speed
|
||||
*/
|
||||
|
||||
issolved=AX_EQ_B_BK(jacTjac, jacTe, Dp, m); ++nlss; linsolver=AX_EQ_B_BK;
|
||||
//issolved=AX_EQ_B_LU(jacTjac, jacTe, Dp, m); ++nlss; linsolver=AX_EQ_B_LU;
|
||||
//issolved=AX_EQ_B_CHOL(jacTjac, jacTe, Dp, m); ++nlss; linsolver=AX_EQ_B_CHOL;
|
||||
#ifdef HAVE_PLASMA
|
||||
//issolved=AX_EQ_B_PLASMA_CHOL(jacTjac, jacTe, Dp, m); ++nlss; linsolver=AX_EQ_B_PLASMA_CHOL;
|
||||
#endif
|
||||
//issolved=AX_EQ_B_QR(jacTjac, jacTe, Dp, m); ++nlss; linsolver=AX_EQ_B_QR;
|
||||
//issolved=AX_EQ_B_QRLS(jacTjac, jacTe, Dp, m, m); ++nlss; linsolver=(int (*)(LM_REAL *A, LM_REAL *B, LM_REAL *x, int m))AX_EQ_B_QRLS;
|
||||
//issolved=AX_EQ_B_SVD(jacTjac, jacTe, Dp, m); ++nlss; linsolver=AX_EQ_B_SVD;
|
||||
|
||||
#else
|
||||
/* use the LU included with levmar */
|
||||
issolved=AX_EQ_B_LU(jacTjac, jacTe, Dp, m); ++nlss; linsolver=AX_EQ_B_LU;
|
||||
#endif /* HAVE_LAPACK */
|
||||
|
||||
if(issolved){
|
||||
/* compute p's new estimate and ||Dp||^2 */
|
||||
for(i=0, Dp_L2=0.0; i<m; ++i){
|
||||
pDp[i]=p[i] + (tmp=Dp[i]);
|
||||
Dp_L2+=tmp*tmp;
|
||||
}
|
||||
//Dp_L2=sqrt(Dp_L2);
|
||||
|
||||
if(Dp_L2<=eps2_sq*p_L2){ /* relative change in p is small, stop */
|
||||
//if(Dp_L2<=eps2*(p_L2 + eps2)){ /* relative change in p is small, stop */
|
||||
stop=2;
|
||||
break;
|
||||
}
|
||||
|
||||
if(Dp_L2>=(p_L2+eps2)/(LM_CNST(EPSILON)*LM_CNST(EPSILON))){ /* almost singular */
|
||||
//if(Dp_L2>=(p_L2+eps2)/LM_CNST(EPSILON)){ /* almost singular */
|
||||
stop=4;
|
||||
break;
|
||||
}
|
||||
|
||||
(*func)(pDp, hx, m, n, adata); ++nfev; /* evaluate function at p + Dp */
|
||||
/* compute ||e(pDp)||_2 */
|
||||
/* ### hx=x-hx, pDp_eL2=||hx|| */
|
||||
#if 1
|
||||
pDp_eL2=LEVMAR_L2NRMXMY(hx, x, hx, n);
|
||||
#else
|
||||
for(i=0, pDp_eL2=0.0; i<n; ++i){
|
||||
hx[i]=tmp=x[i]-hx[i];
|
||||
pDp_eL2+=tmp*tmp;
|
||||
}
|
||||
#endif
|
||||
if(!LM_FINITE(pDp_eL2)){ /* sum of squares is not finite, most probably due to a user error.
|
||||
* This check makes sure that the inner loop does not run indefinitely.
|
||||
* Thanks to Steve Danauskas for reporting such cases
|
||||
*/
|
||||
stop=7;
|
||||
break;
|
||||
}
|
||||
|
||||
for(i=0, dL=0.0; i<m; ++i)
|
||||
dL+=Dp[i]*(mu*Dp[i]+jacTe[i]);
|
||||
|
||||
dF=p_eL2-pDp_eL2;
|
||||
|
||||
if(dL>0.0 && dF>0.0){ /* reduction in error, increment is accepted */
|
||||
tmp=(LM_CNST(2.0)*dF/dL-LM_CNST(1.0));
|
||||
tmp=LM_CNST(1.0)-tmp*tmp*tmp;
|
||||
mu=mu*( (tmp>=LM_CNST(ONE_THIRD))? tmp : LM_CNST(ONE_THIRD) );
|
||||
nu=2;
|
||||
|
||||
for(i=0 ; i<m; ++i) /* update p's estimate */
|
||||
p[i]=pDp[i];
|
||||
|
||||
for(i=0; i<n; ++i) /* update e and ||e||_2 */
|
||||
e[i]=hx[i];
|
||||
p_eL2=pDp_eL2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* if this point is reached, either the linear system could not be solved or
|
||||
* the error did not reduce; in any case, the increment must be rejected
|
||||
*/
|
||||
|
||||
mu*=nu;
|
||||
nu2=nu<<1; // 2*nu;
|
||||
if(nu2<=nu){ /* nu has wrapped around (overflown). Thanks to Frank Jordan for spotting this case */
|
||||
stop=5;
|
||||
break;
|
||||
}
|
||||
nu=nu2;
|
||||
|
||||
for(i=0; i<m; ++i) /* restore diagonal J^T J entries */
|
||||
jacTjac[i*m+i]=diag_jacTjac[i];
|
||||
} /* inner loop */
|
||||
}
|
||||
|
||||
if(k>=itmax) stop=3;
|
||||
|
||||
for(i=0; i<m; ++i) /* restore diagonal J^T J entries */
|
||||
jacTjac[i*m+i]=diag_jacTjac[i];
|
||||
|
||||
if(info){
|
||||
info[0]=init_p_eL2;
|
||||
info[1]=p_eL2;
|
||||
info[2]=jacTe_inf;
|
||||
info[3]=Dp_L2;
|
||||
for(i=0, tmp=LM_REAL_MIN; i<m; ++i)
|
||||
if(tmp<jacTjac[i*m+i]) tmp=jacTjac[i*m+i];
|
||||
info[4]=mu/tmp;
|
||||
info[5]=(LM_REAL)k;
|
||||
info[6]=(LM_REAL)stop;
|
||||
info[7]=(LM_REAL)nfev;
|
||||
info[8]=(LM_REAL)njev;
|
||||
info[9]=(LM_REAL)nlss;
|
||||
}
|
||||
|
||||
/* covariance matrix */
|
||||
if(covar){
|
||||
LEVMAR_COVAR(jacTjac, covar, p_eL2, m, n);
|
||||
}
|
||||
|
||||
if(freework) free(work);
|
||||
|
||||
#ifdef LINSOLVERS_RETAIN_MEMORY
|
||||
if(linsolver) (*linsolver)(NULL, NULL, NULL, 0);
|
||||
#endif
|
||||
|
||||
return (stop!=4 && stop!=7)? k : LM_ERROR;
|
||||
}
|
||||
|
||||
|
||||
/* Secant version of the LEVMAR_DER() function above: the Jacobian is approximated with
|
||||
* the aid of finite differences (forward or central, see the comment for the opts argument)
|
||||
*/
|
||||
int LEVMAR_DIF(
|
||||
void (*func)(LM_REAL *p, LM_REAL *hx, int m, int n, void *adata), /* functional relation describing measurements. A p \in R^m yields a \hat{x} \in R^n */
|
||||
LM_REAL *p, /* I/O: initial parameter estimates. On output has the estimated solution */
|
||||
LM_REAL *x, /* I: measurement vector. NULL implies a zero vector */
|
||||
int m, /* I: parameter vector dimension (i.e. #unknowns) */
|
||||
int n, /* I: measurement vector dimension */
|
||||
int itmax, /* I: maximum number of iterations */
|
||||
LM_REAL opts[5], /* I: opts[0-4] = minim. options [\mu, \epsilon1, \epsilon2, \epsilon3, \delta]. Respectively the
|
||||
* scale factor for initial \mu, stopping thresholds for ||J^T e||_inf, ||Dp||_2 and ||e||_2 and
|
||||
* the step used in difference approximation to the Jacobian. Set to NULL for defaults to be used.
|
||||
* If \delta<0, the Jacobian is approximated with central differences which are more accurate
|
||||
* (but slower!) compared to the forward differences employed by default.
|
||||
*/
|
||||
LM_REAL info[LM_INFO_SZ],
|
||||
/* O: information regarding the minimization. Set to NULL if don't care
|
||||
* info[0]= ||e||_2 at initial p.
|
||||
* info[1-4]=[ ||e||_2, ||J^T e||_inf, ||Dp||_2, mu/max[J^T J]_ii ], all computed at estimated p.
|
||||
* info[5]= # iterations,
|
||||
* info[6]=reason for terminating: 1 - stopped by small gradient J^T e
|
||||
* 2 - stopped by small Dp
|
||||
* 3 - stopped by itmax
|
||||
* 4 - singular matrix. Restart from current p with increased mu
|
||||
* 5 - no further error reduction is possible. Restart with increased mu
|
||||
* 6 - stopped by small ||e||_2
|
||||
* 7 - stopped by invalid (i.e. NaN or Inf) "func" values. This is a user error
|
||||
* info[7]= # function evaluations
|
||||
* info[8]= # Jacobian evaluations
|
||||
* info[9]= # linear systems solved, i.e. # attempts for reducing error
|
||||
*/
|
||||
LM_REAL *work, /* working memory at least LM_DIF_WORKSZ() reals large, allocated if NULL */
|
||||
LM_REAL *covar, /* O: Covariance matrix corresponding to LS solution; mxm. Set to NULL if not needed. */
|
||||
void *adata) /* pointer to possibly additional data, passed uninterpreted to func.
|
||||
* Set to NULL if not needed
|
||||
*/
|
||||
{
|
||||
register int i, j, k, l;
|
||||
int worksz, freework=0, issolved;
|
||||
/* temp work arrays */
|
||||
LM_REAL *e, /* nx1 */
|
||||
*hx, /* \hat{x}_i, nx1 */
|
||||
*jacTe, /* J^T e_i mx1 */
|
||||
*jac, /* nxm */
|
||||
*jacTjac, /* mxm */
|
||||
*Dp, /* mx1 */
|
||||
*diag_jacTjac, /* diagonal of J^T J, mx1 */
|
||||
*pDp, /* p + Dp, mx1 */
|
||||
*wrk, /* nx1 */
|
||||
*wrk2; /* nx1, used only for holding a temporary e vector and when differentiating with central differences */
|
||||
|
||||
int using_ffdif=1;
|
||||
|
||||
register LM_REAL mu, /* damping constant */
|
||||
tmp; /* mainly used in matrix & vector multiplications */
|
||||
LM_REAL p_eL2, jacTe_inf, pDp_eL2; /* ||e(p)||_2, ||J^T e||_inf, ||e(p+Dp)||_2 */
|
||||
LM_REAL p_L2, Dp_L2=LM_REAL_MAX, dF, dL;
|
||||
LM_REAL tau, eps1, eps2, eps2_sq, eps3, delta;
|
||||
LM_REAL init_p_eL2;
|
||||
int nu, nu2, stop=0, nfev, njap=0, nlss=0, K=(m>=10)? m: 10, updjac, updp=1, newjac;
|
||||
const int nm=n*m;
|
||||
int (*linsolver)(LM_REAL *A, LM_REAL *B, LM_REAL *x, int m)=NULL;
|
||||
|
||||
mu=jacTe_inf=p_L2=0.0; /* -Wall */
|
||||
updjac=newjac=0; /* -Wall */
|
||||
|
||||
if(n<m){
|
||||
fprintf(stderr, LCAT(LEVMAR_DIF, "(): cannot solve a problem with fewer measurements [%d] than unknowns [%d]\n"), n, m);
|
||||
return LM_ERROR;
|
||||
}
|
||||
|
||||
if(opts){
|
||||
tau=opts[0];
|
||||
eps1=opts[1];
|
||||
eps2=opts[2];
|
||||
eps2_sq=opts[2]*opts[2];
|
||||
eps3=opts[3];
|
||||
delta=opts[4];
|
||||
if(delta<0.0){
|
||||
delta=-delta; /* make positive */
|
||||
using_ffdif=0; /* use central differencing */
|
||||
}
|
||||
}
|
||||
else{ // use default values
|
||||
tau=LM_CNST(LM_INIT_MU);
|
||||
eps1=LM_CNST(LM_STOP_THRESH);
|
||||
eps2=LM_CNST(LM_STOP_THRESH);
|
||||
eps2_sq=LM_CNST(LM_STOP_THRESH)*LM_CNST(LM_STOP_THRESH);
|
||||
eps3=LM_CNST(LM_STOP_THRESH);
|
||||
delta=LM_CNST(LM_DIFF_DELTA);
|
||||
}
|
||||
|
||||
if(!work){
|
||||
worksz=LM_DIF_WORKSZ(m, n); //4*n+4*m + n*m + m*m;
|
||||
work=(LM_REAL *)malloc(worksz*sizeof(LM_REAL)); /* allocate a big chunk in one step */
|
||||
if(!work){
|
||||
fprintf(stderr, LCAT(LEVMAR_DIF, "(): memory allocation request failed\n"));
|
||||
return LM_ERROR;
|
||||
}
|
||||
freework=1;
|
||||
}
|
||||
|
||||
/* set up work arrays */
|
||||
e=work;
|
||||
hx=e + n;
|
||||
jacTe=hx + n;
|
||||
jac=jacTe + m;
|
||||
jacTjac=jac + nm;
|
||||
Dp=jacTjac + m*m;
|
||||
diag_jacTjac=Dp + m;
|
||||
pDp=diag_jacTjac + m;
|
||||
wrk=pDp + m;
|
||||
wrk2=wrk + n;
|
||||
|
||||
/* compute e=x - f(p) and its L2 norm */
|
||||
(*func)(p, hx, m, n, adata); nfev=1;
|
||||
/* ### e=x-hx, p_eL2=||e|| */
|
||||
#if 1
|
||||
p_eL2=LEVMAR_L2NRMXMY(e, x, hx, n);
|
||||
#else
|
||||
for(i=0, p_eL2=0.0; i<n; ++i){
|
||||
e[i]=tmp=x[i]-hx[i];
|
||||
p_eL2+=tmp*tmp;
|
||||
}
|
||||
#endif
|
||||
init_p_eL2=p_eL2;
|
||||
if(!LM_FINITE(p_eL2)) stop=7;
|
||||
|
||||
nu=20; /* force computation of J */
|
||||
|
||||
for(k=0; k<itmax && !stop; ++k){
|
||||
/* Note that p and e have been updated at a previous iteration */
|
||||
|
||||
if(p_eL2<=eps3){ /* error is small */
|
||||
stop=6;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Compute the Jacobian J at p, J^T J, J^T e, ||J^T e||_inf and ||p||^2.
|
||||
* The symmetry of J^T J is again exploited for speed
|
||||
*/
|
||||
|
||||
if((updp && nu>16) || updjac==K){ /* compute difference approximation to J */
|
||||
if(using_ffdif){ /* use forward differences */
|
||||
LEVMAR_FDIF_FORW_JAC_APPROX(func, p, hx, wrk, delta, jac, m, n, adata);
|
||||
++njap; nfev+=m;
|
||||
}
|
||||
else{ /* use central differences */
|
||||
LEVMAR_FDIF_CENT_JAC_APPROX(func, p, wrk, wrk2, delta, jac, m, n, adata);
|
||||
++njap; nfev+=2*m;
|
||||
}
|
||||
nu=2; updjac=0; updp=0; newjac=1;
|
||||
}
|
||||
|
||||
if(newjac){ /* Jacobian has changed, recompute J^T J, J^t e, etc */
|
||||
newjac=0;
|
||||
|
||||
/* J^T J, J^T e */
|
||||
if(nm<=__BLOCKSZ__SQ){ // this is a small problem
|
||||
/* J^T*J_ij = \sum_l J^T_il * J_lj = \sum_l J_li * J_lj.
|
||||
* Thus, the product J^T J can be computed using an outer loop for
|
||||
* l that adds J_li*J_lj to each element ij of the result. Note that
|
||||
* with this scheme, the accesses to J and JtJ are always along rows,
|
||||
* therefore induces less cache misses compared to the straightforward
|
||||
* algorithm for computing the product (i.e., l loop is innermost one).
|
||||
* A similar scheme applies to the computation of J^T e.
|
||||
* However, for large minimization problems (i.e., involving a large number
|
||||
* of unknowns and measurements) for which J/J^T J rows are too large to
|
||||
* fit in the L1 cache, even this scheme incures many cache misses. In
|
||||
* such cases, a cache-efficient blocking scheme is preferable.
|
||||
*
|
||||
* Thanks to John Nitao of Lawrence Livermore Lab for pointing out this
|
||||
* performance problem.
|
||||
*
|
||||
* Note that the non-blocking algorithm is faster on small
|
||||
* problems since in this case it avoids the overheads of blocking.
|
||||
*/
|
||||
register int l;
|
||||
register LM_REAL alpha, *jaclm, *jacTjacim;
|
||||
|
||||
/* looping downwards saves a few computations */
|
||||
for(i=m*m; i-->0; )
|
||||
jacTjac[i]=0.0;
|
||||
for(i=m; i-->0; )
|
||||
jacTe[i]=0.0;
|
||||
|
||||
for(l=n; l-->0; ){
|
||||
jaclm=jac+l*m;
|
||||
for(i=m; i-->0; ){
|
||||
jacTjacim=jacTjac+i*m;
|
||||
alpha=jaclm[i]; //jac[l*m+i];
|
||||
for(j=i+1; j-->0; ) /* j<=i computes lower triangular part only */
|
||||
jacTjacim[j]+=jaclm[j]*alpha; //jacTjac[i*m+j]+=jac[l*m+j]*alpha
|
||||
|
||||
/* J^T e */
|
||||
jacTe[i]+=alpha*e[l];
|
||||
}
|
||||
}
|
||||
|
||||
for(i=m; i-->0; ) /* copy to upper part */
|
||||
for(j=i+1; j<m; ++j)
|
||||
jacTjac[i*m+j]=jacTjac[j*m+i];
|
||||
}
|
||||
else{ // this is a large problem
|
||||
/* Cache efficient computation of J^T J based on blocking
|
||||
*/
|
||||
LEVMAR_TRANS_MAT_MAT_MULT(jac, jacTjac, n, m);
|
||||
|
||||
/* cache efficient computation of J^T e */
|
||||
for(i=0; i<m; ++i)
|
||||
jacTe[i]=0.0;
|
||||
|
||||
for(i=0; i<n; ++i){
|
||||
register LM_REAL *jacrow;
|
||||
|
||||
for(l=0, jacrow=jac+i*m, tmp=e[i]; l<m; ++l)
|
||||
jacTe[l]+=jacrow[l]*tmp;
|
||||
}
|
||||
}
|
||||
|
||||
/* Compute ||J^T e||_inf and ||p||^2 */
|
||||
for(i=0, p_L2=jacTe_inf=0.0; i<m; ++i){
|
||||
if(jacTe_inf < (tmp=FABS(jacTe[i]))) jacTe_inf=tmp;
|
||||
|
||||
diag_jacTjac[i]=jacTjac[i*m+i]; /* save diagonal entries so that augmentation can be later canceled */
|
||||
p_L2+=p[i]*p[i];
|
||||
}
|
||||
//p_L2=sqrt(p_L2);
|
||||
}
|
||||
|
||||
#if 0
|
||||
if(!(k%100)){
|
||||
printf("Current estimate: ");
|
||||
for(i=0; i<m; ++i)
|
||||
printf("%.9g ", p[i]);
|
||||
printf("-- errors %.9g %0.9g\n", jacTe_inf, p_eL2);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* check for convergence */
|
||||
if((jacTe_inf <= eps1)){
|
||||
Dp_L2=0.0; /* no increment for p in this case */
|
||||
stop=1;
|
||||
break;
|
||||
}
|
||||
|
||||
/* compute initial damping factor */
|
||||
if(k==0){
|
||||
for(i=0, tmp=LM_REAL_MIN; i<m; ++i)
|
||||
if(diag_jacTjac[i]>tmp) tmp=diag_jacTjac[i]; /* find max diagonal element */
|
||||
mu=tau*tmp;
|
||||
}
|
||||
|
||||
/* determine increment using adaptive damping */
|
||||
|
||||
/* augment normal equations */
|
||||
for(i=0; i<m; ++i)
|
||||
jacTjac[i*m+i]+=mu;
|
||||
|
||||
/* solve augmented equations */
|
||||
#ifdef HAVE_LAPACK
|
||||
/* 7 alternatives are available: LU, Cholesky + Cholesky with PLASMA, LDLt, 2 variants of QR decomposition and SVD.
|
||||
* For matrices with dimensions of at least a few hundreds, the PLASMA implementation of Cholesky is the fastest.
|
||||
* From the serial solvers, Cholesky is the fastest but might occasionally be inapplicable due to numerical round-off;
|
||||
* QR is slower but more robust; SVD is the slowest but most robust; LU is quite robust but
|
||||
* slower than LDLt; LDLt offers a good tradeoff between robustness and speed
|
||||
*/
|
||||
|
||||
issolved=AX_EQ_B_BK(jacTjac, jacTe, Dp, m); ++nlss; linsolver=AX_EQ_B_BK;
|
||||
//issolved=AX_EQ_B_LU(jacTjac, jacTe, Dp, m); ++nlss; linsolver=AX_EQ_B_LU;
|
||||
//issolved=AX_EQ_B_CHOL(jacTjac, jacTe, Dp, m); ++nlss; linsolver=AX_EQ_B_CHOL;
|
||||
#ifdef HAVE_PLASMA
|
||||
//issolved=AX_EQ_B_PLASMA_CHOL(jacTjac, jacTe, Dp, m); ++nlss; linsolver=AX_EQ_B_PLASMA_CHOL;
|
||||
#endif
|
||||
//issolved=AX_EQ_B_QR(jacTjac, jacTe, Dp, m); ++nlss; linsolver=AX_EQ_B_QR;
|
||||
//issolved=AX_EQ_B_QRLS(jacTjac, jacTe, Dp, m, m); ++nlss; linsolver=(int (*)(LM_REAL *A, LM_REAL *B, LM_REAL *x, int m))AX_EQ_B_QRLS;
|
||||
//issolved=AX_EQ_B_SVD(jacTjac, jacTe, Dp, m); ++nlss; linsolver=AX_EQ_B_SVD;
|
||||
#else
|
||||
/* use the LU included with levmar */
|
||||
issolved=AX_EQ_B_LU(jacTjac, jacTe, Dp, m); ++nlss; linsolver=AX_EQ_B_LU;
|
||||
#endif /* HAVE_LAPACK */
|
||||
|
||||
if(issolved){
|
||||
/* compute p's new estimate and ||Dp||^2 */
|
||||
for(i=0, Dp_L2=0.0; i<m; ++i){
|
||||
pDp[i]=p[i] + (tmp=Dp[i]);
|
||||
Dp_L2+=tmp*tmp;
|
||||
}
|
||||
//Dp_L2=sqrt(Dp_L2);
|
||||
|
||||
if(Dp_L2<=eps2_sq*p_L2){ /* relative change in p is small, stop */
|
||||
//if(Dp_L2<=eps2*(p_L2 + eps2)){ /* relative change in p is small, stop */
|
||||
stop=2;
|
||||
break;
|
||||
}
|
||||
|
||||
if(Dp_L2>=(p_L2+eps2)/(LM_CNST(EPSILON)*LM_CNST(EPSILON))){ /* almost singular */
|
||||
//if(Dp_L2>=(p_L2+eps2)/LM_CNST(EPSILON)){ /* almost singular */
|
||||
stop=4;
|
||||
break;
|
||||
}
|
||||
|
||||
(*func)(pDp, wrk, m, n, adata); ++nfev; /* evaluate function at p + Dp */
|
||||
/* compute ||e(pDp)||_2 */
|
||||
/* ### wrk2=x-wrk, pDp_eL2=||wrk2|| */
|
||||
#if 1
|
||||
pDp_eL2=LEVMAR_L2NRMXMY(wrk2, x, wrk, n);
|
||||
#else
|
||||
for(i=0, pDp_eL2=0.0; i<n; ++i){
|
||||
wrk2[i]=tmp=x[i]-wrk[i];
|
||||
pDp_eL2+=tmp*tmp;
|
||||
}
|
||||
#endif
|
||||
if(!LM_FINITE(pDp_eL2)){ /* sum of squares is not finite, most probably due to a user error.
|
||||
* This check makes sure that the loop terminates early in the case
|
||||
* of invalid input. Thanks to Steve Danauskas for suggesting it
|
||||
*/
|
||||
|
||||
stop=7;
|
||||
break;
|
||||
}
|
||||
|
||||
dF=p_eL2-pDp_eL2;
|
||||
if(updp || dF>0){ /* update jac */
|
||||
for(i=0; i<n; ++i){
|
||||
for(l=0, tmp=0.0; l<m; ++l)
|
||||
tmp+=jac[i*m+l]*Dp[l]; /* (J * Dp)[i] */
|
||||
tmp=(wrk[i] - hx[i] - tmp)/Dp_L2; /* (f(p+dp)[i] - f(p)[i] - (J * Dp)[i])/(dp^T*dp) */
|
||||
for(j=0; j<m; ++j)
|
||||
jac[i*m+j]+=tmp*Dp[j];
|
||||
}
|
||||
++updjac;
|
||||
newjac=1;
|
||||
}
|
||||
|
||||
for(i=0, dL=0.0; i<m; ++i)
|
||||
dL+=Dp[i]*(mu*Dp[i]+jacTe[i]);
|
||||
|
||||
if(dL>0.0 && dF>0.0){ /* reduction in error, increment is accepted */
|
||||
tmp=(LM_CNST(2.0)*dF/dL-LM_CNST(1.0));
|
||||
tmp=LM_CNST(1.0)-tmp*tmp*tmp;
|
||||
mu=mu*( (tmp>=LM_CNST(ONE_THIRD))? tmp : LM_CNST(ONE_THIRD) );
|
||||
nu=2;
|
||||
|
||||
for(i=0 ; i<m; ++i) /* update p's estimate */
|
||||
p[i]=pDp[i];
|
||||
|
||||
for(i=0; i<n; ++i){ /* update e, hx and ||e||_2 */
|
||||
e[i]=wrk2[i]; //x[i]-wrk[i];
|
||||
hx[i]=wrk[i];
|
||||
}
|
||||
p_eL2=pDp_eL2;
|
||||
updp=1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
/* if this point is reached, either the linear system could not be solved or
|
||||
* the error did not reduce; in any case, the increment must be rejected
|
||||
*/
|
||||
|
||||
mu*=nu;
|
||||
nu2=nu<<1; // 2*nu;
|
||||
if(nu2<=nu){ /* nu has wrapped around (overflown). Thanks to Frank Jordan for spotting this case */
|
||||
stop=5;
|
||||
break;
|
||||
}
|
||||
nu=nu2;
|
||||
|
||||
for(i=0; i<m; ++i) /* restore diagonal J^T J entries */
|
||||
jacTjac[i*m+i]=diag_jacTjac[i];
|
||||
}
|
||||
|
||||
if(k>=itmax) stop=3;
|
||||
|
||||
for(i=0; i<m; ++i) /* restore diagonal J^T J entries */
|
||||
jacTjac[i*m+i]=diag_jacTjac[i];
|
||||
|
||||
if(info){
|
||||
info[0]=init_p_eL2;
|
||||
info[1]=p_eL2;
|
||||
info[2]=jacTe_inf;
|
||||
info[3]=Dp_L2;
|
||||
for(i=0, tmp=LM_REAL_MIN; i<m; ++i)
|
||||
if(tmp<jacTjac[i*m+i]) tmp=jacTjac[i*m+i];
|
||||
info[4]=mu/tmp;
|
||||
info[5]=(LM_REAL)k;
|
||||
info[6]=(LM_REAL)stop;
|
||||
info[7]=(LM_REAL)nfev;
|
||||
info[8]=(LM_REAL)njap;
|
||||
info[9]=(LM_REAL)nlss;
|
||||
}
|
||||
|
||||
/* covariance matrix */
|
||||
if(covar){
|
||||
LEVMAR_COVAR(jacTjac, covar, p_eL2, m, n);
|
||||
}
|
||||
|
||||
|
||||
if(freework) free(work);
|
||||
|
||||
#ifdef LINSOLVERS_RETAIN_MEMORY
|
||||
if(linsolver) (*linsolver)(NULL, NULL, NULL, 0);
|
||||
#endif
|
||||
|
||||
return (stop!=4 && stop!=7)? k : LM_ERROR;
|
||||
}
|
||||
|
||||
/* undefine everything. THIS MUST REMAIN AT THE END OF THE FILE */
|
||||
#undef LEVMAR_DER
|
||||
#undef LEVMAR_DIF
|
||||
#undef LEVMAR_FDIF_FORW_JAC_APPROX
|
||||
#undef LEVMAR_FDIF_CENT_JAC_APPROX
|
||||
#undef LEVMAR_COVAR
|
||||
#undef LEVMAR_TRANS_MAT_MAT_MULT
|
||||
#undef LEVMAR_L2NRMXMY
|
||||
#undef AX_EQ_B_LU
|
||||
#undef AX_EQ_B_CHOL
|
||||
#undef AX_EQ_B_PLASMA_CHOL
|
||||
#undef AX_EQ_B_QR
|
||||
#undef AX_EQ_B_QRLS
|
||||
#undef AX_EQ_B_SVD
|
||||
#undef AX_EQ_B_BK
|
||||
87
contrib/levmar/lmbc.c
Normal file
87
contrib/levmar/lmbc.c
Normal file
@@ -0,0 +1,87 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Levenberg - Marquardt non-linear minimization algorithm
|
||||
// Copyright (C) 2004-05 Manolis Lourakis (lourakis at ics forth gr)
|
||||
// Institute of Computer Science, Foundation for Research & Technology - Hellas
|
||||
// Heraklion, Crete, Greece.
|
||||
//
|
||||
// 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 2 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/********************************************************************************
|
||||
* Box-constrained Levenberg-Marquardt nonlinear minimization. The same core code
|
||||
* is used with appropriate #defines to derive single and double precision versions,
|
||||
* see also lmbc_core.c
|
||||
********************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
|
||||
#include "levmar.h"
|
||||
#include "compiler.h"
|
||||
#include "misc.h"
|
||||
|
||||
#define EPSILON 1E-12
|
||||
#define ONE_THIRD 0.3333333334 /* 1.0/3.0 */
|
||||
#define _LSITMAX_ 150 /* max #iterations for line search */
|
||||
#define _POW_ 2.1
|
||||
|
||||
#if !defined(LM_DBL_PREC) && !defined(LM_SNGL_PREC)
|
||||
#error At least one of LM_DBL_PREC, LM_SNGL_PREC should be defined!
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef LM_SNGL_PREC
|
||||
/* single precision (float) definitions */
|
||||
#define LM_REAL float
|
||||
#define LM_PREFIX s
|
||||
|
||||
#define LM_REAL_MAX FLT_MAX
|
||||
#define LM_REAL_MIN -FLT_MAX
|
||||
|
||||
#define LM_REAL_EPSILON FLT_EPSILON
|
||||
#define __SUBCNST(x) x##F
|
||||
#define LM_CNST(x) __SUBCNST(x) // force substitution
|
||||
|
||||
#include "lmbc_core.c" // read in core code
|
||||
|
||||
#undef LM_REAL
|
||||
#undef LM_PREFIX
|
||||
#undef LM_REAL_MAX
|
||||
#undef LM_REAL_MIN
|
||||
#undef LM_REAL_EPSILON
|
||||
#undef __SUBCNST
|
||||
#undef LM_CNST
|
||||
#endif /* LM_SNGL_PREC */
|
||||
|
||||
#ifdef LM_DBL_PREC
|
||||
/* double precision definitions */
|
||||
#define LM_REAL double
|
||||
#define LM_PREFIX d
|
||||
|
||||
#define LM_REAL_MAX DBL_MAX
|
||||
#define LM_REAL_MIN -DBL_MAX
|
||||
|
||||
#define LM_REAL_EPSILON DBL_EPSILON
|
||||
#define LM_CNST(x) (x)
|
||||
|
||||
#include "lmbc_core.c" // read in core code
|
||||
|
||||
#undef LM_REAL
|
||||
#undef LM_PREFIX
|
||||
#undef LM_REAL_MAX
|
||||
#undef LM_REAL_MIN
|
||||
#undef LM_REAL_EPSILON
|
||||
#undef LM_CNST
|
||||
#endif /* LM_DBL_PREC */
|
||||
1154
contrib/levmar/lmbc_core.c
Normal file
1154
contrib/levmar/lmbc_core.c
Normal file
File diff suppressed because it is too large
Load Diff
87
contrib/levmar/lmblec.c
Normal file
87
contrib/levmar/lmblec.c
Normal file
@@ -0,0 +1,87 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Levenberg - Marquardt non-linear minimization algorithm
|
||||
// Copyright (C) 2004-06 Manolis Lourakis (lourakis at ics forth gr)
|
||||
// Institute of Computer Science, Foundation for Research & Technology - Hellas
|
||||
// Heraklion, Crete, Greece.
|
||||
//
|
||||
// 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 2 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/********************************************************************************
|
||||
* combined box and linear equation constraints Levenberg-Marquardt nonlinear
|
||||
* minimization. The same core code is used with appropriate #defines to derive
|
||||
* single and double precision versions, see also lmblec_core.c
|
||||
********************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
|
||||
#include "levmar.h"
|
||||
#include "misc.h"
|
||||
|
||||
#ifndef HAVE_LAPACK
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma message("Combined box and linearly constrained optimization requires LAPACK and was not compiled!")
|
||||
#else
|
||||
#warning Combined box and linearly constrained optimization requires LAPACK and was not compiled!
|
||||
#endif // _MSC_VER
|
||||
|
||||
#else // LAPACK present
|
||||
|
||||
#if !defined(LM_DBL_PREC) && !defined(LM_SNGL_PREC)
|
||||
#error At least one of LM_DBL_PREC, LM_SNGL_PREC should be defined!
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef LM_SNGL_PREC
|
||||
/* single precision (float) definitions */
|
||||
#define LM_REAL float
|
||||
#define LM_PREFIX s
|
||||
|
||||
#define LM_REAL_MAX FLT_MAX
|
||||
#define LM_REAL_MIN -FLT_MAX
|
||||
#define __SUBCNST(x) x##F
|
||||
#define LM_CNST(x) __SUBCNST(x) // force substitution
|
||||
|
||||
#include "lmblec_core.c" // read in core code
|
||||
|
||||
#undef LM_REAL
|
||||
#undef LM_PREFIX
|
||||
#undef LM_REAL_MAX
|
||||
#undef LM_REAL_MIN
|
||||
#undef __SUBCNST
|
||||
#undef LM_CNST
|
||||
#endif /* LM_SNGL_PREC */
|
||||
|
||||
#ifdef LM_DBL_PREC
|
||||
/* double precision definitions */
|
||||
#define LM_REAL double
|
||||
#define LM_PREFIX d
|
||||
|
||||
#define LM_REAL_MAX DBL_MAX
|
||||
#define LM_REAL_MIN -DBL_MAX
|
||||
#define LM_CNST(x) (x)
|
||||
|
||||
#include "lmblec_core.c" // read in core code
|
||||
|
||||
#undef LM_REAL
|
||||
#undef LM_PREFIX
|
||||
#undef LM_REAL_MAX
|
||||
#undef LM_REAL_MIN
|
||||
#undef LM_CNST
|
||||
#endif /* LM_DBL_PREC */
|
||||
|
||||
#endif /* HAVE_LAPACK */
|
||||
413
contrib/levmar/lmblec_core.c
Normal file
413
contrib/levmar/lmblec_core.c
Normal file
@@ -0,0 +1,413 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Levenberg - Marquardt non-linear minimization algorithm
|
||||
// Copyright (C) 2004-06 Manolis Lourakis (lourakis at ics forth gr)
|
||||
// Institute of Computer Science, Foundation for Research & Technology - Hellas
|
||||
// Heraklion, Crete, Greece.
|
||||
//
|
||||
// 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 2 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*******************************************************************************
|
||||
* This file implements combined box and linear equation constraints.
|
||||
*
|
||||
* Note that the algorithm implementing linearly constrained minimization does
|
||||
* so by a change in parameters that transforms the original program into an
|
||||
* unconstrained one. To employ the same idea for implementing box & linear
|
||||
* constraints would require the transformation of box constraints on the
|
||||
* original parameters to box constraints for the new parameter set. This
|
||||
* being impossible, a different approach is used here for finding the minimum.
|
||||
* The trick is to remove the box constraints by augmenting the function to
|
||||
* be fitted with penalty terms and then solve the resulting problem (which
|
||||
* involves linear constrains only) with the functions in lmlec.c
|
||||
*
|
||||
* More specifically, for the constraint a<=x[i]<=b to hold, the term C[i]=
|
||||
* (2*x[i]-(a+b))/(b-a) should be within [-1, 1]. This is enforced by adding
|
||||
* the penalty term w[i]*max((C[i])^2-1, 0) to the objective function, where
|
||||
* w[i] is a large weight. In the case of constraints of the form a<=x[i],
|
||||
* the term C[i]=a-x[i] has to be non positive, thus the penalty term is
|
||||
* w[i]*max(C[i], 0). If x[i]<=b, C[i]=x[i]-b has to be non negative and
|
||||
* the penalty is w[i]*max(C[i], 0). The derivatives needed for the Jacobian
|
||||
* are as follows:
|
||||
* For the constraint a<=x[i]<=b: 4*(2*x[i]-(a+b))/(b-a)^2 if x[i] not in [a, b],
|
||||
* 0 otherwise
|
||||
* For the constraint a<=x[i]: -1 if x[i]<=a, 0 otherwise
|
||||
* For the constraint x[i]<=b: 1 if b<=x[i], 0 otherwise
|
||||
*
|
||||
* Note that for the above to work, the weights w[i] should be large enough;
|
||||
* depending on your minimization problem, the default values might need some
|
||||
* tweaking (see arg "wghts" below).
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef LM_REAL // not included by lmblec.c
|
||||
#error This file should not be compiled directly!
|
||||
#endif
|
||||
|
||||
|
||||
#define __MAX__(x, y) (((x)>=(y))? (x) : (y))
|
||||
#define __BC_WEIGHT__ LM_CNST(1E+04)
|
||||
|
||||
#define __BC_INTERVAL__ 0
|
||||
#define __BC_LOW__ 1
|
||||
#define __BC_HIGH__ 2
|
||||
|
||||
/* precision-specific definitions */
|
||||
#define LEVMAR_BOX_CHECK LM_ADD_PREFIX(levmar_box_check)
|
||||
#define LMBLEC_DATA LM_ADD_PREFIX(lmblec_data)
|
||||
#define LMBLEC_FUNC LM_ADD_PREFIX(lmblec_func)
|
||||
#define LMBLEC_JACF LM_ADD_PREFIX(lmblec_jacf)
|
||||
#define LEVMAR_LEC_DER LM_ADD_PREFIX(levmar_lec_der)
|
||||
#define LEVMAR_LEC_DIF LM_ADD_PREFIX(levmar_lec_dif)
|
||||
#define LEVMAR_BLEC_DER LM_ADD_PREFIX(levmar_blec_der)
|
||||
#define LEVMAR_BLEC_DIF LM_ADD_PREFIX(levmar_blec_dif)
|
||||
#define LEVMAR_COVAR LM_ADD_PREFIX(levmar_covar)
|
||||
|
||||
struct LMBLEC_DATA{
|
||||
LM_REAL *x, *lb, *ub, *w;
|
||||
int *bctype;
|
||||
void (*func)(LM_REAL *p, LM_REAL *hx, int m, int n, void *adata);
|
||||
void (*jacf)(LM_REAL *p, LM_REAL *jac, int m, int n, void *adata);
|
||||
void *adata;
|
||||
};
|
||||
|
||||
/* augmented measurements */
|
||||
static void LMBLEC_FUNC(LM_REAL *p, LM_REAL *hx, int m, int n, void *adata)
|
||||
{
|
||||
struct LMBLEC_DATA *data=(struct LMBLEC_DATA *)adata;
|
||||
int nn;
|
||||
register int i, j, *typ;
|
||||
register LM_REAL *lb, *ub, *w, tmp;
|
||||
|
||||
nn=n-m;
|
||||
lb=data->lb;
|
||||
ub=data->ub;
|
||||
w=data->w;
|
||||
typ=data->bctype;
|
||||
(*(data->func))(p, hx, m, nn, data->adata);
|
||||
|
||||
for(i=nn, j=0; i<n; ++i, ++j){
|
||||
switch(typ[j]){
|
||||
case __BC_INTERVAL__:
|
||||
tmp=(LM_CNST(2.0)*p[j]-(lb[j]+ub[j]))/(ub[j]-lb[j]);
|
||||
hx[i]=w[j]*__MAX__(tmp*tmp-LM_CNST(1.0), LM_CNST(0.0));
|
||||
break;
|
||||
|
||||
case __BC_LOW__:
|
||||
hx[i]=w[j]*__MAX__(lb[j]-p[j], LM_CNST(0.0));
|
||||
break;
|
||||
|
||||
case __BC_HIGH__:
|
||||
hx[i]=w[j]*__MAX__(p[j]-ub[j], LM_CNST(0.0));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* augmented Jacobian */
|
||||
static void LMBLEC_JACF(LM_REAL *p, LM_REAL *jac, int m, int n, void *adata)
|
||||
{
|
||||
struct LMBLEC_DATA *data=(struct LMBLEC_DATA *)adata;
|
||||
int nn, *typ;
|
||||
register int i, j;
|
||||
register LM_REAL *lb, *ub, *w, tmp;
|
||||
|
||||
nn=n-m;
|
||||
lb=data->lb;
|
||||
ub=data->ub;
|
||||
w=data->w;
|
||||
typ=data->bctype;
|
||||
(*(data->jacf))(p, jac, m, nn, data->adata);
|
||||
|
||||
/* clear all extra rows */
|
||||
for(i=nn*m; i<n*m; ++i)
|
||||
jac[i]=0.0;
|
||||
|
||||
for(i=nn, j=0; i<n; ++i, ++j){
|
||||
switch(typ[j]){
|
||||
case __BC_INTERVAL__:
|
||||
if(lb[j]<=p[j] && p[j]<=ub[j])
|
||||
continue; // corresp. jac element already 0
|
||||
|
||||
/* out of interval */
|
||||
tmp=ub[j]-lb[j];
|
||||
tmp=LM_CNST(4.0)*(LM_CNST(2.0)*p[j]-(lb[j]+ub[j]))/(tmp*tmp);
|
||||
jac[i*m+j]=w[j]*tmp;
|
||||
break;
|
||||
|
||||
case __BC_LOW__: // (lb[j]<=p[j])? 0.0 : -1.0;
|
||||
if(lb[j]<=p[j])
|
||||
continue; // corresp. jac element already 0
|
||||
|
||||
/* smaller than lower bound */
|
||||
jac[i*m+j]=-w[j];
|
||||
break;
|
||||
|
||||
case __BC_HIGH__: // (p[j]<=ub[j])? 0.0 : 1.0;
|
||||
if(p[j]<=ub[j])
|
||||
continue; // corresp. jac element already 0
|
||||
|
||||
/* greater than upper bound */
|
||||
jac[i*m+j]=w[j];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* This function seeks the parameter vector p that best describes the measurements
|
||||
* vector x under box & linear constraints.
|
||||
* More precisely, given a vector function func : R^m --> R^n with n>=m,
|
||||
* it finds p s.t. func(p) ~= x, i.e. the squared second order (i.e. L2) norm of
|
||||
* e=x-func(p) is minimized under the constraints lb[i]<=p[i]<=ub[i] and A p=b;
|
||||
* A is kxm, b kx1. Note that this function DOES NOT check the satisfiability of
|
||||
* the specified box and linear equation constraints.
|
||||
* If no lower bound constraint applies for p[i], use -DBL_MAX/-FLT_MAX for lb[i];
|
||||
* If no upper bound constraint applies for p[i], use DBL_MAX/FLT_MAX for ub[i].
|
||||
*
|
||||
* This function requires an analytic Jacobian. In case the latter is unavailable,
|
||||
* use LEVMAR_BLEC_DIF() bellow
|
||||
*
|
||||
* Returns the number of iterations (>=0) if successful, LM_ERROR if failed
|
||||
*
|
||||
* For more details on the algorithm implemented by this function, please refer to
|
||||
* the comments in the top of this file.
|
||||
*
|
||||
*/
|
||||
int LEVMAR_BLEC_DER(
|
||||
void (*func)(LM_REAL *p, LM_REAL *hx, int m, int n, void *adata), /* functional relation describing measurements. A p \in R^m yields a \hat{x} \in R^n */
|
||||
void (*jacf)(LM_REAL *p, LM_REAL *j, int m, int n, void *adata), /* function to evaluate the Jacobian \part x / \part p */
|
||||
LM_REAL *p, /* I/O: initial parameter estimates. On output has the estimated solution */
|
||||
LM_REAL *x, /* I: measurement vector. NULL implies a zero vector */
|
||||
int m, /* I: parameter vector dimension (i.e. #unknowns) */
|
||||
int n, /* I: measurement vector dimension */
|
||||
LM_REAL *lb, /* I: vector of lower bounds. If NULL, no lower bounds apply */
|
||||
LM_REAL *ub, /* I: vector of upper bounds. If NULL, no upper bounds apply */
|
||||
LM_REAL *A, /* I: constraints matrix, kxm */
|
||||
LM_REAL *b, /* I: right hand constraints vector, kx1 */
|
||||
int k, /* I: number of constraints (i.e. A's #rows) */
|
||||
LM_REAL *wghts, /* mx1 weights for penalty terms, defaults used if NULL */
|
||||
int itmax, /* I: maximum number of iterations */
|
||||
LM_REAL opts[4], /* I: minim. options [\mu, \epsilon1, \epsilon2, \epsilon3]. Respectively the scale factor for initial \mu,
|
||||
* stopping thresholds for ||J^T e||_inf, ||Dp||_2 and ||e||_2. Set to NULL for defaults to be used
|
||||
*/
|
||||
LM_REAL info[LM_INFO_SZ],
|
||||
/* O: information regarding the minimization. Set to NULL if don't care
|
||||
* info[0]= ||e||_2 at initial p.
|
||||
* info[1-4]=[ ||e||_2, ||J^T e||_inf, ||Dp||_2, mu/max[J^T J]_ii ], all computed at estimated p.
|
||||
* info[5]= # iterations,
|
||||
* info[6]=reason for terminating: 1 - stopped by small gradient J^T e
|
||||
* 2 - stopped by small Dp
|
||||
* 3 - stopped by itmax
|
||||
* 4 - singular matrix. Restart from current p with increased mu
|
||||
* 5 - no further error reduction is possible. Restart with increased mu
|
||||
* 6 - stopped by small ||e||_2
|
||||
* 7 - stopped by invalid (i.e. NaN or Inf) "func" values. This is a user error
|
||||
* info[7]= # function evaluations
|
||||
* info[8]= # Jacobian evaluations
|
||||
* info[9]= # linear systems solved, i.e. # attempts for reducing error
|
||||
*/
|
||||
LM_REAL *work, /* working memory at least LM_BLEC_DER_WORKSZ() reals large, allocated if NULL */
|
||||
LM_REAL *covar, /* O: Covariance matrix corresponding to LS solution; mxm. Set to NULL if not needed. */
|
||||
void *adata) /* pointer to possibly additional data, passed uninterpreted to func & jacf.
|
||||
* Set to NULL if not needed
|
||||
*/
|
||||
{
|
||||
struct LMBLEC_DATA data;
|
||||
int ret;
|
||||
LM_REAL locinfo[LM_INFO_SZ];
|
||||
register int i;
|
||||
|
||||
if(!jacf){
|
||||
fprintf(stderr, RCAT("No function specified for computing the Jacobian in ", LEVMAR_BLEC_DER)
|
||||
RCAT("().\nIf no such function is available, use ", LEVMAR_BLEC_DIF) RCAT("() rather than ", LEVMAR_BLEC_DER) "()\n");
|
||||
return LM_ERROR;
|
||||
}
|
||||
|
||||
if(!lb && !ub){
|
||||
fprintf(stderr, RCAT(LCAT(LEVMAR_BLEC_DER, "(): lower and upper bounds for box constraints cannot be both NULL, use "),
|
||||
LEVMAR_LEC_DER) "() in this case!\n");
|
||||
return LM_ERROR;
|
||||
}
|
||||
|
||||
if(!LEVMAR_BOX_CHECK(lb, ub, m)){
|
||||
fprintf(stderr, LCAT(LEVMAR_BLEC_DER, "(): at least one lower bound exceeds the upper one\n"));
|
||||
return LM_ERROR;
|
||||
}
|
||||
|
||||
/* measurement vector needs to be extended by m */
|
||||
if(x){ /* nonzero x */
|
||||
data.x=(LM_REAL *)malloc((n+m)*sizeof(LM_REAL));
|
||||
if(!data.x){
|
||||
fprintf(stderr, LCAT(LEVMAR_BLEC_DER, "(): memory allocation request #1 failed\n"));
|
||||
return LM_ERROR;
|
||||
}
|
||||
|
||||
for(i=0; i<n; ++i)
|
||||
data.x[i]=x[i];
|
||||
for(i=n; i<n+m; ++i)
|
||||
data.x[i]=0.0;
|
||||
}
|
||||
else
|
||||
data.x=NULL;
|
||||
|
||||
data.w=(LM_REAL *)malloc(m*sizeof(LM_REAL) + m*sizeof(int)); /* should be arranged in that order for proper doubles alignment */
|
||||
if(!data.w){
|
||||
fprintf(stderr, LCAT(LEVMAR_BLEC_DER, "(): memory allocation request #2 failed\n"));
|
||||
if(data.x) free(data.x);
|
||||
return LM_ERROR;
|
||||
}
|
||||
data.bctype=(int *)(data.w+m);
|
||||
|
||||
/* note: at this point, one of lb, ub are not NULL */
|
||||
for(i=0; i<m; ++i){
|
||||
data.w[i]=(!wghts)? __BC_WEIGHT__ : wghts[i];
|
||||
if(!lb) data.bctype[i]=__BC_HIGH__;
|
||||
else if(!ub) data.bctype[i]=__BC_LOW__;
|
||||
else if(ub[i]!=LM_REAL_MAX && lb[i]!=LM_REAL_MIN) data.bctype[i]=__BC_INTERVAL__;
|
||||
else if(lb[i]!=LM_REAL_MIN) data.bctype[i]=__BC_LOW__;
|
||||
else data.bctype[i]=__BC_HIGH__;
|
||||
}
|
||||
|
||||
data.lb=lb;
|
||||
data.ub=ub;
|
||||
data.func=func;
|
||||
data.jacf=jacf;
|
||||
data.adata=adata;
|
||||
|
||||
if(!info) info=locinfo; /* make sure that LEVMAR_LEC_DER() is called with non-null info */
|
||||
ret=LEVMAR_LEC_DER(LMBLEC_FUNC, LMBLEC_JACF, p, data.x, m, n+m, A, b, k, itmax, opts, info, work, covar, (void *)&data);
|
||||
|
||||
if(data.x) free(data.x);
|
||||
free(data.w);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Similar to the LEVMAR_BLEC_DER() function above, except that the Jacobian is approximated
|
||||
* with the aid of finite differences (forward or central, see the comment for the opts argument)
|
||||
*/
|
||||
int LEVMAR_BLEC_DIF(
|
||||
void (*func)(LM_REAL *p, LM_REAL *hx, int m, int n, void *adata), /* functional relation describing measurements. A p \in R^m yields a \hat{x} \in R^n */
|
||||
LM_REAL *p, /* I/O: initial parameter estimates. On output has the estimated solution */
|
||||
LM_REAL *x, /* I: measurement vector. NULL implies a zero vector */
|
||||
int m, /* I: parameter vector dimension (i.e. #unknowns) */
|
||||
int n, /* I: measurement vector dimension */
|
||||
LM_REAL *lb, /* I: vector of lower bounds. If NULL, no lower bounds apply */
|
||||
LM_REAL *ub, /* I: vector of upper bounds. If NULL, no upper bounds apply */
|
||||
LM_REAL *A, /* I: constraints matrix, kxm */
|
||||
LM_REAL *b, /* I: right hand constraints vector, kx1 */
|
||||
int k, /* I: number of constraints (i.e. A's #rows) */
|
||||
LM_REAL *wghts, /* mx1 weights for penalty terms, defaults used if NULL */
|
||||
int itmax, /* I: maximum number of iterations */
|
||||
LM_REAL opts[5], /* I: opts[0-3] = minim. options [\mu, \epsilon1, \epsilon2, \epsilon3, \delta]. Respectively the
|
||||
* scale factor for initial \mu, stopping thresholds for ||J^T e||_inf, ||Dp||_2 and ||e||_2 and
|
||||
* the step used in difference approximation to the Jacobian. Set to NULL for defaults to be used.
|
||||
* If \delta<0, the Jacobian is approximated with central differences which are more accurate
|
||||
* (but slower!) compared to the forward differences employed by default.
|
||||
*/
|
||||
LM_REAL info[LM_INFO_SZ],
|
||||
/* O: information regarding the minimization. Set to NULL if don't care
|
||||
* info[0]= ||e||_2 at initial p.
|
||||
* info[1-4]=[ ||e||_2, ||J^T e||_inf, ||Dp||_2, mu/max[J^T J]_ii ], all computed at estimated p.
|
||||
* info[5]= # iterations,
|
||||
* info[6]=reason for terminating: 1 - stopped by small gradient J^T e
|
||||
* 2 - stopped by small Dp
|
||||
* 3 - stopped by itmax
|
||||
* 4 - singular matrix. Restart from current p with increased mu
|
||||
* 5 - no further error reduction is possible. Restart with increased mu
|
||||
* 6 - stopped by small ||e||_2
|
||||
* 7 - stopped by invalid (i.e. NaN or Inf) "func" values. This is a user error
|
||||
* info[7]= # function evaluations
|
||||
* info[8]= # Jacobian evaluations
|
||||
* info[9]= # linear systems solved, i.e. # attempts for reducing error
|
||||
*/
|
||||
LM_REAL *work, /* working memory at least LM_BLEC_DIF_WORKSZ() reals large, allocated if NULL */
|
||||
LM_REAL *covar, /* O: Covariance matrix corresponding to LS solution; mxm. Set to NULL if not needed. */
|
||||
void *adata) /* pointer to possibly additional data, passed uninterpreted to func.
|
||||
* Set to NULL if not needed
|
||||
*/
|
||||
{
|
||||
struct LMBLEC_DATA data;
|
||||
int ret;
|
||||
register int i;
|
||||
LM_REAL locinfo[LM_INFO_SZ];
|
||||
|
||||
if(!lb && !ub){
|
||||
fprintf(stderr, RCAT(LCAT(LEVMAR_BLEC_DIF, "(): lower and upper bounds for box constraints cannot be both NULL, use "),
|
||||
LEVMAR_LEC_DIF) "() in this case!\n");
|
||||
return LM_ERROR;
|
||||
}
|
||||
|
||||
if(!LEVMAR_BOX_CHECK(lb, ub, m)){
|
||||
fprintf(stderr, LCAT(LEVMAR_BLEC_DER, "(): at least one lower bound exceeds the upper one\n"));
|
||||
return LM_ERROR;
|
||||
}
|
||||
|
||||
/* measurement vector needs to be extended by m */
|
||||
if(x){ /* nonzero x */
|
||||
data.x=(LM_REAL *)malloc((n+m)*sizeof(LM_REAL));
|
||||
if(!data.x){
|
||||
fprintf(stderr, LCAT(LEVMAR_BLEC_DER, "(): memory allocation request #1 failed\n"));
|
||||
return LM_ERROR;
|
||||
}
|
||||
|
||||
for(i=0; i<n; ++i)
|
||||
data.x[i]=x[i];
|
||||
for(i=n; i<n+m; ++i)
|
||||
data.x[i]=0.0;
|
||||
}
|
||||
else
|
||||
data.x=NULL;
|
||||
|
||||
data.w=(LM_REAL *)malloc(m*sizeof(LM_REAL) + m*sizeof(int)); /* should be arranged in that order for proper doubles alignment */
|
||||
if(!data.w){
|
||||
fprintf(stderr, LCAT(LEVMAR_BLEC_DER, "(): memory allocation request #2 failed\n"));
|
||||
if(data.x) free(data.x);
|
||||
return LM_ERROR;
|
||||
}
|
||||
data.bctype=(int *)(data.w+m);
|
||||
|
||||
/* note: at this point, one of lb, ub are not NULL */
|
||||
for(i=0; i<m; ++i){
|
||||
data.w[i]=(!wghts)? __BC_WEIGHT__ : wghts[i];
|
||||
if(!lb) data.bctype[i]=__BC_HIGH__;
|
||||
else if(!ub) data.bctype[i]=__BC_LOW__;
|
||||
else if(ub[i]!=LM_REAL_MAX && lb[i]!=LM_REAL_MIN) data.bctype[i]=__BC_INTERVAL__;
|
||||
else if(lb[i]!=LM_REAL_MIN) data.bctype[i]=__BC_LOW__;
|
||||
else data.bctype[i]=__BC_HIGH__;
|
||||
}
|
||||
|
||||
data.lb=lb;
|
||||
data.ub=ub;
|
||||
data.func=func;
|
||||
data.jacf=NULL;
|
||||
data.adata=adata;
|
||||
|
||||
if(!info) info=locinfo; /* make sure that LEVMAR_LEC_DIF() is called with non-null info */
|
||||
ret=LEVMAR_LEC_DIF(LMBLEC_FUNC, p, data.x, m, n+m, A, b, k, itmax, opts, info, work, covar, (void *)&data);
|
||||
|
||||
if(data.x) free(data.x);
|
||||
free(data.w);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* undefine all. THIS MUST REMAIN AT THE END OF THE FILE */
|
||||
#undef LEVMAR_BOX_CHECK
|
||||
#undef LMBLEC_DATA
|
||||
#undef LMBLEC_FUNC
|
||||
#undef LMBLEC_JACF
|
||||
#undef LEVMAR_COVAR
|
||||
#undef LEVMAR_LEC_DER
|
||||
#undef LEVMAR_LEC_DIF
|
||||
#undef LEVMAR_BLEC_DER
|
||||
#undef LEVMAR_BLEC_DIF
|
||||
89
contrib/levmar/lmbleic.c
Normal file
89
contrib/levmar/lmbleic.c
Normal file
@@ -0,0 +1,89 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Levenberg - Marquardt non-linear minimization algorithm
|
||||
// Copyright (C) 2009 Manolis Lourakis (lourakis at ics forth gr)
|
||||
// Institute of Computer Science, Foundation for Research & Technology - Hellas
|
||||
// Heraklion, Crete, Greece.
|
||||
//
|
||||
// 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 2 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*******************************************************************************
|
||||
* Wrappers for linear inequality constrained Levenberg-Marquardt minimization.
|
||||
* The same core code is used with appropriate #defines to derive single and
|
||||
* double precision versions, see also lmbleic_core.c
|
||||
*******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
|
||||
#include "levmar.h"
|
||||
#include "misc.h"
|
||||
|
||||
|
||||
#ifndef HAVE_LAPACK
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma message("Linear inequalities constrained optimization requires LAPACK and was not compiled!")
|
||||
#else
|
||||
#warning Linear inequalities constrained optimization requires LAPACK and was not compiled!
|
||||
#endif // _MSC_VER
|
||||
|
||||
#else // LAPACK present
|
||||
|
||||
#if !defined(LM_DBL_PREC) && !defined(LM_SNGL_PREC)
|
||||
#error At least one of LM_DBL_PREC, LM_SNGL_PREC should be defined!
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef LM_SNGL_PREC
|
||||
/* single precision (float) definitions */
|
||||
#define LM_REAL float
|
||||
#define LM_PREFIX s
|
||||
|
||||
#define LM_REAL_MAX FLT_MAX
|
||||
#define LM_REAL_MIN -FLT_MAX
|
||||
#define __SUBCNST(x) x##F
|
||||
#define LM_CNST(x) __SUBCNST(x) // force substitution
|
||||
|
||||
#include "lmbleic_core.c" // read in core code
|
||||
|
||||
#undef LM_REAL
|
||||
#undef LM_PREFIX
|
||||
#undef LM_REAL_MAX
|
||||
#undef LM_REAL_MIN
|
||||
#undef __SUBCNST
|
||||
#undef LM_CNST
|
||||
#endif /* LM_SNGL_PREC */
|
||||
|
||||
#ifdef LM_DBL_PREC
|
||||
/* double precision definitions */
|
||||
#define LM_REAL double
|
||||
#define LM_PREFIX d
|
||||
|
||||
#define LM_REAL_MAX DBL_MAX
|
||||
#define LM_REAL_MIN -DBL_MAX
|
||||
#define LM_CNST(x) (x)
|
||||
|
||||
#include "lmbleic_core.c" // read in core code
|
||||
|
||||
#undef LM_REAL
|
||||
#undef LM_PREFIX
|
||||
#undef LM_REAL_MAX
|
||||
#undef LM_REAL_MIN
|
||||
#undef LM_CNST
|
||||
#endif /* LM_DBL_PREC */
|
||||
|
||||
#endif /* HAVE_LAPACK */
|
||||
|
||||
506
contrib/levmar/lmbleic_core.c
Normal file
506
contrib/levmar/lmbleic_core.c
Normal file
@@ -0,0 +1,506 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Levenberg - Marquardt non-linear minimization algorithm
|
||||
// Copyright (C) 2009 Manolis Lourakis (lourakis at ics forth gr)
|
||||
// Institute of Computer Science, Foundation for Research & Technology - Hellas
|
||||
// Heraklion, Crete, Greece.
|
||||
//
|
||||
// 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 2 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef LM_REAL // not included by lmbleic.c
|
||||
#error This file should not be compiled directly!
|
||||
#endif
|
||||
|
||||
|
||||
/* precision-specific definitions */
|
||||
#define LMBLEIC_DATA LM_ADD_PREFIX(lmbleic_data)
|
||||
#define LMBLEIC_ELIM LM_ADD_PREFIX(lmbleic_elim)
|
||||
#define LMBLEIC_FUNC LM_ADD_PREFIX(lmbleic_func)
|
||||
#define LMBLEIC_JACF LM_ADD_PREFIX(lmbleic_jacf)
|
||||
#define LEVMAR_BLEIC_DER LM_ADD_PREFIX(levmar_bleic_der)
|
||||
#define LEVMAR_BLEIC_DIF LM_ADD_PREFIX(levmar_bleic_dif)
|
||||
#define LEVMAR_BLIC_DER LM_ADD_PREFIX(levmar_blic_der)
|
||||
#define LEVMAR_BLIC_DIF LM_ADD_PREFIX(levmar_blic_dif)
|
||||
#define LEVMAR_LEIC_DER LM_ADD_PREFIX(levmar_leic_der)
|
||||
#define LEVMAR_LEIC_DIF LM_ADD_PREFIX(levmar_leic_dif)
|
||||
#define LEVMAR_LIC_DER LM_ADD_PREFIX(levmar_lic_der)
|
||||
#define LEVMAR_LIC_DIF LM_ADD_PREFIX(levmar_lic_dif)
|
||||
#define LEVMAR_BLEC_DER LM_ADD_PREFIX(levmar_blec_der)
|
||||
#define LEVMAR_BLEC_DIF LM_ADD_PREFIX(levmar_blec_dif)
|
||||
#define LEVMAR_TRANS_MAT_MAT_MULT LM_ADD_PREFIX(levmar_trans_mat_mat_mult)
|
||||
#define LEVMAR_COVAR LM_ADD_PREFIX(levmar_covar)
|
||||
#define LEVMAR_FDIF_FORW_JAC_APPROX LM_ADD_PREFIX(levmar_fdif_forw_jac_approx)
|
||||
|
||||
struct LMBLEIC_DATA{
|
||||
LM_REAL *jac;
|
||||
int nineqcnstr; // #inequality constraints
|
||||
void (*func)(LM_REAL *p, LM_REAL *hx, int m, int n, void *adata);
|
||||
void (*jacf)(LM_REAL *p, LM_REAL *jac, int m, int n, void *adata);
|
||||
void *adata;
|
||||
};
|
||||
|
||||
|
||||
/* wrapper ensuring that the user-supplied function is called with the right number of variables (i.e. m) */
|
||||
static void LMBLEIC_FUNC(LM_REAL *pext, LM_REAL *hx, int mm, int n, void *adata)
|
||||
{
|
||||
struct LMBLEIC_DATA *data=(struct LMBLEIC_DATA *)adata;
|
||||
int m;
|
||||
|
||||
m=mm-data->nineqcnstr;
|
||||
(*(data->func))(pext, hx, m, n, data->adata);
|
||||
}
|
||||
|
||||
|
||||
/* wrapper for computing the Jacobian at pext. The Jacobian is nxmm */
|
||||
static void LMBLEIC_JACF(LM_REAL *pext, LM_REAL *jacext, int mm, int n, void *adata)
|
||||
{
|
||||
struct LMBLEIC_DATA *data=(struct LMBLEIC_DATA *)adata;
|
||||
int m;
|
||||
register int i, j;
|
||||
LM_REAL *jac, *jacim, *jacextimm;
|
||||
|
||||
m=mm-data->nineqcnstr;
|
||||
jac=data->jac;
|
||||
|
||||
(*(data->jacf))(pext, jac, m, n, data->adata);
|
||||
|
||||
for(i=0; i<n; ++i){
|
||||
jacextimm=jacext+i*mm;
|
||||
jacim=jac+i*m;
|
||||
for(j=0; j<m; ++j)
|
||||
jacextimm[j]=jacim[j]; //jacext[i*mm+j]=jac[i*m+j];
|
||||
|
||||
for(j=m; j<mm; ++j)
|
||||
jacextimm[j]=0.0; //jacext[i*mm+j]=0.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This function is similar to LEVMAR_DER except that the minimization is
|
||||
* performed subject to the box constraints lb[i]<=p[i]<=ub[i], the linear
|
||||
* equation constraints A*p=b, A being k1xm, b k1x1, and the linear inequality
|
||||
* constraints C*p>=d, C being k2xm, d k2x1.
|
||||
*
|
||||
* The inequalities are converted to equations by introducing surplus variables,
|
||||
* i.e. c^T*p >= d becomes c^T*p - y = d, with y>=0. To transform all inequalities
|
||||
* to equations, a total of k2 surplus variables are introduced; a problem with only
|
||||
* box and linear constraints results then and is solved with LEVMAR_BLEC_DER()
|
||||
* Note that opposite direction inequalities should be converted to the desired
|
||||
* direction by negating, i.e. c^T*p <= d becomes -c^T*p >= -d
|
||||
*
|
||||
* This function requires an analytic Jacobian. In case the latter is unavailable,
|
||||
* use LEVMAR_BLEIC_DIF() bellow
|
||||
*
|
||||
*/
|
||||
int LEVMAR_BLEIC_DER(
|
||||
void (*func)(LM_REAL *p, LM_REAL *hx, int m, int n, void *adata), /* functional relation describing measurements. A p \in R^m yields a \hat{x} \in R^n */
|
||||
void (*jacf)(LM_REAL *p, LM_REAL *j, int m, int n, void *adata), /* function to evaluate the Jacobian \part x / \part p */
|
||||
LM_REAL *p, /* I/O: initial parameter estimates. On output has the estimated solution */
|
||||
LM_REAL *x, /* I: measurement vector. NULL implies a zero vector */
|
||||
int m, /* I: parameter vector dimension (i.e. #unknowns) */
|
||||
int n, /* I: measurement vector dimension */
|
||||
LM_REAL *lb, /* I: vector of lower bounds. If NULL, no lower bounds apply */
|
||||
LM_REAL *ub, /* I: vector of upper bounds. If NULL, no upper bounds apply */
|
||||
LM_REAL *A, /* I: equality constraints matrix, k1xm. If NULL, no linear equation constraints apply */
|
||||
LM_REAL *b, /* I: right hand constraints vector, k1x1 */
|
||||
int k1, /* I: number of constraints (i.e. A's #rows) */
|
||||
LM_REAL *C, /* I: inequality constraints matrix, k2xm */
|
||||
LM_REAL *d, /* I: right hand constraints vector, k2x1 */
|
||||
int k2, /* I: number of inequality constraints (i.e. C's #rows) */
|
||||
int itmax, /* I: maximum number of iterations */
|
||||
LM_REAL opts[4], /* I: minim. options [\mu, \epsilon1, \epsilon2, \epsilon3]. Respectively the scale factor for initial \mu,
|
||||
* stopping thresholds for ||J^T e||_inf, ||Dp||_2 and ||e||_2. Set to NULL for defaults to be used
|
||||
*/
|
||||
LM_REAL info[LM_INFO_SZ],
|
||||
/* O: information regarding the minimization. Set to NULL if don't care
|
||||
* info[0]= ||e||_2 at initial p.
|
||||
* info[1-4]=[ ||e||_2, ||J^T e||_inf, ||Dp||_2, mu/max[J^T J]_ii ], all computed at estimated p.
|
||||
* info[5]= # iterations,
|
||||
* info[6]=reason for terminating: 1 - stopped by small gradient J^T e
|
||||
* 2 - stopped by small Dp
|
||||
* 3 - stopped by itmax
|
||||
* 4 - singular matrix. Restart from current p with increased mu
|
||||
* 5 - no further error reduction is possible. Restart with increased mu
|
||||
* 6 - stopped by small ||e||_2
|
||||
* 7 - stopped by invalid (i.e. NaN or Inf) "func" values. This is a user error
|
||||
* info[7]= # function evaluations
|
||||
* info[8]= # Jacobian evaluations
|
||||
* info[9]= # linear systems solved, i.e. # attempts for reducing error
|
||||
*/
|
||||
LM_REAL *work, /* working memory at least LM_BLEIC_DER_WORKSZ() reals large, allocated if NULL */
|
||||
LM_REAL *covar, /* O: Covariance matrix corresponding to LS solution; mxm. Set to NULL if not needed. */
|
||||
void *adata) /* pointer to possibly additional data, passed uninterpreted to func & jacf.
|
||||
* Set to NULL if not needed
|
||||
*/
|
||||
{
|
||||
struct LMBLEIC_DATA data;
|
||||
LM_REAL *ptr, *pext, *Aext, *bext, *covext; /* corresponding to p, A, b, covar for the full set of variables;
|
||||
pext=[p, surplus], pext is mm, Aext is (k1+k2)xmm, bext (k1+k2), covext is mmxmm
|
||||
*/
|
||||
LM_REAL *lbext, *ubext; // corresponding to lb, ub for the full set of variables
|
||||
int mm, ret, k12;
|
||||
register int i, j, ii;
|
||||
register LM_REAL tmp;
|
||||
LM_REAL locinfo[LM_INFO_SZ];
|
||||
|
||||
if(!jacf){
|
||||
fprintf(stderr, RCAT("No function specified for computing the Jacobian in ", LEVMAR_BLEIC_DER)
|
||||
RCAT("().\nIf no such function is available, use ", LEVMAR_BLEIC_DIF) RCAT("() rather than ", LEVMAR_BLEIC_DER) "()\n");
|
||||
return LM_ERROR;
|
||||
}
|
||||
|
||||
if(!C || !d){
|
||||
fprintf(stderr, RCAT(LCAT(LEVMAR_BLEIC_DER, "(): missing inequality constraints, use "), LEVMAR_BLEC_DER) "() in this case!\n");
|
||||
return LM_ERROR;
|
||||
}
|
||||
|
||||
if(!A || !b) k1=0; // sanity check
|
||||
|
||||
mm=m+k2;
|
||||
|
||||
if(n<m-k1){
|
||||
fprintf(stderr, LCAT(LEVMAR_BLEIC_DER, "(): cannot solve a problem with fewer measurements + equality constraints [%d + %d] than unknowns [%d]\n"), n, k1, m);
|
||||
return LM_ERROR;
|
||||
}
|
||||
|
||||
k12=k1+k2;
|
||||
ptr=(LM_REAL *)malloc((3*mm + k12*mm + k12 + n*m + (covar? mm*mm : 0))*sizeof(LM_REAL));
|
||||
if(!ptr){
|
||||
fprintf(stderr, LCAT(LEVMAR_BLEIC_DER, "(): memory allocation request failed\n"));
|
||||
return LM_ERROR;
|
||||
}
|
||||
pext=ptr;
|
||||
lbext=pext+mm;
|
||||
ubext=lbext+mm;
|
||||
Aext=ubext+mm;
|
||||
bext=Aext+k12*mm;
|
||||
data.jac=bext+k12;
|
||||
covext=covar? data.jac+n*m : NULL;
|
||||
data.nineqcnstr=k2;
|
||||
data.func=func;
|
||||
data.jacf=jacf;
|
||||
data.adata=adata;
|
||||
|
||||
/* compute y s.t. C*p - y=d, i.e. y=C*p-d.
|
||||
* y is stored in the last k2 elements of pext
|
||||
*/
|
||||
for(i=0; i<k2; ++i){
|
||||
for(j=0, tmp=0.0; j<m; ++j)
|
||||
tmp+=C[i*m+j]*p[j];
|
||||
pext[j=i+m]=tmp-d[i];
|
||||
|
||||
/* surplus variables must be >=0 */
|
||||
lbext[j]=0.0;
|
||||
ubext[j]=LM_REAL_MAX;
|
||||
}
|
||||
/* set the first m elements of pext equal to p */
|
||||
for(i=0; i<m; ++i){
|
||||
pext[i]=p[i];
|
||||
lbext[i]=lb? lb[i] : LM_REAL_MIN;
|
||||
ubext[i]=ub? ub[i] : LM_REAL_MAX;
|
||||
}
|
||||
|
||||
/* setup the constraints matrix */
|
||||
/* original linear equation constraints */
|
||||
for(i=0; i<k1; ++i){
|
||||
for(j=0; j<m; ++j)
|
||||
Aext[i*mm+j]=A[i*m+j];
|
||||
|
||||
for(j=m; j<mm; ++j)
|
||||
Aext[i*mm+j]=0.0;
|
||||
|
||||
bext[i]=b[i];
|
||||
}
|
||||
/* linear equation constraints resulting from surplus variables */
|
||||
for(i=0, ii=k1; i<k2; ++i, ++ii){
|
||||
for(j=0; j<m; ++j)
|
||||
Aext[ii*mm+j]=C[i*m+j];
|
||||
|
||||
for(j=m; j<mm; ++j)
|
||||
Aext[ii*mm+j]=0.0;
|
||||
|
||||
Aext[ii*mm+m+i]=-1.0;
|
||||
|
||||
bext[ii]=d[i];
|
||||
}
|
||||
|
||||
if(!info) info=locinfo; /* make sure that LEVMAR_BLEC_DER() is called with non-null info */
|
||||
/* note that the default weights for the penalty terms are being used below */
|
||||
ret=LEVMAR_BLEC_DER(LMBLEIC_FUNC, LMBLEIC_JACF, pext, x, mm, n, lbext, ubext, Aext, bext, k12, NULL, itmax, opts, info, work, covext, (void *)&data);
|
||||
|
||||
/* copy back the minimizer */
|
||||
for(i=0; i<m; ++i)
|
||||
p[i]=pext[i];
|
||||
|
||||
#if 0
|
||||
printf("Surplus variables for the minimizer:\n");
|
||||
for(i=m; i<mm; ++i)
|
||||
printf("%g ", pext[i]);
|
||||
printf("\n\n");
|
||||
#endif
|
||||
|
||||
if(covar){
|
||||
for(i=0; i<m; ++i){
|
||||
for(j=0; j<m; ++j)
|
||||
covar[i*m+j]=covext[i*mm+j];
|
||||
}
|
||||
}
|
||||
|
||||
free(ptr);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Similar to the LEVMAR_BLEIC_DER() function above, except that the Jacobian is approximated
|
||||
* with the aid of finite differences (forward or central, see the comment for the opts argument)
|
||||
*/
|
||||
int LEVMAR_BLEIC_DIF(
|
||||
void (*func)(LM_REAL *p, LM_REAL *hx, int m, int n, void *adata), /* functional relation describing measurements. A p \in R^m yields a \hat{x} \in R^n */
|
||||
LM_REAL *p, /* I/O: initial parameter estimates. On output has the estimated solution */
|
||||
LM_REAL *x, /* I: measurement vector. NULL implies a zero vector */
|
||||
int m, /* I: parameter vector dimension (i.e. #unknowns) */
|
||||
int n, /* I: measurement vector dimension */
|
||||
LM_REAL *lb, /* I: vector of lower bounds. If NULL, no lower bounds apply */
|
||||
LM_REAL *ub, /* I: vector of upper bounds. If NULL, no upper bounds apply */
|
||||
LM_REAL *A, /* I: equality constraints matrix, k1xm. If NULL, no linear equation constraints apply */
|
||||
LM_REAL *b, /* I: right hand constraints vector, k1x1 */
|
||||
int k1, /* I: number of constraints (i.e. A's #rows) */
|
||||
LM_REAL *C, /* I: inequality constraints matrix, k2xm */
|
||||
LM_REAL *d, /* I: right hand constraints vector, k2x1 */
|
||||
int k2, /* I: number of inequality constraints (i.e. C's #rows) */
|
||||
int itmax, /* I: maximum number of iterations */
|
||||
LM_REAL opts[5], /* I: opts[0-3] = minim. options [\mu, \epsilon1, \epsilon2, \epsilon3, \delta]. Respectively the
|
||||
* scale factor for initial \mu, stopping thresholds for ||J^T e||_inf, ||Dp||_2 and ||e||_2 and
|
||||
* the step used in difference approximation to the Jacobian. Set to NULL for defaults to be used.
|
||||
* If \delta<0, the Jacobian is approximated with central differences which are more accurate
|
||||
* (but slower!) compared to the forward differences employed by default.
|
||||
*/
|
||||
LM_REAL info[LM_INFO_SZ],
|
||||
/* O: information regarding the minimization. Set to NULL if don't care
|
||||
* info[0]= ||e||_2 at initial p.
|
||||
* info[1-4]=[ ||e||_2, ||J^T e||_inf, ||Dp||_2, mu/max[J^T J]_ii ], all computed at estimated p.
|
||||
* info[5]= # iterations,
|
||||
* info[6]=reason for terminating: 1 - stopped by small gradient J^T e
|
||||
* 2 - stopped by small Dp
|
||||
* 3 - stopped by itmax
|
||||
* 4 - singular matrix. Restart from current p with increased mu
|
||||
* 5 - no further error reduction is possible. Restart with increased mu
|
||||
* 6 - stopped by small ||e||_2
|
||||
* 7 - stopped by invalid (i.e. NaN or Inf) "func" values. This is a user error
|
||||
* info[7]= # function evaluations
|
||||
* info[8]= # Jacobian evaluations
|
||||
* info[9]= # linear systems solved, i.e. # attempts for reducing error
|
||||
*/
|
||||
LM_REAL *work, /* working memory at least LM_BLEIC_DIF_WORKSZ() reals large, allocated if NULL */
|
||||
LM_REAL *covar, /* O: Covariance matrix corresponding to LS solution; mxm. Set to NULL if not needed. */
|
||||
void *adata) /* pointer to possibly additional data, passed uninterpreted to func.
|
||||
* Set to NULL if not needed
|
||||
*/
|
||||
{
|
||||
struct LMBLEIC_DATA data;
|
||||
LM_REAL *ptr, *pext, *Aext, *bext, *covext; /* corresponding to p, A, b, covar for the full set of variables;
|
||||
pext=[p, surplus], pext is mm, Aext is (k1+k2)xmm, bext (k1+k2), covext is mmxmm
|
||||
*/
|
||||
LM_REAL *lbext, *ubext; // corresponding to lb, ub for the full set of variables
|
||||
int mm, ret, k12;
|
||||
register int i, j, ii;
|
||||
register LM_REAL tmp;
|
||||
LM_REAL locinfo[LM_INFO_SZ];
|
||||
|
||||
if(!C || !d){
|
||||
fprintf(stderr, RCAT(LCAT(LEVMAR_BLEIC_DIF, "(): missing inequality constraints, use "), LEVMAR_BLEC_DIF) "() in this case!\n");
|
||||
return LM_ERROR;
|
||||
}
|
||||
if(!A || !b) k1=0; // sanity check
|
||||
|
||||
mm=m+k2;
|
||||
|
||||
if(n<m-k1){
|
||||
fprintf(stderr, LCAT(LEVMAR_BLEIC_DIF, "(): cannot solve a problem with fewer measurements + equality constraints [%d + %d] than unknowns [%d]\n"), n, k1, m);
|
||||
return LM_ERROR;
|
||||
}
|
||||
|
||||
k12=k1+k2;
|
||||
ptr=(LM_REAL *)malloc((3*mm + k12*mm + k12 + (covar? mm*mm : 0))*sizeof(LM_REAL));
|
||||
if(!ptr){
|
||||
fprintf(stderr, LCAT(LEVMAR_BLEIC_DIF, "(): memory allocation request failed\n"));
|
||||
return LM_ERROR;
|
||||
}
|
||||
pext=ptr;
|
||||
lbext=pext+mm;
|
||||
ubext=lbext+mm;
|
||||
Aext=ubext+mm;
|
||||
bext=Aext+k12*mm;
|
||||
data.jac=NULL;
|
||||
covext=covar? bext+k12 : NULL;
|
||||
data.nineqcnstr=k2;
|
||||
data.func=func;
|
||||
data.jacf=NULL;
|
||||
data.adata=adata;
|
||||
|
||||
/* compute y s.t. C*p - y=d, i.e. y=C*p-d.
|
||||
* y is stored in the last k2 elements of pext
|
||||
*/
|
||||
for(i=0; i<k2; ++i){
|
||||
for(j=0, tmp=0.0; j<m; ++j)
|
||||
tmp+=C[i*m+j]*p[j];
|
||||
pext[j=i+m]=tmp-d[i];
|
||||
|
||||
/* surplus variables must be >=0 */
|
||||
lbext[j]=0.0;
|
||||
ubext[j]=LM_REAL_MAX;
|
||||
}
|
||||
/* set the first m elements of pext equal to p */
|
||||
for(i=0; i<m; ++i){
|
||||
pext[i]=p[i];
|
||||
lbext[i]=lb? lb[i] : LM_REAL_MIN;
|
||||
ubext[i]=ub? ub[i] : LM_REAL_MAX;
|
||||
}
|
||||
|
||||
/* setup the constraints matrix */
|
||||
/* original linear equation constraints */
|
||||
for(i=0; i<k1; ++i){
|
||||
for(j=0; j<m; ++j)
|
||||
Aext[i*mm+j]=A[i*m+j];
|
||||
|
||||
for(j=m; j<mm; ++j)
|
||||
Aext[i*mm+j]=0.0;
|
||||
|
||||
bext[i]=b[i];
|
||||
}
|
||||
/* linear equation constraints resulting from surplus variables */
|
||||
for(i=0, ii=k1; i<k2; ++i, ++ii){
|
||||
for(j=0; j<m; ++j)
|
||||
Aext[ii*mm+j]=C[i*m+j];
|
||||
|
||||
for(j=m; j<mm; ++j)
|
||||
Aext[ii*mm+j]=0.0;
|
||||
|
||||
Aext[ii*mm+m+i]=-1.0;
|
||||
|
||||
bext[ii]=d[i];
|
||||
}
|
||||
|
||||
if(!info) info=locinfo; /* make sure that LEVMAR_BLEC_DIF() is called with non-null info */
|
||||
/* note that the default weights for the penalty terms are being used below */
|
||||
ret=LEVMAR_BLEC_DIF(LMBLEIC_FUNC, pext, x, mm, n, lbext, ubext, Aext, bext, k12, NULL, itmax, opts, info, work, covext, (void *)&data);
|
||||
|
||||
/* copy back the minimizer */
|
||||
for(i=0; i<m; ++i)
|
||||
p[i]=pext[i];
|
||||
|
||||
#if 0
|
||||
printf("Surplus variables for the minimizer:\n");
|
||||
for(i=m; i<mm; ++i)
|
||||
printf("%g ", pext[i]);
|
||||
printf("\n\n");
|
||||
#endif
|
||||
|
||||
if(covar){
|
||||
for(i=0; i<m; ++i){
|
||||
for(j=0; j<m; ++j)
|
||||
covar[i*m+j]=covext[i*mm+j];
|
||||
}
|
||||
}
|
||||
|
||||
free(ptr);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/* convenience wrappers to LEVMAR_BLEIC_DER/LEVMAR_BLEIC_DIF */
|
||||
|
||||
/* box & linear inequality constraints */
|
||||
int LEVMAR_BLIC_DER(
|
||||
void (*func)(LM_REAL *p, LM_REAL *hx, int m, int n, void *adata),
|
||||
void (*jacf)(LM_REAL *p, LM_REAL *j, int m, int n, void *adata),
|
||||
LM_REAL *p, LM_REAL *x, int m, int n,
|
||||
LM_REAL *lb, LM_REAL *ub,
|
||||
LM_REAL *C, LM_REAL *d, int k2,
|
||||
int itmax, LM_REAL opts[4], LM_REAL info[LM_INFO_SZ], LM_REAL *work, LM_REAL *covar, void *adata)
|
||||
{
|
||||
return LEVMAR_BLEIC_DER(func, jacf, p, x, m, n, lb, ub, NULL, NULL, 0, C, d, k2, itmax, opts, info, work, covar, adata);
|
||||
}
|
||||
|
||||
int LEVMAR_BLIC_DIF(
|
||||
void (*func)(LM_REAL *p, LM_REAL *hx, int m, int n, void *adata),
|
||||
LM_REAL *p, LM_REAL *x, int m, int n,
|
||||
LM_REAL *lb, LM_REAL *ub,
|
||||
LM_REAL *C, LM_REAL *d, int k2,
|
||||
int itmax, LM_REAL opts[5], LM_REAL info[LM_INFO_SZ], LM_REAL *work, LM_REAL *covar, void *adata)
|
||||
{
|
||||
return LEVMAR_BLEIC_DIF(func, p, x, m, n, lb, ub, NULL, NULL, 0, C, d, k2, itmax, opts, info, work, covar, adata);
|
||||
}
|
||||
|
||||
/* linear equation & inequality constraints */
|
||||
int LEVMAR_LEIC_DER(
|
||||
void (*func)(LM_REAL *p, LM_REAL *hx, int m, int n, void *adata),
|
||||
void (*jacf)(LM_REAL *p, LM_REAL *j, int m, int n, void *adata),
|
||||
LM_REAL *p, LM_REAL *x, int m, int n,
|
||||
LM_REAL *A, LM_REAL *b, int k1,
|
||||
LM_REAL *C, LM_REAL *d, int k2,
|
||||
int itmax, LM_REAL opts[4], LM_REAL info[LM_INFO_SZ], LM_REAL *work, LM_REAL *covar, void *adata)
|
||||
{
|
||||
return LEVMAR_BLEIC_DER(func, jacf, p, x, m, n, NULL, NULL, A, b, k1, C, d, k2, itmax, opts, info, work, covar, adata);
|
||||
}
|
||||
|
||||
int LEVMAR_LEIC_DIF(
|
||||
void (*func)(LM_REAL *p, LM_REAL *hx, int m, int n, void *adata),
|
||||
LM_REAL *p, LM_REAL *x, int m, int n,
|
||||
LM_REAL *A, LM_REAL *b, int k1,
|
||||
LM_REAL *C, LM_REAL *d, int k2,
|
||||
int itmax, LM_REAL opts[5], LM_REAL info[LM_INFO_SZ], LM_REAL *work, LM_REAL *covar, void *adata)
|
||||
{
|
||||
return LEVMAR_BLEIC_DIF(func, p, x, m, n, NULL, NULL, A, b, k1, C, d, k2, itmax, opts, info, work, covar, adata);
|
||||
}
|
||||
|
||||
/* linear inequality constraints */
|
||||
int LEVMAR_LIC_DER(
|
||||
void (*func)(LM_REAL *p, LM_REAL *hx, int m, int n, void *adata),
|
||||
void (*jacf)(LM_REAL *p, LM_REAL *j, int m, int n, void *adata),
|
||||
LM_REAL *p, LM_REAL *x, int m, int n,
|
||||
LM_REAL *C, LM_REAL *d, int k2,
|
||||
int itmax, LM_REAL opts[4], LM_REAL info[LM_INFO_SZ], LM_REAL *work, LM_REAL *covar, void *adata)
|
||||
{
|
||||
return LEVMAR_BLEIC_DER(func, jacf, p, x, m, n, NULL, NULL, NULL, NULL, 0, C, d, k2, itmax, opts, info, work, covar, adata);
|
||||
}
|
||||
|
||||
int LEVMAR_LIC_DIF(
|
||||
void (*func)(LM_REAL *p, LM_REAL *hx, int m, int n, void *adata),
|
||||
LM_REAL *p, LM_REAL *x, int m, int n,
|
||||
LM_REAL *C, LM_REAL *d, int k2,
|
||||
int itmax, LM_REAL opts[5], LM_REAL info[LM_INFO_SZ], LM_REAL *work, LM_REAL *covar, void *adata)
|
||||
{
|
||||
return LEVMAR_BLEIC_DIF(func, p, x, m, n, NULL, NULL, NULL, NULL, 0, C, d, k2, itmax, opts, info, work, covar, adata);
|
||||
}
|
||||
|
||||
/* undefine all. THIS MUST REMAIN AT THE END OF THE FILE */
|
||||
#undef LMBLEIC_DATA
|
||||
#undef LMBLEIC_ELIM
|
||||
#undef LMBLEIC_FUNC
|
||||
#undef LMBLEIC_JACF
|
||||
#undef LEVMAR_FDIF_FORW_JAC_APPROX
|
||||
#undef LEVMAR_COVAR
|
||||
#undef LEVMAR_TRANS_MAT_MAT_MULT
|
||||
#undef LEVMAR_BLEIC_DER
|
||||
#undef LEVMAR_BLEIC_DIF
|
||||
#undef LEVMAR_BLIC_DER
|
||||
#undef LEVMAR_BLIC_DIF
|
||||
#undef LEVMAR_LEIC_DER
|
||||
#undef LEVMAR_LEIC_DIF
|
||||
#undef LEVMAR_LIC_DER
|
||||
#undef LEVMAR_LIC_DIF
|
||||
#undef LEVMAR_BLEC_DER
|
||||
#undef LEVMAR_BLEC_DIF
|
||||
80
contrib/levmar/lmlec.c
Normal file
80
contrib/levmar/lmlec.c
Normal file
@@ -0,0 +1,80 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Levenberg - Marquardt non-linear minimization algorithm
|
||||
// Copyright (C) 2004-05 Manolis Lourakis (lourakis at ics forth gr)
|
||||
// Institute of Computer Science, Foundation for Research & Technology - Hellas
|
||||
// Heraklion, Crete, Greece.
|
||||
//
|
||||
// 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 2 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*******************************************************************************
|
||||
* Wrappers for linearly constrained Levenberg-Marquardt minimization. The same
|
||||
* core code is used with appropriate #defines to derive single and double
|
||||
* precision versions, see also lmlec_core.c
|
||||
*******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "levmar.h"
|
||||
#include "misc.h"
|
||||
|
||||
|
||||
#ifndef HAVE_LAPACK
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma message("Linearly constrained optimization requires LAPACK and was not compiled!")
|
||||
#else
|
||||
#warning Linearly constrained optimization requires LAPACK and was not compiled!
|
||||
#endif // _MSC_VER
|
||||
|
||||
#else // LAPACK present
|
||||
|
||||
#if !defined(LM_DBL_PREC) && !defined(LM_SNGL_PREC)
|
||||
#error At least one of LM_DBL_PREC, LM_SNGL_PREC should be defined!
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef LM_SNGL_PREC
|
||||
/* single precision (float) definitions */
|
||||
#define LM_REAL float
|
||||
#define LM_PREFIX s
|
||||
|
||||
#define __SUBCNST(x) x##F
|
||||
#define LM_CNST(x) __SUBCNST(x) // force substitution
|
||||
|
||||
#include "lmlec_core.c" // read in core code
|
||||
|
||||
#undef LM_REAL
|
||||
#undef LM_PREFIX
|
||||
#undef __SUBCNST
|
||||
#undef LM_CNST
|
||||
#endif /* LM_SNGL_PREC */
|
||||
|
||||
#ifdef LM_DBL_PREC
|
||||
/* double precision definitions */
|
||||
#define LM_REAL double
|
||||
#define LM_PREFIX d
|
||||
|
||||
#define LM_CNST(x) (x)
|
||||
|
||||
#include "lmlec_core.c" // read in core code
|
||||
|
||||
#undef LM_REAL
|
||||
#undef LM_PREFIX
|
||||
#undef LM_CNST
|
||||
#endif /* LM_DBL_PREC */
|
||||
|
||||
#endif /* HAVE_LAPACK */
|
||||
|
||||
656
contrib/levmar/lmlec_core.c
Normal file
656
contrib/levmar/lmlec_core.c
Normal file
@@ -0,0 +1,656 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Levenberg - Marquardt non-linear minimization algorithm
|
||||
// Copyright (C) 2004-05 Manolis Lourakis (lourakis at ics forth gr)
|
||||
// Institute of Computer Science, Foundation for Research & Technology - Hellas
|
||||
// Heraklion, Crete, Greece.
|
||||
//
|
||||
// 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 2 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef LM_REAL // not included by lmlec.c
|
||||
#error This file should not be compiled directly!
|
||||
#endif
|
||||
|
||||
|
||||
/* precision-specific definitions */
|
||||
#define LMLEC_DATA LM_ADD_PREFIX(lmlec_data)
|
||||
#define LMLEC_ELIM LM_ADD_PREFIX(lmlec_elim)
|
||||
#define LMLEC_FUNC LM_ADD_PREFIX(lmlec_func)
|
||||
#define LMLEC_JACF LM_ADD_PREFIX(lmlec_jacf)
|
||||
#define LEVMAR_LEC_DER LM_ADD_PREFIX(levmar_lec_der)
|
||||
#define LEVMAR_LEC_DIF LM_ADD_PREFIX(levmar_lec_dif)
|
||||
#define LEVMAR_DER LM_ADD_PREFIX(levmar_der)
|
||||
#define LEVMAR_DIF LM_ADD_PREFIX(levmar_dif)
|
||||
#define LEVMAR_TRANS_MAT_MAT_MULT LM_ADD_PREFIX(levmar_trans_mat_mat_mult)
|
||||
#define LEVMAR_COVAR LM_ADD_PREFIX(levmar_covar)
|
||||
#define LEVMAR_FDIF_FORW_JAC_APPROX LM_ADD_PREFIX(levmar_fdif_forw_jac_approx)
|
||||
|
||||
#define GEQP3 LM_MK_LAPACK_NAME(geqp3)
|
||||
#define ORGQR LM_MK_LAPACK_NAME(orgqr)
|
||||
#define TRTRI LM_MK_LAPACK_NAME(trtri)
|
||||
|
||||
struct LMLEC_DATA{
|
||||
LM_REAL *c, *Z, *p, *jac;
|
||||
int ncnstr;
|
||||
void (*func)(LM_REAL *p, LM_REAL *hx, int m, int n, void *adata);
|
||||
void (*jacf)(LM_REAL *p, LM_REAL *jac, int m, int n, void *adata);
|
||||
void *adata;
|
||||
};
|
||||
|
||||
/* prototypes for LAPACK routines */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
extern int GEQP3(int *m, int *n, LM_REAL *a, int *lda, int *jpvt,
|
||||
LM_REAL *tau, LM_REAL *work, int *lwork, int *info);
|
||||
|
||||
extern int ORGQR(int *m, int *n, int *k, LM_REAL *a, int *lda, LM_REAL *tau,
|
||||
LM_REAL *work, int *lwork, int *info);
|
||||
|
||||
extern int TRTRI(char *uplo, char *diag, int *n, LM_REAL *a, int *lda, int *info);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This function implements an elimination strategy for linearly constrained
|
||||
* optimization problems. The strategy relies on QR decomposition to transform
|
||||
* an optimization problem constrained by Ax=b to an equivalent, unconstrained
|
||||
* one. Also referred to as "null space" or "reduced Hessian" method.
|
||||
* See pp. 430-433 (chap. 15) of "Numerical Optimization" by Nocedal-Wright
|
||||
* for details.
|
||||
*
|
||||
* A is mxn with m<=n and rank(A)=m
|
||||
* Two matrices Y and Z of dimensions nxm and nx(n-m) are computed from A^T so that
|
||||
* their columns are orthonormal and every x can be written as x=Y*b + Z*x_z=
|
||||
* c + Z*x_z, where c=Y*b is a fixed vector of dimension n and x_z is an
|
||||
* arbitrary vector of dimension n-m. Then, the problem of minimizing f(x)
|
||||
* subject to Ax=b is equivalent to minimizing f(c + Z*x_z) with no constraints.
|
||||
* The computed Y and Z are such that any solution of Ax=b can be written as
|
||||
* x=Y*x_y + Z*x_z for some x_y, x_z. Furthermore, A*Y is nonsingular, A*Z=0
|
||||
* and Z spans the null space of A.
|
||||
*
|
||||
* The function accepts A, b and computes c, Y, Z. If b or c is NULL, c is not
|
||||
* computed. Also, Y can be NULL in which case it is not referenced.
|
||||
* The function returns LM_ERROR in case of error, A's computed rank if successful
|
||||
*
|
||||
*/
|
||||
static int LMLEC_ELIM(LM_REAL *A, LM_REAL *b, LM_REAL *c, LM_REAL *Y, LM_REAL *Z, int m, int n)
|
||||
{
|
||||
static LM_REAL eps=LM_CNST(-1.0);
|
||||
|
||||
LM_REAL *buf=NULL;
|
||||
LM_REAL *a, *tau, *work, *r, aux;
|
||||
register LM_REAL tmp;
|
||||
int a_sz, jpvt_sz, tau_sz, r_sz, Y_sz, worksz;
|
||||
int info, rank, *jpvt, tot_sz, mintmn, tm, tn;
|
||||
register int i, j, k;
|
||||
|
||||
if(m>n){
|
||||
fprintf(stderr, RCAT("matrix of constraints cannot have more rows than columns in", LMLEC_ELIM) "()!\n");
|
||||
return LM_ERROR;
|
||||
}
|
||||
|
||||
tm=n; tn=m; // transpose dimensions
|
||||
mintmn=m;
|
||||
|
||||
/* calculate required memory size */
|
||||
worksz=-1; // workspace query. Optimal work size is returned in aux
|
||||
//ORGQR((int *)&tm, (int *)&tm, (int *)&mintmn, NULL, (int *)&tm, NULL, (LM_REAL *)&aux, &worksz, &info);
|
||||
GEQP3((int *)&tm, (int *)&tn, NULL, (int *)&tm, NULL, NULL, (LM_REAL *)&aux, (int *)&worksz, &info);
|
||||
worksz=(int)aux;
|
||||
a_sz=tm*tm; // tm*tn is enough for xgeqp3()
|
||||
jpvt_sz=tn;
|
||||
tau_sz=mintmn;
|
||||
r_sz=mintmn*mintmn; // actually smaller if a is not of full row rank
|
||||
Y_sz=(Y)? 0 : tm*tn;
|
||||
|
||||
tot_sz=(a_sz + tau_sz + r_sz + worksz + Y_sz)*sizeof(LM_REAL) + jpvt_sz*sizeof(int); /* should be arranged in that order for proper doubles alignment */
|
||||
buf=(LM_REAL *)malloc(tot_sz); /* allocate a "big" memory chunk at once */
|
||||
if(!buf){
|
||||
fprintf(stderr, RCAT("Memory allocation request failed in ", LMLEC_ELIM) "()\n");
|
||||
return LM_ERROR;
|
||||
}
|
||||
|
||||
a=buf;
|
||||
tau=a+a_sz;
|
||||
r=tau+tau_sz;
|
||||
work=r+r_sz;
|
||||
if(!Y){
|
||||
Y=work+worksz;
|
||||
jpvt=(int *)(Y+Y_sz);
|
||||
}
|
||||
else
|
||||
jpvt=(int *)(work+worksz);
|
||||
|
||||
/* copy input array so that LAPACK won't destroy it. Note that copying is
|
||||
* done in row-major order, which equals A^T in column-major
|
||||
*/
|
||||
for(i=0; i<tm*tn; ++i)
|
||||
a[i]=A[i];
|
||||
|
||||
/* clear jpvt */
|
||||
for(i=0; i<jpvt_sz; ++i) jpvt[i]=0;
|
||||
|
||||
/* rank revealing QR decomposition of A^T*/
|
||||
GEQP3((int *)&tm, (int *)&tn, a, (int *)&tm, jpvt, tau, work, (int *)&worksz, &info);
|
||||
//dgeqpf_((int *)&tm, (int *)&tn, a, (int *)&tm, jpvt, tau, work, &info);
|
||||
/* error checking */
|
||||
if(info!=0){
|
||||
if(info<0){
|
||||
fprintf(stderr, RCAT(RCAT("LAPACK error: illegal value for argument %d of ", GEQP3) " in ", LMLEC_ELIM) "()\n", -info);
|
||||
}
|
||||
else if(info>0){
|
||||
fprintf(stderr, RCAT(RCAT("unknown LAPACK error (%d) for ", GEQP3) " in ", LMLEC_ELIM) "()\n", info);
|
||||
}
|
||||
free(buf);
|
||||
return LM_ERROR;
|
||||
}
|
||||
/* the upper triangular part of a now contains the upper triangle of the unpermuted R */
|
||||
|
||||
if(eps<0.0){
|
||||
LM_REAL aux;
|
||||
|
||||
/* compute machine epsilon. DBL_EPSILON should do also */
|
||||
for(eps=LM_CNST(1.0); aux=eps+LM_CNST(1.0), aux-LM_CNST(1.0)>0.0; eps*=LM_CNST(0.5))
|
||||
;
|
||||
eps*=LM_CNST(2.0);
|
||||
}
|
||||
|
||||
tmp=tm*LM_CNST(10.0)*eps*FABS(a[0]); // threshold. tm is max(tm, tn)
|
||||
tmp=(tmp>LM_CNST(1E-12))? tmp : LM_CNST(1E-12); // ensure that threshold is not too small
|
||||
/* compute A^T's numerical rank by counting the non-zeros in R's diagonal */
|
||||
for(i=rank=0; i<mintmn; ++i)
|
||||
if(a[i*(tm+1)]>tmp || a[i*(tm+1)]<-tmp) ++rank; /* loop across R's diagonal elements */
|
||||
else break; /* diagonal is arranged in absolute decreasing order */
|
||||
|
||||
if(rank<tn){
|
||||
fprintf(stderr, RCAT("\nConstraints matrix in ", LMLEC_ELIM) "() is not of full row rank (i.e. %d < %d)!\n"
|
||||
"Make sure that you do not specify redundant or inconsistent constraints.\n\n", rank, tn);
|
||||
free(buf);
|
||||
return LM_ERROR;
|
||||
}
|
||||
|
||||
/* compute the permuted inverse transpose of R */
|
||||
/* first, copy R from the upper triangular part of a to the lower part of r (thus transposing it). R is rank x rank */
|
||||
for(j=0; j<rank; ++j){
|
||||
for(i=0; i<=j; ++i)
|
||||
r[j+i*rank]=a[i+j*tm];
|
||||
for(i=j+1; i<rank; ++i)
|
||||
r[j+i*rank]=0.0; // upper part is zero
|
||||
}
|
||||
/* r now contains R^T */
|
||||
|
||||
/* compute the inverse */
|
||||
TRTRI("L", "N", (int *)&rank, r, (int *)&rank, &info);
|
||||
/* error checking */
|
||||
if(info!=0){
|
||||
if(info<0){
|
||||
fprintf(stderr, RCAT(RCAT("LAPACK error: illegal value for argument %d of ", TRTRI) " in ", LMLEC_ELIM) "()\n", -info);
|
||||
}
|
||||
else if(info>0){
|
||||
fprintf(stderr, RCAT(RCAT("A(%d, %d) is exactly zero for ", TRTRI) " (singular matrix) in ", LMLEC_ELIM) "()\n", info, info);
|
||||
}
|
||||
free(buf);
|
||||
return LM_ERROR;
|
||||
}
|
||||
|
||||
/* finally, permute R^-T using Y as intermediate storage */
|
||||
for(j=0; j<rank; ++j)
|
||||
for(i=0, k=jpvt[j]-1; i<rank; ++i)
|
||||
Y[i+k*rank]=r[i+j*rank];
|
||||
|
||||
for(i=0; i<rank*rank; ++i) // copy back to r
|
||||
r[i]=Y[i];
|
||||
|
||||
/* resize a to be tm x tm, filling with zeroes */
|
||||
for(i=tm*tn; i<tm*tm; ++i)
|
||||
a[i]=0.0;
|
||||
|
||||
/* compute Q in a as the product of elementary reflectors. Q is tm x tm */
|
||||
ORGQR((int *)&tm, (int *)&tm, (int *)&mintmn, a, (int *)&tm, tau, work, &worksz, &info);
|
||||
/* error checking */
|
||||
if(info!=0){
|
||||
if(info<0){
|
||||
fprintf(stderr, RCAT(RCAT("LAPACK error: illegal value for argument %d of ", ORGQR) " in ", LMLEC_ELIM) "()\n", -info);
|
||||
}
|
||||
else if(info>0){
|
||||
fprintf(stderr, RCAT(RCAT("unknown LAPACK error (%d) for ", ORGQR) " in ", LMLEC_ELIM) "()\n", info);
|
||||
}
|
||||
free(buf);
|
||||
return LM_ERROR;
|
||||
}
|
||||
|
||||
/* compute Y=Q_1*R^-T*P^T. Y is tm x rank */
|
||||
for(i=0; i<tm; ++i)
|
||||
for(j=0; j<rank; ++j){
|
||||
for(k=0, tmp=0.0; k<rank; ++k)
|
||||
tmp+=a[i+k*tm]*r[k+j*rank];
|
||||
Y[i*rank+j]=tmp;
|
||||
}
|
||||
|
||||
if(b && c){
|
||||
/* compute c=Y*b */
|
||||
for(i=0; i<tm; ++i){
|
||||
for(j=0, tmp=0.0; j<rank; ++j)
|
||||
tmp+=Y[i*rank+j]*b[j];
|
||||
|
||||
c[i]=tmp;
|
||||
}
|
||||
}
|
||||
|
||||
/* copy Q_2 into Z. Z is tm x (tm-rank) */
|
||||
for(j=0; j<tm-rank; ++j)
|
||||
for(i=0, k=j+rank; i<tm; ++i)
|
||||
Z[i*(tm-rank)+j]=a[i+k*tm];
|
||||
|
||||
free(buf);
|
||||
|
||||
return rank;
|
||||
}
|
||||
|
||||
/* constrained measurements: given pp, compute the measurements at c + Z*pp */
|
||||
static void LMLEC_FUNC(LM_REAL *pp, LM_REAL *hx, int mm, int n, void *adata)
|
||||
{
|
||||
struct LMLEC_DATA *data=(struct LMLEC_DATA *)adata;
|
||||
int m;
|
||||
register int i, j;
|
||||
register LM_REAL sum;
|
||||
LM_REAL *c, *Z, *p, *Zimm;
|
||||
|
||||
m=mm+data->ncnstr;
|
||||
c=data->c;
|
||||
Z=data->Z;
|
||||
p=data->p;
|
||||
/* p=c + Z*pp */
|
||||
for(i=0; i<m; ++i){
|
||||
Zimm=Z+i*mm;
|
||||
for(j=0, sum=c[i]; j<mm; ++j)
|
||||
sum+=Zimm[j]*pp[j]; // sum+=Z[i*mm+j]*pp[j];
|
||||
p[i]=sum;
|
||||
}
|
||||
|
||||
(*(data->func))(p, hx, m, n, data->adata);
|
||||
}
|
||||
|
||||
/* constrained Jacobian: given pp, compute the Jacobian at c + Z*pp
|
||||
* Using the chain rule, the Jacobian with respect to pp equals the
|
||||
* product of the Jacobian with respect to p (at c + Z*pp) times Z
|
||||
*/
|
||||
static void LMLEC_JACF(LM_REAL *pp, LM_REAL *jacjac, int mm, int n, void *adata)
|
||||
{
|
||||
struct LMLEC_DATA *data=(struct LMLEC_DATA *)adata;
|
||||
int m;
|
||||
register int i, j, l;
|
||||
register LM_REAL sum, *aux1, *aux2;
|
||||
LM_REAL *c, *Z, *p, *jac;
|
||||
|
||||
m=mm+data->ncnstr;
|
||||
c=data->c;
|
||||
Z=data->Z;
|
||||
p=data->p;
|
||||
jac=data->jac;
|
||||
/* p=c + Z*pp */
|
||||
for(i=0; i<m; ++i){
|
||||
aux1=Z+i*mm;
|
||||
for(j=0, sum=c[i]; j<mm; ++j)
|
||||
sum+=aux1[j]*pp[j]; // sum+=Z[i*mm+j]*pp[j];
|
||||
p[i]=sum;
|
||||
}
|
||||
|
||||
(*(data->jacf))(p, jac, m, n, data->adata);
|
||||
|
||||
/* compute jac*Z in jacjac */
|
||||
if(n*m<=__BLOCKSZ__SQ){ // this is a small problem
|
||||
/* This is the straightforward way to compute jac*Z. However, due to
|
||||
* its noncontinuous memory access pattern, it incures many cache misses when
|
||||
* applied to large minimization problems (i.e. problems involving a large
|
||||
* number of free variables and measurements), in which jac is too large to
|
||||
* fit in the L1 cache. For such problems, a cache-efficient blocking scheme
|
||||
* is preferable. On the other hand, the straightforward algorithm is faster
|
||||
* on small problems since in this case it avoids the overheads of blocking.
|
||||
*/
|
||||
|
||||
for(i=0; i<n; ++i){
|
||||
aux1=jac+i*m;
|
||||
aux2=jacjac+i*mm;
|
||||
for(j=0; j<mm; ++j){
|
||||
for(l=0, sum=0.0; l<m; ++l)
|
||||
sum+=aux1[l]*Z[l*mm+j]; // sum+=jac[i*m+l]*Z[l*mm+j];
|
||||
|
||||
aux2[j]=sum; // jacjac[i*mm+j]=sum;
|
||||
}
|
||||
}
|
||||
}
|
||||
else{ // this is a large problem
|
||||
/* Cache efficient computation of jac*Z based on blocking
|
||||
*/
|
||||
#define __MIN__(x, y) (((x)<=(y))? (x) : (y))
|
||||
register int jj, ll;
|
||||
|
||||
for(jj=0; jj<mm; jj+=__BLOCKSZ__){
|
||||
for(i=0; i<n; ++i){
|
||||
aux1=jacjac+i*mm;
|
||||
for(j=jj; j<__MIN__(jj+__BLOCKSZ__, mm); ++j)
|
||||
aux1[j]=0.0; //jacjac[i*mm+j]=0.0;
|
||||
}
|
||||
|
||||
for(ll=0; ll<m; ll+=__BLOCKSZ__){
|
||||
for(i=0; i<n; ++i){
|
||||
aux1=jacjac+i*mm; aux2=jac+i*m;
|
||||
for(j=jj; j<__MIN__(jj+__BLOCKSZ__, mm); ++j){
|
||||
sum=0.0;
|
||||
for(l=ll; l<__MIN__(ll+__BLOCKSZ__, m); ++l)
|
||||
sum+=aux2[l]*Z[l*mm+j]; //jac[i*m+l]*Z[l*mm+j];
|
||||
aux1[j]+=sum; //jacjac[i*mm+j]+=sum;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#undef __MIN__
|
||||
|
||||
|
||||
/*
|
||||
* This function is similar to LEVMAR_DER except that the minimization
|
||||
* is performed subject to the linear constraints A p=b, A is kxm, b kx1
|
||||
*
|
||||
* This function requires an analytic Jacobian. In case the latter is unavailable,
|
||||
* use LEVMAR_LEC_DIF() bellow
|
||||
*
|
||||
*/
|
||||
int LEVMAR_LEC_DER(
|
||||
void (*func)(LM_REAL *p, LM_REAL *hx, int m, int n, void *adata), /* functional relation describing measurements. A p \in R^m yields a \hat{x} \in R^n */
|
||||
void (*jacf)(LM_REAL *p, LM_REAL *j, int m, int n, void *adata), /* function to evaluate the Jacobian \part x / \part p */
|
||||
LM_REAL *p, /* I/O: initial parameter estimates. On output has the estimated solution */
|
||||
LM_REAL *x, /* I: measurement vector. NULL implies a zero vector */
|
||||
int m, /* I: parameter vector dimension (i.e. #unknowns) */
|
||||
int n, /* I: measurement vector dimension */
|
||||
LM_REAL *A, /* I: constraints matrix, kxm */
|
||||
LM_REAL *b, /* I: right hand constraints vector, kx1 */
|
||||
int k, /* I: number of constraints (i.e. A's #rows) */
|
||||
int itmax, /* I: maximum number of iterations */
|
||||
LM_REAL opts[4], /* I: minim. options [\mu, \epsilon1, \epsilon2, \epsilon3]. Respectively the scale factor for initial \mu,
|
||||
* stopping thresholds for ||J^T e||_inf, ||Dp||_2 and ||e||_2. Set to NULL for defaults to be used
|
||||
*/
|
||||
LM_REAL info[LM_INFO_SZ],
|
||||
/* O: information regarding the minimization. Set to NULL if don't care
|
||||
* info[0]= ||e||_2 at initial p.
|
||||
* info[1-4]=[ ||e||_2, ||J^T e||_inf, ||Dp||_2, mu/max[J^T J]_ii ], all computed at estimated p.
|
||||
* info[5]= # iterations,
|
||||
* info[6]=reason for terminating: 1 - stopped by small gradient J^T e
|
||||
* 2 - stopped by small Dp
|
||||
* 3 - stopped by itmax
|
||||
* 4 - singular matrix. Restart from current p with increased mu
|
||||
* 5 - no further error reduction is possible. Restart with increased mu
|
||||
* 6 - stopped by small ||e||_2
|
||||
* 7 - stopped by invalid (i.e. NaN or Inf) "func" values. This is a user error
|
||||
* info[7]= # function evaluations
|
||||
* info[8]= # Jacobian evaluations
|
||||
* info[9]= # linear systems solved, i.e. # attempts for reducing error
|
||||
*/
|
||||
LM_REAL *work, /* working memory at least LM_LEC_DER_WORKSZ() reals large, allocated if NULL */
|
||||
LM_REAL *covar, /* O: Covariance matrix corresponding to LS solution; mxm. Set to NULL if not needed. */
|
||||
void *adata) /* pointer to possibly additional data, passed uninterpreted to func & jacf.
|
||||
* Set to NULL if not needed
|
||||
*/
|
||||
{
|
||||
struct LMLEC_DATA data;
|
||||
LM_REAL *ptr, *Z, *pp, *p0, *Zimm; /* Z is mxmm */
|
||||
int mm, ret;
|
||||
register int i, j;
|
||||
register LM_REAL tmp;
|
||||
LM_REAL locinfo[LM_INFO_SZ];
|
||||
|
||||
if(!jacf){
|
||||
fprintf(stderr, RCAT("No function specified for computing the Jacobian in ", LEVMAR_LEC_DER)
|
||||
RCAT("().\nIf no such function is available, use ", LEVMAR_LEC_DIF) RCAT("() rather than ", LEVMAR_LEC_DER) "()\n");
|
||||
return LM_ERROR;
|
||||
}
|
||||
|
||||
mm=m-k;
|
||||
|
||||
if(n<mm){
|
||||
fprintf(stderr, LCAT(LEVMAR_LEC_DER, "(): cannot solve a problem with fewer measurements + equality constraints [%d + %d] than unknowns [%d]\n"), n, k, m);
|
||||
return LM_ERROR;
|
||||
}
|
||||
|
||||
ptr=(LM_REAL *)malloc((2*m + m*mm + n*m + mm)*sizeof(LM_REAL));
|
||||
if(!ptr){
|
||||
fprintf(stderr, LCAT(LEVMAR_LEC_DER, "(): memory allocation request failed\n"));
|
||||
return LM_ERROR;
|
||||
}
|
||||
data.p=p;
|
||||
p0=ptr;
|
||||
data.c=p0+m;
|
||||
data.Z=Z=data.c+m;
|
||||
data.jac=data.Z+m*mm;
|
||||
pp=data.jac+n*m;
|
||||
data.ncnstr=k;
|
||||
data.func=func;
|
||||
data.jacf=jacf;
|
||||
data.adata=adata;
|
||||
|
||||
ret=LMLEC_ELIM(A, b, data.c, NULL, Z, k, m); // compute c, Z
|
||||
if(ret==LM_ERROR){
|
||||
free(ptr);
|
||||
return LM_ERROR;
|
||||
}
|
||||
|
||||
/* compute pp s.t. p = c + Z*pp or (Z^T Z)*pp=Z^T*(p-c)
|
||||
* Due to orthogonality, Z^T Z = I and the last equation
|
||||
* becomes pp=Z^T*(p-c). Also, save the starting p in p0
|
||||
*/
|
||||
for(i=0; i<m; ++i){
|
||||
p0[i]=p[i];
|
||||
p[i]-=data.c[i];
|
||||
}
|
||||
|
||||
/* Z^T*(p-c) */
|
||||
for(i=0; i<mm; ++i){
|
||||
for(j=0, tmp=0.0; j<m; ++j)
|
||||
tmp+=Z[j*mm+i]*p[j];
|
||||
pp[i]=tmp;
|
||||
}
|
||||
|
||||
/* compute the p corresponding to pp (i.e. c + Z*pp) and compare with p0 */
|
||||
for(i=0; i<m; ++i){
|
||||
Zimm=Z+i*mm;
|
||||
for(j=0, tmp=data.c[i]; j<mm; ++j)
|
||||
tmp+=Zimm[j]*pp[j]; // tmp+=Z[i*mm+j]*pp[j];
|
||||
if(FABS(tmp-p0[i])>LM_CNST(1E-03))
|
||||
fprintf(stderr, RCAT("Warning: component %d of starting point not feasible in ", LEVMAR_LEC_DER) "()! [%.10g reset to %.10g]\n",
|
||||
i, p0[i], tmp);
|
||||
}
|
||||
|
||||
if(!info) info=locinfo; /* make sure that LEVMAR_DER() is called with non-null info */
|
||||
/* note that covariance computation is not requested from LEVMAR_DER() */
|
||||
ret=LEVMAR_DER(LMLEC_FUNC, LMLEC_JACF, pp, x, mm, n, itmax, opts, info, work, NULL, (void *)&data);
|
||||
|
||||
/* p=c + Z*pp */
|
||||
for(i=0; i<m; ++i){
|
||||
Zimm=Z+i*mm;
|
||||
for(j=0, tmp=data.c[i]; j<mm; ++j)
|
||||
tmp+=Zimm[j]*pp[j]; // tmp+=Z[i*mm+j]*pp[j];
|
||||
p[i]=tmp;
|
||||
}
|
||||
|
||||
/* compute the covariance from the Jacobian in data.jac */
|
||||
if(covar){
|
||||
LEVMAR_TRANS_MAT_MAT_MULT(data.jac, covar, n, m); /* covar = J^T J */
|
||||
LEVMAR_COVAR(covar, covar, info[1], m, n);
|
||||
}
|
||||
|
||||
free(ptr);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Similar to the LEVMAR_LEC_DER() function above, except that the Jacobian is approximated
|
||||
* with the aid of finite differences (forward or central, see the comment for the opts argument)
|
||||
*/
|
||||
int LEVMAR_LEC_DIF(
|
||||
void (*func)(LM_REAL *p, LM_REAL *hx, int m, int n, void *adata), /* functional relation describing measurements. A p \in R^m yields a \hat{x} \in R^n */
|
||||
LM_REAL *p, /* I/O: initial parameter estimates. On output has the estimated solution */
|
||||
LM_REAL *x, /* I: measurement vector. NULL implies a zero vector */
|
||||
int m, /* I: parameter vector dimension (i.e. #unknowns) */
|
||||
int n, /* I: measurement vector dimension */
|
||||
LM_REAL *A, /* I: constraints matrix, kxm */
|
||||
LM_REAL *b, /* I: right hand constraints vector, kx1 */
|
||||
int k, /* I: number of constraints (i.e. A's #rows) */
|
||||
int itmax, /* I: maximum number of iterations */
|
||||
LM_REAL opts[5], /* I: opts[0-3] = minim. options [\mu, \epsilon1, \epsilon2, \epsilon3, \delta]. Respectively the
|
||||
* scale factor for initial \mu, stopping thresholds for ||J^T e||_inf, ||Dp||_2 and ||e||_2 and
|
||||
* the step used in difference approximation to the Jacobian. Set to NULL for defaults to be used.
|
||||
* If \delta<0, the Jacobian is approximated with central differences which are more accurate
|
||||
* (but slower!) compared to the forward differences employed by default.
|
||||
*/
|
||||
LM_REAL info[LM_INFO_SZ],
|
||||
/* O: information regarding the minimization. Set to NULL if don't care
|
||||
* info[0]= ||e||_2 at initial p.
|
||||
* info[1-4]=[ ||e||_2, ||J^T e||_inf, ||Dp||_2, mu/max[J^T J]_ii ], all computed at estimated p.
|
||||
* info[5]= # iterations,
|
||||
* info[6]=reason for terminating: 1 - stopped by small gradient J^T e
|
||||
* 2 - stopped by small Dp
|
||||
* 3 - stopped by itmax
|
||||
* 4 - singular matrix. Restart from current p with increased mu
|
||||
* 5 - no further error reduction is possible. Restart with increased mu
|
||||
* 6 - stopped by small ||e||_2
|
||||
* 7 - stopped by invalid (i.e. NaN or Inf) "func" values. This is a user error
|
||||
* info[7]= # function evaluations
|
||||
* info[8]= # Jacobian evaluations
|
||||
* info[9]= # linear systems solved, i.e. # attempts for reducing error
|
||||
*/
|
||||
LM_REAL *work, /* working memory at least LM_LEC_DIF_WORKSZ() reals large, allocated if NULL */
|
||||
LM_REAL *covar, /* O: Covariance matrix corresponding to LS solution; mxm. Set to NULL if not needed. */
|
||||
void *adata) /* pointer to possibly additional data, passed uninterpreted to func.
|
||||
* Set to NULL if not needed
|
||||
*/
|
||||
{
|
||||
struct LMLEC_DATA data;
|
||||
LM_REAL *ptr, *Z, *pp, *p0, *Zimm; /* Z is mxmm */
|
||||
int mm, ret;
|
||||
register int i, j;
|
||||
register LM_REAL tmp;
|
||||
LM_REAL locinfo[LM_INFO_SZ];
|
||||
|
||||
mm=m-k;
|
||||
|
||||
if(n<mm){
|
||||
fprintf(stderr, LCAT(LEVMAR_LEC_DIF, "(): cannot solve a problem with fewer measurements + equality constraints [%d + %d] than unknowns [%d]\n"), n, k, m);
|
||||
return LM_ERROR;
|
||||
}
|
||||
|
||||
ptr=(LM_REAL *)malloc((2*m + m*mm + mm)*sizeof(LM_REAL));
|
||||
if(!ptr){
|
||||
fprintf(stderr, LCAT(LEVMAR_LEC_DIF, "(): memory allocation request failed\n"));
|
||||
return LM_ERROR;
|
||||
}
|
||||
data.p=p;
|
||||
p0=ptr;
|
||||
data.c=p0+m;
|
||||
data.Z=Z=data.c+m;
|
||||
data.jac=NULL;
|
||||
pp=data.Z+m*mm;
|
||||
data.ncnstr=k;
|
||||
data.func=func;
|
||||
data.jacf=NULL;
|
||||
data.adata=adata;
|
||||
|
||||
ret=LMLEC_ELIM(A, b, data.c, NULL, Z, k, m); // compute c, Z
|
||||
if(ret==LM_ERROR){
|
||||
free(ptr);
|
||||
return LM_ERROR;
|
||||
}
|
||||
|
||||
/* compute pp s.t. p = c + Z*pp or (Z^T Z)*pp=Z^T*(p-c)
|
||||
* Due to orthogonality, Z^T Z = I and the last equation
|
||||
* becomes pp=Z^T*(p-c). Also, save the starting p in p0
|
||||
*/
|
||||
for(i=0; i<m; ++i){
|
||||
p0[i]=p[i];
|
||||
p[i]-=data.c[i];
|
||||
}
|
||||
|
||||
/* Z^T*(p-c) */
|
||||
for(i=0; i<mm; ++i){
|
||||
for(j=0, tmp=0.0; j<m; ++j)
|
||||
tmp+=Z[j*mm+i]*p[j];
|
||||
pp[i]=tmp;
|
||||
}
|
||||
|
||||
/* compute the p corresponding to pp (i.e. c + Z*pp) and compare with p0 */
|
||||
for(i=0; i<m; ++i){
|
||||
Zimm=Z+i*mm;
|
||||
for(j=0, tmp=data.c[i]; j<mm; ++j)
|
||||
tmp+=Zimm[j]*pp[j]; // tmp+=Z[i*mm+j]*pp[j];
|
||||
if(FABS(tmp-p0[i])>LM_CNST(1E-03))
|
||||
fprintf(stderr, RCAT("Warning: component %d of starting point not feasible in ", LEVMAR_LEC_DIF) "()! [%.10g reset to %.10g]\n",
|
||||
i, p0[i], tmp);
|
||||
}
|
||||
|
||||
if(!info) info=locinfo; /* make sure that LEVMAR_DIF() is called with non-null info */
|
||||
/* note that covariance computation is not requested from LEVMAR_DIF() */
|
||||
ret=LEVMAR_DIF(LMLEC_FUNC, pp, x, mm, n, itmax, opts, info, work, NULL, (void *)&data);
|
||||
|
||||
/* p=c + Z*pp */
|
||||
for(i=0; i<m; ++i){
|
||||
Zimm=Z+i*mm;
|
||||
for(j=0, tmp=data.c[i]; j<mm; ++j)
|
||||
tmp+=Zimm[j]*pp[j]; // tmp+=Z[i*mm+j]*pp[j];
|
||||
p[i]=tmp;
|
||||
}
|
||||
|
||||
/* compute the Jacobian with finite differences and use it to estimate the covariance */
|
||||
if(covar){
|
||||
LM_REAL *hx, *wrk, *jac;
|
||||
|
||||
hx=(LM_REAL *)malloc((2*n+n*m)*sizeof(LM_REAL));
|
||||
if(!hx){
|
||||
fprintf(stderr, LCAT(LEVMAR_LEC_DIF, "(): memory allocation request failed\n"));
|
||||
free(ptr);
|
||||
return LM_ERROR;
|
||||
}
|
||||
|
||||
wrk=hx+n;
|
||||
jac=wrk+n;
|
||||
|
||||
(*func)(p, hx, m, n, adata); /* evaluate function at p */
|
||||
LEVMAR_FDIF_FORW_JAC_APPROX(func, p, hx, wrk, (LM_REAL)LM_DIFF_DELTA, jac, m, n, adata); /* compute the Jacobian at p */
|
||||
LEVMAR_TRANS_MAT_MAT_MULT(jac, covar, n, m); /* covar = J^T J */
|
||||
LEVMAR_COVAR(covar, covar, info[1], m, n);
|
||||
free(hx);
|
||||
}
|
||||
|
||||
free(ptr);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* undefine all. THIS MUST REMAIN AT THE END OF THE FILE */
|
||||
#undef LMLEC_DATA
|
||||
#undef LMLEC_ELIM
|
||||
#undef LMLEC_FUNC
|
||||
#undef LMLEC_JACF
|
||||
#undef LEVMAR_FDIF_FORW_JAC_APPROX
|
||||
#undef LEVMAR_COVAR
|
||||
#undef LEVMAR_TRANS_MAT_MAT_MULT
|
||||
#undef LEVMAR_LEC_DER
|
||||
#undef LEVMAR_LEC_DIF
|
||||
#undef LEVMAR_DER
|
||||
#undef LEVMAR_DIF
|
||||
|
||||
#undef GEQP3
|
||||
#undef ORGQR
|
||||
#undef TRTRI
|
||||
70
contrib/levmar/misc.c
Normal file
70
contrib/levmar/misc.c
Normal file
@@ -0,0 +1,70 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Levenberg - Marquardt non-linear minimization algorithm
|
||||
// Copyright (C) 2004-05 Manolis Lourakis (lourakis at ics forth gr)
|
||||
// Institute of Computer Science, Foundation for Research & Technology - Hellas
|
||||
// Heraklion, Crete, Greece.
|
||||
//
|
||||
// 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 2 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/********************************************************************************
|
||||
* Miscelaneous functions for Levenberg-Marquardt nonlinear minimization. The
|
||||
* same core code is used with appropriate #defines to derive single and double
|
||||
* precision versions, see also misc_core.c
|
||||
********************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
|
||||
#include "levmar.h"
|
||||
#include "misc.h"
|
||||
|
||||
#if !defined(LM_DBL_PREC) && !defined(LM_SNGL_PREC)
|
||||
#error At least one of LM_DBL_PREC, LM_SNGL_PREC should be defined!
|
||||
#endif
|
||||
|
||||
#ifdef LM_SNGL_PREC
|
||||
/* single precision (float) definitions */
|
||||
#define LM_REAL float
|
||||
#define LM_PREFIX s
|
||||
|
||||
#define LM_REAL_EPSILON FLT_EPSILON
|
||||
#define __SUBCNST(x) x##F
|
||||
#define LM_CNST(x) __SUBCNST(x) // force substitution
|
||||
|
||||
#include "misc_core.c" // read in core code
|
||||
|
||||
#undef LM_REAL
|
||||
#undef LM_PREFIX
|
||||
#undef LM_REAL_EPSILON
|
||||
#undef __SUBCNST
|
||||
#undef LM_CNST
|
||||
#endif /* LM_SNGL_PREC */
|
||||
|
||||
#ifdef LM_DBL_PREC
|
||||
/* double precision definitions */
|
||||
#define LM_REAL double
|
||||
#define LM_PREFIX d
|
||||
|
||||
#define LM_REAL_EPSILON DBL_EPSILON
|
||||
#define LM_CNST(x) (x)
|
||||
|
||||
#include "misc_core.c" // read in core code
|
||||
|
||||
#undef LM_REAL
|
||||
#undef LM_PREFIX
|
||||
#undef LM_REAL_EPSILON
|
||||
#undef LM_CNST
|
||||
#endif /* LM_DBL_PREC */
|
||||
114
contrib/levmar/misc.h
Normal file
114
contrib/levmar/misc.h
Normal file
@@ -0,0 +1,114 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Levenberg - Marquardt non-linear minimization algorithm
|
||||
// Copyright (C) 2004 Manolis Lourakis (lourakis at ics forth gr)
|
||||
// Institute of Computer Science, Foundation for Research & Technology - Hellas
|
||||
// Heraklion, Crete, Greece.
|
||||
//
|
||||
// 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 2 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _MISC_H_
|
||||
#define _MISC_H_
|
||||
|
||||
/* common suffix for LAPACK subroutines. Define empty in case of no prefix. */
|
||||
#define LM_LAPACK_SUFFIX _
|
||||
//#define LM_LAPACK_SUFFIX // define empty
|
||||
|
||||
/* common prefix for BLAS subroutines. Leave undefined in case of no prefix.
|
||||
* You might also need to modify LM_BLAS_PREFIX below
|
||||
*/
|
||||
/* f2c'd BLAS */
|
||||
//#define LM_BLAS_PREFIX f2c_
|
||||
/* C BLAS */
|
||||
//#define LM_BLAS_PREFIX cblas_
|
||||
|
||||
/* common suffix for BLAS subroutines */
|
||||
//#define LM_BLAS_SUFFIX // define empty if a f2c_ or cblas_ prefix was defined for LM_BLAS_PREFIX above
|
||||
#define LM_BLAS_SUFFIX _ // use this in case of no BLAS prefix
|
||||
|
||||
|
||||
#define LCAT_(a, b) #a b
|
||||
#define LCAT(a, b) LCAT_(a, b) // force substitution
|
||||
#define RCAT_(a, b) a #b
|
||||
#define RCAT(a, b) RCAT_(a, b) // force substitution
|
||||
|
||||
#define LM_MK_LAPACK_NAME(s) LM_ADD_PREFIX(LM_CAT_(s, LM_LAPACK_SUFFIX))
|
||||
|
||||
#ifdef LM_BLAS_PREFIX
|
||||
#define LM_MK_BLAS_NAME(s) LM_CAT_(LM_BLAS_PREFIX, LM_ADD_PREFIX(LM_CAT_(s, LM_BLAS_SUFFIX)))
|
||||
#else
|
||||
#define LM_MK_BLAS_NAME(s) LM_ADD_PREFIX(LM_CAT_(s, LM_BLAS_SUFFIX))
|
||||
#endif
|
||||
|
||||
|
||||
#define __BLOCKSZ__ 32 /* block size for cache-friendly matrix-matrix multiply. It should be
|
||||
* such that __BLOCKSZ__^2*sizeof(LM_REAL) is smaller than the CPU (L1)
|
||||
* data cache size. Notice that a value of 32 when LM_REAL=double assumes
|
||||
* an 8Kb L1 data cache (32*32*8=8K). This is a concervative choice since
|
||||
* newer Pentium 4s have a L1 data cache of size 16K, capable of holding
|
||||
* up to 45x45 double blocks.
|
||||
*/
|
||||
#define __BLOCKSZ__SQ (__BLOCKSZ__)*(__BLOCKSZ__)
|
||||
|
||||
/* add a prefix in front of a token */
|
||||
#define LM_CAT__(a, b) a ## b
|
||||
#define LM_CAT_(a, b) LM_CAT__(a, b) // force substitution
|
||||
#define LM_ADD_PREFIX(s) LM_CAT_(LM_PREFIX, s)
|
||||
|
||||
#define FABS(x) (((x)>=0.0)? (x) : -(x))
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* blocking-based matrix multiply */
|
||||
extern void slevmar_trans_mat_mat_mult(float *a, float *b, int n, int m);
|
||||
extern void dlevmar_trans_mat_mat_mult(double *a, double *b, int n, int m);
|
||||
|
||||
/* forward finite differences */
|
||||
extern void slevmar_fdif_forw_jac_approx(void (*func)(float *p, float *hx, int m, int n, void *adata),
|
||||
float *p, float *hx, float *hxx, float delta,
|
||||
float *jac, int m, int n, void *adata);
|
||||
extern void dlevmar_fdif_forw_jac_approx(void (*func)(double *p, double *hx, int m, int n, void *adata),
|
||||
double *p, double *hx, double *hxx, double delta,
|
||||
double *jac, int m, int n, void *adata);
|
||||
|
||||
/* central finite differences */
|
||||
extern void slevmar_fdif_cent_jac_approx(void (*func)(float *p, float *hx, int m, int n, void *adata),
|
||||
float *p, float *hxm, float *hxp, float delta,
|
||||
float *jac, int m, int n, void *adata);
|
||||
extern void dlevmar_fdif_cent_jac_approx(void (*func)(double *p, double *hx, int m, int n, void *adata),
|
||||
double *p, double *hxm, double *hxp, double delta,
|
||||
double *jac, int m, int n, void *adata);
|
||||
|
||||
/* e=x-y and ||e|| */
|
||||
extern float slevmar_L2nrmxmy(float *e, float *x, float *y, int n);
|
||||
extern double dlevmar_L2nrmxmy(double *e, double *x, double *y, int n);
|
||||
|
||||
/* covariance of LS fit */
|
||||
extern int slevmar_covar(float *JtJ, float *C, float sumsq, int m, int n);
|
||||
extern int dlevmar_covar(double *JtJ, double *C, double sumsq, int m, int n);
|
||||
|
||||
/* box constraints consistency check */
|
||||
extern int slevmar_box_check(float *lb, float *ub, int m);
|
||||
extern int dlevmar_box_check(double *lb, double *ub, int m);
|
||||
|
||||
/* Cholesky */
|
||||
extern int slevmar_chol(float *C, float *W, int m);
|
||||
extern int dlevmar_chol(double *C, double *W, int m);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _MISC_H_ */
|
||||
831
contrib/levmar/misc_core.c
Normal file
831
contrib/levmar/misc_core.c
Normal file
@@ -0,0 +1,831 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Levenberg - Marquardt non-linear minimization algorithm
|
||||
// Copyright (C) 2004-05 Manolis Lourakis (lourakis at ics forth gr)
|
||||
// Institute of Computer Science, Foundation for Research & Technology - Hellas
|
||||
// Heraklion, Crete, Greece.
|
||||
//
|
||||
// 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 2 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef LM_REAL // not included by misc.c
|
||||
#error This file should not be compiled directly!
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
|
||||
#pragma GCC diagnostic ignored "-Wcpp"
|
||||
#endif
|
||||
|
||||
/* precision-specific definitions */
|
||||
#define LEVMAR_CHKJAC LM_ADD_PREFIX(levmar_chkjac)
|
||||
#define LEVMAR_FDIF_FORW_JAC_APPROX LM_ADD_PREFIX(levmar_fdif_forw_jac_approx)
|
||||
#define LEVMAR_FDIF_CENT_JAC_APPROX LM_ADD_PREFIX(levmar_fdif_cent_jac_approx)
|
||||
#define LEVMAR_TRANS_MAT_MAT_MULT LM_ADD_PREFIX(levmar_trans_mat_mat_mult)
|
||||
#define LEVMAR_COVAR LM_ADD_PREFIX(levmar_covar)
|
||||
#define LEVMAR_STDDEV LM_ADD_PREFIX(levmar_stddev)
|
||||
#define LEVMAR_CORCOEF LM_ADD_PREFIX(levmar_corcoef)
|
||||
#define LEVMAR_R2 LM_ADD_PREFIX(levmar_R2)
|
||||
#define LEVMAR_BOX_CHECK LM_ADD_PREFIX(levmar_box_check)
|
||||
#define LEVMAR_L2NRMXMY LM_ADD_PREFIX(levmar_L2nrmxmy)
|
||||
|
||||
#ifdef HAVE_LAPACK
|
||||
#define LEVMAR_PSEUDOINVERSE LM_ADD_PREFIX(levmar_pseudoinverse)
|
||||
static int LEVMAR_PSEUDOINVERSE(LM_REAL *A, LM_REAL *B, int m);
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/* BLAS matrix multiplication, LAPACK SVD & Cholesky routines */
|
||||
#define GEMM LM_MK_BLAS_NAME(gemm)
|
||||
/* C := alpha*op( A )*op( B ) + beta*C */
|
||||
extern void GEMM(char *transa, char *transb, int *m, int *n, int *k,
|
||||
LM_REAL *alpha, LM_REAL *a, int *lda, LM_REAL *b, int *ldb, LM_REAL *beta, LM_REAL *c, int *ldc);
|
||||
|
||||
#define GESVD LM_MK_LAPACK_NAME(gesvd)
|
||||
#define GESDD LM_MK_LAPACK_NAME(gesdd)
|
||||
extern int GESVD(char *jobu, char *jobvt, int *m, int *n, LM_REAL *a, int *lda, LM_REAL *s, LM_REAL *u, int *ldu,
|
||||
LM_REAL *vt, int *ldvt, LM_REAL *work, int *lwork, int *info);
|
||||
|
||||
/* lapack 3.0 new SVD routine, faster than xgesvd() */
|
||||
extern int GESDD(char *jobz, int *m, int *n, LM_REAL *a, int *lda, LM_REAL *s, LM_REAL *u, int *ldu, LM_REAL *vt, int *ldvt,
|
||||
LM_REAL *work, int *lwork, int *iwork, int *info);
|
||||
|
||||
/* Cholesky decomposition */
|
||||
#define POTF2 LM_MK_LAPACK_NAME(potf2)
|
||||
extern int POTF2(char *uplo, int *n, LM_REAL *a, int *lda, int *info);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#define LEVMAR_CHOLESKY LM_ADD_PREFIX(levmar_chol)
|
||||
|
||||
#else /* !HAVE_LAPACK */
|
||||
#define LEVMAR_LUINVERSE LM_ADD_PREFIX(levmar_LUinverse_noLapack)
|
||||
|
||||
static int LEVMAR_LUINVERSE(LM_REAL *A, LM_REAL *B, int m);
|
||||
#endif /* HAVE_LAPACK */
|
||||
|
||||
/* blocked multiplication of the transpose of the nxm matrix a with itself (i.e. a^T a)
|
||||
* using a block size of bsize. The product is returned in b.
|
||||
* Since a^T a is symmetric, its computation can be sped up by computing only its
|
||||
* upper triangular part and copying it to the lower part.
|
||||
*
|
||||
* More details on blocking can be found at
|
||||
* http://www-2.cs.cmu.edu/afs/cs/academic/class/15213-f02/www/R07/section_a/Recitation07-SectionA.pdf
|
||||
*/
|
||||
void LEVMAR_TRANS_MAT_MAT_MULT(LM_REAL *a, LM_REAL *b, int n, int m)
|
||||
{
|
||||
#ifdef HAVE_LAPACK /* use BLAS matrix multiply */
|
||||
|
||||
LM_REAL alpha=LM_CNST(1.0), beta=LM_CNST(0.0);
|
||||
/* Fool BLAS to compute a^T*a avoiding transposing a: a is equivalent to a^T in column major,
|
||||
* therefore BLAS computes a*a^T with a and a*a^T in column major, which is equivalent to
|
||||
* computing a^T*a in row major!
|
||||
*/
|
||||
GEMM("N", "T", &m, &m, &n, &alpha, a, &m, a, &m, &beta, b, &m);
|
||||
|
||||
#else /* no LAPACK, use blocking-based multiply */
|
||||
|
||||
register int i, j, k, jj, kk;
|
||||
register LM_REAL sum, *bim, *akm;
|
||||
const int bsize=__BLOCKSZ__;
|
||||
|
||||
#define __MIN__(x, y) (((x)<=(y))? (x) : (y))
|
||||
#define __MAX__(x, y) (((x)>=(y))? (x) : (y))
|
||||
|
||||
/* compute upper triangular part using blocking */
|
||||
for(jj=0; jj<m; jj+=bsize){
|
||||
for(i=0; i<m; ++i){
|
||||
bim=b+i*m;
|
||||
for(j=__MAX__(jj, i); j<__MIN__(jj+bsize, m); ++j)
|
||||
bim[j]=0.0; //b[i*m+j]=0.0;
|
||||
}
|
||||
|
||||
for(kk=0; kk<n; kk+=bsize){
|
||||
for(i=0; i<m; ++i){
|
||||
bim=b+i*m;
|
||||
for(j=__MAX__(jj, i); j<__MIN__(jj+bsize, m); ++j){
|
||||
sum=0.0;
|
||||
for(k=kk; k<__MIN__(kk+bsize, n); ++k){
|
||||
akm=a+k*m;
|
||||
sum+=akm[i]*akm[j]; //a[k*m+i]*a[k*m+j];
|
||||
}
|
||||
bim[j]+=sum; //b[i*m+j]+=sum;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* copy upper triangular part to the lower one */
|
||||
for(i=0; i<m; ++i)
|
||||
for(j=0; j<i; ++j)
|
||||
b[i*m+j]=b[j*m+i];
|
||||
|
||||
#undef __MIN__
|
||||
#undef __MAX__
|
||||
|
||||
#endif /* HAVE_LAPACK */
|
||||
}
|
||||
|
||||
/* forward finite difference approximation to the Jacobian of func */
|
||||
void LEVMAR_FDIF_FORW_JAC_APPROX(
|
||||
void (*func)(LM_REAL *p, LM_REAL *hx, int m, int n, void *adata),
|
||||
/* function to differentiate */
|
||||
LM_REAL *p, /* I: current parameter estimate, mx1 */
|
||||
LM_REAL *hx, /* I: func evaluated at p, i.e. hx=func(p), nx1 */
|
||||
LM_REAL *hxx, /* W/O: work array for evaluating func(p+delta), nx1 */
|
||||
LM_REAL delta, /* increment for computing the Jacobian */
|
||||
LM_REAL *jac, /* O: array for storing approximated Jacobian, nxm */
|
||||
int m,
|
||||
int n,
|
||||
void *adata)
|
||||
{
|
||||
register int i, j;
|
||||
LM_REAL tmp;
|
||||
register LM_REAL d;
|
||||
|
||||
for(j=0; j<m; ++j){
|
||||
/* determine d=max(1E-04*|p[j]|, delta), see HZ */
|
||||
d=LM_CNST(1E-04)*p[j]; // force evaluation
|
||||
d=FABS(d);
|
||||
if(d<delta)
|
||||
d=delta;
|
||||
|
||||
tmp=p[j];
|
||||
p[j]+=d;
|
||||
|
||||
(*func)(p, hxx, m, n, adata);
|
||||
|
||||
p[j]=tmp; /* restore */
|
||||
|
||||
d=LM_CNST(1.0)/d; /* invert so that divisions can be carried out faster as multiplications */
|
||||
for(i=0; i<n; ++i){
|
||||
jac[i*m+j]=(hxx[i]-hx[i])*d;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* central finite difference approximation to the Jacobian of func */
|
||||
void LEVMAR_FDIF_CENT_JAC_APPROX(
|
||||
void (*func)(LM_REAL *p, LM_REAL *hx, int m, int n, void *adata),
|
||||
/* function to differentiate */
|
||||
LM_REAL *p, /* I: current parameter estimate, mx1 */
|
||||
LM_REAL *hxm, /* W/O: work array for evaluating func(p-delta), nx1 */
|
||||
LM_REAL *hxp, /* W/O: work array for evaluating func(p+delta), nx1 */
|
||||
LM_REAL delta, /* increment for computing the Jacobian */
|
||||
LM_REAL *jac, /* O: array for storing approximated Jacobian, nxm */
|
||||
int m,
|
||||
int n,
|
||||
void *adata)
|
||||
{
|
||||
register int i, j;
|
||||
LM_REAL tmp;
|
||||
register LM_REAL d;
|
||||
|
||||
for(j=0; j<m; ++j){
|
||||
/* determine d=max(1E-04*|p[j]|, delta), see HZ */
|
||||
d=LM_CNST(1E-04)*p[j]; // force evaluation
|
||||
d=FABS(d);
|
||||
if(d<delta)
|
||||
d=delta;
|
||||
|
||||
tmp=p[j];
|
||||
p[j]-=d;
|
||||
(*func)(p, hxm, m, n, adata);
|
||||
|
||||
p[j]=tmp+d;
|
||||
(*func)(p, hxp, m, n, adata);
|
||||
p[j]=tmp; /* restore */
|
||||
|
||||
d=LM_CNST(0.5)/d; /* invert so that divisions can be carried out faster as multiplications */
|
||||
for(i=0; i<n; ++i){
|
||||
jac[i*m+j]=(hxp[i]-hxm[i])*d;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Check the Jacobian of a n-valued nonlinear function in m variables
|
||||
* evaluated at a point p, for consistency with the function itself.
|
||||
*
|
||||
* Based on fortran77 subroutine CHKDER by
|
||||
* Burton S. Garbow, Kenneth E. Hillstrom, Jorge J. More
|
||||
* Argonne National Laboratory. MINPACK project. March 1980.
|
||||
*
|
||||
*
|
||||
* func points to a function from R^m --> R^n: Given a p in R^m it yields hx in R^n
|
||||
* jacf points to a function implementing the Jacobian of func, whose correctness
|
||||
* is to be tested. Given a p in R^m, jacf computes into the nxm matrix j the
|
||||
* Jacobian of func at p. Note that row i of j corresponds to the gradient of
|
||||
* the i-th component of func, evaluated at p.
|
||||
* p is an input array of length m containing the point of evaluation.
|
||||
* m is the number of variables
|
||||
* n is the number of functions
|
||||
* adata points to possible additional data and is passed uninterpreted
|
||||
* to func, jacf.
|
||||
* err is an array of length n. On output, err contains measures
|
||||
* of correctness of the respective gradients. if there is
|
||||
* no severe loss of significance, then if err[i] is 1.0 the
|
||||
* i-th gradient is correct, while if err[i] is 0.0 the i-th
|
||||
* gradient is incorrect. For values of err between 0.0 and 1.0,
|
||||
* the categorization is less certain. In general, a value of
|
||||
* err[i] greater than 0.5 indicates that the i-th gradient is
|
||||
* probably correct, while a value of err[i] less than 0.5
|
||||
* indicates that the i-th gradient is probably incorrect.
|
||||
*
|
||||
*
|
||||
* The function does not perform reliably if cancellation or
|
||||
* rounding errors cause a severe loss of significance in the
|
||||
* evaluation of a function. therefore, none of the components
|
||||
* of p should be unusually small (in particular, zero) or any
|
||||
* other value which may cause loss of significance.
|
||||
*/
|
||||
|
||||
void LEVMAR_CHKJAC(
|
||||
void (*func)(LM_REAL *p, LM_REAL *hx, int m, int n, void *adata),
|
||||
void (*jacf)(LM_REAL *p, LM_REAL *j, int m, int n, void *adata),
|
||||
LM_REAL *p, int m, int n, void *adata, LM_REAL *err)
|
||||
{
|
||||
LM_REAL factor=LM_CNST(100.0);
|
||||
LM_REAL one=LM_CNST(1.0);
|
||||
LM_REAL zero=LM_CNST(0.0);
|
||||
LM_REAL *fvec, *fjac, *pp, *fvecp, *buf;
|
||||
|
||||
register int i, j;
|
||||
LM_REAL eps, epsf, temp, epsmch;
|
||||
LM_REAL epslog;
|
||||
int fvec_sz=n, fjac_sz=n*m, pp_sz=m, fvecp_sz=n;
|
||||
|
||||
epsmch=LM_REAL_EPSILON;
|
||||
eps=(LM_REAL)sqrt(epsmch);
|
||||
|
||||
buf=(LM_REAL *)malloc((fvec_sz + fjac_sz + pp_sz + fvecp_sz)*sizeof(LM_REAL));
|
||||
if(!buf){
|
||||
fprintf(stderr, LCAT(LEVMAR_CHKJAC, "(): memory allocation request failed\n"));
|
||||
exit(1);
|
||||
}
|
||||
fvec=buf;
|
||||
fjac=fvec+fvec_sz;
|
||||
pp=fjac+fjac_sz;
|
||||
fvecp=pp+pp_sz;
|
||||
|
||||
/* compute fvec=func(p) */
|
||||
(*func)(p, fvec, m, n, adata);
|
||||
|
||||
/* compute the Jacobian at p */
|
||||
(*jacf)(p, fjac, m, n, adata);
|
||||
|
||||
/* compute pp */
|
||||
for(j=0; j<m; ++j){
|
||||
temp=eps*FABS(p[j]);
|
||||
if(temp==zero) temp=eps;
|
||||
pp[j]=p[j]+temp;
|
||||
}
|
||||
|
||||
/* compute fvecp=func(pp) */
|
||||
(*func)(pp, fvecp, m, n, adata);
|
||||
|
||||
epsf=factor*epsmch;
|
||||
epslog=(LM_REAL)log10(eps);
|
||||
|
||||
for(i=0; i<n; ++i)
|
||||
err[i]=zero;
|
||||
|
||||
for(j=0; j<m; ++j){
|
||||
temp=FABS(p[j]);
|
||||
if(temp==zero) temp=one;
|
||||
|
||||
for(i=0; i<n; ++i)
|
||||
err[i]+=temp*fjac[i*m+j];
|
||||
}
|
||||
|
||||
for(i=0; i<n; ++i){
|
||||
temp=one;
|
||||
if(fvec[i]!=zero && fvecp[i]!=zero && FABS(fvecp[i]-fvec[i])>=epsf*FABS(fvec[i]))
|
||||
temp=eps*FABS((fvecp[i]-fvec[i])/eps - err[i])/(FABS(fvec[i])+FABS(fvecp[i]));
|
||||
err[i]=one;
|
||||
if(temp>epsmch && temp<eps)
|
||||
err[i]=((LM_REAL)log10(temp) - epslog)/epslog;
|
||||
if(temp>=eps) err[i]=zero;
|
||||
}
|
||||
|
||||
free(buf);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef HAVE_LAPACK
|
||||
/*
|
||||
* This function computes the pseudoinverse of a square matrix A
|
||||
* into B using SVD. A and B can coincide
|
||||
*
|
||||
* The function returns 0 in case of error (e.g. A is singular),
|
||||
* the rank of A if successful
|
||||
*
|
||||
* A, B are mxm
|
||||
*
|
||||
*/
|
||||
static int LEVMAR_PSEUDOINVERSE(LM_REAL *A, LM_REAL *B, int m)
|
||||
{
|
||||
LM_REAL *buf=NULL;
|
||||
int buf_sz=0;
|
||||
static LM_REAL eps=LM_CNST(-1.0);
|
||||
|
||||
register int i, j;
|
||||
LM_REAL *a, *u, *s, *vt, *work;
|
||||
int a_sz, u_sz, s_sz, vt_sz, tot_sz;
|
||||
LM_REAL thresh, one_over_denom;
|
||||
int info, rank, worksz, *iwork, iworksz;
|
||||
|
||||
/* calculate required memory size */
|
||||
worksz=5*m; // min worksize for GESVD
|
||||
//worksz=m*(7*m+4); // min worksize for GESDD
|
||||
iworksz=8*m;
|
||||
a_sz=m*m;
|
||||
u_sz=m*m; s_sz=m; vt_sz=m*m;
|
||||
|
||||
tot_sz=(a_sz + u_sz + s_sz + vt_sz + worksz)*sizeof(LM_REAL) + iworksz*sizeof(int); /* should be arranged in that order for proper doubles alignment */
|
||||
|
||||
buf_sz=tot_sz;
|
||||
buf=(LM_REAL *)malloc(buf_sz);
|
||||
if(!buf){
|
||||
fprintf(stderr, RCAT("memory allocation in ", LEVMAR_PSEUDOINVERSE) "() failed!\n");
|
||||
return 0; /* error */
|
||||
}
|
||||
|
||||
a=buf;
|
||||
u=a+a_sz;
|
||||
s=u+u_sz;
|
||||
vt=s+s_sz;
|
||||
work=vt+vt_sz;
|
||||
iwork=(int *)(work+worksz);
|
||||
|
||||
/* store A (column major!) into a */
|
||||
for(i=0; i<m; i++)
|
||||
for(j=0; j<m; j++)
|
||||
a[i+j*m]=A[i*m+j];
|
||||
|
||||
/* SVD decomposition of A */
|
||||
GESVD("A", "A", (int *)&m, (int *)&m, a, (int *)&m, s, u, (int *)&m, vt, (int *)&m, work, (int *)&worksz, &info);
|
||||
//GESDD("A", (int *)&m, (int *)&m, a, (int *)&m, s, u, (int *)&m, vt, (int *)&m, work, (int *)&worksz, iwork, &info);
|
||||
|
||||
/* error treatment */
|
||||
if(info!=0){
|
||||
if(info<0){
|
||||
fprintf(stderr, RCAT(RCAT(RCAT("LAPACK error: illegal value for argument %d of ", GESVD), "/" GESDD) " in ", LEVMAR_PSEUDOINVERSE) "()\n", -info);
|
||||
}
|
||||
else{
|
||||
fprintf(stderr, RCAT("LAPACK error: dgesdd (dbdsdc)/dgesvd (dbdsqr) failed to converge in ", LEVMAR_PSEUDOINVERSE) "() [info=%d]\n", info);
|
||||
}
|
||||
free(buf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(eps<0.0){
|
||||
LM_REAL aux;
|
||||
|
||||
/* compute machine epsilon */
|
||||
for(eps=LM_CNST(1.0); aux=eps+LM_CNST(1.0), aux-LM_CNST(1.0)>0.0; eps*=LM_CNST(0.5))
|
||||
;
|
||||
eps*=LM_CNST(2.0);
|
||||
}
|
||||
|
||||
/* compute the pseudoinverse in B */
|
||||
for(i=0; i<a_sz; i++) B[i]=0.0; /* initialize to zero */
|
||||
for(rank=0, thresh=eps*s[0]; rank<m && s[rank]>thresh; rank++){
|
||||
one_over_denom=LM_CNST(1.0)/s[rank];
|
||||
|
||||
for(j=0; j<m; j++)
|
||||
for(i=0; i<m; i++)
|
||||
B[i*m+j]+=vt[rank+i*m]*u[j+rank*m]*one_over_denom;
|
||||
}
|
||||
|
||||
free(buf);
|
||||
|
||||
return rank;
|
||||
}
|
||||
#else // no LAPACK
|
||||
|
||||
/*
|
||||
* This function computes the inverse of A in B. A and B can coincide
|
||||
*
|
||||
* The function employs LAPACK-free LU decomposition of A to solve m linear
|
||||
* systems A*B_i=I_i, where B_i and I_i are the i-th columns of B and I.
|
||||
*
|
||||
* A and B are mxm
|
||||
*
|
||||
* The function returns 0 in case of error, 1 if successful
|
||||
*
|
||||
*/
|
||||
static int LEVMAR_LUINVERSE(LM_REAL *A, LM_REAL *B, int m)
|
||||
{
|
||||
void *buf=NULL;
|
||||
//int buf_sz=0;
|
||||
|
||||
register int i, j, k, l;
|
||||
int *idx, maxi=-1, idx_sz, a_sz, x_sz, work_sz, tot_sz;
|
||||
LM_REAL *a, *x, *work, max, sum, tmp;
|
||||
|
||||
/* calculate required memory size */
|
||||
idx_sz=m;
|
||||
a_sz=m*m;
|
||||
x_sz=m;
|
||||
work_sz=m;
|
||||
tot_sz=(a_sz + x_sz + work_sz)*sizeof(LM_REAL) + idx_sz*sizeof(int); /* should be arranged in that order for proper doubles alignment */
|
||||
|
||||
//buf_sz=tot_sz;
|
||||
buf=(void *)malloc(tot_sz);
|
||||
if(!buf){
|
||||
fprintf(stderr, RCAT("memory allocation in ", LEVMAR_LUINVERSE) "() failed!\n");
|
||||
return 0; /* error */
|
||||
}
|
||||
|
||||
a=buf;
|
||||
x=a+a_sz;
|
||||
work=x+x_sz;
|
||||
idx=(int *)(work+work_sz);
|
||||
|
||||
/* avoid destroying A by copying it to a */
|
||||
for(i=0; i<a_sz; ++i) a[i]=A[i];
|
||||
|
||||
/* compute the LU decomposition of a row permutation of matrix a; the permutation itself is saved in idx[] */
|
||||
for(i=0; i<m; ++i){
|
||||
max=0.0;
|
||||
for(j=0; j<m; ++j)
|
||||
if((tmp=FABS(a[i*m+j]))>max)
|
||||
max=tmp;
|
||||
if(max==0.0){
|
||||
fprintf(stderr, RCAT("Singular matrix A in ", LEVMAR_LUINVERSE) "()!\n");
|
||||
free(buf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
work[i]=LM_CNST(1.0)/max;
|
||||
}
|
||||
|
||||
for(j=0; j<m; ++j){
|
||||
for(i=0; i<j; ++i){
|
||||
sum=a[i*m+j];
|
||||
for(k=0; k<i; ++k)
|
||||
sum-=a[i*m+k]*a[k*m+j];
|
||||
a[i*m+j]=sum;
|
||||
}
|
||||
max=0.0;
|
||||
for(i=j; i<m; ++i){
|
||||
sum=a[i*m+j];
|
||||
for(k=0; k<j; ++k)
|
||||
sum-=a[i*m+k]*a[k*m+j];
|
||||
a[i*m+j]=sum;
|
||||
if((tmp=work[i]*FABS(sum))>=max){
|
||||
max=tmp;
|
||||
maxi=i;
|
||||
}
|
||||
}
|
||||
if(j!=maxi){
|
||||
for(k=0; k<m; ++k){
|
||||
tmp=a[maxi*m+k];
|
||||
a[maxi*m+k]=a[j*m+k];
|
||||
a[j*m+k]=tmp;
|
||||
}
|
||||
work[maxi]=work[j];
|
||||
}
|
||||
idx[j]=maxi;
|
||||
if(a[j*m+j]==0.0)
|
||||
a[j*m+j]=LM_REAL_EPSILON;
|
||||
if(j!=m-1){
|
||||
tmp=LM_CNST(1.0)/(a[j*m+j]);
|
||||
for(i=j+1; i<m; ++i)
|
||||
a[i*m+j]*=tmp;
|
||||
}
|
||||
}
|
||||
|
||||
/* The decomposition has now replaced a. Solve the m linear systems using
|
||||
* forward and back substitution
|
||||
*/
|
||||
for(l=0; l<m; ++l){
|
||||
for(i=0; i<m; ++i) x[i]=0.0;
|
||||
x[l]=LM_CNST(1.0);
|
||||
|
||||
for(i=k=0; i<m; ++i){
|
||||
j=idx[i];
|
||||
sum=x[j];
|
||||
x[j]=x[i];
|
||||
if(k!=0)
|
||||
for(j=k-1; j<i; ++j)
|
||||
sum-=a[i*m+j]*x[j];
|
||||
else
|
||||
if(sum!=0.0)
|
||||
k=i+1;
|
||||
x[i]=sum;
|
||||
}
|
||||
|
||||
for(i=m-1; i>=0; --i){
|
||||
sum=x[i];
|
||||
for(j=i+1; j<m; ++j)
|
||||
sum-=a[i*m+j]*x[j];
|
||||
x[i]=sum/a[i*m+i];
|
||||
}
|
||||
|
||||
for(i=0; i<m; ++i)
|
||||
B[i*m+l]=x[i];
|
||||
}
|
||||
|
||||
free(buf);
|
||||
|
||||
return 1;
|
||||
}
|
||||
#endif /* HAVE_LAPACK */
|
||||
|
||||
/*
|
||||
* This function computes in C the covariance matrix corresponding to a least
|
||||
* squares fit. JtJ is the approximate Hessian at the solution (i.e. J^T*J, where
|
||||
* J is the Jacobian at the solution), sumsq is the sum of squared residuals
|
||||
* (i.e. goodnes of fit) at the solution, m is the number of parameters (variables)
|
||||
* and n the number of observations. JtJ can coincide with C.
|
||||
*
|
||||
* if JtJ is of full rank, C is computed as sumsq/(n-m)*(JtJ)^-1
|
||||
* otherwise and if LAPACK is available, C=sumsq/(n-r)*(JtJ)^+
|
||||
* where r is JtJ's rank and ^+ denotes the pseudoinverse
|
||||
* The diagonal of C is made up from the estimates of the variances
|
||||
* of the estimated regression coefficients.
|
||||
* See the documentation of routine E04YCF from the NAG fortran lib
|
||||
*
|
||||
* The function returns the rank of JtJ if successful, 0 on error
|
||||
*
|
||||
* A and C are mxm
|
||||
*
|
||||
*/
|
||||
int LEVMAR_COVAR(LM_REAL *JtJ, LM_REAL *C, LM_REAL sumsq, int m, int n)
|
||||
{
|
||||
register int i;
|
||||
int rnk;
|
||||
LM_REAL fact;
|
||||
|
||||
#ifdef HAVE_LAPACK
|
||||
rnk=LEVMAR_PSEUDOINVERSE(JtJ, C, m);
|
||||
if(!rnk) return 0;
|
||||
#else
|
||||
#ifdef _MSC_VER
|
||||
#pragma message("LAPACK not available, LU will be used for matrix inversion when computing the covariance; this might be unstable at times")
|
||||
#else
|
||||
#warning LAPACK not available, LU will be used for matrix inversion when computing the covariance; this might be unstable at times
|
||||
#endif // _MSC_VER
|
||||
|
||||
rnk=LEVMAR_LUINVERSE(JtJ, C, m);
|
||||
if(!rnk) return 0;
|
||||
|
||||
rnk=m; /* assume full rank */
|
||||
#endif /* HAVE_LAPACK */
|
||||
|
||||
fact=sumsq/(LM_REAL)(n-rnk);
|
||||
for(i=0; i<m*m; ++i)
|
||||
C[i]*=fact;
|
||||
|
||||
return rnk;
|
||||
}
|
||||
|
||||
/* standard deviation of the best-fit parameter i.
|
||||
* covar is the mxm covariance matrix of the best-fit parameters (see also LEVMAR_COVAR()).
|
||||
*
|
||||
* The standard deviation is computed as \sigma_{i} = \sqrt{C_{ii}}
|
||||
*/
|
||||
LM_REAL LEVMAR_STDDEV(LM_REAL *covar, int m, int i)
|
||||
{
|
||||
return (LM_REAL)sqrt(covar[i*m+i]);
|
||||
}
|
||||
|
||||
/* Pearson's correlation coefficient of the best-fit parameters i and j.
|
||||
* covar is the mxm covariance matrix of the best-fit parameters (see also LEVMAR_COVAR()).
|
||||
*
|
||||
* The coefficient is computed as \rho_{ij} = C_{ij} / sqrt(C_{ii} C_{jj})
|
||||
*/
|
||||
LM_REAL LEVMAR_CORCOEF(LM_REAL *covar, int m, int i, int j)
|
||||
{
|
||||
return (LM_REAL)(covar[i*m+j]/sqrt(covar[i*m+i]*covar[j*m+j]));
|
||||
}
|
||||
|
||||
/* coefficient of determination.
|
||||
* see http://en.wikipedia.org/wiki/Coefficient_of_determination
|
||||
*/
|
||||
LM_REAL LEVMAR_R2(void (*func)(LM_REAL *p, LM_REAL *hx, int m, int n, void *adata),
|
||||
LM_REAL *p, LM_REAL *x, int m, int n, void *adata)
|
||||
{
|
||||
register int i;
|
||||
register LM_REAL tmp;
|
||||
LM_REAL SSerr, // sum of squared errors, i.e. residual sum of squares \sum_i (x_i-hx_i)^2
|
||||
SStot, // \sum_i (x_i-xavg)^2
|
||||
*hx, xavg;
|
||||
|
||||
|
||||
if((hx=(LM_REAL *)malloc(n*sizeof(LM_REAL)))==NULL){
|
||||
fprintf(stderr, RCAT("memory allocation request failed in ", LEVMAR_R2) "()\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* hx=f(p) */
|
||||
(*func)(p, hx, m, n, adata);
|
||||
|
||||
for(i=n, tmp=0.0; i-->0; )
|
||||
tmp+=x[i];
|
||||
xavg=tmp/(LM_REAL)n;
|
||||
|
||||
if(x)
|
||||
for(i=n, SSerr=SStot=0.0; i-->0; ){
|
||||
tmp=x[i]-hx[i];
|
||||
SSerr+=tmp*tmp;
|
||||
|
||||
tmp=x[i]-xavg;
|
||||
SStot+=tmp*tmp;
|
||||
}
|
||||
else /* x==0 */
|
||||
for(i=n, SSerr=SStot=0.0; i-->0; ){
|
||||
tmp=-hx[i];
|
||||
SSerr+=tmp*tmp;
|
||||
|
||||
tmp=-xavg;
|
||||
SStot+=tmp*tmp;
|
||||
}
|
||||
|
||||
free(hx);
|
||||
|
||||
return LM_CNST(1.0) - SSerr/SStot;
|
||||
}
|
||||
|
||||
/* check box constraints for consistency */
|
||||
int LEVMAR_BOX_CHECK(LM_REAL *lb, LM_REAL *ub, int m)
|
||||
{
|
||||
register int i;
|
||||
|
||||
if(!lb || !ub) return 1;
|
||||
|
||||
for(i=0; i<m; ++i)
|
||||
if(lb[i]>ub[i]) return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef HAVE_LAPACK
|
||||
|
||||
/* compute the Cholesky decomposition of C in W, s.t. C=W^t W and W is upper triangular */
|
||||
int LEVMAR_CHOLESKY(LM_REAL *C, LM_REAL *W, int m)
|
||||
{
|
||||
register int i, j;
|
||||
int info;
|
||||
|
||||
/* copy weights array C to W so that LAPACK won't destroy it;
|
||||
* C is assumed symmetric, hence no transposition is needed
|
||||
*/
|
||||
for(i=0, j=m*m; i<j; ++i)
|
||||
W[i]=C[i];
|
||||
|
||||
/* Cholesky decomposition */
|
||||
POTF2("L", (int *)&m, W, (int *)&m, (int *)&info);
|
||||
/* error treatment */
|
||||
if(info!=0){
|
||||
if(info<0){
|
||||
fprintf(stderr, "LAPACK error: illegal value for argument %d of dpotf2 in %s\n", -info, LCAT(LEVMAR_CHOLESKY, "()"));
|
||||
}
|
||||
else{
|
||||
fprintf(stderr, "LAPACK error: the leading minor of order %d is not positive definite,\n%s()\n", info,
|
||||
RCAT("and the Cholesky factorization could not be completed in ", LEVMAR_CHOLESKY));
|
||||
}
|
||||
return LM_ERROR;
|
||||
}
|
||||
|
||||
/* the decomposition is in the lower part of W (in column-major order!).
|
||||
* zeroing the upper part makes it lower triangular which is equivalent to
|
||||
* upper triangular in row-major order
|
||||
*/
|
||||
for(i=0; i<m; i++)
|
||||
for(j=i+1; j<m; j++)
|
||||
W[i+j*m]=0.0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif /* HAVE_LAPACK */
|
||||
|
||||
|
||||
/* Compute e=x-y for two n-vectors x and y and return the squared L2 norm of e.
|
||||
* e can coincide with either x or y; x can be NULL, in which case it is assumed
|
||||
* to be equal to the zero vector.
|
||||
* Uses loop unrolling and blocking to reduce bookkeeping overhead & pipeline
|
||||
* stalls and increase instruction-level parallelism; see http://www.abarnett.demon.co.uk/tutorial.html
|
||||
*/
|
||||
|
||||
LM_REAL LEVMAR_L2NRMXMY(LM_REAL *e, LM_REAL *x, LM_REAL *y, int n)
|
||||
{
|
||||
const int blocksize=8, bpwr=3; /* 8=2^3 */
|
||||
register int i;
|
||||
int j1, j2, j3, j4, j5, j6, j7;
|
||||
int blockn;
|
||||
register LM_REAL sum0=0.0, sum1=0.0, sum2=0.0, sum3=0.0;
|
||||
|
||||
/* n may not be divisible by blocksize,
|
||||
* go as near as we can first, then tidy up.
|
||||
*/
|
||||
blockn = (n>>bpwr)<<bpwr; /* (n / blocksize) * blocksize; */
|
||||
|
||||
/* unroll the loop in blocks of `blocksize'; looping downwards gains some more speed */
|
||||
if(x){
|
||||
for(i=blockn-1; i>0; i-=blocksize){
|
||||
e[i ]=x[i ]-y[i ]; sum0+=e[i ]*e[i ];
|
||||
j1=i-1; e[j1]=x[j1]-y[j1]; sum1+=e[j1]*e[j1];
|
||||
j2=i-2; e[j2]=x[j2]-y[j2]; sum2+=e[j2]*e[j2];
|
||||
j3=i-3; e[j3]=x[j3]-y[j3]; sum3+=e[j3]*e[j3];
|
||||
j4=i-4; e[j4]=x[j4]-y[j4]; sum0+=e[j4]*e[j4];
|
||||
j5=i-5; e[j5]=x[j5]-y[j5]; sum1+=e[j5]*e[j5];
|
||||
j6=i-6; e[j6]=x[j6]-y[j6]; sum2+=e[j6]*e[j6];
|
||||
j7=i-7; e[j7]=x[j7]-y[j7]; sum3+=e[j7]*e[j7];
|
||||
}
|
||||
|
||||
/*
|
||||
* There may be some left to do.
|
||||
* This could be done as a simple for() loop,
|
||||
* but a switch is faster (and more interesting)
|
||||
*/
|
||||
|
||||
i=blockn;
|
||||
if(i<n){
|
||||
/* Jump into the case at the place that will allow
|
||||
* us to finish off the appropriate number of items.
|
||||
*/
|
||||
|
||||
switch(n - i){
|
||||
case 7 : e[i]=x[i]-y[i]; sum0+=e[i]*e[i]; ++i;
|
||||
case 6 : e[i]=x[i]-y[i]; sum1+=e[i]*e[i]; ++i;
|
||||
case 5 : e[i]=x[i]-y[i]; sum2+=e[i]*e[i]; ++i;
|
||||
case 4 : e[i]=x[i]-y[i]; sum3+=e[i]*e[i]; ++i;
|
||||
case 3 : e[i]=x[i]-y[i]; sum0+=e[i]*e[i]; ++i;
|
||||
case 2 : e[i]=x[i]-y[i]; sum1+=e[i]*e[i]; ++i;
|
||||
case 1 : e[i]=x[i]-y[i]; sum2+=e[i]*e[i]; //++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
else{ /* x==0 */
|
||||
for(i=blockn-1; i>0; i-=blocksize){
|
||||
e[i ]=-y[i ]; sum0+=e[i ]*e[i ];
|
||||
j1=i-1; e[j1]=-y[j1]; sum1+=e[j1]*e[j1];
|
||||
j2=i-2; e[j2]=-y[j2]; sum2+=e[j2]*e[j2];
|
||||
j3=i-3; e[j3]=-y[j3]; sum3+=e[j3]*e[j3];
|
||||
j4=i-4; e[j4]=-y[j4]; sum0+=e[j4]*e[j4];
|
||||
j5=i-5; e[j5]=-y[j5]; sum1+=e[j5]*e[j5];
|
||||
j6=i-6; e[j6]=-y[j6]; sum2+=e[j6]*e[j6];
|
||||
j7=i-7; e[j7]=-y[j7]; sum3+=e[j7]*e[j7];
|
||||
}
|
||||
|
||||
/*
|
||||
* There may be some left to do.
|
||||
* This could be done as a simple for() loop,
|
||||
* but a switch is faster (and more interesting)
|
||||
*/
|
||||
|
||||
i=blockn;
|
||||
if(i<n){
|
||||
/* Jump into the case at the place that will allow
|
||||
* us to finish off the appropriate number of items.
|
||||
*/
|
||||
|
||||
switch(n - i){
|
||||
case 7 : e[i]=-y[i]; sum0+=e[i]*e[i]; ++i;
|
||||
case 6 : e[i]=-y[i]; sum1+=e[i]*e[i]; ++i;
|
||||
case 5 : e[i]=-y[i]; sum2+=e[i]*e[i]; ++i;
|
||||
case 4 : e[i]=-y[i]; sum3+=e[i]*e[i]; ++i;
|
||||
case 3 : e[i]=-y[i]; sum0+=e[i]*e[i]; ++i;
|
||||
case 2 : e[i]=-y[i]; sum1+=e[i]*e[i]; ++i;
|
||||
case 1 : e[i]=-y[i]; sum2+=e[i]*e[i]; //++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return sum0+sum1+sum2+sum3;
|
||||
}
|
||||
|
||||
/* undefine everything. THIS MUST REMAIN AT THE END OF THE FILE */
|
||||
#undef POTF2
|
||||
#undef GESVD
|
||||
#undef GESDD
|
||||
#undef GEMM
|
||||
#undef LEVMAR_PSEUDOINVERSE
|
||||
#undef LEVMAR_LUINVERSE
|
||||
#undef LEVMAR_BOX_CHECK
|
||||
#undef LEVMAR_CHOLESKY
|
||||
#undef LEVMAR_COVAR
|
||||
#undef LEVMAR_STDDEV
|
||||
#undef LEVMAR_CORCOEF
|
||||
#undef LEVMAR_R2
|
||||
#undef LEVMAR_CHKJAC
|
||||
#undef LEVMAR_FDIF_FORW_JAC_APPROX
|
||||
#undef LEVMAR_FDIF_CENT_JAC_APPROX
|
||||
#undef LEVMAR_TRANS_MAT_MAT_MULT
|
||||
#undef LEVMAR_L2NRMXMY
|
||||
30
contrib/lmfit/COPYING
Normal file
30
contrib/lmfit/COPYING
Normal file
@@ -0,0 +1,30 @@
|
||||
The package lmfit is distributed under the FreeBSD License:
|
||||
|
||||
--
|
||||
Copyright (c) 1980-1999 University of Chicago,
|
||||
as operator of Argonne National Laboratory
|
||||
Copyright (c) 2004-2015 Joachim Wuttke, Forschungszentrum Juelich GmbH
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
- Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
This software is provided by the copyright holders and contributors "as is"
|
||||
and any express or implied warranties, including, but not limited to, the
|
||||
implied warranties of merchantability and fitness for a particular purpose
|
||||
are disclaimed. In no event shall the copyright holder or contributors
|
||||
be liable for any direct, indirect, incidental, special, exemplary, or
|
||||
consequential damages (including, but not limited to, procurement of
|
||||
substitute goods or services; loss of use, data, or profits; or business
|
||||
interruption) however caused and on any theory of liability, whether in
|
||||
contract, strict liability, or tort (including negligence or otherwise)
|
||||
arising in any way out of the use of this software, even if advised of the
|
||||
possibility of such damage.
|
||||
--
|
||||
53
contrib/lmfit/lmcurve.c
Normal file
53
contrib/lmfit/lmcurve.c
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Library: lmfit (Levenberg-Marquardt least squares fitting)
|
||||
*
|
||||
* File: lmcurve.c
|
||||
*
|
||||
* Contents: Implements lmcurve, a simplified API for curve fitting
|
||||
* using the generic Levenberg-Marquardt routine lmmin.
|
||||
*
|
||||
* Copyright: Joachim Wuttke, Forschungszentrum Juelich GmbH (2004-2013)
|
||||
*
|
||||
* License: see ../COPYING (FreeBSD)
|
||||
*
|
||||
* Homepage: apps.jcns.fz-juelich.de/lmfit
|
||||
*
|
||||
* Note to programmers: Don't patch and fork, but copy and modify!
|
||||
* If you need to compute residues differently, then please do not patch
|
||||
* lmcurve.h and lmcurve.c, but copy them, and create differently named
|
||||
* versions of lmcurve_data_struct, lmcurve_evaluate, and lmcurve of your own.
|
||||
*/
|
||||
|
||||
#include "lmmin.h"
|
||||
|
||||
|
||||
typedef struct {
|
||||
const double *const t;
|
||||
const double *const y;
|
||||
double (*const g) (const double t, const double *par);
|
||||
} lmcurve_data_struct;
|
||||
|
||||
|
||||
void lmcurve_evaluate(
|
||||
const double *const par, const int m_dat, const void *const data,
|
||||
double *const fvec, int *const info)
|
||||
{
|
||||
(void)(info);
|
||||
for (int i = 0; i < m_dat; i++ )
|
||||
fvec[i] =
|
||||
((lmcurve_data_struct*)data)->y[i] -
|
||||
((lmcurve_data_struct*)data)->g(
|
||||
((lmcurve_data_struct*)data)->t[i], par );
|
||||
}
|
||||
|
||||
|
||||
void lmcurve(
|
||||
const int n_par, double *const par, const int m_dat,
|
||||
const double *const t, const double *const y,
|
||||
double (*const g)(const double t, const double *const par),
|
||||
const lm_control_struct *const control, lm_status_struct *const status)
|
||||
{
|
||||
lmcurve_data_struct data = {t, y, g};
|
||||
lmmin(n_par, par, m_dat, NULL, (const void *const) &data,
|
||||
lmcurve_evaluate, control, status);
|
||||
}
|
||||
45
contrib/lmfit/lmcurve.h
Normal file
45
contrib/lmfit/lmcurve.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Library: lmfit (Levenberg-Marquardt least squares fitting)
|
||||
*
|
||||
* File: lmcurve.h
|
||||
*
|
||||
* Contents: Declares lmcurve, a simplified API for curve fitting
|
||||
* using the generic Levenberg-Marquardt routine lmmin.
|
||||
*
|
||||
* Copyright: Joachim Wuttke, Forschungszentrum Juelich GmbH (2004-2013)
|
||||
*
|
||||
* License: see ../COPYING (FreeBSD)
|
||||
*
|
||||
* Homepage: apps.jcns.fz-juelich.de/lmfit
|
||||
*
|
||||
* Note to programmers: Don't patch and fork, but copy and variate!
|
||||
* If you need to compute residues differently, then please do not patch
|
||||
* lmcurve.h, but copy it to a differently named file, and change lmcurve()
|
||||
* into a differently named function declaration, like we have done in
|
||||
* lmcurve_tyd.h.
|
||||
*/
|
||||
|
||||
#ifndef LMCURVE_H
|
||||
#define LMCURVE_H
|
||||
#undef __BEGIN_DECLS
|
||||
#undef __END_DECLS
|
||||
#ifdef __cplusplus
|
||||
#define __BEGIN_DECLS extern "C" {
|
||||
#define __END_DECLS }
|
||||
#else
|
||||
#define __BEGIN_DECLS /* empty */
|
||||
#define __END_DECLS /* empty */
|
||||
#endif
|
||||
|
||||
#include<lmstruct.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
void lmcurve(
|
||||
const int n_par, double* par, const int m_dat,
|
||||
const double* t, const double* y,
|
||||
double (*g)(const double t, const double* par),
|
||||
const lm_control_struct* control, lm_status_struct* status);
|
||||
|
||||
__END_DECLS
|
||||
#endif /* LMCURVE_H */
|
||||
39
contrib/lmfit/lmcurve_tyd.h
Normal file
39
contrib/lmfit/lmcurve_tyd.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Library: lmfit (Levenberg-Marquardt least squares fitting)
|
||||
*
|
||||
* File: lmcurve_tyd.h
|
||||
*
|
||||
* Contents: Declares lmcurve_tyd(), a variant of lmcurve() that weighs
|
||||
* data points y(t) with the inverse of the standard deviations dy.
|
||||
*
|
||||
* Copyright: Joachim Wuttke, Forschungszentrum Juelich GmbH (2004-2013)
|
||||
*
|
||||
* License: see ../COPYING (FreeBSD)
|
||||
*
|
||||
* Homepage: apps.jcns.fz-juelich.de/lmfit
|
||||
*/
|
||||
|
||||
#ifndef LMCURVETYD_H
|
||||
#define LMCURVETYD_H
|
||||
#undef __BEGIN_DECLS
|
||||
#undef __END_DECLS
|
||||
#ifdef __cplusplus
|
||||
#define __BEGIN_DECLS extern "C" {
|
||||
#define __END_DECLS }
|
||||
#else
|
||||
#define __BEGIN_DECLS /* empty */
|
||||
#define __END_DECLS /* empty */
|
||||
#endif
|
||||
|
||||
#include <lmstruct.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
void lmcurve_tyd(
|
||||
const int n_par, double* par, const int m_dat,
|
||||
const double* t, const double* y, const double* dy,
|
||||
double (*f)(double t, const double* par),
|
||||
const lm_control_struct* control, lm_status_struct* status);
|
||||
|
||||
__END_DECLS
|
||||
#endif /* LMCURVETYD_H */
|
||||
1283
contrib/lmfit/lmmin.c
Normal file
1283
contrib/lmfit/lmmin.c
Normal file
File diff suppressed because it is too large
Load Diff
84
contrib/lmfit/lmmin.h
Normal file
84
contrib/lmfit/lmmin.h
Normal file
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Library: lmfit (Levenberg-Marquardt least squares fitting)
|
||||
*
|
||||
* File: lmmin.h
|
||||
*
|
||||
* Contents: Declarations for Levenberg-Marquardt minimization.
|
||||
*
|
||||
* Copyright: Joachim Wuttke, Forschungszentrum Juelich GmbH (2004-2013)
|
||||
*
|
||||
* License: see ../COPYING (FreeBSD)
|
||||
*
|
||||
* Homepage: apps.jcns.fz-juelich.de/lmfit
|
||||
*/
|
||||
|
||||
#ifndef LMMIN_H
|
||||
#define LMMIN_H
|
||||
#undef __BEGIN_DECLS
|
||||
#undef __END_DECLS
|
||||
#ifdef __cplusplus
|
||||
#define __BEGIN_DECLS extern "C" {
|
||||
#define __END_DECLS }
|
||||
#else
|
||||
#define __BEGIN_DECLS /* empty */
|
||||
#define __END_DECLS /* empty */
|
||||
#endif
|
||||
|
||||
#include "lmstruct.h"
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/* Levenberg-Marquardt minimization. */
|
||||
void lmmin(
|
||||
const int n_par, double* par, const int m_dat, const double* y,
|
||||
const void* data,
|
||||
void (*evaluate)(
|
||||
const double* par, const int m_dat, const void* data,
|
||||
double* fvec, int* userbreak),
|
||||
const lm_control_struct* control, lm_status_struct* status);
|
||||
/*
|
||||
* This routine contains the core algorithm of our library.
|
||||
*
|
||||
* It minimizes the sum of the squares of m nonlinear functions
|
||||
* in n variables by a modified Levenberg-Marquardt algorithm.
|
||||
* The function evaluation is done by the user-provided routine 'evaluate'.
|
||||
* The Jacobian is then calculated by a forward-difference approximation.
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
* n_par is the number of variables (INPUT, positive integer).
|
||||
*
|
||||
* par is the solution vector (INPUT/OUTPUT, array of length n).
|
||||
* On input it must be set to an estimated solution.
|
||||
* On output it yields the final estimate of the solution.
|
||||
*
|
||||
* m_dat is the number of functions to be minimized (INPUT, positive integer).
|
||||
* It must fulfill m>=n.
|
||||
*
|
||||
* y contains data to be fitted. Use a null pointer if there are no data.
|
||||
*
|
||||
* data is a pointer that is ignored by lmmin; it is however forwarded
|
||||
* to the user-supplied functions evaluate and printout.
|
||||
* In a typical application, it contains experimental data to be fitted.
|
||||
*
|
||||
* evaluate is a user-supplied function that calculates the m functions.
|
||||
* Parameters:
|
||||
* n, x, m, data as above.
|
||||
* fvec is an array of length m; on OUTPUT, it must contain the
|
||||
* m function values for the parameter vector x.
|
||||
* userbreak is an integer pointer. When *userbreak is set to a
|
||||
* nonzero value, lmmin will terminate.
|
||||
*
|
||||
* control contains INPUT variables that control the fit algorithm,
|
||||
* as declared and explained in lmstruct.h
|
||||
*
|
||||
* status contains OUTPUT variables that inform about the fit result,
|
||||
* as declared and explained in lmstruct.h
|
||||
*/
|
||||
|
||||
/* Refined calculation of Eucledian norm. */
|
||||
double lm_enorm(const int, const double*);
|
||||
double lm_fnorm(const int, const double*, const double*);
|
||||
|
||||
__END_DECLS
|
||||
#endif /* LMMIN_H */
|
||||
81
contrib/lmfit/lmstruct.h
Normal file
81
contrib/lmfit/lmstruct.h
Normal file
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Library: lmfit (Levenberg-Marquardt least squares fitting)
|
||||
*
|
||||
* File: lmstruct.h
|
||||
*
|
||||
* Contents: Declarations of parameter records, used in lmmin.h and lmcurve.h
|
||||
*
|
||||
* Copyright: Joachim Wuttke, Forschungszentrum Juelich GmbH (2004-2013)
|
||||
*
|
||||
* License: see ../COPYING (FreeBSD)
|
||||
*
|
||||
* Homepage: apps.jcns.fz-juelich.de/lmfit
|
||||
*/
|
||||
|
||||
#ifndef LMSTRUCT_H
|
||||
#define LMSTRUCT_H
|
||||
#undef __BEGIN_DECLS
|
||||
#undef __END_DECLS
|
||||
#ifdef __cplusplus
|
||||
#define __BEGIN_DECLS extern "C" {
|
||||
#define __END_DECLS }
|
||||
#else
|
||||
#define __BEGIN_DECLS /* empty */
|
||||
#define __END_DECLS /* empty */
|
||||
#endif
|
||||
__BEGIN_DECLS
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* Collection of input parameters for fit control. */
|
||||
typedef struct {
|
||||
double ftol; /* Relative error desired in the sum of squares.
|
||||
Termination occurs when both the actual and
|
||||
predicted relative reductions in the sum of squares
|
||||
are at most ftol. */
|
||||
double xtol; /* Relative error between last two approximations.
|
||||
Termination occurs when the relative error between
|
||||
two consecutive iterates is at most xtol. */
|
||||
double gtol; /* Orthogonality desired between fvec and its derivs.
|
||||
Termination occurs when the cosine of the angle
|
||||
between fvec and any column of the Jacobian is at
|
||||
most gtol in absolute value. */
|
||||
double epsilon; /* Step used to calculate the Jacobian, should be
|
||||
slightly larger than the relative error in the
|
||||
user-supplied functions. */
|
||||
double stepbound; /* Used in determining the initial step bound. This
|
||||
bound is set to the product of stepbound and the
|
||||
Euclidean norm of diag*x if nonzero, or else to
|
||||
stepbound itself. In most cases stepbound should lie
|
||||
in the interval (0.1,100.0). Generally, the value
|
||||
100.0 is recommended. */
|
||||
int patience; /* Used to set the maximum number of function evaluations
|
||||
to patience*(number_of_parameters+1). */
|
||||
int scale_diag; /* If 1, the variables will be rescaled internally.
|
||||
Recommended value is 1. */
|
||||
FILE* msgfile; /* Progress messages will be written to this file. */
|
||||
int verbosity; /* OR'ed: 1: print some messages; 2: print Jacobian. */
|
||||
int n_maxpri; /* -1, or max number of parameters to print. */
|
||||
int m_maxpri; /* -1, or max number of residuals to print. */
|
||||
} lm_control_struct;
|
||||
|
||||
/* Collection of output parameters for status info. */
|
||||
typedef struct {
|
||||
double fnorm; /* norm of the residue vector fvec. */
|
||||
int nfev; /* actual number of iterations. */
|
||||
int outcome; /* Status indicator. Nonnegative values are used as index
|
||||
for the message text lm_infmsg, set in lmmin.c. */
|
||||
int userbreak; /* Set when function evaluation requests termination. */
|
||||
} lm_status_struct;
|
||||
|
||||
/* Preset (and recommended) control parameter settings. */
|
||||
extern const lm_control_struct lm_control_double;
|
||||
extern const lm_control_struct lm_control_float;
|
||||
|
||||
/* Preset message texts. */
|
||||
|
||||
extern const char* lm_infmsg[];
|
||||
extern const char* lm_shortmsg[];
|
||||
|
||||
__END_DECLS
|
||||
#endif /* LMSTRUCT_H */
|
||||
@@ -29,7 +29,7 @@ void QwtPlotGappedCurve::drawSeries(QPainter *painter, const QwtScaleMap &xMap,
|
||||
return;
|
||||
|
||||
if (to < 0)
|
||||
to = dataSize() - 1;
|
||||
to = dataSize();
|
||||
|
||||
int i = from;
|
||||
double last = 0;
|
||||
@@ -38,7 +38,11 @@ void QwtPlotGappedCurve::drawSeries(QPainter *painter, const QwtScaleMap &xMap,
|
||||
// First non-missed point will be the start of curve section.
|
||||
double x = sample(i).x();
|
||||
double y = sample(i).y();
|
||||
if ((y < (naValue_ + -0.001) || y > (naValue_ + 0.001)) && x - last <= gapValue_) {
|
||||
double yprev = 0;
|
||||
if (i>0) yprev = sample(i-1).y();
|
||||
|
||||
if ((y < (naValue_ + -0.001) || y > (naValue_ + 0.001)) && (x - last <= gapValue_) &&
|
||||
(yprev < (naValue_ + -0.001) || yprev > (naValue_ + 0.001))) {
|
||||
|
||||
int start = i-1;
|
||||
int end = i;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user