Compare commits

..

40 Commits

Author SHA1 Message Date
34498dbe56 Mod-bskin: Fix 0 radius hang out 2015-10-06 22:51:21 +07:00
ea5054ba5a Mob-bskin: Fix degenerate adjcent edges. Fix wrong winding order in cyclic cases. Fix wrong radius interpolation in cyclic cases 2015-10-06 22:15:36 +07:00
fbbfa43d75 Merge branch 'master' into mod-bskin 2015-10-04 15:16:29 +11:00
0dc3984924 Cleanup: warnings/style 2015-10-04 11:15:17 +11:00
344cf0ad24 Cleanup/warnings 2015-10-03 21:43:38 +10:00
01c1e6b9ff Merge branch 'master' into mod-bskin 2015-10-03 21:26:16 +10:00
e6bc4da2ad Bskin: Remove debug code 2015-10-02 22:26:35 +07:00
aacc54d533 Bskin: Reduce flickering at connection nodes. Add isolated mesh part support. Clean code 2015-10-02 22:00:04 +07:00
c216d345aa Merge branch 'master' into mod-bskin 2015-09-25 02:18:00 +10:00
112f665a43 Resolve minor issues for gcc 2015-09-25 02:17:46 +10:00
5bcdc5513b Mod_bskin:remove unused functions 2015-09-24 21:37:14 +07:00
a5646b2d5b Bskin: add ununiform scaling. add hole support. add bulging effect support at branch verts. reduce triangles at stiching region 2015-09-24 21:19:16 +07:00
96282b866d Correct for building with gcc 2015-09-16 14:23:15 +10:00
b7c2199583 Merge branch 'master' into mod-bskin 2015-09-16 14:12:53 +10:00
8324750899 Bskin: Add cyclic mesh support. Use RNG random generator instread rand. Some optimizations 2015-09-13 17:13:24 +07:00
0e8a3f8439 Revert "C:/Program Files (x86)/Git/*"
This reverts commit 2e5b5cc5f2.
2015-09-13 17:09:58 +07:00
2e5b5cc5f2 C:/Program Files (x86)/Git/* 2015-09-13 17:06:06 +07:00
c486ae82a5 Revert "Add cyclic mesh support. Use RNG random generator instead of rand. Disable subdivision level. Some optimizations"
This reverts commit 67c4ffcbef.
2015-09-13 16:54:36 +07:00
67c4ffcbef Add cyclic mesh support. Use RNG random generator instead of rand. Disable subdivision level. Some optimizations 2015-09-13 15:08:14 +07:00
0cb67c60fa Reduce MIN_VALENCE to 6 2015-09-13 15:00:01 +07:00
5a284e1b62 Merge branch 'master' into mod-bskin 2015-09-11 15:58:32 +10:00
3b10f500c2 Cleanup: warnings 2015-09-09 04:54:02 +10:00
0c275ea18a Fix large branch node assert. Clone amarture create, mark root, equalize radius from the old modifier 2015-09-07 21:50:49 +07:00
e54fb3f78f Build with GCC strict warnings 2015-09-07 02:27:26 +10:00
c73a009bfc Cleanup & build with gcc 2015-09-05 00:40:43 +10:00
38ed9107cd Merge branch 'master' into mod-bskin 2015-09-05 00:26:29 +10:00
e132af62e1 Fix incorrect convex hull building in case of plannar vertex set. Add some check 2015-09-04 20:56:59 +07:00
727b88fa67 Use priority queue for better triangle merging at branch nodes 2015-09-03 21:42:18 +07:00
8cd121ecaa Reduce quad resolution at skeleton limbs 2015-09-03 20:57:55 +07:00
129e0b8ab5 Reduce mesh resolution in the middle region of skeleton limbs 2015-09-03 20:54:15 +07:00
8e8aed9efa Cleanup: now warning free w/ GCC 2015-09-03 19:52:35 +10:00
d1640d5fab Quiet compiler warnings 2015-09-03 19:45:16 +10:00
913cfc4d1a Cleanup: style 2015-09-03 19:27:55 +10:00
39a437181c Quiet -Wdeclaration-after-statement warnings 2015-09-03 03:07:48 +10:00
06e61746f2 Merge branch 'master' into mod-bskin 2015-09-03 01:59:09 +10:00
0ddc05a07e Fix sphere projection while splitting polyhedra 2015-09-02 22:17:39 +07:00
2387e1629a fix flickering problem 2015-09-02 16:54:14 +07:00
5b02f8006a Add Python UI 2015-09-01 21:44:33 +10:00
a6409f3cb4 Minor changes needed for building on linux 2015-09-01 21:37:18 +10:00
36a9ae9c11 new skin modifier implementation, diff D1465 by @(khanh_ha 2015-09-01 21:24:35 +10:00
1073 changed files with 19301 additions and 23011 deletions

View File

@@ -511,11 +511,7 @@ if(APPLE)
endif()
execute_process(COMMAND uname -r OUTPUT_VARIABLE MAC_SYS) # check for actual system-version
if(${MAC_SYS} MATCHES 15)
set(OSX_SYSTEM 10.11)
# throw an error here, older cmake cannot handle 2 digit subversion!
cmake_minimum_required(VERSION 3.0.0)
elseif(${MAC_SYS} MATCHES 14)
if(${MAC_SYS} MATCHES 14)
set(OSX_SYSTEM 10.10)
# throw an error here, older cmake cannot handle 2 digit subversion!
cmake_minimum_required(VERSION 3.0.0)
@@ -532,11 +528,13 @@ if(APPLE)
else()
set(OSX_SYSTEM unsupported)
endif()
message(STATUS "Detected system-version: " ${OSX_SYSTEM})
# workaround for incorrect cmake xcode lookup for developer previews - XCODE_VERSION does not take xcode-select path into accout
# but would always look into /Applications/Xcode.app while dev versions are named Xcode<version>-DP<preview_number>
execute_process(COMMAND xcode-select --print-path OUTPUT_VARIABLE XCODE_CHECK OUTPUT_STRIP_TRAILING_WHITESPACE)
string(REPLACE "/Contents/Developer" "" XCODE_BUNDLE ${XCODE_CHECK}) # truncate to bundlepath in any case
message(STATUS "Xcode-bundle : " ${XCODE_BUNDLE})
if(${CMAKE_GENERATOR} MATCHES "Xcode")
@@ -564,8 +562,8 @@ if(APPLE)
string(SUBSTRING "${XCODE_VERS_BUILD_NR}" 6 3 XCODE_VERSION) # truncate away build-nr
unset(XCODE_VERS_BUILD_NR)
endif()
message(STATUS "Detected OS X ${OSX_SYSTEM} and Xcode ${XCODE_VERSION} at ${XCODE_BUNDLE}")
message(STATUS "Detected Xcode-version: " ${XCODE_VERSION})
if(${XCODE_VERSION} VERSION_LESS 4.3)
set(CMAKE_OSX_SYSROOT /Developer/SDKs/MacOSX${OSX_SYSTEM}.sdk CACHE PATH "" FORCE) # use guaranteed existing sdk
@@ -2326,7 +2324,6 @@ 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)
@@ -2334,12 +2331,6 @@ 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

@@ -331,10 +331,7 @@ if env['OURPLATFORM']=='darwin':
print B.bc.OKGREEN + "Available SDK's: \n" + B.bc.ENDC + MACOSX_SDK_CHECK.replace('\t', '')
if env['MACOSX_SDK'] == '': # no set sdk, choosing best one found
if 'OS X 10.11' in MACOSX_SDK_CHECK:
env['MACOSX_DEPLOYMENT_TARGET'] = '10.6'
env['MACOSX_SDK']='/Developer/SDKs/MacOSX10.11.sdk'
elif 'OS X 10.10' in MACOSX_SDK_CHECK:
if 'OS X 10.10' in MACOSX_SDK_CHECK:
env['MACOSX_DEPLOYMENT_TARGET'] = '10.6'
env['MACOSX_SDK']='/Developer/SDKs/MacOSX10.10.sdk'
elif 'OS X 10.9' in MACOSX_SDK_CHECK:

View File

@@ -2,5 +2,4 @@ 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 = []
BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_20', 'sm_21', 'sm_30', 'sm_35', 'sm_50', 'sm_52']

View File

@@ -1,5 +1,5 @@
#CC = "../lib/darwin-9.x.universal/clang-omp-3.5/bin/clang"
#CXX = "../lib/darwin-9.x.universal/clang-omp-3.5/bin/clang++"
CC = "../lib/darwin-9.x.universal/clang-omp-3.5/bin/clang"
CXX = "../lib/darwin-9.x.universal/clang-omp-3.5/bin/clang++"
MACOSX_ARCHITECTURE = 'x86_64' # valid archs: ppc, i386, ppc64, x86_64

View File

@@ -52,10 +52,7 @@ if 'cmake' in builder:
cmake_options.append(['-G', '"Visual Studio 12 2013"'])
cmake_options.append("-C../blender.git/build_files/cmake/config/blender_full.cmake")
if 'win32' not in builder:
cmake_options.append("-DWITH_CYCLES_CUDA_BINARIES=1")
else:
cmake_options.append("-DWITH_CYCLES_CUDA_BINARIES=0")
cmake_options.append("-DWITH_CYCLES_CUDA_BINARIES=1")
# configure and make
retcode = subprocess.call(['cmake', blender_dir] + cmake_options)
if retcode != 0:

View File

@@ -12,7 +12,7 @@ if(EXISTS ${SOURCE_DIR}/.git)
# The FindGit.cmake module is part of the standard distribution
find_package(Git)
if(GIT_FOUND)
message(STATUS "Found Git: ${GIT_EXECUTABLE}")
message(STATUS "-- Found Git: ${GIT_EXECUTABLE}")
execute_process(COMMAND git rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${SOURCE_DIR}

View File

@@ -50,8 +50,6 @@ 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()
@@ -209,8 +207,8 @@ def create_nb_project_main():
build_cmd = "${MAKE} -f Makefile"
clean_cmd = "${MAKE} -f Makefile clean"
f.write(' <buildCommand>%s</buildCommand>\n' % escape(build_cmd))
f.write(' <cleanCommand>%s</cleanCommand>\n' % escape(clean_cmd))
f.write(' <buildCommand>%s</buildCommand>\n' % build_cmd)
f.write(' <cleanCommand>%s</cleanCommand>\n' % clean_cmd)
f.write(' <executablePath>./bin/blender</executablePath>\n')
del build_cmd, clean_cmd
@@ -221,7 +219,7 @@ def create_nb_project_main():
f.write(' </incDir>\n')
f.write(' <preprocessorList>\n')
for cdef in defines:
f.write(' <Elem>%s</Elem>\n' % escape(cdef))
f.write(' <Elem>%s</Elem>\n' % cdef)
f.write(' </preprocessorList>\n')
f.write(' <cTool>\n')

View File

@@ -48,6 +48,7 @@ set(WITH_OPENCOLORIO OFF CACHE BOOL "" FORCE)
set(WITH_OPENIMAGEIO OFF CACHE BOOL "" FORCE)
set(WITH_OPENMP OFF CACHE BOOL "" FORCE)
set(WITH_OPENNL OFF CACHE BOOL "" FORCE)
set(WITH_PYTHON_INSTALL OFF CACHE BOOL "" FORCE)
set(WITH_RAYOPTIMIZATION OFF CACHE BOOL "" FORCE)
set(WITH_SDL OFF CACHE BOOL "" FORCE)
set(WITH_X11_XINPUT OFF CACHE BOOL "" FORCE)

View File

@@ -212,8 +212,6 @@ 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}")
@@ -231,13 +229,10 @@ 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()
@@ -474,8 +469,7 @@ endfunction()
function(SETUP_BLENDER_SORTED_LIBS)
# get_property(BLENDER_LINK_LIBS GLOBAL PROPERTY BLENDER_LINK_LIBS)
set(BLENDER_LINK_LIBS)
get_property(BLENDER_LINK_LIBS GLOBAL PROPERTY BLENDER_LINK_LIBS)
list(APPEND BLENDER_LINK_LIBS
bf_windowmanager

View File

@@ -23,7 +23,7 @@ set(MY_WC_HASH "unknown")
if(EXISTS ${CMAKE_SOURCE_DIR}/.git/)
find_package(Git)
if(GIT_FOUND)
message(STATUS "Found Git: ${GIT_EXECUTABLE}")
message(STATUS "-- Found Git: ${GIT_EXECUTABLE}")
execute_process(COMMAND git rev-parse --short HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE MY_WC_HASH
@@ -37,8 +37,7 @@ unset(MY_WC_HASH)
# Force Package Name
execute_process(COMMAND date "+%Y%m%d" OUTPUT_VARIABLE CPACK_DATE OUTPUT_STRIP_TRAILING_WHITESPACE)
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})
set(CPACK_PACKAGE_FILE_NAME ${PROJECT_NAME}-${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}-git${CPACK_DATE}.${BUILD_REV}-${CMAKE_SYSTEM_PROCESSOR})
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
# RPM packages
@@ -74,7 +73,6 @@ 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

@@ -796,8 +796,6 @@ def AppIt(target=None, source=None, env=None):
commands.getoutput(cmd)
cmd = 'cp -R %s/release/site-packages/ %s/%s.app/Contents/Resources/%s/python/lib/python%s/site-packages/'%(libdir,installdir,binary,VERSION,env['BF_PYTHON_VERSION'])
commands.getoutput(cmd)
cmd = 'cp -r %s/python/bin -d %s/%s.app/Contents/Resources/%s/python/'%(libdir,installdir,binary,VERSION)
commands.getoutput(cmd)
cmd = 'chmod +x %s/%s.app/Contents/MacOS/%s'%(installdir,binary, binary)
commands.getoutput(cmd)

View File

@@ -1,192 +0,0 @@
# 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

@@ -25,7 +25,7 @@ base class --- :class:`PyObjectPlus`
The maximum number of jumps a character can perform before having to touch the ground. By default this is set to 1. 2 allows for a double jump, etc.
:type: int in [0, 255], default 1
:type: int
.. attribute:: jumpCount

View File

@@ -799,7 +799,7 @@ base class --- :class:`SCA_IObject`
:return: the first object hit or None if no object or object does not match prop
:rtype: :class:`KX_GameObject`
.. method:: rayCast(objto, objfrom, dist, prop, face, xray, poly, mask)
.. method:: rayCast(objto, objfrom, dist, prop, face, xray, poly)
Look from a point/object to another point/object and find first object hit within dist that matches prop.
if poly is 0, returns a 3-tuple with object reference, hit point and hit normal or (None, None, None) if no hit.
@@ -851,8 +851,6 @@ base class --- :class:`SCA_IObject`
* 2: return value is a 5-tuple and the 5th element is a 2-tuple (u, v) with the UV mapping of the hit point or None if no hit, or the object doesn't use a mesh collision shape, or doesn't have a UV mapping.
:type poly: integer
:arg mask: collision mask: The collision mask (16 layers mapped to a 16-bit integer) is combined with each object's collision group, to hit only a subset of the objects in the scene. Only those objects for which ``collisionGroup & mask`` is true can be hit.
:type mask: bitfield
:return: (object, hitpoint, hitnormal) or (object, hitpoint, hitnormal, polygon) or (object, hitpoint, hitnormal, polygon, hituv).
* object, hitpoint and hitnormal are None if no hit.

View File

@@ -0,0 +1,65 @@
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,12 +25,6 @@ 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

@@ -63,17 +63,17 @@ base class --- :class:`PyObjectPlus`
The color of the mist. Black = [0.0, 0.0, 0.0], White = [1.0, 1.0, 1.0].
Mist and background color sould always set to the same color.
:type: :class:`mathutils.Color`
:type: :class:`mathutils.Vector`
.. attribute:: backgroundColor
The color of the background. Black = [0.0, 0.0, 0.0], White = [1.0, 1.0, 1.0].
Mist and background color sould always set to the same color.
:type: :class:`mathutils.Color`
:type: :class:`mathutils.Vector`
.. attribute:: ambientColor
The color of the ambient light. Black = [0.0, 0.0, 0.0], White = [1.0, 1.0, 1.0].
:type: :class:`mathutils.Color`
:type: :class:`mathutils.Vector`

View File

@@ -277,12 +277,6 @@ 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 importlib
import imp
importlib.reload(myscript)
imp.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 importlib
importlib.reload(myscript)
import imp
imp.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,9 +163,6 @@ 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,7 +261,6 @@ else:
"bpy.utils.previews",
"bpy_extras",
"gpu",
"gpu.offscreen",
"mathutils",
"mathutils.geometry",
"mathutils.bvhtree",
@@ -1660,9 +1659,7 @@ def write_rst_contents(basepath):
# mathutils
"mathutils", "mathutils.geometry", "mathutils.bvhtree", "mathutils.kdtree", "mathutils.noise",
# misc
"freestyle", "bgl", "blf",
"gpu", "gpu.offscreen",
"aud", "bpy_extras",
"freestyle", "bgl", "blf", "gpu", "aud", "bpy_extras",
# bmesh, submodules are in own page
"bmesh",
)
@@ -1802,7 +1799,6 @@ 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,10 +18,8 @@ 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
@@ -54,7 +52,7 @@ SPHINXBASE=doc/python_api
if $DO_EXE_BLENDER ; then
# dont delete existing docs, now partial updates are used for quick builds.
$BLENDER_BIN --background -noaudio --factory-startup --python $SPHINXBASE/sphinx_doc_gen.py
$BLENDER --background -noaudio --factory-startup --python $SPHINXBASE/sphinx_doc_gen.py
fi

View File

@@ -34,14 +34,8 @@ set(SRC
eigen3_capi.h
intern/eigenvalues.cc
intern/svd.cc
intern/eigenvalues.h
intern/svd.h
)
set(LIB
)
blender_add_lib(extern_eigen3 "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
blender_add_lib(extern_eigen3 "${SRC}" "${INC}" "${INC_SYS}")

View File

@@ -28,6 +28,5 @@
#define __EIGEN3_C_API_H__
#include "intern/eigenvalues.h"
#include "intern/svd.h"
#endif /* __EIGEN3_C_API_H__ */

