1
1

Compare commits

...

275 Commits

Author SHA1 Message Date
71a1c7ab1d mostly building (except for cycles/cuda) 2015-11-09 20:27:48 +11:00
6bcdc385a3 Initial cmake refacror test 2015-11-09 14:54:24 +11:00
56933373e2 Code cleanup: remove some unused mesh laplacian code. 2015-11-08 15:17:29 +01:00
73977064a6 Remove outdated TODO, it's supported already 2015-11-08 10:20:54 +05:00
d6059e991a Point Density: Prevent crash when scene is not sent to calc_point_density() 2015-11-08 10:10:55 +05:00
5f95a4fb33 Remove unused header files
Was a left-over from recent OpenSubdiv changes.
2015-11-08 07:56:39 +05:00
15a1faefe9 Fix T46712: Crash while rendering Freestyle scene
The issue was in fact caused by missing initialization of motion blur shutter
curve for all new scenes when not using "Copy Scene Settings" option.
2015-11-08 07:29:12 +05:00
Martijn Berger
8c3538c3e7 Cmake Cpack fix cpack on Apple and Linux 2015-11-07 22:42:21 +01:00
ee8fbebd46 Change cpack package name to be "blender" instead of "Blender" 2015-11-07 08:34:27 +01:00
659af5d4f2 [Windows] Make installer use the template 2015-11-07 08:26:45 +01:00
6208ca25fa Cleanup: ui align header 2015-11-07 17:36:10 +11:00
dcc41c4f78 Cleanup: spelling, headers 2015-11-07 17:31:28 +11:00
02f3cebf6e Fix T46522: DataTransfer modifier: Impossible to set multiple transfer modes by script
(if they're on different properties).

This patch basically gets rid of (ui-related) hack where we was adding specific
'fake' enums for datatypes needing additional options.

That was done because of broken UI code - to summarize, 'align' code did not support
correctly layout mixing vertical and horizontal sub-layouts, in particular if
it was 'column-major'.

A complete rewrite of this align code has been done, so now we can use a more
sane UI code.
2015-11-06 19:27:39 +01:00
e77e018d48 Fix typo in new error reporting during arg parsing. 2015-11-06 18:54:52 +01:00
3d39b98f94 New uialign code, based on 2D positions of widgets.
This new code fixes a tons of issues with previous one, which basically was epic-failing
in many non-basic cases (especially mixed columns and rows with column-dominant layout).

It basically no more relies over order of buttons declaration in the uiBlock, instead it
finds and stores spatial neighbors and uses that data to compute needed stitching.
See code comments for details.

New code seems to be roughly ten times slower than old one (for complex grouped layouts),
that is, about a few microsecconds per alignment group - this remains reasonable.

Also, ui-align code becomming rather big in itself, it was separated in
own new `interface_align.c` file.

Reviewers: campbellbarton, severin

Reviewed By: campbellbarton, severin

Differential Revision: https://developer.blender.org/D1573
2015-11-06 18:54:33 +01:00
a25df21631 Command line args: print error w/ invalid numbers 2015-11-07 02:07:06 +11:00
Julian Eisel
cf08dc9f0c Use toggle buttons instead of checkboxes for VSE proxy percentage
Was inconsistent with Clip Editor which uses toggle buttons. Toggle buttons are narrower, so changing to them.

Reported in T46708.
2015-11-06 15:01:19 +01:00
97c8619b42 Fix T46587: Drivers do not work in node groups
This commit makes drivers on node groups to with when using new dependency graph.

Still TODO: Need a relation between drivers and tree evaluation  perhaps, so we
guarantee proper order of all operations.
2015-11-06 18:36:22 +05:00
1ffdb1b472 Fix T46696: Voxel crash indexing over INT_MAX
Use int64_t for index values.
2015-11-06 20:09:56 +11:00
Julian Eisel
4b316e78b6 Draw limit & mist indicators darker for non-active cameras
Darkens the colors for limit and mist indicators of non-active cameras. This makes it easier to see which indicators belong to the active camera and which don't.
Useful for layouts with multiple cameras.

Requested by the Caminandes team.
2015-11-05 19:41:39 +01:00
7a09d15ade Cleanup: comments/style 2015-11-06 05:34:05 +11:00
1adc196723 Correct error in recent commit 2015-11-06 01:56:29 +11:00
131c2a2bef Use 'beauty' for sculpt triangulation
Causes fewer degenerate quads.
2015-11-06 01:13:23 +11:00
0f769afe07 Fix T46692: Triangulate creates duplicate faces
Caused a crash in dyntopo.
2015-11-06 01:13:23 +11:00
cb39a4171b Fix T46691: Graph Editor, Channel, Toggle Channel Editability. Cannot reassign hotkey after removing it.
Anim Channels keymap is not editor-related...
2015-11-05 12:57:52 +01:00
fcf8f01ca0 BGE: Cleanup occlusion buffer in CcdPhysicsEnvironment.cpp
This patch cleanup spaces/braces and newlines.

Reviewers: moguri, kupoman

Reviewed By: moguri, kupoman

Subscribers: kupoman

Differential Revision: https://developer.blender.org/D1607
2015-11-05 12:34:31 +01:00
ebb2a78c7a Error in last commit 2015-11-05 22:25:09 +11:00
06ef778e08 Fix T46699: copy_prev_settings() gives misleading error message when previous version's config dir doesn't exist. 2015-11-05 11:10:49 +01:00
3863660c37 Fix face creation using incorrect loop-custom-data
Custom-data on newly created face data was often rotated.

Now the API doesn't copy data from adjacent loops when creating faces.
Most functions were already overwriting this anyway.

Since such decisions are better made at a higher level, now it's the responsibility of the caller.
2015-11-05 20:19:09 +11:00
41e267b4b4 API Docs: use importlib in examples 2015-11-05 19:08:17 +11:00
534c0af4d3 Fix BMesh memory leak w/ multires data 2015-11-05 19:07:22 +11:00
23344bca6c BMesh: triangulate & poke - multires data support 2015-11-05 17:40:33 +11:00
ce49c70956 BMesh: generalize logic for quad/ngon triangulate
Avoid having 2 different code-paths for face triangulation.
2015-11-05 08:19:05 +11:00
3152419e7e Add missing check for multires interpolation 2015-11-05 06:03:26 +11:00
206c42f3ce Fix compilation error with OpenSubdiv disabled 2015-11-04 22:31:06 +05:00
a5f4f1e2ce OpenSubdiv: Use pool for delayed OpenGL buffers free when freeing from non-main thread
This is really similar to what GPU module was already doing. There are number of
possible improvements still:

- Re-use allocated VAOs when requesting new ones instead of going to the trouble
  of freeing VAO and then re-creating it again.

- Move VAO handling to GPU module.

Fixes T46589: OpenSubdiv crash with drivers
2015-11-04 21:30:25 +05:00
4ff6e08a6d Tracking: Solve annoying "script needs updating" warning printed to the console 2015-11-04 20:13:21 +05:00
321a609caa Fix T46687: Animating tracks properties from objects didn't use proper path 2015-11-04 20:13:21 +05:00
7db2979dcf Tracking: Move tracks list base search to an utility function
No functional changes expected, just makes it easier for reuse.
2015-11-04 20:13:21 +05:00
b566adec52 File Selector, support filepath dropping
This adds support for dropping a filepath on an open file-selector to set that path.
2015-11-05 01:33:50 +11:00
e43b6e2f97 Fix T46672: Concurrent access to source DM in datatransfer modifier.
There is no real elegant solution here, ideally a modifier shall never *modify*
a source DM, but that would imply much better ways to ensure required data
is available in that source DM, which we do not have currently.

So instead, let's use brute force solution for now and always create a local copy
of our source DM, that we can modify to our heart content!
2015-11-03 21:16:58 +01:00
584f439112 imp: show alert color if mesh has weight groups but no active group is selected 2015-11-03 20:19:16 +01:00
8c25c1c484 Fix T46683: High pitch sound artifact on import of 48k audio
The bug header is wrong, the file contains the high pitched sound, but the bug that existed was that animation rendering did not use the high quality resampler, while audio mixdown does.
Blender uses the low quality resampler to be as little CPU consuming as possible.
2015-11-03 19:34:33 +01:00
7f57bc9ef4 Avoid assert weight painting w/o an active group 2015-11-04 04:37:47 +11:00
020fdeb760 Cleanup: de-duplicate quad_coord & resolve_quad_uv_v2 2015-11-04 04:01:15 +11:00
1fb512f4a9 Fix T46611: Vertex group locking fails 2015-11-04 03:00:50 +11:00
883a894d77 Fix related to T46567: Skin modifier: add a warning message when no valid root vertex is found.
Otherwise user may have a hard time understanding why their modifier is no more working
after they e.g. deleted some vertices... including the root one. ;)
2015-11-03 14:53:11 +01:00
537bd0eb51 Fix T46671: Cycles assert with CMJ sample function
With current formulation of cmj_fast_div_pow2() it should always return 0
in the case of first argument is zero and no assert really needed anymore.
2015-11-03 18:49:27 +05:00
268538853c Correct error in recent commit 2015-11-04 00:01:41 +11:00
aa15ede3b9 Don't expand toggle brush on linking
Toggle brush is more a runtime only feature, not really supposed to be used
as real ID linking as it's done for modifiers i.e.
2015-11-03 15:30:57 +05:00
bed91b623f Edge/Vert slide: improve multires interpolation
Need to re-interpolate the entire face, not just the connected loop.

Also add BM_face_interp_multires()
2015-11-03 20:38:23 +11:00
f29f4c92f2 BGE: Remove KX_IPOActuator.
KX_IPOActuator is not used since 2.4.

This patch removes:
	- KX_IPOActuator.h/cpp;
	- Python doc;
	- Write of IPO actuator in write.c;
	- Allocation of IPOactuator in sca.c;
	- Conversion in KX_ConvertActuators.cpp;
	- Initialization of the python proxy in KX_PythonInitTypes.cpp;
	- Other minor remove in logic_windows.c and in KX_PythonInit.cpp.

Reviewers: sybren, campbellbarton

Reviewed By: campbellbarton

Subscribers: moguri

Differential Revision: https://developer.blender.org/D1603
2015-11-03 10:31:08 +01:00
6063790732 Fix T46677: OpenSubdiv crashes when witching from simple and CC subdivisions
Crash was happening due to OpenGL free from the non-main thread. Ideally we need
to implement somewhat delayed unused buffer free for OpenSubdiv similar to what we
are doing in GPU module.
2015-11-03 14:26:56 +05:00
0d0fa446b7 Fix: edge/vert slide ignored multires data
Multires data fails the CustomData_layer_has_math() check,
so meshes without UV's for eg werent getting interpolated multires.
2015-11-03 19:14:19 +11:00
f75d6c4a8f BMesh: add BM_loop_interp_multires_ex which takes cached vars
Avoid recalculating face centers (for each loop) when interpolating multires.
2015-11-03 18:28:13 +11:00
77e223ddd5 BMesh: inline vert-loop iteration for normal calc
Calculating normals is called often (sculpting for eg),
so avoid using high-level iterator here.
2015-11-03 17:46:09 +11:00
ac7abb55d7 Cleanup: use 'const' for BMesh checking funcs 2015-11-03 17:06:56 +11:00
073ae9c572 Fix flip normals w/ multires
Needs Z axis flip to maintain the shape.
2015-11-03 15:50:59 +11:00
5f0f861b1d BMesh: avoid mdisp lookups (minor optimization) 2015-11-03 15:50:52 +11:00
d0d523d809 Better fix for pthread ID comparison crap on windows.
Suggested by Sergey, thanks!
2015-11-02 19:25:00 +01:00
d2fbbed462 Attempt to fix win32 compilation after own recent commits. 2015-11-02 18:48:14 +01:00
15fb2bd477 Filebrowser: fix preview handling to make correct use of task scheduler.
We needed the 'background' feature here, since we never wait on those preview-generation tasks.

Note that it also simplifies the code, and as usual testing is needed here on all possible platforms...
2015-11-02 17:04:31 +01:00
04ac8768ef BLI_task: add support for full-background taskpools.
With current code, in single-threaded context, a pool of task may never be executed
until one calls BLI_task_pool_work_and_wait() on it, this is not acceptable for
asynchronous tasks where you never want to actually lock the main thread.

This commits adds an extra thread in single-threaded case, and a new 'type' of pool,
such that one can create real background pools of tasks. See code for details.

Review: D1565
2015-11-02 16:57:48 +01:00
44774f8160 BLI_task: add freedata callback to tasks.
Useful in case one needs more complex handling of tasks data than a mere MEM_freeN().
2015-11-02 16:52:19 +01:00
952afbf916 BLI_task: Fix/enhance logic of exiting worker threads.
In previous code, worker would exit in case it gets awoken from a condition_wait() and
task queue is empty. However, there may be spurious wake up (either due to pthread itself,
or to some race condition between workers) that would lead to wrongly exiting a worker before
we actually exit the whole scheduler. See code for more details.
2015-11-02 16:42:39 +01:00
ba5d6f5b6b Fix/workaround T46622: crash w/ metas & particles
Metas are scanning all scenes duplis,
which can go into particle systems without an initialized derived-mesh.

For now just do NULL check, its not correct but real fix is not fitting well with current design.
2015-11-02 23:08:44 +11:00
7b7aba31f2 Fix T46626: Crash generating previews
Brush.toggle_brush was allowed to be an invalid pointer,
it worked for the one operator that used it - but in general bad practice,
requiring a lookup on every access.

Ensure the pointer is kept valid now.
2015-11-02 21:42:47 +11:00
7a9693fa8b Library API: pass Main struct to unlink functions 2015-11-02 21:20:03 +11:00
56bcda8bc6 Fix BMesh selection flushing w/ mixed modes
Fix for T46494 wasn't working properly when de-selecting faces,
adjacent faces would remain selected but have unselected edges.

Logic here is admittedly rather fragile since it relies on both
selection functions and flushing afterwards.
2015-11-02 17:04:29 +11:00
8e7eb0b733 Fix T46660: No need to set explicitely UI range of auto smooth angle anymore. 2015-11-01 19:58:41 +01:00
9bce104c8c Cycles: Partially revert previous commit
Apparently removing kernel arguments broke NVidia OpenCL.

Needs more investigation, for the time being revering changes which caused problem.
2015-11-01 21:01:12 +05:00
dc9e0b819b Cycles: Remove unused argument from the split kernel functions
Should be no functional changes, just simplifies operation with kernels.
2015-11-01 17:22:42 +05:00
84e8b05e97 Cycles: Minor code style cleanup 2015-11-01 15:40:17 +05:00
99df433ea7 Fix T46655: crash reading unknown ID types 2015-11-01 14:27:25 +11:00
632ed6a0d6 Cleanup: remove unused scene recalc 2015-11-01 12:49:43 +11:00
cf5154dcff Cleanup: old comments 2015-11-01 12:49:40 +11:00
df61c50ffa Fix T46651: Select linked crash w/ wire seam edges 2015-10-31 17:10:22 +11:00
92ab3ba385 Fix T46648: Recalculate normals fails
Certain shapes could trick the inside/outside test.
An edge between 2 planar faces could be selected for detecting face-flipping (which failed).
While this could be prevented by skipping those edges,
use a method which searches for the outer most face-loop, then check it faces the center.
2015-10-31 13:52:28 +11:00
a0d9953841 Fix netbeans project generator
Need to escape defines
2015-10-31 11:31:58 +11:00
a43e087fb8 Cycles: Add split kernel headers to project generation 2015-10-31 04:08:19 +05:00
Julian Eisel
37fbabc64b Fix T46647: Crash when using redo panel after extrude individual faces
Caused by rBe0c60985b6.
2015-10-30 21:54:47 +01:00
cb1cb63d40 Cycles: Fixes for few typos in OpenCL kernel 2015-10-30 23:31:24 +05:00
16845a5f34 Fix memory leak caused by recent shutter curve commits 2015-10-30 18:01:53 +05:00
5bfa43d385 Include Python binary in system-info.txt 2015-10-30 22:33:24 +11:00
0a5fdb6354 Python: check version binary name first
Check version name first since 'python' binary may be a different version.
2015-10-30 22:33:24 +11:00
43bf78c946 Image editor: Add options to display separate R, G and B channels
Works totally similar to backdrop in the compositor.

Requested by Sean Kennedy, but could be useful for lots for VFX guys.

Reviewers: campbellbarton

Reviewed By: campbellbarton

Subscribers: sebastian_k, hype

Differential Revision: https://developer.blender.org/D1590
2015-10-30 16:07:10 +05:00
e6abc3ad57 Transform: Support storing virtual cursor location
Grabbing now doesn't 'jump' when shift is released (matching rotation modes).

This simplifies most logic for transform input,
where mouse input callbacks can choose to use the 'virtual' cursor,
which accounts for precision when shift is held.
2015-10-30 18:24:02 +11:00
d2af140151 BGE: Fix SetMass function affecting own object gravity.
Each time we setted the mass the own object gravity was divided by its
old mass (i.e you could convert you car in a flying DeLorean with a
simple mass car modification).

A note will be included in release notes due to retro compability
issues.
2015-10-30 06:51:22 +01:00
c03598955b Optimization: use dot product for angle comparison 2015-10-30 16:20:22 +11:00
a3c9374440 Fix T46507: Cycles baking re-orders face
Regression in 2.76, order of tessellated vertices needs to follow MFace tessellation.
2015-10-30 14:59:48 +11:00
d8233d2308 Fix T46619: Levels node becomes Undefined
regression caused by 79c345ac
2015-10-30 10:57:02 +11:00
8014180720 Vertex Paint: orbit last stroke support
This option works for all paint modes now.
2015-10-30 09:56:33 +11:00
Julian Eisel
cd1d6d7770 Fix T46632: Graph editor frame navigation shortcuts not working 2015-10-29 20:50:30 +01:00
286f5ffa59 BGE: Fix T38986: Start object position not initialized in IPO.
The start position must be initialized at the first call of KX_IpoSGController::Update when m_ipo_start_initialized is to false, not when also the frame time is not 0.
2015-10-29 18:44:09 +01:00
537f41250f Cycles: Fix typo in split kernel
Shadow blocked kernel was using wrong array for storing intersection.
2015-10-29 21:52:56 +05:00
3300b1f232 Cycles: Add option to force mega kernel to be used
This way it's possible to test mega kernel on various hardware.

That being said mega kernel seems to work on Fiji card here in the studio.
2015-10-29 21:52:56 +05:00
4ca688a963 Cycles: OpenCL split kernel cleanup, move casts from .h files to .cl files
Ideally we shouldn't use char* at all, but for now we have to, so at least
let's assume common .h files are free from pointer magic.
2015-10-29 21:52:56 +05:00
fc5f717888 BGE: Cleanup KX_IPO_SGCOntroller.
- Add spaces around operators.
- Replace !(a == b) by a != b
- Add "f" at end of float value.
- Remove extras lines in fonctions declaration.
- Remove indentation to align attributes definition.
2015-10-29 17:24:35 +01:00
6005bb5846 OpenCL wrangler: Update to latest version to fix issues with -1001 error code 2015-10-29 20:37:38 +05:00
324d20bc64 Fix error introduced by D1588 2015-10-30 00:09:25 +11:00
8d3d931f6a BGE: Fix T46338 replace mesh from an other scene.
To make consistent with KX_GameObject.replaceMesh, we don't allow this behavior but print an error message for the replace mesh actuator.
e.g : Warning: object "Cube" from ReplaceMesh actuator "Edit Object" uses a mesh not owned by an object in scene "scene1"

Reviewers: youle.
2015-10-29 12:14:40 +01:00
0e80d0893f New depsgraph: Optimize updates flush
Previously it was possible that same component will be tagged for update
again and again, making update flushing really slow. Now we'll store flag
whether component was fully tagged.

This is still temporary solution because ideally we should just support
partial updates, but that's for the future.

Gives around 10% speedup on file from jpbouza.
2015-10-29 14:19:25 +05:00
a15a3952f4 BGE: Fix T35188: Duplicate an instance of group.
This behavior caused a double free.
Before when we duplicated an instance of a group the new instance keep the pointer of the group but was not added in the group instance list (normal).
And during the object deletion we tried to remove the object in the instance list but anyways if it failed decrement the reference count.
Set the group and the instance list to NULL in ProcessReplica avoid these kind of problems.
2015-10-28 22:11:15 +01:00
Dalai Felinto
138decb7dc Temporary "fix" for crash when saving OpenEXR Multi-View from Image Editor 2015-10-28 14:06:55 -02:00
Dalai Felinto
20a94e956a Fix T46617 File Output Node seems to save only black images into OpenEXR image data
If the node output had only one layer, it would be detected as singlelayer, and it would miss the blender exr header string
2015-10-28 14:06:55 -02:00
734af18651 Freestyle: Fix for 'Distance from Object' modifiers without a target object.
'Distance from Object' color/alpha/thickness modifiers without a target
object were raising a run-time exception although it is not considered an
error condition.
2015-10-28 23:33:25 +09:00
efd774ce5a Fix T44231: Freestyle causes crash on render.
The reported crash was confirmed as a segmentation fault in std::sort().
The cause of the crash was traced down to a binary comparison function
that was not satisfying the so-called strict weak ordering requirements of
the C++ standard sorting function.  Specifically, the comparison operator
has to return false when two objects are equivalent (i.e., comp(a, a) must
be false), but that requirement was not met.

Since the binary comparison operator in question could be a user-defined
Python function, here a safety measure is implemented in the C++ layer to
make sure the aforementioned requirement is always satisfied.
2015-10-28 23:22:58 +09:00
ced1c34f74 Ceres: Update to the latest version
It brings all the performance improvements, bug fixes and stability improvements
which were done in the last year of Ceres development.
2015-10-28 19:20:50 +05:00
f10db730bc BGE: Fix T45945: Action bouncing.
Bug introduced in 583fa7d1e, KX_GameObject.setActionFrame can make BL_Action::m_starttime negative. But in BL_Action::Update m_starttime is set to the current time if it's negative.
To fix it we use a boolean BL_Action::m_initializedTime to know if we should initialize the time in BL_Action::Update, it's more stable than comparing times.

Tested with bug task T45945 and T32054, with an extra patch about to fix suspend resume scene issues with actions : D1569
2015-10-28 15:13:12 +01:00
e0c60985b6 Transform: Replace t->imval w/ t->mouse.imval
Initial mouse position was saved in two different places

D1588 by @mauge
2015-10-28 23:31:15 +11:00
d1e18c35d3 Docs: support alternate binary path for PyAPI 2015-10-28 23:30:37 +11:00
5196da4b98 Cleanup: warning/style 2015-10-28 23:30:37 +11:00
0e76c52033 Cycles: Fix compilation error with MSVC 2015-10-28 17:33:31 +05:00
fd8c3fe070 Follow up to previous commit, proper fix for T46284, incorrect Texture
shading in Texture paint mode and cycles
2015-10-28 12:51:50 +02:00
e3d882b335 Revert "Fix T46284: Texture paint, wrong shading mode"
Should fix T46616 but will reintroduce T46284.
The second, original bug needs different handling

This reverts commit 904db487a7.
2015-10-28 12:36:25 +02:00
40b2e75b20 BGE: Fix T46557: Empty collision bounds option with character physics
- Fix in rna_object.c rna_GameObjectSettings_physics_type_set->The
collision bounds type can't be empty for character physics
- Add do_version for the .blends already saved with collision bounds
option empty (characters)

Reviewers: campbellbarton, panzergame, lordloki

Reviewed By: panzergame, lordloki

Subscribers: lordloki

Projects: #game_engine

Maniphest Tasks: T46557

Differential Revision: https://developer.blender.org/D1576
2015-10-28 02:04:30 +01:00
9eb7eb5379 BGE: Fix T44448: LOD will display wrong LOD level object if zoomed out
then in

Current object distance hasn't to be cached.
2015-10-28 01:22:16 +01:00
fd1487977b Fix T46471: Sculpt strokes doesn't mark file as modified 2015-10-28 04:10:00 +05:00
16796c2813 Buldbot: Disable 32bit kernels
Currently disable all of them, in practice i think way to go should be:

