# quiet output for Makefiles, 'make -s' helps too
# set_property(GLOBAL PROPERTY RULE_MESSAGES OFF)
-# global compile definitions since add_definitions() adds for all.
-set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG DEBUG _DEBUG)
-set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_RELEASE NDEBUG)
-set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_MINSIZEREL NDEBUG)
-set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_RELWITHDEBINFO DEBUG _DEBUG)
-
-
#-----------------------------------------------------------------------------
# Set policy
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin CACHE INTERNAL "" FORCE )
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib CACHE INTERNAL "" FORCE )
+set(INCLUDE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/include CACHE INTERNAL "" FORCE )
#-----------------------------------------------------------------------------
# Set default config options
endif()
if(UNIX AND NOT APPLE)
- option(WITH_X11_XINPUT "Enable X11 Xinput (tablet support and unicode input)" ON)
+ option(WITH_X11_XINPUT "Enable X11 Xinput (tablet support)" ON)
option(WITH_BUILTIN_GLEW "Use GLEW OpenGL wrapper library bundled with blender" ON)
else()
# not an option for other OS's
endif()
option(WITH_PYTHON_INSTALL "Copy system python into the blender install folder" ON)
+# Cycles
+option(WITH_CYCLES "Enable Cycles Render Engine" ON)
+OPTION(WITH_CYCLES_OSL "Build with Open Shading Language support" OFF)
+OPTION(WITH_CYCLES_CUDA "Build with CUDA binaries" OFF)
+OPTION(WITH_CYCLES_BLENDER "Build Blender Python extension" ON)
+OPTION(WITH_CYCLES_PARTIO "Build with Partio point cloud support (unfinished)" OFF)
+OPTION(WITH_CYCLES_NETWORK "Build with network rendering support (unfinished)" OFF)
+OPTION(WITH_CYCLES_TEST "Build cycles test application" OFF)
+
# disable for now, but plan to support on all platforms eventually
option(WITH_MEM_JEMALLOC "Enable malloc replacement (http://www.canonware.com/jemalloc)" OFF)
mark_as_advanced(WITH_MEM_JEMALLOC)
set(WITH_HEADLESS ON)
endif()
+# auto enable openimageio and boost for cycles
+if(WITH_CYCLES)
+ set(WITH_OPENIMAGEIO ON)
+ set(WITH_BOOST ON)
+endif()
+
+if(WITH_OPENIMAGEIO)
+ set(WITH_BOOST ON)
+endif()
+
TEST_SSE_SUPPORT(COMPILER_SSE_FLAG COMPILER_SSE2_FLAG)
# don't store paths to libs for portable distrobution
endif()
endif()
+ if(WITH_BOOST)
+ if(CYCLES_BOOST)
+ set(BOOST ${CYCLES_BOOST} CACHE PATH "Boost Directory")
+ unset(CYCLES_BOOST CACHE)
+ else()
+ set(BOOST "/usr" CACHE PATH "Boost Directory")
+ endif()
+
+ if(NOT BOOST_CUSTOM)
+ set(BOOST_ROOT ${BOOST})
+ set(Boost_USE_MULTITHREADED ON)
+ find_package(Boost 1.34 REQUIRED COMPONENTS filesystem regex system thread)
+ endif()
+
+ set(BOOST_INCLUDE_DIR ${Boost_INCLUDE_DIRS})
+ set(BOOST_LIBRARIES ${Boost_LIBRARIES})
+ set(BOOST_LIBPATH ${Boost_LIBRARY_DIRS})
+ set(BOOST_DEFINITIONS "-DBOOST_ALL_NO_LIB")
+ endif()
+
+ if(WITH_OPENIMAGEIO)
+
+ # temp, update
+ if(CYCLES_OIIO)
+ set(OPENIMAGEIO ${CYCLES_OIIO})
+ unset(CYCLES_OIIO CACHE)
+ endif()
+
+ set(OPENIMAGEIO_ROOT_DIR ${OPENIMAGEIO})
+ find_package(OpenImageIO REQUIRED)
+
+ set(OPENIMAGEIO_LIBRARIES ${OPENIMAGEIO_LIBRARIES} ${PNG_LIBRARIES} ${JPEG_LIBRARIES} ${TIFF_LIBRARY} ${OPENEXR_LIBRARIES} ${ZLIB_LIBRARIES} ${BOOST_LIBRARIES})
+ set(OPENIMAGEIO_LIBPATH) # TODO, remove and reference the absolute path everywhere
+ set(OPENIMAGEIO_DEFINITIONS)
+
+ if(NOT OPENIMAGEIO_FOUND)
+ set(WITH_OPENIMAGEIO OFF)
+ endif()
+
+ endif()
+
# OpenSuse needs lutil, ArchLinux not, for now keep, can avoid by using --as-needed
set(PLATFORM_LINKLIBS "-lutil -lc -lm -lpthread -lstdc++")
set(PLATFORM_LINKFLAGS "-pthread")
- # lfs on glibc, all compilers should use
- add_definitions(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE")
# GNU Compiler
if(CMAKE_COMPILER_IS_GNUCC)
set(CMAKE_C_FLAGS "/nologo /J /W0 /Gd /wd4018 /wd4244 /wd4305 /wd4800 /wd4065 /wd4267 /we4013 /EHsc" CACHE STRING "MSVC MT C++ flags " FORCE)
if(CMAKE_CL_64)
- set(CMAKE_CXX_FLAGS_DEBUG "/Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
+ set(CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
else()
- set(CMAKE_CXX_FLAGS_DEBUG "/Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /ZI /J" CACHE STRING "MSVC MT flags " FORCE)
+ set(CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /ZI /J" CACHE STRING "MSVC MT flags " FORCE)
endif()
- set(CMAKE_CXX_FLAGS_RELEASE "/O2 /Ob2 /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
- set(CMAKE_CXX_FLAGS_MINSIZEREL "/O1 /Ob1 /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
- set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/O2 /Ob1 /EHsc /MT /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
+ set(CMAKE_CXX_FLAGS_RELEASE "/O2 /Ob2 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
+ set(CMAKE_CXX_FLAGS_MINSIZEREL "/O1 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
+ set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/O2 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
if(CMAKE_CL_64)
- set(CMAKE_C_FLAGS_DEBUG "/Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
+ set(CMAKE_C_FLAGS_DEBUG "/D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
else()
- set(CMAKE_C_FLAGS_DEBUG "/Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /ZI /J" CACHE STRING "MSVC MT flags " FORCE)
+ set(CMAKE_C_FLAGS_DEBUG "/D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /ZI /J" CACHE STRING "MSVC MT flags " FORCE)
endif()
- set(CMAKE_C_FLAGS_RELEASE "/O2 /Ob2 /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
- set(CMAKE_C_FLAGS_MINSIZEREL "/O1 /Ob1 /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
- set(CMAKE_C_FLAGS_RELWITHDEBINFO "/O2 /Ob1 /EHsc /MT /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
+ set(CMAKE_C_FLAGS_RELEASE "/O2 /Ob2 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
+ set(CMAKE_C_FLAGS_MINSIZEREL "/O1 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
+ set(CMAKE_C_FLAGS_RELWITHDEBINFO "/O2 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
if(WITH_INTERNATIONAL)
set(GETTEXT ${LIBDIR}/gettext)
set(PYTHON_LIBRARIES "${PYTHON_LIBRARY}")
endif()
+ if(WITH_BOOST)
+ set(BOOST ${LIBDIR}/boost)
+ set(BOOST_INCLUDE_DIR ${BOOST}/include)
+ if(CMAKE_CL_64)
+ set(BOOST_POSTFIX "vc90-mt-s-1_45.lib")
+ set(BOOST_DEBUG_POSTFIX "vc90-mt-sgd-1_45.lib")
+ else()
+ set(BOOST_POSTFIX "vc90-mt-s-1_46_1.lib")
+ set(BOOST_DEBUG_POSTFIX "vc90-mt-sgd-1_46_1.lib")
+ endif()
+ set(BOOST_LIBRARIES
+ optimized libboost_date_time-${BOOST_POSTFIX} libboost_filesystem-${BOOST_POSTFIX}
+ libboost_regex-${BOOST_POSTFIX} libboost_system-${BOOST_POSTFIX} libboost_thread-${BOOST_POSTFIX}
+ debug libboost_date_time-${BOOST_DEBUG_POSTFIX} libboost_filesystem-${BOOST_DEBUG_POSTFIX}
+ libboost_regex-${BOOST_DEBUG_POSTFIX} libboost_system-${BOOST_DEBUG_POSTFIX} libboost_thread-${BOOST_DEBUG_POSTFIX})
+ set(BOOST_LIBPATH ${BOOST}/lib)
+ set(BOOST_DEFINITIONS "-DBOOST_ALL_NO_LIB")
+ endif()
+
+ if(WITH_OPENIMAGEIO)
+ set(OPENIMAGEIO ${LIBDIR}/openimageio)
+ set(OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO}/include)
+ set(OPENIMAGEIO_LIBRARIES OpenImageIO)
+ set(OPENIMAGEIO_LIBPATH ${OPENIMAGEIO}/lib)
+ set(OPENIMAGEIO_DEFINITIONS)
+ endif()
+
set(PLATFORM_LINKFLAGS "/SUBSYSTEM:CONSOLE /STACK:2097152 /INCREMENTAL:NO /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:msvcmrt.lib /NODEFAULTLIB:msvcurt.lib /NODEFAULTLIB:msvcrtd.lib")
# MSVC only, Mingw doesnt need
add_definitions(-DFREE_WINDOWS)
+ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
+ set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")
+
if(WITH_INTERNATIONAL)
set(GETTEXT ${LIBDIR}/gcc/gettext)
set(GETTEXT_INCLUDE_DIRS ${GETTEXT}/include)
set(PYTHON_LIBRARIES "${PYTHON_LIBRARY}")
endif()
+ if(WITH_BOOST)
+ set(BOOST ${LIBDIR}/boost)
+ set(BOOST_INCLUDE_DIR ${BOOST}/include)
+ set(BOOST_POSTFIX "vc90-mt-s-1_46_1")
+ set(BOOST_DEBUG_POSTFIX "vc90-mt-sgd-1_46_1")
+ set(BOOST_LIBRARIES
+ optimized libboost_date_time-${BOOST_POSTFIX} libboost_filesystem-${BOOST_POSTFIX}
+ libboost_regex-${BOOST_POSTFIX} libboost_system-${BOOST_POSTFIX} libboost_thread-${BOOST_POSTFIX}
+ debug libboost_date_time-${BOOST_DEBUG_POSTFIX} libboost_filesystem-${BOOST_DEBUG_POSTFIX}
+ libboost_regex-${BOOST_DEBUG_POSTFIX} libboost_system-${BOOST_DEBUG_POSTFIX} libboost_thread-${BOOST_DEBUG_POSTFIX})
+ set(BOOST_LIBPATH ${BOOST}/lib)
+ set(BOOST_DEFINITIONS "-DBOOST_ALL_NO_LIB")
+ endif()
+
+ if(WITH_OPENIMAGEIO)
+ set(OPENIMAGEIO ${LIBDIR}/openimageio)
+ set(OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO}/include)
+ set(OPENIMAGEIO_LIBRARIES OpenImageIO)
+ set(OPENIMAGEIO_LIBPATH ${OPENIMAGEIO}/lib)
+ set(OPENIMAGEIO_DEFINITIONS)
+ endif()
+
set(PLATFORM_LINKFLAGS "--stack,2097152")
endif()
# linker needs "-weak_framework 3DconnexionClient"
endif()
+ if(WITH_BOOST)
+ set(BOOST ${LIBDIR}/boost)
+ set(BOOST_INCLUDE_DIR ${BOOST}/include)
+ set(BOOST_LIBRARIES boost_date_time-mt boost_filesystem-mt boost_regex-mt boost_system-mt boost_thread-mt)
+ set(BOOST_LIBPATH ${BOOST}/lib)
+ set(BOOST_DEFINITIONS)
+ endif()
+
+ if(WITH_OPENIMAGEIO)
+ set(OPENIMAGEIO ${LIBDIR}/openimageio)
+ set(OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO}/include)
+ set(OPENIMAGEIO_LIBRARIES OpenImageIO ${PNG_LIBRARIES} ${JPEG_LIBRARIES} ${TIFF_LIBRARY} ${OPENEXR_LIBRARIES} ${ZLIB_LIBRARIES})
+ set(OPENIMAGEIO_LIBPATH ${OPENIMAGEIO}/lib ${JPEG_LIBPATH} ${PNG_LIBPATH} ${TIFF_LIBPATH} ${OPENEXR_LIBPATH} ${ZLIB_LIBPATH})
+ set(OPENIMAGEIO_DEFINITIONS "-DOIIO_STATIC_BUILD")
+ endif()
+
set(EXETYPE MACOSX_BUNDLE)
set(CMAKE_C_FLAGS_DEBUG "-fno-strict-aliasing -g")
#-----------------------------------------------------------------------------
# Extra compile flags
+if((NOT WIN32) AND (NOT MSVC))
+ # used for internal debug checks
+ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG")
+ set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG")
+
+ # assert() checks for this.
+ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG")
+ set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -DNDEBUG")
+ set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DNDEBUG")
+
+ set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNDEBUG")
+ set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -DNDEBUG")
+ set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -DNDEBUG")
+endif()
+
if(CMAKE_COMPILER_IS_GNUCC)
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ALL -Wall)
info_cfg_option(WITH_IMAGE_OPENJPEG)
info_cfg_option(WITH_IMAGE_REDCODE)
info_cfg_option(WITH_IMAGE_TIFF)
+ info_cfg_option(WITH_OPENIMAGEIO)
info_cfg_text("Audio:")
info_cfg_option(WITH_OPENAL)
# -*- mode: gnumakefile; tab-width: 8; indent-tabs-mode: t; -*-
-# vim: tabstop=4
+# vim: tabstop=8
+# $Id: GNUmakefile 41122 2011-10-19 21:55:27Z campbellbarton $
#
# ##### BEGIN GPL LICENSE BLOCK #####
#
#!/usr/bin/env python
-#
+# $Id: SConstruct 41169 2011-10-21 04:23:26Z campbellbarton $
# ***** BEGIN GPL LICENSE BLOCK *****
#
# This program is free software; you can redistribute it and/or
# Then read all SConscripts and build
#
# TODO: fix /FORCE:MULTIPLE on windows to get proper debug builds.
-# TODO: directory copy functions are far too complicated, see:
-# http://wiki.blender.org/index.php/User:Ideasman42/SConsNotSimpleInstallingFiles
import platform as pltfrm
--- /dev/null
+# - Find OpenImageIO library
+# Find the native OpenImageIO includes and library
+# This module defines
+# OPENIMAGEIO_INCLUDE_DIRS, where to find openimageio.h, Set when
+# OPENIMAGEIO_INCLUDE_DIR is found.
+# OPENIMAGEIO_LIBRARIES, libraries to link against to use OpenImageIO.
+# OPENIMAGEIO_ROOT_DIR, The base directory to search for OpenImageIO.
+# This can also be an environment variable.
+# OPENIMAGEIO_FOUND, If false, do not try to use OpenImageIO.
+#
+# also defined, but not for general use are
+# OPENIMAGEIO_LIBRARY, where to find the OpenImageIO library.
+
+#=============================================================================
+# Copyright 2011 Blender Foundation.
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+
+# If OPENIMAGEIO_ROOT_DIR was defined in the environment, use it.
+IF(NOT OPENIMAGEIO_ROOT_DIR AND NOT $ENV{OPENIMAGEIO_ROOT_DIR} STREQUAL "")
+ SET(OPENIMAGEIO_ROOT_DIR $ENV{OPENIMAGEIO_ROOT_DIR})
+ENDIF()
+
+SET(_openimageio_SEARCH_DIRS
+ ${OPENIMAGEIO_ROOT_DIR}
+ /usr/local
+ /sw # Fink
+ /opt/local # DarwinPorts
+ /opt/csw # Blastwave
+)
+
+FIND_PATH(OPENIMAGEIO_INCLUDE_DIR
+ NAMES
+ OpenImageIO/imageio.h
+ HINTS
+ ${_openimageio_SEARCH_DIRS}
+ PATH_SUFFIXES
+ include
+)
+
+FIND_LIBRARY(OPENIMAGEIO_LIBRARY
+ NAMES
+ OpenImageIO
+ HINTS
+ ${_openimageio_SEARCH_DIRS}
+ PATH_SUFFIXES
+ lib64 lib
+ )
+
+# handle the QUIETLY and REQUIRED arguments and set OPENIMAGEIO_FOUND to TRUE if
+# all listed variables are TRUE
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenImageIO DEFAULT_MSG
+ OPENIMAGEIO_LIBRARY OPENIMAGEIO_INCLUDE_DIR)
+
+IF(OPENIMAGEIO_FOUND)
+ SET(OPENIMAGEIO_LIBRARIES ${OPENIMAGEIO_LIBRARY})
+ SET(OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO_INCLUDE_DIR})
+ENDIF(OPENIMAGEIO_FOUND)
+
+MARK_AS_ADVANCED(
+ OPENIMAGEIO_INCLUDE_DIR
+ OPENIMAGEIO_LIBRARY
+)
def is_c(filename):
ext = splitext(filename)[1]
- return (ext in (".c", ".cpp", ".cxx", ".m", ".mm", ".rc", ".cc", ".inl"))
+ return (ext in (".c", ".cpp", ".cxx", ".m", ".mm", ".rc"))
def is_c_any(filename):
unset(_file_name_EXT)
endmacro()
-# useful for adding debug suffix to library lists:
+# usefil for adding debug suffix to library lists:
# /somepath/foo.lib --> /somepath/foo_d.lib
macro(file_list_suffix
fp_list_new fp_list fn_suffix
if(WITH_IMAGE_TIFF)
link_directories(${TIFF_LIBPATH})
endif()
+ if(WITH_BOOST)
+ link_directories(${BOOST_LIBPATH})
+ endif()
+ if(WITH_OPENIMAGEIO)
+ link_directories(${OPENIMAGEIO_LIBPATH})
+ endif()
if(WITH_IMAGE_OPENJPEG AND UNIX AND NOT APPLE)
link_directories(${OPENJPEG_LIBPATH})
endif()
if(WITH_IMAGE_TIFF)
target_link_libraries(${target} ${TIFF_LIBRARY})
endif()
+ if(WITH_OPENIMAGEIO)
+ target_link_libraries(${target} ${OPENIMAGEIO_LIBRARIES})
+ endif()
+ if(WITH_BOOST)
+ target_link_libraries(${target} ${BOOST_LIBRARIES})
+ endif()
if(WITH_IMAGE_OPENEXR)
if(WIN32 AND NOT UNIX)
file_list_suffix(OPENEXR_LIBRARIES_DEBUG "${OPENEXR_LIBRARIES}" "_d")
endmacro()
-# note, we can only append flags on a single file so we need to negate the options.
-# at the moment we cant shut up ffmpeg deprecations, so use this, but will
-# probably add more removals here.
-macro(remove_strict_flags_file
- filenames)
-
- foreach(_SOURCE ${ARGV})
-
- if(CMAKE_COMPILER_IS_GNUCC)
- set_source_files_properties(${_SOURCE}
- PROPERTIES
- COMPILE_FLAGS "-Wno-deprecated-declarations"
- )
- endif()
-
- if(MSVC)
- # TODO
- endif()
-
- endforeach()
-
- unset(_SOURCE)
-
-endmacro()
-
-
macro(ADD_CHECK_C_COMPILER_FLAG
_CFLAGS
_CACHE_VAR
endif()
endmacro()
+
+# pair of macros to allow libraries to be specify files to install, but to
+# only install them at the end so the directories don't get cleared with
+# the files in them. used by cycles to install addon.
+macro(delayed_install
+ base
+ files
+ destination)
+
+ foreach(f ${files})
+ set_property(GLOBAL APPEND PROPERTY DELAYED_INSTALL_FILES ${base}/${f})
+ set_property(GLOBAL APPEND PROPERTY DELAYED_INSTALL_DESTINATIONS ${destination})
+ endforeach()
+endmacro()
+
+# note this is a function instead of a macro so that ${BUILD_TYPE} in targetdir
+# does not get expanded in calling but is preserved
+function(delayed_do_install
+ targetdir)
+
+ get_property(files GLOBAL PROPERTY DELAYED_INSTALL_FILES)
+ get_property(destinations GLOBAL PROPERTY DELAYED_INSTALL_DESTINATIONS)
+
+ if(files)
+ list(LENGTH files n)
+ math(EXPR n "${n}-1")
+
+ foreach(i RANGE ${n})
+ list(GET files ${i} f)
+ list(GET destinations ${i} d)
+ install(FILES ${f} DESTINATION ${targetdir}/${d})
+ endforeach()
+ endif()
+endfunction()
+
def is_c(filename):
ext = os.path.splitext(filename)[1]
- return (ext in (".c", ".cpp", ".cxx", ".m", ".mm", ".rc", ".cc", ".inl"))
+ return (ext in (".c", ".cpp", ".cxx", ".m", ".mm", ".rc"))
def is_c_any(filename):
# Otherwise we get warnings here that we cant fix in external projects
remove_strict_flags()
-add_subdirectory(colamd)
-
if(WITH_BULLET)
add_subdirectory(bullet2)
endif()
--- /dev/null
+#ifndef EIGEN_ARRAY_MODULE_H
+#define EIGEN_ARRAY_MODULE_H
+
+#include "Core"
+
+#include "src/Core/util/DisableMSVCWarnings.h"
+
+namespace Eigen {
+
+/** \defgroup Array_Module Array module
+ * This module provides several handy features to manipulate matrices as simple array of values.
+ * In addition to listed classes, it defines various methods of the Cwise interface
+ * (accessible from MatrixBase::cwise()), including:
+ * - matrix-scalar sum,
+ * - coeff-wise comparison operators,
+ * - sin, cos, sqrt, pow, exp, log, square, cube, inverse (reciprocal).
+ *
+ * This module also provides various MatrixBase methods, including:
+ * - \ref MatrixBase::all() "all", \ref MatrixBase::any() "any",
+ * - \ref MatrixBase::Random() "random matrix initialization"
+ *
+ * \code
+ * #include <Eigen/Array>
+ * \endcode
+ */
+
+#include "src/Array/CwiseOperators.h"
+#include "src/Array/Functors.h"
+#include "src/Array/BooleanRedux.h"
+#include "src/Array/Select.h"
+#include "src/Array/PartialRedux.h"
+#include "src/Array/Random.h"
+#include "src/Array/Norms.h"
+
+} // namespace Eigen
+
+#include "src/Core/util/EnableMSVCWarnings.h"
+
+#endif // EIGEN_ARRAY_MODULE_H
--- /dev/null
+#ifndef EIGEN_CHOLESKY_MODULE_H
+#define EIGEN_CHOLESKY_MODULE_H
+
+#include "Core"
+
+#include "src/Core/util/DisableMSVCWarnings.h"
+
+// Note that EIGEN_HIDE_HEAVY_CODE has to be defined per module
+#if (defined EIGEN_EXTERN_INSTANTIATIONS) && (EIGEN_EXTERN_INSTANTIATIONS>=2)
+ #ifndef EIGEN_HIDE_HEAVY_CODE
+ #define EIGEN_HIDE_HEAVY_CODE
+ #endif
+#elif defined EIGEN_HIDE_HEAVY_CODE
+ #undef EIGEN_HIDE_HEAVY_CODE
+#endif
+
+namespace Eigen {
+
+/** \defgroup Cholesky_Module Cholesky module
+ *
+ * \nonstableyet
+ *
+ * This module provides two variants of the Cholesky decomposition for selfadjoint (hermitian) matrices.
+ * Those decompositions are accessible via the following MatrixBase methods:
+ * - MatrixBase::llt(),
+ * - MatrixBase::ldlt()
+ *
+ * \code
+ * #include <Eigen/Cholesky>
+ * \endcode
+ */
+
+#include "src/Array/CwiseOperators.h"
+#include "src/Array/Functors.h"
+#include "src/Cholesky/LLT.h"
+#include "src/Cholesky/LDLT.h"
+
+} // namespace Eigen
+
+#define EIGEN_CHOLESKY_MODULE_INSTANTIATE_TYPE(MATRIXTYPE,PREFIX) \
+ PREFIX template class LLT<MATRIXTYPE>; \
+ PREFIX template class LDLT<MATRIXTYPE>
+
+#define EIGEN_CHOLESKY_MODULE_INSTANTIATE(PREFIX) \
+ EIGEN_CHOLESKY_MODULE_INSTANTIATE_TYPE(Matrix2f,PREFIX); \
+ EIGEN_CHOLESKY_MODULE_INSTANTIATE_TYPE(Matrix2d,PREFIX); \
+ EIGEN_CHOLESKY_MODULE_INSTANTIATE_TYPE(Matrix3f,PREFIX); \
+ EIGEN_CHOLESKY_MODULE_INSTANTIATE_TYPE(Matrix3d,PREFIX); \
+ EIGEN_CHOLESKY_MODULE_INSTANTIATE_TYPE(Matrix4f,PREFIX); \
+ EIGEN_CHOLESKY_MODULE_INSTANTIATE_TYPE(Matrix4d,PREFIX); \
+ EIGEN_CHOLESKY_MODULE_INSTANTIATE_TYPE(MatrixXf,PREFIX); \
+ EIGEN_CHOLESKY_MODULE_INSTANTIATE_TYPE(MatrixXd,PREFIX); \
+ EIGEN_CHOLESKY_MODULE_INSTANTIATE_TYPE(MatrixXcf,PREFIX); \
+ EIGEN_CHOLESKY_MODULE_INSTANTIATE_TYPE(MatrixXcd,PREFIX)
+
+#ifdef EIGEN_EXTERN_INSTANTIATIONS
+
+namespace Eigen {
+ EIGEN_CHOLESKY_MODULE_INSTANTIATE(extern);
+} // namespace Eigen
+#endif
+
+#include "src/Core/util/EnableMSVCWarnings.h"
+
+#endif // EIGEN_CHOLESKY_MODULE_H
--- /dev/null
+#ifndef EIGEN_CORE_H
+#define EIGEN_CORE_H
+
+// first thing Eigen does: prevent MSVC from committing suicide
+#include "src/Core/util/DisableMSVCWarnings.h"
+
+#ifdef _MSC_VER
+ #include <malloc.h> // for _aligned_malloc -- need it regardless of whether vectorization is enabled
+ #if (_MSC_VER >= 1500) // 2008 or later
+ // Remember that usage of defined() in a #define is undefined by the standard.
+ // a user reported that in 64-bit mode, MSVC doesn't care to define _M_IX86_FP.
+ #if (defined(_M_IX86_FP) && (_M_IX86_FP >= 2)) || defined(_M_X64)
+ #define EIGEN_SSE2_ON_MSVC_2008_OR_LATER
+ #endif
+ #endif
+#endif
+
+#ifdef __GNUC__
+ #define EIGEN_GNUC_AT_LEAST(x,y) ((__GNUC__>=x && __GNUC_MINOR__>=y) || __GNUC__>x)
+#else
+ #define EIGEN_GNUC_AT_LEAST(x,y) 0
+#endif
+
+// Remember that usage of defined() in a #define is undefined by the standard
+#if (defined __SSE2__) && ( (!defined __GNUC__) || EIGEN_GNUC_AT_LEAST(4,2) )
+ #define EIGEN_SSE2_BUT_NOT_OLD_GCC
+#endif
+
+#ifndef EIGEN_DONT_VECTORIZE
+ #if defined (EIGEN_SSE2_BUT_NOT_OLD_GCC) || defined(EIGEN_SSE2_ON_MSVC_2008_OR_LATER)
+ #define EIGEN_VECTORIZE
+ #define EIGEN_VECTORIZE_SSE
+ #include <emmintrin.h>
+ #include <xmmintrin.h>
+ #ifdef __SSE3__
+ #include <pmmintrin.h>
+ #endif
+ #ifdef __SSSE3__
+ #include <tmmintrin.h>
+ #endif
+ #elif defined __ALTIVEC__
+ #define EIGEN_VECTORIZE
+ #define EIGEN_VECTORIZE_ALTIVEC
+ #include <altivec.h>
+ // We need to #undef all these ugly tokens defined in <altivec.h>
+ // => use __vector instead of vector
+ #undef bool
+ #undef vector
+ #undef pixel
+ #endif
+#endif
+
+#include <cstdlib>
+#include <cmath>
+#include <complex>
+#include <cassert>
+#include <functional>
+#include <iostream>
+#include <cstring>
+#include <string>
+#include <limits>
+#include <cstddef>
+
+#if (defined(_CPPUNWIND) || defined(__EXCEPTIONS)) && !defined(EIGEN_NO_EXCEPTIONS)
+ #define EIGEN_EXCEPTIONS
+#endif
+
+#ifdef EIGEN_EXCEPTIONS
+ #include <new>
+#endif
+
+// this needs to be done after all possible windows C header includes and before any Eigen source includes
+// (system C++ includes are supposed to be able to deal with this already):
+// windows.h defines min and max macros which would make Eigen fail to compile.
+#if defined(min) || defined(max)
+#error The preprocessor symbols 'min' or 'max' are defined. If you are compiling on Windows, do #define NOMINMAX to prevent windows.h from defining these symbols.
+#endif
+
+namespace Eigen {
+
+/** \defgroup Core_Module Core module
+ * This is the main module of Eigen providing dense matrix and vector support
+ * (both fixed and dynamic size) with all the features corresponding to a BLAS library
+ * and much more...
+ *
+ * \code
+ * #include <Eigen/Core>
+ * \endcode
+ */
+
+#include "src/Core/util/Macros.h"
+#include "src/Core/util/Constants.h"
+#include "src/Core/util/ForwardDeclarations.h"
+#include "src/Core/util/Meta.h"
+#include "src/Core/util/XprHelper.h"
+#include "src/Core/util/StaticAssert.h"
+#include "src/Core/util/Memory.h"
+
+#include "src/Core/NumTraits.h"
+#include "src/Core/MathFunctions.h"
+#include "src/Core/GenericPacketMath.h"
+
+#if defined EIGEN_VECTORIZE_SSE
+ #include "src/Core/arch/SSE/PacketMath.h"
+#elif defined EIGEN_VECTORIZE_ALTIVEC
+ #include "src/Core/arch/AltiVec/PacketMath.h"
+#endif
+
+#ifndef EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD
+#define EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD 16
+#endif
+
+#include "src/Core/Functors.h"
+#include "src/Core/MatrixBase.h"
+#include "src/Core/Coeffs.h"
+
+#ifndef EIGEN_PARSED_BY_DOXYGEN // work around Doxygen bug triggered by Assign.h r814874
+ // at least confirmed with Doxygen 1.5.5 and 1.5.6
+ #include "src/Core/Assign.h"
+#endif
+
+#include "src/Core/MatrixStorage.h"
+#include "src/Core/NestByValue.h"
+#include "src/Core/Flagged.h"
+#include "src/Core/Matrix.h"
+#include "src/Core/Cwise.h"
+#include "src/Core/CwiseBinaryOp.h"
+#include "src/Core/CwiseUnaryOp.h"
+#include "src/Core/CwiseNullaryOp.h"
+#include "src/Core/Dot.h"
+#include "src/Core/Product.h"
+#include "src/Core/DiagonalProduct.h"
+#include "src/Core/SolveTriangular.h"
+#include "src/Core/MapBase.h"
+#include "src/Core/Map.h"
+#include "src/Core/Block.h"
+#include "src/Core/Minor.h"
+#include "src/Core/Transpose.h"
+#include "src/Core/DiagonalMatrix.h"
+#include "src/Core/DiagonalCoeffs.h"
+#include "src/Core/Sum.h"
+#include "src/Core/Redux.h"
+#include "src/Core/Visitor.h"
+#include "src/Core/Fuzzy.h"
+#include "src/Core/IO.h"
+#include "src/Core/Swap.h"
+#include "src/Core/CommaInitializer.h"
+#include "src/Core/Part.h"
+#include "src/Core/CacheFriendlyProduct.h"
+
+} // namespace Eigen
+
+#include "src/Core/util/EnableMSVCWarnings.h"
+
+#endif // EIGEN_CORE_H
#include "Core"
+#include "Array"
#include "LU"
#include "Cholesky"
#include "QR"
#include "SVD"
#include "Geometry"
-#include "Eigenvalues"
+#include "LeastSquares"
--- /dev/null
+#include "Dense"
+#include "Sparse"
--- /dev/null
+#ifndef EIGEN_GEOMETRY_MODULE_H
+#define EIGEN_GEOMETRY_MODULE_H
+
+#include "Core"
+
+#include "src/Core/util/DisableMSVCWarnings.h"
+
+#include "Array"
+#include <limits>
+
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
+namespace Eigen {
+
+/** \defgroup Geometry_Module Geometry module
+ *
+ * \nonstableyet
+ *
+ * This module provides support for:
+ * - fixed-size homogeneous transformations
+ * - translation, scaling, 2D and 3D rotations
+ * - quaternions
+ * - \ref MatrixBase::cross() "cross product"
+ * - \ref MatrixBase::unitOrthogonal() "orthognal vector generation"
+ * - some linear components: parametrized-lines and hyperplanes
+ *
+ * \code
+ * #include <Eigen/Geometry>
+ * \endcode
+ */
+
+#include "src/Geometry/OrthoMethods.h"
+#include "src/Geometry/RotationBase.h"
+#include "src/Geometry/Rotation2D.h"
+#include "src/Geometry/Quaternion.h"
+#include "src/Geometry/AngleAxis.h"
+#include "src/Geometry/EulerAngles.h"
+#include "src/Geometry/Transform.h"
+#include "src/Geometry/Translation.h"
+#include "src/Geometry/Scaling.h"
+#include "src/Geometry/Hyperplane.h"
+#include "src/Geometry/ParametrizedLine.h"
+#include "src/Geometry/AlignedBox.h"
+
+} // namespace Eigen
+
+#include "src/Core/util/EnableMSVCWarnings.h"
+
+#endif // EIGEN_GEOMETRY_MODULE_H
#include "Core"
-#include "src/Core/util/DisableStupidWarnings.h"
+#include "src/Core/util/DisableMSVCWarnings.h"
namespace Eigen {
* \endcode
*/
-#include "src/misc/Solve.h"
-#include "src/misc/Kernel.h"
-#include "src/misc/Image.h"
-#include "src/LU/FullPivLU.h"
-#include "src/LU/PartialPivLU.h"
+#include "src/LU/LU.h"
#include "src/LU/Determinant.h"
#include "src/LU/Inverse.h"
-#if defined EIGEN_VECTORIZE_SSE
- #include "src/LU/arch/Inverse_SSE.h"
-#endif
-
-#ifdef EIGEN2_SUPPORT
- #include "src/Eigen2Support/LU.h"
-#endif
-
} // namespace Eigen
-#include "src/Core/util/ReenableStupidWarnings.h"
+#include "src/Core/util/EnableMSVCWarnings.h"
#endif // EIGEN_LU_MODULE_H
-/* vim: set filetype=cpp et sw=2 ts=2 ai: */
--- /dev/null
+#ifndef EIGEN_REGRESSION_MODULE_H
+#define EIGEN_REGRESSION_MODULE_H
+
+#include "Core"
+
+#include "src/Core/util/DisableMSVCWarnings.h"
+
+#include "QR"
+#include "Geometry"
+
+namespace Eigen {
+
+/** \defgroup LeastSquares_Module LeastSquares module
+ * This module provides linear regression and related features.
+ *
+ * \code
+ * #include <Eigen/LeastSquares>
+ * \endcode
+ */
+
+#include "src/LeastSquares/LeastSquares.h"
+
+} // namespace Eigen
+
+#include "src/Core/util/EnableMSVCWarnings.h"
+
+#endif // EIGEN_REGRESSION_MODULE_H
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra.
//
-// Copyright (C) 2009 Gael Guennebaud <gael.guennebaud@inria.fr>
+// Copyright (C) 2009 Gael Guennebaud <g.gael@free.fr>
// Copyright (C) 2009 Hauke Heibel <hauke.heibel@googlemail.com>
//
// Eigen is free software; you can redistribute it and/or
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
-#ifndef EIGEN_STDVECTOR_H
-#define EIGEN_STDVECTOR_H
-
-#include "Eigen/src/StlSupport/details.h"
-
-/**
- * This section contains a convenience MACRO which allows an easy specialization of
- * std::vector such that for data types with alignment issues the correct allocator
- * is used automatically.
- */
-#define EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(...) \
-namespace std \
-{ \
- template<> \
- class vector<__VA_ARGS__, std::allocator<__VA_ARGS__> > \
- : public vector<__VA_ARGS__, EIGEN_ALIGNED_ALLOCATOR<__VA_ARGS__> > \
- { \
- typedef vector<__VA_ARGS__, EIGEN_ALIGNED_ALLOCATOR<__VA_ARGS__> > vector_base; \
- public: \
- typedef __VA_ARGS__ value_type; \
- typedef vector_base::allocator_type allocator_type; \
- typedef vector_base::size_type size_type; \
- typedef vector_base::iterator iterator; \
- explicit vector(const allocator_type& a = allocator_type()) : vector_base(a) {} \
- template<typename InputIterator> \
- vector(InputIterator first, InputIterator last, const allocator_type& a = allocator_type()) : vector_base(first, last, a) {} \
- vector(const vector& c) : vector_base(c) {} \
- explicit vector(size_type num, const value_type& val = value_type()) : vector_base(num, val) {} \
- vector(iterator start, iterator end) : vector_base(start, end) {} \
- vector& operator=(const vector& x) { \
- vector_base::operator=(x); \
- return *this; \
- } \
- }; \
+#ifndef EIGEN_STDVECTOR_MODULE_H
+#define EIGEN_STDVECTOR_MODULE_H
+
+#include "Core"
+#include <vector>
+
+namespace Eigen {
+
+// This one is needed to prevent reimplementing the whole std::vector.
+template <class T>
+class aligned_allocator_indirection : public aligned_allocator<T>
+{
+public:
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+ typedef T* pointer;
+ typedef const T* const_pointer;
+ typedef T& reference;
+ typedef const T& const_reference;
+ typedef T value_type;
+
+ template<class U>
+ struct rebind
+ {
+ typedef aligned_allocator_indirection<U> other;
+ };
+
+ aligned_allocator_indirection() throw() {}
+ aligned_allocator_indirection(const aligned_allocator_indirection& ) throw() : aligned_allocator<T>() {}
+ aligned_allocator_indirection(const aligned_allocator<T>& ) throw() {}
+ template<class U>
+ aligned_allocator_indirection(const aligned_allocator_indirection<U>& ) throw() {}
+ template<class U>
+ aligned_allocator_indirection(const aligned_allocator<U>& ) throw() {}
+ ~aligned_allocator_indirection() throw() {}
+};
+
+#ifdef _MSC_VER
+
+ // sometimes, MSVC detects, at compile time, that the argument x
+ // in std::vector::resize(size_t s,T x) won't be aligned and generate an error
+ // even if this function is never called. Whence this little wrapper.
+ #define EIGEN_WORKAROUND_MSVC_STD_VECTOR(T) Eigen::ei_workaround_msvc_std_vector<T>
+ template<typename T> struct ei_workaround_msvc_std_vector : public T
+ {
+ inline ei_workaround_msvc_std_vector() : T() {}
+ inline ei_workaround_msvc_std_vector(const T& other) : T(other) {}
+ inline operator T& () { return *static_cast<T*>(this); }
+ inline operator const T& () const { return *static_cast<const T*>(this); }
+ template<typename OtherT>
+ inline T& operator=(const OtherT& other)
+ { T::operator=(other); return *this; }
+ inline ei_workaround_msvc_std_vector& operator=(const ei_workaround_msvc_std_vector& other)
+ { T::operator=(other); return *this; }
+ };
+
+#else
+
+ #define EIGEN_WORKAROUND_MSVC_STD_VECTOR(T) T
+
+#endif
+
}
namespace std {
return *this; \
}
- template<typename T>
- class vector<T,EIGEN_ALIGNED_ALLOCATOR<T> >
- : public vector<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T),
- Eigen::aligned_allocator_indirection<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T)> >
+template<typename T>
+class vector<T,Eigen::aligned_allocator<T> >
+ : public vector<EIGEN_WORKAROUND_MSVC_STD_VECTOR(T),
+ Eigen::aligned_allocator_indirection<EIGEN_WORKAROUND_MSVC_STD_VECTOR(T)> >
{
- typedef vector<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T),
- Eigen::aligned_allocator_indirection<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T)> > vector_base;
+ typedef vector<EIGEN_WORKAROUND_MSVC_STD_VECTOR(T),
+ Eigen::aligned_allocator_indirection<EIGEN_WORKAROUND_MSVC_STD_VECTOR(T)> > vector_base;
EIGEN_STD_VECTOR_SPECIALIZATION_BODY
void resize(size_type new_size)
{ return vector_base::insert(position,x); }
void insert(const_iterator position, size_type new_size, const value_type& x)
{ vector_base::insert(position, new_size, x); }
-#elif defined(_GLIBCXX_VECTOR) && (!(EIGEN_GNUC_AT_LEAST(4,1)))
- /* Note that before gcc-4.1 we already have: std::vector::resize(size_type,const T&).
- * However, this specialization is still needed to make the above EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION trick to work. */
- void resize(size_type new_size, const value_type& x)
- {
- vector_base::resize(new_size,x);
- }
#elif defined(_GLIBCXX_VECTOR) && EIGEN_GNUC_AT_LEAST(4,2)
// workaround GCC std::vector implementation
void resize(size_type new_size, const value_type& x)
else
vector_base::insert(vector_base::end(), new_size - vector_base::size(), x);
}
+#elif defined(_GLIBCXX_VECTOR) && (!EIGEN_GNUC_AT_LEAST(4,1))
+ // Note that before gcc-4.1 we already have: std::vector::resize(size_type,const T&),
+ // no no need to workaround !
+ using vector_base::resize;
#else
// either GCC 4.1 or non-GCC
// default implementation which should always work.
vector_base::insert(vector_base::end(), new_size - vector_base::size(), x);
}
#endif
- };
+
+};
+
}
-#endif // EIGEN_STDVECTOR_H
+#endif // EIGEN_STDVECTOR_MODULE_H
--- /dev/null
+#ifndef EIGEN_QR_MODULE_H
+#define EIGEN_QR_MODULE_H
+
+#include "Core"
+
+#include "src/Core/util/DisableMSVCWarnings.h"
+
+#include "Cholesky"
+
+// Note that EIGEN_HIDE_HEAVY_CODE has to be defined per module
+#if (defined EIGEN_EXTERN_INSTANTIATIONS) && (EIGEN_EXTERN_INSTANTIATIONS>=2)
+ #ifndef EIGEN_HIDE_HEAVY_CODE
+ #define EIGEN_HIDE_HEAVY_CODE
+ #endif
+#elif defined EIGEN_HIDE_HEAVY_CODE
+ #undef EIGEN_HIDE_HEAVY_CODE
+#endif
+
+namespace Eigen {
+
+/** \defgroup QR_Module QR module
+ *
+ * \nonstableyet
+ *
+ * This module mainly provides QR decomposition and an eigen value solver.
+ * This module also provides some MatrixBase methods, including:
+ * - MatrixBase::qr(),
+ * - MatrixBase::eigenvalues(),
+ * - MatrixBase::operatorNorm()
+ *
+ * \code
+ * #include <Eigen/QR>
+ * \endcode
+ */
+
+#include "src/QR/QR.h"
+#include "src/QR/Tridiagonalization.h"
+#include "src/QR/EigenSolver.h"
+#include "src/QR/SelfAdjointEigenSolver.h"
+#include "src/QR/HessenbergDecomposition.h"
+
+// declare all classes for a given matrix type
+#define EIGEN_QR_MODULE_INSTANTIATE_TYPE(MATRIXTYPE,PREFIX) \
+ PREFIX template class QR<MATRIXTYPE>; \
+ PREFIX template class Tridiagonalization<MATRIXTYPE>; \
+ PREFIX template class HessenbergDecomposition<MATRIXTYPE>; \
+ PREFIX template class SelfAdjointEigenSolver<MATRIXTYPE>
+
+// removed because it does not support complex yet
+// PREFIX template class EigenSolver<MATRIXTYPE>
+
+// declare all class for all types
+#define EIGEN_QR_MODULE_INSTANTIATE(PREFIX) \
+ EIGEN_QR_MODULE_INSTANTIATE_TYPE(Matrix2f,PREFIX); \
+ EIGEN_QR_MODULE_INSTANTIATE_TYPE(Matrix2d,PREFIX); \
+ EIGEN_QR_MODULE_INSTANTIATE_TYPE(Matrix3f,PREFIX); \
+ EIGEN_QR_MODULE_INSTANTIATE_TYPE(Matrix3d,PREFIX); \
+ EIGEN_QR_MODULE_INSTANTIATE_TYPE(Matrix4f,PREFIX); \
+ EIGEN_QR_MODULE_INSTANTIATE_TYPE(Matrix4d,PREFIX); \
+ EIGEN_QR_MODULE_INSTANTIATE_TYPE(MatrixXf,PREFIX); \
+ EIGEN_QR_MODULE_INSTANTIATE_TYPE(MatrixXd,PREFIX); \
+ EIGEN_QR_MODULE_INSTANTIATE_TYPE(MatrixXcf,PREFIX); \
+ EIGEN_QR_MODULE_INSTANTIATE_TYPE(MatrixXcd,PREFIX)
+
+#ifdef EIGEN_EXTERN_INSTANTIATIONS
+ EIGEN_QR_MODULE_INSTANTIATE(extern);
+#endif // EIGEN_EXTERN_INSTANTIATIONS
+
+} // namespace Eigen
+
+#include "src/Core/util/EnableMSVCWarnings.h"
+
+#endif // EIGEN_QR_MODULE_H
--- /dev/null
+
+#ifndef EIGEN_QTMALLOC_MODULE_H
+#define EIGEN_QTMALLOC_MODULE_H
+
+#include "Core"
+
+#if (!EIGEN_MALLOC_ALREADY_ALIGNED)
+
+inline void *qMalloc(size_t size)
+{
+ return Eigen::ei_aligned_malloc(size);
+}
+
+inline void qFree(void *ptr)
+{
+ Eigen::ei_aligned_free(ptr);
+}
+
+inline void *qRealloc(void *ptr, size_t size)
+{
+ void* newPtr = Eigen::ei_aligned_malloc(size);
+ memcpy(newPtr, ptr, size);
+ Eigen::ei_aligned_free(ptr);
+ return newPtr;
+}
+
+#endif
+
+#endif // EIGEN_QTMALLOC_MODULE_H
#ifndef EIGEN_SVD_MODULE_H
#define EIGEN_SVD_MODULE_H
-#include "QR"
-#include "Householder"
-#include "Jacobi"
+#include "Core"
-#include "src/Core/util/DisableStupidWarnings.h"
+#include "src/Core/util/DisableMSVCWarnings.h"
namespace Eigen {
/** \defgroup SVD_Module SVD module
*
- *
+ * \nonstableyet
*
* This module provides SVD decomposition for (currently) real matrices.
* This decomposition is accessible via the following MatrixBase method:
* \endcode
*/
-#include "src/misc/Solve.h"
-#include "src/SVD/JacobiSVD.h"
-#include "src/SVD/UpperBidiagonalization.h"
-
-#ifdef EIGEN2_SUPPORT
-#include "src/Eigen2Support/SVD.h"
-#endif
+#include "src/SVD/SVD.h"
} // namespace Eigen
-#include "src/Core/util/ReenableStupidWarnings.h"
+#include "src/Core/util/EnableMSVCWarnings.h"
#endif // EIGEN_SVD_MODULE_H
-/* vim: set filetype=cpp et sw=2 ts=2 ai: */
--- /dev/null
+#ifndef EIGEN_SPARSE_MODULE_H
+#define EIGEN_SPARSE_MODULE_H
+
+#include "Core"
+
+#include "src/Core/util/DisableMSVCWarnings.h"
+
+#include <vector>
+#include <map>
+#include <cstdlib>
+#include <cstring>
+#include <algorithm>
+
+#ifdef EIGEN_GOOGLEHASH_SUPPORT
+ #include <google/dense_hash_map>
+#endif
+
+#ifdef EIGEN_CHOLMOD_SUPPORT
+ extern "C" {
+ #include "cholmod.h"
+ }
+#endif
+
+#ifdef EIGEN_TAUCS_SUPPORT
+ // taucs.h declares a lot of mess
+ #define isnan
+ #define finite
+ #define isinf
+ extern "C" {
+ #include "taucs.h"
+ }
+ #undef isnan
+ #undef finite
+ #undef isinf
+
+ #ifdef min
+ #undef min
+ #endif
+ #ifdef max
+ #undef max
+ #endif
+ #ifdef complex
+ #undef complex
+ #endif
+#endif
+
+#ifdef EIGEN_SUPERLU_SUPPORT
+ typedef int int_t;
+ #include "superlu/slu_Cnames.h"
+ #include "superlu/supermatrix.h"
+ #include "superlu/slu_util.h"
+
+ namespace SuperLU_S {
+ #include "superlu/slu_sdefs.h"
+ }
+ namespace SuperLU_D {
+ #include "superlu/slu_ddefs.h"
+ }
+ namespace SuperLU_C {
+ #include "superlu/slu_cdefs.h"
+ }
+ namespace SuperLU_Z {
+ #include "superlu/slu_zdefs.h"
+ }
+ namespace Eigen { struct SluMatrix; }
+#endif
+
+#ifdef EIGEN_UMFPACK_SUPPORT
+ #include "umfpack.h"
+#endif
+
+namespace Eigen {
+
+/** \defgroup Sparse_Module Sparse module
+ *
+ * \nonstableyet
+ *
+ * See the \ref TutorialSparse "Sparse tutorial"
+ *
+ * \code
+ * #include <Eigen/QR>
+ * \endcode
+ */
+
+#include "src/Sparse/SparseUtil.h"
+#include "src/Sparse/SparseMatrixBase.h"
+#include "src/Sparse/CompressedStorage.h"
+#include "src/Sparse/AmbiVector.h"
+#include "src/Sparse/RandomSetter.h"
+#include "src/Sparse/SparseBlock.h"
+#include "src/Sparse/SparseMatrix.h"
+#include "src/Sparse/DynamicSparseMatrix.h"
+#include "src/Sparse/MappedSparseMatrix.h"
+#include "src/Sparse/SparseVector.h"
+#include "src/Sparse/CoreIterators.h"
+#include "src/Sparse/SparseTranspose.h"
+#include "src/Sparse/SparseCwise.h"
+#include "src/Sparse/SparseCwiseUnaryOp.h"
+#include "src/Sparse/SparseCwiseBinaryOp.h"
+#include "src/Sparse/SparseDot.h"
+#include "src/Sparse/SparseAssign.h"
+#include "src/Sparse/SparseRedux.h"
+#include "src/Sparse/SparseFuzzy.h"
+#include "src/Sparse/SparseFlagged.h"
+#include "src/Sparse/SparseProduct.h"
+#include "src/Sparse/SparseDiagonalProduct.h"
+#include "src/Sparse/TriangularSolver.h"
+#include "src/Sparse/SparseLLT.h"
+#include "src/Sparse/SparseLDLT.h"
+#include "src/Sparse/SparseLU.h"
+
+#ifdef EIGEN_CHOLMOD_SUPPORT
+# include "src/Sparse/CholmodSupport.h"
+#endif
+
+#ifdef EIGEN_TAUCS_SUPPORT
+# include "src/Sparse/TaucsSupport.h"
+#endif
+
+#ifdef EIGEN_SUPERLU_SUPPORT
+# include "src/Sparse/SuperLUSupport.h"
+#endif
+
+#ifdef EIGEN_UMFPACK_SUPPORT
+# include "src/Sparse/UmfPackSupport.h"
+#endif
+
+} // namespace Eigen
+
+#include "src/Core/util/EnableMSVCWarnings.h"
+
+#endif // EIGEN_SPARSE_MODULE_H
--- /dev/null
+#ifdef EIGEN_USE_NEW_STDVECTOR
+#include "NewStdVector"
+#else
+
+#ifndef EIGEN_STDVECTOR_MODULE_H
+#define EIGEN_STDVECTOR_MODULE_H
+
+#if defined(_GLIBCXX_VECTOR) || defined(_VECTOR_)
+#error you must include <Eigen/StdVector> before <vector>. Also note that <Eigen/Sparse> includes <vector>, so it must be included after <Eigen/StdVector> too.
+#endif
+
+#ifndef EIGEN_GNUC_AT_LEAST
+#ifdef __GNUC__
+ #define EIGEN_GNUC_AT_LEAST(x,y) ((__GNUC__>=x && __GNUC_MINOR__>=y) || __GNUC__>x)
+#else
+ #define EIGEN_GNUC_AT_LEAST(x,y) 0
+#endif
+#endif
+
+#define vector std_vector
+#include <vector>
+#undef vector
+
+namespace Eigen {
+
+template<typename T> class aligned_allocator;
+
+// meta programming to determine if a class has a given member
+struct ei_does_not_have_aligned_operator_new_marker_sizeof {int a[1];};
+struct ei_has_aligned_operator_new_marker_sizeof {int a[2];};
+
+template<typename ClassType>
+struct ei_has_aligned_operator_new {
+ template<typename T>
+ static ei_has_aligned_operator_new_marker_sizeof
+ test(T const *, typename T::ei_operator_new_marker_type const * = 0);
+ static ei_does_not_have_aligned_operator_new_marker_sizeof
+ test(...);
+
+ // note that the following indirection is needed for gcc-3.3
+ enum {ret = sizeof(test(static_cast<ClassType*>(0)))
+ == sizeof(ei_has_aligned_operator_new_marker_sizeof) };
+};
+
+#ifdef _MSC_VER
+
+ // sometimes, MSVC detects, at compile time, that the argument x
+ // in std::vector::resize(size_t s,T x) won't be aligned and generate an error
+ // even if this function is never called. Whence this little wrapper.
+ #define _EIGEN_WORKAROUND_MSVC_STD_VECTOR(T) Eigen::ei_workaround_msvc_std_vector<T>
+ template<typename T> struct ei_workaround_msvc_std_vector : public T
+ {
+ inline ei_workaround_msvc_std_vector() : T() {}
+ inline ei_workaround_msvc_std_vector(const T& other) : T(other) {}
+ inline operator T& () { return *static_cast<T*>(this); }
+ inline operator const T& () const { return *static_cast<const T*>(this); }
+ template<typename OtherT>
+ inline T& operator=(const OtherT& other)
+ { T::operator=(other); return *this; }
+ inline ei_workaround_msvc_std_vector& operator=(const ei_workaround_msvc_std_vector& other)
+ { T::operator=(other); return *this; }
+ };
+
+#else
+
+ #define _EIGEN_WORKAROUND_MSVC_STD_VECTOR(T) T
+
+#endif
+
+}
+
+namespace std {
+
+#define EIGEN_STD_VECTOR_SPECIALIZATION_BODY \
+ public: \
+ typedef T value_type; \
+ typedef typename vector_base::allocator_type allocator_type; \
+ typedef typename vector_base::size_type size_type; \
+ typedef typename vector_base::iterator iterator; \
+ explicit vector(const allocator_type& __a = allocator_type()) : vector_base(__a) {} \
+ vector(const vector& c) : vector_base(c) {} \
+ vector(size_type num, const value_type& val = value_type()) : vector_base(num, val) {} \
+ vector(iterator start, iterator end) : vector_base(start, end) {} \
+ vector& operator=(const vector& __x) { \
+ vector_base::operator=(__x); \
+ return *this; \
+ }
+
+template<typename T,
+ typename AllocT = std::allocator<T>,
+ bool HasAlignedNew = Eigen::ei_has_aligned_operator_new<T>::ret>
+class vector : public std::std_vector<T,AllocT>
+{
+ typedef std_vector<T, AllocT> vector_base;
+ EIGEN_STD_VECTOR_SPECIALIZATION_BODY
+};
+
+template<typename T,typename DummyAlloc>
+class vector<T,DummyAlloc,true>
+ : public std::std_vector<_EIGEN_WORKAROUND_MSVC_STD_VECTOR(T),
+ Eigen::aligned_allocator<_EIGEN_WORKAROUND_MSVC_STD_VECTOR(T)> >
+{
+ typedef std_vector<_EIGEN_WORKAROUND_MSVC_STD_VECTOR(T),
+ Eigen::aligned_allocator<_EIGEN_WORKAROUND_MSVC_STD_VECTOR(T)> > vector_base;
+ EIGEN_STD_VECTOR_SPECIALIZATION_BODY
+
+ void resize(size_type __new_size)
+ { resize(__new_size, T()); }
+
+ #if defined(_VECTOR_)
+ // workaround MSVC std::vector implementation
+ void resize(size_type __new_size, const value_type& __x)
+ {
+ if (vector_base::size() < __new_size)
+ vector_base::_Insert_n(vector_base::end(), __new_size - vector_base::size(), __x);
+ else if (__new_size < vector_base::size())
+ vector_base::erase(vector_base::begin() + __new_size, vector_base::end());
+ }
+ #elif defined(_GLIBCXX_VECTOR) && EIGEN_GNUC_AT_LEAST(4,2)
+ // workaround GCC std::vector implementation
+ void resize(size_type __new_size, const value_type& __x)
+ {
+ if (__new_size < vector_base::size())
+ vector_base::_M_erase_at_end(this->_M_impl._M_start + __new_size);
+ else
+ vector_base::insert(vector_base::end(), __new_size - vector_base::size(), __x);
+ }
+ #elif defined(_GLIBCXX_VECTOR) && EIGEN_GNUC_AT_LEAST(4,1)
+ void resize(size_type __new_size, const value_type& __x)
+ {
+ if (__new_size < vector_base::size())
+ vector_base::erase(vector_base::begin() + __new_size, vector_base::end());
+ else
+ vector_base::insert(vector_base::end(), __new_size - vector_base::size(), __x);
+ }
+ #else
+ // Before gcc-4.1 we already have: std::vector::resize(size_type,const T&),
+ // so no need for a workaround !
+ using vector_base::resize;
+ #endif
+};
+
+}
+
+#endif // EIGEN_STDVECTOR_MODULE_H
+
+#endif // EIGEN_USE_NEW_STDVECTOR
\ No newline at end of file
// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra.
+// for linear algebra. Eigen itself is part of the KDE project.
//
-// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
+// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
#ifndef EIGEN_ALLANDANY_H
#define EIGEN_ALLANDANY_H
-namespace internal {
-
template<typename Derived, int UnrollCount>
-struct all_unroller
+struct ei_all_unroller
{
enum {
col = (UnrollCount-1) / Derived::RowsAtCompileTime,
inline static bool run(const Derived &mat)
{
- return all_unroller<Derived, UnrollCount-1>::run(mat) && mat.coeff(row, col);
+ return ei_all_unroller<Derived, UnrollCount-1>::run(mat) && mat.coeff(row, col);
}
};
template<typename Derived>
-struct all_unroller<Derived, 1>
+struct ei_all_unroller<Derived, 1>
{
inline static bool run(const Derived &mat) { return mat.coeff(0, 0); }
};
template<typename Derived>
-struct all_unroller<Derived, Dynamic>
+struct ei_all_unroller<Derived, Dynamic>
{
inline static bool run(const Derived &) { return false; }
};
template<typename Derived, int UnrollCount>
-struct any_unroller
+struct ei_any_unroller
{
enum {
col = (UnrollCount-1) / Derived::RowsAtCompileTime,
inline static bool run(const Derived &mat)
{
- return any_unroller<Derived, UnrollCount-1>::run(mat) || mat.coeff(row, col);
+ return ei_any_unroller<Derived, UnrollCount-1>::run(mat) || mat.coeff(row, col);
}
};
template<typename Derived>
-struct any_unroller<Derived, 1>
+struct ei_any_unroller<Derived, 1>
{
inline static bool run(const Derived &mat) { return mat.coeff(0, 0); }
};
template<typename Derived>
-struct any_unroller<Derived, Dynamic>
+struct ei_any_unroller<Derived, Dynamic>
{
inline static bool run(const Derived &) { return false; }
};
-} // end namespace internal
-
-/** \returns true if all coefficients are true
+/** \array_module
+ *
+ * \returns true if all coefficients are true
+ *
+ * \addexample CwiseAll \label How to check whether a point is inside a box (using operator< and all())
*
* Example: \include MatrixBase_all.cpp
* Output: \verbinclude MatrixBase_all.out
*
- * \sa any(), Cwise::operator<()
+ * \sa MatrixBase::any(), Cwise::operator<()
*/
template<typename Derived>
-inline bool DenseBase<Derived>::all() const
+inline bool MatrixBase<Derived>::all() const
{
- enum {
- unroll = SizeAtCompileTime != Dynamic
- && CoeffReadCost != Dynamic
- && NumTraits<Scalar>::AddCost != Dynamic
- && SizeAtCompileTime * (CoeffReadCost + NumTraits<Scalar>::AddCost) <= EIGEN_UNROLLING_LIMIT
- };
+ const bool unroll = SizeAtCompileTime * (CoeffReadCost + NumTraits<Scalar>::AddCost)
+ <= EIGEN_UNROLLING_LIMIT;
if(unroll)
- return internal::all_unroller<Derived,
+ return ei_all_unroller<Derived,
unroll ? int(SizeAtCompileTime) : Dynamic
>::run(derived());
else
{
- for(Index j = 0; j < cols(); ++j)
- for(Index i = 0; i < rows(); ++i)
+ for(int j = 0; j < cols(); ++j)
+ for(int i = 0; i < rows(); ++i)
if (!coeff(i, j)) return false;
return true;
}
}
-/** \returns true if at least one coefficient is true
+/** \array_module
+ *
+ * \returns true if at least one coefficient is true
*
- * \sa all()
+ * \sa MatrixBase::all()
*/
template<typename Derived>
-inline bool DenseBase<Derived>::any() const
+inline bool MatrixBase<Derived>::any() const
{
- enum {
- unroll = SizeAtCompileTime != Dynamic
- && CoeffReadCost != Dynamic
- && NumTraits<Scalar>::AddCost != Dynamic
- && SizeAtCompileTime * (CoeffReadCost + NumTraits<Scalar>::AddCost) <= EIGEN_UNROLLING_LIMIT
- };
+ const bool unroll = SizeAtCompileTime * (CoeffReadCost + NumTraits<Scalar>::AddCost)
+ <= EIGEN_UNROLLING_LIMIT;
if(unroll)
- return internal::any_unroller<Derived,
+ return ei_any_unroller<Derived,
unroll ? int(SizeAtCompileTime) : Dynamic
>::run(derived());
else
{
- for(Index j = 0; j < cols(); ++j)
- for(Index i = 0; i < rows(); ++i)
+ for(int j = 0; j < cols(); ++j)
+ for(int i = 0; i < rows(); ++i)
if (coeff(i, j)) return true;
return false;
}
}
-/** \returns the number of coefficients which evaluate to true
+/** \array_module
+ *
+ * \returns the number of coefficients which evaluate to true
*
- * \sa all(), any()
+ * \sa MatrixBase::all(), MatrixBase::any()
*/
template<typename Derived>
-inline typename DenseBase<Derived>::Index DenseBase<Derived>::count() const
+inline int MatrixBase<Derived>::count() const
{
- return derived().template cast<bool>().template cast<Index>().sum();
+ return this->cast<bool>().cast<int>().sum();
}
#endif // EIGEN_ALLANDANY_H
--- /dev/null
+// This file is part of Eigen, a lightweight C++ template library
+// for linear algebra. Eigen itself is part of the KDE project.
+//
+// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
+//
+// Eigen is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 3 of the License, or (at your option) any later version.
+//
+// Alternatively, 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.
+//
+// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License and a copy of the GNU General Public License along with
+// Eigen. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef EIGEN_ARRAY_CWISE_OPERATORS_H
+#define EIGEN_ARRAY_CWISE_OPERATORS_H
+
+// -- unary operators --
+
+/** \array_module
+ *
+ * \returns an expression of the coefficient-wise square root of *this.
+ *
+ * Example: \include Cwise_sqrt.cpp
+ * Output: \verbinclude Cwise_sqrt.out
+ *
+ * \sa pow(), square()
+ */
+template<typename ExpressionType>
+inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_sqrt_op)
+Cwise<ExpressionType>::sqrt() const
+{
+ return _expression();
+}
+
+/** \array_module
+ *
+ * \returns an expression of the coefficient-wise exponential of *this.
+ *
+ * Example: \include Cwise_exp.cpp
+ * Output: \verbinclude Cwise_exp.out
+ *
+ * \sa pow(), log(), sin(), cos()
+ */
+template<typename ExpressionType>
+inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_exp_op)
+Cwise<ExpressionType>::exp() const
+{
+ return _expression();
+}
+
+/** \array_module
+ *
+ * \returns an expression of the coefficient-wise logarithm of *this.
+ *
+ * Example: \include Cwise_log.cpp
+ * Output: \verbinclude Cwise_log.out
+ *
+ * \sa exp()
+ */
+template<typename ExpressionType>
+inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_log_op)
+Cwise<ExpressionType>::log() const
+{
+ return _expression();
+}
+
+/** \array_module
+ *
+ * \returns an expression of the coefficient-wise cosine of *this.
+ *
+ * Example: \include Cwise_cos.cpp
+ * Output: \verbinclude Cwise_cos.out
+ *
+ * \sa sin(), exp()
+ */
+template<typename ExpressionType>
+inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_cos_op)
+Cwise<ExpressionType>::cos() const
+{
+ return _expression();
+}
+
+
+/** \array_module
+ *
+ * \returns an expression of the coefficient-wise sine of *this.
+ *
+ * Example: \include Cwise_sin.cpp
+ * Output: \verbinclude Cwise_sin.out
+ *
+ * \sa cos(), exp()
+ */
+template<typename ExpressionType>
+inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_sin_op)
+Cwise<ExpressionType>::sin() const
+{
+ return _expression();
+}
+
+
+/** \array_module
+ *
+ * \returns an expression of the coefficient-wise power of *this to the given exponent.
+ *
+ * Example: \include Cwise_pow.cpp
+ * Output: \verbinclude Cwise_pow.out
+ *
+ * \sa exp(), log()
+ */
+template<typename ExpressionType>
+inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_pow_op)
+Cwise<ExpressionType>::pow(const Scalar& exponent) const
+{
+ return EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_pow_op)(_expression(), ei_scalar_pow_op<Scalar>(exponent));
+}
+
+
+/** \array_module
+ *
+ * \returns an expression of the coefficient-wise inverse of *this.
+ *
+ * Example: \include Cwise_inverse.cpp
+ * Output: \verbinclude Cwise_inverse.out
+ *
+ * \sa operator/(), operator*()
+ */
+template<typename ExpressionType>
+inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_inverse_op)
+Cwise<ExpressionType>::inverse() const
+{
+ return _expression();
+}
+
+/** \array_module
+ *
+ * \returns an expression of the coefficient-wise square of *this.
+ *
+ * Example: \include Cwise_square.cpp
+ * Output: \verbinclude Cwise_square.out
+ *
+ * \sa operator/(), operator*(), abs2()
+ */
+template<typename ExpressionType>
+inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_square_op)
+Cwise<ExpressionType>::square() const
+{
+ return _expression();
+}
+
+/** \array_module
+ *
+ * \returns an expression of the coefficient-wise cube of *this.
+ *
+ * Example: \include Cwise_cube.cpp
+ * Output: \verbinclude Cwise_cube.out
+ *
+ * \sa square(), pow()
+ */
+template<typename ExpressionType>
+inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_cube_op)
+Cwise<ExpressionType>::cube() const
+{
+ return _expression();
+}
+
+
+// -- binary operators --
+
+/** \array_module
+ *
+ * \returns an expression of the coefficient-wise \< operator of *this and \a other
+ *
+ * Example: \include Cwise_less.cpp
+ * Output: \verbinclude Cwise_less.out
+ *
+ * \sa MatrixBase::all(), MatrixBase::any(), operator>(), operator<=()
+ */
+template<typename ExpressionType>
+template<typename OtherDerived>
+inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less)
+Cwise<ExpressionType>::operator<(const MatrixBase<OtherDerived> &other) const
+{
+ return EIGEN_CWISE_BINOP_RETURN_TYPE(std::less)(_expression(), other.derived());
+}
+
+/** \array_module
+ *
+ * \returns an expression of the coefficient-wise \<= operator of *this and \a other
+ *
+ * Example: \include Cwise_less_equal.cpp
+ * Output: \verbinclude Cwise_less_equal.out
+ *
+ * \sa MatrixBase::all(), MatrixBase::any(), operator>=(), operator<()
+ */
+template<typename ExpressionType>
+template<typename OtherDerived>
+inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less_equal)
+Cwise<ExpressionType>::operator<=(const MatrixBase<OtherDerived> &other) const
+{
+ return EIGEN_CWISE_BINOP_RETURN_TYPE(std::less_equal)(_expression(), other.derived());
+}
+
+/** \array_module
+ *
+ * \returns an expression of the coefficient-wise \> operator of *this and \a other
+ *
+ * Example: \include Cwise_greater.cpp
+ * Output: \verbinclude Cwise_greater.out
+ *
+ * \sa MatrixBase::all(), MatrixBase::any(), operator>=(), operator<()
+ */
+template<typename ExpressionType>
+template<typename OtherDerived>
+inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater)
+Cwise<ExpressionType>::operator>(const MatrixBase<OtherDerived> &other) const
+{
+ return EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater)(_expression(), other.derived());
+}
+
+/** \array_module
+ *
+ * \returns an expression of the coefficient-wise \>= operator of *this and \a other
+ *
+ * Example: \include Cwise_greater_equal.cpp
+ * Output: \verbinclude Cwise_greater_equal.out
+ *
+ * \sa MatrixBase::all(), MatrixBase::any(), operator>(), operator<=()
+ */
+template<typename ExpressionType>
+template<typename OtherDerived>
+inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater_equal)
+Cwise<ExpressionType>::operator>=(const MatrixBase<OtherDerived> &other) const
+{
+ return EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater_equal)(_expression(), other.derived());
+}
+
+/** \array_module
+ *
+ * \returns an expression of the coefficient-wise == operator of *this and \a other
+ *
+ * \warning this performs an exact comparison, which is generally a bad idea with floating-point types.
+ * In order to check for equality between two vectors or matrices with floating-point coefficients, it is
+ * generally a far better idea to use a fuzzy comparison as provided by MatrixBase::isApprox() and
+ * MatrixBase::isMuchSmallerThan().
+ *
+ * Example: \include Cwise_equal_equal.cpp
+ * Output: \verbinclude Cwise_equal_equal.out
+ *
+ * \sa MatrixBase::all(), MatrixBase::any(), MatrixBase::isApprox(), MatrixBase::isMuchSmallerThan()
+ */
+template<typename ExpressionType>
+template<typename OtherDerived>
+inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::equal_to)
+Cwise<ExpressionType>::operator==(const MatrixBase<OtherDerived> &other) const
+{
+ return EIGEN_CWISE_BINOP_RETURN_TYPE(std::equal_to)(_expression(), other.derived());
+}
+
+/** \array_module
+ *
+ * \returns an expression of the coefficient-wise != operator of *this and \a other
+ *
+ * \warning this performs an exact comparison, which is generally a bad idea with floating-point types.
+ * In order to check for equality between two vectors or matrices with floating-point coefficients, it is
+ * generally a far better idea to use a fuzzy comparison as provided by MatrixBase::isApprox() and
+ * MatrixBase::isMuchSmallerThan().
+ *
+ * Example: \include Cwise_not_equal.cpp
+ * Output: \verbinclude Cwise_not_equal.out
+ *
+ * \sa MatrixBase::all(), MatrixBase::any(), MatrixBase::isApprox(), MatrixBase::isMuchSmallerThan()
+ */
+template<typename ExpressionType>
+template<typename OtherDerived>
+inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::not_equal_to)
+Cwise<ExpressionType>::operator!=(const MatrixBase<OtherDerived> &other) const
+{
+ return EIGEN_CWISE_BINOP_RETURN_TYPE(std::not_equal_to)(_expression(), other.derived());
+}
+
+// comparisons to scalar value
+
+/** \array_module
+ *
+ * \returns an expression of the coefficient-wise \< operator of *this and a scalar \a s
+ *
+ * \sa operator<(const MatrixBase<OtherDerived> &) const
+ */
+template<typename ExpressionType>
+inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less)
+Cwise<ExpressionType>::operator<(Scalar s) const
+{
+ return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less)(_expression(),
+ typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s));
+}
+
+/** \array_module
+ *
+ * \returns an expression of the coefficient-wise \<= operator of *this and a scalar \a s
+ *
+ * \sa operator<=(const MatrixBase<OtherDerived> &) const
+ */
+template<typename ExpressionType>
+inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less_equal)
+Cwise<ExpressionType>::operator<=(Scalar s) const
+{
+ return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less_equal)(_expression(),
+ typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s));
+}
+
+/** \array_module
+ *
+ * \returns an expression of the coefficient-wise \> operator of *this and a scalar \a s
+ *
+ * \sa operator>(const MatrixBase<OtherDerived> &) const
+ */
+template<typename ExpressionType>
+inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater)
+Cwise<ExpressionType>::operator>(Scalar s) const
+{
+ return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater)(_expression(),
+ typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s));
+}
+
+/** \array_module
+ *
+ * \returns an expression of the coefficient-wise \>= operator of *this and a scalar \a s
+ *
+ * \sa operator>=(const MatrixBase<OtherDerived> &) const
+ */
+template<typename ExpressionType>
+inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater_equal)
+Cwise<ExpressionType>::operator>=(Scalar s) const
+{
+ return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater_equal)(_expression(),
+ typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s));
+}
+
+/** \array_module
+ *
+ * \returns an expression of the coefficient-wise == operator of *this and a scalar \a s
+ *
+ * \warning this performs an exact comparison, which is generally a bad idea with floating-point types.
+ * In order to check for equality between two vectors or matrices with floating-point coefficients, it is
+ * generally a far better idea to use a fuzzy comparison as provided by MatrixBase::isApprox() and
+ * MatrixBase::isMuchSmallerThan().
+ *
+ * \sa operator==(const MatrixBase<OtherDerived> &) const
+ */
+template<typename ExpressionType>
+inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::equal_to)
+Cwise<ExpressionType>::operator==(Scalar s) const
+{
+ return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::equal_to)(_expression(),
+ typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s));
+}
+
+/** \array_module
+ *
+ * \returns an expression of the coefficient-wise != operator of *this and a scalar \a s
+ *
+ * \warning this performs an exact comparison, which is generally a bad idea with floating-point types.
+ * In order to check for equality between two vectors or matrices with floating-point coefficients, it is
+ * generally a far better idea to use a fuzzy comparison as provided by MatrixBase::isApprox() and
+ * MatrixBase::isMuchSmallerThan().
+ *
+ * \sa operator!=(const MatrixBase<OtherDerived> &) const
+ */
+template<typename ExpressionType>
+inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::not_equal_to)
+Cwise<ExpressionType>::operator!=(Scalar s) const
+{
+ return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::not_equal_to)(_expression(),
+ typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s));
+}
+
+// scalar addition
+
+/** \array_module
+ *
+ * \returns an expression of \c *this with each coeff incremented by the constant \a scalar
+ *
+ * Example: \include Cwise_plus.cpp
+ * Output: \verbinclude Cwise_plus.out
+ *
+ * \sa operator+=(), operator-()
+ */
+template<typename ExpressionType>
+inline const typename Cwise<ExpressionType>::ScalarAddReturnType
+Cwise<ExpressionType>::operator+(const Scalar& scalar) const
+{
+ return typename Cwise<ExpressionType>::ScalarAddReturnType(m_matrix, ei_scalar_add_op<Scalar>(scalar));
+}
+
+/** \array_module
+ *
+ * Adds the given \a scalar to each coeff of this expression.
+ *
+ * Example: \include Cwise_plus_equal.cpp
+ * Output: \verbinclude Cwise_plus_equal.out
+ *
+ * \sa operator+(), operator-=()
+ */
+template<typename ExpressionType>
+inline ExpressionType& Cwise<ExpressionType>::operator+=(const Scalar& scalar)
+{
+ return m_matrix.const_cast_derived() = *this + scalar;
+}
+
+/** \array_module
+ *
+ * \returns an expression of \c *this with each coeff decremented by the constant \a scalar
+ *
+ * Example: \include Cwise_minus.cpp
+ * Output: \verbinclude Cwise_minus.out
+ *
+ * \sa operator+(), operator-=()
+ */
+template<typename ExpressionType>
+inline const typename Cwise<ExpressionType>::ScalarAddReturnType
+Cwise<ExpressionType>::operator-(const Scalar& scalar) const
+{
+ return *this + (-scalar);
+}
+
+/** \array_module
+ *
+ * Substracts the given \a scalar from each coeff of this expression.
+ *
+ * Example: \include Cwise_minus_equal.cpp
+ * Output: \verbinclude Cwise_minus_equal.out
+ *
+ * \sa operator+=(), operator-()
+ */
+
+template<typename ExpressionType>
+inline ExpressionType& Cwise<ExpressionType>::operator-=(const Scalar& scalar)
+{
+ return m_matrix.const_cast_derived() = *this - scalar;
+}
+
+#endif // EIGEN_ARRAY_CWISE_OPERATORS_H
--- /dev/null
+// This file is part of Eigen, a lightweight C++ template library
+// for linear algebra. Eigen itself is part of the KDE project.
+//
+// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
+//
+// Eigen is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 3 of the License, or (at your option) any later version.
+//
+// Alternatively, 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.
+//
+// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License and a copy of the GNU General Public License along with
+// Eigen. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef EIGEN_ARRAY_FUNCTORS_H
+#define EIGEN_ARRAY_FUNCTORS_H
+
+/** \internal
+ * \array_module
+ *
+ * \brief Template functor to add a scalar to a fixed other one
+ *
+ * \sa class CwiseUnaryOp, Array::operator+
+ */
+/* If you wonder why doing the ei_pset1() in packetOp() is an optimization check ei_scalar_multiple_op */
+template<typename Scalar>
+struct ei_scalar_add_op {
+ typedef typename ei_packet_traits<Scalar>::type PacketScalar;
+ // FIXME default copy constructors seems bugged with std::complex<>
+ inline ei_scalar_add_op(const ei_scalar_add_op& other) : m_other(other.m_other) { }
+ inline ei_scalar_add_op(const Scalar& other) : m_other(other) { }
+ inline Scalar operator() (const Scalar& a) const { return a + m_other; }
+ inline const PacketScalar packetOp(const PacketScalar& a) const
+ { return ei_padd(a, ei_pset1(m_other)); }
+ const Scalar m_other;
+private:
+ ei_scalar_add_op& operator=(const ei_scalar_add_op&);
+};
+template<typename Scalar>
+struct ei_functor_traits<ei_scalar_add_op<Scalar> >
+{ enum { Cost = NumTraits<Scalar>::AddCost, PacketAccess = ei_packet_traits<Scalar>::size>1 }; };
+
+/** \internal
+ *
+ * \array_module
+ *
+ * \brief Template functor to compute the square root of a scalar
+ *
+ * \sa class CwiseUnaryOp, Cwise::sqrt()
+ */
+template<typename Scalar> struct ei_scalar_sqrt_op EIGEN_EMPTY_STRUCT {
+ inline const Scalar operator() (const Scalar& a) const { return ei_sqrt(a); }
+};
+template<typename Scalar>
+struct ei_functor_traits<ei_scalar_sqrt_op<Scalar> >
+{ enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = false }; };
+
+/** \internal
+ *
+ * \array_module
+ *
+ * \brief Template functor to compute the exponential of a scalar
+ *
+ * \sa class CwiseUnaryOp, Cwise::exp()
+ */
+template<typename Scalar> struct ei_scalar_exp_op EIGEN_EMPTY_STRUCT {
+ inline const Scalar operator() (const Scalar& a) const { return ei_exp(a); }
+};
+template<typename Scalar>
+struct ei_functor_traits<ei_scalar_exp_op<Scalar> >
+{ enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = false }; };
+
+/** \internal
+ *
+ * \array_module
+ *
+ * \brief Template functor to compute the logarithm of a scalar
+ *
+ * \sa class CwiseUnaryOp, Cwise::log()
+ */
+template<typename Scalar> struct ei_scalar_log_op EIGEN_EMPTY_STRUCT {
+ inline const Scalar operator() (const Scalar& a) const { return ei_log(a); }
+};
+template<typename Scalar>
+struct ei_functor_traits<ei_scalar_log_op<Scalar> >
+{ enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = false }; };
+
+/** \internal
+ *
+ * \array_module
+ *
+ * \brief Template functor to compute the cosine of a scalar
+ *
+ * \sa class CwiseUnaryOp, Cwise::cos()
+ */
+template<typename Scalar> struct ei_scalar_cos_op EIGEN_EMPTY_STRUCT {
+ inline const Scalar operator() (const Scalar& a) const { return ei_cos(a); }
+};
+template<typename Scalar>
+struct ei_functor_traits<ei_scalar_cos_op<Scalar> >
+{ enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = false }; };
+
+/** \internal
+ *
+ * \array_module
+ *
+ * \brief Template functor to compute the sine of a scalar
+ *
+ * \sa class CwiseUnaryOp, Cwise::sin()
+ */
+template<typename Scalar> struct ei_scalar_sin_op EIGEN_EMPTY_STRUCT {
+ inline const Scalar operator() (const Scalar& a) const { return ei_sin(a); }
+};
+template<typename Scalar>
+struct ei_functor_traits<ei_scalar_sin_op<Scalar> >
+{ enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = false }; };
+
+/** \internal
+ *
+ * \array_module
+ *
+ * \brief Template functor to raise a scalar to a power
+ *
+ * \sa class CwiseUnaryOp, Cwise::pow
+ */
+template<typename Scalar>
+struct ei_scalar_pow_op {
+ // FIXME default copy constructors seems bugged with std::complex<>
+ inline ei_scalar_pow_op(const ei_scalar_pow_op& other) : m_exponent(other.m_exponent) { }
+ inline ei_scalar_pow_op(const Scalar& exponent) : m_exponent(exponent) {}
+ inline Scalar operator() (const Scalar& a) const { return ei_pow(a, m_exponent); }
+ const Scalar m_exponent;
+private:
+ ei_scalar_pow_op& operator=(const ei_scalar_pow_op&);
+};
+template<typename Scalar>
+struct ei_functor_traits<ei_scalar_pow_op<Scalar> >
+{ enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = false }; };
+
+/** \internal
+ *
+ * \array_module
+ *
+ * \brief Template functor to compute the inverse of a scalar
+ *
+ * \sa class CwiseUnaryOp, Cwise::inverse()
+ */
+template<typename Scalar>
+struct ei_scalar_inverse_op {
+ inline Scalar operator() (const Scalar& a) const { return Scalar(1)/a; }
+ template<typename PacketScalar>
+ inline const PacketScalar packetOp(const PacketScalar& a) const
+ { return ei_pdiv(ei_pset1(Scalar(1)),a); }
+};
+template<typename Scalar>
+struct ei_functor_traits<ei_scalar_inverse_op<Scalar> >
+{ enum { Cost = NumTraits<Scalar>::MulCost, PacketAccess = int(ei_packet_traits<Scalar>::size)>1 }; };
+
+/** \internal
+ *
+ * \array_module
+ *
+ * \brief Template functor to compute the square of a scalar
+ *
+ * \sa class CwiseUnaryOp, Cwise::square()
+ */
+template<typename Scalar>
+struct ei_scalar_square_op {
+ inline Scalar operator() (const Scalar& a) const { return a*a; }
+ template<typename PacketScalar>
+ inline const PacketScalar packetOp(const PacketScalar& a) const
+ { return ei_pmul(a,a); }
+};
+template<typename Scalar>
+struct ei_functor_traits<ei_scalar_square_op<Scalar> >
+{ enum { Cost = NumTraits<Scalar>::MulCost, PacketAccess = int(ei_packet_traits<Scalar>::size)>1 }; };
+
+/** \internal
+ *
+ * \array_module
+ *
+ * \brief Template functor to compute the cube of a scalar
+ *
+ * \sa class CwiseUnaryOp, Cwise::cube()
+ */
+template<typename Scalar>
+struct ei_scalar_cube_op {
+ inline Scalar operator() (const Scalar& a) const { return a*a*a; }
+ template<typename PacketScalar>
+ inline const PacketScalar packetOp(const PacketScalar& a) const
+ { return ei_pmul(a,ei_pmul(a,a)); }
+};
+template<typename Scalar>
+struct ei_functor_traits<ei_scalar_cube_op<Scalar> >
+{ enum { Cost = 2*NumTraits<Scalar>::MulCost, PacketAccess = int(ei_packet_traits<Scalar>::size)>1 }; };
+
+// default ei_functor_traits for STL functors:
+
+template<typename T>
+struct ei_functor_traits<std::multiplies<T> >
+{ enum { Cost = NumTraits<T>::MulCost, PacketAccess = false }; };
+
+template<typename T>
+struct ei_functor_traits<std::divides<T> >
+{ enum { Cost = NumTraits<T>::MulCost, PacketAccess = false }; };
+
+template<typename T>
+struct ei_functor_traits<std::plus<T> >
+{ enum { Cost = NumTraits<T>::AddCost, PacketAccess = false }; };
+
+template<typename T>
+struct ei_functor_traits<std::minus<T> >
+{ enum { Cost = NumTraits<T>::AddCost, PacketAccess = false }; };
+
+template<typename T>
+struct ei_functor_traits<std::negate<T> >
+{ enum { Cost = NumTraits<T>::AddCost, PacketAccess = false }; };
+
+template<typename T>
+struct ei_functor_traits<std::logical_or<T> >
+{ enum { Cost = 1, PacketAccess = false }; };
+
+template<typename T>
+struct ei_functor_traits<std::logical_and<T> >
+{ enum { Cost = 1, PacketAccess = false }; };
+
+template<typename T>
+struct ei_functor_traits<std::logical_not<T> >
+{ enum { Cost = 1, PacketAccess = false }; };
+
+template<typename T>
+struct ei_functor_traits<std::greater<T> >
+{ enum { Cost = 1, PacketAccess = false }; };
+
+template<typename T>
+struct ei_functor_traits<std::less<T> >
+{ enum { Cost = 1, PacketAccess = false }; };
+
+template<typename T>
+struct ei_functor_traits<std::greater_equal<T> >
+{ enum { Cost = 1, PacketAccess = false }; };
+
+template<typename T>
+struct ei_functor_traits<std::less_equal<T> >
+{ enum { Cost = 1, PacketAccess = false }; };
+
+template<typename T>
+struct ei_functor_traits<std::equal_to<T> >
+{ enum { Cost = 1, PacketAccess = false }; };
+
+template<typename T>
+struct ei_functor_traits<std::not_equal_to<T> >
+{ enum { Cost = 1, PacketAccess = false }; };
+
+template<typename T>
+struct ei_functor_traits<std::binder2nd<T> >
+{ enum { Cost = ei_functor_traits<T>::Cost, PacketAccess = false }; };
+
+template<typename T>
+struct ei_functor_traits<std::binder1st<T> >
+{ enum { Cost = ei_functor_traits<T>::Cost, PacketAccess = false }; };
+
+template<typename T>
+struct ei_functor_traits<std::unary_negate<T> >
+{ enum { Cost = 1 + ei_functor_traits<T>::Cost, PacketAccess = false }; };
+
+template<typename T>
+struct ei_functor_traits<std::binary_negate<T> >
+{ enum { Cost = 1 + ei_functor_traits<T>::Cost, PacketAccess = false }; };
+
+#ifdef EIGEN_STDEXT_SUPPORT
+
+template<typename T0,typename T1>
+struct ei_functor_traits<std::project1st<T0,T1> >
+{ enum { Cost = 0, PacketAccess = false }; };
+
+template<typename T0,typename T1>
+struct ei_functor_traits<std::project2nd<T0,T1> >
+{ enum { Cost = 0, PacketAccess = false }; };
+
+template<typename T0,typename T1>
+struct ei_functor_traits<std::select2nd<std::pair<T0,T1> > >
+{ enum { Cost = 0, PacketAccess = false }; };
+
+template<typename T0,typename T1>
+struct ei_functor_traits<std::select1st<std::pair<T0,T1> > >
+{ enum { Cost = 0, PacketAccess = false }; };
+
+template<typename T0,typename T1>
+struct ei_functor_traits<std::unary_compose<T0,T1> >
+{ enum { Cost = ei_functor_traits<T0>::Cost + ei_functor_traits<T1>::Cost, PacketAccess = false }; };
+
+template<typename T0,typename T1,typename T2>
+struct ei_functor_traits<std::binary_compose<T0,T1,T2> >
+{ enum { Cost = ei_functor_traits<T0>::Cost + ei_functor_traits<T1>::Cost + ei_functor_traits<T2>::Cost, PacketAccess = false }; };
+
+#endif // EIGEN_STDEXT_SUPPORT
+
+#endif // EIGEN_ARRAY_FUNCTORS_H
--- /dev/null
+// This file is part of Eigen, a lightweight C++ template library
+// for linear algebra. Eigen itself is part of the KDE project.
+//
+// Copyright (C) 2008 Benoit Jacob <jacob.benoit.1@gmail.com>
+//
+// Eigen is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 3 of the License, or (at your option) any later version.
+//
+// Alternatively, 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.
+//
+// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License and a copy of the GNU General Public License along with
+// Eigen. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef EIGEN_ARRAY_NORMS_H
+#define EIGEN_ARRAY_NORMS_H
+
+template<typename Derived, int p>
+struct ei_lpNorm_selector
+{
+ typedef typename NumTraits<typename ei_traits<Derived>::Scalar>::Real RealScalar;
+ inline static RealScalar run(const MatrixBase<Derived>& m)
+ {
+ return ei_pow(m.cwise().abs().cwise().pow(p).sum(), RealScalar(1)/p);
+ }
+};
+
+template<typename Derived>
+struct ei_lpNorm_selector<Derived, 1>
+{
+ inline static typename NumTraits<typename ei_traits<Derived>::Scalar>::Real run(const MatrixBase<Derived>& m)
+ {
+ return m.cwise().abs().sum();
+ }
+};
+
+template<typename Derived>
+struct ei_lpNorm_selector<Derived, 2>
+{
+ inline static typename NumTraits<typename ei_traits<Derived>::Scalar>::Real run(const MatrixBase<Derived>& m)
+ {
+ return m.norm();
+ }
+};
+
+template<typename Derived>
+struct ei_lpNorm_selector<Derived, Infinity>
+{
+ inline static typename NumTraits<typename ei_traits<Derived>::Scalar>::Real run(const MatrixBase<Derived>& m)
+ {
+ return m.cwise().abs().maxCoeff();
+ }
+};
+
+/** \array_module
+ *
+ * \returns the \f$ \ell^p \f$ norm of *this, that is, returns the p-th root of the sum of the p-th powers of the absolute values
+ * of the coefficients of *this. If \a p is the special value \a Eigen::Infinity, this function returns the \f$ \ell^p\infty \f$
+ * norm, that is the maximum of the absolute values of the coefficients of *this.
+ *
+ * \sa norm()
+ */
+template<typename Derived>
+template<int p>
+inline typename NumTraits<typename ei_traits<Derived>::Scalar>::Real MatrixBase<Derived>::lpNorm() const
+{
+ return ei_lpNorm_selector<Derived, p>::run(*this);
+}
+
+#endif // EIGEN_ARRAY_NORMS_H
--- /dev/null
+// This file is part of Eigen, a lightweight C++ template library
+// for linear algebra. Eigen itself is part of the KDE project.
+//
+// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
+// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
+//
+// Eigen is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 3 of the License, or (at your option) any later version.
+//
+// Alternatively, 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.
+//
+// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License and a copy of the GNU General Public License along with
+// Eigen. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef EIGEN_PARTIAL_REDUX_H
+#define EIGEN_PARTIAL_REDUX_H
+
+/** \array_module \ingroup Array
+ *
+ * \class PartialReduxExpr
+ *
+ * \brief Generic expression of a partially reduxed matrix
+ *
+ * \param MatrixType the type of the matrix we are applying the redux operation
+ * \param MemberOp type of the member functor
+ * \param Direction indicates the direction of the redux (Vertical or Horizontal)
+ *
+ * This class represents an expression of a partial redux operator of a matrix.
+ * It is the return type of PartialRedux functions,
+ * and most of the time this is the only way it is used.
+ *
+ * \sa class PartialRedux
+ */
+
+template< typename MatrixType, typename MemberOp, int Direction>
+class PartialReduxExpr;
+
+template<typename MatrixType, typename MemberOp, int Direction>
+struct ei_traits<PartialReduxExpr<MatrixType, MemberOp, Direction> >
+{
+ typedef typename MemberOp::result_type Scalar;
+ typedef typename MatrixType::Scalar InputScalar;
+ typedef typename ei_nested<MatrixType>::type MatrixTypeNested;
+ typedef typename ei_cleantype<MatrixTypeNested>::type _MatrixTypeNested;
+ enum {
+ RowsAtCompileTime = Direction==Vertical ? 1 : MatrixType::RowsAtCompileTime,
+ ColsAtCompileTime = Direction==Horizontal ? 1 : MatrixType::ColsAtCompileTime,
+ MaxRowsAtCompileTime = Direction==Vertical ? 1 : MatrixType::MaxRowsAtCompileTime,
+ MaxColsAtCompileTime = Direction==Horizontal ? 1 : MatrixType::MaxColsAtCompileTime,
+ Flags = (unsigned int)_MatrixTypeNested::Flags & HereditaryBits,
+ TraversalSize = Direction==Vertical ? RowsAtCompileTime : ColsAtCompileTime
+ };
+ #if EIGEN_GNUC_AT_LEAST(3,4)
+ typedef typename MemberOp::template Cost<InputScalar,int(TraversalSize)> CostOpType;
+ #else
+ typedef typename MemberOp::template Cost<InputScalar,TraversalSize> CostOpType;
+ #endif
+ enum {
+ CoeffReadCost = TraversalSize * ei_traits<_MatrixTypeNested>::CoeffReadCost + int(CostOpType::value)
+ };
+};
+
+template< typename MatrixType, typename MemberOp, int Direction>
+class PartialReduxExpr : ei_no_assignment_operator,
+ public MatrixBase<PartialReduxExpr<MatrixType, MemberOp, Direction> >
+{
+ public:
+
+ EIGEN_GENERIC_PUBLIC_INTERFACE(PartialReduxExpr)
+ typedef typename ei_traits<PartialReduxExpr>::MatrixTypeNested MatrixTypeNested;
+ typedef typename ei_traits<PartialReduxExpr>::_MatrixTypeNested _MatrixTypeNested;
+
+ PartialReduxExpr(const MatrixType& mat, const MemberOp& func = MemberOp())
+ : m_matrix(mat), m_functor(func) {}
+
+ int rows() const { return (Direction==Vertical ? 1 : m_matrix.rows()); }
+ int cols() const { return (Direction==Horizontal ? 1 : m_matrix.cols()); }
+
+ const Scalar coeff(int i, int j) const
+ {
+ if (Direction==Vertical)
+ return m_functor(m_matrix.col(j));
+ else
+ return m_functor(m_matrix.row(i));
+ }
+
+ protected:
+ const MatrixTypeNested m_matrix;
+ const MemberOp m_functor;
+};
+
+#define EIGEN_MEMBER_FUNCTOR(MEMBER,COST) \
+ template <typename ResultType> \
+ struct ei_member_##MEMBER EIGEN_EMPTY_STRUCT { \
+ typedef ResultType result_type; \
+ template<typename Scalar, int Size> struct Cost \
+ { enum { value = COST }; }; \
+ template<typename Derived> \
+ inline ResultType operator()(const MatrixBase<Derived>& mat) const \
+ { return mat.MEMBER(); } \
+ }
+
+EIGEN_MEMBER_FUNCTOR(squaredNorm, Size * NumTraits<Scalar>::MulCost + (Size-1)*NumTraits<Scalar>::AddCost);
+EIGEN_MEMBER_FUNCTOR(norm, (Size+5) * NumTraits<Scalar>::MulCost + (Size-1)*NumTraits<Scalar>::AddCost);
+EIGEN_MEMBER_FUNCTOR(sum, (Size-1)*NumTraits<Scalar>::AddCost);
+EIGEN_MEMBER_FUNCTOR(minCoeff, (Size-1)*NumTraits<Scalar>::AddCost);
+EIGEN_MEMBER_FUNCTOR(maxCoeff, (Size-1)*NumTraits<Scalar>::AddCost);
+EIGEN_MEMBER_FUNCTOR(all, (Size-1)*NumTraits<Scalar>::AddCost);
+EIGEN_MEMBER_FUNCTOR(any, (Size-1)*NumTraits<Scalar>::AddCost);
+EIGEN_MEMBER_FUNCTOR(count, (Size-1)*NumTraits<Scalar>::AddCost);
+
+/** \internal */
+template <typename BinaryOp, typename Scalar>
+struct ei_member_redux {
+ typedef typename ei_result_of<
+ BinaryOp(Scalar)
+ >::type result_type;
+ template<typename _Scalar, int Size> struct Cost
+ { enum { value = (Size-1) * ei_functor_traits<BinaryOp>::Cost }; };
+ ei_member_redux(const BinaryOp func) : m_functor(func) {}
+ template<typename Derived>
+ inline result_type operator()(const MatrixBase<Derived>& mat) const
+ { return mat.redux(m_functor); }
+ const BinaryOp m_functor;
+private:
+ ei_member_redux& operator=(const ei_member_redux&);
+};
+
+/** \array_module \ingroup Array
+ *
+ * \class PartialRedux
+ *
+ * \brief Pseudo expression providing partial reduction operations
+ *
+ * \param ExpressionType the type of the object on which to do partial reductions
+ * \param Direction indicates the direction of the redux (Vertical or Horizontal)
+ *
+ * This class represents a pseudo expression with partial reduction features.
+ * It is the return type of MatrixBase::colwise() and MatrixBase::rowwise()
+ * and most of the time this is the only way it is used.
+ *
+ * Example: \include MatrixBase_colwise.cpp
+ * Output: \verbinclude MatrixBase_colwise.out
+ *
+ * \sa MatrixBase::colwise(), MatrixBase::rowwise(), class PartialReduxExpr
+ */
+template<typename ExpressionType, int Direction> class PartialRedux
+{
+ public:
+
+ typedef typename ei_traits<ExpressionType>::Scalar Scalar;
+ typedef typename ei_meta_if<ei_must_nest_by_value<ExpressionType>::ret,
+ ExpressionType, const ExpressionType&>::ret ExpressionTypeNested;
+
+ template<template<typename _Scalar> class Functor> struct ReturnType
+ {
+ typedef PartialReduxExpr<ExpressionType,
+ Functor<typename ei_traits<ExpressionType>::Scalar>,
+ Direction
+ > Type;
+ };
+
+ template<typename BinaryOp> struct ReduxReturnType
+ {
+ typedef PartialReduxExpr<ExpressionType,
+ ei_member_redux<BinaryOp,typename ei_traits<ExpressionType>::Scalar>,
+ Direction
+ > Type;
+ };
+
+ typedef typename ExpressionType::PlainMatrixType CrossReturnType;
+
+ inline PartialRedux(const ExpressionType& matrix) : m_matrix(matrix) {}
+
+ /** \internal */
+ inline const ExpressionType& _expression() const { return m_matrix; }
+
+ template<typename BinaryOp>
+ const typename ReduxReturnType<BinaryOp>::Type
+ redux(const BinaryOp& func = BinaryOp()) const;
+
+ /** \returns a row (or column) vector expression of the smallest coefficient
+ * of each column (or row) of the referenced expression.
+ *
+ * Example: \include PartialRedux_minCoeff.cpp
+ * Output: \verbinclude PartialRedux_minCoeff.out
+ *
+ * \sa MatrixBase::minCoeff() */
+ const typename ReturnType<ei_member_minCoeff>::Type minCoeff() const
+ { return _expression(); }
+
+ /** \returns a row (or column) vector expression of the largest coefficient
+ * of each column (or row) of the referenced expression.
+ *
+ * Example: \include PartialRedux_maxCoeff.cpp
+ * Output: \verbinclude PartialRedux_maxCoeff.out
+ *
+ * \sa MatrixBase::maxCoeff() */
+ const typename ReturnType<ei_member_maxCoeff>::Type maxCoeff() const
+ { return _expression(); }
+
+ /** \returns a row (or column) vector expression of the squared norm
+ * of each column (or row) of the referenced expression.
+ *
+ * Example: \include PartialRedux_squaredNorm.cpp
+ * Output: \verbinclude PartialRedux_squaredNorm.out
+ *
+ * \sa MatrixBase::squaredNorm() */
+ const typename ReturnType<ei_member_squaredNorm>::Type squaredNorm() const
+ { return _expression(); }
+
+ /** \returns a row (or column) vector expression of the norm
+ * of each column (or row) of the referenced expression.
+ *
+ * Example: \include PartialRedux_norm.cpp
+ * Output: \verbinclude PartialRedux_norm.out
+ *
+ * \sa MatrixBase::norm() */
+ const typename ReturnType<ei_member_norm>::Type norm() const
+ { return _expression(); }
+
+ /** \returns a row (or column) vector expression of the sum
+ * of each column (or row) of the referenced expression.
+ *
+ * Example: \include PartialRedux_sum.cpp
+ * Output: \verbinclude PartialRedux_sum.out
+ *
+ * \sa MatrixBase::sum() */
+ const typename ReturnType<ei_member_sum>::Type sum() const
+ { return _expression(); }
+
+ /** \returns a row (or column) vector expression representing
+ * whether \b all coefficients of each respective column (or row) are \c true.
+ *
+ * \sa MatrixBase::all() */
+ const typename ReturnType<ei_member_all>::Type all() const
+ { return _expression(); }
+
+ /** \returns a row (or column) vector expression representing
+ * whether \b at \b least one coefficient of each respective column (or row) is \c true.
+ *
+ * \sa MatrixBase::any() */
+ const typename ReturnType<ei_member_any>::Type any() const
+ { return _expression(); }
+
+ /** \returns a row (or column) vector expression representing
+ * the number of \c true coefficients of each respective column (or row).
+ *
+ * Example: \include PartialRedux_count.cpp
+ * Output: \verbinclude PartialRedux_count.out
+ *
+ * \sa MatrixBase::count() */
+ const PartialReduxExpr<ExpressionType, ei_member_count<int>, Direction> count() const
+ { return _expression(); }
+
+ /** \returns a 3x3 matrix expression of the cross product
+ * of each column or row of the referenced expression with the \a other vector.
+ *
+ * \geometry_module
+ *
+ * \sa MatrixBase::cross() */
+ template<typename OtherDerived>
+ const CrossReturnType cross(const MatrixBase<OtherDerived>& other) const
+ {
+ EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(CrossReturnType,3,3)
+ EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,3)
+ EIGEN_STATIC_ASSERT((ei_is_same_type<Scalar, typename OtherDerived::Scalar>::ret),
+ YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
+
+ if(Direction==Vertical)
+ return (CrossReturnType()
+ << _expression().col(0).cross(other),
+ _expression().col(1).cross(other),
+ _expression().col(2).cross(other)).finished();
+ else
+ return (CrossReturnType()
+ << _expression().row(0).cross(other),
+ _expression().row(1).cross(other),
+ _expression().row(2).cross(other)).finished();
+ }
+
+ protected:
+ ExpressionTypeNested m_matrix;
+
+ private:
+ PartialRedux& operator=(const PartialRedux&);
+};
+
+/** \array_module
+ *
+ * \returns a PartialRedux wrapper of *this providing additional partial reduction operations
+ *
+ * Example: \include MatrixBase_colwise.cpp
+ * Output: \verbinclude MatrixBase_colwise.out
+ *
+ * \sa rowwise(), class PartialRedux
+ */
+template<typename Derived>
+inline const PartialRedux<Derived,Vertical>
+MatrixBase<Derived>::colwise() const
+{
+ return derived();
+}
+
+/** \array_module
+ *
+ * \returns a PartialRedux wrapper of *this providing additional partial reduction operations
+ *
+ * Example: \include MatrixBase_rowwise.cpp
+ * Output: \verbinclude MatrixBase_rowwise.out
+ *
+ * \sa colwise(), class PartialRedux
+ */
+template<typename Derived>
+inline const PartialRedux<Derived,Horizontal>
+MatrixBase<Derived>::rowwise() const
+{
+ return derived();
+}
+
+/** \returns a row or column vector expression of \c *this reduxed by \a func
+ *
+ * The template parameter \a BinaryOp is the type of the functor
+ * of the custom redux operator. Note that func must be an associative operator.
+ *
+ * \sa class PartialRedux, MatrixBase::colwise(), MatrixBase::rowwise()
+ */
+template<typename ExpressionType, int Direction>
+template<typename BinaryOp>
+const typename PartialRedux<ExpressionType,Direction>::template ReduxReturnType<BinaryOp>::Type
+PartialRedux<ExpressionType,Direction>::redux(const BinaryOp& func) const
+{
+ return typename ReduxReturnType<BinaryOp>::Type(_expression(), func);
+}
+
+#endif // EIGEN_PARTIAL_REDUX_H
// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra.
+// for linear algebra. Eigen itself is part of the KDE project.
//
-// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
+// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
#ifndef EIGEN_RANDOM_H
#define EIGEN_RANDOM_H
-namespace internal {
-
-template<typename Scalar> struct scalar_random_op {
- EIGEN_EMPTY_STRUCT_CTOR(scalar_random_op)
- template<typename Index>
- inline const Scalar operator() (Index, Index = 0) const { return random<Scalar>(); }
+template<typename Scalar> struct ei_scalar_random_op EIGEN_EMPTY_STRUCT {
+ inline ei_scalar_random_op(void) {}
+ inline const Scalar operator() (int, int) const { return ei_random<Scalar>(); }
};
-
template<typename Scalar>
-struct functor_traits<scalar_random_op<Scalar> >
+struct ei_functor_traits<ei_scalar_random_op<Scalar> >
{ enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = false, IsRepeatable = false }; };
-} // end namespace internal
-
-/** \returns a random matrix expression
+/** \array_module
+ *
+ * \returns a random matrix (not an expression, the matrix is immediately evaluated).
*
* The parameters \a rows and \a cols are the number of rows and of columns of
* the returned matrix. Must be compatible with this MatrixBase type.
*
* This variant is meant to be used for dynamic-size matrix types. For fixed-size types,
- * it is redundant to pass \a rows and \a cols as arguments, so Random() should be used
+ * it is redundant to pass \a rows and \a cols as arguments, so ei_random() should be used
* instead.
*
+ * \addexample RandomExample \label How to create a matrix with random coefficients
+ *
* Example: \include MatrixBase_random_int_int.cpp
* Output: \verbinclude MatrixBase_random_int_int.out
*
- * This expression has the "evaluate before nesting" flag so that it will be evaluated into
- * a temporary matrix whenever it is nested in a larger expression. This prevents unexpected
- * behavior with expressions involving random matrices.
- *
- * \sa MatrixBase::setRandom(), MatrixBase::Random(Index), MatrixBase::Random()
+ * \sa MatrixBase::setRandom(), MatrixBase::Random(int), MatrixBase::Random()
*/
template<typename Derived>
-inline const CwiseNullaryOp<internal::scalar_random_op<typename internal::traits<Derived>::Scalar>, Derived>
-DenseBase<Derived>::Random(Index rows, Index cols)
+inline const CwiseNullaryOp<ei_scalar_random_op<typename ei_traits<Derived>::Scalar>, Derived>
+MatrixBase<Derived>::Random(int rows, int cols)
{
- return NullaryExpr(rows, cols, internal::scalar_random_op<Scalar>());
+ return NullaryExpr(rows, cols, ei_scalar_random_op<Scalar>());
}
-/** \returns a random vector expression
+/** \array_module
+ *
+ * \returns a random vector (not an expression, the vector is immediately evaluated).
*
* The parameter \a size is the size of the returned vector.
* Must be compatible with this MatrixBase type.
* \only_for_vectors
*
* This variant is meant to be used for dynamic-size vector types. For fixed-size types,
- * it is redundant to pass \a size as argument, so Random() should be used
+ * it is redundant to pass \a size as argument, so ei_random() should be used
* instead.
*
* Example: \include MatrixBase_random_int.cpp
* Output: \verbinclude MatrixBase_random_int.out
*
- * This expression has the "evaluate before nesting" flag so that it will be evaluated into
- * a temporary vector whenever it is nested in a larger expression. This prevents unexpected
- * behavior with expressions involving random matrices.
- *
- * \sa MatrixBase::setRandom(), MatrixBase::Random(Index,Index), MatrixBase::Random()
+ * \sa MatrixBase::setRandom(), MatrixBase::Random(int,int), MatrixBase::Random()
*/
template<typename Derived>
-inline const CwiseNullaryOp<internal::scalar_random_op<typename internal::traits<Derived>::Scalar>, Derived>
-DenseBase<Derived>::Random(Index size)
+inline const CwiseNullaryOp<ei_scalar_random_op<typename ei_traits<Derived>::Scalar>, Derived>
+MatrixBase<Derived>::Random(int size)
{
- return NullaryExpr(size, internal::scalar_random_op<Scalar>());
+ return NullaryExpr(size, ei_scalar_random_op<Scalar>());
}
-/** \returns a fixed-size random matrix or vector expression
+/** \array_module
+ *
+ * \returns a fixed-size random matrix or vector
+ * (not an expression, the matrix is immediately evaluated).
*
* This variant is only for fixed-size MatrixBase types. For dynamic-size types, you
* need to use the variants taking size arguments.
* Example: \include MatrixBase_random.cpp
* Output: \verbinclude MatrixBase_random.out
*
- * This expression has the "evaluate before nesting" flag so that it will be evaluated into
- * a temporary matrix whenever it is nested in a larger expression. This prevents unexpected
- * behavior with expressions involving random matrices.
- *
- * \sa MatrixBase::setRandom(), MatrixBase::Random(Index,Index), MatrixBase::Random(Index)
+ * \sa MatrixBase::setRandom(), MatrixBase::Random(int,int), MatrixBase::Random(int)
*/
template<typename Derived>
-inline const CwiseNullaryOp<internal::scalar_random_op<typename internal::traits<Derived>::Scalar>, Derived>
-DenseBase<Derived>::Random()
+inline const CwiseNullaryOp<ei_scalar_random_op<typename ei_traits<Derived>::Scalar>, Derived>
+MatrixBase<Derived>::Random()
{
- return NullaryExpr(RowsAtCompileTime, ColsAtCompileTime, internal::scalar_random_op<Scalar>());
+ return NullaryExpr(RowsAtCompileTime, ColsAtCompileTime, ei_scalar_random_op<Scalar>());
}
-/** Sets all coefficients in this expression to random values.
+/** \array_module
+ *
+ * Sets all coefficients in this expression to random values.
*
* Example: \include MatrixBase_setRandom.cpp
* Output: \verbinclude MatrixBase_setRandom.out
*
- * \sa class CwiseNullaryOp, setRandom(Index), setRandom(Index,Index)
+ * \sa class CwiseNullaryOp, setRandom(int), setRandom(int,int)
*/
template<typename Derived>
-inline Derived& DenseBase<Derived>::setRandom()
+inline Derived& MatrixBase<Derived>::setRandom()
{
return *this = Random(rows(), cols());
}
* Example: \include Matrix_setRandom_int.cpp
* Output: \verbinclude Matrix_setRandom_int.out
*
- * \sa MatrixBase::setRandom(), setRandom(Index,Index), class CwiseNullaryOp, MatrixBase::Random()
+ * \sa MatrixBase::setRandom(), setRandom(int,int), class CwiseNullaryOp, MatrixBase::Random()
*/
-template<typename Derived>
-EIGEN_STRONG_INLINE Derived&
-PlainObjectBase<Derived>::setRandom(Index size)
+template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
+EIGEN_STRONG_INLINE Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>&
+Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::setRandom(int size)
{
resize(size);
return setRandom();
* Example: \include Matrix_setRandom_int_int.cpp
* Output: \verbinclude Matrix_setRandom_int_int.out
*
- * \sa MatrixBase::setRandom(), setRandom(Index), class CwiseNullaryOp, MatrixBase::Random()
+ * \sa MatrixBase::setRandom(), setRandom(int), class CwiseNullaryOp, MatrixBase::Random()
*/
-template<typename Derived>
-EIGEN_STRONG_INLINE Derived&
-PlainObjectBase<Derived>::setRandom(Index rows, Index cols)
+template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
+EIGEN_STRONG_INLINE Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>&
+Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::setRandom(int rows, int cols)
{
resize(rows, cols);
return setRandom();
// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra.
+// for linear algebra. Eigen itself is part of the KDE project.
//
-// Copyright (C) 2008-2010 Gael Guennebaud <gael.guennebaud@inria.fr>
+// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
#ifndef EIGEN_SELECT_H
#define EIGEN_SELECT_H
-/** \class Select
- * \ingroup Core_Module
+/** \array_module \ingroup Array
+ *
+ * \class Select
*
* \brief Expression of a coefficient wise version of the C++ ternary operator ?:
*
* \param ElseMatrixType the type of the \em else expression
*
* This class represents an expression of a coefficient wise version of the C++ ternary operator ?:.
- * It is the return type of DenseBase::select() and most of the time this is the only way it is used.
+ * It is the return type of MatrixBase::select() and most of the time this is the only way it is used.
*
- * \sa DenseBase::select(const DenseBase<ThenDerived>&, const DenseBase<ElseDerived>&) const
+ * \sa MatrixBase::select(const MatrixBase<ThenDerived>&, const MatrixBase<ElseDerived>&) const
*/
-namespace internal {
template<typename ConditionMatrixType, typename ThenMatrixType, typename ElseMatrixType>
-struct traits<Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> >
- : traits<ThenMatrixType>
+struct ei_traits<Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> >
{
- typedef typename traits<ThenMatrixType>::Scalar Scalar;
- typedef Dense StorageKind;
- typedef typename traits<ThenMatrixType>::XprKind XprKind;
+ typedef typename ei_traits<ThenMatrixType>::Scalar Scalar;
typedef typename ConditionMatrixType::Nested ConditionMatrixNested;
typedef typename ThenMatrixType::Nested ThenMatrixNested;
typedef typename ElseMatrixType::Nested ElseMatrixNested;
MaxRowsAtCompileTime = ConditionMatrixType::MaxRowsAtCompileTime,
MaxColsAtCompileTime = ConditionMatrixType::MaxColsAtCompileTime,
Flags = (unsigned int)ThenMatrixType::Flags & ElseMatrixType::Flags & HereditaryBits,
- CoeffReadCost = traits<typename remove_all<ConditionMatrixNested>::type>::CoeffReadCost
- + EIGEN_SIZE_MAX(traits<typename remove_all<ThenMatrixNested>::type>::CoeffReadCost,
- traits<typename remove_all<ElseMatrixNested>::type>::CoeffReadCost)
+ CoeffReadCost = ei_traits<typename ei_cleantype<ConditionMatrixNested>::type>::CoeffReadCost
+ + EIGEN_ENUM_MAX(ei_traits<typename ei_cleantype<ThenMatrixNested>::type>::CoeffReadCost,
+ ei_traits<typename ei_cleantype<ElseMatrixNested>::type>::CoeffReadCost)
};
};
-}
template<typename ConditionMatrixType, typename ThenMatrixType, typename ElseMatrixType>
-class Select : internal::no_assignment_operator,
- public internal::dense_xpr_base< Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> >::type
+class Select : ei_no_assignment_operator,
+ public MatrixBase<Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> >
{
public:
- typedef typename internal::dense_xpr_base<Select>::type Base;
- EIGEN_DENSE_PUBLIC_INTERFACE(Select)
+ EIGEN_GENERIC_PUBLIC_INTERFACE(Select)
Select(const ConditionMatrixType& conditionMatrix,
const ThenMatrixType& thenMatrix,
const ElseMatrixType& elseMatrix)
: m_condition(conditionMatrix), m_then(thenMatrix), m_else(elseMatrix)
{
- eigen_assert(m_condition.rows() == m_then.rows() && m_condition.rows() == m_else.rows());
- eigen_assert(m_condition.cols() == m_then.cols() && m_condition.cols() == m_else.cols());
+ ei_assert(m_condition.rows() == m_then.rows() && m_condition.rows() == m_else.rows());
+ ei_assert(m_condition.cols() == m_then.cols() && m_condition.cols() == m_else.cols());
}
- Index rows() const { return m_condition.rows(); }
- Index cols() const { return m_condition.cols(); }
+ int rows() const { return m_condition.rows(); }
+ int cols() const { return m_condition.cols(); }
- const Scalar coeff(Index i, Index j) const
+ const Scalar coeff(int i, int j) const
{
if (m_condition.coeff(i,j))
return m_then.coeff(i,j);
else
return m_else.coeff(i,j);
}
-
- const Scalar coeff(Index i) const
+
+ const Scalar coeff(int i) const
{
if (m_condition.coeff(i))
return m_then.coeff(i);
};
-/** \returns a matrix where each coefficient (i,j) is equal to \a thenMatrix(i,j)
+/** \array_module
+ *
+ * \returns a matrix where each coefficient (i,j) is equal to \a thenMatrix(i,j)
* if \c *this(i,j), and \a elseMatrix(i,j) otherwise.
*
* Example: \include MatrixBase_select.cpp
template<typename Derived>
template<typename ThenDerived,typename ElseDerived>
inline const Select<Derived,ThenDerived,ElseDerived>
-DenseBase<Derived>::select(const DenseBase<ThenDerived>& thenMatrix,
- const DenseBase<ElseDerived>& elseMatrix) const
+MatrixBase<Derived>::select(const MatrixBase<ThenDerived>& thenMatrix,
+ const MatrixBase<ElseDerived>& elseMatrix) const
{
return Select<Derived,ThenDerived,ElseDerived>(derived(), thenMatrix.derived(), elseMatrix.derived());
}
-/** Version of DenseBase::select(const DenseBase&, const DenseBase&) with
+/** \array_module
+ *
+ * Version of MatrixBase::select(const MatrixBase&, const MatrixBase&) with
* the \em else expression being a scalar value.
*
- * \sa DenseBase::select(const DenseBase<ThenDerived>&, const DenseBase<ElseDerived>&) const, class Select
+ * \sa MatrixBase::select(const MatrixBase<ThenDerived>&, const MatrixBase<ElseDerived>&) const, class Select
*/
template<typename Derived>
template<typename ThenDerived>
-inline const Select<Derived,ThenDerived, typename ThenDerived::ConstantReturnType>
-DenseBase<Derived>::select(const DenseBase<ThenDerived>& thenMatrix,
+inline const Select<Derived,ThenDerived, NestByValue<typename ThenDerived::ConstantReturnType> >
+MatrixBase<Derived>::select(const MatrixBase<ThenDerived>& thenMatrix,
typename ThenDerived::Scalar elseScalar) const
{
- return Select<Derived,ThenDerived,typename ThenDerived::ConstantReturnType>(
+ return Select<Derived,ThenDerived,NestByValue<typename ThenDerived::ConstantReturnType> >(
derived(), thenMatrix.derived(), ThenDerived::Constant(rows(),cols(),elseScalar));
}
-/** Version of DenseBase::select(const DenseBase&, const DenseBase&) with
+/** \array_module
+ *
+ * Version of MatrixBase::select(const MatrixBase&, const MatrixBase&) with
* the \em then expression being a scalar value.
*
- * \sa DenseBase::select(const DenseBase<ThenDerived>&, const DenseBase<ElseDerived>&) const, class Select
+ * \sa MatrixBase::select(const MatrixBase<ThenDerived>&, const MatrixBase<ElseDerived>&) const, class Select
*/
template<typename Derived>
template<typename ElseDerived>
-inline const Select<Derived, typename ElseDerived::ConstantReturnType, ElseDerived >
-DenseBase<Derived>::select(typename ElseDerived::Scalar thenScalar,
- const DenseBase<ElseDerived>& elseMatrix) const
+inline const Select<Derived, NestByValue<typename ElseDerived::ConstantReturnType>, ElseDerived >
+MatrixBase<Derived>::select(typename ElseDerived::Scalar thenScalar,
+ const MatrixBase<ElseDerived>& elseMatrix) const
{
- return Select<Derived,typename ElseDerived::ConstantReturnType,ElseDerived>(
+ return Select<Derived,NestByValue<typename ElseDerived::ConstantReturnType>,ElseDerived>(
derived(), ElseDerived::Constant(rows(),cols(),thenScalar), elseMatrix.derived());
}
// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra.
+// for linear algebra. Eigen itself is part of the KDE project.
//
-// Copyright (C) 2011 Benoit Jacob <jacob.benoit.1@gmail.com>
+// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
-#ifndef EIGEN2_MACROS_H
-#define EIGEN2_MACROS_H
+#ifndef EIGEN_EXTERN_INSTANTIATIONS
+#define EIGEN_EXTERN_INSTANTIATIONS
+#endif
+#include "../../Core"
+#undef EIGEN_EXTERN_INSTANTIATIONS
-#define ei_assert eigen_assert
-#define ei_internal_assert eigen_internal_assert
+#include "../../Cholesky"
-#define EIGEN_ALIGN_128 EIGEN_ALIGN16
-
-#define EIGEN_ARCH_WANTS_ALIGNMENT EIGEN_ALIGN_STATICALLY
-
-#endif // EIGEN2_MACROS_H
+namespace Eigen {
+ EIGEN_CHOLESKY_MODULE_INSTANTIATE();
+}
--- /dev/null
+// This file is part of Eigen, a lightweight C++ template library
+// for linear algebra. Eigen itself is part of the KDE project.
+//
+// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
+//
+// Eigen is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 3 of the License, or (at your option) any later version.
+//
+// Alternatively, 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.
+//
+// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License and a copy of the GNU General Public License along with
+// Eigen. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef EIGEN_LDLT_H
+#define EIGEN_LDLT_H
+
+/** \ingroup cholesky_Module