View File

@@ -1,72 +0,0 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2015 Blender Foundation.
* All rights reserved.
*
* Contributor(s): Blender Foundation,
* Bastien Montagne
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef __EIGEN3_SVD_C_API_CC__
#define __EIGEN3_SVD_C_API_CC__
/* Eigen gives annoying huge amount of warnings here, silence them! */
#ifdef __GNUC__
# pragma GCC diagnostic ignored "-Wlogical-op"
#endif
#include <Eigen/Core>
#include <Eigen/SVD>
#include "svd.h"
using Eigen::JacobiSVD;
using Eigen::NoQRPreconditioner;
using Eigen::ComputeThinU;
using Eigen::ComputeThinV;
using Eigen::MatrixXf;
using Eigen::VectorXf;
using Eigen::Map;
void EG3_svd_square_matrix(const int size, const float *matrix, float *r_U, float *r_S, float *r_V)
{
/* Since our matrix is squared, we can use thinU/V. */
unsigned int flags = (r_U ? ComputeThinU : 0) | (r_V ? ComputeThinV : 0);
/* Blender and Eigen matrices are both column-major. */
JacobiSVD<MatrixXf, NoQRPreconditioner> svd(Map<MatrixXf>((float *)matrix, size, size), flags);
if (r_U) {
Map<MatrixXf>(r_U, size, size) = svd.matrixU();
}
if (r_S) {
Map<VectorXf>(r_S, size) = svd.singularValues();
}
if (r_V) {
Map<MatrixXf>(r_V, size, size) = svd.matrixV();
}
}
#endif /* __EIGEN3_SVD_C_API_CC__ */

View File

@@ -1,40 +0,0 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2015 Blender Foundation.
* All rights reserved.
*
* Contributor(s): Blender Foundation,
* Bastien Montagne
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef __EIGEN3_SVD_C_API_H__
#define __EIGEN3_SVD_C_API_H__
#ifdef __cplusplus
extern "C" {
#endif
void EG3_svd_square_matrix(const int size, const float *matrix, float *r_U, float *r_S, float *r_V);
#ifdef __cplusplus
}
#endif
#endif /* __EIGEN3_SVD_C_API_H__ */