- Disable Experimental kernels on 32 bit, build up to sm_35
- Later we can drop all 32bit kernels, but try to keep at least one release
  with some of the kernels (they'll cover 99% of users anyway)

Before doing any changes we should surely communicate such a changes before
we apply them.
2015-10-28 02:43:06 +05:00
b909dfdae1 Cycles: Expose user-defined shutter curve to the interface
Shutter curve now can be controlled using curve mapping widget in the motion
blur panel in Render buttons. Only mapping from 0..1 by x axis are allowed,
Y values will be normalized to fill in 0..1 space as well automatically.

Y values of 0 means fully closed shutter, Y values of 1 means fully opened
shutter.

Default mapping is set to old behavior when shutter opens and closes instantly.

This shutter mapping curve could easily be used by any other render engine by
accessing scene.render.motion_blur_shutter_curve.

Reviewers: #cycles, brecht, juicyfruit, campbellbarton

Differential Revision: https://developer.blender.org/D1585
2015-10-28 02:43:06 +05:00
6a529e14f4 Cycles: Support user-defined shutter curve
Previously shutter was instantly opening, staying opened for the shutter time
period of time and then instantly closing. This isn't quite how real cameras
are working, where shutter is opening with some curve. Now it is possible to
define user curve for how much shutter is opened across the sampling period
of time.

This could be used for example to make motion blur trails softer.
2015-10-28 02:43:06 +05:00
c07c066685 Cycles: Use new CDF evaluation utility for the pixel filter
Filter table should stay exactly the same, no changes in the render
results are expected at all.
2015-10-28 02:43:06 +05:00
548ef2d88b Cycles: Add utility functions to evaluate CDF of a given functor 2015-10-28 02:43:06 +05:00
868717e312 Support symmetrical curve mapping presets
Previously curve mapping was always setting to only a single slope which then
was symmetrizied by a tools (such as brush or compositing).

With this change it's possible to set curve to symmetrical slopes as a part
of preset.
2015-10-28 02:43:06 +05:00
4f6b01ce1f Fix curve mapping linear preset not setting handle type correctly 2015-10-28 02:43:06 +05:00
25b99b1922 Fix makesrna generated C++ header have consistent whitespace for strings. 2015-10-27 22:11:33 +01:00
68f677e655 Fix OS X user preferences open crash when changing virtual pixel size.
The separate window state setting caused a crash due to doing live resize code
redrawing a window that has not yet been fully initialized.
2015-10-27 20:06:04 +01:00
1617f3e425 Docs: callback comments 2015-10-28 03:14:27 +11:00
242246e9fc Fix T46605: Compositing causes access violation when rendering from command line
Seems was caused by the race condition in the stats printing, should be all fine now.

Nice for 'a' release.
2015-10-27 21:03:22 +05:00
7e7527d3ce OpenSubdiv: Fix wrong handling of vertex parent
Vertex parent was not registered as CPU data requirement.

Should be in the 'a' release.
2015-10-27 20:44:14 +05:00
f1555c8bba Compositor: Use mask name as mask node label
This way it becomes much easier to navigate in roto compositor where it could
be 100s of masks in a production shot.
2015-10-27 20:36:02 +05:00
ea67f55b87 Compositor: Add Invert option to the movie clip stabilization node
This appears to be really common workflow when you stabilize shot to make compo
easier (roto, some effects and so) and then re-introduce the motion back.

Surely it's doable with some magic nodes and manual network for transforming
but such workflow is too common in VFX to resist adding one small option in
single node for this.
2015-10-27 20:01:10 +05:00
b2f57190d9 BGE: Fix T43218: Text of framerate and profile glitch in Multitexture shading
Fix T43218: Text of framerate and profile glitch in Multitexture shading

Reviewers: lordloki, panzergame

Reviewed By: panzergame

Subscribers: medved

Projects: #game_engine

Maniphest Tasks: T43218

Differential Revision: https://developer.blender.org/D1536
2015-10-27 15:29:09 +01:00
Dalai Felinto
3f85eeddaa View3D offscreen buffer was interferring with view navigation
the RegionView3D matrices need to be re-set after drawing.

Review and touch ups by Campbell Barton
2015-10-27 11:29:21 -02:00
Julian Eisel
505a31bd22 Fix: Open tmp windows with size multiplied by virtual pixelsize
Opening a tmp window on a 4K display with virtual pixelsize set to double results in a too small window. For Retina this seems to be handled on GHOST level already, so multiply by virtual pixelsize only.
2015-10-27 12:53:58 +01:00
19137e86bb Fix T46606: Trackball Rotate jumps releasing shift 2015-10-27 21:49:51 +11:00
13a4bcd148 BGE: Fix T31357: wrong zoom when sets camera.
This patch makes independant the override camera zoom and the default camera object zoom. The override zoom is 2.0f and the camera object zoom is computed with the RegionView3D camera zoom.
These features are only used for the embedded BGE, so there's no compatibility issues with the blenderplayer.
I let the override zoom with a setter to allow later to create an override camera in blenderplayer easily.

Tested with the 3 framing modes in embedded and standalone.
2015-10-27 11:10:12 +01:00
95164a09a7 BGE: generic python callback list + replace KX_PythonSeq.
I made this patch to declared a python list without converting all elements in python object (too slow) or use a CListValue which required CValue items (too expensive in memory).  In the case of a big list of points like a collision contacts points list, to use a CListValue we must implement a new class based on CValue for 3D vector to create a python proxy even if mathutils do it perfectly, we must also convert all points (frequently ~100 points) when fill the CListValue even if the list is not used (in the case of the collision callback). The easy way is to use callback (it doesn't worth to do an inheritance) which convert the item in PyObject only during an acces.
5 callbacks are used :
- Check if the list is valid = allow acces (like PyObjectPlus.invalid)
- Get the list size
- Get an item in the list by index.
- Get an item name in the list by index (used for operator `list["name"]`)
- Set an item in the list at the index position.
All of these callback take as first argument the client instance.
Why do we use a void * for the client instance ? : In KX_PythonInitTypes.cpp we have to initialize each python inherited class, if we use a template (the only other way) we must add this class each time we use a new type with in KX_PythonInitTypes.cpp

To check if the list can be accessed from python by the user, we check if the python proxy,  which is the `m_base` member, is still a valid proxy like in PyObjectPlus. But we can use a callback for more control of user access (e.g a list of collision point invalidate a frame later, in this case no real python owner).

This python list is easily defined with :
```
CPythonCallBackList(
void *client, // The client instance
PyObject *base, // The python instance which owned this list, used to know if the list is valid (like in KX_PythonSeq)
bool (*checkValid)(void *), // A callback to check if this list is till valid (optional)
int (*getSize)(void *), // A callback to get size
PyObject *(*getItem)(void *, int), // A callback to get an item
const char *(*getItemName)(void *, int), // A callback to get an item name (optional) use for acces by string key
bool (*setItem)(void *, int, PyObject *) // A callback to set an item (optional)
)
```
To show its usecase i replaced the odd KX_PythonSeq, it modify KX_Gameobject.sensors/controllers/actuators, SCA_IController.sensors/actuators and BL_ArmatureObject.constraints/channels.

Example : {F245193}, See message in console, press R to erase the object and see invalid proxy error message.

Reviewers: brita_, #game_python, youle, campbellbarton, moguri, agoose77, sergey

Reviewed By: campbellbarton, moguri, agoose77, sergey

Subscribers: sergey

Projects: #game_engine

Differential Revision: https://developer.blender.org/D1363
2015-10-26 20:27:08 +01:00
5b3af3dd46 Fix T46537: UV Image Editor. UV Sculpt toggle button doesn't show hotkey label when active.
Poll function of that keymap was slightly... agressive.
2015-10-26 16:37:59 +01:00
3751eb18c3 Fix broken comment about our WM progress report for python (its not a progress bar at all). 2015-10-26 14:10:25 +01:00
52d074ba39 Fix T46604: Crash in ChainPredicateIterator instantiated without predicates.
Also fixed a potential crash in the copy constructor case.
2015-10-26 20:55:37 +09:00
3e9f6fc281 Freestyle: minor speed-up by omitting the calculation of the smallest edge size.
BlenderFileLoader tries to find the smallest edge size but the computed value is not used.
2015-10-26 20:55:34 +09:00
afe3b55483 Cleanup: warning & whitespace 2015-10-26 22:22:30 +11:00
85876923bf Cleanup: Remove ToDo comment.
I don't see how this could conflict, madd() in util_ssef.h has a different function signature.
2015-10-26 11:52:24 +01:00
aa49c16bd9 Cleanup: Avoid some warnings on OS X with clang and update comment. 2015-10-26 11:52:24 +01:00
72592cfbe0 Cleanup: Move pixel aspect to blender_camera_init(). 2015-10-26 11:52:24 +01:00
04ff2784da Fix: Prevent warnings from popping up when trying to edit driver expressions from buttons
Previously, a warning was added to provide feedback to users trying to change the values
of driven properties why their edits would not have any effect on the propeerty. However,
it turned out that instead of only showing up when the user tried to increment/decrement/slide
the property's value, it was also firing everytime they were trying to edit the expression.
That however is not what we want at all!

This fix assumes that BUTTON_STATE_TEXT_EDITING is used for expression editing, and
BUTTON_STATE_NUM_EDITING (or everything else) refers to the user trying to adjust the
value normally.
2015-10-26 23:24:41 +13:00
0a3ca175af Graph Editor: Use Cursor X in Drivers mode during Transforms (where appropriate) 2015-10-26 20:18:13 +13:00
1b286352a3 Graph Editor: Snap and Mirror keyframes now respect Cursor X in Drivers mode
When using the "Current Frame" options for these operators, the Cursor X value
will now be used instead of the current frame. Perhaps the labels could be changed
too, but for now, I guess this will be good enough.
2015-10-26 20:18:12 +13:00
b3edd7bdcd Graph Editor: Adjusting Change Frame and Jump to Keyframes operators to work with Drivers Cursor 2015-10-26 20:18:11 +13:00
0860fdc53c Fix T46599: Copy Rotation behaves erratically when Use Y is disabled
When the "Use Y" option in the Copy Rotation constraint is disabled, the constraint
behaves eratically when rotating all the target on all axes at the same time.
This is partially to be expected due to the way that euler rotations work
(i.e. the rotation orders stuff - you should use a rotation order based on most to
least important/significant rotations). Hence, by locking Y, you're causing accuracy
problems for Z.

What was not expected though was that changing the rotation orders on the objects
involved (for the record, it's the constraint owner that counts) did nothing.
It turns out that for objects, the rotation order settings were getting ignored!
This commit fixes this problem, and this particular case can be resolved by using
"XZY".

Notes:
* Since all object constraints were previously working on the assumption that they
  used XYZ (default) order, it is possible that this change may have the unintended
  consequence of changing the behaviour of some rigs which relied on the buggy
  behaviour. Hopefully this will be a rare occurrence.
2015-10-26 20:18:11 +13:00
65072499c6 Graph Editor: Allow "cursor x" to have fractional values when working with Drivers (T46004)
When working is the Graph Editor it can be very important to be able to work with fractions
(sub integers), especially when working with Drivers. Currently the "Cursor Y" is hooked up
to "cursor_position_y" which allows fractions  but "Cursor X" is directly hooked up to
"frame_current" which is an integer.

This commit adds initial support for this feature.
* When in Drivers mode, the x-part of the cursor is mapped to a new "cursor_position_x"
  value which can have fractional values. Animation mode however remains mapped to frame_current

* This commit only adds the UI/property/drawing tweaks needed to support this.
  Many operators still need to be modified to consider this value instead of the
  current frame, for this to be more useful.
2015-10-26 20:18:10 +13:00
2092056745 Fix: Missing update after scrubbing time in Graph Editor
Sometimes the timeline header didn't update after time-scrubbing in the graph
editor ends, leaving the "Pause" button visible until the next refresh of the
timeline (e.g. on mouse over)
2015-10-26 20:18:09 +13:00
a93605b95b Fix: X-axis values in Graph Editor should not be displayed as timecodes in "Drivers" mode 2015-10-26 20:18:08 +13:00
21f4c77a76 Alternative presentation for interpolation indicator for discrete properties 2015-10-26 20:18:07 +13:00
ebe3923137 Graph Editor: Disable interpolation setting for enum/boolean FCurves, as no interpolation is performed on those 2015-10-26 20:18:07 +13:00
c3cec828e8 ndof: rework Mac driver glue
Load driver dynamically at runtime instead of weak-linking the
3Dconnexion framework. Driver no longer needed at build time!

Works with really old drivers (as in PowerMac old), more recent
versions, and the latest which allows us to process events on a
separate thread.
2015-10-25 21:19:26 +01:00
4f767e37e8 BGE: Cleanup: Code style BL_Shader
Reviewers: lordloki, youle, campbellbarton, sergey, kupoman, moguri, panzergame

Reviewed By: panzergame

Projects: #game_engine

Differential Revision: https://developer.blender.org/D1397
2015-10-25 19:43:46 +01:00
06d2ad0185 BGE: Fix issues with async libload.
This patch fixes:
- the call of LibFree on a unfinished loaded library;
- memory leak created on end of game : the async libraries are loaded but not converted, so not freed with the master scene.

Reviewers: campbellbarton, sybren, youle, hg1, moguri, lordloki

Reviewed By: moguri, lordloki

Differential Revision: https://developer.blender.org/D1571
2015-10-25 19:22:29 +01:00
0d59acccd3 Use BLI_strncasecmp for text suggestions 2015-10-25 17:44:32 +11:00
6f2aa50a72 Avoid redundant normalize in obmat_to_viewmat 2015-10-25 17:30:16 +11:00
Dalai Felinto
3bc5399f72 Fix T46590 Strange camera behavior (partial revert of fbca69c6)
I'm sure there is a way of using the new functions for the
obmat_to_viewmat() routine. But for now let's get it back to a working
state
2015-10-24 21:02:42 -02:00
11c00caddc Fix error in bone UI 2015-10-25 05:50:40 +11:00
c5945ebb2c Cleanup: use quat to eul w/ mathutils API 2015-10-24 17:50:20 +11:00
25c00ae460 Fix invalid exceptions w/ preview API
D1575 by @januz
2015-10-24 17:50:20 +11:00
a6c9a09061 Fix T46538: Mark and Clear Seam in UV Editor, assigning Hotkeys.
UV Editor keymap is not bound to a given editor (spacetype)...
2015-10-24 08:38:13 +02:00
c4e1837e6a Fix related to T46538: do not popup choice menu of mark/clear seam UV editor op invoke when prop is already set! 2015-10-24 08:38:13 +02:00
fbca69c69a BLI_math: add mat3_normalized_to_* functions
Many uses of matrices for rotation keep them normalized,
so no need to normalize each time.
2015-10-24 07:02:51 +11:00
3a98426ed6 Cleanup: remove redundant math calls 2015-10-24 06:03:48 +11:00
ba1df8265d Cleanup: simplify ED_view3d_from_m4 2015-10-24 04:33:54 +11:00
9d8a01dba1 BLI_math: add invert_qt_normalized
When the quat is known to be unit length, so we can avoid scaling
(just conjugate_qt which asserts on non unit quats).
2015-10-24 03:51:00 +11:00
d5fb0e517c Cleanup: rename 'datablocks' -> 'data-blocks'
Similar to addons -> add-ons, for reading it fits better to hyphenate.
2015-10-24 02:44:43 +11:00
4ff10119f7 Node Border Select: only frames inside border
Without this you can't easily select a few nodes inside a frame,
without selecting the whole frame, noted in T46540
2015-10-24 01:06:28 +11:00
0870612268 Cleanup: use int for view_id's & view count
`size_t` is useful for memory sizes or offsets,
the number of views wont realistically exceed an int.
2015-10-24 01:01:10 +11:00
23848a70de Correct own error w/ snap-scale T46503
Don't use nan for comparisons.
2015-10-23 21:33:15 +11:00
0d638172ec BGE: Fix T30179 action actuator not stoped when state changed.
The function SCA_IActuator::DecLink is now under virtual : in some case the actuator have to know when is useless.
2015-10-23 10:54:08 +02:00
d04ad07f98 Quiet audaspace unused macro warnings 2015-10-23 18:40:42 +11:00
e435593fc0 Fix ffmpeg memory leaks
- audio_stream wasn't freed.
- audio/video stream + context weren't freed on failure.
2015-10-23 18:40:27 +11:00
050980e635 Fix ffmpeg saving long paths
Was checking wrong length on string copy.
2015-10-23 18:40:06 +11:00
48f4e1a63f Fix for error w/ RenderView in ImageView list 2015-10-23 17:06:42 +11:00
b2f8da1c53 Comments for link-list types 2015-10-23 16:47:44 +11:00
6222505739 Fix snap-scale w/ axis constraint
Related to T46503,
fix only worked when the snap target was axis-aligned.
2015-10-23 12:27:15 +11:00
586ec50022 BGE: Fix T46556: check on null sound datablock pointer. 2015-10-22 20:11:05 +02:00
ebf197724e Version Bump: 2.76.2, deprecate values
- RegionView3D.view RV3D_VIEW_PERSPORTHO
  only ever set on initialization, never checked for.
- Lamp.type LA_YF_PHOTON
  from old 2.4x yafray files.

Also iniitalize movie-clip + grease-pencil theme colors.
2015-10-23 04:56:37 +11:00
47b1279762 Cycles: Watertight fix for SSS intersection
Same as previous commit, just was missing in there.
2015-10-22 22:10:40 +05:00
f84cbae43e Cycles: Fix for watertight intersection
It was possible to miss some intersection caused by wrong barycentric
coordinates sign.

Cases when one of the coordinate is zero and other are negative was not
handled correct.
2015-10-22 22:07:28 +05:00
54a18f6d51 View3D: make ndof turntable & orbit speed match 2015-10-23 03:16:57 +11:00
80470b639c BLI_math: axis_angle_to_quat_single
Useful to avoid defining a vector for an axis-aligned rotation.
Matches axis_angle_to_mat3_single behavior.
2015-10-23 03:09:28 +11:00
0d54aa9c02 Fix T46521: Python: bvh.ray_cast doesn't find a plane facing in the other direction under certain circumstances
The issue was caused by wrong sign check. It originally came from more optimized
Cycles code where because of other reasons it wasn't visible yet. But in fact it
should be solved there as well.
2015-10-22 20:34:51 +05:00
9a6a3f5346 Fix T46569: Crash w/ mask & locked-track enabled 2015-10-23 01:40:36 +11:00
e6c943c917 Cleanup: remove script ID-types
Unused since 2.4x and unlikely to be reintroduced as ID-types.
2015-10-23 01:20:01 +11:00
e7cd64dc97 Fix T46561: Crash in outliner delete hierarchy
When children & parents were selected in the outliner,
it attempted to free the the object twice.
2015-10-22 18:42:44 +11:00
c6d98fa841 Fix T46565: Movie render crash w/o permissions
Rendering to a path that didn't have write permissions would crash.

Also fix error where `G.is_rendering` was left set when rendering failed.
2015-10-22 17:25:37 +11:00
85072eb4e9 BGE: Cleanup ConvertMaterial function.
- cleanup spaces;
- add braces;
- remove indendation around operator.
2015-10-21 22:28:33 +02:00
c272017868 Fix T46524: Use Alpha (Straight/Premultiply) option missing in 2.76, part II.
Different issue actually, here RAWTGA was simply forgotten in the alpha-capable formats...
2015-10-21 20:06:49 +02:00
729e9651ac BGE: Fix physics meshes conversion with modifiers.
Previously meshes with modifiers were considerate as empty (no polys).
2015-10-21 12:15:35 +02:00
6bc0076102 Usual i18n tweaks & fixes... 2015-10-20 20:08:37 +02:00
e96411aaad Fix T46544: Can't unpack generated image 2015-10-21 03:07:40 +11:00
24cc885057 RNA: Change behavior of Image.save()
Previously it would save packed file(s),
which would ignore the image.filepath,
making it impossible to set the destination.

Add image.packed_files[...].save() so you can save packed files if its needed.
2015-10-21 02:26:23 +11:00
af23b09e72 Fix T46496: GL Render fails w/ Anti-Aliasing
Needed to check if scaled-multisample-blit is supported.
2015-10-21 00:16:07 +11:00
e5916187e8 First step to handle missing libs/datablocks when reading a file.
Idea is, instead of ignoring completely missing linked datablocks, to
create void placeholders for them.

That way, you can work on your file, save it, and find again your missing data once
lib becomes available again. Or you can edit missing lib's path (in Outliner),
save and reload the file, and you are done.

Also, Outliner now shows broken libraries (and placeholders) with a 'broken lib' icon.

Future plans are also to be able to relocate missing libs and reload them at runtime.

Code notes:
    - Placeholder ID is just a regular datablock of same type as expected linked one,
      with 'default' data, and a LIB_MISSING bitflag set.
    - To allow creation of such datablocks, creation of datablocks in BKE was split in two step:
        + Allocation of memory itself.
        + Setting of all internal data to default values.

See also the design task (T43351).

Reviewed by @campbellbarton, thanks a bunch!

Differential Revision: https://developer.blender.org/D1394
2015-10-20 14:44:57 +02:00
dcb56d79a8 BLI: add new 'memory_utils' module with func checking a whole memory chunk is filled of zero,
and an helper to ensure all memory of a given structure passed a given member is filled of zero.
2015-10-20 14:44:15 +02:00
f08dad0e03 Minor edits to sytem-info script
- list script paths on their own line.
- use title util function.
2015-10-20 17:38:15 +11:00
8bcc68b21c Add operator to close a window
Useful for Python scripts, which could duplicate but not close windows.
2015-10-20 15:42:30 +11:00
Dalai Felinto
0173116117 New function to draw offscreen, and related API changes
This expose the capability of handling offscreen drawing. The initial
support lays the barebones for addons to work with framebuffer objects
and implement 3d viewport offscreen drawing. This can be used by script
writers to make fisheye lens preview, head mounted display support, ...

The complete documentation is here: http://www.blender.org/api/blender_python_api_2_76_1/gpu.offscreen.html

Review and many changes by Campbell Barton (thank you :)

https://developer.blender.org/D1533
2015-10-20 01:15:03 -02:00
70dfb61300 Cleanup: remove _POSIX_C_SOURCE undefine 2015-10-20 14:06:29 +11:00
ed7c7a0a05 BGE: Cleanup BL_Action
Remove initialization of m_endtime : fix compile about previous BL_Action cleanup.
2015-10-19 20:28:05 +02:00
2c369b1490 BGE: Cleanup BL_Action.
- Rename m_localtime to m_localframe to avoid ambiguity : it's a count for the actual action frame, not time.
- Delete m_end : it's unused.
2015-10-19 20:27:04 +02:00
38cd6329d6 Py API docs: fix extracting bmesh.ops from C code. 2015-10-20 03:55:31 +11:00
43c0f60523 Fix T46534: Crash loading corrupt HDR's 2015-10-20 02:13:14 +11:00
69c163b367 Cleanup: use UNLIKELY for checking corrupt HDR's 2015-10-20 02:13:14 +11:00
728d1ec504 BGE: Fix T46381 : last action frame not updated.
It fix T46381. Normally BL_Action::Update (manage action time, end, loop…) should be called the same number of times as BL_Action::UpdateIPO (update action position, scale ect… in the game object).
But the bug report shows that UpdateIPO is called one less time than Update. To fix it i revert the commit 362b25b382 and implement a mutex in BL_Action::Update.
Example file : {F245823}

Reviewers: lordloki, kupoman, campbellbarton, youle, moguri, sybren

Reviewed By: youle, moguri, sybren

Maniphest Tasks: T39928, T46381

Differential Revision: https://developer.blender.org/D1562
2015-10-19 16:03:40 +02:00
2b12cf40a1 Fix T46529: Unwrap UV w/ use-subsurf fails
Regression since moving to looptri.
2015-10-19 22:15:03 +11:00
67e1c97350 GPU: check for blit support, using MSAA FBO's
Used for reading off-screen buffers,
possible cause of failure for drivers that don't support it.
2015-10-19 12:36:15 +11:00
a25892543a Fix T46531: Cannot use % in filenames.
Same case as with space char really, one should not use those special chars in
filenames, but they are globally supported by all current FS/OS, so no real reason
to enforce that behvior on users here.

To be backported to 'a' release.
2015-10-18 18:51:08 +02:00
f56392f224 BLI_task: fix bad freeing of current task_thread in case POSIX thread creation fails.
Trying to MEM_free a single item of a whole MEM_calloc'ated array, tsst...
Luckily looks like POSIX thread creation does not fail often! :P
2015-10-18 14:39:37 +02:00
5551948b31 Fix T46520: mathutils.bvhtree crashes with distance input.
Should be backported to 'a' release.
2015-10-18 12:09:42 +02:00
94791bd5da Fix T46524: Use Alpha (Straight/Premultiply) option missing in 2.76 for DDS files.
All optional image format are not #define'd in submodules like DDS read/write code.
This means values of `eImbTypes` would not always be the same in all contexts, yuck!

This is a regression and should be backported to 'a' release.
2015-10-18 11:13:33 +02:00
6158a9826d BGE: Use references in CcdPhysicsEnvironment::RemoveConstraint.
It avoids assert calls on rigid body destructor.
2015-10-17 21:49:37 +02:00
0a2b48e3c6 Fix T46429: Movie clip is deformed by resolution multiplier when offset is added in sequence editor. 2015-10-17 11:32:04 +02:00
2927fa4450 correct own error in rectangle clamping 2015-10-17 18:52:05 +11:00
88767a1939 IMB_thumbs: add missing error check 2015-10-17 16:16:08 +11:00
eb49a76dca Cleanup: warnings
- remove NULL checks for args already set as ATTR_NONNULL.
- double promotion.
2015-10-17 16:06:45 +11:00
3d69ef240e Cleanup: BLI_path comments 2015-10-17 16:04:54 +11:00
0b23799b6f Cleanup: remove unused BLI_string_to_utf8 2015-10-17 16:00:59 +11:00
bfdb42047a Fix broken CD_NORMAL interpolation callback (would generate non-unit vectors).
Even if the weights are normalized, the weighted sum of normalized vectors
usually does **not** give a normalized vector (unless all source vectors
are aligned).

This probably was not a big issue in most cases, since we usually interpolate
similar vectors here - but still!
2015-10-16 21:56:42 +02:00
8172712841 Fix T46508: data_transfer of normals fails in case objects are transformed.
The final stage of the process (copying/interpolating new dst cddata from src cddata)
was simply broken in normal case, where we need to convert from source to destination
object space.

This patch is a bit verbose, but I cannot see how to avoid it really.

To think this code is in master since over 6 months and it only gets reported now... :/
2015-10-16 21:56:42 +02:00
a88ae6fa70 Mesh remapping: fix loop 'best matching normals' not using transform space.
Also, cleanup, reduce declarations of tmp_co/_no...
2015-10-16 21:56:42 +02:00
d307c24a8b Cleanup: style
Also use gcc style file:line: syntax for errors.
2015-10-17 02:46:38 +11:00
a1b34c0d28 Fix T46510: VSE View-all crops out image 2015-10-17 02:03:17 +11:00
1ec549886b Cleanup: use bools for v2d, minor ws edits 2015-10-17 01:01:57 +11:00
34e749beef Fix popup menu glitch, scrolling at high dpi
Popups were clamped be screen-margin,
then clipped by UI_POPUP_MENU_TOP, causing regular popups
not to have enough room & add scroll buttons.
2015-10-17 00:31:11 +11:00
b6b15f07a1 UI: expose UI_POPUP_MENU_TOP for use elsewhere. 2015-10-17 00:22:51 +11:00
e6aa464757 BLI_rect: add BLI_rctf_clamp
Clamp one rect within another.

This is done inline in the UI code, which gets verbose.
2015-10-17 00:03:29 +11:00
99cf636e84 Cleanup: redundant struct qualifiers 2015-10-17 00:02:07 +11:00
85f3b21cc8 error in last commit 2015-10-16 21:57:59 +11:00
7dc80097a4 Fix for missing id_lib_extern, assigning ID's 2015-10-16 21:53:01 +11:00
b5a4a00998 Fix T46502: Linked dupli-group lost on reload 2015-10-16 20:56:39 +11:00
7bf7f67a46 Revert part of rB4d9345479aa86f61, and cleanup a bit.
'thumbnail_size' is now used in all cases, it controlls column width in other viewmodes
of filebrowser. We cannot (easily) rename that DNA member, but I also renamed RNA
property, and fixed its tooltip...
2015-10-16 11:21:12 +02:00
4d9345479a UI: only show thumbnail size when its enabled
Also make enum identifiers less cryptic.
2015-10-16 18:51:33 +11:00
c9d3243f2b Cleanup: simplify BLI_stringdec use 2015-10-16 15:17:54 +11:00
2f35217849 Fix T46503: Snap scale fails using corner pivot 2015-10-16 15:00:18 +11:00
c62468aabb VBO implementation for GLSL subsurfed meshes (non-mapped case)
As with cdderivedmesh, performance here is still CPU-limited if material
needs tangents/UVs/vcolors. Draw calls have much less overhead though.
Also, as with derivedmesh, kept an exception for old drawing for NVIDIA
+OSX+VBO off or setDrawOptions callback not being NULL.

setDrawOptions should be ommitable and fully VBOfialbe (?) in the
future, usually those just check for hidden flag of poly or similar.
2015-10-15 23:20:30 +03:00
2f0db80155 Fix crash pressing +/- in file-selector
Filenames over 128 chars would crash.
Move BLI_newname into file_ops,
this was only used in one place and isn't all that re-usable.
Also remove special behavior for 4 digits.
2015-10-16 04:57:52 +11:00
cebaedd709 Fix crash w/ PlayAnim & long filenames
Paths >128 chars could crash.
Replace BLI_newname with direct BLI_stringenc/dec use which makes more sense in this case.
2015-10-16 04:31:17 +11:00
14de9a5982 Knife tool: generalize angle snapping code
Replace hard-coded snap angles with function that allows arbitrary snapping increments.

Currently no user visible change.
2015-10-16 04:04:45 +11:00
99142ec7e0 BLI_math: isect_ray_plane_v3 now takes 4d plane
Was taking a triangle and doing ray-tri intersect.
2015-10-16 03:06:12 +11:00
2746bbe30e Fix T46493: Wrong camera zoom blur with non-unit pixel aspect 2015-10-15 19:33:02 +05:00
fa3dd5d9f4 Cleanup: BLO_read: linking API arg order and name.
linking API funcs would use 'name, idcode', when all other code here uses
(more sensible) 'idcode, name'.

Also, use 'name' arg name when we expect a bare name, without the prepended ID code, and
'idname' arg name when we expect a complete ID name.

And here too, idcode shall be short, not int!
2015-10-15 16:12:00 +02:00
25f79d97de Cleanup: BKE_idcode: idcode (types) are short, not int...
Also, use 'idcode' var name, as in many other places in Blender.
2015-10-15 16:12:00 +02:00
df1e9fac06 Fix error w/ printing knife header angle-snapping 2015-10-16 00:41:14 +11:00
e60d535443 3D View: support non-uniform scaled lamps
D1378 by @youle

Non-uniform scaled lamps now cast oval/rectangular shadows, viewport & BGE.
2015-10-15 22:36:31 +11:00
3de81314fa Error in last commit 2015-10-15 21:30:24 +11:00
83d6b73e96 Error in last commit 2015-10-15 21:28:07 +11:00
0a82a20fe4 BLI_math: add normalize_m#_ex functions
Useful when we need to use the axis lengths too.
2015-10-15 21:03:27 +11:00
f53a21747c Fix T46494: Can't de-select a face w/ mixed modes 2015-10-15 19:57:51 +11:00
a595cda2cd Fix memory leaks in PlayAnim
Was never freeing filenames or pictures.
2015-10-15 17:45:53 +11:00
0be6ca0b83 Fix T46465: Lag scrubbing w/ PlayAnim 2015-10-15 17:25:43 +11:00
b4b2caffd8 PlayAnim: avoid list count setting frame from mouse 2015-10-15 16:56:30 +11:00
0296642794 Change version cycle to 'alpha' 2015-10-15 16:56:30 +11:00
767d3f23b7 Fix T45900: Allow again white spaces in file names.
Should probably be added to 'a' release, should we do one...
2015-10-15 07:44:25 +02:00
f823b9ece8 Fix T46483: vertex/edge slide with correct UVs sometimes pinning UVs. 2015-10-15 03:14:38 +02:00
12c705ec86 Fix related to T46223: memory leak when loading multilayer multiview images.
Differential Revision: https://developer.blender.org/D1549
2015-10-15 01:58:33 +02:00
8191066c0b Fix T46223: multiview image sequences crashing.
Differential Revision: https://developer.blender.org/D1549
2015-10-15 01:58:28 +02:00
4965c43df7 Fix T46451: vertex/edge slide clamp not available in redo popup. 2015-10-15 01:51:57 +02:00
75e4e4b67f BGE: Fix animations update when scene is suspended. 2015-10-14 22:54:20 +02:00
59ba52628f Fix T46487: OpenSubdiv objects are invisible in Blender Internal "Rendered" viewport mode 2015-10-15 00:19:38 +05:00
51fc7aee34 Fix T46453: JPEG quality not stored in file
This is a feature unique to jpeg that would store the quality it was saved.

- Use struct instead of bit-shifting.
- No longer store the 'flag'.
2015-10-14 21:04:17 +11:00
2635f5b2c8 Cleanup: remove historic, blender-only jpeg io 2015-10-14 20:18:18 +11:00
ad58310161 Comment cleanup, use better lower bound for waveform 2015-10-14 12:23:17 +03:00
6562e4ebe9 Fix T46189, draw style for waveforms occludes sequence strip text.
Used old (2.49 era) filled style for drawing here, with white color and
alpha blending.
Also changed drawing to do linear interpolation between samples instead
of ugly square wave in high zoom.
This could be improved upon, with real waveform drawing in higher zoom
levels, but I'll leave this for later since it may need some hacking on
audaspace level.
2015-10-14 12:15:03 +03:00
904db487a7 Fix T46284: Texture paint, wrong shading mode
Project-paint now supports painting to cycles materials.
2015-10-14 16:22:23 +11:00
56021cad31 Support for multi-sample sequencer GL render
OpenGL sequencer render now uses a single fbo for all rendering.
2015-10-14 12:50:03 +11:00
53d73c51a7 Support for multi-sample off-screen buffers
Replaces much slower manual accumulation buffer which simply did multiple renders.

Needs OpenGL3.2, otherwise multi-sample is disabled.
2015-10-14 10:51:17 +11:00
5d3e07862c Cycles: Add support for motion blur position
This adds an option to control at what time relative to the current frame
the shutter is fully opened. Supported options are:

- Shutter is starting to open at the current frame
- Shutter is fully opened at the current frame
- Shutter is fully closed  at the current frame

Custom shutter time offset is possible, same as custom curve for shutter
openness but those are considered nice things to have rather than something
crucial.

Reviewers: juicyfruit, dingto

Subscribers: venomgfx, hjalti

Differential Revision: https://developer.blender.org/D1380
2015-10-13 21:05:27 +05:00
833 changed files with 14213 additions and 9797 deletions

View File

@@ -2326,6 +2326,7 @@ if(WITH_IMAGE_OPENJPEG)
else()
set(OPENJPEG_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/extern/libopenjpeg")
set(OPENJPEG_DEFINES "-DOPJ_STATIC")
set(OPENJPEG_LIBRARIES "extern_openjpeg")
endif()
# Special handling of Windows platform where openjpeg is always static.
if(WIN32)
@@ -2333,6 +2334,12 @@ if(WITH_IMAGE_OPENJPEG)
endif()
endif()
if(WITH_LZO)
if(NOT WITH_SYSTEM_LZO)
set(LZO_LIBRARIES "extern_minilzo")
endif()
endif()
if(WITH_IMAGE_REDCODE)
set(REDCODE ${CMAKE_SOURCE_DIR}/extern)
set(REDCODE_INC ${REDCODE})

View File

@@ -2,4 +2,5 @@ BF_BUILDDIR = '../blender-build/linux-glibc211-i686'
BF_INSTALLDIR = '../blender-install/linux-glibc211-i686'
BF_NUMJOBS = 1
BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_20', 'sm_21', 'sm_30', 'sm_35', 'sm_50', 'sm_52']
#BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_20', 'sm_21', 'sm_30', 'sm_35', 'sm_50', 'sm_52']
BF_CYCLES_CUDA_BINARIES_ARCH = []

View File

@@ -50,6 +50,8 @@ from os.path import join, dirname, normpath, relpath, exists
def create_nb_project_main():
from xml.sax.saxutils import escape
files = list(source_list(SOURCE_DIR, filename_check=is_project_file))
files_rel = [relpath(f, start=PROJECT_DIR) for f in files]
files_rel.sort()
@@ -207,8 +209,8 @@ def create_nb_project_main():
build_cmd = "${MAKE} -f Makefile"
clean_cmd = "${MAKE} -f Makefile clean"
f.write(' <buildCommand>%s</buildCommand>\n' % build_cmd)
f.write(' <cleanCommand>%s</cleanCommand>\n' % clean_cmd)
f.write(' <buildCommand>%s</buildCommand>\n' % escape(build_cmd))
f.write(' <cleanCommand>%s</cleanCommand>\n' % escape(clean_cmd))
f.write(' <executablePath>./bin/blender</executablePath>\n')
del build_cmd, clean_cmd
@@ -219,7 +221,7 @@ def create_nb_project_main():
f.write(' </incDir>\n')
f.write(' <preprocessorList>\n')
for cdef in defines:
f.write(' <Elem>%s</Elem>\n' % cdef)
f.write(' <Elem>%s</Elem>\n' % escape(cdef))
f.write(' </preprocessorList>\n')
f.write(' <cTool>\n')

View File

@@ -212,6 +212,8 @@ function(blender_add_lib_nolist
add_library(${name} ${sources})
target_link_libraries(${name} ${lib_depends})
# works fine without having the includes
# listed is helpful for IDE's (QtCreator/MSVC)
blender_source_group("${sources}")
@@ -229,10 +231,13 @@ function(blender_add_lib
sources
includes
includes_sys
libs
)
blender_add_lib_nolist(${name} "${sources}" "${includes}" "${includes_sys}")
target_link_libraries(${name} "${libs}")
set_property(GLOBAL APPEND PROPERTY BLENDER_LINK_LIBS ${name})
endfunction()
@@ -469,7 +474,8 @@ endfunction()
function(SETUP_BLENDER_SORTED_LIBS)
get_property(BLENDER_LINK_LIBS GLOBAL PROPERTY BLENDER_LINK_LIBS)
# get_property(BLENDER_LINK_LIBS GLOBAL PROPERTY BLENDER_LINK_LIBS)
set(BLENDER_LINK_LIBS)
list(APPEND BLENDER_LINK_LIBS
bf_windowmanager

View File

@@ -37,7 +37,8 @@ unset(MY_WC_HASH)
# Force Package Name
execute_process(COMMAND date "+%Y%m%d" OUTPUT_VARIABLE CPACK_DATE OUTPUT_STRIP_TRAILING_WHITESPACE)
set(CPACK_PACKAGE_FILE_NAME ${PROJECT_NAME}-${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}-git${CPACK_DATE}.${BUILD_REV}-${CMAKE_SYSTEM_PROCESSOR})
string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER)
set(CPACK_PACKAGE_FILE_NAME ${PROJECT_NAME_LOWER}-${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}-git${CPACK_DATE}.${BUILD_REV}-${CMAKE_SYSTEM_PROCESSOR})
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
# RPM packages
@@ -73,6 +74,7 @@ if(WIN32)
set(CPACK_WIX_PRODUCT_ICON ${CMAKE_SOURCE_DIR}/source/icons/winblender.ico)
set(CPACK_WIX_UPGRADE_GUID "B767E4FD-7DE7-4094-B051-3AE62E13A17A")
set(CPACK_WIX_TEMPLATE ${LIBDIR}/package/installer_wix/WIX.template)
set(CPACK_WIX_UI_BANNER ${LIBDIR}/package/installer_wix/WIX_UI_BANNER.bmp)
set(CPACK_WIX_UI_DIALOG ${LIBDIR}/package/installer_wix/WIX_UI_DIALOG.bmp)

View File

@@ -0,0 +1,192 @@
# Draws an off-screen buffer and display it in the corner of the view.
import bpy
from bgl import *
class OffScreenDraw(bpy.types.Operator):
bl_idname = "view3d.offscreen_draw"
bl_label = "View3D Offscreen Draw"
_handle_calc = None
_handle_draw = None
is_enabled = False
# manage draw handler
@staticmethod
def draw_callback_px(self, context):
scene = context.scene
aspect_ratio = scene.render.resolution_x / scene.render.resolution_y
self._update_offscreen(context, self._offscreen)
self._opengl_draw(context, self._texture, aspect_ratio, 0.2)
@staticmethod
def handle_add(self, context):
OffScreenDraw._handle_draw = bpy.types.SpaceView3D.draw_handler_add(
self.draw_callback_px, (self, context),
'WINDOW', 'POST_PIXEL',
)
@staticmethod
def handle_remove():
if OffScreenDraw._handle_draw is not None:
bpy.types.SpaceView3D.draw_handler_remove(OffScreenDraw._handle_draw, 'WINDOW')
OffScreenDraw._handle_draw = None
# off-screen buffer
@staticmethod
def _setup_offscreen(context):
import gpu
scene = context.scene
aspect_ratio = scene.render.resolution_x / scene.render.resolution_y
try:
offscreen = gpu.offscreen.new(512, int(512 / aspect_ratio))
except Exception as e:
print(e)
offscreen = None
return offscreen
@staticmethod
def _update_offscreen(context, offscreen):
scene = context.scene
render = scene.render
camera = scene.camera
modelview_matrix = camera.matrix_world.inverted()
projection_matrix = camera.calc_matrix_camera(
render.resolution_x,
render.resolution_y,
render.pixel_aspect_x,
render.pixel_aspect_y,
)
offscreen.draw_view3d(
scene,
context.space_data,
context.region,
projection_matrix,
modelview_matrix,
)
@staticmethod
def _opengl_draw(context, texture, aspect_ratio, scale):
"""
OpenGL code to draw a rectangle in the viewport
"""
glDisable(GL_DEPTH_TEST)
# view setup
glMatrixMode(GL_PROJECTION)
glPushMatrix()
glLoadIdentity()
glMatrixMode(GL_MODELVIEW)
glPushMatrix()
glLoadIdentity()
glOrtho(-1, 1, -1, 1, -15, 15)
gluLookAt(0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0)
act_tex = Buffer(GL_INT, 1)
glGetIntegerv(GL_TEXTURE_2D, act_tex)
viewport = Buffer(GL_INT, 4)
glGetIntegerv(GL_VIEWPORT, viewport)
width = int(scale * viewport[2])
height = int(width / aspect_ratio)
glViewport(viewport[0], viewport[1], width, height)
glScissor(viewport[0], viewport[1], width, height)
# draw routine
glEnable(GL_TEXTURE_2D)
glActiveTexture(GL_TEXTURE0)
glBindTexture(GL_TEXTURE_2D, texture)
texco = [(1, 1), (0, 1), (0, 0), (1, 0)]
verco = [(1.0, 1.0), (-1.0, 1.0), (-1.0, -1.0), (1.0, -1.0)]
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)
glColor4f(1.0, 1.0, 1.0, 1.0)
glBegin(GL_QUADS)
for i in range(4):
glTexCoord3f(texco[i][0], texco[i][1], 0.0)
glVertex2f(verco[i][0], verco[i][1])
glEnd()
# restoring settings
glBindTexture(GL_TEXTURE_2D, act_tex[0])
glDisable(GL_TEXTURE_2D)
# reset view
glMatrixMode(GL_PROJECTION)
glPopMatrix()
glMatrixMode(GL_MODELVIEW)
glPopMatrix()
glViewport(viewport[0], viewport[1], viewport[2], viewport[3])
glScissor(viewport[0], viewport[1], viewport[2], viewport[3])
# operator functions
@classmethod
def poll(cls, context):
return context.area.type == 'VIEW_3D'
def modal(self, context, event):
if context.area:
context.area.tag_redraw()
return {'PASS_THROUGH'}
def invoke(self, context, event):
if OffScreenDraw.is_enabled:
self.cancel(context)
return {'FINISHED'}
else:
self._offscreen = OffScreenDraw._setup_offscreen(context)
if self._offscreen:
self._texture = self._offscreen.color_texture
else:
self.report({'ERROR'}, "Error initializing offscreen buffer. More details in the console")
return {'CANCELLED'}
OffScreenDraw.handle_add(self, context)
OffScreenDraw.is_enabled = True
if context.area:
context.area.tag_redraw()
context.window_manager.modal_handler_add(self)
return {'RUNNING_MODAL'}
def cancel(self, context):
OffScreenDraw.handle_remove()
OffScreenDraw.is_enabled = False
if context.area:
context.area.tag_redraw()
def register():
bpy.utils.register_class(OffScreenDraw)
def unregister():
bpy.utils.unregister_class(OffScreenDraw)
if __name__ == "__main__":
register()

View File

@@ -1,65 +0,0 @@
KX_IpoActuator(SCA_IActuator)
=============================
.. module:: bge.types
base class --- :class:`SCA_IActuator`
.. class:: KX_IpoActuator(SCA_IActuator)
IPO actuator activates an animation.
.. attribute:: frameStart
Start frame.
:type: float
.. attribute:: frameEnd
End frame.
:type: float
.. attribute:: propName
Use this property to define the Ipo position.
:type: string
.. attribute:: framePropName
Assign this property this action current frame number.
:type: string
.. attribute:: mode
Play mode for the ipo. Can be on of :ref:`these constants <ipo-actuator>`
:type: integer
.. attribute:: useIpoAsForce
Apply Ipo as a global or local force depending on the local option (dynamic objects only).
:type: boolean
.. attribute:: useIpoAdd
Ipo is added to the current loc/rot/scale in global or local coordinate according to Local flag.
:type: boolean
.. attribute:: useIpoLocal
Let the ipo acts in local coordinates, used in Force and Add mode.
:type: boolean
.. attribute:: useChildren
Update IPO on all children Objects as well.
:type: boolean

View File

@@ -25,6 +25,12 @@ base class --- :class:`PyObjectPlus`
:type: callable
.. attribute:: finished
The current status of the lib load.
:type: boolean
.. attribute:: progress
The current progress of the lib load as a normalized value from 0.0 to 1.0.

View File

@@ -277,6 +277,12 @@ GLSL Lamp Uniforms
:type: float
.. data:: GPU_DYNAMIC_LAMP_SPOTSCALE
Represents the SpotLamp local scale.
:type: float2
GLSL Sampler Uniforms
^^^^^^^^^^^^^^^^^^^^^

View File

@@ -114,9 +114,9 @@ This example shows loading a script in as a module and executing a module functi
.. code-block:: python
import myscript
import imp
import importlib
imp.reload(myscript)
importlib.reload(myscript)
myscript.main()
@@ -143,8 +143,8 @@ this example adds the current blend files directory to the search path, then loa
sys.path.append(blend_dir)
import myscript
import imp
imp.reload(myscript)
import importlib
importlib.reload(myscript)
myscript.main()
@@ -307,7 +307,7 @@ Since it's possible to access data which has been removed (see Gotcha's),
this can be hard to track down the cause of crashes.
To raise Python exceptions on accessing freed data (rather than crashing),
enable the CMake build option WITH_PYTHON_SAFETY.
enable the CMake build option ``WITH_PYTHON_SAFETY``.
This enables data tracking which makes data access about 2x slower
which is why the option isn't enabled in release builds.

View File

@@ -163,6 +163,9 @@ def main():
for i, l in enumerate(b):
l = l.strip()
# casts
l = l.replace("(int)", "")
l = l.replace("{", "(")
l = l.replace("}", ")")

View File

@@ -261,6 +261,7 @@ else:
"bpy.utils.previews",
"bpy_extras",
"gpu",
"gpu.offscreen",
"mathutils",
"mathutils.geometry",
"mathutils.bvhtree",
@@ -1659,7 +1660,9 @@ def write_rst_contents(basepath):
# mathutils
"mathutils", "mathutils.geometry", "mathutils.bvhtree", "mathutils.kdtree", "mathutils.noise",
# misc
"freestyle", "bgl", "blf", "gpu", "aud", "bpy_extras",
"freestyle", "bgl", "blf",
"gpu", "gpu.offscreen",
"aud", "bpy_extras",
# bmesh, submodules are in own page
"bmesh",
)
@@ -1799,6 +1802,7 @@ def write_rst_importable_modules(basepath):
# C_modules
"aud" : "Audio System",
"blf" : "Font Drawing",
"gpu.offscreen" : "GPU Off-Screen Buffer",
"bmesh" : "BMesh Module",
"bmesh.types" : "BMesh Types",
"bmesh.utils" : "BMesh Utilities",

View File

@@ -18,8 +18,10 @@ DO_OUT_HTML=true
DO_OUT_HTML_ZIP=true
DO_OUT_PDF=false
if [ -z $BLENDER_BIN ] ; then
BLENDER_BIN="./blender.bin"
fi
BLENDER="./blender.bin"
SSH_USER=$1
SSH_HOST=$SSH_USER"@blender.org"
SSH_UPLOAD="/data/www/vhosts/www.blender.org/api" # blender_python_api_VERSION, added after
@@ -52,7 +54,7 @@ SPHINXBASE=doc/python_api
if $DO_EXE_BLENDER ; then
# dont delete existing docs, now partial updates are used for quick builds.
$BLENDER --background -noaudio --factory-startup --python $SPHINXBASE/sphinx_doc_gen.py
$BLENDER_BIN --background -noaudio --factory-startup --python $SPHINXBASE/sphinx_doc_gen.py
fi

View File

@@ -40,4 +40,8 @@ set(SRC
intern/svd.h
)
blender_add_lib(extern_eigen3 "${SRC}" "${INC}" "${INC_SYS}")
set(LIB
)
blender_add_lib(extern_eigen3 "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")

View File

@@ -32,7 +32,11 @@ set(SRC
include/binreloc.h
)
set(LIB
)
add_definitions(-DENABLE_BINRELOC)
blender_add_lib(extern_binreloc "${SRC}" "${INC}" "${INC_SYS}")
blender_add_lib(extern_binreloc "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")

View File

@@ -403,4 +403,4 @@ if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive")
endif()
blender_add_lib(extern_bullet "${SRC}" "${INC}" "${INC_SYS}")
blender_add_lib(extern_bullet "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")

View File

@@ -169,4 +169,4 @@ if(WITH_BOOST)
)
endif()
blender_add_lib(extern_carve "${SRC}" "${INC}" "${INC_SYS}")
blender_add_lib(extern_carve "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")

View File

@@ -37,6 +37,10 @@ set(SRC
src/clew.c
)
set(LIB
)
add_definitions(-DCL_USE_DEPRECATED_OPENCL_1_1_APIS)
blender_add_lib(extern_clew "${SRC}" "${INC}" "${INC_SYS}")
blender_add_lib(extern_clew "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")

View File

@@ -78,13 +78,13 @@ extern "C" {
#define CL_API_SUFFIX__VERSION_1_0 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
#define CL_EXT_SUFFIX__VERSION_1_0 CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
#define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
#define CL_EXT_PREFIX__VERSION_1_0_DEPRECATED CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
#define CL_API_SUFFIX__VERSION_1_1 CL_EXTENSION_WEAK_LINK
#define CL_EXT_SUFFIX__VERSION_1_1 CL_EXTENSION_WEAK_LINK
#define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
#define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
#define CL_API_SUFFIX__VERSION_1_2 CL_EXTENSION_WEAK_LINK
#define CL_EXT_SUFFIX__VERSION_1_2 CL_EXTENSION_WEAK_LINK
#define CL_EXT_PREFIX__VERSION_1_0_DEPRECATED CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
#define CL_API_SUFFIX__VERSION_1_1 CL_EXTENSION_WEAK_LINK
#define CL_EXT_SUFFIX__VERSION_1_1 CL_EXTENSION_WEAK_LINK
#define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
#define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
#define CL_API_SUFFIX__VERSION_1_2 CL_EXTENSION_WEAK_LINK
#define CL_EXT_SUFFIX__VERSION_1_2 CL_EXTENSION_WEAK_LINK
#else
#define CL_EXTENSION_WEAK_LINK
#define CL_API_SUFFIX__VERSION_1_0
@@ -2484,7 +2484,7 @@ PFNCLCREATEFROMGLTEXTURE3D)(cl_context /* context */,
#ifdef __APPLE__
# pragma GCC diagnostic pop // ignored "-Wignored-attributes"
#endif
/* cl_khr_gl_sharing extension */
#define cl_khr_gl_sharing 1

View File

@@ -378,5 +378,15 @@ const char* clewErrorString(cl_int error)
, "CL_INVALID_DEVICE_PARTITION_COUNT" // -68
};
static const int num_errors = sizeof(strings) / sizeof(strings[0]);
if (error == -1001) {
return "CL_PLATFORM_NOT_FOUND_KHR";
}
if (error > 0 || -error >= num_errors) {
return "Unknown OpenCL error";
}
return strings[-error];
}

