diff --git a/CMakeLists.txt b/CMakeLists.txt
index f3a193c20c83fe8df737be838d23d9f5247c997c..bb6e27b6286fabfb9f89dd44c7fe6cdfeaaf2af1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -449,10 +449,10 @@ macro_optional_find_package(KdepimLibs 4.6.0)
macro_log_feature(KDEPIMLIBS_FOUND "KDE PIMLibs" "KDE Personal Information Management Libraries" "http://www.kde.org/" FALSE "" "Required by Plan and the KDE address book integration (available as a module in KDE)")
##
-## Test for eigen2
+## Test for eigen3
##
-macro_optional_find_package(Eigen2)
-macro_log_feature(EIGEN2_FOUND "Eigen" "C++ template library for linear algebra" "http://eigen.tuxfamily.org" FALSE "2.0" "Required by Calligra Sheets and Krita")
+macro_optional_find_package(Eigen3)
+macro_log_feature(EIGEN3_FOUND "Eigen" "C++ template library for linear algebra" "http://eigen.tuxfamily.org" FALSE "3.0" "Required by Calligra Sheets and Krita")
##
## Test for QCA2
@@ -941,13 +941,13 @@ if(NOT Soprano_FOUND)
calligra_disable_product(RDF "Soprano not found")
endif(NOT Soprano_FOUND)
-if(NOT EIGEN2_FOUND)
+if(NOT EIGEN3_FOUND)
calligra_disable_product(SHEETS_PART "Eigen devel not found")
-endif(NOT EIGEN2_FOUND)
+endif(NOT EIGEN3_FOUND)
-if(NOT EIGEN2_FOUND OR NOT EXIV2_FOUND OR NOT HAVE_REQUIRED_LCMS_VERSION OR NOT SHARED_MIME_INFO_FOUND)
- calligra_disable_product(KRITA_APP "SharedMimeInfo|libeigen2|libexiv2|lcms devel not found ")
-endif(NOT EIGEN2_FOUND OR NOT EXIV2_FOUND OR NOT HAVE_REQUIRED_LCMS_VERSION OR NOT SHARED_MIME_INFO_FOUND)
+if(NOT EIGEN3_FOUND OR NOT EXIV2_FOUND OR NOT HAVE_REQUIRED_LCMS_VERSION OR NOT SHARED_MIME_INFO_FOUND)
+ calligra_disable_product(KRITA_APP "SharedMimeInfo|libeigen3|libexiv2|lcms devel not found ")
+endif(NOT EIGEN3_FOUND OR NOT EXIV2_FOUND OR NOT HAVE_REQUIRED_LCMS_VERSION OR NOT SHARED_MIME_INFO_FOUND)
if(NOT APPLE AND NOT REQUIRED_Xinput_FOUND)
calligra_disable_product(KRITA_APP "Xinput devel not found ")
diff --git a/cmake/modules/FindEigen3.cmake b/cmake/modules/FindEigen3.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..9c546a05d859b18c49554d7ee7221cc486b7760e
--- /dev/null
+++ b/cmake/modules/FindEigen3.cmake
@@ -0,0 +1,81 @@
+# - Try to find Eigen3 lib
+#
+# This module supports requiring a minimum version, e.g. you can do
+# find_package(Eigen3 3.1.2)
+# to require version 3.1.2 or newer of Eigen3.
+#
+# Once done this will define
+#
+# EIGEN3_FOUND - system has eigen lib with correct version
+# EIGEN3_INCLUDE_DIR - the eigen include directory
+# EIGEN3_VERSION - eigen version
+
+# Copyright (c) 2006, 2007 Montel Laurent, <montel@kde.org>
+# Copyright (c) 2008, 2009 Gael Guennebaud, <g.gael@free.fr>
+# Copyright (c) 2009 Benoit Jacob <jacob.benoit.1@gmail.com>
+# Redistribution and use is allowed according to the terms of the 2-clause BSD license.
+
+if(NOT Eigen3_FIND_VERSION)
+ if(NOT Eigen3_FIND_VERSION_MAJOR)
+ set(Eigen3_FIND_VERSION_MAJOR 2)
+ endif(NOT Eigen3_FIND_VERSION_MAJOR)
+ if(NOT Eigen3_FIND_VERSION_MINOR)
+ set(Eigen3_FIND_VERSION_MINOR 91)
+ endif(NOT Eigen3_FIND_VERSION_MINOR)
+ if(NOT Eigen3_FIND_VERSION_PATCH)
+ set(Eigen3_FIND_VERSION_PATCH 0)
+ endif(NOT Eigen3_FIND_VERSION_PATCH)
+
+ set(Eigen3_FIND_VERSION "${Eigen3_FIND_VERSION_MAJOR}.${Eigen3_FIND_VERSION_MINOR}.${Eigen3_FIND_VERSION_PATCH}")
+endif(NOT Eigen3_FIND_VERSION)
+
+macro(_eigen3_check_version)
+ file(READ "${EIGEN3_INCLUDE_DIR}/Eigen/src/Core/util/Macros.h" _eigen3_version_header)
+
+ string(REGEX MATCH "define[ \t]+EIGEN_WORLD_VERSION[ \t]+([0-9]+)" _eigen3_world_version_match "${_eigen3_version_header}")
+ set(EIGEN3_WORLD_VERSION "${CMAKE_MATCH_1}")
+ string(REGEX MATCH "define[ \t]+EIGEN_MAJOR_VERSION[ \t]+([0-9]+)" _eigen3_major_version_match "${_eigen3_version_header}")
+ set(EIGEN3_MAJOR_VERSION "${CMAKE_MATCH_1}")
+ string(REGEX MATCH "define[ \t]+EIGEN_MINOR_VERSION[ \t]+([0-9]+)" _eigen3_minor_version_match "${_eigen3_version_header}")
+ set(EIGEN3_MINOR_VERSION "${CMAKE_MATCH_1}")
+
+ set(EIGEN3_VERSION ${EIGEN3_WORLD_VERSION}.${EIGEN3_MAJOR_VERSION}.${EIGEN3_MINOR_VERSION})
+ if(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION})
+ set(EIGEN3_VERSION_OK FALSE)
+ else(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION})
+ set(EIGEN3_VERSION_OK TRUE)
+ endif(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION})
+
+ if(NOT EIGEN3_VERSION_OK)
+
+ message(STATUS "Eigen3 version ${EIGEN3_VERSION} found in ${EIGEN3_INCLUDE_DIR}, "
+ "but at least version ${Eigen3_FIND_VERSION} is required")
+ endif(NOT EIGEN3_VERSION_OK)
+endmacro(_eigen3_check_version)
+
+if (EIGEN3_INCLUDE_DIR)
+
+ # in cache already
+ _eigen3_check_version()
+ set(EIGEN3_FOUND ${EIGEN3_VERSION_OK})
+
+else (EIGEN3_INCLUDE_DIR)
+
+ find_path(EIGEN3_INCLUDE_DIR NAMES signature_of_eigen3_matrix_library
+ PATHS
+ ${CMAKE_INSTALL_PREFIX}/include
+ ${KDE4_INCLUDE_DIR}
+ PATH_SUFFIXES eigen3 eigen
+ )
+
+ if(EIGEN3_INCLUDE_DIR)
+ _eigen3_check_version()
+ endif(EIGEN3_INCLUDE_DIR)
+
+ include(FindPackageHandleStandardArgs)
+ find_package_handle_standard_args(Eigen3 DEFAULT_MSG EIGEN3_INCLUDE_DIR EIGEN3_VERSION_OK)
+
+ mark_as_advanced(EIGEN3_INCLUDE_DIR)
+
+endif(EIGEN3_INCLUDE_DIR)
+
diff --git a/krita/CMakeLists.txt b/krita/CMakeLists.txt
index b81e9f41c78291b284e04a613b00ba4d1c8a5191..3184351bc3ae34359eace80d54a9814547452d14 100644
--- a/krita/CMakeLists.txt
+++ b/krita/CMakeLists.txt
@@ -105,7 +105,7 @@ set(KRITA_INCLUDES
${CMAKE_SOURCE_DIR}/libs/widgets/colorwidgets
${CMAKE_SOURCE_DIR}/libs/widgetutils
- ${EIGEN2_INCLUDE_DIR}
+ ${EIGEN3_INCLUDE_DIR}
${Vc_INCLUDE_DIR}
# 'Export' this for use by filters
diff --git a/krita/image/kis_perspective_math.cpp b/krita/image/kis_perspective_math.cpp
index 74566e205244e92627cf84adc1360204028ddeba..cf7f73724736c973d8069c2f6829eb483ddddefc 100644
--- a/krita/image/kis_perspective_math.cpp
+++ b/krita/image/kis_perspective_math.cpp
@@ -86,7 +86,7 @@ Matrix3qreal KisPerspectiveMath::computeMatrixTransfo(const QPointF& topLeft1, c
b.coeffRef(8) = 1;
// dbgImage <<" a := { {" << a(0,0) <<" ," << a(0,1) <<" ," << a(0,2) <<" ," << a(0,3) <<" ," << a(0,4) <<" ," << a(0,5) <<" ," << a(0,6) <<" ," << a(0,7) <<" ," << a(0,8) <<" } , {" << a(1,0) <<" ," << a(1,1) <<" ," << a(1,2) <<" ," << a(1,3) <<" ," << a(1,4) <<" ," << a(1,5) <<" ," << a(1,6) <<" ," << a(1,7) <<" ," << a(1,8) <<" } , {" << a(2,0) <<" ," << a(2,1) <<" ," << a(2,2) <<" ," << a(2,3) <<" ," << a(2,4) <<" ," << a(2,5) <<" ," << a(2,6) <<" ," << a(2,7) <<" ," << a(2,8) <<" } , {" << a(3,0) <<" ," << a(3,1) <<" ," << a(3,2) <<" ," << a(3,3) <<" ," << a(3,4) <<" ," << a(3,5) <<" ," << a(3,6) <<" ," << a(3,7) <<" ," << a(3,8) <<" } , {" << a(4,0) <<" ," << a(4,1) <<" ," << a(4,2) <<" ," << a(4,3) <<" ," << a(4,4) <<" ," << a(4,5) <<" ," << a(4,6) <<" ," << a(4,7) <<" ," << a(4,8) <<" } , {" << a(5,0) <<" ," << a(5,1) <<" ," << a(5,2) <<" ," << a(5,3) <<" ," << a(5,4) <<" ," << a(5,5) <<" ," << a(5,6) <<" ," << a(5,7) <<" ," << a(5,8) <<" } , {" << a(6,0) <<" ," << a(6,1) <<" ," << a(6,2) <<" ," << a(6,3) <<" ," << a(6,4) <<" ," << a(6,5) <<" ," << a(6,6) <<" ," << a(6,7) <<" ," << a(6,8) <<" } , {"<< a(7,0) <<" ," << a(7,1) <<" ," << a(7,2) <<" ," << a(7,3) <<" ," << a(7,4) <<" ," << a(7,5) <<" ," << a(7,6) <<" ," << a(7,7) <<" ," << a(7,8) <<" } , {"<< a(8,0) <<" ," << a(8,1) <<" ," << a(8,2) <<" ," << a(8,3) <<" ," << a(8,4) <<" ," << a(8,5) <<" ," << a(8,6) <<" ," << a(8,7) <<" ," << a(8,8) <<" } };";
Vector9qreal v;
- a.lu().solve(b, &v);
+ v = a.lu().solve(b);
Matrix3qreal matrix;
for (int r = 0; r < 3; r++) for (int c = 0; c < 3; c++) matrix.coeffRef(r, c) = v.coeff(3 * r + c);
return matrix;
diff --git a/krita/image/tests/kis_convolution_painter_test.cpp b/krita/image/tests/kis_convolution_painter_test.cpp
index d6562dd3aef886d4173ee4f2c18692fc0ae13f82..c5d64a5008205d0d0019d75726c7b2f4320081cc 100644
--- a/krita/image/tests/kis_convolution_painter_test.cpp
+++ b/krita/image/tests/kis_convolution_painter_test.cpp
@@ -117,15 +117,15 @@ void KisConvolutionPainterTest::testIdentityConvolution()
dev->convertFromQImage(qimage, 0, 0, 0);
KisConvolutionKernelSP kernel = new KisConvolutionKernel(3, 3, 0, 0);
- kernel->data()[0] = 0;
- kernel->data()[1] = 0;
- kernel->data()[2] = 0;
- kernel->data()[3] = 0;
- kernel->data()[4] = 1;
- kernel->data()[5] = 0;
- kernel->data()[6] = 0;
- kernel->data()[7] = 0;
- kernel->data()[8] = 0;
+ kernel->data()(0) = 0;
+ kernel->data()(1) = 0;
+ kernel->data()(2) = 0;
+ kernel->data()(3) = 0;
+ kernel->data()(4) = 1;
+ kernel->data()(5) = 0;
+ kernel->data()(6) = 0;
+ kernel->data()(7) = 0;
+ kernel->data()(8) = 0;
KisConvolutionPainter gc(dev);
gc.beginTransaction(0);
gc.applyMatrix(kernel, dev, QPoint(0, 0), QPoint(0, 0), QSize(qimage.width(), qimage.height()));
diff --git a/krita/image/tests/kis_paint_information_test.cpp b/krita/image/tests/kis_paint_information_test.cpp
index 188103c29add9bb706134ff75ae9e260af5b0de0..011e6d2bca73fd0a956f23f9cebee3106fee2556 100644
--- a/krita/image/tests/kis_paint_information_test.cpp
+++ b/krita/image/tests/kis_paint_information_test.cpp
@@ -23,7 +23,7 @@
#include "kis_paint_information.h"
#include <QDomDocument>
-#include <Eigen/Array>
+#include <Eigen/Core>
#include <kdebug.h>
diff --git a/krita/plugins/extensions/dockers/advancedcolorselector/kis_color_selector_ring.cpp b/krita/plugins/extensions/dockers/advancedcolorselector/kis_color_selector_ring.cpp
index 5f88701aea3eddcf4d3deb5059f91d12cb22fd71..8b5c4a7a9460a313f2940f980f9432fb3b74c2a5 100644
--- a/krita/plugins/extensions/dockers/advancedcolorselector/kis_color_selector_ring.cpp
+++ b/krita/plugins/extensions/dockers/advancedcolorselector/kis_color_selector_ring.cpp
@@ -21,7 +21,7 @@
#include <QMouseEvent>
#include <Eigen/Core>
-USING_PART_OF_NAMESPACE_EIGEN
+using namespace Eigen;
#include <cmath>
#include "KoColor.h"
diff --git a/krita/plugins/extensions/dockers/advancedcolorselector/kis_color_selector_triangle.cpp b/krita/plugins/extensions/dockers/advancedcolorselector/kis_color_selector_triangle.cpp
index f2889b866c3d733f8fbc3ac5c93ba94061099b2c..8e828d831174cc0f6d54553dbae98b50f81e5e49 100644
--- a/krita/plugins/extensions/dockers/advancedcolorselector/kis_color_selector_triangle.cpp
+++ b/krita/plugins/extensions/dockers/advancedcolorselector/kis_color_selector_triangle.cpp
@@ -21,7 +21,7 @@
#include <QMouseEvent>
#include <Eigen/Core>
-USING_PART_OF_NAMESPACE_EIGEN
+using namespace Eigen;
#include <cmath>
#include "KoColor.h"
diff --git a/krita/plugins/tools/selectiontools/kis_tool_select_brush.cc b/krita/plugins/tools/selectiontools/kis_tool_select_brush.cc
index 08cd4efdc071145485abd511885546a63c44390e..297f68cc1d34784e0fcf262565b3e928f4089d50 100644
--- a/krita/plugins/tools/selectiontools/kis_tool_select_brush.cc
+++ b/krita/plugins/tools/selectiontools/kis_tool_select_brush.cc
@@ -35,7 +35,7 @@
#include <KoCompositeOp.h>
#include <Eigen/Core>
-USING_PART_OF_NAMESPACE_EIGEN
+using namespace Eigen;
#include "kis_cursor.h"
#include "kis_canvas2.h"
diff --git a/krita/plugins/tools/selectiontools/kis_tool_select_magnetic.h b/krita/plugins/tools/selectiontools/kis_tool_select_magnetic.h
index d69c6b82845b00bc6e540d5daccafcc9850f4dc5..8c711e039d13488b26c9817e9750b16e6f050cdc 100644
--- a/krita/plugins/tools/selectiontools/kis_tool_select_magnetic.h
+++ b/krita/plugins/tools/selectiontools/kis_tool_select_magnetic.h
@@ -42,7 +42,7 @@ namespace Ui {
}
#include <Eigen/Core>
-USING_PART_OF_NAMESPACE_EIGEN
+using namespace Eigen;
typedef Eigen::Matrix3d FilterMatrix;
diff --git a/sheets/CMakeLists.txt b/sheets/CMakeLists.txt
index 04f213f72a06c32f790c86091d97e19900a70a91..193bbd097064de1f57517661874cec7f10fa2d84 100644
--- a/sheets/CMakeLists.txt
+++ b/sheets/CMakeLists.txt
@@ -5,7 +5,7 @@ include_directories( ${CMAKE_SOURCE_DIR}/interfaces
${KOTEXT_INCLUDES}
${TEXTLAYOUT_INCLUDES}
${Boost_INCLUDE_DIR}
- ${EIGEN2_INCLUDE_DIR} )
+ ${EIGEN3_INCLUDE_DIR} )
if (SHOULD_BUILD_SHEETS_PART)
diff --git a/sheets/functions/CMakeLists.txt b/sheets/functions/CMakeLists.txt
index ba20613be6ca0c8516f19a6bcb9da861370b098b..27f8c8fabe184b1b5a337b617eaa51734dec996d 100644
--- a/sheets/functions/CMakeLists.txt
+++ b/sheets/functions/CMakeLists.txt
@@ -1,4 +1,4 @@
-include_directories(${CMAKE_SOURCE_DIR}/sheets ${KOMAIN_INCLUDES} ${FLAKE_INCLUDES} ${EIGEN2_INCLUDE_DIR})
+include_directories(${CMAKE_SOURCE_DIR}/sheets ${KOMAIN_INCLUDES} ${FLAKE_INCLUDES} ${EIGEN3_INCLUDE_DIR})
########### next target ###############
diff --git a/sheets/functions/math.cpp b/sheets/functions/math.cpp
index 6b475f5dbc4bac22b2f6930ec25e08b302e6abe2..8724f4950f3d71b1ba13e8b073cd3e5c6d10f450 100644
--- a/sheets/functions/math.cpp
+++ b/sheets/functions/math.cpp
@@ -1226,11 +1226,10 @@ Value func_minverse(valVector args, ValueCalc* calc, FuncExtra*)
if (matrix.columns() != matrix.rows() || matrix.rows() < 1)
return Value::errorVALUE();
- Eigen::MatrixXd eMatrix = convert(matrix, calc),
- eMatrixInverse(eMatrix.rows(), eMatrix.cols());
- Eigen::LU<Eigen::MatrixXd> lu(eMatrix);
+ Eigen::MatrixXd eMatrix = convert(matrix, calc);
+ Eigen::FullPivLU<Eigen::MatrixXd> lu(eMatrix);
if (lu.isInvertible()) {
- lu.computeInverse(&eMatrixInverse);
+ Eigen::MatrixXd eMatrixInverse = lu.inverse();
return convert(eMatrixInverse);
} else
return Value::errorDIV0();
diff --git a/sheets/tests/CMakeLists.txt b/sheets/tests/CMakeLists.txt
index 0d1d37c09d0415c10133cc5c27dad9b3e9693eb1..ca935430963f9cf474310dd54f34dfc5e2272d43 100644
--- a/sheets/tests/CMakeLists.txt
+++ b/sheets/tests/CMakeLists.txt
@@ -1,6 +1,6 @@
include(MacroAddCompileFlags)
set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} )
-include_directories( ${CMAKE_SOURCE_DIR}/sheets ${EIGEN2_INCLUDE_DIR} ${KOMAIN_INCLUDES} ${KDE4_INCLUDES} )
+include_directories( ${CMAKE_SOURCE_DIR}/sheets ${EIGEN3_INCLUDE_DIR} ${KOMAIN_INCLUDES} ${KDE4_INCLUDES} )
########### Core Functionality ###############