View File

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

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}" "${LIB}")
blender_add_lib(extern_bullet "${SRC}" "${INC}" "${INC_SYS}")

View File

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

View File

@@ -37,10 +37,6 @@ 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}" "${LIB}")
blender_add_lib(extern_clew "${SRC}" "${INC}" "${INC_SYS}")

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
@@ -2781,7 +2781,7 @@ CLEW_FUN_EXPORT PFNCLGETGLCONTEXTINFOKHR __clewGetGLContextInfoKH
#define CLEW_ERROR_ATEXIT_FAILED -2 //!< Error code for failing to queue the closing of the dynamic library to atexit()
//! \brief Load OpenCL dynamic library and set function entry points
int clewInit (void);
int clewInit ();
//! \brief Convert an OpenCL error code to its string equivalent
const char* clewErrorString (cl_int error);

View File

@@ -378,15 +378,5 @@ 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}" "${LIB}")
blender_add_lib(extern_colamd "${SRC}" "${INC}" "${INC_SYS}")

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,5 @@
/*
** The OpenGL Extension Wrangler Library
** Copyright (C) 2008-2015, Nigel Stewart <nigels[]users sourceforge net>
** Copyright (C) 2002-2008, Milan Ikits <milan ikits[]ieee org>
** Copyright (C) 2002-2008, Marcelo E. Magallon <mmagallo[]debian org>
** Copyright (C) 2002, Lev Povalahev
@@ -201,12 +200,12 @@ typedef Display* ( * PFNGLXGETCURRENTDISPLAYPROC) (void);
#ifndef GLX_VERSION_1_3
#define GLX_VERSION_1_3 1
#define GLX_FRONT_LEFT_BUFFER_BIT 0x00000001
#define GLX_RGBA_BIT 0x00000001
#define GLX_FRONT_LEFT_BUFFER_BIT 0x00000001
#define GLX_WINDOW_BIT 0x00000001
#define GLX_COLOR_INDEX_BIT 0x00000002
#define GLX_FRONT_RIGHT_BUFFER_BIT 0x00000002
#define GLX_PIXMAP_BIT 0x00000002
#define GLX_FRONT_RIGHT_BUFFER_BIT 0x00000002
#define GLX_BACK_LEFT_BUFFER_BIT 0x00000004
#define GLX_PBUFFER_BIT 0x00000004
#define GLX_BACK_RIGHT_BUFFER_BIT 0x00000008
@@ -387,19 +386,6 @@ typedef Bool ( * PFNGLXMAKEASSOCIATEDCONTEXTCURRENTAMDPROC) (GLXContext ctx);
#endif /* GLX_AMD_gpu_association */
/* --------------------- GLX_ARB_context_flush_control --------------------- */
#ifndef GLX_ARB_context_flush_control
#define GLX_ARB_context_flush_control 1
#define GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0x0000
#define GLX_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097
#define GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098
#define GLXEW_ARB_context_flush_control GLXEW_GET_VAR(__GLXEW_ARB_context_flush_control)
#endif /* GLX_ARB_context_flush_control */
/* ------------------------- GLX_ARB_create_context ------------------------ */
#ifndef GLX_ARB_create_context
@@ -451,8 +437,8 @@ typedef GLXContext ( * PFNGLXCREATECONTEXTATTRIBSARBPROC) (Display* dpy, GLXFBCo
#ifndef GLX_ARB_fbconfig_float
#define GLX_ARB_fbconfig_float 1
#define GLX_RGBA_FLOAT_BIT_ARB 0x00000004
#define GLX_RGBA_FLOAT_TYPE_ARB 0x20B9
#define GLX_RGBA_FLOAT_BIT 0x00000004
#define GLX_RGBA_FLOAT_TYPE 0x20B9
#define GLXEW_ARB_fbconfig_float GLXEW_GET_VAR(__GLXEW_ARB_fbconfig_float)
@@ -679,19 +665,6 @@ typedef int ( * PFNGLXQUERYCONTEXTINFOEXTPROC) (Display* dpy, GLXContext context
#endif /* GLX_EXT_scene_marker */
/* -------------------------- GLX_EXT_stereo_tree -------------------------- */
#ifndef GLX_EXT_stereo_tree
#define GLX_EXT_stereo_tree 1
#define GLX_STEREO_NOTIFY_EXT 0x00000000
#define GLX_STEREO_NOTIFY_MASK_EXT 0x00000001
#define GLX_STEREO_TREE_EXT 0x20F5
#define GLXEW_EXT_stereo_tree GLXEW_GET_VAR(__GLXEW_EXT_stereo_tree)
#endif /* GLX_EXT_stereo_tree */
/* -------------------------- GLX_EXT_swap_control ------------------------- */
#ifndef GLX_EXT_swap_control
@@ -858,38 +831,6 @@ typedef GLXPixmap ( * PFNGLXCREATEGLXPIXMAPMESAPROC) (Display* dpy, XVisualInfo
#endif /* GLX_MESA_pixmap_colormap */
/* ------------------------ GLX_MESA_query_renderer ------------------------ */
#ifndef GLX_MESA_query_renderer
#define GLX_MESA_query_renderer 1
#define GLX_RENDERER_VENDOR_ID_MESA 0x8183
#define GLX_RENDERER_DEVICE_ID_MESA 0x8184
#define GLX_RENDERER_VERSION_MESA 0x8185
#define GLX_RENDERER_ACCELERATED_MESA 0x8186
#define GLX_RENDERER_VIDEO_MEMORY_MESA 0x8187
#define GLX_RENDERER_UNIFIED_MEMORY_ARCHITECTURE_MESA 0x8188
#define GLX_RENDERER_PREFERRED_PROFILE_MESA 0x8189
#define GLX_RENDERER_OPENGL_CORE_PROFILE_VERSION_MESA 0x818A
#define GLX_RENDERER_OPENGL_COMPATIBILITY_PROFILE_VERSION_MESA 0x818B
#define GLX_RENDERER_OPENGL_ES_PROFILE_VERSION_MESA 0x818C
#define GLX_RENDERER_OPENGL_ES2_PROFILE_VERSION_MESA 0x818D
#define GLX_RENDERER_ID_MESA 0x818E
typedef Bool ( * PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC) (int attribute, unsigned int* value);
typedef const char* ( * PFNGLXQUERYCURRENTRENDERERSTRINGMESAPROC) (int attribute);
typedef Bool ( * PFNGLXQUERYRENDERERINTEGERMESAPROC) (Display* dpy, int screen, int renderer, int attribute, unsigned int *value);
typedef const char* ( * PFNGLXQUERYRENDERERSTRINGMESAPROC) (Display *dpy, int screen, int renderer, int attribute);
#define glXQueryCurrentRendererIntegerMESA GLXEW_GET_FUN(__glewXQueryCurrentRendererIntegerMESA)
#define glXQueryCurrentRendererStringMESA GLXEW_GET_FUN(__glewXQueryCurrentRendererStringMESA)
#define glXQueryRendererIntegerMESA GLXEW_GET_FUN(__glewXQueryRendererIntegerMESA)
#define glXQueryRendererStringMESA GLXEW_GET_FUN(__glewXQueryRendererStringMESA)
#define GLXEW_MESA_query_renderer GLXEW_GET_VAR(__GLXEW_MESA_query_renderer)
#endif /* GLX_MESA_query_renderer */
/* ------------------------ GLX_MESA_release_buffers ----------------------- */
#ifndef GLX_MESA_release_buffers
@@ -934,21 +875,6 @@ typedef int ( * PFNGLXSWAPINTERVALMESAPROC) (unsigned int interval);
#endif /* GLX_MESA_swap_control */
/* --------------------------- GLX_NV_copy_buffer -------------------------- */
#ifndef GLX_NV_copy_buffer
#define GLX_NV_copy_buffer 1
typedef void ( * PFNGLXCOPYBUFFERSUBDATANVPROC) (Display* dpy, GLXContext readCtx, GLXContext writeCtx, GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
typedef void ( * PFNGLXNAMEDCOPYBUFFERSUBDATANVPROC) (Display* dpy, GLXContext readCtx, GLXContext writeCtx, GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
#define glXCopyBufferSubDataNV GLXEW_GET_FUN(__glewXCopyBufferSubDataNV)
#define glXNamedCopyBufferSubDataNV GLXEW_GET_FUN(__glewXNamedCopyBufferSubDataNV)
#define GLXEW_NV_copy_buffer GLXEW_GET_VAR(__GLXEW_NV_copy_buffer)
#endif /* GLX_NV_copy_buffer */
/* --------------------------- GLX_NV_copy_image --------------------------- */
#ifndef GLX_NV_copy_image
@@ -962,19 +888,6 @@ typedef void ( * PFNGLXCOPYIMAGESUBDATANVPROC) (Display *dpy, GLXContext srcCtx,
#endif /* GLX_NV_copy_image */
/* ------------------------ GLX_NV_delay_before_swap ----------------------- */
#ifndef GLX_NV_delay_before_swap
#define GLX_NV_delay_before_swap 1
typedef Bool ( * PFNGLXDELAYBEFORESWAPNVPROC) (Display* dpy, GLXDrawable drawable, GLfloat seconds);
#define glXDelayBeforeSwapNV GLXEW_GET_FUN(__glewXDelayBeforeSwapNV)
#define GLXEW_NV_delay_before_swap GLXEW_GET_VAR(__GLXEW_NV_delay_before_swap)
#endif /* GLX_NV_delay_before_swap */
/* -------------------------- GLX_NV_float_buffer -------------------------- */
#ifndef GLX_NV_float_buffer
@@ -1080,10 +993,10 @@ typedef void ( * PFNGLXRELEASEVIDEOCAPTUREDEVICENVPROC) (Display* dpy, GLXVideoC
#endif /* GLX_NV_video_capture */
/* ---------------------------- GLX_NV_video_out --------------------------- */
/* -------------------------- GLX_NV_video_output -------------------------- */
#ifndef GLX_NV_video_out
#define GLX_NV_video_out 1
#ifndef GLX_NV_video_output
#define GLX_NV_video_output 1
#define GLX_VIDEO_OUT_COLOR_NV 0x20C3
#define GLX_VIDEO_OUT_ALPHA_NV 0x20C4
@@ -1110,9 +1023,9 @@ typedef int ( * PFNGLXSENDPBUFFERTOVIDEONVPROC) (Display* dpy, GLXPbuffer pbuf,
#define glXReleaseVideoImageNV GLXEW_GET_FUN(__glewXReleaseVideoImageNV)
#define glXSendPbufferToVideoNV GLXEW_GET_FUN(__glewXSendPbufferToVideoNV)
#define GLXEW_NV_video_out GLXEW_GET_VAR(__GLXEW_NV_video_out)
#define GLXEW_NV_video_output GLXEW_GET_VAR(__GLXEW_NV_video_output)
#endif /* GLX_NV_video_out */
#endif /* GLX_NV_video_output */
/* -------------------------- GLX_OML_swap_method -------------------------- */
@@ -1198,10 +1111,10 @@ typedef Bool ( * PFNGLXWAITFORSBCOMLPROC) (Display* dpy, GLXDrawable drawable, i
#ifndef GLX_SGIX_fbconfig
#define GLX_SGIX_fbconfig 1
#define GLX_RGBA_BIT_SGIX 0x00000001
#define GLX_WINDOW_BIT_SGIX 0x00000001
#define GLX_COLOR_INDEX_BIT_SGIX 0x00000002
#define GLX_RGBA_BIT_SGIX 0x00000001
#define GLX_PIXMAP_BIT_SGIX 0x00000002
#define GLX_COLOR_INDEX_BIT_SGIX 0x00000002
#define GLX_SCREEN_EXT 0x800C
#define GLX_DRAWABLE_TYPE_SGIX 0x8010
#define GLX_RENDER_TYPE_SGIX 0x8011
@@ -1238,8 +1151,8 @@ typedef XVisualInfo* ( * PFNGLXGETVISUALFROMFBCONFIGSGIXPROC) (Display *dpy, GLX
#define GLX_HYPERPIPE_DISPLAY_PIPE_SGIX 0x00000001
#define GLX_PIPE_RECT_SGIX 0x00000001
#define GLX_HYPERPIPE_RENDER_PIPE_SGIX 0x00000002
#define GLX_PIPE_RECT_LIMITS_SGIX 0x00000002
#define GLX_HYPERPIPE_RENDER_PIPE_SGIX 0x00000002
#define GLX_HYPERPIPE_STEREO_SGIX 0x00000003
#define GLX_HYPERPIPE_PIXEL_AVERAGE_SGIX 0x00000004
#define GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX 80
@@ -1305,8 +1218,8 @@ typedef GLXHyperpipeNetworkSGIX * ( * PFNGLXQUERYHYPERPIPENETWORKSGIXPROC) (Disp
#define GLX_FRONT_LEFT_BUFFER_BIT_SGIX 0x00000001
#define GLX_FRONT_RIGHT_BUFFER_BIT_SGIX 0x00000002
#define GLX_BACK_LEFT_BUFFER_BIT_SGIX 0x00000004
#define GLX_PBUFFER_BIT_SGIX 0x00000004
#define GLX_BACK_LEFT_BUFFER_BIT_SGIX 0x00000004
#define GLX_BACK_RIGHT_BUFFER_BIT_SGIX 0x00000008
#define GLX_AUX_BUFFERS_BIT_SGIX 0x00000010
#define GLX_DEPTH_BUFFER_BIT_SGIX 0x00000020
@@ -1560,11 +1473,6 @@ GLXEW_FUN_EXPORT PFNGLXCOPYSUBBUFFERMESAPROC __glewXCopySubBufferMESA;
GLXEW_FUN_EXPORT PFNGLXCREATEGLXPIXMAPMESAPROC __glewXCreateGLXPixmapMESA;
GLXEW_FUN_EXPORT PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC __glewXQueryCurrentRendererIntegerMESA;
GLXEW_FUN_EXPORT PFNGLXQUERYCURRENTRENDERERSTRINGMESAPROC __glewXQueryCurrentRendererStringMESA;
GLXEW_FUN_EXPORT PFNGLXQUERYRENDERERINTEGERMESAPROC __glewXQueryRendererIntegerMESA;
GLXEW_FUN_EXPORT PFNGLXQUERYRENDERERSTRINGMESAPROC __glewXQueryRendererStringMESA;
GLXEW_FUN_EXPORT PFNGLXRELEASEBUFFERSMESAPROC __glewXReleaseBuffersMESA;
GLXEW_FUN_EXPORT PFNGLXSET3DFXMODEMESAPROC __glewXSet3DfxModeMESA;
@@ -1572,13 +1480,8 @@ GLXEW_FUN_EXPORT PFNGLXSET3DFXMODEMESAPROC __glewXSet3DfxModeMESA;
GLXEW_FUN_EXPORT PFNGLXGETSWAPINTERVALMESAPROC __glewXGetSwapIntervalMESA;
GLXEW_FUN_EXPORT PFNGLXSWAPINTERVALMESAPROC __glewXSwapIntervalMESA;
GLXEW_FUN_EXPORT PFNGLXCOPYBUFFERSUBDATANVPROC __glewXCopyBufferSubDataNV;
GLXEW_FUN_EXPORT PFNGLXNAMEDCOPYBUFFERSUBDATANVPROC __glewXNamedCopyBufferSubDataNV;
GLXEW_FUN_EXPORT PFNGLXCOPYIMAGESUBDATANVPROC __glewXCopyImageSubDataNV;
GLXEW_FUN_EXPORT PFNGLXDELAYBEFORESWAPNVPROC __glewXDelayBeforeSwapNV;
GLXEW_FUN_EXPORT PFNGLXBINDVIDEODEVICENVPROC __glewXBindVideoDeviceNV;
GLXEW_FUN_EXPORT PFNGLXENUMERATEVIDEODEVICESNVPROC __glewXEnumerateVideoDevicesNV;
@@ -1671,7 +1574,6 @@ GLXEW_VAR_EXPORT GLboolean __GLXEW_VERSION_1_3;
GLXEW_VAR_EXPORT GLboolean __GLXEW_VERSION_1_4;
GLXEW_VAR_EXPORT GLboolean __GLXEW_3DFX_multisample;
GLXEW_VAR_EXPORT GLboolean __GLXEW_AMD_gpu_association;
GLXEW_VAR_EXPORT GLboolean __GLXEW_ARB_context_flush_control;
GLXEW_VAR_EXPORT GLboolean __GLXEW_ARB_create_context;
GLXEW_VAR_EXPORT GLboolean __GLXEW_ARB_create_context_profile;
GLXEW_VAR_EXPORT GLboolean __GLXEW_ARB_create_context_robustness;
@@ -1691,7 +1593,6 @@ GLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_fbconfig_packed_float;
GLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_framebuffer_sRGB;
GLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_import_context;
GLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_scene_marker;
GLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_stereo_tree;
GLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_swap_control;
GLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_swap_control_tear;
GLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_texture_from_pixmap;
@@ -1701,20 +1602,17 @@ GLXEW_VAR_EXPORT GLboolean __GLXEW_INTEL_swap_event;
GLXEW_VAR_EXPORT GLboolean __GLXEW_MESA_agp_offset;
GLXEW_VAR_EXPORT GLboolean __GLXEW_MESA_copy_sub_buffer;
GLXEW_VAR_EXPORT GLboolean __GLXEW_MESA_pixmap_colormap;
GLXEW_VAR_EXPORT GLboolean __GLXEW_MESA_query_renderer;
GLXEW_VAR_EXPORT GLboolean __GLXEW_MESA_release_buffers;
GLXEW_VAR_EXPORT GLboolean __GLXEW_MESA_set_3dfx_mode;
GLXEW_VAR_EXPORT GLboolean __GLXEW_MESA_swap_control;
GLXEW_VAR_EXPORT GLboolean __GLXEW_NV_copy_buffer;
GLXEW_VAR_EXPORT GLboolean __GLXEW_NV_copy_image;
GLXEW_VAR_EXPORT GLboolean __GLXEW_NV_delay_before_swap;
GLXEW_VAR_EXPORT GLboolean __GLXEW_NV_float_buffer;
GLXEW_VAR_EXPORT GLboolean __GLXEW_NV_multisample_coverage;
GLXEW_VAR_EXPORT GLboolean __GLXEW_NV_present_video;
GLXEW_VAR_EXPORT GLboolean __GLXEW_NV_swap_group;
GLXEW_VAR_EXPORT GLboolean __GLXEW_NV_vertex_array_range;
GLXEW_VAR_EXPORT GLboolean __GLXEW_NV_video_capture;
GLXEW_VAR_EXPORT GLboolean __GLXEW_NV_video_out;
GLXEW_VAR_EXPORT GLboolean __GLXEW_NV_video_output;
GLXEW_VAR_EXPORT GLboolean __GLXEW_OML_swap_method;
GLXEW_VAR_EXPORT GLboolean __GLXEW_OML_sync_control;
GLXEW_VAR_EXPORT GLboolean __GLXEW_SGIS_blended_overlay;
@@ -1755,12 +1653,11 @@ GLEWAPI GLboolean GLEWAPIENTRY glxewContextIsSupported (const GLXEWContext *ctx,
#else /* GLEW_MX */
GLEWAPI GLenum GLEWAPIENTRY glxewInit ();
GLEWAPI GLboolean GLEWAPIENTRY glxewIsSupported (const char *name);
#define GLXEW_GET_VAR(x) (*(const GLboolean*)&x)
#define GLXEW_GET_FUN(x) x
GLEWAPI GLboolean GLEWAPIENTRY glxewIsSupported (const char *name);
#endif /* GLEW_MX */
GLEWAPI GLboolean GLEWAPIENTRY glxewGetExtension (const char *name);

View File

@@ -1,6 +1,5 @@
/*
** The OpenGL Extension Wrangler Library
** Copyright (C) 2008-2015, Nigel Stewart <nigels[]users sourceforge net>
** Copyright (C) 2002-2008, Milan Ikits <milan ikits[]ieee org>
** Copyright (C) 2002-2008, Marcelo E. Magallon <mmagallo[]debian org>
** Copyright (C) 2002, Lev Povalahev
@@ -183,19 +182,6 @@ typedef BOOL (WINAPI * PFNWGLSAVEBUFFERREGIONARBPROC) (HANDLE hRegion, int x, in
#endif /* WGL_ARB_buffer_region */
/* --------------------- WGL_ARB_context_flush_control --------------------- */
#ifndef WGL_ARB_context_flush_control
#define WGL_ARB_context_flush_control 1
#define WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0x0000
#define WGL_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097
#define WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098
#define WGLEW_ARB_context_flush_control WGLEW_GET_VAR(__WGLEW_ARB_context_flush_control)
#endif /* WGL_ARB_context_flush_control */
/* ------------------------- WGL_ARB_create_context ------------------------ */
#ifndef WGL_ARB_create_context
@@ -942,19 +928,6 @@ typedef BOOL (WINAPI * PFNWGLCOPYIMAGESUBDATANVPROC) (HGLRC hSrcRC, GLuint srcNa
#endif /* WGL_NV_copy_image */
/* ------------------------ WGL_NV_delay_before_swap ----------------------- */
#ifndef WGL_NV_delay_before_swap
#define WGL_NV_delay_before_swap 1
typedef BOOL (WINAPI * PFNWGLDELAYBEFORESWAPNVPROC) (HDC hDC, GLfloat seconds);
#define wglDelayBeforeSwapNV WGLEW_GET_FUN(__wglewDelayBeforeSwapNV)
#define WGLEW_NV_delay_before_swap WGLEW_GET_VAR(__WGLEW_NV_delay_before_swap)
#endif /* WGL_NV_delay_before_swap */
/* -------------------------- WGL_NV_float_buffer -------------------------- */
#ifndef WGL_NV_float_buffer
@@ -1318,8 +1291,6 @@ WGLEW_FUN_EXPORT PFNWGLDXUNREGISTEROBJECTNVPROC __wglewDXUnregisterObjectNV;
WGLEW_FUN_EXPORT PFNWGLCOPYIMAGESUBDATANVPROC __wglewCopyImageSubDataNV;
WGLEW_FUN_EXPORT PFNWGLDELAYBEFORESWAPNVPROC __wglewDelayBeforeSwapNV;
WGLEW_FUN_EXPORT PFNWGLCREATEAFFINITYDCNVPROC __wglewCreateAffinityDCNV;
WGLEW_FUN_EXPORT PFNWGLDELETEDCNVPROC __wglewDeleteDCNV;
WGLEW_FUN_EXPORT PFNWGLENUMGPUDEVICESNVPROC __wglewEnumGpuDevicesNV;
@@ -1363,7 +1334,6 @@ WGLEW_VAR_EXPORT GLboolean __WGLEW_3DFX_multisample;
WGLEW_VAR_EXPORT GLboolean __WGLEW_3DL_stereo_control;
WGLEW_VAR_EXPORT GLboolean __WGLEW_AMD_gpu_association;
WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_buffer_region;
WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_context_flush_control;
WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_create_context;
WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_create_context_profile;
WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_create_context_robustness;
@@ -1401,7 +1371,6 @@ WGLEW_VAR_EXPORT GLboolean __WGLEW_I3D_swap_frame_usage;
WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_DX_interop;
WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_DX_interop2;
WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_copy_image;
WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_delay_before_swap;
WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_float_buffer;
WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_gpu_affinity;
WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_multisample_coverage;
@@ -1434,12 +1403,11 @@ GLEWAPI GLboolean GLEWAPIENTRY wglewContextIsSupported (const WGLEWContext *ctx,
#else /* GLEW_MX */
GLEWAPI GLenum GLEWAPIENTRY wglewInit ();
GLEWAPI GLboolean GLEWAPIENTRY wglewIsSupported (const char *name);
#define WGLEW_GET_VAR(x) (*(const GLboolean*)&x)
#define WGLEW_GET_FUN(x) x
GLEWAPI GLboolean GLEWAPIENTRY wglewIsSupported (const char *name);
#endif /* GLEW_MX */
GLEWAPI GLboolean GLEWAPIENTRY wglewGetExtension (const char *name);

4848
extern/glew/src/glew.c vendored

File diff suppressed because it is too large Load Diff

View File

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

View File

@@ -72,11 +72,6 @@ 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)
@@ -224,7 +219,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")
@@ -264,8 +259,7 @@ else()
)
endif()
blender_add_lib(extern_libmv "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
unset(LIB)
blender_add_lib(extern_libmv "${SRC}" "${INC}" "${INC_SYS}")
if(WITH_LIBMV)
add_subdirectory(third_party)
@@ -351,5 +345,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

@@ -61,8 +61,7 @@ class ArrayND : public BaseArray {
Resize(s0, s1, s2);
}
ArrayND(T* data, int s0, int s1, int s2)
: shape_(0), strides_(0), data_(data), own_data_(false) {
ArrayND(T* data, int s0, int s1, int s2) : data_(data), own_data_(false) {
Resize(s0, s1, s2);
}

View File

@@ -80,6 +80,7 @@ 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
@@ -208,6 +209,7 @@ 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
@@ -268,7 +270,6 @@ 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
@@ -287,7 +288,6 @@ 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}" "${LIB}")
blender_add_lib(extern_ceres "${SRC}" "${INC}" "${INC_SYS}")

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/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 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2014 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -30,16 +30,13 @@
// 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 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.
// 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.
#ifndef CERES_PUBLIC_INTERNAL_CONFIG_H_
#define CERES_PUBLIC_INTERNAL_CONFIG_H_

View File

@@ -157,6 +157,8 @@ 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 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// 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 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2013 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// 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 2015 Google Inc. All rights reserved.
* http://ceres-solver.org/
* Copyright 2013 Google Inc. All rights reserved.
* http://code.google.com/p/ceres-solver/
*
* 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 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2014 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// 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 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// 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 std::vector<CostFunction*>& conditioners,
const 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_;
std::vector<CostFunction*> conditioners_;
vector<CostFunction*> conditioners_;
Ownership ownership_;
};

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// 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 std::vector<int32>& parameter_block_sizes() const {
const vector<int32>& parameter_block_sizes() const {
return parameter_block_sizes_;
}
@@ -124,7 +124,7 @@ class CERES_EXPORT CostFunction {
}
protected:
std::vector<int32>* mutable_parameter_block_sizes() {
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).
std::vector<int32> parameter_block_sizes_;
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 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2013 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// 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
// SizedCostFunction objects in templated functors which are to be used for
// CostFunction 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* observation);
// IntrinsicProjection(const double* observations);
// virtual bool Evaluate(double const* const* parameters,
// double* residuals,
// double** jacobians) const;
@@ -62,8 +62,10 @@
// Then we can now do the following,
//
// struct CameraProjection {
// CameraProjection(const double* observation)
// : intrinsic_projection_(new IntrinsicProjection(observation)) {
// CameraProjection(double* observation) {
// intrinsic_projection_.reset(
// new CostFunctionToFunctor<2, 5, 3>(
// new IntrinsicProjection(observation_)));
// }
// template <typename T>
// bool operator()(const T* rotation,
@@ -77,11 +79,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:
// CostFunctionToFunctor<2,5,3> intrinsic_projection_;
// scoped_ptr<CostFunctionToFunctor<2,5,3> > intrinsic_projection_;
// };
#ifndef CERES_PUBLIC_COST_FUNCTION_TO_FUNCTOR_H_
@@ -91,7 +93,6 @@
#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"
@@ -103,29 +104,28 @@ 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_functor_(cost_function) {
: cost_function_(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) || // 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
((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)))
<< "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 std::vector<int32>& parameter_block_sizes =
const 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_functor_(&x0, residuals);
return cost_function_->Evaluate(&x0, residuals, NULL);
}
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_functor_(parameter_blocks.get(), residuals);
return cost_function_->Evaluate(parameter_blocks.get(), residuals, NULL);
}
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_functor_(parameter_blocks.get(), residuals);
return cost_function_->Evaluate(parameter_blocks.get(), residuals, NULL);
}
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_functor_(parameter_blocks.get(), residuals);
return cost_function_->Evaluate(parameter_blocks.get(), residuals, NULL);
}
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_functor_(parameter_blocks.get(), residuals);
return cost_function_->Evaluate(parameter_blocks.get(), residuals, NULL);
}
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_functor_(parameter_blocks.get(), residuals);
return cost_function_->Evaluate(parameter_blocks.get(), residuals, NULL);
}
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_functor_(parameter_blocks.get(), residuals);
return cost_function_->Evaluate(parameter_blocks.get(), residuals, NULL);
}
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_functor_(parameter_blocks.get(), residuals);
return cost_function_->Evaluate(parameter_blocks.get(), residuals, NULL);
}
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_functor_(parameter_blocks.get(), residuals);
return cost_function_->Evaluate(parameter_blocks.get(), residuals, NULL);
}
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_functor_(parameter_blocks.get(), residuals);
return cost_function_->Evaluate(parameter_blocks.get(), residuals, NULL);
}
template <typename JetT>
@@ -418,7 +418,7 @@ class CostFunctionToFunctor {
CHECK_EQ(N7, 0);
CHECK_EQ(N8, 0);
CHECK_EQ(N9, 0);
return cost_functor_(&x0, residuals);
return EvaluateWithJets(&x0, residuals);
}
template <typename JetT>
@@ -438,7 +438,7 @@ class CostFunctionToFunctor {
internal::FixedArray<const JetT*> jets(2);
jets[0] = x0;
jets[1] = x1;
return cost_functor_(jets.get(), residuals);
return EvaluateWithJets(jets.get(), residuals);
}
template <typename JetT>
@@ -460,7 +460,7 @@ class CostFunctionToFunctor {
jets[0] = x0;
jets[1] = x1;
jets[2] = x2;
return cost_functor_(jets.get(), residuals);
return EvaluateWithJets(jets.get(), residuals);
}
template <typename JetT>
@@ -484,7 +484,7 @@ class CostFunctionToFunctor {
jets[1] = x1;
jets[2] = x2;
jets[3] = x3;
return cost_functor_(jets.get(), residuals);
return EvaluateWithJets(jets.get(), residuals);
}
template <typename JetT>
@@ -510,7 +510,7 @@ class CostFunctionToFunctor {
jets[2] = x2;
jets[3] = x3;
jets[4] = x4;
return cost_functor_(jets.get(), residuals);
return EvaluateWithJets(jets.get(), residuals);
}
template <typename JetT>
@@ -538,7 +538,7 @@ class CostFunctionToFunctor {
jets[3] = x3;
jets[4] = x4;
jets[5] = x5;
return cost_functor_(jets.get(), residuals);
return EvaluateWithJets(jets.get(), residuals);
}
template <typename JetT>
@@ -568,7 +568,7 @@ class CostFunctionToFunctor {
jets[4] = x4;
jets[5] = x5;
jets[6] = x6;
return cost_functor_(jets.get(), residuals);
return EvaluateWithJets(jets.get(), residuals);
}
template <typename JetT>
@@ -600,7 +600,7 @@ class CostFunctionToFunctor {
jets[5] = x5;
jets[6] = x6;
jets[7] = x7;
return cost_functor_(jets.get(), residuals);
return EvaluateWithJets(jets.get(), residuals);
}
template <typename JetT>
@@ -634,7 +634,7 @@ class CostFunctionToFunctor {
jets[6] = x6;
jets[7] = x7;
jets[8] = x8;
return cost_functor_(jets.get(), residuals);
return EvaluateWithJets(jets.get(), residuals);
}
template <typename JetT>
@@ -670,11 +670,79 @@ class CostFunctionToFunctor {
jets[7] = x7;
jets[8] = x8;
jets[9] = x9;
return cost_functor_(jets.get(), residuals);
return EvaluateWithJets(jets.get(), residuals);
}
private:
DynamicCostFunctionToFunctor cost_functor_;
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_;
};
} // namespace ceres

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2013 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// 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);
//
// std::vector<std::pair<const double*, const double*> > covariance_blocks;
// vector<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,11 +353,10 @@ class CERES_EXPORT Covariance {
// Covariance::Options for more on the conditions under which this
// function returns false.
bool Compute(
const std::vector<std::pair<const double*,
const double*> >& covariance_blocks,
const vector<pair<const double*, const double*> >& covariance_blocks,
Problem* problem);
// Return the block of the cross-covariance matrix corresponding to
// Return the block of the covariance matrix corresponding to
// parameter_block1 and parameter_block2.
//
// Compute must be called before the first call to
@@ -374,26 +373,6 @@ 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 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// 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]
std::vector<int> cols;
std::vector<int> rows;
std::vector<double> values;
vector<int> cols;
vector<int> rows;
vector<double> values;
};
} // namespace ceres

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2013 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// 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.
std::vector<Jet<double, Stride> > input_jets(num_parameters);
std::vector<Jet<double, Stride> > output_jets(num_residuals());
vector<Jet<double, Stride> > input_jets(num_parameters);
vector<Jet<double, Stride> > output_jets(num_residuals());
// Make the parameter pack that is sent to the functor (reused).
std::vector<Jet<double, Stride>* > jet_parameters(num_parameter_blocks,
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.
std::vector<int> start_derivative_section;
vector<int> start_derivative_section;
bool in_derivative_section = false;
int parameter_cursor = 0;

View File

@@ -1,190 +0,0 @@
// 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 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -29,7 +29,6 @@
// 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
@@ -42,6 +41,7 @@
// 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,37 +68,19 @@
#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, NumericDiffMethodType method = CENTRAL>
template <typename CostFunctor, NumericDiffMethod method = CENTRAL>
class DynamicNumericDiffCostFunction : public CostFunction {
public:
explicit DynamicNumericDiffCostFunction(
const CostFunctor* functor,
Ownership ownership = TAKE_OWNERSHIP,
const NumericDiffOptions& options = NumericDiffOptions())
explicit DynamicNumericDiffCostFunction(const CostFunctor* functor,
Ownership ownership = TAKE_OWNERSHIP,
double relative_step_size = 1e-6)
: functor_(functor),
ownership_(ownership),
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;
relative_step_size_(relative_step_size) {
}
virtual ~DynamicNumericDiffCostFunction() {
@@ -118,12 +100,11 @@ 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 std::vector<int32>& block_sizes = parameter_block_sizes();
const vector<int32>& block_sizes = parameter_block_sizes();
CHECK(!block_sizes.empty())
<< "You must call DynamicNumericDiffCostFunction::AddParameterBlock() "
<< "before DynamicNumericDiffCostFunction::Evaluate().";
@@ -135,8 +116,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);
std::vector<double> parameters_copy(parameters_size);
std::vector<double*> parameters_references_copy(block_sizes.size());
vector<double> parameters_copy(parameters_size);
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]
@@ -152,18 +133,12 @@ class DynamicNumericDiffCostFunction : public CostFunction {
for (int block = 0; block < block_sizes.size(); ++block) {
if (jacobians[block] != NULL &&
!NumericDiff<CostFunctor, method, DYNAMIC,
DYNAMIC, DYNAMIC, DYNAMIC, DYNAMIC, DYNAMIC,
DYNAMIC, DYNAMIC, DYNAMIC, DYNAMIC, DYNAMIC,
DYNAMIC, DYNAMIC>::EvaluateJacobianForParameterBlock(
functor_.get(),
residuals,
options_,
this->num_residuals(),
!EvaluateJacobianForParameterBlock(block_sizes[block],
block,
block_sizes[block],
relative_step_size_,
residuals,
&parameters_references_copy[0],
jacobians[block])) {
jacobians)) {
return false;
}
}
@@ -171,6 +146,91 @@ 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(),
@@ -197,7 +257,7 @@ class DynamicNumericDiffCostFunction : public CostFunction {
internal::scoped_ptr<const CostFunctor> functor_;
Ownership ownership_;
NumericDiffOptions options_;
const double relative_step_size_;
};
} // namespace ceres

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -50,9 +50,26 @@ 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) { // NOLINT
const int classification = _fpclass(x);
return (classification == _FPCLASS_NN || classification == _FPCLASS_PN);
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);
}
# else

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// 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.
std::vector<Matrix> term_jacobians;
vector<Matrix> term_jacobians;
// Derivatives as computed by finite differencing.
std::vector<Matrix> finite_difference_jacobians;
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 std::vector<int32>& block_sizes = term->parameter_block_sizes();
const 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 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2014 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// 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 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2014 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// 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(std::string* error) const;
bool IsValid(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.
std::vector<IterationCallback*> callbacks;
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.
std::string BriefReport() const;
string BriefReport() const;
// A full multiline description of the state of the solver after
// termination.
std::string FullReport() const;
string FullReport() const;
bool IsSolutionUsable() const;
@@ -281,7 +281,7 @@ class CERES_EXPORT GradientProblemSolver {
TerminationType termination_type;
// Reason why the solver terminated.
std::string message;
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.
std::vector<IterationSummary> iterations;
vector<IterationSummary> iterations;
// Sum total of all time spent inside Ceres when Solve is called.
double total_time_in_seconds;
@@ -303,10 +303,6 @@ 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 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// 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) || // 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
((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)))
<< "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 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2014 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// 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 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// 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 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// 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 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// 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 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// 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 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2013 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -28,9 +28,8 @@
//
// Author: sameeragarwal@google.com (Sameer Agarwal)
// mierle@gmail.com (Keir Mierle)
// tbennun@gmail.com (Tal Ben-Nun)
//
// Finite differencing routines used by NumericDiffCostFunction.
// Finite differencing routine used by NumericDiffCostFunction.
#ifndef CERES_PUBLIC_INTERNAL_NUMERIC_DIFF_H_
#define CERES_PUBLIC_INTERNAL_NUMERIC_DIFF_H_
@@ -38,12 +37,9 @@
#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"
@@ -82,7 +78,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,
NumericDiffMethodType kMethod,
NumericDiffMethod kMethod,
int kNumResiduals,
int N0, int N1, int N2, int N3, int N4,
int N5, int N6, int N7, int N8, int N9,
@@ -92,11 +88,9 @@ struct NumericDiff {
// Mutates parameters but must restore them before return.
static bool EvaluateJacobianForParameterBlock(
const CostFunctor* functor,
const double* residuals_at_eval_point,
const NumericDiffOptions& options,
double const* residuals_at_eval_point,
const double relative_step_size,
int num_residuals,
int parameter_block_index,
int parameter_block_size,
double **parameters,
double *jacobian) {
using Eigen::Map;
@@ -104,14 +98,8 @@ struct NumericDiff {
using Eigen::RowMajor;
using Eigen::ColMajor;
const int num_residuals_internal =
const int NUM_RESIDUALS =
(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;
@@ -127,288 +115,73 @@ struct NumericDiff {
JacobianMatrix;
Map<JacobianMatrix> parameter_jacobian(jacobian,
num_residuals_internal,
parameter_block_size_internal);
NUM_RESIDUALS,
kParameterBlockSize);
Map<ParameterVector> x_plus_delta(
parameters[parameter_block_index_internal],
parameter_block_size_internal);
// Mutate 1 element at a time and then restore.
Map<ParameterVector> x_plus_delta(parameters[kParameterBlock],
kParameterBlockSize);
ParameterVector x(x_plus_delta);
ParameterVector step_size = x.array().abs() *
((kMethod == RIDDERS) ? options.ridders_relative_initial_step_size :
options.relative_step_size);
ParameterVector step_size = x.array().abs() * relative_step_size;
// 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);
}
// 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();
// 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);
for (int j = 0; j < parameter_block_size_internal; ++j) {
const double delta = std::max(min_step_size, step_size(j));
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);
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;
x_plus_delta(j) = x(j) + delta;
if (!EvaluateImpl<CostFunctor, N0, N1, N2, N3, N4, N5, N6, N7, N8, N9>(
functor, parameters, temp_residuals.data(), functor)) {
functor, parameters, residuals.data(), functor)) {
return false;
}
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);
}
// 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;
// Restore x_plus_delta.
x_plus_delta(parameter_index) = x(parameter_index);
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;
// Divide out the run to get slope.
residuals *= one_over_delta;
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;
}
// 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;
}
if (!EvaluateImpl<CostFunctor, N0, N1, N2, N3, N4, N5, N6, N7, N8, N9>(
functor, parameters, residuals.data(), functor)) {
return false;
}
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);
}
x_plus_delta(j) = x(j); // Restore x_plus_delta.
// 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);
// Divide out the run to get slope.
parameter_jacobian.col(j) *= one_over_delta;
}
return true;
}
};
template <typename CostFunctor,
NumericDiffMethodType kMethod,
NumericDiffMethod kMethod,
int kNumResiduals,
int N0, int N1, int N2, int N3, int N4,
int N5, int N6, int N7, int N8, int N9,
@@ -419,22 +192,11 @@ struct NumericDiff<CostFunctor, kMethod, kNumResiduals,
// Mutates parameters but must restore them before return.
static bool EvaluateJacobianForParameterBlock(
const CostFunctor* functor,
const double* residuals_at_eval_point,
const NumericDiffOptions& options,
double const* residuals_at_eval_point,
const double relative_step_size,
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 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -34,6 +34,8 @@
// This file needs to compile as c code.
#ifdef __cplusplus
#include <string>
#include "ceres/internal/config.h"
#if defined(CERES_TR1_MEMORY_HEADER)
@@ -44,6 +46,16 @@
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 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2014 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// 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 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// 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 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2013 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -35,7 +35,6 @@
#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"
@@ -177,17 +176,6 @@ 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 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// 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 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// 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.v[0]
// << "df/dy = " << z.v[1];
// LOG(INFO) << "df/dx = " << z.a[0]
// << "df/dy = " << z.a[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,41 +482,6 @@ 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
@@ -608,101 +573,22 @@ Jet<T, N> pow(const Jet<T, N>& f, double g) {
}
// pow -- base is a constant, exponent is a differentiable function.
// 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.
// (a)^(p+dp) ~= a^p + a^p log(a) dp
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 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2014 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -34,7 +34,6 @@
#include <vector>
#include "ceres/internal/port.h"
#include "ceres/internal/scoped_ptr.h"
#include "ceres/internal/disable_warnings.h"
namespace ceres {
@@ -174,7 +173,7 @@ class CERES_EXPORT IdentityParameterization : public LocalParameterization {
class CERES_EXPORT SubsetParameterization : public LocalParameterization {
public:
explicit SubsetParameterization(int size,
const std::vector<int>& constant_parameters);
const vector<int>& constant_parameters);
virtual ~SubsetParameterization() {}
virtual bool Plus(const double* x,
const double* delta,
@@ -192,7 +191,7 @@ class CERES_EXPORT SubsetParameterization : public LocalParameterization {
private:
const int local_size_;
std::vector<char> constancy_mask_;
vector<int> constancy_mask_;
};
// Plus(x, delta) = [cos(|delta|), sin(|delta|) delta / |delta|] * x
@@ -211,89 +210,6 @@ 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 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -274,28 +274,10 @@ 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 CERES_EXPORT ComposedLoss : public LossFunction {
class ComposedLoss : public LossFunction {
public:
explicit ComposedLoss(const LossFunction* f, Ownership ownership_f,
const LossFunction* g, Ownership ownership_g);
@@ -358,9 +340,6 @@ 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;
@@ -397,14 +376,8 @@ class CERES_EXPORT LossFunctionWrapper : public LossFunction {
}
virtual void Evaluate(double sq_norm, double out[3]) const {
if (rho_.get() == NULL) {
out[0] = sq_norm;
out[1] = 1.0;
out[2] = 0.0;
}
else {
rho_->Evaluate(sq_norm, out);
}
CHECK_NOTNULL(rho_.get());
rho_->Evaluate(sq_norm, out);
}
void Reset(LossFunction* rho, Ownership ownership) {
@@ -423,6 +396,6 @@ class CERES_EXPORT LossFunctionWrapper : public LossFunction {
} // namespace ceres
#include "ceres/internal/reenable_warnings.h"
#include "ceres/internal/disable_warnings.h"
#endif // CERES_PUBLIC_LOSS_FUNCTION_H_

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// 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 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// 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 reasons, including compatibility with legacy code,
// For a variety of reason, including compatibility with legacy code,
// NumericDiffCostFunction can also take CostFunction objects as
// input. The following describes how.
//
@@ -165,7 +165,6 @@
#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"
@@ -173,7 +172,7 @@
namespace ceres {
template <typename CostFunctor,
NumericDiffMethodType method = CENTRAL,
NumericDiffMethod 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.
@@ -190,43 +189,19 @@ 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 NumericDiffOptions& options = NumericDiffOptions())
: functor_(functor),
ownership_(ownership),
options_(options) {
if (kNumResiduals == DYNAMIC) {
SizedCostFunction<kNumResiduals,
N0, N1, N2, N3, N4,
N5, N6, N7, N8, N9>
::set_num_residuals(num_residuals);
}
}
// 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)
Ownership ownership = TAKE_OWNERSHIP,
int num_residuals = kNumResiduals,
const double relative_step_size = 1e-6)
: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.";
relative_step_size_(relative_step_size) {
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() {
@@ -275,25 +250,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 CERES_COPY_PARAMETER_BLOCK(block) \
#define COPY_PARAMETER_BLOCK(block) \
if (N ## block) memcpy(parameters_reference_copy[block], \
parameters[block], \
sizeof(double) * N ## block); // NOLINT
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);
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);
#undef CERES_COPY_PARAMETER_BLOCK
#undef COPY_PARAMETER_BLOCK
#define CERES_EVALUATE_JACOBIAN_FOR_BLOCK(block) \
#define EVALUATE_JACOBIAN_FOR_BLOCK(block) \
if (N ## block && jacobians[block] != NULL) { \
if (!NumericDiff<CostFunctor, \
method, \
@@ -303,30 +278,28 @@ class NumericDiffCostFunction
N ## block >::EvaluateJacobianForParameterBlock( \
functor_.get(), \
residuals, \
options_, \
relative_step_size_, \
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; \
} \
}
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);
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);
#undef CERES_EVALUATE_JACOBIAN_FOR_BLOCK
#undef EVALUATE_JACOBIAN_FOR_BLOCK
return true;
}
@@ -334,7 +307,7 @@ class NumericDiffCostFunction
private:
internal::scoped_ptr<CostFunctor> functor_;
Ownership ownership_;
NumericDiffOptions options_;
const double relative_step_size_;
};
} // namespace ceres

View File

@@ -1,79 +0,0 @@
// 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 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -63,8 +63,7 @@ class OrderedGroups {
return false;
}
typename std::map<T, int>::const_iterator it =
element_to_group_.find(element);
typename 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.
@@ -108,7 +107,7 @@ class OrderedGroups {
// Bulk remove elements. The return value indicates the number of
// elements successfully removed.
int Remove(const std::vector<T>& elements) {
int Remove(const vector<T>& elements) {
if (NumElements() == 0 || elements.size() == 0) {
return 0;
}
@@ -122,18 +121,14 @@ class OrderedGroups {
// Reverse the order of the groups in place.
void Reverse() {
if (NumGroups() == 0) {
return;
}
typename std::map<int, std::set<T> >::reverse_iterator it =
typename map<int, set<T> >::reverse_iterator it =
group_to_elements_.rbegin();
std::map<int, std::set<T> > new_group_to_elements;
map<int, 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 std::set<T>::const_iterator element_it = it->second.begin();
for (typename set<T>::const_iterator element_it = it->second.begin();
element_it != it->second.end();
++element_it) {
element_to_group_[*element_it] = new_group_id;
@@ -148,8 +143,7 @@ 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 std::map<T, int>::const_iterator it =
element_to_group_.find(element);
typename map<T, int>::const_iterator it = element_to_group_.find(element);
if (it == element_to_group_.end()) {
return -1;
}
@@ -157,15 +151,14 @@ class OrderedGroups {
}
bool IsMember(const T element) const {
typename std::map<T, int>::const_iterator it =
element_to_group_.find(element);
typename 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 std::map<int, std::set<T> >::const_iterator it =
typename map<int, set<T> >::const_iterator it =
group_to_elements_.find(group);
return (it == group_to_elements_.end()) ? 0 : it->second.size();
}
@@ -187,17 +180,17 @@ class OrderedGroups {
return group_to_elements_.begin()->first;
}
const std::map<int, std::set<T> >& group_to_elements() const {
const map<int, set<T> >& group_to_elements() const {
return group_to_elements_;
}
const std::map<T, int>& element_to_group() const {
const map<T, int>& element_to_group() const {
return element_to_group_;
}
private:
std::map<int, std::set<T> > group_to_elements_;
std::map<T, int> element_to_group_;
map<int, set<T> > group_to_elements_;
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 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2013 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -211,10 +211,9 @@ 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 std::vector<double*>& parameter_blocks);
ResidualBlockId AddResidualBlock(CostFunction* cost_function,
LossFunction* loss_function,
const vector<double*>& parameter_blocks);
// Convenience methods for adding residuals with a small number of
// parameters. This is the common case. Instead of specifying the
@@ -357,17 +356,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(std::vector<double*>* parameter_blocks) const;
void GetParameterBlocks(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(std::vector<ResidualBlockId>* residual_blocks) const;
void GetResidualBlocks(vector<ResidualBlockId>* residual_blocks) const;
// Get all the parameter blocks that depend on the given residual block.
void GetParameterBlocksForResidualBlock(
const ResidualBlockId residual_block,
std::vector<double*>* parameter_blocks) const;
vector<double*>* parameter_blocks) const;
// Get the CostFunction for the given residual block.
const CostFunction* GetCostFunctionForResidualBlock(
@@ -386,7 +385,7 @@ class CERES_EXPORT Problem {
// block will incur a scan of the entire Problem object.
void GetResidualBlocksForParameterBlock(
const double* values,
std::vector<ResidualBlockId>* residual_blocks) const;
vector<ResidualBlockId>* residual_blocks) const;
// Options struct to control Problem::Evaluate.
struct EvaluateOptions {
@@ -409,17 +408,18 @@ 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.
std::vector<double*> parameter_blocks;
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. 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;
// 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;
// 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,
std::vector<double>* residuals,
std::vector<double>* gradient,
vector<double>* residuals,
vector<double>* gradient,
CRSMatrix* jacobian);
private:

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -47,7 +47,6 @@
#include <algorithm>
#include <cmath>
#include <limits>
#include "glog/logging.h"
namespace ceres {
@@ -95,17 +94,6 @@ 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.
@@ -153,11 +141,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]);
@@ -168,8 +156,6 @@ 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]);
@@ -308,46 +294,6 @@ 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
@@ -362,10 +308,80 @@ template <typename T, int row_stride, int col_stride>
void RotationMatrixToAngleAxis(
const MatrixAdapter<const T, row_stride, col_stride>& R,
T* angle_axis) {
T quaternion[4];
RotationMatrixToQuaternion(R, quaternion);
QuaternionToAngleAxis(quaternion, angle_axis);
return;
// 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];
}
}
}
template <typename T>

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// 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) || // 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
((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)))
<< "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 CERES_ADD_PARAMETER_BLOCK(N) \
#define ADD_PARAMETER_BLOCK(N) \
if (N) mutable_parameter_block_sizes()->push_back(N);
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
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
}
virtual ~SizedCostFunction() { }

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2014 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// 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) // NOLINT
#if defined(CERES_NO_SUITESPARSE) && defined(CERES_NO_CXSPARSE) && !defined(CERES_ENABLE_LGPL_CODE)
linear_solver_type = DENSE_QR;
#else
linear_solver_type = SPARSE_NORMAL_CHOLESKY;
@@ -104,8 +104,7 @@ class CERES_EXPORT Solver {
// Choose a default sparse linear algebra library in the order:
//
// SUITE_SPARSE > CX_SPARSE > EIGEN_SPARSE > NO_SPARSE
sparse_linear_algebra_library_type = NO_SPARSE;
// SUITE_SPARSE > CX_SPARSE > EIGEN_SPARSE
#if !defined(CERES_NO_SUITESPARSE)
sparse_linear_algebra_library_type = SUITE_SPARSE;
#else
@@ -141,7 +140,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(std::string* error) const;
bool IsValid(string* error) const;
// Minimizer options ----------------------------------------
@@ -677,13 +676,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.
std::vector<int> trust_region_minimizer_iterations_to_dump;
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.
std::string trust_region_problem_dump_directory;
string trust_region_problem_dump_directory;
DumpFormatType trust_region_problem_dump_format_type;
// Finite differences options ----------------------------------------------
@@ -747,7 +746,7 @@ class CERES_EXPORT Solver {
// executed, then set update_state_every_iteration to true.
//
// The solver does NOT take ownership of these pointers.
std::vector<IterationCallback*> callbacks;
vector<IterationCallback*> callbacks;
};
struct CERES_EXPORT Summary {
@@ -755,11 +754,11 @@ class CERES_EXPORT Solver {
// A brief one line description of the state of the solver after
// termination.
std::string BriefReport() const;
string BriefReport() const;
// A full multiline description of the state of the solver after
// termination.
std::string FullReport() const;
string FullReport() const;
bool IsSolutionUsable() const;
@@ -769,7 +768,7 @@ class CERES_EXPORT Solver {
TerminationType termination_type;
// Reason why the solver terminated.
std::string message;
string message;
// Cost of the problem (value of the objective function) before
// the optimization.
@@ -785,7 +784,7 @@ class CERES_EXPORT Solver {
double fixed_cost;
// IterationSummary for each minimizer iteration in order.
std::vector<IterationSummary> iterations;
vector<IterationSummary> iterations;
// Number of minimizer iterations in which the step was
// accepted. Unless use_non_monotonic_steps is true this is also
@@ -833,26 +832,6 @@ 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;
@@ -892,9 +871,6 @@ 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;
@@ -926,7 +902,7 @@ class CERES_EXPORT Solver {
// Size of the elimination groups given by the user as hints to
// the linear solver.
std::vector<int> linear_solver_ordering_given;
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
@@ -934,7 +910,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.
std::vector<int> linear_solver_ordering_used;
vector<int> linear_solver_ordering_used;
// True if the user asked for inner iterations to be used as part
// of the optimization.
@@ -948,7 +924,7 @@ class CERES_EXPORT Solver {
// Size of the parameter groups given by the user for performing
// inner iterations.
std::vector<int> inner_iteration_ordering_given;
vector<int> inner_iteration_ordering_given;
// Size of the parameter groups given used by the solver for
// performing inner iterations. This maybe different from
@@ -956,7 +932,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.
std::vector<int> inner_iteration_ordering_used;
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 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -157,12 +157,7 @@ enum SparseLinearAlgebraLibraryType {
// Eigen's sparse linear algebra routines. In particular Ceres uses
// the Simplicial LDLT routines.
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
EIGEN_SPARSE
};
enum DenseLinearAlgebraLibraryType {
@@ -397,19 +392,9 @@ enum DimensionType {
DYNAMIC = -1
};
// 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.
enum NumericDiffMethod {
CENTRAL,
// 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
FORWARD
};
enum LineSearchInterpolationType {
@@ -426,73 +411,67 @@ enum CovarianceAlgorithmType {
CERES_EXPORT const char* LinearSolverTypeToString(
LinearSolverType type);
CERES_EXPORT bool StringToLinearSolverType(std::string value,
CERES_EXPORT bool StringToLinearSolverType(string value,
LinearSolverType* type);
CERES_EXPORT const char* PreconditionerTypeToString(PreconditionerType type);
CERES_EXPORT bool StringToPreconditionerType(std::string value,
CERES_EXPORT bool StringToPreconditionerType(string value,
PreconditionerType* type);
CERES_EXPORT const char* VisibilityClusteringTypeToString(
VisibilityClusteringType type);
CERES_EXPORT bool StringToVisibilityClusteringType(std::string value,
CERES_EXPORT bool StringToVisibilityClusteringType(string value,
VisibilityClusteringType* type);
CERES_EXPORT const char* SparseLinearAlgebraLibraryTypeToString(
SparseLinearAlgebraLibraryType type);
CERES_EXPORT bool StringToSparseLinearAlgebraLibraryType(
std::string value,
string value,
SparseLinearAlgebraLibraryType* type);
CERES_EXPORT const char* DenseLinearAlgebraLibraryTypeToString(
DenseLinearAlgebraLibraryType type);
CERES_EXPORT bool StringToDenseLinearAlgebraLibraryType(
std::string value,
string value,
DenseLinearAlgebraLibraryType* type);
CERES_EXPORT const char* TrustRegionStrategyTypeToString(
TrustRegionStrategyType type);
CERES_EXPORT bool StringToTrustRegionStrategyType(std::string value,
CERES_EXPORT bool StringToTrustRegionStrategyType(string value,
TrustRegionStrategyType* type);
CERES_EXPORT const char* DoglegTypeToString(DoglegType type);
CERES_EXPORT bool StringToDoglegType(std::string value, DoglegType* type);
CERES_EXPORT bool StringToDoglegType(string value, DoglegType* type);
CERES_EXPORT const char* MinimizerTypeToString(MinimizerType type);
CERES_EXPORT bool StringToMinimizerType(std::string value, MinimizerType* type);
CERES_EXPORT bool StringToMinimizerType(string value, MinimizerType* type);
CERES_EXPORT const char* LineSearchDirectionTypeToString(
LineSearchDirectionType type);
CERES_EXPORT bool StringToLineSearchDirectionType(std::string value,
CERES_EXPORT bool StringToLineSearchDirectionType(string value,
LineSearchDirectionType* type);
CERES_EXPORT const char* LineSearchTypeToString(LineSearchType type);
CERES_EXPORT bool StringToLineSearchType(std::string value, LineSearchType* type);
CERES_EXPORT bool StringToLineSearchType(string value, LineSearchType* type);
CERES_EXPORT const char* NonlinearConjugateGradientTypeToString(
NonlinearConjugateGradientType type);
CERES_EXPORT bool StringToNonlinearConjugateGradientType(
std::string value,
string value,
NonlinearConjugateGradientType* type);
CERES_EXPORT const char* LineSearchInterpolationTypeToString(
LineSearchInterpolationType type);
CERES_EXPORT bool StringToLineSearchInterpolationType(
std::string value,
string value,
LineSearchInterpolationType* type);
CERES_EXPORT const char* CovarianceAlgorithmTypeToString(
CovarianceAlgorithmType type);
CERES_EXPORT bool StringToCovarianceAlgorithmType(
std::string value,
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 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2014 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -32,8 +32,9 @@
#define CERES_PUBLIC_VERSION_H_
#define CERES_VERSION_MAJOR 1
#define CERES_VERSION_MINOR 11
#define CERES_VERSION_MINOR 10
#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 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -41,8 +41,6 @@
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
@@ -73,7 +71,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 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -43,7 +43,6 @@
#ifndef CERES_INTERNAL_ARRAY_UTILS_H_
#define CERES_INTERNAL_ARRAY_UTILS_H_
#include <string>
#include "ceres/internal/port.h"
namespace ceres {
@@ -64,7 +63,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, std::string* result);
void AppendArrayToString(const int size, const double* x, string* result);
extern const double kImpossibleValue;

View File

@@ -1,6 +1,6 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2013 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -32,7 +32,6 @@
#include "ceres/internal/port.h"
#include "glog/logging.h"
#ifndef CERES_NO_LAPACK
extern "C" void dsyrk_(char* uplo,
char* trans,
int* n,
@@ -43,7 +42,6 @@ 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 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2013 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// 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 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// 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 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// 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 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// 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();
std::vector<int> blocks(bs->cols.size());
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 std::vector<Cell>& cells = bs->rows[i].cells;
const 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 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2014 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// 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 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -41,9 +41,6 @@
namespace ceres {
namespace internal {
using std::vector;
namespace {
// Given the residual block ordering, build a lookup table to determine which
@@ -166,7 +163,8 @@ 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 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
// http://code.google.com/p/ceres-solver/
//
// 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'.
std::vector<int*> jacobian_layout_;
vector<int*> jacobian_layout_;
// The pointers in jacobian_layout_ point directly into this vector.
std::vector<int> jacobian_layout_storage_;
vector<int> jacobian_layout_storage_;
};
} // namespace internal

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