View File

@@ -38,4 +38,4 @@ set(SRC
Include/UFconfig.h
)
blender_add_lib(extern_colamd "${SRC}" "${INC}" "${INC_SYS}")
blender_add_lib(extern_colamd "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")

View File

@@ -37,4 +37,8 @@ set(SRC
src/cuew.c
)
blender_add_lib(extern_cuew "${SRC}" "${INC}" "${INC_SYS}")
set(LIB
)
blender_add_lib(extern_cuew "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")

View File

@@ -47,6 +47,10 @@ set(SRC
include/GL/wglew.h
)
set(LIB
)
add_definitions(${GL_DEFINITIONS})
if(WITH_GLEW_MX)
@@ -54,4 +58,4 @@ if(WITH_GLEW_MX)
endif()
blender_add_lib(extern_glew_es "${SRC}" "${INC}" "${INC_SYS}")
blender_add_lib(extern_glew_es "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")

View File

@@ -51,4 +51,4 @@ if(WITH_GLEW_MX)
add_definitions(-DGLEW_MX)
endif()
blender_add_lib(extern_glew "${SRC}" "${INC}" "${INC_SYS}")
blender_add_lib(extern_glew "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")

View File

@@ -69,4 +69,8 @@ set(SRC
include/gtest/internal/gtest-type-util.h
)
blender_add_lib(extern_gtest "${SRC}" "${INC}" "${INC_SYS}")
set(LIB
)
blender_add_lib(extern_gtest "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")

View File

@@ -72,6 +72,11 @@ if(WITH_LIBMV OR WITH_GTESTS OR (WITH_CYCLES AND WITH_CYCLES_LOGGING))
)
endif()
set(LIB
extern_ceres
extern_glog
)
if(WITH_LIBMV)
TEST_SHARED_PTR_SUPPORT()
if(SHARED_PTR_FOUND)
@@ -219,7 +224,7 @@ if(WITH_LIBMV)
if(WITH_GTESTS)
blender_add_lib(libmv_test_dataset "./libmv/multiview/test_data_sets.cc" "" "")
blender_add_lib(libmv_test_dataset "./libmv/multiview/test_data_sets.cc" "" "" "")
BLENDER_SRC_GTEST("libmv_predict_tracks" "./libmv/autotrack/predict_tracks_test.cc" "libmv_test_dataset;extern_libmv;extern_ceres")
BLENDER_SRC_GTEST("libmv_tracks" "./libmv/autotrack/tracks_test.cc" "libmv_test_dataset;extern_libmv;extern_ceres")
@@ -259,7 +264,8 @@ else()
)
endif()
blender_add_lib(extern_libmv "${SRC}" "${INC}" "${INC_SYS}")
blender_add_lib(extern_libmv "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
unset(LIB)
if(WITH_LIBMV)
add_subdirectory(third_party)
@@ -345,5 +351,5 @@ if(WITH_LIBMV OR WITH_GTESTS OR (WITH_CYCLES AND WITH_CYCLES_LOGGING))
)
endif()
blender_add_lib(extern_glog "${GLOG_SRC}" "${INC}" "${INC_SYS}")
blender_add_lib(extern_glog "${GLOG_SRC}" "${INC}" "${INC_SYS}" "")
endif()

View File

@@ -80,7 +80,6 @@ set(SRC
internal/ceres/gradient_problem.cc
internal/ceres/gradient_problem_solver.cc
internal/ceres/implicit_schur_complement.cc
internal/ceres/incomplete_lq_factorization.cc
internal/ceres/iterative_schur_complement_solver.cc
internal/ceres/lapack.cc
internal/ceres/levenberg_marquardt_strategy.cc
@@ -209,7 +208,6 @@ set(SRC
internal/ceres/graph_algorithms.h
internal/ceres/graph.h
internal/ceres/implicit_schur_complement.h
internal/ceres/incomplete_lq_factorization.h
internal/ceres/integral_types.h
internal/ceres/iterative_schur_complement_solver.h
internal/ceres/lapack.h
@@ -270,6 +268,7 @@ if(WITH_LIBMV_SCHUR_SPECIALIZATIONS)
internal/ceres/generated/partitioned_matrix_view_2_2_d.cc
internal/ceres/generated/partitioned_matrix_view_2_3_3.cc
internal/ceres/generated/partitioned_matrix_view_2_3_4.cc
internal/ceres/generated/partitioned_matrix_view_2_3_6.cc
internal/ceres/generated/partitioned_matrix_view_2_3_9.cc
internal/ceres/generated/partitioned_matrix_view_2_3_d.cc
internal/ceres/generated/partitioned_matrix_view_2_4_3.cc
@@ -288,6 +287,7 @@ if(WITH_LIBMV_SCHUR_SPECIALIZATIONS)
internal/ceres/generated/schur_eliminator_2_2_d.cc
internal/ceres/generated/schur_eliminator_2_3_3.cc
internal/ceres/generated/schur_eliminator_2_3_4.cc
internal/ceres/generated/schur_eliminator_2_3_6.cc
internal/ceres/generated/schur_eliminator_2_3_9.cc
internal/ceres/generated/schur_eliminator_2_3_d.cc
internal/ceres/generated/schur_eliminator_2_4_3.cc
@@ -356,4 +356,4 @@ else()
endif()
endif()
blender_add_lib(extern_ceres "${SRC}" "${INC}" "${INC_SYS}")
blender_add_lib(extern_ceres "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python
# NOTE: This file is automatically generated by bundle.sh script
# If you're doing changes in this file, please update template

View File

@@ -129,7 +129,7 @@ set(INC
)
set(INC_SYS
${EIGEN3_INCLUDE_DIRS}
\${EIGEN3_INCLUDE_DIRS}
)
set(SRC

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2014 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -30,13 +30,16 @@
// Default (empty) configuration options for Ceres.
//
// IMPORTANT: Most users of Ceres will not use this file, when compiling Ceres
// with CMake, CMake will configure a new config.h with the currently
// selected Ceres compile options and copy it into the source
// directory before compilation. However, for some users of Ceres
// who compile without CMake, this file ensures that Ceres will
// compile, with the user either specifying manually the Ceres
// compile options, or passing them directly through the compiler.
// IMPORTANT: Most users of Ceres will not use this file, when
// compiling Ceres with CMake, CMake will configure a new
// config.h with the currently selected Ceres compile
// options in <BUILD_DIR>/config, which will be added to
// the include path for compilation, and installed with the
// public Ceres headers. However, for some users of Ceres
// who compile without CMake (Android), this file ensures
// that Ceres will compile, with the user either specifying
// manually the Ceres compile options, or passing them
// directly through the compiler.
#ifndef CERES_PUBLIC_INTERNAL_CONFIG_H_
#define CERES_PUBLIC_INTERNAL_CONFIG_H_

View File

@@ -157,8 +157,6 @@ internal/ceres/graph_algorithms.h
internal/ceres/graph.h
internal/ceres/implicit_schur_complement.cc
internal/ceres/implicit_schur_complement.h
internal/ceres/incomplete_lq_factorization.cc
internal/ceres/incomplete_lq_factorization.h
internal/ceres/integral_types.h
internal/ceres/iterative_schur_complement_solver.cc
internal/ceres/iterative_schur_complement_solver.h

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2013 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -33,9 +33,9 @@
#ifndef CERES_PUBLIC_AUTODIFF_LOCAL_PARAMETERIZATION_H_
#define CERES_PUBLIC_AUTODIFF_LOCAL_PARAMETERIZATION_H_
#include "ceres/local_parameterization.h"
#include "ceres/internal/autodiff.h"
#include "ceres/internal/scoped_ptr.h"
#include "ceres/local_parameterization.h"
namespace ceres {

View File

@@ -1,6 +1,6 @@
/* Ceres Solver - A fast non-linear least squares minimizer
* Copyright 2013 Google Inc. All rights reserved.
* http://code.google.com/p/ceres-solver/
* Copyright 2015 Google Inc. All rights reserved.
* http://ceres-solver.org/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2014 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -78,7 +78,7 @@ class CERES_EXPORT ConditionedCostFunction : public CostFunction {
// functions, or not, depending on the ownership parameter. Conditioners
// may be NULL, in which case the corresponding residual is not modified.
ConditionedCostFunction(CostFunction* wrapped_cost_function,
const vector<CostFunction*>& conditioners,
const std::vector<CostFunction*>& conditioners,
Ownership ownership);
virtual ~ConditionedCostFunction();
@@ -88,7 +88,7 @@ class CERES_EXPORT ConditionedCostFunction : public CostFunction {
private:
internal::scoped_ptr<CostFunction> wrapped_cost_function_;
vector<CostFunction*> conditioners_;
std::vector<CostFunction*> conditioners_;
Ownership ownership_;
};

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -115,7 +115,7 @@ class CERES_EXPORT CostFunction {
double* residuals,
double** jacobians) const = 0;
const vector<int32>& parameter_block_sizes() const {
const std::vector<int32>& parameter_block_sizes() const {
return parameter_block_sizes_;
}
@@ -124,7 +124,7 @@ class CERES_EXPORT CostFunction {
}
protected:
vector<int32>* mutable_parameter_block_sizes() {
std::vector<int32>* mutable_parameter_block_sizes() {
return &parameter_block_sizes_;
}
@@ -135,7 +135,7 @@ class CERES_EXPORT CostFunction {
private:
// Cost function signature metadata: number of inputs & their sizes,
// number of outputs (residuals).
vector<int32> parameter_block_sizes_;
std::vector<int32> parameter_block_sizes_;
int num_residuals_;
CERES_DISALLOW_COPY_AND_ASSIGN(CostFunction);
};

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2013 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -29,7 +29,7 @@
// Author: sameeragarwal@google.com (Sameer Agarwal)
//
// CostFunctionToFunctor is an adapter class that allows users to use
// CostFunction objects in templated functors which are to be used for
// SizedCostFunction objects in templated functors which are to be used for
// automatic differentiation. This allows the user to seamlessly mix
// analytic, numeric and automatic differentiation.
//
@@ -37,7 +37,7 @@
//
// class IntrinsicProjection : public SizedCostFunction<2, 5, 3> {
// public:
// IntrinsicProjection(const double* observations);
// IntrinsicProjection(const double* observation);
// virtual bool Evaluate(double const* const* parameters,
// double* residuals,
// double** jacobians) const;
@@ -62,10 +62,8 @@
// Then we can now do the following,
//
// struct CameraProjection {
// CameraProjection(double* observation) {
// intrinsic_projection_.reset(
// new CostFunctionToFunctor<2, 5, 3>(
// new IntrinsicProjection(observation_)));
// CameraProjection(const double* observation)
// : intrinsic_projection_(new IntrinsicProjection(observation)) {
// }
// template <typename T>
// bool operator()(const T* rotation,
@@ -79,11 +77,11 @@
// // Note that we call intrinsic_projection_, just like it was
// // any other templated functor.
//
// return (*intrinsic_projection_)(intrinsics, transformed_point, residual);
// return intrinsic_projection_(intrinsics, transformed_point, residual);
// }
//
// private:
// scoped_ptr<CostFunctionToFunctor<2,5,3> > intrinsic_projection_;
// CostFunctionToFunctor<2,5,3> intrinsic_projection_;
// };
#ifndef CERES_PUBLIC_COST_FUNCTION_TO_FUNCTOR_H_
@@ -93,6 +91,7 @@
#include <vector>
#include "ceres/cost_function.h"
#include "ceres/dynamic_cost_function_to_functor.h"
#include "ceres/internal/fixed_array.h"
#include "ceres/internal/port.h"
#include "ceres/internal/scoped_ptr.h"
@@ -104,28 +103,29 @@ template <int kNumResiduals,
int N5 = 0, int N6 = 0, int N7 = 0, int N8 = 0, int N9 = 0>
class CostFunctionToFunctor {
public:
// Takes ownership of cost_function.
explicit CostFunctionToFunctor(CostFunction* cost_function)
: cost_function_(cost_function) {
: cost_functor_(cost_function) {
CHECK_NOTNULL(cost_function);
CHECK(kNumResiduals > 0 || kNumResiduals == DYNAMIC);
// This block breaks the 80 column rule to keep it somewhat readable.
CHECK((!N1 && !N2 && !N3 && !N4 && !N5 && !N6 && !N7 && !N8 && !N9) ||
((N1 > 0) && !N2 && !N3 && !N4 && !N5 && !N6 && !N7 && !N8 && !N9) ||
((N1 > 0) && (N2 > 0) && !N3 && !N4 && !N5 && !N6 && !N7 && !N8 && !N9) ||
((N1 > 0) && (N2 > 0) && (N3 > 0) && !N4 && !N5 && !N6 && !N7 && !N8 && !N9) ||
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && !N5 && !N6 && !N7 && !N8 && !N9) ||
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && (N5 > 0) && !N6 && !N7 && !N8 && !N9) ||
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && (N5 > 0) && (N6 > 0) && !N7 && !N8 && !N9) ||
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && (N5 > 0) && (N6 > 0) && (N7 > 0) && !N8 && !N9) ||
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && (N5 > 0) && (N6 > 0) && (N7 > 0) && (N8 > 0) && !N9) ||
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && (N5 > 0) && (N6 > 0) && (N7 > 0) && (N8 > 0) && (N9 > 0)))
((N1 > 0) && (N2 > 0) && !N3 && !N4 && !N5 && !N6 && !N7 && !N8 && !N9) || // NOLINT
((N1 > 0) && (N2 > 0) && (N3 > 0) && !N4 && !N5 && !N6 && !N7 && !N8 && !N9) || // NOLINT
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && !N5 && !N6 && !N7 && !N8 && !N9) || // NOLINT
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && (N5 > 0) && !N6 && !N7 && !N8 && !N9) || // NOLINT
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && (N5 > 0) && (N6 > 0) && !N7 && !N8 && !N9) || // NOLINT
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && (N5 > 0) && (N6 > 0) && (N7 > 0) && !N8 && !N9) || // NOLINT
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && (N5 > 0) && (N6 > 0) && (N7 > 0) && (N8 > 0) && !N9) || // NOLINT
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && (N5 > 0) && (N6 > 0) && (N7 > 0) && (N8 > 0) && (N9 > 0))) // NOLINT
<< "Zero block cannot precede a non-zero block. Block sizes are "
<< "(ignore trailing 0s): " << N0 << ", " << N1 << ", " << N2 << ", "
<< N3 << ", " << N4 << ", " << N5 << ", " << N6 << ", " << N7 << ", "
<< N8 << ", " << N9;
const vector<int32>& parameter_block_sizes =
const std::vector<int32>& parameter_block_sizes =
cost_function->parameter_block_sizes();
const int num_parameter_blocks =
(N0 > 0) + (N1 > 0) + (N2 > 0) + (N3 > 0) + (N4 > 0) +
@@ -160,7 +160,7 @@ class CostFunctionToFunctor {
CHECK_EQ(N8, 0);
CHECK_EQ(N9, 0);
return cost_function_->Evaluate(&x0, residuals, NULL);
return cost_functor_(&x0, residuals);
}
bool operator()(const double* x0,
@@ -179,7 +179,7 @@ class CostFunctionToFunctor {
internal::FixedArray<const double*> parameter_blocks(2);
parameter_blocks[0] = x0;
parameter_blocks[1] = x1;
return cost_function_->Evaluate(parameter_blocks.get(), residuals, NULL);
return cost_functor_(parameter_blocks.get(), residuals);
}
bool operator()(const double* x0,
@@ -200,7 +200,7 @@ class CostFunctionToFunctor {
parameter_blocks[0] = x0;
parameter_blocks[1] = x1;
parameter_blocks[2] = x2;
return cost_function_->Evaluate(parameter_blocks.get(), residuals, NULL);
return cost_functor_(parameter_blocks.get(), residuals);
}
bool operator()(const double* x0,
@@ -223,7 +223,7 @@ class CostFunctionToFunctor {
parameter_blocks[1] = x1;
parameter_blocks[2] = x2;
parameter_blocks[3] = x3;
return cost_function_->Evaluate(parameter_blocks.get(), residuals, NULL);
return cost_functor_(parameter_blocks.get(), residuals);
}
bool operator()(const double* x0,
@@ -248,7 +248,7 @@ class CostFunctionToFunctor {
parameter_blocks[2] = x2;
parameter_blocks[3] = x3;
parameter_blocks[4] = x4;
return cost_function_->Evaluate(parameter_blocks.get(), residuals, NULL);
return cost_functor_(parameter_blocks.get(), residuals);
}
bool operator()(const double* x0,
@@ -275,7 +275,7 @@ class CostFunctionToFunctor {
parameter_blocks[3] = x3;
parameter_blocks[4] = x4;
parameter_blocks[5] = x5;
return cost_function_->Evaluate(parameter_blocks.get(), residuals, NULL);
return cost_functor_(parameter_blocks.get(), residuals);
}
bool operator()(const double* x0,
@@ -304,7 +304,7 @@ class CostFunctionToFunctor {
parameter_blocks[4] = x4;
parameter_blocks[5] = x5;
parameter_blocks[6] = x6;
return cost_function_->Evaluate(parameter_blocks.get(), residuals, NULL);
return cost_functor_(parameter_blocks.get(), residuals);
}
bool operator()(const double* x0,
@@ -335,7 +335,7 @@ class CostFunctionToFunctor {
parameter_blocks[5] = x5;
parameter_blocks[6] = x6;
parameter_blocks[7] = x7;
return cost_function_->Evaluate(parameter_blocks.get(), residuals, NULL);
return cost_functor_(parameter_blocks.get(), residuals);
}
bool operator()(const double* x0,
@@ -368,7 +368,7 @@ class CostFunctionToFunctor {
parameter_blocks[6] = x6;
parameter_blocks[7] = x7;
parameter_blocks[8] = x8;
return cost_function_->Evaluate(parameter_blocks.get(), residuals, NULL);
return cost_functor_(parameter_blocks.get(), residuals);
}
bool operator()(const double* x0,
@@ -403,7 +403,7 @@ class CostFunctionToFunctor {
parameter_blocks[7] = x7;
parameter_blocks[8] = x8;
parameter_blocks[9] = x9;
return cost_function_->Evaluate(parameter_blocks.get(), residuals, NULL);
return cost_functor_(parameter_blocks.get(), residuals);
}
template <typename JetT>
@@ -418,7 +418,7 @@ class CostFunctionToFunctor {
CHECK_EQ(N7, 0);
CHECK_EQ(N8, 0);
CHECK_EQ(N9, 0);
return EvaluateWithJets(&x0, residuals);
return cost_functor_(&x0, residuals);
}
template <typename JetT>
@@ -438,7 +438,7 @@ class CostFunctionToFunctor {
internal::FixedArray<const JetT*> jets(2);
jets[0] = x0;
jets[1] = x1;
return EvaluateWithJets(jets.get(), residuals);
return cost_functor_(jets.get(), residuals);
}
template <typename JetT>
@@ -460,7 +460,7 @@ class CostFunctionToFunctor {
jets[0] = x0;
jets[1] = x1;
jets[2] = x2;
return EvaluateWithJets(jets.get(), residuals);
return cost_functor_(jets.get(), residuals);
}
template <typename JetT>
@@ -484,7 +484,7 @@ class CostFunctionToFunctor {
jets[1] = x1;
jets[2] = x2;
jets[3] = x3;
return EvaluateWithJets(jets.get(), residuals);
return cost_functor_(jets.get(), residuals);
}
template <typename JetT>
@@ -510,7 +510,7 @@ class CostFunctionToFunctor {
jets[2] = x2;
jets[3] = x3;
jets[4] = x4;
return EvaluateWithJets(jets.get(), residuals);
return cost_functor_(jets.get(), residuals);
}
template <typename JetT>
@@ -538,7 +538,7 @@ class CostFunctionToFunctor {
jets[3] = x3;
jets[4] = x4;
jets[5] = x5;
return EvaluateWithJets(jets.get(), residuals);
return cost_functor_(jets.get(), residuals);
}
template <typename JetT>
@@ -568,7 +568,7 @@ class CostFunctionToFunctor {
jets[4] = x4;
jets[5] = x5;
jets[6] = x6;
return EvaluateWithJets(jets.get(), residuals);
return cost_functor_(jets.get(), residuals);
}
template <typename JetT>
@@ -600,7 +600,7 @@ class CostFunctionToFunctor {
jets[5] = x5;
jets[6] = x6;
jets[7] = x7;
return EvaluateWithJets(jets.get(), residuals);
return cost_functor_(jets.get(), residuals);
}
template <typename JetT>
@@ -634,7 +634,7 @@ class CostFunctionToFunctor {
jets[6] = x6;
jets[7] = x7;
jets[8] = x8;
return EvaluateWithJets(jets.get(), residuals);
return cost_functor_(jets.get(), residuals);
}
template <typename JetT>
@@ -670,79 +670,11 @@ class CostFunctionToFunctor {
jets[7] = x7;
jets[8] = x8;
jets[9] = x9;
return EvaluateWithJets(jets.get(), residuals);
return cost_functor_(jets.get(), residuals);
}
private:
template <typename JetT>
bool EvaluateWithJets(const JetT** inputs, JetT* output) const {
const int kNumParameters = N0 + N1 + N2 + N3 + N4 + N5 + N6 + N7 + N8 + N9;
const vector<int32>& parameter_block_sizes =
cost_function_->parameter_block_sizes();
const int num_parameter_blocks = parameter_block_sizes.size();
const int num_residuals = cost_function_->num_residuals();
internal::FixedArray<double> parameters(kNumParameters);
internal::FixedArray<double*> parameter_blocks(num_parameter_blocks);
internal::FixedArray<double> jacobians(num_residuals * kNumParameters);
internal::FixedArray<double*> jacobian_blocks(num_parameter_blocks);
internal::FixedArray<double> residuals(num_residuals);
// Build a set of arrays to get the residuals and jacobians from
// the CostFunction wrapped by this functor.
double* parameter_ptr = parameters.get();
double* jacobian_ptr = jacobians.get();
for (int i = 0; i < num_parameter_blocks; ++i) {
parameter_blocks[i] = parameter_ptr;
jacobian_blocks[i] = jacobian_ptr;
for (int j = 0; j < parameter_block_sizes[i]; ++j) {
*parameter_ptr++ = inputs[i][j].a;
}
jacobian_ptr += num_residuals * parameter_block_sizes[i];
}
if (!cost_function_->Evaluate(parameter_blocks.get(),
residuals.get(),
jacobian_blocks.get())) {
return false;
}
// Now that we have the incoming Jets, which are carrying the
// partial derivatives of each of the inputs w.r.t to some other
// underlying parameters. The derivative of the outputs of the
// cost function w.r.t to the same underlying parameters can now
// be computed by applying the chain rule.
//
// d output[i] d output[i] d input[j]
// -------------- = sum_j ----------- * ------------
// d parameter[k] d input[j] d parameter[k]
//
// d input[j]
// -------------- = inputs[j], so
// d parameter[k]
//
// outputJet[i] = sum_k jacobian[i][k] * inputJet[k]
//
// The following loop, iterates over the residuals, computing one
// output jet at a time.
for (int i = 0; i < num_residuals; ++i) {
output[i].a = residuals[i];
output[i].v.setZero();
for (int j = 0; j < num_parameter_blocks; ++j) {
const int32 block_size = parameter_block_sizes[j];
for (int k = 0; k < parameter_block_sizes[j]; ++k) {
output[i].v +=
jacobian_blocks[j][i * block_size + k] * inputs[j][k].v;
}
}
}
return true;
}
private:
internal::scoped_ptr<CostFunction> cost_function_;
DynamicCostFunctionToFunctor cost_functor_;
};
} // namespace ceres

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2013 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -183,7 +183,7 @@ class CovarianceImpl;
// Covariance::Options options;
// Covariance covariance(options);
//
// vector<pair<const double*, const double*> > covariance_blocks;
// std::vector<std::pair<const double*, const double*> > covariance_blocks;
// covariance_blocks.push_back(make_pair(x, x));
// covariance_blocks.push_back(make_pair(y, y));
// covariance_blocks.push_back(make_pair(x, y));
@@ -353,10 +353,11 @@ class CERES_EXPORT Covariance {
// Covariance::Options for more on the conditions under which this
// function returns false.
bool Compute(
const vector<pair<const double*, const double*> >& covariance_blocks,
const std::vector<std::pair<const double*,
const double*> >& covariance_blocks,
Problem* problem);
// Return the block of the covariance matrix corresponding to
// Return the block of the cross-covariance matrix corresponding to
// parameter_block1 and parameter_block2.
//
// Compute must be called before the first call to
@@ -373,6 +374,26 @@ class CERES_EXPORT Covariance {
const double* parameter_block2,
double* covariance_block) const;
// Return the block of the cross-covariance matrix corresponding to
// parameter_block1 and parameter_block2.
// Returns cross-covariance in the tangent space if a local
// parameterization is associated with either parameter block;
// else returns cross-covariance in the ambient space.
//
// Compute must be called before the first call to
// GetCovarianceBlock and the pair <parameter_block1,
// parameter_block2> OR the pair <parameter_block2,
// parameter_block1> must have been present in the vector
// covariance_blocks when Compute was called. Otherwise
// GetCovarianceBlock will return false.
//
// covariance_block must point to a memory location that can store a
// parameter_block1_local_size x parameter_block2_local_size matrix. The
// returned covariance will be a row-major matrix.
bool GetCovarianceBlockInTangentSpace(const double* parameter_block1,
const double* parameter_block2,
double* covariance_block) const;
private:
internal::scoped_ptr<internal::CovarianceImpl> impl_;
};

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -74,9 +74,9 @@ struct CERES_EXPORT CRSMatrix {
// cols = [ 1, 3, 1, 2, 3, 0, 1]
// values = [10, 4, 2, -3, 2, 1, 2]
vector<int> cols;
vector<int> rows;
vector<double> values;
std::vector<int> cols;
std::vector<int> rows;
std::vector<double> values;
};
} // namespace ceres

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2013 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -120,18 +120,18 @@ class DynamicAutoDiffCostFunction : public CostFunction {
0);
// Allocate scratch space for the strided evaluation.
vector<Jet<double, Stride> > input_jets(num_parameters);
vector<Jet<double, Stride> > output_jets(num_residuals());
std::vector<Jet<double, Stride> > input_jets(num_parameters);
std::vector<Jet<double, Stride> > output_jets(num_residuals());
// Make the parameter pack that is sent to the functor (reused).
vector<Jet<double, Stride>* > jet_parameters(num_parameter_blocks,
std::vector<Jet<double, Stride>* > jet_parameters(num_parameter_blocks,
static_cast<Jet<double, Stride>* >(NULL));
int num_active_parameters = 0;
// To handle constant parameters between non-constant parameter blocks, the
// start position --- a raw parameter index --- of each contiguous block of
// non-constant parameters is recorded in start_derivative_section.
vector<int> start_derivative_section;
std::vector<int> start_derivative_section;
bool in_derivative_section = false;
int parameter_cursor = 0;

View File

@@ -0,0 +1,190 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// 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.
// * Neither the name of Google Inc. nor the names of its contributors may be
// used to endorse or promote products derived from this software without
// specific prior written permission.
//
// 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 OWNER 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.
//
// Author: sameeragarwal@google.com (Sameer Agarwal)
// dgossow@google.com (David Gossow)
//
// DynamicCostFunctionToFunctor allows users to use CostFunction
// objects in templated functors which are to be used for automatic
// differentiation. It works similar to CostFunctionToFunctor, with the
// difference that it allows you to wrap a cost function with dynamic numbers
// of parameters and residuals.
//
// For example, let us assume that
//
// class IntrinsicProjection : public CostFunction {
// public:
// IntrinsicProjection(const double* observation);
// virtual bool Evaluate(double const* const* parameters,
// double* residuals,
// double** jacobians) const;
// };
//
// is a cost function that implements the projection of a point in its
// local coordinate system onto its image plane and subtracts it from
// the observed point projection. It can compute its residual and
// either via analytic or numerical differentiation can compute its
// jacobians. The intrinsics are passed in as parameters[0] and the point as
// parameters[1].
//
// Now we would like to compose the action of this CostFunction with
// the action of camera extrinsics, i.e., rotation and
// translation. Say we have a templated function
//
// template<typename T>
// void RotateAndTranslatePoint(double const* const* parameters,
// double* residuals);
//
// Then we can now do the following,
//
// struct CameraProjection {
// CameraProjection(const double* observation)
// : intrinsic_projection_.(new IntrinsicProjection(observation)) {
// }
// template <typename T>
// bool operator()(T const* const* parameters,
// T* residual) const {
// const T* rotation = parameters[0];
// const T* translation = parameters[1];
// const T* intrinsics = parameters[2];
// const T* point = parameters[3];
// T transformed_point[3];
// RotateAndTranslatePoint(rotation, translation, point, transformed_point);
//
// // Note that we call intrinsic_projection_, just like it was
// // any other templated functor.
// const T* projection_parameters[2];
// projection_parameters[0] = intrinsics;
// projection_parameters[1] = transformed_point;
// return intrinsic_projection_(projection_parameters, residual);
// }
//
// private:
// DynamicCostFunctionToFunctor intrinsic_projection_;
// };
#ifndef CERES_PUBLIC_DYNAMIC_COST_FUNCTION_TO_FUNCTOR_H_
#define CERES_PUBLIC_DYNAMIC_COST_FUNCTION_TO_FUNCTOR_H_
#include <numeric>
#include <vector>
#include "ceres/cost_function.h"
#include "ceres/internal/fixed_array.h"
#include "ceres/internal/port.h"
#include "ceres/internal/scoped_ptr.h"
namespace ceres {
class DynamicCostFunctionToFunctor {
public:
// Takes ownership of cost_function.
explicit DynamicCostFunctionToFunctor(CostFunction* cost_function)
: cost_function_(cost_function) {
CHECK_NOTNULL(cost_function);
}
bool operator()(double const* const* parameters, double* residuals) const {
return cost_function_->Evaluate(parameters, residuals, NULL);
}
template <typename JetT>
bool operator()(JetT const* const* inputs, JetT* output) const {
const std::vector<int32>& parameter_block_sizes =
cost_function_->parameter_block_sizes();
const int num_parameter_blocks = parameter_block_sizes.size();
const int num_residuals = cost_function_->num_residuals();
const int num_parameters = std::accumulate(parameter_block_sizes.begin(),
parameter_block_sizes.end(), 0);
internal::FixedArray<double> parameters(num_parameters);
internal::FixedArray<double*> parameter_blocks(num_parameter_blocks);
internal::FixedArray<double> jacobians(num_residuals * num_parameters);
internal::FixedArray<double*> jacobian_blocks(num_parameter_blocks);
internal::FixedArray<double> residuals(num_residuals);
// Build a set of arrays to get the residuals and jacobians from
// the CostFunction wrapped by this functor.
double* parameter_ptr = parameters.get();
double* jacobian_ptr = jacobians.get();
for (int i = 0; i < num_parameter_blocks; ++i) {
parameter_blocks[i] = parameter_ptr;
jacobian_blocks[i] = jacobian_ptr;
for (int j = 0; j < parameter_block_sizes[i]; ++j) {
*parameter_ptr++ = inputs[i][j].a;
}
jacobian_ptr += num_residuals * parameter_block_sizes[i];
}
if (!cost_function_->Evaluate(parameter_blocks.get(),
residuals.get(),
jacobian_blocks.get())) {
return false;
}
// Now that we have the incoming Jets, which are carrying the
// partial derivatives of each of the inputs w.r.t to some other
// underlying parameters. The derivative of the outputs of the
// cost function w.r.t to the same underlying parameters can now
// be computed by applying the chain rule.
//
// d output[i] d output[i] d input[j]
// -------------- = sum_j ----------- * ------------
// d parameter[k] d input[j] d parameter[k]
//
// d input[j]
// -------------- = inputs[j], so
// d parameter[k]
//
// outputJet[i] = sum_k jacobian[i][k] * inputJet[k]
//
// The following loop, iterates over the residuals, computing one
// output jet at a time.
for (int i = 0; i < num_residuals; ++i) {
output[i].a = residuals[i];
output[i].v.setZero();
for (int j = 0; j < num_parameter_blocks; ++j) {
const int32 block_size = parameter_block_sizes[j];
for (int k = 0; k < parameter_block_sizes[j]; ++k) {
output[i].v +=
jacobian_blocks[j][i * block_size + k] * inputs[j][k].v;
}
}
}
return true;
}
private:
internal::scoped_ptr<CostFunction> cost_function_;
};
} // namespace ceres
#endif // CERES_PUBLIC_DYNAMIC_COST_FUNCTION_TO_FUNCTOR_H_

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -29,6 +29,7 @@
// Author: mierle@gmail.com (Keir Mierle)
// sameeragarwal@google.com (Sameer Agarwal)
// thadh@gmail.com (Thad Hughes)
// tbennun@gmail.com (Tal Ben-Nun)
//
// This numeric diff implementation differs from the one found in
// numeric_diff_cost_function.h by supporting numericdiff on cost
@@ -41,7 +42,6 @@
// numeric diff; the expected interface for the cost functors is:
//
// struct MyCostFunctor {
// template<typename T>
// bool operator()(double const* const* parameters, double* residuals) const {
// // Use parameters[i] to access the i'th parameter block.
// }
@@ -68,19 +68,37 @@
#include "ceres/internal/scoped_ptr.h"
#include "ceres/internal/eigen.h"
#include "ceres/internal/numeric_diff.h"
#include "ceres/numeric_diff_options.h"
#include "glog/logging.h"
namespace ceres {
template <typename CostFunctor, NumericDiffMethod method = CENTRAL>
template <typename CostFunctor, NumericDiffMethodType method = CENTRAL>
class DynamicNumericDiffCostFunction : public CostFunction {
public:
explicit DynamicNumericDiffCostFunction(const CostFunctor* functor,
Ownership ownership = TAKE_OWNERSHIP,
double relative_step_size = 1e-6)
explicit DynamicNumericDiffCostFunction(
const CostFunctor* functor,
Ownership ownership = TAKE_OWNERSHIP,
const NumericDiffOptions& options = NumericDiffOptions())
: functor_(functor),
ownership_(ownership),
relative_step_size_(relative_step_size) {
options_(options) {
}
// Deprecated. New users should avoid using this constructor. Instead, use the
// constructor with NumericDiffOptions.
DynamicNumericDiffCostFunction(
const CostFunctor* functor,
Ownership ownership,
double relative_step_size)
: functor_(functor),
ownership_(ownership),
options_() {
LOG(WARNING) << "This constructor is deprecated and will be removed in "
"a future version. Please use the NumericDiffOptions "
"constructor instead.";
options_.relative_step_size = relative_step_size;
}
virtual ~DynamicNumericDiffCostFunction() {
@@ -100,11 +118,12 @@ class DynamicNumericDiffCostFunction : public CostFunction {
virtual bool Evaluate(double const* const* parameters,
double* residuals,
double** jacobians) const {
using internal::NumericDiff;
CHECK_GT(num_residuals(), 0)
<< "You must call DynamicNumericDiffCostFunction::SetNumResiduals() "
<< "before DynamicNumericDiffCostFunction::Evaluate().";
const vector<int32>& block_sizes = parameter_block_sizes();
const std::vector<int32>& block_sizes = parameter_block_sizes();
CHECK(!block_sizes.empty())
<< "You must call DynamicNumericDiffCostFunction::AddParameterBlock() "
<< "before DynamicNumericDiffCostFunction::Evaluate().";
@@ -116,8 +135,8 @@ class DynamicNumericDiffCostFunction : public CostFunction {
// Create local space for a copy of the parameters which will get mutated.
int parameters_size = accumulate(block_sizes.begin(), block_sizes.end(), 0);
vector<double> parameters_copy(parameters_size);
vector<double*> parameters_references_copy(block_sizes.size());
std::vector<double> parameters_copy(parameters_size);
std::vector<double*> parameters_references_copy(block_sizes.size());
parameters_references_copy[0] = &parameters_copy[0];
for (int block = 1; block < block_sizes.size(); ++block) {
parameters_references_copy[block] = parameters_references_copy[block - 1]
@@ -133,12 +152,18 @@ class DynamicNumericDiffCostFunction : public CostFunction {
for (int block = 0; block < block_sizes.size(); ++block) {
if (jacobians[block] != NULL &&
!EvaluateJacobianForParameterBlock(block_sizes[block],
block,
relative_step_size_,
!NumericDiff<CostFunctor, method, DYNAMIC,
DYNAMIC, DYNAMIC, DYNAMIC, DYNAMIC, DYNAMIC,
DYNAMIC, DYNAMIC, DYNAMIC, DYNAMIC, DYNAMIC,
DYNAMIC, DYNAMIC>::EvaluateJacobianForParameterBlock(
functor_.get(),
residuals,
options_,
this->num_residuals(),
block,
block_sizes[block],
&parameters_references_copy[0],
jacobians)) {
jacobians[block])) {
return false;
}
}
@@ -146,91 +171,6 @@ class DynamicNumericDiffCostFunction : public CostFunction {
}
private:
bool EvaluateJacobianForParameterBlock(const int parameter_block_size,
const int parameter_block,
const double relative_step_size,
double const* residuals_at_eval_point,
double** parameters,
double** jacobians) const {
using Eigen::Map;
using Eigen::Matrix;
using Eigen::Dynamic;
using Eigen::RowMajor;
typedef Matrix<double, Dynamic, 1> ResidualVector;
typedef Matrix<double, Dynamic, 1> ParameterVector;
typedef Matrix<double, Dynamic, Dynamic, RowMajor> JacobianMatrix;
int num_residuals = this->num_residuals();
Map<JacobianMatrix> parameter_jacobian(jacobians[parameter_block],
num_residuals,
parameter_block_size);
// Mutate one element at a time and then restore.
Map<ParameterVector> x_plus_delta(parameters[parameter_block],
parameter_block_size);
ParameterVector x(x_plus_delta);
ParameterVector step_size = x.array().abs() * relative_step_size;
// To handle cases where a paremeter is exactly zero, instead use
// the mean step_size for the other dimensions.
double fallback_step_size = step_size.sum() / step_size.rows();
if (fallback_step_size == 0.0) {
// If all the parameters are zero, there's no good answer. Use the given
// relative step_size as absolute step_size and hope for the best.
fallback_step_size = relative_step_size;
}
// For each parameter in the parameter block, use finite
// differences to compute the derivative for that parameter.
for (int j = 0; j < parameter_block_size; ++j) {
if (step_size(j) == 0.0) {
// The parameter is exactly zero, so compromise and use the
// mean step_size from the other parameters. This can break in
// many cases, but it's hard to pick a good number without
// problem specific knowledge.
step_size(j) = fallback_step_size;
}
x_plus_delta(j) = x(j) + step_size(j);
ResidualVector residuals(num_residuals);
if (!EvaluateCostFunctor(parameters, &residuals[0])) {
// Something went wrong; bail.
return false;
}
// Compute this column of the jacobian in 3 steps:
// 1. Store residuals for the forward part.
// 2. Subtract residuals for the backward (or 0) part.
// 3. Divide out the run.
parameter_jacobian.col(j).matrix() = residuals;
double one_over_h = 1 / step_size(j);
if (method == CENTRAL) {
// Compute the function on the other side of x(j).
x_plus_delta(j) = x(j) - step_size(j);
if (!EvaluateCostFunctor(parameters, &residuals[0])) {
// Something went wrong; bail.
return false;
}
parameter_jacobian.col(j) -= residuals;
one_over_h /= 2;
} else {
// Forward difference only; reuse existing residuals evaluation.
parameter_jacobian.col(j) -=
Map<const ResidualVector>(residuals_at_eval_point, num_residuals);
}
x_plus_delta(j) = x(j); // Restore x_plus_delta.
// Divide out the run to get slope.
parameter_jacobian.col(j) *= one_over_h;
}
return true;
}
bool EvaluateCostFunctor(double const* const* parameters,
double* residuals) const {
return EvaluateCostFunctorImpl(functor_.get(),
@@ -257,7 +197,7 @@ class DynamicNumericDiffCostFunction : public CostFunction {
internal::scoped_ptr<const CostFunctor> functor_;
Ownership ownership_;
const double relative_step_size_;
NumericDiffOptions options_;
};
} // namespace ceres

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -50,26 +50,9 @@ namespace ceres {
inline bool IsFinite (double x) { return _finite(x) != 0; }
inline bool IsInfinite(double x) { return _finite(x) == 0 && _isnan(x) == 0; }
inline bool IsNaN (double x) { return _isnan(x) != 0; }
inline bool IsNormal (double x) {
int classification = _fpclass(x);
return classification == _FPCLASS_NN ||
classification == _FPCLASS_PN;
}
#elif defined(ANDROID) && defined(_STLPORT_VERSION)
// On Android, when using the STLPort, the C++ isnan and isnormal functions
// are defined as macros.
inline bool IsNaN (double x) { return isnan(x); }
inline bool IsNormal (double x) { return isnormal(x); }
// On Android NDK r6, when using STLPort, the isinf and isfinite functions are
// not available, so reimplement them.
inline bool IsInfinite(double x) {
return x == std::numeric_limits<double>::infinity() ||
x == -std::numeric_limits<double>::infinity();
}
inline bool IsFinite(double x) {
return !isnan(x) && !IsInfinite(x);
inline bool IsNormal (double x) { // NOLINT
const int classification = _fpclass(x);
return (classification == _FPCLASS_NN || classification == _FPCLASS_PN);
}
# else

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -78,10 +78,10 @@ class GradientChecker {
// block.
// Derivatives as computed by the cost function.
vector<Matrix> term_jacobians;
std::vector<Matrix> term_jacobians;
// Derivatives as computed by finite differencing.
vector<Matrix> finite_difference_jacobians;
std::vector<Matrix> finite_difference_jacobians;
// Infinity-norm of term_jacobians - finite_difference_jacobians.
double error_jacobians;
@@ -119,7 +119,7 @@ class GradientChecker {
// Do a consistency check between the term and the template parameters.
CHECK_EQ(M, term->num_residuals());
const int num_residuals = M;
const vector<int32>& block_sizes = term->parameter_block_sizes();
const std::vector<int32>& block_sizes = term->parameter_block_sizes();
const int num_blocks = block_sizes.size();
CHECK_LE(num_blocks, 5) << "Unable to test functions that take more "

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2014 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2014 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -81,7 +81,7 @@ class CERES_EXPORT GradientProblemSolver {
// Returns true if the options struct has a valid
// configuration. Returns false otherwise, and fills in *error
// with a message describing the problem.
bool IsValid(string* error) const;
bool IsValid(std::string* error) const;
// Minimizer options ----------------------------------------
LineSearchDirectionType line_search_direction_type;
@@ -261,7 +261,7 @@ class CERES_EXPORT GradientProblemSolver {
// executed, then set update_state_every_iteration to true.
//
// The solver does NOT take ownership of these pointers.
vector<IterationCallback*> callbacks;
std::vector<IterationCallback*> callbacks;
};
struct CERES_EXPORT Summary {
@@ -269,11 +269,11 @@ class CERES_EXPORT GradientProblemSolver {
// A brief one line description of the state of the solver after
// termination.
string BriefReport() const;
std::string BriefReport() const;
// A full multiline description of the state of the solver after
// termination.
string FullReport() const;
std::string FullReport() const;
bool IsSolutionUsable() const;
@@ -281,7 +281,7 @@ class CERES_EXPORT GradientProblemSolver {
TerminationType termination_type;
// Reason why the solver terminated.
string message;
std::string message;
// Cost of the problem (value of the objective function) before
// the optimization.
@@ -292,7 +292,7 @@ class CERES_EXPORT GradientProblemSolver {
double final_cost;
// IterationSummary for each minimizer iteration in order.
vector<IterationSummary> iterations;
std::vector<IterationSummary> iterations;
// Sum total of all time spent inside Ceres when Solve is called.
double total_time_in_seconds;
@@ -303,6 +303,10 @@ class CERES_EXPORT GradientProblemSolver {
// Time (in seconds) spent evaluating the gradient.
double gradient_evaluation_time_in_seconds;
// Time (in seconds) spent minimizing the interpolating polynomial
// to compute the next candidate step size as part of a line search.
double line_search_polynomial_minimization_time_in_seconds;
// Number of parameters in the probem.
int num_parameters;

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -214,15 +214,15 @@ struct AutoDiff {
// This block breaks the 80 column rule to keep it somewhat readable.
DCHECK_GT(num_outputs, 0);
DCHECK((!N1 && !N2 && !N3 && !N4 && !N5 && !N6 && !N7 && !N8 && !N9) ||
((N1 > 0) && !N2 && !N3 && !N4 && !N5 && !N6 && !N7 && !N8 && !N9) ||
((N1 > 0) && (N2 > 0) && !N3 && !N4 && !N5 && !N6 && !N7 && !N8 && !N9) ||
((N1 > 0) && (N2 > 0) && (N3 > 0) && !N4 && !N5 && !N6 && !N7 && !N8 && !N9) ||
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && !N5 && !N6 && !N7 && !N8 && !N9) ||
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && (N5 > 0) && !N6 && !N7 && !N8 && !N9) ||
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && (N5 > 0) && (N6 > 0) && !N7 && !N8 && !N9) ||
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && (N5 > 0) && (N6 > 0) && (N7 > 0) && !N8 && !N9) ||
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && (N5 > 0) && (N6 > 0) && (N7 > 0) && (N8 > 0) && !N9) ||
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && (N5 > 0) && (N6 > 0) && (N7 > 0) && (N8 > 0) && (N9 > 0)))
((N1 > 0) && !N2 && !N3 && !N4 && !N5 && !N6 && !N7 && !N8 && !N9) ||
((N1 > 0) && (N2 > 0) && !N3 && !N4 && !N5 && !N6 && !N7 && !N8 && !N9) || // NOLINT
((N1 > 0) && (N2 > 0) && (N3 > 0) && !N4 && !N5 && !N6 && !N7 && !N8 && !N9) || // NOLINT
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && !N5 && !N6 && !N7 && !N8 && !N9) || // NOLINT
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && (N5 > 0) && !N6 && !N7 && !N8 && !N9) || // NOLINT
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && (N5 > 0) && (N6 > 0) && !N7 && !N8 && !N9) || // NOLINT
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && (N5 > 0) && (N6 > 0) && (N7 > 0) && !N8 && !N9) || // NOLINT
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && (N5 > 0) && (N6 > 0) && (N7 > 0) && (N8 > 0) && !N9) || // NOLINT
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && (N5 > 0) && (N6 > 0) && (N7 > 0) && (N8 > 0) && (N9 > 0))) // NOLINT
<< "Zero block cannot precede a non-zero block. Block sizes are "
<< "(ignore trailing 0s): " << N0 << ", " << N1 << ", " << N2 << ", "
<< N3 << ", " << N4 << ", " << N5 << ", " << N6 << ", " << N7 << ", "

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2014 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2013 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -28,8 +28,9 @@
//
// Author: sameeragarwal@google.com (Sameer Agarwal)
// mierle@gmail.com (Keir Mierle)
// tbennun@gmail.com (Tal Ben-Nun)
//
// Finite differencing routine used by NumericDiffCostFunction.
// Finite differencing routines used by NumericDiffCostFunction.
#ifndef CERES_PUBLIC_INTERNAL_NUMERIC_DIFF_H_
#define CERES_PUBLIC_INTERNAL_NUMERIC_DIFF_H_
@@ -37,9 +38,12 @@
#include <cstring>
#include "Eigen/Dense"
#include "Eigen/StdVector"
#include "ceres/cost_function.h"
#include "ceres/internal/fixed_array.h"
#include "ceres/internal/scoped_ptr.h"
#include "ceres/internal/variadic_evaluate.h"
#include "ceres/numeric_diff_options.h"
#include "ceres/types.h"
#include "glog/logging.h"
@@ -78,7 +82,7 @@ bool EvaluateImpl(const CostFunctor* functor,
// specializations for member functions. The alternative is to repeat the main
// class for differing numbers of parameters, which is also unfortunate.
template <typename CostFunctor,
NumericDiffMethod kMethod,
NumericDiffMethodType kMethod,
int kNumResiduals,
int N0, int N1, int N2, int N3, int N4,
int N5, int N6, int N7, int N8, int N9,
@@ -88,9 +92,11 @@ struct NumericDiff {
// Mutates parameters but must restore them before return.
static bool EvaluateJacobianForParameterBlock(
const CostFunctor* functor,
double const* residuals_at_eval_point,
const double relative_step_size,
const double* residuals_at_eval_point,
const NumericDiffOptions& options,
int num_residuals,
int parameter_block_index,
int parameter_block_size,
double **parameters,
double *jacobian) {
using Eigen::Map;
@@ -98,8 +104,14 @@ struct NumericDiff {
using Eigen::RowMajor;
using Eigen::ColMajor;
const int NUM_RESIDUALS =
const int num_residuals_internal =
(kNumResiduals != ceres::DYNAMIC ? kNumResiduals : num_residuals);
const int parameter_block_index_internal =
(kParameterBlock != ceres::DYNAMIC ? kParameterBlock :
parameter_block_index);
const int parameter_block_size_internal =
(kParameterBlockSize != ceres::DYNAMIC ? kParameterBlockSize :
parameter_block_size);
typedef Matrix<double, kNumResiduals, 1> ResidualVector;
typedef Matrix<double, kParameterBlockSize, 1> ParameterVector;
@@ -115,73 +127,288 @@ struct NumericDiff {
JacobianMatrix;
Map<JacobianMatrix> parameter_jacobian(jacobian,
NUM_RESIDUALS,
kParameterBlockSize);
num_residuals_internal,
parameter_block_size_internal);
// Mutate 1 element at a time and then restore.
Map<ParameterVector> x_plus_delta(parameters[kParameterBlock],
kParameterBlockSize);
Map<ParameterVector> x_plus_delta(
parameters[parameter_block_index_internal],
parameter_block_size_internal);
ParameterVector x(x_plus_delta);
ParameterVector step_size = x.array().abs() * relative_step_size;
ParameterVector step_size = x.array().abs() *
((kMethod == RIDDERS) ? options.ridders_relative_initial_step_size :
options.relative_step_size);
// To handle cases where a parameter is exactly zero, instead use
// the mean step_size for the other dimensions. If all the
// parameters are zero, there's no good answer. Take
// relative_step_size as a guess and hope for the best.
const double fallback_step_size =
(step_size.sum() == 0)
? relative_step_size
: step_size.sum() / step_size.rows();
// It is not a good idea to make the step size arbitrarily
// small. This will lead to problems with round off and numerical
// instability when dividing by the step size. The general
// recommendation is to not go down below sqrt(epsilon).
double min_step_size = std::sqrt(std::numeric_limits<double>::epsilon());
// For Ridders' method, the initial step size is required to be large,
// thus ridders_relative_initial_step_size is used.
if (kMethod == RIDDERS) {
min_step_size = std::max(min_step_size,
options.ridders_relative_initial_step_size);
}
// For each parameter in the parameter block, use finite differences to
// compute the derivative for that parameter.
FixedArray<double> temp_residual_array(num_residuals_internal);
FixedArray<double> residual_array(num_residuals_internal);
Map<ResidualVector> residuals(residual_array.get(),
num_residuals_internal);
ResidualVector residuals(NUM_RESIDUALS);
for (int j = 0; j < kParameterBlockSize; ++j) {
const double delta =
(step_size(j) == 0.0) ? fallback_step_size : step_size(j);
for (int j = 0; j < parameter_block_size_internal; ++j) {
const double delta = std::max(min_step_size, step_size(j));
x_plus_delta(j) = x(j) + delta;
if (kMethod == RIDDERS) {
if (!EvaluateRiddersJacobianColumn(functor, j, delta,
options,
num_residuals_internal,
parameter_block_size_internal,
x.data(),
residuals_at_eval_point,
parameters,
x_plus_delta.data(),
temp_residual_array.get(),
residual_array.get())) {
return false;
}
} else {
if (!EvaluateJacobianColumn(functor, j, delta,
num_residuals_internal,
parameter_block_size_internal,
x.data(),
residuals_at_eval_point,
parameters,
x_plus_delta.data(),
temp_residual_array.get(),
residual_array.get())) {
return false;
}
}
parameter_jacobian.col(j).matrix() = residuals;
}
return true;
}
static bool EvaluateJacobianColumn(const CostFunctor* functor,
int parameter_index,
double delta,
int num_residuals,
int parameter_block_size,
const double* x_ptr,
const double* residuals_at_eval_point,
double** parameters,
double* x_plus_delta_ptr,
double* temp_residuals_ptr,
double* residuals_ptr) {
using Eigen::Map;
using Eigen::Matrix;
typedef Matrix<double, kNumResiduals, 1> ResidualVector;
typedef Matrix<double, kParameterBlockSize, 1> ParameterVector;
Map<const ParameterVector> x(x_ptr, parameter_block_size);
Map<ParameterVector> x_plus_delta(x_plus_delta_ptr,
parameter_block_size);
Map<ResidualVector> residuals(residuals_ptr, num_residuals);
Map<ResidualVector> temp_residuals(temp_residuals_ptr, num_residuals);
// Mutate 1 element at a time and then restore.
x_plus_delta(parameter_index) = x(parameter_index) + delta;
if (!EvaluateImpl<CostFunctor, N0, N1, N2, N3, N4, N5, N6, N7, N8, N9>(
functor, parameters, residuals.data(), functor)) {
return false;
}
// Compute this column of the jacobian in 3 steps:
// 1. Store residuals for the forward part.
// 2. Subtract residuals for the backward (or 0) part.
// 3. Divide out the run.
double one_over_delta = 1.0 / delta;
if (kMethod == CENTRAL || kMethod == RIDDERS) {
// Compute the function on the other side of x(parameter_index).
x_plus_delta(parameter_index) = x(parameter_index) - delta;
if (!EvaluateImpl<CostFunctor, N0, N1, N2, N3, N4, N5, N6, N7, N8, N9>(
functor, parameters, residuals.data(), functor)) {
functor, parameters, temp_residuals.data(), functor)) {
return false;
}
// Compute this column of the jacobian in 3 steps:
// 1. Store residuals for the forward part.
// 2. Subtract residuals for the backward (or 0) part.
// 3. Divide out the run.
parameter_jacobian.col(j) = residuals;
residuals -= temp_residuals;
one_over_delta /= 2;
} else {
// Forward difference only; reuse existing residuals evaluation.
residuals -=
Map<const ResidualVector>(residuals_at_eval_point,
num_residuals);
}
double one_over_delta = 1.0 / delta;
if (kMethod == CENTRAL) {
// Compute the function on the other side of x(j).
x_plus_delta(j) = x(j) - delta;
// Restore x_plus_delta.
x_plus_delta(parameter_index) = x(parameter_index);
if (!EvaluateImpl<CostFunctor, N0, N1, N2, N3, N4, N5, N6, N7, N8, N9>(
functor, parameters, residuals.data(), functor)) {
return false;
}
// Divide out the run to get slope.
residuals *= one_over_delta;
parameter_jacobian.col(j) -= residuals;
one_over_delta /= 2;
} else {
// Forward difference only; reuse existing residuals evaluation.
parameter_jacobian.col(j) -=
Map<const ResidualVector>(residuals_at_eval_point, NUM_RESIDUALS);
return true;
}
// This numeric difference implementation uses adaptive differentiation
// on the parameters to obtain the Jacobian matrix. The adaptive algorithm
// is based on Ridders' method for adaptive differentiation, which creates
// a Romberg tableau from varying step sizes and extrapolates the
// intermediate results to obtain the current computational error.
//
// References:
// C.J.F. Ridders, Accurate computation of F'(x) and F'(x) F"(x), Advances
// in Engineering Software (1978), Volume 4, Issue 2, April 1982,
// Pages 75-76, ISSN 0141-1195,
// http://dx.doi.org/10.1016/S0141-1195(82)80057-0.
static bool EvaluateRiddersJacobianColumn(
const CostFunctor* functor,
int parameter_index,
double delta,
const NumericDiffOptions& options,
int num_residuals,
int parameter_block_size,
const double* x_ptr,
const double* residuals_at_eval_point,
double** parameters,
double* x_plus_delta_ptr,
double* temp_residuals_ptr,
double* residuals_ptr) {
using Eigen::Map;
using Eigen::Matrix;
using Eigen::aligned_allocator;
typedef Matrix<double, kNumResiduals, 1> ResidualVector;
typedef Matrix<double, kNumResiduals, Eigen::Dynamic> ResidualCandidateMatrix;
typedef Matrix<double, kParameterBlockSize, 1> ParameterVector;
Map<const ParameterVector> x(x_ptr, parameter_block_size);
Map<ParameterVector> x_plus_delta(x_plus_delta_ptr,
parameter_block_size);
Map<ResidualVector> residuals(residuals_ptr, num_residuals);
Map<ResidualVector> temp_residuals(temp_residuals_ptr, num_residuals);
// In order for the algorithm to converge, the step size should be
// initialized to a value that is large enough to produce a significant
// change in the function.
// As the derivative is estimated, the step size decreases.
// By default, the step sizes are chosen so that the middle column
// of the Romberg tableau uses the input delta.
double current_step_size = delta *
pow(options.ridders_step_shrink_factor,
options.max_num_ridders_extrapolations / 2);
// Double-buffering temporary differential candidate vectors
// from previous step size.
ResidualCandidateMatrix stepsize_candidates_a(
num_residuals,
options.max_num_ridders_extrapolations);
ResidualCandidateMatrix stepsize_candidates_b(
num_residuals,
options.max_num_ridders_extrapolations);
ResidualCandidateMatrix* current_candidates = &stepsize_candidates_a;
ResidualCandidateMatrix* previous_candidates = &stepsize_candidates_b;
// Represents the computational error of the derivative. This variable is
// initially set to a large value, and is set to the difference between
// current and previous finite difference extrapolations.
// norm_error is supposed to decrease as the finite difference tableau
// generation progresses, serving both as an estimate for differentiation
// error and as a measure of differentiation numerical stability.
double norm_error = std::numeric_limits<double>::max();
// Loop over decreasing step sizes until:
// 1. Error is smaller than a given value (ridders_epsilon),
// 2. Maximal order of extrapolation reached, or
// 3. Extrapolation becomes numerically unstable.
for (int i = 0; i < options.max_num_ridders_extrapolations; ++i) {
// Compute the numerical derivative at this step size.
if (!EvaluateJacobianColumn(functor, parameter_index, current_step_size,
num_residuals,
parameter_block_size,
x.data(),
residuals_at_eval_point,
parameters,
x_plus_delta.data(),
temp_residuals.data(),
current_candidates->col(0).data())) {
// Something went wrong; bail.
return false;
}
x_plus_delta(j) = x(j); // Restore x_plus_delta.
// Divide out the run to get slope.
parameter_jacobian.col(j) *= one_over_delta;
// Store initial results.
if (i == 0) {
residuals = current_candidates->col(0);
}
// Shrink differentiation step size.
current_step_size /= options.ridders_step_shrink_factor;
// Extrapolation factor for Richardson acceleration method (see below).
double richardson_factor = options.ridders_step_shrink_factor *
options.ridders_step_shrink_factor;
for (int k = 1; k <= i; ++k) {
// Extrapolate the various orders of finite differences using
// the Richardson acceleration method.
current_candidates->col(k) =
(richardson_factor * current_candidates->col(k - 1) -
previous_candidates->col(k - 1)) / (richardson_factor - 1.0);
richardson_factor *= options.ridders_step_shrink_factor *
options.ridders_step_shrink_factor;
// Compute the difference between the previous value and the current.
double candidate_error = std::max(
(current_candidates->col(k) -
current_candidates->col(k - 1)).norm(),
(current_candidates->col(k) -
previous_candidates->col(k - 1)).norm());
// If the error has decreased, update results.
if (candidate_error <= norm_error) {
norm_error = candidate_error;
residuals = current_candidates->col(k);
// If the error is small enough, stop.
if (norm_error < options.ridders_epsilon) {
break;
}
}
}
// After breaking out of the inner loop, declare convergence.
if (norm_error < options.ridders_epsilon) {
break;
}
// Check to see if the current gradient estimate is numerically unstable.
// If so, bail out and return the last stable result.
if (i > 0) {
double tableau_error = (current_candidates->col(i) -
previous_candidates->col(i - 1)).norm();
// Compare current error to the chosen candidate's error.
if (tableau_error >= 2 * norm_error) {
break;
}
}
std::swap(current_candidates, previous_candidates);
}
return true;
}
};
template <typename CostFunctor,
NumericDiffMethod kMethod,
NumericDiffMethodType kMethod,
int kNumResiduals,
int N0, int N1, int N2, int N3, int N4,
int N5, int N6, int N7, int N8, int N9,
@@ -192,11 +419,22 @@ struct NumericDiff<CostFunctor, kMethod, kNumResiduals,
// Mutates parameters but must restore them before return.
static bool EvaluateJacobianForParameterBlock(
const CostFunctor* functor,
double const* residuals_at_eval_point,
const double relative_step_size,
const double* residuals_at_eval_point,
const NumericDiffOptions& options,
const int num_residuals,
const int parameter_block_index,
const int parameter_block_size,
double **parameters,
double *jacobian) {
// Silence unused parameter compiler warnings.
(void)functor;
(void)residuals_at_eval_point;
(void)options;
(void)num_residuals;
(void)parameter_block_index;
(void)parameter_block_size;
(void)parameters;
(void)jacobian;
LOG(FATAL) << "Control should never reach here.";
return true;
}

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -34,8 +34,6 @@
// This file needs to compile as c code.
#ifdef __cplusplus
#include <string>
#include "ceres/internal/config.h"
#if defined(CERES_TR1_MEMORY_HEADER)
@@ -46,16 +44,6 @@
namespace ceres {
// It is unfortunate that this import of the entire standard namespace is
// necessary. The reasons are historical and won't be explained here, but
// suffice to say it is not a mistake and can't be removed without breaking
// things outside of the Ceres optimization package.
using namespace std;
// This is necessary to properly handle the case that there is a different
// "string" implementation in the global namespace.
using std::string;
#if defined(CERES_TR1_SHARED_PTR)
using std::tr1::shared_ptr;
#else

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2014 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2013 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -35,6 +35,7 @@
#include <stddef.h>
#include "ceres/jet.h"
#include "ceres/types.h"
#include "ceres/internal/eigen.h"
#include "ceres/internal/fixed_array.h"
#include "glog/logging.h"
@@ -176,6 +177,17 @@ struct VariadicEvaluate<Functor, T, N0, 0, 0, 0, 0, 0, 0, 0, 0, 0> {
}
};
// Template instantiation for dynamically-sized functors.
template<typename Functor, typename T>
struct VariadicEvaluate<Functor, T, ceres::DYNAMIC, ceres::DYNAMIC,
ceres::DYNAMIC, ceres::DYNAMIC, ceres::DYNAMIC,
ceres::DYNAMIC, ceres::DYNAMIC, ceres::DYNAMIC,
ceres::DYNAMIC, ceres::DYNAMIC> {
static bool Call(const Functor& functor, T const *const *input, T* output) {
return functor(input, output);
}
};
} // namespace internal
} // namespace ceres

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -106,8 +106,8 @@
// Jet<double, 2> y(1); // Pick the 1st dual number for y.
// Jet<double, 2> z = f(x, y);
//
// LOG(INFO) << "df/dx = " << z.a[0]
// << "df/dy = " << z.a[1];
// LOG(INFO) << "df/dx = " << z.v[0]
// << "df/dy = " << z.v[1];
//
// Most users should not use Jet objects directly; a wrapper around Jet objects,
// which makes computing the derivative, gradient, or jacobian of templated
@@ -482,6 +482,41 @@ Jet<T, N> tanh(const Jet<T, N>& f) {
return Jet<T, N>(tanh_a, tmp * f.v);
}
// Bessel functions of the first kind with integer order equal to 0, 1, n.
inline double BesselJ0(double x) { return j0(x); }
inline double BesselJ1(double x) { return j1(x); }
inline double BesselJn(int n, double x) { return jn(n, x); }
// For the formulae of the derivatives of the Bessel functions see the book:
// Olver, Lozier, Boisvert, Clark, NIST Handbook of Mathematical Functions,
// Cambridge University Press 2010.
//
// Formulae are also available at http://dlmf.nist.gov
// See formula http://dlmf.nist.gov/10.6#E3
// j0(a + h) ~= j0(a) - j1(a) h
template <typename T, int N> inline
Jet<T, N> BesselJ0(const Jet<T, N>& f) {
return Jet<T, N>(BesselJ0(f.a),
-BesselJ1(f.a) * f.v);
}
// See formula http://dlmf.nist.gov/10.6#E1
// j1(a + h) ~= j1(a) + 0.5 ( j0(a) - j2(a) ) h
template <typename T, int N> inline
Jet<T, N> BesselJ1(const Jet<T, N>& f) {
return Jet<T, N>(BesselJ1(f.a),
T(0.5) * (BesselJ0(f.a) - BesselJn(2, f.a)) * f.v);
}
// See formula http://dlmf.nist.gov/10.6#E1
// j_n(a + h) ~= j_n(a) + 0.5 ( j_{n-1}(a) - j_{n+1}(a) ) h
template <typename T, int N> inline
Jet<T, N> BesselJn(int n, const Jet<T, N>& f) {
return Jet<T, N>(BesselJn(n, f.a),
T(0.5) * (BesselJn(n - 1, f.a) - BesselJn(n + 1, f.a)) * f.v);
}
// Jet Classification. It is not clear what the appropriate semantics are for
// these classifications. This picks that IsFinite and isnormal are "all"
// operations, i.e. all elements of the jet must be finite for the jet itself
@@ -573,22 +608,101 @@ Jet<T, N> pow(const Jet<T, N>& f, double g) {
}
// pow -- base is a constant, exponent is a differentiable function.
// (a)^(p+dp) ~= a^p + a^p log(a) dp
// We have various special cases, see the comment for pow(Jet, Jet) for
// analysis:
//
// 1. For f > 0 we have: (f)^(g + dg) ~= f^g + f^g log(f) dg
//
// 2. For f == 0 and g > 0 we have: (f)^(g + dg) ~= f^g
//
// 3. For f < 0 and integer g we have: (f)^(g + dg) ~= f^g but if dg
// != 0, the derivatives are not defined and we return NaN.
template <typename T, int N> inline
Jet<T, N> pow(double f, const Jet<T, N>& g) {
if (f == 0 && g.a > 0) {
// Handle case 2.
return Jet<T, N>(T(0.0));
}
if (f < 0 && g.a == floor(g.a)) {
// Handle case 3.
Jet<T, N> ret(pow(f, g.a));
for (int i = 0; i < N; i++) {
if (g.v[i] != T(0.0)) {
// Return a NaN when g.v != 0.
ret.v[i] = std::numeric_limits<T>::quiet_NaN();
}
}
return ret;
}
// Handle case 1.
T const tmp = pow(f, g.a);
return Jet<T, N>(tmp, log(f) * tmp * g.v);
}
// pow -- both base and exponent are differentiable functions. This has a
// variety of special cases that require careful handling.
//
// 1. For f > 0:
// (f + df)^(g + dg) ~= f^g + f^(g - 1) * (g * df + f * log(f) * dg)
// The numerical evaluation of f * log(f) for f > 0 is well behaved, even for
// extremely small values (e.g. 1e-99).
//
// 2. For f == 0 and g > 1: (f + df)^(g + dg) ~= 0
// This cases is needed because log(0) can not be evaluated in the f > 0
// expression. However the function f*log(f) is well behaved around f == 0
// and its limit as f-->0 is zero.
//
// 3. For f == 0 and g == 1: (f + df)^(g + dg) ~= 0 + df
//
// 4. For f == 0 and 0 < g < 1: The value is finite but the derivatives are not.
//
// 5. For f == 0 and g < 0: The value and derivatives of f^g are not finite.
//
// 6. For f == 0 and g == 0: The C standard incorrectly defines 0^0 to be 1
// "because there are applications that can exploit this definition". We
// (arbitrarily) decree that derivatives here will be nonfinite, since that
// is consistent with the behavior for f == 0, g < 0 and 0 < g < 1.
// Practically any definition could have been justified because mathematical
// consistency has been lost at this point.
//
// 7. For f < 0, g integer, dg == 0: (f + df)^(g + dg) ~= f^g + g * f^(g - 1) df
// This is equivalent to the case where f is a differentiable function and g
// is a constant (to first order).
//
// 8. For f < 0, g integer, dg != 0: The value is finite but the derivatives are
// not, because any change in the value of g moves us away from the point
// with a real-valued answer into the region with complex-valued answers.
//
// 9. For f < 0, g noninteger: The value and derivatives of f^g are not finite.
// pow -- both base and exponent are differentiable functions.
// (a+da)^(b+db) ~= a^b + b * a^(b-1) da + a^b log(a) * db
template <typename T, int N> inline
Jet<T, N> pow(const Jet<T, N>& f, const Jet<T, N>& g) {
if (f.a == 0 && g.a >= 1) {
// Handle cases 2 and 3.
if (g.a > 1) {
return Jet<T, N>(T(0.0));
}
return f;
}
if (f.a < 0 && g.a == floor(g.a)) {
// Handle cases 7 and 8.
T const tmp = g.a * pow(f.a, g.a - T(1.0));
Jet<T, N> ret(pow(f.a, g.a), tmp * f.v);
for (int i = 0; i < N; i++) {
if (g.v[i] != T(0.0)) {
// Return a NaN when g.v != 0.
ret.v[i] = std::numeric_limits<T>::quiet_NaN();
}
}
return ret;
}
// Handle the remaining cases. For cases 4,5,6,9 we allow the log() function
// to generate -HUGE_VAL or NaN, since those cases result in a nonfinite
// derivative.
T const tmp1 = pow(f.a, g.a);
T const tmp2 = g.a * pow(f.a, g.a - T(1.0));
T const tmp3 = tmp1 * log(f.a);
return Jet<T, N>(tmp1, tmp2 * f.v + tmp3 * g.v);
}

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2014 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -34,6 +34,7 @@
#include <vector>
#include "ceres/internal/port.h"
#include "ceres/internal/scoped_ptr.h"
#include "ceres/internal/disable_warnings.h"
namespace ceres {
@@ -173,7 +174,7 @@ class CERES_EXPORT IdentityParameterization : public LocalParameterization {
class CERES_EXPORT SubsetParameterization : public LocalParameterization {
public:
explicit SubsetParameterization(int size,
const vector<int>& constant_parameters);
const std::vector<int>& constant_parameters);
virtual ~SubsetParameterization() {}
virtual bool Plus(const double* x,
const double* delta,
@@ -191,7 +192,7 @@ class CERES_EXPORT SubsetParameterization : public LocalParameterization {
private:
const int local_size_;
vector<int> constancy_mask_;
std::vector<char> constancy_mask_;
};
// Plus(x, delta) = [cos(|delta|), sin(|delta|) delta / |delta|] * x
@@ -210,6 +211,89 @@ class CERES_EXPORT QuaternionParameterization : public LocalParameterization {
virtual int LocalSize() const { return 3; }
};
// This provides a parameterization for homogeneous vectors which are commonly
// used in Structure for Motion problems. One example where they are used is
// in representing points whose triangulation is ill-conditioned. Here
// it is advantageous to use an over-parameterization since homogeneous vectors
// can represent points at infinity.
//
// The plus operator is defined as
// Plus(x, delta) =
// [sin(0.5 * |delta|) * delta / |delta|, cos(0.5 * |delta|)] * x
// with * defined as an operator which applies the update orthogonal to x to
// remain on the sphere. We assume that the last element of x is the scalar
// component. The size of the homogeneous vector is required to be greater than
// 1.
class CERES_EXPORT HomogeneousVectorParameterization :
public LocalParameterization {
public:
explicit HomogeneousVectorParameterization(int size);
virtual ~HomogeneousVectorParameterization() {}
virtual bool Plus(const double* x,
const double* delta,
double* x_plus_delta) const;
virtual bool ComputeJacobian(const double* x,
double* jacobian) const;
virtual int GlobalSize() const { return size_; }
virtual int LocalSize() const { return size_ - 1; }
private:
const int size_;
};
// Construct a local parameterization by taking the Cartesian product
// of a number of other local parameterizations. This is useful, when
// a parameter block is the cartesian product of two or more
// manifolds. For example the parameters of a camera consist of a
// rotation and a translation, i.e., SO(3) x R^3.
//
// Currently this class supports taking the cartesian product of up to
// four local parameterizations.
//
// Example usage:
//
// ProductParameterization product_param(new QuaterionionParameterization(),
// new IdentityParameterization(3));
//
// is the local parameterization for a rigid transformation, where the
// rotation is represented using a quaternion.
class CERES_EXPORT ProductParameterization : public LocalParameterization {
public:
//
// NOTE: All the constructors take ownership of the input local
// parameterizations.
//
ProductParameterization(LocalParameterization* local_param1,
LocalParameterization* local_param2);
ProductParameterization(LocalParameterization* local_param1,
LocalParameterization* local_param2,
LocalParameterization* local_param3);
ProductParameterization(LocalParameterization* local_param1,
LocalParameterization* local_param2,
LocalParameterization* local_param3,
LocalParameterization* local_param4);
virtual ~ProductParameterization();
virtual bool Plus(const double* x,
const double* delta,
double* x_plus_delta) const;
virtual bool ComputeJacobian(const double* x,
double* jacobian) const;
virtual int GlobalSize() const { return global_size_; }
virtual int LocalSize() const { return local_size_; }
private:
void Init();
std::vector<LocalParameterization*> local_params_;
int local_size_;
int global_size_;
int buffer_size_;
};
} // namespace ceres
#include "ceres/internal/reenable_warnings.h"

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -274,10 +274,28 @@ class CERES_EXPORT TolerantLoss : public LossFunction {
const double a_, b_, c_;
};
// This is the Tukey biweight loss function which aggressively
// attempts to suppress large errors.
//
// The term is computed as:
//
// rho(s) = a^2 / 6 * (1 - (1 - s / a^2)^3 ) for s <= a^2,
// rho(s) = a^2 / 6 for s > a^2.
//
// At s = 0: rho = [0, 0.5, -1 / a^2]
class CERES_EXPORT TukeyLoss : public ceres::LossFunction {
public:
explicit TukeyLoss(double a) : a_squared_(a * a) { }
virtual void Evaluate(double, double*) const;
private:
const double a_squared_;
};
// Composition of two loss functions. The error is the result of first
// evaluating g followed by f to yield the composition f(g(s)).
// The loss functions must not be NULL.
class ComposedLoss : public LossFunction {
class CERES_EXPORT ComposedLoss : public LossFunction {
public:
explicit ComposedLoss(const LossFunction* f, Ownership ownership_f,
const LossFunction* g, Ownership ownership_g);
@@ -340,6 +358,9 @@ class CERES_EXPORT ScaledLoss : public LossFunction {
// whose scale can be mutated after an optimization problem has been
// constructed.
//
// Since we treat the a NULL Loss function as the Identity loss
// function, rho = NULL is a valid input.
//
// Example usage
//
// Problem problem;
@@ -376,8 +397,14 @@ class CERES_EXPORT LossFunctionWrapper : public LossFunction {
}
virtual void Evaluate(double sq_norm, double out[3]) const {
CHECK_NOTNULL(rho_.get());
rho_->Evaluate(sq_norm, out);
if (rho_.get() == NULL) {
out[0] = sq_norm;
out[1] = 1.0;
out[2] = 0.0;
}
else {
rho_->Evaluate(sq_norm, out);
}
}
void Reset(LossFunction* rho, Ownership ownership) {
@@ -396,6 +423,6 @@ class CERES_EXPORT LossFunctionWrapper : public LossFunction {
} // namespace ceres
#include "ceres/internal/disable_warnings.h"
#include "ceres/internal/reenable_warnings.h"
#endif // CERES_PUBLIC_LOSS_FUNCTION_H_

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -132,7 +132,7 @@
//
// ALTERNATE INTERFACE
//
// For a variety of reason, including compatibility with legacy code,
// For a variety of reasons, including compatibility with legacy code,
// NumericDiffCostFunction can also take CostFunction objects as
// input. The following describes how.
//
@@ -165,6 +165,7 @@
#include "ceres/cost_function.h"
#include "ceres/internal/numeric_diff.h"
#include "ceres/internal/scoped_ptr.h"
#include "ceres/numeric_diff_options.h"
#include "ceres/sized_cost_function.h"
#include "ceres/types.h"
#include "glog/logging.h"
@@ -172,7 +173,7 @@
namespace ceres {
template <typename CostFunctor,
NumericDiffMethod method = CENTRAL,
NumericDiffMethodType method = CENTRAL,
int kNumResiduals = 0, // Number of residuals, or ceres::DYNAMIC
int N0 = 0, // Number of parameters in block 0.
int N1 = 0, // Number of parameters in block 1.
@@ -189,13 +190,14 @@ class NumericDiffCostFunction
N0, N1, N2, N3, N4,
N5, N6, N7, N8, N9> {
public:
NumericDiffCostFunction(CostFunctor* functor,
Ownership ownership = TAKE_OWNERSHIP,
int num_residuals = kNumResiduals,
const double relative_step_size = 1e-6)
:functor_(functor),
ownership_(ownership),
relative_step_size_(relative_step_size) {
NumericDiffCostFunction(
CostFunctor* functor,
Ownership ownership = TAKE_OWNERSHIP,
int num_residuals = kNumResiduals,
const NumericDiffOptions& options = NumericDiffOptions())
: functor_(functor),
ownership_(ownership),
options_(options) {
if (kNumResiduals == DYNAMIC) {
SizedCostFunction<kNumResiduals,
N0, N1, N2, N3, N4,
@@ -204,6 +206,29 @@ class NumericDiffCostFunction
}
}
// Deprecated. New users should avoid using this constructor. Instead, use the
// constructor with NumericDiffOptions.
NumericDiffCostFunction(CostFunctor* functor,
Ownership ownership,
int num_residuals,
const double relative_step_size)
:functor_(functor),
ownership_(ownership),
options_() {
LOG(WARNING) << "This constructor is deprecated and will be removed in "
"a future version. Please use the NumericDiffOptions "
"constructor instead.";
if (kNumResiduals == DYNAMIC) {
SizedCostFunction<kNumResiduals,
N0, N1, N2, N3, N4,
N5, N6, N7, N8, N9>
::set_num_residuals(num_residuals);
}
options_.relative_step_size = relative_step_size;
}
~NumericDiffCostFunction() {
if (ownership_ != TAKE_OWNERSHIP) {
functor_.release();
@@ -250,25 +275,25 @@ class NumericDiffCostFunction
if (N8) parameters_reference_copy[8] = parameters_reference_copy[7] + N7;
if (N9) parameters_reference_copy[9] = parameters_reference_copy[8] + N8;
#define COPY_PARAMETER_BLOCK(block) \
#define CERES_COPY_PARAMETER_BLOCK(block) \
if (N ## block) memcpy(parameters_reference_copy[block], \
parameters[block], \
sizeof(double) * N ## block); // NOLINT
COPY_PARAMETER_BLOCK(0);
COPY_PARAMETER_BLOCK(1);
COPY_PARAMETER_BLOCK(2);
COPY_PARAMETER_BLOCK(3);
COPY_PARAMETER_BLOCK(4);
COPY_PARAMETER_BLOCK(5);
COPY_PARAMETER_BLOCK(6);
COPY_PARAMETER_BLOCK(7);
COPY_PARAMETER_BLOCK(8);
COPY_PARAMETER_BLOCK(9);
CERES_COPY_PARAMETER_BLOCK(0);
CERES_COPY_PARAMETER_BLOCK(1);
CERES_COPY_PARAMETER_BLOCK(2);
CERES_COPY_PARAMETER_BLOCK(3);
CERES_COPY_PARAMETER_BLOCK(4);
CERES_COPY_PARAMETER_BLOCK(5);
CERES_COPY_PARAMETER_BLOCK(6);
CERES_COPY_PARAMETER_BLOCK(7);
CERES_COPY_PARAMETER_BLOCK(8);
CERES_COPY_PARAMETER_BLOCK(9);
#undef COPY_PARAMETER_BLOCK
#undef CERES_COPY_PARAMETER_BLOCK
#define EVALUATE_JACOBIAN_FOR_BLOCK(block) \
#define CERES_EVALUATE_JACOBIAN_FOR_BLOCK(block) \
if (N ## block && jacobians[block] != NULL) { \
if (!NumericDiff<CostFunctor, \
method, \
@@ -278,28 +303,30 @@ class NumericDiffCostFunction
N ## block >::EvaluateJacobianForParameterBlock( \
functor_.get(), \
residuals, \
relative_step_size_, \
options_, \
SizedCostFunction<kNumResiduals, \
N0, N1, N2, N3, N4, \
N5, N6, N7, N8, N9>::num_residuals(), \
block, \
N ## block, \
parameters_reference_copy.get(), \
jacobians[block])) { \
return false; \
} \
}
EVALUATE_JACOBIAN_FOR_BLOCK(0);
EVALUATE_JACOBIAN_FOR_BLOCK(1);
EVALUATE_JACOBIAN_FOR_BLOCK(2);
EVALUATE_JACOBIAN_FOR_BLOCK(3);
EVALUATE_JACOBIAN_FOR_BLOCK(4);
EVALUATE_JACOBIAN_FOR_BLOCK(5);
EVALUATE_JACOBIAN_FOR_BLOCK(6);
EVALUATE_JACOBIAN_FOR_BLOCK(7);
EVALUATE_JACOBIAN_FOR_BLOCK(8);
EVALUATE_JACOBIAN_FOR_BLOCK(9);
CERES_EVALUATE_JACOBIAN_FOR_BLOCK(0);
CERES_EVALUATE_JACOBIAN_FOR_BLOCK(1);
CERES_EVALUATE_JACOBIAN_FOR_BLOCK(2);
CERES_EVALUATE_JACOBIAN_FOR_BLOCK(3);
CERES_EVALUATE_JACOBIAN_FOR_BLOCK(4);
CERES_EVALUATE_JACOBIAN_FOR_BLOCK(5);
CERES_EVALUATE_JACOBIAN_FOR_BLOCK(6);
CERES_EVALUATE_JACOBIAN_FOR_BLOCK(7);
CERES_EVALUATE_JACOBIAN_FOR_BLOCK(8);
CERES_EVALUATE_JACOBIAN_FOR_BLOCK(9);
#undef EVALUATE_JACOBIAN_FOR_BLOCK
#undef CERES_EVALUATE_JACOBIAN_FOR_BLOCK
return true;
}
@@ -307,7 +334,7 @@ class NumericDiffCostFunction
private:
internal::scoped_ptr<CostFunctor> functor_;
Ownership ownership_;
const double relative_step_size_;
NumericDiffOptions options_;
};
} // namespace ceres

View File

@@ -0,0 +1,79 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// 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.
// * Neither the name of Google Inc. nor the names of its contributors may be
// used to endorse or promote products derived from this software without
// specific prior written permission.
//
// 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 OWNER 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.
//
// Author: tbennun@gmail.com (Tal Ben-Nun)
//
#ifndef CERES_PUBLIC_NUMERIC_DIFF_OPTIONS_H_
#define CERES_PUBLIC_NUMERIC_DIFF_OPTIONS_H_
namespace ceres {
// Options pertaining to numeric differentiation (e.g., convergence criteria,
// step sizes).
struct CERES_EXPORT NumericDiffOptions {
NumericDiffOptions() {
relative_step_size = 1e-6;
ridders_relative_initial_step_size = 1e-2;
max_num_ridders_extrapolations = 10;
ridders_epsilon = 1e-12;
ridders_step_shrink_factor = 2.0;
}
// Numeric differentiation step size (multiplied by parameter block's
// order of magnitude). If parameters are close to zero, the step size
// is set to sqrt(machine_epsilon).
double relative_step_size;
// Initial step size for Ridders adaptive numeric differentiation (multiplied
// by parameter block's order of magnitude).
// If parameters are close to zero, Ridders' method sets the step size
// directly to this value. This parameter is separate from
// "relative_step_size" in order to set a different default value.
//
// Note: For Ridders' method to converge, the step size should be initialized
// to a value that is large enough to produce a significant change in the
// function. As the derivative is estimated, the step size decreases.
double ridders_relative_initial_step_size;
// Maximal number of adaptive extrapolations (sampling) in Ridders' method.
int max_num_ridders_extrapolations;
// Convergence criterion on extrapolation error for Ridders adaptive
// differentiation. The available error estimation methods are defined in
// NumericDiffErrorType and set in the "ridders_error_method" field.
double ridders_epsilon;
// The factor in which to shrink the step size with each extrapolation in
// Ridders' method.
double ridders_step_shrink_factor;
};
} // namespace ceres
#endif // CERES_PUBLIC_NUMERIC_DIFF_OPTIONS_H_

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -63,7 +63,8 @@ class OrderedGroups {
return false;
}
typename map<T, int>::const_iterator it = element_to_group_.find(element);
typename std::map<T, int>::const_iterator it =
element_to_group_.find(element);
if (it != element_to_group_.end()) {
if (it->second == group) {
// Element is already in the right group, nothing to do.
@@ -107,7 +108,7 @@ class OrderedGroups {
// Bulk remove elements. The return value indicates the number of
// elements successfully removed.
int Remove(const vector<T>& elements) {
int Remove(const std::vector<T>& elements) {
if (NumElements() == 0 || elements.size() == 0) {
return 0;
}
@@ -121,14 +122,18 @@ class OrderedGroups {
// Reverse the order of the groups in place.
void Reverse() {
typename map<int, set<T> >::reverse_iterator it =
if (NumGroups() == 0) {
return;
}
typename std::map<int, std::set<T> >::reverse_iterator it =
group_to_elements_.rbegin();
map<int, set<T> > new_group_to_elements;
std::map<int, std::set<T> > new_group_to_elements;
new_group_to_elements[it->first] = it->second;
int new_group_id = it->first + 1;
for (++it; it != group_to_elements_.rend(); ++it) {
for (typename set<T>::const_iterator element_it = it->second.begin();
for (typename std::set<T>::const_iterator element_it = it->second.begin();
element_it != it->second.end();
++element_it) {
element_to_group_[*element_it] = new_group_id;
@@ -143,7 +148,8 @@ class OrderedGroups {
// Return the group id for the element. If the element is not a
// member of any group, return -1.
int GroupId(const T element) const {
typename map<T, int>::const_iterator it = element_to_group_.find(element);
typename std::map<T, int>::const_iterator it =
element_to_group_.find(element);
if (it == element_to_group_.end()) {
return -1;
}
@@ -151,14 +157,15 @@ class OrderedGroups {
}
bool IsMember(const T element) const {
typename map<T, int>::const_iterator it = element_to_group_.find(element);
typename std::map<T, int>::const_iterator it =
element_to_group_.find(element);
return (it != element_to_group_.end());
}
// This function always succeeds, i.e., implicitly there exists a
// group for every integer.
int GroupSize(const int group) const {
typename map<int, set<T> >::const_iterator it =
typename std::map<int, std::set<T> >::const_iterator it =
group_to_elements_.find(group);
return (it == group_to_elements_.end()) ? 0 : it->second.size();
}
@@ -180,17 +187,17 @@ class OrderedGroups {
return group_to_elements_.begin()->first;
}
const map<int, set<T> >& group_to_elements() const {
const std::map<int, std::set<T> >& group_to_elements() const {
return group_to_elements_;
}
const map<T, int>& element_to_group() const {
const std::map<T, int>& element_to_group() const {
return element_to_group_;
}
private:
map<int, set<T> > group_to_elements_;
map<T, int> element_to_group_;
std::map<int, std::set<T> > group_to_elements_;
std::map<T, int> element_to_group_;
};
// Typedef for the most commonly used version of OrderedGroups.

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2013 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -211,9 +211,10 @@ class CERES_EXPORT Problem {
// problem.AddResidualBlock(new MyUnaryCostFunction(...), NULL, x1);
// problem.AddResidualBlock(new MyBinaryCostFunction(...), NULL, x2, x1);
//
ResidualBlockId AddResidualBlock(CostFunction* cost_function,
LossFunction* loss_function,
const vector<double*>& parameter_blocks);
ResidualBlockId AddResidualBlock(
CostFunction* cost_function,
LossFunction* loss_function,
const std::vector<double*>& parameter_blocks);
// Convenience methods for adding residuals with a small number of
// parameters. This is the common case. Instead of specifying the
@@ -356,17 +357,17 @@ class CERES_EXPORT Problem {
// Fills the passed parameter_blocks vector with pointers to the
// parameter blocks currently in the problem. After this call,
// parameter_block.size() == NumParameterBlocks.
void GetParameterBlocks(vector<double*>* parameter_blocks) const;
void GetParameterBlocks(std::vector<double*>* parameter_blocks) const;
// Fills the passed residual_blocks vector with pointers to the
// residual blocks currently in the problem. After this call,
// residual_blocks.size() == NumResidualBlocks.
void GetResidualBlocks(vector<ResidualBlockId>* residual_blocks) const;
void GetResidualBlocks(std::vector<ResidualBlockId>* residual_blocks) const;
// Get all the parameter blocks that depend on the given residual block.
void GetParameterBlocksForResidualBlock(
const ResidualBlockId residual_block,
vector<double*>* parameter_blocks) const;
std::vector<double*>* parameter_blocks) const;
// Get the CostFunction for the given residual block.
const CostFunction* GetCostFunctionForResidualBlock(
@@ -385,7 +386,7 @@ class CERES_EXPORT Problem {
// block will incur a scan of the entire Problem object.
void GetResidualBlocksForParameterBlock(
const double* values,
vector<ResidualBlockId>* residual_blocks) const;
std::vector<ResidualBlockId>* residual_blocks) const;
// Options struct to control Problem::Evaluate.
struct EvaluateOptions {
@@ -408,18 +409,17 @@ class CERES_EXPORT Problem {
// used to add parameter blocks to the Problem. These parameter
// block should NOT point to new memory locations. Bad things will
// happen otherwise.
vector<double*> parameter_blocks;
std::vector<double*> parameter_blocks;
// The set of residual blocks to evaluate. This vector determines
// the order in which the residuals occur, and how the rows of the
// jacobian are ordered. If residual_blocks is empty, then it is
// assumed to be equal to the vector containing all the residual
// blocks. If this vector is empty, then it is assumed to be equal
// to a vector containing ALL the residual blocks. Generally
// speaking the residual blocks will occur in the order in which
// they were added to the problem. But, this may change if the
// user removes any residual blocks from the problem.
vector<ResidualBlockId> residual_blocks;
// assumed to be equal to the vector containing ALL the residual
// blocks. Generally speaking the residual blocks will occur in
// the order in which they were added to the problem. But, this
// may change if the user removes any residual blocks from the
// problem.
std::vector<ResidualBlockId> residual_blocks;
// Even though the residual blocks in the problem may contain loss
// functions, setting apply_loss_function to false will turn off
@@ -463,8 +463,8 @@ class CERES_EXPORT Problem {
// columns in the jacobian).
bool Evaluate(const EvaluateOptions& options,
double* cost,
vector<double>* residuals,
vector<double>* gradient,
std::vector<double>* residuals,
std::vector<double>* gradient,
CRSMatrix* jacobian);
private:

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -47,6 +47,7 @@
#include <algorithm>
#include <cmath>
#include <limits>
#include "glog/logging.h"
namespace ceres {
@@ -94,6 +95,17 @@ void AngleAxisToQuaternion(const T* angle_axis, T* quaternion);
template<typename T>
void QuaternionToAngleAxis(const T* quaternion, T* angle_axis);
// Conversions between 3x3 rotation matrix (in column major order) and
// quaternion rotation representations. Templated for use with
// autodifferentiation.
template <typename T>
void RotationMatrixToQuaternion(const T* R, T* quaternion);
template <typename T, int row_stride, int col_stride>
void RotationMatrixToQuaternion(
const MatrixAdapter<const T, row_stride, col_stride>& R,
T* quaternion);
// Conversions between 3x3 rotation matrix (in column major order) and
// axis-angle rotation representations. Templated for use with
// autodifferentiation.
@@ -141,11 +153,11 @@ void EulerAnglesToRotationMatrix(
// the cross-product matrix of [a b c]. Together with the property that
// R(q1 * q2) = R(q1) * R(q2) this uniquely defines the mapping from q to R.
//
// The rotation matrix is row-major.
//
// No normalization of the quaternion is performed, i.e.
// R = ||q||^2 * Q, where Q is an orthonormal matrix
// such that det(Q) = 1 and Q*Q' = I
//
// WARNING: The rotation matrix is ROW MAJOR
template <typename T> inline
void QuaternionToScaledRotation(const T q[4], T R[3 * 3]);
@@ -156,6 +168,8 @@ void QuaternionToScaledRotation(
// Same as above except that the rotation matrix is normalized by the
// Frobenius norm, so that R * R' = I (and det(R) = 1).
//
// WARNING: The rotation matrix is ROW MAJOR
template <typename T> inline
void QuaternionToRotation(const T q[4], T R[3 * 3]);
@@ -294,6 +308,46 @@ inline void QuaternionToAngleAxis(const T* quaternion, T* angle_axis) {
}
}
template <typename T>
void RotationMatrixToQuaternion(const T* R, T* angle_axis) {
RotationMatrixToQuaternion(ColumnMajorAdapter3x3(R), angle_axis);
}
// This algorithm comes from "Quaternion Calculus and Fast Animation",
// Ken Shoemake, 1987 SIGGRAPH course notes
template <typename T, int row_stride, int col_stride>
void RotationMatrixToQuaternion(
const MatrixAdapter<const T, row_stride, col_stride>& R,
T* quaternion) {
const T trace = R(0, 0) + R(1, 1) + R(2, 2);
if (trace >= 0.0) {
T t = sqrt(trace + T(1.0));
quaternion[0] = T(0.5) * t;
t = T(0.5) / t;
quaternion[1] = (R(2, 1) - R(1, 2)) * t;
quaternion[2] = (R(0, 2) - R(2, 0)) * t;
quaternion[3] = (R(1, 0) - R(0, 1)) * t;
} else {
int i = 0;
if (R(1, 1) > R(0, 0)) {
i = 1;
}
if (R(2, 2) > R(i, i)) {
i = 2;
}
const int j = (i + 1) % 3;
const int k = (j + 1) % 3;
T t = sqrt(R(i, i) - R(j, j) - R(k, k) + T(1.0));
quaternion[i + 1] = T(0.5) * t;
t = T(0.5) / t;
quaternion[0] = (R(k, j) - R(j, k)) * t;
quaternion[j + 1] = (R(j, i) + R(i, j)) * t;
quaternion[k + 1] = (R(k, i) + R(i, k)) * t;
}
}
// The conversion of a rotation matrix to the angle-axis form is
// numerically problematic when then rotation angle is close to zero
// or to Pi. The following implementation detects when these two cases
@@ -308,80 +362,10 @@ template <typename T, int row_stride, int col_stride>
void RotationMatrixToAngleAxis(
const MatrixAdapter<const T, row_stride, col_stride>& R,
T* angle_axis) {
// x = k * 2 * sin(theta), where k is the axis of rotation.
angle_axis[0] = R(2, 1) - R(1, 2);
angle_axis[1] = R(0, 2) - R(2, 0);
angle_axis[2] = R(1, 0) - R(0, 1);
static const T kOne = T(1.0);
static const T kTwo = T(2.0);
// Since the right hand side may give numbers just above 1.0 or
// below -1.0 leading to atan misbehaving, we threshold.
T costheta = std::min(std::max((R(0, 0) + R(1, 1) + R(2, 2) - kOne) / kTwo,
T(-1.0)),
kOne);
// sqrt is guaranteed to give non-negative results, so we only
// threshold above.
T sintheta = std::min(sqrt(angle_axis[0] * angle_axis[0] +
angle_axis[1] * angle_axis[1] +
angle_axis[2] * angle_axis[2]) / kTwo,
kOne);
// Use the arctan2 to get the right sign on theta
const T theta = atan2(sintheta, costheta);
// Case 1: sin(theta) is large enough, so dividing by it is not a
// problem. We do not use abs here, because while jets.h imports
// std::abs into the namespace, here in this file, abs resolves to
// the int version of the function, which returns zero always.
//
// We use a threshold much larger then the machine epsilon, because
// if sin(theta) is small, not only do we risk overflow but even if
// that does not occur, just dividing by a small number will result
// in numerical garbage. So we play it safe.
static const double kThreshold = 1e-12;
if ((sintheta > kThreshold) || (sintheta < -kThreshold)) {
const T r = theta / (kTwo * sintheta);
for (int i = 0; i < 3; ++i) {
angle_axis[i] *= r;
}
return;
}
// Case 2: theta ~ 0, means sin(theta) ~ theta to a good
// approximation.
if (costheta > 0.0) {
const T kHalf = T(0.5);
for (int i = 0; i < 3; ++i) {
angle_axis[i] *= kHalf;
}
return;
}
// Case 3: theta ~ pi, this is the hard case. Since theta is large,
// and sin(theta) is small. Dividing by theta by sin(theta) will
// either give an overflow or worse still numerically meaningless
// results. Thus we use an alternate more complicated formula
// here.
// Since cos(theta) is negative, division by (1-cos(theta)) cannot
// overflow.
const T inv_one_minus_costheta = kOne / (kOne - costheta);
// We now compute the absolute value of coordinates of the axis
// vector using the diagonal entries of R. To resolve the sign of
// these entries, we compare the sign of angle_axis[i]*sin(theta)
// with the sign of sin(theta). If they are the same, then
// angle_axis[i] should be positive, otherwise negative.
for (int i = 0; i < 3; ++i) {
angle_axis[i] = theta * sqrt((R(i, i) - costheta) * inv_one_minus_costheta);
if (((sintheta < 0.0) && (angle_axis[i] > 0.0)) ||
((sintheta > 0.0) && (angle_axis[i] < 0.0))) {
angle_axis[i] = -angle_axis[i];
}
}
T quaternion[4];
RotationMatrixToQuaternion(R, quaternion);
QuaternionToAngleAxis(quaternion, angle_axis);
return;
}
template <typename T>

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -55,15 +55,15 @@ class SizedCostFunction : public CostFunction {
// This block breaks the 80 column rule to keep it somewhat readable.
CHECK((!N1 && !N2 && !N3 && !N4 && !N5 && !N6 && !N7 && !N8 && !N9) ||
((N1 > 0) && !N2 && !N3 && !N4 && !N5 && !N6 && !N7 && !N8 && !N9) ||
((N1 > 0) && (N2 > 0) && !N3 && !N4 && !N5 && !N6 && !N7 && !N8 && !N9) ||
((N1 > 0) && (N2 > 0) && (N3 > 0) && !N4 && !N5 && !N6 && !N7 && !N8 && !N9) ||
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && !N5 && !N6 && !N7 && !N8 && !N9) ||
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && (N5 > 0) && !N6 && !N7 && !N8 && !N9) ||
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && (N5 > 0) && (N6 > 0) && !N7 && !N8 && !N9) ||
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && (N5 > 0) && (N6 > 0) && (N7 > 0) && !N8 && !N9) ||
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && (N5 > 0) && (N6 > 0) && (N7 > 0) && (N8 > 0) && !N9) ||
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && (N5 > 0) && (N6 > 0) && (N7 > 0) && (N8 > 0) && (N9 > 0)))
((N1 > 0) && !N2 && !N3 && !N4 && !N5 && !N6 && !N7 && !N8 && !N9) ||
((N1 > 0) && (N2 > 0) && !N3 && !N4 && !N5 && !N6 && !N7 && !N8 && !N9) || // NOLINT
((N1 > 0) && (N2 > 0) && (N3 > 0) && !N4 && !N5 && !N6 && !N7 && !N8 && !N9) || // NOLINT
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && !N5 && !N6 && !N7 && !N8 && !N9) || // NOLINT
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && (N5 > 0) && !N6 && !N7 && !N8 && !N9) || // NOLINT
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && (N5 > 0) && (N6 > 0) && !N7 && !N8 && !N9) || // NOLINT
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && (N5 > 0) && (N6 > 0) && (N7 > 0) && !N8 && !N9) || // NOLINT
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && (N5 > 0) && (N6 > 0) && (N7 > 0) && (N8 > 0) && !N9) || // NOLINT
((N1 > 0) && (N2 > 0) && (N3 > 0) && (N4 > 0) && (N5 > 0) && (N6 > 0) && (N7 > 0) && (N8 > 0) && (N9 > 0))) // NOLINT
<< "Zero block cannot precede a non-zero block. Block sizes are "
<< "(ignore trailing 0s): " << N0 << ", " << N1 << ", " << N2 << ", "
<< N3 << ", " << N4 << ", " << N5 << ", " << N6 << ", " << N7 << ", "
@@ -71,19 +71,19 @@ class SizedCostFunction : public CostFunction {
set_num_residuals(kNumResiduals);
#define ADD_PARAMETER_BLOCK(N) \
#define CERES_ADD_PARAMETER_BLOCK(N) \
if (N) mutable_parameter_block_sizes()->push_back(N);
ADD_PARAMETER_BLOCK(N0);
ADD_PARAMETER_BLOCK(N1);
ADD_PARAMETER_BLOCK(N2);
ADD_PARAMETER_BLOCK(N3);
ADD_PARAMETER_BLOCK(N4);
ADD_PARAMETER_BLOCK(N5);
ADD_PARAMETER_BLOCK(N6);
ADD_PARAMETER_BLOCK(N7);
ADD_PARAMETER_BLOCK(N8);
ADD_PARAMETER_BLOCK(N9);
#undef ADD_PARAMETER_BLOCK
CERES_ADD_PARAMETER_BLOCK(N0);
CERES_ADD_PARAMETER_BLOCK(N1);
CERES_ADD_PARAMETER_BLOCK(N2);
CERES_ADD_PARAMETER_BLOCK(N3);
CERES_ADD_PARAMETER_BLOCK(N4);
CERES_ADD_PARAMETER_BLOCK(N5);
CERES_ADD_PARAMETER_BLOCK(N6);
CERES_ADD_PARAMETER_BLOCK(N7);
CERES_ADD_PARAMETER_BLOCK(N8);
CERES_ADD_PARAMETER_BLOCK(N9);
#undef CERES_ADD_PARAMETER_BLOCK
}
virtual ~SizedCostFunction() { }

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2014 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -92,7 +92,7 @@ class CERES_EXPORT Solver {
gradient_tolerance = 1e-10;
parameter_tolerance = 1e-8;
#if defined(CERES_NO_SUITESPARSE) && defined(CERES_NO_CXSPARSE) && !defined(CERES_ENABLE_LGPL_CODE)
#if defined(CERES_NO_SUITESPARSE) && defined(CERES_NO_CXSPARSE) && !defined(CERES_ENABLE_LGPL_CODE) // NOLINT
linear_solver_type = DENSE_QR;
#else
linear_solver_type = SPARSE_NORMAL_CHOLESKY;
@@ -104,7 +104,8 @@ class CERES_EXPORT Solver {
// Choose a default sparse linear algebra library in the order:
//
// SUITE_SPARSE > CX_SPARSE > EIGEN_SPARSE
// SUITE_SPARSE > CX_SPARSE > EIGEN_SPARSE > NO_SPARSE
sparse_linear_algebra_library_type = NO_SPARSE;
#if !defined(CERES_NO_SUITESPARSE)
sparse_linear_algebra_library_type = SUITE_SPARSE;
#else
@@ -140,7 +141,7 @@ class CERES_EXPORT Solver {
// Returns true if the options struct has a valid
// configuration. Returns false otherwise, and fills in *error
// with a message describing the problem.
bool IsValid(string* error) const;
bool IsValid(std::string* error) const;
// Minimizer options ----------------------------------------
@@ -676,13 +677,13 @@ class CERES_EXPORT Solver {
// List of iterations at which the minimizer should dump the trust
// region problem. Useful for testing and benchmarking. If empty
// (default), no problems are dumped.
vector<int> trust_region_minimizer_iterations_to_dump;
std::vector<int> trust_region_minimizer_iterations_to_dump;
// Directory to which the problems should be written to. Should be
// non-empty if trust_region_minimizer_iterations_to_dump is
// non-empty and trust_region_problem_dump_format_type is not
// CONSOLE.
string trust_region_problem_dump_directory;
std::string trust_region_problem_dump_directory;
DumpFormatType trust_region_problem_dump_format_type;
// Finite differences options ----------------------------------------------
@@ -746,7 +747,7 @@ class CERES_EXPORT Solver {
// executed, then set update_state_every_iteration to true.
//
// The solver does NOT take ownership of these pointers.
vector<IterationCallback*> callbacks;
std::vector<IterationCallback*> callbacks;
};
struct CERES_EXPORT Summary {
@@ -754,11 +755,11 @@ class CERES_EXPORT Solver {
// A brief one line description of the state of the solver after
// termination.
string BriefReport() const;
std::string BriefReport() const;
// A full multiline description of the state of the solver after
// termination.
string FullReport() const;
std::string FullReport() const;
bool IsSolutionUsable() const;
@@ -768,7 +769,7 @@ class CERES_EXPORT Solver {
TerminationType termination_type;
// Reason why the solver terminated.
string message;
std::string message;
// Cost of the problem (value of the objective function) before
// the optimization.
@@ -784,7 +785,7 @@ class CERES_EXPORT Solver {
double fixed_cost;
// IterationSummary for each minimizer iteration in order.
vector<IterationSummary> iterations;
std::vector<IterationSummary> iterations;
// Number of minimizer iterations in which the step was
// accepted. Unless use_non_monotonic_steps is true this is also
@@ -832,6 +833,26 @@ class CERES_EXPORT Solver {
// Time (in seconds) spent doing inner iterations.
double inner_iteration_time_in_seconds;
// Cumulative timing information for line searches performed as part of the
// solve. Note that in addition to the case when the Line Search minimizer
// is used, the Trust Region minimizer also uses a line search when
// solving a constrained problem.
// Time (in seconds) spent evaluating the univariate cost function as part
// of a line search.
double line_search_cost_evaluation_time_in_seconds;
// Time (in seconds) spent evaluating the gradient of the univariate cost
// function as part of a line search.
double line_search_gradient_evaluation_time_in_seconds;
// Time (in seconds) spent minimizing the interpolating polynomial
// to compute the next candidate step size as part of a line search.
double line_search_polynomial_minimization_time_in_seconds;
// Total time (in seconds) spent performing line searches.
double line_search_total_time_in_seconds;
// Number of parameter blocks in the problem.
int num_parameter_blocks;
@@ -871,6 +892,9 @@ class CERES_EXPORT Solver {
// Number of residuals in the reduced problem.
int num_residuals_reduced;
// Is the reduced problem bounds constrained.
bool is_constrained;
// Number of threads specified by the user for Jacobian and
// residual evaluation.
int num_threads_given;
@@ -902,7 +926,7 @@ class CERES_EXPORT Solver {
// Size of the elimination groups given by the user as hints to
// the linear solver.
vector<int> linear_solver_ordering_given;
std::vector<int> linear_solver_ordering_given;
// Size of the parameter groups used by the solver when ordering
// the columns of the Jacobian. This maybe different from
@@ -910,7 +934,7 @@ class CERES_EXPORT Solver {
// linear_solver_ordering_given blank and asked for an automatic
// ordering, or if the problem contains some constant or inactive
// parameter blocks.
vector<int> linear_solver_ordering_used;
std::vector<int> linear_solver_ordering_used;
// True if the user asked for inner iterations to be used as part
// of the optimization.
@@ -924,7 +948,7 @@ class CERES_EXPORT Solver {
// Size of the parameter groups given by the user for performing
// inner iterations.
vector<int> inner_iteration_ordering_given;
std::vector<int> inner_iteration_ordering_given;
// Size of the parameter groups given used by the solver for
// performing inner iterations. This maybe different from
@@ -932,7 +956,7 @@ class CERES_EXPORT Solver {
// inner_iteration_ordering_given blank and asked for an automatic
// ordering, or if the problem contains some constant or inactive
// parameter blocks.
vector<int> inner_iteration_ordering_used;
std::vector<int> inner_iteration_ordering_used;
// Type of the preconditioner requested by the user.
PreconditionerType preconditioner_type_given;

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -157,7 +157,12 @@ enum SparseLinearAlgebraLibraryType {
// Eigen's sparse linear algebra routines. In particular Ceres uses
// the Simplicial LDLT routines.
EIGEN_SPARSE
EIGEN_SPARSE,
// No sparse linear solver should be used. This does not necessarily
// imply that Ceres was built without any sparse library, although that
// is the likely use case, merely that one should not be used.
NO_SPARSE
};
enum DenseLinearAlgebraLibraryType {
@@ -392,9 +397,19 @@ enum DimensionType {
DYNAMIC = -1
};
enum NumericDiffMethod {
// The differentiation method used to compute numerical derivatives in
// NumericDiffCostFunction and DynamicNumericDiffCostFunction.
enum NumericDiffMethodType {
// Compute central finite difference: f'(x) ~ (f(x+h) - f(x-h)) / 2h.
CENTRAL,
FORWARD
// Compute forward finite difference: f'(x) ~ (f(x+h) - f(x)) / h.
FORWARD,
// Adaptive numerical differentiation using Ridders' method. Provides more
// accurate and robust derivatives at the expense of additional cost
// function evaluations.
RIDDERS
};
enum LineSearchInterpolationType {
@@ -411,67 +426,73 @@ enum CovarianceAlgorithmType {
CERES_EXPORT const char* LinearSolverTypeToString(
LinearSolverType type);
CERES_EXPORT bool StringToLinearSolverType(string value,
CERES_EXPORT bool StringToLinearSolverType(std::string value,
LinearSolverType* type);
CERES_EXPORT const char* PreconditionerTypeToString(PreconditionerType type);
CERES_EXPORT bool StringToPreconditionerType(string value,
CERES_EXPORT bool StringToPreconditionerType(std::string value,
PreconditionerType* type);
CERES_EXPORT const char* VisibilityClusteringTypeToString(
VisibilityClusteringType type);
CERES_EXPORT bool StringToVisibilityClusteringType(string value,
CERES_EXPORT bool StringToVisibilityClusteringType(std::string value,
VisibilityClusteringType* type);
CERES_EXPORT const char* SparseLinearAlgebraLibraryTypeToString(
SparseLinearAlgebraLibraryType type);
CERES_EXPORT bool StringToSparseLinearAlgebraLibraryType(
string value,
std::string value,
SparseLinearAlgebraLibraryType* type);
CERES_EXPORT const char* DenseLinearAlgebraLibraryTypeToString(
DenseLinearAlgebraLibraryType type);
CERES_EXPORT bool StringToDenseLinearAlgebraLibraryType(
string value,
std::string value,
DenseLinearAlgebraLibraryType* type);
CERES_EXPORT const char* TrustRegionStrategyTypeToString(
TrustRegionStrategyType type);
CERES_EXPORT bool StringToTrustRegionStrategyType(string value,
CERES_EXPORT bool StringToTrustRegionStrategyType(std::string value,
TrustRegionStrategyType* type);
CERES_EXPORT const char* DoglegTypeToString(DoglegType type);
CERES_EXPORT bool StringToDoglegType(string value, DoglegType* type);
CERES_EXPORT bool StringToDoglegType(std::string value, DoglegType* type);
CERES_EXPORT const char* MinimizerTypeToString(MinimizerType type);
CERES_EXPORT bool StringToMinimizerType(string value, MinimizerType* type);
CERES_EXPORT bool StringToMinimizerType(std::string value, MinimizerType* type);
CERES_EXPORT const char* LineSearchDirectionTypeToString(
LineSearchDirectionType type);
CERES_EXPORT bool StringToLineSearchDirectionType(string value,
CERES_EXPORT bool StringToLineSearchDirectionType(std::string value,
LineSearchDirectionType* type);
CERES_EXPORT const char* LineSearchTypeToString(LineSearchType type);
CERES_EXPORT bool StringToLineSearchType(string value, LineSearchType* type);
CERES_EXPORT bool StringToLineSearchType(std::string value, LineSearchType* type);
CERES_EXPORT const char* NonlinearConjugateGradientTypeToString(
NonlinearConjugateGradientType type);
CERES_EXPORT bool StringToNonlinearConjugateGradientType(
string value,
std::string value,
NonlinearConjugateGradientType* type);
CERES_EXPORT const char* LineSearchInterpolationTypeToString(
LineSearchInterpolationType type);
CERES_EXPORT bool StringToLineSearchInterpolationType(
string value,
std::string value,
LineSearchInterpolationType* type);
CERES_EXPORT const char* CovarianceAlgorithmTypeToString(
CovarianceAlgorithmType type);
CERES_EXPORT bool StringToCovarianceAlgorithmType(
string value,
std::string value,
CovarianceAlgorithmType* type);
CERES_EXPORT const char* NumericDiffMethodTypeToString(
NumericDiffMethodType type);
CERES_EXPORT bool StringToNumericDiffMethodType(
std::string value,
NumericDiffMethodType* type);
CERES_EXPORT const char* TerminationTypeToString(TerminationType type);
CERES_EXPORT bool IsSchurType(LinearSolverType type);

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2014 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -32,9 +32,8 @@
#define CERES_PUBLIC_VERSION_H_
#define CERES_VERSION_MAJOR 1
#define CERES_VERSION_MINOR 10
#define CERES_VERSION_MINOR 11
#define CERES_VERSION_REVISION 0
#define CERES_VERSION_ABI 1
// Classic CPP stringifcation; the extra level of indirection allows the
// preprocessor to expand the macro before being converted to a string.

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -41,6 +41,8 @@
namespace ceres {
namespace internal {
using std::string;
// It is a near impossibility that user code generates this exact
// value in normal operation, thus we will use it to fill arrays
// before passing them to user code. If on return an element of the
@@ -71,7 +73,7 @@ int FindInvalidValue(const int size, const double* x) {
}
return size;
};
}
void InvalidateArray(const int size, double* x) {
if (x != NULL) {

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -43,6 +43,7 @@
#ifndef CERES_INTERNAL_ARRAY_UTILS_H_
#define CERES_INTERNAL_ARRAY_UTILS_H_
#include <string>
#include "ceres/internal/port.h"
namespace ceres {
@@ -63,7 +64,7 @@ int FindInvalidValue(const int size, const double* x);
// Utility routine to print an array of doubles to a string. If the
// array pointer is NULL, it is treated as an array of zeros.
void AppendArrayToString(const int size, const double* x, string* result);
void AppendArrayToString(const int size, const double* x, std::string* result);
extern const double kImpossibleValue;

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2013 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -32,6 +32,7 @@
#include "ceres/internal/port.h"
#include "glog/logging.h"
#ifndef CERES_NO_LAPACK
extern "C" void dsyrk_(char* uplo,
char* trans,
int* n,
@@ -42,6 +43,7 @@ extern "C" void dsyrk_(char* uplo,
double* beta,
double* c,
int* ldc);
#endif
namespace ceres {
namespace internal {

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2013 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -43,7 +43,7 @@ namespace internal {
BlockJacobiPreconditioner::BlockJacobiPreconditioner(
const BlockSparseMatrix& A) {
const CompressedRowBlockStructure* bs = A.block_structure();
vector<int> blocks(bs->cols.size());
std::vector<int> blocks(bs->cols.size());
for (int i = 0; i < blocks.size(); ++i) {
blocks[i] = bs->cols[i].size;
}
@@ -60,7 +60,7 @@ bool BlockJacobiPreconditioner::UpdateImpl(const BlockSparseMatrix& A,
m_->SetZero();
for (int i = 0; i < bs->rows.size(); ++i) {
const int row_block_size = bs->rows[i].block.size;
const vector<Cell>& cells = bs->rows[i].cells;
const std::vector<Cell>& cells = bs->rows[i].cells;
for (int j = 0; j < cells.size(); ++j) {
const int block_id = cells[j].block_id;
const int col_block_size = bs->cols[block_id].size;

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2014 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -41,6 +41,9 @@
namespace ceres {
namespace internal {
using std::vector;
namespace {
// Given the residual block ordering, build a lookup table to determine which
@@ -163,8 +166,7 @@ SparseMatrix* BlockJacobianWriter::CreateJacobian() const {
}
// Construct the cells in each row.
const vector<ResidualBlock*>& residual_blocks =
program_->residual_blocks();
const vector<ResidualBlock*>& residual_blocks = program_->residual_blocks();
int row_block_position = 0;
bs->rows.resize(residual_blocks.size());
for (int i = 0; i < residual_blocks.size(); ++i) {

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -115,10 +115,10 @@ class BlockJacobianWriter {
//
// which indicates that dr/dx is located at values_[0], and dr/dz is at
// values_[12]. See BlockEvaluatePreparer::Prepare()'s comments about 'j'.
vector<int*> jacobian_layout_;
std::vector<int*> jacobian_layout_;
// The pointers in jacobian_layout_ point directly into this vector.
vector<int> jacobian_layout_storage_;
std::vector<int> jacobian_layout_storage_;
};
} // namespace internal

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -39,7 +39,7 @@ namespace ceres {
namespace internal {
BlockRandomAccessDenseMatrix::BlockRandomAccessDenseMatrix(
const vector<int>& blocks) {
const std::vector<int>& blocks) {
const int num_blocks = blocks.size();
block_layout_.resize(num_blocks, 0);
num_rows_ = 0;

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -56,7 +56,7 @@ class BlockRandomAccessDenseMatrix : public BlockRandomAccessMatrix {
public:
// blocks is a vector of block sizes. The resulting matrix has
// blocks.size() * blocks.size() cells.
explicit BlockRandomAccessDenseMatrix(const vector<int>& blocks);
explicit BlockRandomAccessDenseMatrix(const std::vector<int>& blocks);
// The destructor is not thread safe. It assumes that no one is
// modifying any cells when the matrix is being destroyed.
@@ -85,7 +85,7 @@ class BlockRandomAccessDenseMatrix : public BlockRandomAccessMatrix {
private:
int num_rows_;
vector<int> block_layout_;
std::vector<int> block_layout_;
scoped_array<double> values_;
scoped_array<CellInfo> cell_infos_;

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2013 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -45,6 +45,8 @@
namespace ceres {
namespace internal {
using std::vector;
// TODO(sameeragarwal): Drop the dependence on TripletSparseMatrix.
BlockRandomAccessDiagonalMatrix::BlockRandomAccessDiagonalMatrix(

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2013 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -52,7 +52,7 @@ namespace internal {
class BlockRandomAccessDiagonalMatrix : public BlockRandomAccessMatrix {
public:
// blocks is an array of block sizes.
explicit BlockRandomAccessDiagonalMatrix(const vector<int>& blocks);
explicit BlockRandomAccessDiagonalMatrix(const std::vector<int>& blocks);
// The destructor is not thread safe. It assumes that no one is
// modifying any cells when the matrix is being destroyed.
@@ -85,8 +85,8 @@ class BlockRandomAccessDiagonalMatrix : public BlockRandomAccessMatrix {
private:
// row/column block sizes.
const vector<int> blocks_;
vector<CellInfo*> layout_;
const std::vector<int> blocks_;
std::vector<CellInfo*> layout_;
// The underlying matrix object which actually stores the cells.
scoped_ptr<TripletSparseMatrix> tsm_;

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -44,6 +44,11 @@
namespace ceres {
namespace internal {
using std::make_pair;
using std::pair;
using std::set;
using std::vector;
BlockRandomAccessSparseMatrix::BlockRandomAccessSparseMatrix(
const vector<int>& blocks,
const set<pair<int, int> >& block_pairs)

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -57,8 +57,9 @@ class BlockRandomAccessSparseMatrix : public BlockRandomAccessMatrix {
// blocks is an array of block sizes. block_pairs is a set of
// <row_block_id, col_block_id> pairs to identify the non-zero cells
// of this matrix.
BlockRandomAccessSparseMatrix(const vector<int>& blocks,
const set<pair<int, int> >& block_pairs);
BlockRandomAccessSparseMatrix(
const std::vector<int>& blocks,
const std::set<std::pair<int, int> >& block_pairs);
// The destructor is not thread safe. It assumes that no one is
// modifying any cells when the matrix is being destroyed.
@@ -103,8 +104,8 @@ class BlockRandomAccessSparseMatrix : public BlockRandomAccessMatrix {
const int64 kMaxRowBlocks;
// row/column block sizes.
const vector<int> blocks_;
vector<int> block_positions_;
const std::vector<int> blocks_;
std::vector<int> block_positions_;
// A mapping from <row_block_id, col_block_id> to the position in
// the values array of tsm_ where the block is stored.
@@ -114,7 +115,7 @@ class BlockRandomAccessSparseMatrix : public BlockRandomAccessMatrix {
// In order traversal of contents of the matrix. This allows us to
// implement a matrix-vector which is 20% faster than using the
// iterator in the Layout object instead.
vector<pair<pair<int, int>, double*> > cell_values_;
std::vector<std::pair<std::pair<int, int>, double*> > cell_values_;
// The underlying matrix object which actually stores the cells.
scoped_ptr<TripletSparseMatrix> tsm_;

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -42,6 +42,8 @@
namespace ceres {
namespace internal {
using std::vector;
BlockSparseMatrix::~BlockSparseMatrix() {}
BlockSparseMatrix::BlockSparseMatrix(
@@ -82,7 +84,7 @@ BlockSparseMatrix::BlockSparseMatrix(
}
void BlockSparseMatrix::SetZero() {
fill(values_.get(), values_.get() + num_nonzeros_, 0.0);
std::fill(values_.get(), values_.get() + num_nonzeros_, 0.0);
}
void BlockSparseMatrix::RightMultiply(const double* x, double* y) const {

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -71,20 +71,20 @@ bool CellLessThan(const Cell& lhs, const Cell& rhs);
struct CompressedList {
Block block;
vector<Cell> cells;
std::vector<Cell> cells;
};
typedef CompressedList CompressedRow;
typedef CompressedList CompressedColumn;
struct CompressedRowBlockStructure {
vector<Block> cols;
vector<CompressedRow> rows;
std::vector<Block> cols;
std::vector<CompressedRow> rows;
};
struct CompressedColumnBlockStructure {
vector<Block> rows;
vector<CompressedColumn> cols;
std::vector<Block> rows;
std::vector<CompressedColumn> cols;
};
} // namespace internal

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2013 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2014 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -37,6 +37,8 @@
namespace ceres {
namespace internal {
using std::string;
StateUpdatingCallback::StateUpdatingCallback(Program* program,
double* parameters)
: program_(program), parameters_(parameters) {}
@@ -78,27 +80,27 @@ CallbackReturnType LoggingCallback::operator()(
summary.cumulative_time_in_seconds);
} else if (minimizer_type == TRUST_REGION) {
if (summary.iteration == 0) {
output = "iter cost cost_change |gradient| |step| tr_ratio tr_radius ls_iter iter_time total_time\n";
output = "iter cost cost_change |gradient| |step| tr_ratio tr_radius ls_iter iter_time total_time\n"; // NOLINT
}
const char* kReportRowFormat =
"% 4d % 8e % 3.2e % 3.2e % 3.2e % 3.2e % 3.2e % 4d % 3.2e % 3.2e";
"% 4d % 8e % 3.2e % 3.2e % 3.2e % 3.2e % 3.2e % 4d % 3.2e % 3.2e"; // NOLINT
output += StringPrintf(kReportRowFormat,
summary.iteration,
summary.cost,
summary.cost_change,
summary.gradient_max_norm,
summary.step_norm,
summary.relative_decrease,
summary.trust_region_radius,
summary.linear_solver_iterations,
summary.iteration_time_in_seconds,
summary.cumulative_time_in_seconds);
summary.iteration,
summary.cost,
summary.cost_change,
summary.gradient_max_norm,
summary.step_norm,
summary.relative_decrease,
summary.trust_region_radius,
summary.linear_solver_iterations,
summary.iteration_time_in_seconds,
summary.cumulative_time_in_seconds);
} else {
LOG(FATAL) << "Unknown minimizer type.";
}
if (log_to_stdout_) {
cout << output << endl;
std::cout << output << std::endl;
} else {
VLOG(1) << output;
}

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2014 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -45,6 +45,8 @@
namespace ceres {
namespace internal {
using std::vector;
typedef HashMap<int, int> IntMap;
typedef HashSet<int> IntSet;

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -102,7 +102,7 @@ struct CanonicalViewsClusteringOptions;
void ComputeCanonicalViewsClustering(
const CanonicalViewsClusteringOptions& options,
const WeightedGraph<int>& graph,
vector<int>* centers,
std::vector<int>* centers,
HashMap<int, int>* membership);
struct CanonicalViewsClusteringOptions {

Some files were not shown because too many files have changed in this diff Show More