├── LICENSE ├── README.md ├── examples ├── .ropeproject │ ├── config.py │ ├── globalnames │ ├── history │ └── objectdb ├── anno1.png ├── anno2.png ├── anno3.png ├── dense_hsal.py ├── im1.png ├── im2.png ├── im3.png ├── inference.py └── utils_example.py ├── pydensecrf ├── __init__.py ├── densecrf.cpp ├── densecrf.pxd ├── densecrf.pyx ├── densecrf │ ├── README.txt │ ├── external │ │ ├── CMakeLists.txt │ │ └── liblbfgs │ │ │ ├── AUTHORS │ │ │ ├── COPYING │ │ │ ├── ChangeLog │ │ │ ├── INSTALL │ │ │ ├── Makefile.am │ │ │ ├── Makefile.in │ │ │ ├── NEWS │ │ │ ├── README │ │ │ ├── aclocal.m4 │ │ │ ├── autogen.sh │ │ │ ├── config.guess │ │ │ ├── config.h.in │ │ │ ├── config.sub │ │ │ ├── configure │ │ │ ├── configure.in │ │ │ ├── depcomp │ │ │ ├── include │ │ │ └── lbfgs.h │ │ │ ├── install-sh │ │ │ ├── lbfgs.sln │ │ │ ├── lib │ │ │ ├── Makefile.am │ │ │ ├── Makefile.in │ │ │ ├── arithmetic_ansi.h │ │ │ ├── arithmetic_sse_double.h │ │ │ ├── arithmetic_sse_float.h │ │ │ ├── lbfgs.c │ │ │ └── lib.vcxproj │ │ │ ├── ltmain.sh │ │ │ ├── missing │ │ │ └── sample │ │ │ ├── Makefile.am │ │ │ ├── Makefile.in │ │ │ ├── sample.c │ │ │ ├── sample.cpp │ │ │ └── sample.vcxproj │ ├── include │ │ ├── Eigen │ │ │ ├── Array │ │ │ ├── CMakeLists.txt │ │ │ ├── Cholesky │ │ │ ├── CholmodSupport │ │ │ ├── Core │ │ │ ├── Dense │ │ │ ├── Eigen │ │ │ ├── Eigen2Support │ │ │ ├── Eigenvalues │ │ │ ├── Geometry │ │ │ ├── Householder │ │ │ ├── IterativeLinearSolvers │ │ │ ├── Jacobi │ │ │ ├── LU │ │ │ ├── LeastSquares │ │ │ ├── OrderingMethods │ │ │ ├── PaStiXSupport │ │ │ ├── PardisoSupport │ │ │ ├── QR │ │ │ ├── QtAlignedMalloc │ │ │ ├── SVD │ │ │ ├── Sparse │ │ │ ├── SparseCholesky │ │ │ ├── SparseCore │ │ │ ├── StdDeque │ │ │ ├── StdList │ │ │ ├── StdVector │ │ │ ├── SuperLUSupport │ │ │ ├── UmfPackSupport │ │ │ └── src │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── Cholesky │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── LDLT.h │ │ │ │ ├── LLT.h │ │ │ │ └── LLT_MKL.h │ │ │ │ ├── CholmodSupport │ │ │ │ ├── CMakeLists.txt │ │ │ │ └── CholmodSupport.h │ │ │ │ ├── Core │ │ │ │ ├── Array.h │ │ │ │ ├── ArrayBase.h │ │ │ │ ├── ArrayWrapper.h │ │ │ │ ├── Assign.h │ │ │ │ ├── Assign_MKL.h │ │ │ │ ├── BandMatrix.h │ │ │ │ ├── Block.h │ │ │ │ ├── BooleanRedux.h │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── CommaInitializer.h │ │ │ │ ├── CwiseBinaryOp.h │ │ │ │ ├── CwiseNullaryOp.h │ │ │ │ ├── CwiseUnaryOp.h │ │ │ │ ├── CwiseUnaryView.h │ │ │ │ ├── DenseBase.h │ │ │ │ ├── DenseCoeffsBase.h │ │ │ │ ├── DenseStorage.h │ │ │ │ ├── Diagonal.h │ │ │ │ ├── DiagonalMatrix.h │ │ │ │ ├── DiagonalProduct.h │ │ │ │ ├── Dot.h │ │ │ │ ├── EigenBase.h │ │ │ │ ├── Flagged.h │ │ │ │ ├── ForceAlignedAccess.h │ │ │ │ ├── Functors.h │ │ │ │ ├── Fuzzy.h │ │ │ │ ├── GeneralProduct.h │ │ │ │ ├── GenericPacketMath.h │ │ │ │ ├── GlobalFunctions.h │ │ │ │ ├── IO.h │ │ │ │ ├── Map.h │ │ │ │ ├── MapBase.h │ │ │ │ ├── MathFunctions.h │ │ │ │ ├── Matrix.h │ │ │ │ ├── MatrixBase.h │ │ │ │ ├── NestByValue.h │ │ │ │ ├── NoAlias.h │ │ │ │ ├── NumTraits.h │ │ │ │ ├── PermutationMatrix.h │ │ │ │ ├── PlainObjectBase.h │ │ │ │ ├── Product.h │ │ │ │ ├── ProductBase.h │ │ │ │ ├── Random.h │ │ │ │ ├── Redux.h │ │ │ │ ├── Replicate.h │ │ │ │ ├── ReturnByValue.h │ │ │ │ ├── Reverse.h │ │ │ │ ├── Select.h │ │ │ │ ├── SelfAdjointView.h │ │ │ │ ├── SelfCwiseBinaryOp.h │ │ │ │ ├── SolveTriangular.h │ │ │ │ ├── StableNorm.h │ │ │ │ ├── Stride.h │ │ │ │ ├── Swap.h │ │ │ │ ├── Transpose.h │ │ │ │ ├── Transpositions.h │ │ │ │ ├── TriangularMatrix.h │ │ │ │ ├── VectorBlock.h │ │ │ │ ├── VectorwiseOp.h │ │ │ │ ├── Visitor.h │ │ │ │ ├── arch │ │ │ │ │ ├── AltiVec │ │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ │ ├── Complex.h │ │ │ │ │ │ └── PacketMath.h │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ ├── Default │ │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ │ └── Settings.h │ │ │ │ │ ├── NEON │ │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ │ ├── Complex.h │ │ │ │ │ │ └── PacketMath.h │ │ │ │ │ └── SSE │ │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ │ ├── Complex.h │ │ │ │ │ │ ├── MathFunctions.h │ │ │ │ │ │ └── PacketMath.h │ │ │ │ ├── products │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ ├── CoeffBasedProduct.h │ │ │ │ │ ├── GeneralBlockPanelKernel.h │ │ │ │ │ ├── GeneralMatrixMatrix.h │ │ │ │ │ ├── GeneralMatrixMatrixTriangular.h │ │ │ │ │ ├── GeneralMatrixMatrixTriangular_MKL.h │ │ │ │ │ ├── GeneralMatrixMatrix_MKL.h │ │ │ │ │ ├── GeneralMatrixVector.h │ │ │ │ │ ├── GeneralMatrixVector_MKL.h │ │ │ │ │ ├── Parallelizer.h │ │ │ │ │ ├── SelfadjointMatrixMatrix.h │ │ │ │ │ ├── SelfadjointMatrixMatrix_MKL.h │ │ │ │ │ ├── SelfadjointMatrixVector.h │ │ │ │ │ ├── SelfadjointMatrixVector_MKL.h │ │ │ │ │ ├── SelfadjointProduct.h │ │ │ │ │ ├── SelfadjointRank2Update.h │ │ │ │ │ ├── TriangularMatrixMatrix.h │ │ │ │ │ ├── TriangularMatrixMatrix_MKL.h │ │ │ │ │ ├── TriangularMatrixVector.h │ │ │ │ │ ├── TriangularMatrixVector_MKL.h │ │ │ │ │ ├── TriangularSolverMatrix.h │ │ │ │ │ ├── TriangularSolverMatrix_MKL.h │ │ │ │ │ └── TriangularSolverVector.h │ │ │ │ └── util │ │ │ │ │ ├── BlasUtil.h │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ ├── Constants.h │ │ │ │ │ ├── DisableStupidWarnings.h │ │ │ │ │ ├── ForwardDeclarations.h │ │ │ │ │ ├── MKL_support.h │ │ │ │ │ ├── Macros.h │ │ │ │ │ ├── Memory.h │ │ │ │ │ ├── Meta.h │ │ │ │ │ ├── NonMPL2.h │ │ │ │ │ ├── ReenableStupidWarnings.h │ │ │ │ │ ├── StaticAssert.h │ │ │ │ │ └── XprHelper.h │ │ │ │ ├── Eigen2Support │ │ │ │ ├── Block.h │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── Cwise.h │ │ │ │ ├── CwiseOperators.h │ │ │ │ ├── Geometry │ │ │ │ │ ├── AlignedBox.h │ │ │ │ │ ├── All.h │ │ │ │ │ ├── AngleAxis.h │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ ├── Hyperplane.h │ │ │ │ │ ├── ParametrizedLine.h │ │ │ │ │ ├── Quaternion.h │ │ │ │ │ ├── Rotation2D.h │ │ │ │ │ ├── RotationBase.h │ │ │ │ │ ├── Scaling.h │ │ │ │ │ ├── Transform.h │ │ │ │ │ └── Translation.h │ │ │ │ ├── LU.h │ │ │ │ ├── Lazy.h │ │ │ │ ├── LeastSquares.h │ │ │ │ ├── Macros.h │ │ │ │ ├── MathFunctions.h │ │ │ │ ├── Memory.h │ │ │ │ ├── Meta.h │ │ │ │ ├── Minor.h │ │ │ │ ├── QR.h │ │ │ │ ├── SVD.h │ │ │ │ ├── TriangularSolver.h │ │ │ │ └── VectorBlock.h │ │ │ │ ├── Eigenvalues │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── ComplexEigenSolver.h │ │ │ │ ├── ComplexSchur.h │ │ │ │ ├── ComplexSchur_MKL.h │ │ │ │ ├── EigenSolver.h │ │ │ │ ├── GeneralizedSelfAdjointEigenSolver.h │ │ │ │ ├── HessenbergDecomposition.h │ │ │ │ ├── MatrixBaseEigenvalues.h │ │ │ │ ├── RealSchur.h │ │ │ │ ├── RealSchur_MKL.h │ │ │ │ ├── SelfAdjointEigenSolver.h │ │ │ │ ├── SelfAdjointEigenSolver_MKL.h │ │ │ │ └── Tridiagonalization.h │ │ │ │ ├── Geometry │ │ │ │ ├── AlignedBox.h │ │ │ │ ├── AngleAxis.h │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── EulerAngles.h │ │ │ │ ├── Homogeneous.h │ │ │ │ ├── Hyperplane.h │ │ │ │ ├── OrthoMethods.h │ │ │ │ ├── ParametrizedLine.h │ │ │ │ ├── Quaternion.h │ │ │ │ ├── Rotation2D.h │ │ │ │ ├── RotationBase.h │ │ │ │ ├── Scaling.h │ │ │ │ ├── Transform.h │ │ │ │ ├── Translation.h │ │ │ │ ├── Umeyama.h │ │ │ │ └── arch │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ └── Geometry_SSE.h │ │ │ │ ├── Householder │ │ │ │ ├── BlockHouseholder.h │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── Householder.h │ │ │ │ └── HouseholderSequence.h │ │ │ │ ├── IterativeLinearSolvers │ │ │ │ ├── BasicPreconditioners.h │ │ │ │ ├── BiCGSTAB.h │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── ConjugateGradient.h │ │ │ │ ├── IncompleteLUT.h │ │ │ │ └── IterativeSolverBase.h │ │ │ │ ├── Jacobi │ │ │ │ ├── CMakeLists.txt │ │ │ │ └── Jacobi.h │ │ │ │ ├── LU │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── Determinant.h │ │ │ │ ├── FullPivLU.h │ │ │ │ ├── Inverse.h │ │ │ │ ├── PartialPivLU.h │ │ │ │ ├── PartialPivLU_MKL.h │ │ │ │ └── arch │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ └── Inverse_SSE.h │ │ │ │ ├── OrderingMethods │ │ │ │ ├── Amd.h │ │ │ │ └── CMakeLists.txt │ │ │ │ ├── PaStiXSupport │ │ │ │ ├── CMakeLists.txt │ │ │ │ └── PaStiXSupport.h │ │ │ │ ├── PardisoSupport │ │ │ │ ├── CMakeLists.txt │ │ │ │ └── PardisoSupport.h │ │ │ │ ├── QR │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── ColPivHouseholderQR.h │ │ │ │ ├── ColPivHouseholderQR_MKL.h │ │ │ │ ├── FullPivHouseholderQR.h │ │ │ │ ├── HouseholderQR.h │ │ │ │ └── HouseholderQR_MKL.h │ │ │ │ ├── SVD │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── JacobiSVD.h │ │ │ │ ├── JacobiSVD_MKL.h │ │ │ │ └── UpperBidiagonalization.h │ │ │ │ ├── SparseCholesky │ │ │ │ ├── CMakeLists.txt │ │ │ │ └── SimplicialCholesky.h │ │ │ │ ├── SparseCore │ │ │ │ ├── AmbiVector.h │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── CompressedStorage.h │ │ │ │ ├── ConservativeSparseSparseProduct.h │ │ │ │ ├── CoreIterators.h │ │ │ │ ├── MappedSparseMatrix.h │ │ │ │ ├── SparseAssign.h │ │ │ │ ├── SparseBlock.h │ │ │ │ ├── SparseCwiseBinaryOp.h │ │ │ │ ├── SparseCwiseUnaryOp.h │ │ │ │ ├── SparseDenseProduct.h │ │ │ │ ├── SparseDiagonalProduct.h │ │ │ │ ├── SparseDot.h │ │ │ │ ├── SparseFuzzy.h │ │ │ │ ├── SparseMatrix.h │ │ │ │ ├── SparseMatrixBase.h │ │ │ │ ├── SparsePermutation.h │ │ │ │ ├── SparseProduct.h │ │ │ │ ├── SparseRedux.h │ │ │ │ ├── SparseSelfAdjointView.h │ │ │ │ ├── SparseSparseProductWithPruning.h │ │ │ │ ├── SparseTranspose.h │ │ │ │ ├── SparseTriangularView.h │ │ │ │ ├── SparseUtil.h │ │ │ │ ├── SparseVector.h │ │ │ │ ├── SparseView.h │ │ │ │ └── TriangularSolver.h │ │ │ │ ├── StlSupport │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── StdDeque.h │ │ │ │ ├── StdList.h │ │ │ │ ├── StdVector.h │ │ │ │ └── details.h │ │ │ │ ├── SuperLUSupport │ │ │ │ ├── CMakeLists.txt │ │ │ │ └── SuperLUSupport.h │ │ │ │ ├── UmfPackSupport │ │ │ │ ├── CMakeLists.txt │ │ │ │ └── UmfPackSupport.h │ │ │ │ ├── misc │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── Image.h │ │ │ │ ├── Kernel.h │ │ │ │ ├── Solve.h │ │ │ │ ├── SparseSolve.h │ │ │ │ └── blas.h │ │ │ │ └── plugins │ │ │ │ ├── ArrayCwiseBinaryOps.h │ │ │ │ ├── ArrayCwiseUnaryOps.h │ │ │ │ ├── BlockMethods.h │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── CommonCwiseBinaryOps.h │ │ │ │ ├── CommonCwiseUnaryOps.h │ │ │ │ ├── MatrixCwiseBinaryOps.h │ │ │ │ └── MatrixCwiseUnaryOps.h │ │ ├── densecrf.h │ │ ├── labelcompatibility.h │ │ ├── objective.h │ │ ├── optimization.h │ │ ├── pairwise.h │ │ ├── permutohedral.h │ │ └── unary.h │ └── src │ │ ├── CMakeLists.txt │ │ ├── densecrf.cpp │ │ ├── labelcompatibility.cpp │ │ ├── objective.cpp │ │ ├── optimization.cpp │ │ ├── pairwise.cpp │ │ ├── permutohedral.cpp │ │ ├── unary.cpp │ │ ├── util.cpp │ │ └── util.h ├── eigen.cpp ├── eigen.pxd ├── eigen.pyx ├── eigen_impl.cpp ├── test.py ├── test_eigen.py └── utils.py └── setup.py /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Lucas Beyer 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # dss_crf 2 | 3 | The original version of this code can be found [here](https://github.com/lucasb-eyer/pydensecrf.git). 4 | Notice that please provide a link to this project as a footnote or a citation if you plan to use it. 5 | 6 | Setup 7 | ``` 8 | sudo python setup.py install 9 | ``` 10 | 11 | Usage 12 | ``` 13 | cd examples 14 | python dense_hsal.py im1.png anno1.png out1.png 15 | ``` 16 | im1.png -> source image 17 | anno1.png -> predicted saliency map (should be gray level) 18 | out1.png -> output (after CRF) 19 | -------------------------------------------------------------------------------- /examples/.ropeproject/config.py: -------------------------------------------------------------------------------- 1 | # The default ``config.py`` 2 | 3 | 4 | def set_prefs(prefs): 5 | """This function is called before opening the project""" 6 | 7 | # Specify which files and folders to ignore in the project. 8 | # Changes to ignored resources are not added to the history and 9 | # VCSs. Also they are not returned in `Project.get_files()`. 10 | # Note that ``?`` and ``*`` match all characters but slashes. 11 | # '*.pyc': matches 'test.pyc' and 'pkg/test.pyc' 12 | # 'mod*.pyc': matches 'test/mod1.pyc' but not 'mod/1.pyc' 13 | # '.svn': matches 'pkg/.svn' and all of its children 14 | # 'build/*.o': matches 'build/lib.o' but not 'build/sub/lib.o' 15 | # 'build//*.o': matches 'build/lib.o' and 'build/sub/lib.o' 16 | prefs['ignored_resources'] = ['*.pyc', '*~', '.ropeproject', 17 | '.hg', '.svn', '_svn', '.git'] 18 | 19 | # Specifies which files should be considered python files. It is 20 | # useful when you have scripts inside your project. Only files 21 | # ending with ``.py`` are considered to be python files by 22 | # default. 23 | #prefs['python_files'] = ['*.py'] 24 | 25 | # Custom source folders: By default rope searches the project 26 | # for finding source folders (folders that should be searched 27 | # for finding modules). You can add paths to that list. Note 28 | # that rope guesses project source folders correctly most of the 29 | # time; use this if you have any problems. 30 | # The folders should be relative to project root and use '/' for 31 | # separating folders regardless of the platform rope is running on. 32 | # 'src/my_source_folder' for instance. 33 | #prefs.add('source_folders', 'src') 34 | 35 | # You can extend python path for looking up modules 36 | #prefs.add('python_path', '~/python/') 37 | 38 | # Should rope save object information or not. 39 | prefs['save_objectdb'] = True 40 | prefs['compress_objectdb'] = False 41 | 42 | # If `True`, rope analyzes each module when it is being saved. 43 | prefs['automatic_soa'] = True 44 | # The depth of calls to follow in static object analysis 45 | prefs['soa_followed_calls'] = 0 46 | 47 | # If `False` when running modules or unit tests "dynamic object 48 | # analysis" is turned off. This makes them much faster. 49 | prefs['perform_doa'] = True 50 | 51 | # Rope can check the validity of its object DB when running. 52 | prefs['validate_objectdb'] = True 53 | 54 | # How many undos to hold? 55 | prefs['max_history_items'] = 32 56 | 57 | # Shows whether to save history across sessions. 58 | prefs['save_history'] = True 59 | prefs['compress_history'] = False 60 | 61 | # Set the number spaces used for indenting. According to 62 | # :PEP:`8`, it is best to use 4 spaces. Since most of rope's 63 | # unit-tests use 4 spaces it is more reliable, too. 64 | prefs['indent_size'] = 4 65 | 66 | # Builtin and c-extension modules that are allowed to be imported 67 | # and inspected by rope. 68 | prefs['extension_modules'] = [] 69 | 70 | # Add all standard c-extensions to extension_modules list. 71 | prefs['import_dynload_stdmods'] = True 72 | 73 | # If `True` modules with syntax errors are considered to be empty. 74 | # The default value is `False`; When `False` syntax errors raise 75 | # `rope.base.exceptions.ModuleSyntaxError` exception. 76 | prefs['ignore_syntax_errors'] = False 77 | 78 | # If `True`, rope ignores unresolvable imports. Otherwise, they 79 | # appear in the importing namespace. 80 | prefs['ignore_bad_imports'] = False 81 | 82 | 83 | def project_opened(project): 84 | """This function is called after opening the project""" 85 | # Do whatever you like here! 86 | -------------------------------------------------------------------------------- /examples/.ropeproject/globalnames: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/houqb/dss_crf/91ac933dc2544d6c4037ce0c3acbb9fea1c70c1c/examples/.ropeproject/globalnames -------------------------------------------------------------------------------- /examples/.ropeproject/history: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/houqb/dss_crf/91ac933dc2544d6c4037ce0c3acbb9fea1c70c1c/examples/.ropeproject/history -------------------------------------------------------------------------------- /examples/.ropeproject/objectdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/houqb/dss_crf/91ac933dc2544d6c4037ce0c3acbb9fea1c70c1c/examples/.ropeproject/objectdb -------------------------------------------------------------------------------- /examples/anno1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/houqb/dss_crf/91ac933dc2544d6c4037ce0c3acbb9fea1c70c1c/examples/anno1.png -------------------------------------------------------------------------------- /examples/anno2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/houqb/dss_crf/91ac933dc2544d6c4037ce0c3acbb9fea1c70c1c/examples/anno2.png -------------------------------------------------------------------------------- /examples/anno3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/houqb/dss_crf/91ac933dc2544d6c4037ce0c3acbb9fea1c70c1c/examples/anno3.png -------------------------------------------------------------------------------- /examples/dense_hsal.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | """ 4 | Adapted from the original C++ example: densecrf/examples/dense_inference.cpp 5 | http://www.philkr.net/home/densecrf Version 2.2 6 | """ 7 | 8 | import numpy as np 9 | import cv2 10 | import pydensecrf.densecrf as dcrf 11 | from skimage.segmentation import relabel_sequential 12 | import sys 13 | 14 | def sigmoid(x): 15 | return 1 / (1 + np.exp(-x)) 16 | 17 | if len(sys.argv) != 4: 18 | print("Usage: python {} IMAGE ANNO OUTPUT".format(sys.argv[0])) 19 | print("") 20 | print("IMAGE and ANNO are inputs and OUTPUT is where the result should be written.") 21 | sys.exit(1) 22 | 23 | EPSILON = 1e-8 24 | 25 | img = cv2.imread(sys.argv[1], 1) 26 | annos = cv2.imread(sys.argv[2], 0) 27 | labels = relabel_sequential(cv2.imread(sys.argv[2], 0))[0].flatten() 28 | output = sys.argv[3] 29 | 30 | M = 2 # salient or not 31 | tau = 1.05 32 | # Setup the CRF model 33 | d = dcrf.DenseCRF2D(img.shape[1], img.shape[0], M) 34 | 35 | anno_norm = annos / 255. 36 | n_energy = -np.log((1.0 - anno_norm + EPSILON)) / (tau * sigmoid(1 - anno_norm)) 37 | p_energy = -np.log(anno_norm + EPSILON) / (tau * sigmoid(anno_norm)) 38 | 39 | U = np.zeros((M, img.shape[0] * img.shape[1]), dtype='float32') 40 | U[0, :] = n_energy.flatten() 41 | U[1, :] = p_energy.flatten() 42 | 43 | d.setUnaryEnergy(U) 44 | 45 | d.addPairwiseGaussian(sxy=3, compat=3) 46 | d.addPairwiseBilateral(sxy=60, srgb=5, rgbim=img, compat=5) 47 | 48 | # Do the inference 49 | infer = np.array(d.inference(1)).astype('float32') 50 | res = infer[1,:] 51 | 52 | #res *= 255 / res.max() 53 | res = res * 255 54 | res = res.reshape(img.shape[:2]) 55 | cv2.imwrite(output, res.astype('uint8')) 56 | -------------------------------------------------------------------------------- /examples/im1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/houqb/dss_crf/91ac933dc2544d6c4037ce0c3acbb9fea1c70c1c/examples/im1.png -------------------------------------------------------------------------------- /examples/im2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/houqb/dss_crf/91ac933dc2544d6c4037ce0c3acbb9fea1c70c1c/examples/im2.png -------------------------------------------------------------------------------- /examples/im3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/houqb/dss_crf/91ac933dc2544d6c4037ce0c3acbb9fea1c70c1c/examples/im3.png -------------------------------------------------------------------------------- /examples/inference.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | """ 4 | Adapted from the original C++ example: densecrf/examples/dense_inference.cpp 5 | http://www.philkr.net/home/densecrf Version 2.2 6 | """ 7 | 8 | import numpy as np 9 | import cv2 10 | import pydensecrf.densecrf as dcrf 11 | from skimage.segmentation import relabel_sequential 12 | import sys 13 | import Image 14 | 15 | if len(sys.argv) != 4: 16 | print("Usage: python {} IMAGE ANNO OUTPUT".format(sys.argv[0])) 17 | print("") 18 | print("IMAGE and ANNO are inputs and OUTPUT is where the result should be written.") 19 | sys.exit(1) 20 | 21 | img = cv2.imread(sys.argv[1], 1) 22 | labels = relabel_sequential(cv2.imread(sys.argv[2], 0))[0].flatten() 23 | output = sys.argv[3] 24 | 25 | palette = [0,0,0, 26 | 128,0,0, 27 | 0,128,0, 28 | 128,128,0, 29 | 0,0,128, 30 | 128,0,128, 31 | 0,128,128, 32 | 128,128,128, 33 | 64,0,0, 34 | 192,0,0, 35 | 64,128,0, 36 | 192,128,0, 37 | 64,0,128, 38 | 192,0,128, 39 | 64,128,128, 40 | 192,128,128, 41 | 0,64,0, 42 | 128,64,0, 43 | 0,192,0, 44 | 128,192,0, 45 | 0,64,128, 46 | 128,64,128, 47 | 0,192,128, 48 | 128,192,128, 49 | 64,64,0, 50 | 192,64,0, 51 | 64,192,0, 52 | 192,192,0] 53 | 54 | M = 21 # number of labels 55 | 56 | # Setup the CRF model 57 | d = dcrf.DenseCRF2D(img.shape[1], img.shape[0], M) 58 | 59 | # Certainty that the ground truth is correct 60 | GT_PROB = 0.5 61 | 62 | # Simple classifier that is 50% certain that the annotation is correct 63 | u_energy = -np.log(1.0 / M) 64 | n_energy = -np.log((1.0 - GT_PROB) / (M - 1)) 65 | p_energy = -np.log(GT_PROB) 66 | 67 | U = np.zeros((M, img.shape[0] * img.shape[1]), dtype='float32') 68 | U[:, labels > 0] = n_energy 69 | U[labels, np.arange(U.shape[1])] = p_energy 70 | U[:, labels == 0] = u_energy 71 | d.setUnaryEnergy(U) 72 | 73 | d.addPairwiseGaussian(sxy=3, compat=3) 74 | d.addPairwiseBilateral(sxy=80, srgb=13, rgbim=img, compat=10) 75 | 76 | # Do the inference 77 | res = np.argmax(d.inference(5), axis=0).astype('uint8') 78 | 79 | res = res.reshape(img.shape[:2]) 80 | res = Image.fromarray(res, mode='P') 81 | res.putpalette(palette) 82 | res.save(output) 83 | -------------------------------------------------------------------------------- /examples/utils_example.py: -------------------------------------------------------------------------------- 1 | """ 2 | Adapted from the inference.py to demonstate the usage of the util functions. 3 | """ 4 | 5 | import sys 6 | import numpy as np 7 | import cv2 8 | import pydensecrf.densecrf as dcrf 9 | from skimage.segmentation import relabel_sequential 10 | 11 | from pydensecrf.utils import compute_unary, create_pairwise_bilateral, \ 12 | create_pairwise_gaussian 13 | 14 | if len(sys.argv) != 4: 15 | print("Usage: python {} IMAGE ANNO OUTPUT".format(sys.argv[0])) 16 | print("") 17 | print("IMAGE and ANNO are inputs and OUTPUT is where the result should be written.") 18 | sys.exit(1) 19 | 20 | fn_im = sys.argv[1] 21 | fn_anno = sys.argv[2] 22 | fn_output = sys.argv[3] 23 | 24 | ################################## 25 | ### Read images and annotation ### 26 | ################################## 27 | img = cv2.imread(fn_im) 28 | labels, _, _ = relabel_sequential(cv2.imread(fn_anno, 0)) 29 | 30 | # Compute the number of classes in the label image 31 | M = len(set(labels.flat)) 32 | 33 | ########################### 34 | ### Setup the CRF model ### 35 | ########################### 36 | use_2d = False 37 | if use_2d: 38 | # Example using the DenseCRF2D code 39 | d = dcrf.DenseCRF2D(img.shape[1], img.shape[0], M) 40 | 41 | # get unary potentials (neg log probability) 42 | U = compute_unary(labels, M) 43 | d.setUnaryEnergy(U) 44 | 45 | # This adds the color-independent term, features are the locations only. 46 | d.addPairwiseGaussian(sxy=(3, 3), compat=3, kernel=dcrf.DIAG_KERNEL, 47 | normalization=dcrf.NORMALIZE_SYMMETRIC) 48 | 49 | # This adds the color-dependent term, i.e. features are (x,y,r,g,b). 50 | d.addPairwiseBilateral(sxy=(80, 80), srgb=(13, 13, 13), rgbim=img, 51 | compat=10, 52 | kernel=dcrf.DIAG_KERNEL, 53 | normalization=dcrf.NORMALIZE_SYMMETRIC) 54 | else: 55 | # Example using the DenseCRF class and the util functions 56 | d = dcrf.DenseCRF(img.shape[0] * img.shape[1], M) 57 | 58 | # get unary potentials (neg log probability) 59 | U = compute_unary(labels, M) 60 | d.setUnaryEnergy(U) 61 | 62 | # This creates the color-independent features and then add them to the CRF 63 | feats = create_pairwise_gaussian(sdims=(3, 3), shape=img.shape[:2]) 64 | d.addPairwiseEnergy(feats, compat=3, 65 | kernel=dcrf.DIAG_KERNEL, 66 | normalization=dcrf.NORMALIZE_SYMMETRIC) 67 | 68 | # This creates the color-dependent features and then add them to the CRF 69 | feats = create_pairwise_bilateral(sdims=(80, 80), schan=(13, 13, 13), 70 | img=img, chdim=2) 71 | d.addPairwiseEnergy(feats, compat=10, 72 | kernel=dcrf.DIAG_KERNEL, 73 | normalization=dcrf.NORMALIZE_SYMMETRIC) 74 | 75 | 76 | #################################### 77 | ### Do inference and compute map ### 78 | #################################### 79 | Q = d.inference(5) 80 | MAP = np.argmax(Q, axis=0).astype('float32') 81 | MAP *= 255 / MAP.max() 82 | MAP = MAP.reshape(img.shape[:2]) 83 | cv2.imwrite(fn_output, MAP.astype('uint8')) 84 | 85 | # Manually inference 86 | Q, tmp1, tmp2 = d.startInference() 87 | for i in range(5): 88 | print("KL-divergence at {}: {}".format(i, d.klDivergence(Q))) 89 | d.stepInference(Q, tmp1, tmp2) 90 | -------------------------------------------------------------------------------- /pydensecrf/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/houqb/dss_crf/91ac933dc2544d6c4037ce0c3acbb9fea1c70c1c/pydensecrf/__init__.py -------------------------------------------------------------------------------- /pydensecrf/densecrf.pxd: -------------------------------------------------------------------------------- 1 | from eigen cimport * 2 | 3 | 4 | cdef extern from "densecrf/include/labelcompatibility.h": 5 | cdef cppclass LabelCompatibility: 6 | pass 7 | 8 | cdef cppclass PottsCompatibility(LabelCompatibility): 9 | PottsCompatibility(float) except + 10 | 11 | cdef cppclass DiagonalCompatibility(LabelCompatibility): 12 | DiagonalCompatibility(const c_VectorXf&) except + 13 | 14 | cdef cppclass MatrixCompatibility(LabelCompatibility): 15 | MatrixCompatibility(const c_MatrixXf&) except + 16 | 17 | 18 | cdef extern from "densecrf/include/unary.h": 19 | cdef cppclass UnaryEnergy: 20 | pass 21 | 22 | cdef cppclass ConstUnaryEnergy(UnaryEnergy): 23 | ConstUnaryEnergy(const c_MatrixXf& unary) except + 24 | 25 | cdef cppclass LogisticUnaryEnergy(UnaryEnergy): 26 | LogisticUnaryEnergy(const c_MatrixXf& L, const c_MatrixXf& feature) except + 27 | 28 | 29 | cdef class Unary: 30 | cdef UnaryEnergy *thisptr 31 | cdef UnaryEnergy* move(self) 32 | 33 | 34 | cdef class ConstUnary(Unary): 35 | pass 36 | 37 | 38 | cdef class LogisticUnary(Unary): 39 | pass 40 | 41 | 42 | cdef extern from "densecrf/include/pairwise.h": 43 | cpdef enum NormalizationType: NO_NORMALIZATION, NORMALIZE_BEFORE, NORMALIZE_AFTER, NORMALIZE_SYMMETRIC 44 | cpdef enum KernelType: CONST_KERNEL, DIAG_KERNEL, FULL_KERNEL 45 | 46 | 47 | cdef extern from "densecrf/include/densecrf.h": 48 | cdef cppclass c_DenseCRF "DenseCRF": 49 | c_DenseCRF(int N, int M) except + 50 | 51 | # Setup methods. 52 | # TODO 53 | #void addPairwiseEnergy(PairwisePotential *potential) 54 | void addPairwiseEnergy(const c_MatrixXf &features, LabelCompatibility*, KernelType, NormalizationType) 55 | void setUnaryEnergy(UnaryEnergy *unary) 56 | void setUnaryEnergy(const c_MatrixXf &unary) 57 | void setUnaryEnergy(const c_MatrixXf &L, const c_MatrixXf &feature) 58 | 59 | # Inference methods. 60 | c_MatrixXf inference(int n_iterations) 61 | # TODO: Not enabled because it would require wrapping VectorXs (note the `s`) 62 | #c_VectorXs map(int n_iterations) 63 | 64 | # Step-by-step inference methods. 65 | c_MatrixXf startInference() const 66 | void stepInference(c_MatrixXf &Q, c_MatrixXf &tmp1, c_MatrixXf &tmp2) const 67 | #double gradient( int n_iterations, const ObjectiveFunction & objective, c_VectorXf * unary_grad, c_VectorXf * lbl_cmp_grad, c_VectorXf * kernel_grad=NULL ) const; 68 | 69 | double klDivergence(const c_MatrixXf &Q) const 70 | 71 | #c_VectorXf unaryParameters() const; 72 | #void setUnaryParameters( const c_VectorXf & v ); 73 | #c_VectorXf labelCompatibilityParameters() const; 74 | #void setLabelCompatibilityParameters( const c_VectorXf & v ); 75 | #c_VectorXf kernelParameters() const; 76 | #void setKernelParameters( const c_VectorXf & v ); 77 | 78 | 79 | cdef extern from "densecrf/include/densecrf.h": 80 | cdef cppclass c_DenseCRF2D "DenseCRF2D" (c_DenseCRF): 81 | c_DenseCRF2D(int W, int H, int M) except + 82 | 83 | void addPairwiseGaussian(float sx, float sy, LabelCompatibility*, KernelType, NormalizationType) 84 | void addPairwiseBilateral(float sx, float sy, float sr, float sg, float sb, const unsigned char *rgbim, LabelCompatibility*, KernelType, NormalizationType) 85 | 86 | 87 | cdef class DenseCRF: 88 | cdef c_DenseCRF *_this 89 | 90 | 91 | cdef class DenseCRF2D(DenseCRF): 92 | cdef c_DenseCRF2D *_this2d 93 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/README.txt: -------------------------------------------------------------------------------- 1 | DenseCRF - Code 2 | ============= 3 | http://graphics.stanford.edu/projects/drf/ 4 | 5 | This software pertains to the research described in the ICML 2013 paper: 6 | Parameter Learning and Convergent Inference for Dense Random Fields, by 7 | Philipp Krähenbühl and Vladlen Koltun 8 | and the NIPS 2011 paper: 9 | Efficient Inference in Fully Connected CRFs with Gaussian Edge Potentials, by 10 | Philipp Krähenbühl and Vladlen Koltun 11 | 12 | If you're using this code in a publication, please cite our papers. 13 | 14 | This software is provided for research purposes, with absolutely no warranty 15 | or suggested support, and use of it most follow the BSD license agreement, at 16 | the top of each source file. *Please do not contact the authors for assistance 17 | with installing, understanding or running the code.* However if you think you 18 | have found an interesting bug, the authors would be grateful if you could pass 19 | on the information. 20 | 21 | Changes to the original code 22 | ---------------------------- 23 | The only major difference in this released version of the code is, that I directly 24 | compute the gradient of the permutohedral lattice, instead of the general Gauss 25 | Transform (3 line formula in p.6 in ICML 2013 paper). The gradient of the 26 | permutohedral lattice evaluated the exact gradient of the approximate filter. 27 | In higher dimensions (>3) the filter can be non continuous, which can complicate 28 | the optimization. The kernel gradient is also scaled lower than other parameters, 29 | which complicates the optimization. 30 | 31 | 32 | How to compile the code 33 | ----------------------- 34 | Dependencies: 35 | * cmake http://www.cmake.org/ 36 | * Eigen (included) 37 | * liblbfgs (included) 38 | 39 | Linux, Mac OS X and Windows (cygwin): 40 | mkdir build 41 | cd build 42 | cmake -D CMAKE_BUILD_TYPE=Release .. 43 | make 44 | cd .. 45 | 46 | Windows 47 | You're probably better off just copying all files into a Visual Studio 48 | project 49 | 50 | 51 | How to run the example 52 | ---------------------- 53 | An example on how to use the DenseCRF can be found in 54 | examples/dense_inference.cpp. The example loads an image and some annotations. 55 | It then uses a very simple classifier to compute a unary term based on those 56 | annotations. A dense CRF with both color dependent and color independent terms 57 | find the final accurate labeling. 58 | 59 | Linux, Mac OS X and Windows (cygwin): 60 | build/examples/dense_inference input_image.ppm annotations.ppm output.ppm 61 | 62 | For example: 63 | build/examples/dense_inference examples/im1.ppm examples/anno1.ppm output1.ppm 64 | 65 | 66 | An example on how to unse the learning code can be found in 67 | examples/dense_learning.cpp. The example loads a color image and ground truth 68 | annotation. It then learn a CRF model with a logistic regression, a label comp 69 | and Gaussian kernel. 70 | 71 | Linux, Mac OS X and Windows (cygwin): 72 | build/examples/dense_learning input_image.ppm annotations.ppm output.ppm 73 | 74 | For example: 75 | build/examples/dense_learning examples/im1.ppm examples/anno1.ppm output1.ppm 76 | 77 | 78 | Please note that this implementation is slightly slower than the one used to 79 | in our NIPS 2011 paper. Mainly because I tried to keep the code clean and easy 80 | to understand. 81 | 82 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/external/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories( liblbfgs/include ) 2 | add_library( lbfgs liblbfgs/lib/lbfgs.c ) 3 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/external/liblbfgs/AUTHORS: -------------------------------------------------------------------------------- 1 | Naoaki Okazaki 2 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/external/liblbfgs/COPYING: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 1990 Jorge Nocedal 4 | Copyright (c) 2007-2010 Naoaki Okazaki 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a 7 | copy of this software and associated documentation files (the "Software"), 8 | to deal in the Software without restriction, including without limitation 9 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | and/or sell copies of the Software, and to permit persons to whom the 11 | Software is furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/external/liblbfgs/Makefile.am: -------------------------------------------------------------------------------- 1 | # $Id$ 2 | 3 | SUBDIRS = lib sample 4 | 5 | docdir = $(prefix)/share/doc/@PACKAGE@ 6 | doc_DATA = README INSTALL COPYING AUTHORS ChangeLog NEWS 7 | 8 | EXTRA_DIST = \ 9 | autogen.sh \ 10 | lbfgs.sln 11 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/external/liblbfgs/NEWS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/houqb/dss_crf/91ac933dc2544d6c4037ce0c3acbb9fea1c70c1c/pydensecrf/densecrf/external/liblbfgs/NEWS -------------------------------------------------------------------------------- /pydensecrf/densecrf/external/liblbfgs/README: -------------------------------------------------------------------------------- 1 | 2 | libLBFGS: C library of limited-memory BFGS (L-BFGS) 3 | 4 | Copyright (c) 1990, Jorge Nocedal 5 | Copyright (c) 2007-2010, Naoaki Okazaki 6 | 7 | ========================================================================= 8 | 1. Introduction 9 | ========================================================================= 10 | libLBFGS is a C port of the implementation of Limited-memory 11 | Broyden-Fletcher-Goldfarb-Shanno (L-BFGS) method written by Jorge Nocedal. 12 | The original FORTRAN source code is available at: 13 | http://www.ece.northwestern.edu/~nocedal/lbfgs.html 14 | 15 | The L-BFGS method solves the unconstrainted minimization problem: 16 | minimize F(x), x = (x1, x2, ..., xN), 17 | only if the objective function F(x) and its gradient G(x) are computable. 18 | 19 | Refer to the libLBFGS web site for more information. 20 | http://www.chokkan.org/software/liblbfgs/ 21 | 22 | 23 | 24 | ========================================================================= 25 | 2. How to build 26 | ========================================================================= 27 | [Microsoft Visual Studio 2008] 28 | Open the solution file "lbfgs.sln" and build it. 29 | 30 | [GCC] 31 | $ ./configure 32 | $ make 33 | $ make install # To install libLBFGS library and header. 34 | 35 | 36 | 37 | ========================================================================= 38 | 3. Note on SSE/SSE2 optimization 39 | ========================================================================= 40 | This library has SSE/SSE2 optimization routines for vector arithmetic 41 | operations on Intel/AMD processors. The SSE2 routine is for 64 bit double 42 | values, and the SSE routine is for 32 bit float values. Since the default 43 | parameters in libLBFGS are tuned for double precision values, it may need 44 | to modify these parameters to use the SSE optimization routines. 45 | 46 | To use the SSE2 optimization routine, specify --enable-sse2 option to the 47 | configure script. 48 | 49 | $ ./configure --enable-sse2 50 | 51 | To build libLBFGS with SSE2 optimization enabled on Microsoft Visual 52 | Studio 2005, define USE_SSE and __SSE2__ symbols. 53 | 54 | Make sure to run libLBFGS on processors where SSE2 instrunctions are 55 | available. The library does not check the existence of SSE2 instructions. 56 | 57 | To package maintainers, 58 | 59 | Please do not enable SSE/SSE2 optimization routine. The library built 60 | with SSE/SSE2 optimization will crash without any notice when necessary 61 | SSE/SSE2 instructions are unavailable on CPUs. 62 | 63 | 64 | 65 | ========================================================================= 66 | 4. License 67 | ========================================================================= 68 | libLBFGS is distributed under the term of the MIT license. 69 | Please refer to COPYING file in the distribution. 70 | 71 | $Id$ 72 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/external/liblbfgs/autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # $Id$ 3 | 4 | if [ "$1" = "--force" ]; 5 | then 6 | FORCE=--force 7 | NOFORCE= 8 | FORCE_MISSING=--force-missing 9 | else 10 | FORCE= 11 | NOFORCE=--no-force 12 | FORCE_MISSING= 13 | fi 14 | 15 | libtoolize --copy $FORCE 2>&1 | sed '/^You should/d' || { 16 | echo "libtoolize failed!" 17 | exit 1 18 | } 19 | 20 | aclocal $FORCE || { 21 | echo "aclocal failed!" 22 | exit 1 23 | } 24 | 25 | autoheader $FORCE || { 26 | echo "autoheader failed!" 27 | exit 1 28 | } 29 | 30 | automake -a -c $NOFORCE || { 31 | echo "automake failed!" 32 | exit 1 33 | } 34 | 35 | autoconf $FORCE || { 36 | echo "autoconf failed!" 37 | exit 1 38 | } 39 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/external/liblbfgs/config.h.in: -------------------------------------------------------------------------------- 1 | /* config.h.in. Generated from configure.in by autoheader. */ 2 | 3 | /* Define to 1 if you have the header file. */ 4 | #undef HAVE_DLFCN_H 5 | 6 | /* Define to 1 if you have the header file. */ 7 | #undef HAVE_EMMINTRIN_H 8 | 9 | /* Define to 1 if you have the header file. */ 10 | #undef HAVE_INTTYPES_H 11 | 12 | /* Define to 1 if you have the `m' library (-lm). */ 13 | #undef HAVE_LIBM 14 | 15 | /* Define to 1 if you have the header file. */ 16 | #undef HAVE_MEMORY_H 17 | 18 | /* Define to 1 if you have the header file. */ 19 | #undef HAVE_STDINT_H 20 | 21 | /* Define to 1 if you have the header file. */ 22 | #undef HAVE_STDLIB_H 23 | 24 | /* Define to 1 if you have the header file. */ 25 | #undef HAVE_STRINGS_H 26 | 27 | /* Define to 1 if you have the header file. */ 28 | #undef HAVE_STRING_H 29 | 30 | /* Define to 1 if you have the header file. */ 31 | #undef HAVE_SYS_STAT_H 32 | 33 | /* Define to 1 if you have the header file. */ 34 | #undef HAVE_SYS_TYPES_H 35 | 36 | /* Define to 1 if you have the header file. */ 37 | #undef HAVE_UNISTD_H 38 | 39 | /* Define to 1 if you have the header file. */ 40 | #undef HAVE_XMMINTRIN_H 41 | 42 | /* Name of package */ 43 | #undef PACKAGE 44 | 45 | /* Define to the address where bug reports for this package should be sent. */ 46 | #undef PACKAGE_BUGREPORT 47 | 48 | /* Define to the full name of this package. */ 49 | #undef PACKAGE_NAME 50 | 51 | /* Define to the full name and version of this package. */ 52 | #undef PACKAGE_STRING 53 | 54 | /* Define to the one symbol short name of this package. */ 55 | #undef PACKAGE_TARNAME 56 | 57 | /* Define to the version of this package. */ 58 | #undef PACKAGE_VERSION 59 | 60 | /* Define to 1 if you have the ANSI C header files. */ 61 | #undef STDC_HEADERS 62 | 63 | /* Version number of package */ 64 | #undef VERSION 65 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/external/liblbfgs/configure.in: -------------------------------------------------------------------------------- 1 | dnl $Id$ 2 | dnl 3 | dnl 4 | dnl Exported and configured variables: 5 | dnl CFLAGS 6 | dnl LDFLAGS 7 | dnl INCLUDES 8 | 9 | 10 | dnl ------------------------------------------------------------------ 11 | dnl Initialization for autoconf 12 | dnl ------------------------------------------------------------------ 13 | AC_PREREQ(2.59) 14 | AC_INIT 15 | AC_CONFIG_SRCDIR([lib/lbfgs.c]) 16 | 17 | 18 | dnl ------------------------------------------------------------------ 19 | dnl Initialization for automake 20 | dnl ------------------------------------------------------------------ 21 | AM_INIT_AUTOMAKE(liblbfgs, 1.10) 22 | AC_CONFIG_HEADERS(config.h) 23 | AM_MAINTAINER_MODE 24 | 25 | 26 | dnl ------------------------------------------------------------------ 27 | dnl Checks for program 28 | dnl ------------------------------------------------------------------ 29 | AC_PROG_LIBTOOL 30 | AC_PROG_INSTALL 31 | AC_PROG_LN_S 32 | AC_PROG_MAKE_SET 33 | 34 | 35 | dnl ------------------------------------------------------------------ 36 | dnl Initialization for variables 37 | dnl ------------------------------------------------------------------ 38 | CFLAGS="${ac_save_CFLAGS} -Wall" 39 | LDFLAGS="${ac_save_LDFLAGS}" 40 | INCLUDES="-I\$(top_srcdir) -I\$(top_srcdir)/include" 41 | 42 | 43 | 44 | dnl ------------------------------------------------------------------ 45 | dnl Checks for header files. 46 | dnl ------------------------------------------------------------------ 47 | AC_HEADER_STDC 48 | AC_CHECK_HEADERS(xmmintrin.h emmintrin.h) 49 | 50 | 51 | 52 | dnl ------------------------------------------------------------------ 53 | dnl Checks for debugging mode 54 | dnl ------------------------------------------------------------------ 55 | AC_ARG_ENABLE( 56 | debug, 57 | [AS_HELP_STRING( 58 | [--enable-debug], 59 | [build for debugging] 60 | )], 61 | [CFLAGS="-DDEBUG -O -g ${CFLAGS}"], 62 | [CFLAGS="-O3 -ffast-math ${CFLAGS}"] 63 | ) 64 | 65 | dnl ------------------------------------------------------------------ 66 | dnl Checks for profiling mode 67 | dnl ------------------------------------------------------------------ 68 | AC_ARG_ENABLE( 69 | profile, 70 | [AS_HELP_STRING( 71 | [--enable-profile], 72 | [build for profiling] 73 | )], 74 | [CFLAGS="-DPROFILE -pg ${CFLAGS}"] 75 | ) 76 | 77 | dnl ------------------------------------------------------------------ 78 | dnl Checks for SSE2 build 79 | dnl ------------------------------------------------------------------ 80 | AC_ARG_ENABLE( 81 | sse2, 82 | [AS_HELP_STRING( 83 | [--enable-sse2], 84 | [enable SSE2 optimization routines] 85 | )], 86 | [CFLAGS="-msse2 -DUSE_SSE ${CFLAGS}"] 87 | ) 88 | 89 | dnl ------------------------------------------------------------------ 90 | dnl Checks for library functions. 91 | dnl ------------------------------------------------------------------ 92 | AC_CHECK_LIB(m, fabs) 93 | 94 | 95 | 96 | dnl ------------------------------------------------------------------ 97 | dnl Export variables 98 | dnl ------------------------------------------------------------------ 99 | AC_SUBST(CFLAGS) 100 | AC_SUBST(LDFLAGS) 101 | AC_SUBST(INCLUDES) 102 | 103 | dnl ------------------------------------------------------------------ 104 | dnl Output the configure results. 105 | dnl ------------------------------------------------------------------ 106 | AC_CONFIG_FILES(Makefile lib/Makefile sample/Makefile) 107 | AC_OUTPUT 108 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/external/liblbfgs/lbfgs.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lib", "lib\lib.vcxproj", "{C4405B73-A899-44BF-8681-04CE040B6705}" 5 | EndProject 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sample", "sample\sample.vcxproj", "{B4D7D5F5-4A4E-49D5-B38A-E5673520DE66}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Release|Win32 = Release|Win32 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {C4405B73-A899-44BF-8681-04CE040B6705}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {C4405B73-A899-44BF-8681-04CE040B6705}.Debug|Win32.Build.0 = Debug|Win32 16 | {C4405B73-A899-44BF-8681-04CE040B6705}.Release|Win32.ActiveCfg = Release|Win32 17 | {C4405B73-A899-44BF-8681-04CE040B6705}.Release|Win32.Build.0 = Release|Win32 18 | {B4D7D5F5-4A4E-49D5-B38A-E5673520DE66}.Debug|Win32.ActiveCfg = Debug|Win32 19 | {B4D7D5F5-4A4E-49D5-B38A-E5673520DE66}.Debug|Win32.Build.0 = Debug|Win32 20 | {B4D7D5F5-4A4E-49D5-B38A-E5673520DE66}.Release|Win32.ActiveCfg = Release|Win32 21 | {B4D7D5F5-4A4E-49D5-B38A-E5673520DE66}.Release|Win32.Build.0 = Release|Win32 22 | EndGlobalSection 23 | GlobalSection(SolutionProperties) = preSolution 24 | HideSolutionNode = FALSE 25 | EndGlobalSection 26 | EndGlobal 27 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/external/liblbfgs/lib/Makefile.am: -------------------------------------------------------------------------------- 1 | # $Id$ 2 | 3 | EXTRA_DIST = \ 4 | lib.vcxproj 5 | 6 | liblbfgsincludedir = $(includedir) 7 | liblbfgsinclude_HEADERS = \ 8 | ../include/lbfgs.h 9 | 10 | lib_LTLIBRARIES = liblbfgs.la 11 | 12 | liblbfgs_la_SOURCES = \ 13 | arithmetic_ansi.h \ 14 | arithmetic_sse_double.h \ 15 | arithmetic_sse_float.h \ 16 | ../include/lbfgs.h \ 17 | lbfgs.c 18 | 19 | liblbfgs_la_LDFLAGS = \ 20 | -no-undefined \ 21 | -release @VERSION@ 22 | 23 | AM_CFLAGS = @CFLAGS@ 24 | INCLUDES = @INCLUDES@ 25 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/external/liblbfgs/lib/arithmetic_ansi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ANSI C implementation of vector operations. 3 | * 4 | * Copyright (c) 2007-2010 Naoaki Okazaki 5 | * All rights reserved. 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | /* $Id$ */ 27 | 28 | #include 29 | #include 30 | 31 | #if LBFGS_FLOAT == 32 && LBFGS_IEEE_FLOAT 32 | #define fsigndiff(x, y) (((*(uint32_t*)(x)) ^ (*(uint32_t*)(y))) & 0x80000000U) 33 | #else 34 | #define fsigndiff(x, y) (*(x) * (*(y) / fabs(*(y))) < 0.) 35 | #endif/*LBFGS_IEEE_FLOAT*/ 36 | 37 | inline static void* vecalloc(size_t size) 38 | { 39 | void *memblock = malloc(size); 40 | if (memblock) { 41 | memset(memblock, 0, size); 42 | } 43 | return memblock; 44 | } 45 | 46 | inline static void vecfree(void *memblock) 47 | { 48 | free(memblock); 49 | } 50 | 51 | inline static void vecset(lbfgsfloatval_t *x, const lbfgsfloatval_t c, const int n) 52 | { 53 | int i; 54 | 55 | for (i = 0;i < n;++i) { 56 | x[i] = c; 57 | } 58 | } 59 | 60 | inline static void veccpy(lbfgsfloatval_t *y, const lbfgsfloatval_t *x, const int n) 61 | { 62 | int i; 63 | 64 | for (i = 0;i < n;++i) { 65 | y[i] = x[i]; 66 | } 67 | } 68 | 69 | inline static void vecncpy(lbfgsfloatval_t *y, const lbfgsfloatval_t *x, const int n) 70 | { 71 | int i; 72 | 73 | for (i = 0;i < n;++i) { 74 | y[i] = -x[i]; 75 | } 76 | } 77 | 78 | inline static void vecadd(lbfgsfloatval_t *y, const lbfgsfloatval_t *x, const lbfgsfloatval_t c, const int n) 79 | { 80 | int i; 81 | 82 | for (i = 0;i < n;++i) { 83 | y[i] += c * x[i]; 84 | } 85 | } 86 | 87 | inline static void vecdiff(lbfgsfloatval_t *z, const lbfgsfloatval_t *x, const lbfgsfloatval_t *y, const int n) 88 | { 89 | int i; 90 | 91 | for (i = 0;i < n;++i) { 92 | z[i] = x[i] - y[i]; 93 | } 94 | } 95 | 96 | inline static void vecscale(lbfgsfloatval_t *y, const lbfgsfloatval_t c, const int n) 97 | { 98 | int i; 99 | 100 | for (i = 0;i < n;++i) { 101 | y[i] *= c; 102 | } 103 | } 104 | 105 | inline static void vecmul(lbfgsfloatval_t *y, const lbfgsfloatval_t *x, const int n) 106 | { 107 | int i; 108 | 109 | for (i = 0;i < n;++i) { 110 | y[i] *= x[i]; 111 | } 112 | } 113 | 114 | inline static void vecdot(lbfgsfloatval_t* s, const lbfgsfloatval_t *x, const lbfgsfloatval_t *y, const int n) 115 | { 116 | int i; 117 | *s = 0.; 118 | for (i = 0;i < n;++i) { 119 | *s += x[i] * y[i]; 120 | } 121 | } 122 | 123 | inline static void vec2norm(lbfgsfloatval_t* s, const lbfgsfloatval_t *x, const int n) 124 | { 125 | vecdot(s, x, x, n); 126 | *s = (lbfgsfloatval_t)sqrt(*s); 127 | } 128 | 129 | inline static void vec2norminv(lbfgsfloatval_t* s, const lbfgsfloatval_t *x, const int n) 130 | { 131 | vec2norm(s, x, n); 132 | *s = (lbfgsfloatval_t)(1.0 / *s); 133 | } 134 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/external/liblbfgs/sample/Makefile.am: -------------------------------------------------------------------------------- 1 | # $Id$ 2 | 3 | EXTRA_DIST = \ 4 | sample.cpp \ 5 | sample.vcxproj 6 | 7 | noinst_PROGRAMS = sample 8 | 9 | sample_SOURCES = \ 10 | sample.c 11 | 12 | sample_LDADD = ../lib/liblbfgs.la 13 | 14 | AM_CFLAGS = @CFLAGS@ 15 | INCLUDES = @INCLUDES@ 16 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/external/liblbfgs/sample/sample.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | static lbfgsfloatval_t evaluate( 5 | void *instance, 6 | const lbfgsfloatval_t *x, 7 | lbfgsfloatval_t *g, 8 | const int n, 9 | const lbfgsfloatval_t step 10 | ) 11 | { 12 | int i; 13 | lbfgsfloatval_t fx = 0.0; 14 | 15 | for (i = 0;i < n;i += 2) { 16 | lbfgsfloatval_t t1 = 1.0 - x[i]; 17 | lbfgsfloatval_t t2 = 10.0 * (x[i+1] - x[i] * x[i]); 18 | g[i+1] = 20.0 * t2; 19 | g[i] = -2.0 * (x[i] * g[i+1] + t1); 20 | fx += t1 * t1 + t2 * t2; 21 | } 22 | return fx; 23 | } 24 | 25 | static int progress( 26 | void *instance, 27 | const lbfgsfloatval_t *x, 28 | const lbfgsfloatval_t *g, 29 | const lbfgsfloatval_t fx, 30 | const lbfgsfloatval_t xnorm, 31 | const lbfgsfloatval_t gnorm, 32 | const lbfgsfloatval_t step, 33 | int n, 34 | int k, 35 | int ls 36 | ) 37 | { 38 | printf("Iteration %d:\n", k); 39 | printf(" fx = %f, x[0] = %f, x[1] = %f\n", fx, x[0], x[1]); 40 | printf(" xnorm = %f, gnorm = %f, step = %f\n", xnorm, gnorm, step); 41 | printf("\n"); 42 | return 0; 43 | } 44 | 45 | #define N 100 46 | 47 | int main(int argc, char *argv[]) 48 | { 49 | int i, ret = 0; 50 | lbfgsfloatval_t fx; 51 | lbfgsfloatval_t *x = lbfgs_malloc(N); 52 | lbfgs_parameter_t param; 53 | 54 | if (x == NULL) { 55 | printf("ERROR: Failed to allocate a memory block for variables.\n"); 56 | return 1; 57 | } 58 | 59 | /* Initialize the variables. */ 60 | for (i = 0;i < N;i += 2) { 61 | x[i] = -1.2; 62 | x[i+1] = 1.0; 63 | } 64 | 65 | /* Initialize the parameters for the L-BFGS optimization. */ 66 | lbfgs_parameter_init(¶m); 67 | /*param.linesearch = LBFGS_LINESEARCH_BACKTRACKING;*/ 68 | 69 | /* 70 | Start the L-BFGS optimization; this will invoke the callback functions 71 | evaluate() and progress() when necessary. 72 | */ 73 | ret = lbfgs(N, x, &fx, evaluate, progress, NULL, ¶m); 74 | 75 | /* Report the result. */ 76 | printf("L-BFGS optimization terminated with status code = %d\n", ret); 77 | printf(" fx = %f, x[0] = %f, x[1] = %f\n", fx, x[0], x[1]); 78 | 79 | lbfgs_free(x); 80 | return 0; 81 | } 82 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/external/liblbfgs/sample/sample.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | class objective_function 5 | { 6 | protected: 7 | lbfgsfloatval_t *m_x; 8 | 9 | public: 10 | objective_function() : m_x(NULL) 11 | { 12 | } 13 | 14 | virtual ~objective_function() 15 | { 16 | if (m_x != NULL) { 17 | lbfgs_free(m_x); 18 | m_x = NULL; 19 | } 20 | } 21 | 22 | int run(int N) 23 | { 24 | lbfgsfloatval_t fx; 25 | lbfgsfloatval_t *m_x = lbfgs_malloc(N); 26 | 27 | if (m_x == NULL) { 28 | printf("ERROR: Failed to allocate a memory block for variables.\n"); 29 | return 1; 30 | } 31 | 32 | /* Initialize the variables. */ 33 | for (int i = 0;i < N;i += 2) { 34 | m_x[i] = -1.2; 35 | m_x[i+1] = 1.0; 36 | } 37 | 38 | /* 39 | Start the L-BFGS optimization; this will invoke the callback functions 40 | evaluate() and progress() when necessary. 41 | */ 42 | int ret = lbfgs(N, m_x, &fx, _evaluate, _progress, this, NULL); 43 | 44 | /* Report the result. */ 45 | printf("L-BFGS optimization terminated with status code = %d\n", ret); 46 | printf(" fx = %f, x[0] = %f, x[1] = %f\n", fx, m_x[0], m_x[1]); 47 | 48 | return ret; 49 | } 50 | 51 | protected: 52 | static lbfgsfloatval_t _evaluate( 53 | void *instance, 54 | const lbfgsfloatval_t *x, 55 | lbfgsfloatval_t *g, 56 | const int n, 57 | const lbfgsfloatval_t step 58 | ) 59 | { 60 | return reinterpret_cast(instance)->evaluate(x, g, n, step); 61 | } 62 | 63 | lbfgsfloatval_t evaluate( 64 | const lbfgsfloatval_t *x, 65 | lbfgsfloatval_t *g, 66 | const int n, 67 | const lbfgsfloatval_t step 68 | ) 69 | { 70 | lbfgsfloatval_t fx = 0.0; 71 | 72 | for (int i = 0;i < n;i += 2) { 73 | lbfgsfloatval_t t1 = 1.0 - x[i]; 74 | lbfgsfloatval_t t2 = 10.0 * (x[i+1] - x[i] * x[i]); 75 | g[i+1] = 20.0 * t2; 76 | g[i] = -2.0 * (x[i] * g[i+1] + t1); 77 | fx += t1 * t1 + t2 * t2; 78 | } 79 | return fx; 80 | } 81 | 82 | static int _progress( 83 | void *instance, 84 | const lbfgsfloatval_t *x, 85 | const lbfgsfloatval_t *g, 86 | const lbfgsfloatval_t fx, 87 | const lbfgsfloatval_t xnorm, 88 | const lbfgsfloatval_t gnorm, 89 | const lbfgsfloatval_t step, 90 | int n, 91 | int k, 92 | int ls 93 | ) 94 | { 95 | return reinterpret_cast(instance)->progress(x, g, fx, xnorm, gnorm, step, n, k, ls); 96 | } 97 | 98 | int progress( 99 | const lbfgsfloatval_t *x, 100 | const lbfgsfloatval_t *g, 101 | const lbfgsfloatval_t fx, 102 | const lbfgsfloatval_t xnorm, 103 | const lbfgsfloatval_t gnorm, 104 | const lbfgsfloatval_t step, 105 | int n, 106 | int k, 107 | int ls 108 | ) 109 | { 110 | printf("Iteration %d:\n", k); 111 | printf(" fx = %f, x[0] = %f, x[1] = %f\n", fx, x[0], x[1]); 112 | printf(" xnorm = %f, gnorm = %f, step = %f\n", xnorm, gnorm, step); 113 | printf("\n"); 114 | return 0; 115 | } 116 | }; 117 | 118 | 119 | 120 | #define N 100 121 | 122 | int main(int argc, char *argv) 123 | { 124 | objective_function obj; 125 | return obj.run(N); 126 | } 127 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/Array: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_ARRAY_MODULE_H 2 | #define EIGEN_ARRAY_MODULE_H 3 | 4 | // include Core first to handle Eigen2 support macros 5 | #include "Core" 6 | 7 | #ifndef EIGEN2_SUPPORT 8 | #error The Eigen/Array header does no longer exist in Eigen3. All that functionality has moved to Eigen/Core. 9 | #endif 10 | 11 | #endif // EIGEN_ARRAY_MODULE_H 12 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include(RegexUtils) 2 | test_escape_string_as_regex() 3 | 4 | file(GLOB Eigen_directory_files "*") 5 | 6 | escape_string_as_regex(ESCAPED_CMAKE_CURRENT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") 7 | 8 | foreach(f ${Eigen_directory_files}) 9 | if(NOT f MATCHES "\\.txt" AND NOT f MATCHES "${ESCAPED_CMAKE_CURRENT_SOURCE_DIR}/[.].+" AND NOT f MATCHES "${ESCAPED_CMAKE_CURRENT_SOURCE_DIR}/src") 10 | list(APPEND Eigen_directory_files_to_install ${f}) 11 | endif() 12 | endforeach(f ${Eigen_directory_files}) 13 | 14 | install(FILES 15 | ${Eigen_directory_files_to_install} 16 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen COMPONENT Devel 17 | ) 18 | 19 | add_subdirectory(src) 20 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/Cholesky: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_CHOLESKY_MODULE_H 2 | #define EIGEN_CHOLESKY_MODULE_H 3 | 4 | #include "Core" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | /** \defgroup Cholesky_Module Cholesky module 9 | * 10 | * 11 | * 12 | * This module provides two variants of the Cholesky decomposition for selfadjoint (hermitian) matrices. 13 | * Those decompositions are accessible via the following MatrixBase methods: 14 | * - MatrixBase::llt(), 15 | * - MatrixBase::ldlt() 16 | * 17 | * \code 18 | * #include 19 | * \endcode 20 | */ 21 | 22 | #include "src/misc/Solve.h" 23 | #include "src/Cholesky/LLT.h" 24 | #include "src/Cholesky/LDLT.h" 25 | #ifdef EIGEN_USE_LAPACKE 26 | #include "src/Cholesky/LLT_MKL.h" 27 | #endif 28 | 29 | #include "src/Core/util/ReenableStupidWarnings.h" 30 | 31 | #endif // EIGEN_CHOLESKY_MODULE_H 32 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 33 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/CholmodSupport: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_CHOLMODSUPPORT_MODULE_H 2 | #define EIGEN_CHOLMODSUPPORT_MODULE_H 3 | 4 | #include "SparseCore" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | extern "C" { 9 | #include 10 | } 11 | 12 | /** \ingroup Support_modules 13 | * \defgroup CholmodSupport_Module CholmodSupport module 14 | * 15 | * This module provides an interface to the Cholmod library which is part of the suitesparse package. 16 | * It provides the two following main factorization classes: 17 | * - class CholmodSupernodalLLT: a supernodal LLT Cholesky factorization. 18 | * - class CholmodDecomposiiton: a general L(D)LT Cholesky factorization with automatic or explicit runtime selection of the underlying factorization method (supernodal or simplicial). 19 | * 20 | * For the sake of completeness, this module also propose the two following classes: 21 | * - class CholmodSimplicialLLT 22 | * - class CholmodSimplicialLDLT 23 | * Note that these classes does not bring any particular advantage compared to the built-in 24 | * SimplicialLLT and SimplicialLDLT factorization classes. 25 | * 26 | * \code 27 | * #include 28 | * \endcode 29 | * 30 | * In order to use this module, the cholmod headers must be accessible from the include paths, and your binary must be linked to the cholmod library and its dependencies. 31 | * The dependencies depend on how cholmod has been compiled. 32 | * For a cmake based project, you can use our FindCholmod.cmake module to help you in this task. 33 | * 34 | */ 35 | 36 | #include "src/misc/Solve.h" 37 | #include "src/misc/SparseSolve.h" 38 | 39 | #include "src/CholmodSupport/CholmodSupport.h" 40 | 41 | 42 | #include "src/Core/util/ReenableStupidWarnings.h" 43 | 44 | #endif // EIGEN_CHOLMODSUPPORT_MODULE_H 45 | 46 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/Dense: -------------------------------------------------------------------------------- 1 | #include "Core" 2 | #include "LU" 3 | #include "Cholesky" 4 | #include "QR" 5 | #include "SVD" 6 | #include "Geometry" 7 | #include "Eigenvalues" 8 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/Eigen: -------------------------------------------------------------------------------- 1 | #include "Dense" 2 | //#include "Sparse" 3 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/Eigen2Support: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN2SUPPORT_H 11 | #define EIGEN2SUPPORT_H 12 | 13 | #if (!defined(EIGEN2_SUPPORT)) || (!defined(EIGEN_CORE_H)) 14 | #error Eigen2 support must be enabled by defining EIGEN2_SUPPORT before including any Eigen header 15 | #endif 16 | 17 | #include "src/Core/util/DisableStupidWarnings.h" 18 | 19 | /** \ingroup Support_modules 20 | * \defgroup Eigen2Support_Module Eigen2 support module 21 | * This module provides a couple of deprecated functions improving the compatibility with Eigen2. 22 | * 23 | * To use it, define EIGEN2_SUPPORT before including any Eigen header 24 | * \code 25 | * #define EIGEN2_SUPPORT 26 | * \endcode 27 | * 28 | */ 29 | 30 | #include "src/Eigen2Support/Macros.h" 31 | #include "src/Eigen2Support/Memory.h" 32 | #include "src/Eigen2Support/Meta.h" 33 | #include "src/Eigen2Support/Lazy.h" 34 | #include "src/Eigen2Support/Cwise.h" 35 | #include "src/Eigen2Support/CwiseOperators.h" 36 | #include "src/Eigen2Support/TriangularSolver.h" 37 | #include "src/Eigen2Support/Block.h" 38 | #include "src/Eigen2Support/VectorBlock.h" 39 | #include "src/Eigen2Support/Minor.h" 40 | #include "src/Eigen2Support/MathFunctions.h" 41 | 42 | 43 | #include "src/Core/util/ReenableStupidWarnings.h" 44 | 45 | // Eigen2 used to include iostream 46 | #include 47 | 48 | #define EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, SizeSuffix) \ 49 | using Eigen::Matrix##SizeSuffix##TypeSuffix; \ 50 | using Eigen::Vector##SizeSuffix##TypeSuffix; \ 51 | using Eigen::RowVector##SizeSuffix##TypeSuffix; 52 | 53 | #define EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(TypeSuffix) \ 54 | EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 2) \ 55 | EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 3) \ 56 | EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 4) \ 57 | EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, X) \ 58 | 59 | #define EIGEN_USING_MATRIX_TYPEDEFS \ 60 | EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(i) \ 61 | EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(f) \ 62 | EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(d) \ 63 | EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(cf) \ 64 | EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(cd) 65 | 66 | #define USING_PART_OF_NAMESPACE_EIGEN \ 67 | EIGEN_USING_MATRIX_TYPEDEFS \ 68 | using Eigen::Matrix; \ 69 | using Eigen::MatrixBase; \ 70 | using Eigen::ei_random; \ 71 | using Eigen::ei_real; \ 72 | using Eigen::ei_imag; \ 73 | using Eigen::ei_conj; \ 74 | using Eigen::ei_abs; \ 75 | using Eigen::ei_abs2; \ 76 | using Eigen::ei_sqrt; \ 77 | using Eigen::ei_exp; \ 78 | using Eigen::ei_log; \ 79 | using Eigen::ei_sin; \ 80 | using Eigen::ei_cos; 81 | 82 | #endif // EIGEN2SUPPORT_H 83 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/Eigenvalues: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_EIGENVALUES_MODULE_H 2 | #define EIGEN_EIGENVALUES_MODULE_H 3 | 4 | #include "Core" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | #include "Cholesky" 9 | #include "Jacobi" 10 | #include "Householder" 11 | #include "LU" 12 | #include "Geometry" 13 | 14 | /** \defgroup Eigenvalues_Module Eigenvalues module 15 | * 16 | * 17 | * 18 | * This module mainly provides various eigenvalue solvers. 19 | * This module also provides some MatrixBase methods, including: 20 | * - MatrixBase::eigenvalues(), 21 | * - MatrixBase::operatorNorm() 22 | * 23 | * \code 24 | * #include 25 | * \endcode 26 | */ 27 | 28 | #include "src/Eigenvalues/Tridiagonalization.h" 29 | #include "src/Eigenvalues/RealSchur.h" 30 | #include "src/Eigenvalues/EigenSolver.h" 31 | #include "src/Eigenvalues/SelfAdjointEigenSolver.h" 32 | #include "src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h" 33 | #include "src/Eigenvalues/HessenbergDecomposition.h" 34 | #include "src/Eigenvalues/ComplexSchur.h" 35 | #include "src/Eigenvalues/ComplexEigenSolver.h" 36 | #include "src/Eigenvalues/MatrixBaseEigenvalues.h" 37 | #ifdef EIGEN_USE_LAPACKE 38 | #include "src/Eigenvalues/RealSchur_MKL.h" 39 | #include "src/Eigenvalues/ComplexSchur_MKL.h" 40 | #include "src/Eigenvalues/SelfAdjointEigenSolver_MKL.h" 41 | #endif 42 | 43 | #include "src/Core/util/ReenableStupidWarnings.h" 44 | 45 | #endif // EIGEN_EIGENVALUES_MODULE_H 46 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 47 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/Geometry: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_GEOMETRY_MODULE_H 2 | #define EIGEN_GEOMETRY_MODULE_H 3 | 4 | #include "Core" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | #include "SVD" 9 | #include "LU" 10 | #include 11 | 12 | #ifndef M_PI 13 | #define M_PI 3.14159265358979323846 14 | #endif 15 | 16 | /** \defgroup Geometry_Module Geometry module 17 | * 18 | * 19 | * 20 | * This module provides support for: 21 | * - fixed-size homogeneous transformations 22 | * - translation, scaling, 2D and 3D rotations 23 | * - quaternions 24 | * - \ref MatrixBase::cross() "cross product" 25 | * - \ref MatrixBase::unitOrthogonal() "orthognal vector generation" 26 | * - some linear components: parametrized-lines and hyperplanes 27 | * 28 | * \code 29 | * #include 30 | * \endcode 31 | */ 32 | 33 | #include "src/Geometry/OrthoMethods.h" 34 | #include "src/Geometry/EulerAngles.h" 35 | 36 | #if EIGEN2_SUPPORT_STAGE > STAGE20_RESOLVE_API_CONFLICTS 37 | #include "src/Geometry/Homogeneous.h" 38 | #include "src/Geometry/RotationBase.h" 39 | #include "src/Geometry/Rotation2D.h" 40 | #include "src/Geometry/Quaternion.h" 41 | #include "src/Geometry/AngleAxis.h" 42 | #include "src/Geometry/Transform.h" 43 | #include "src/Geometry/Translation.h" 44 | #include "src/Geometry/Scaling.h" 45 | #include "src/Geometry/Hyperplane.h" 46 | #include "src/Geometry/ParametrizedLine.h" 47 | #include "src/Geometry/AlignedBox.h" 48 | #include "src/Geometry/Umeyama.h" 49 | 50 | #if defined EIGEN_VECTORIZE_SSE 51 | #include "src/Geometry/arch/Geometry_SSE.h" 52 | #endif 53 | #endif 54 | 55 | #ifdef EIGEN2_SUPPORT 56 | #include "src/Eigen2Support/Geometry/All.h" 57 | #endif 58 | 59 | #include "src/Core/util/ReenableStupidWarnings.h" 60 | 61 | #endif // EIGEN_GEOMETRY_MODULE_H 62 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 63 | 64 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/Householder: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_HOUSEHOLDER_MODULE_H 2 | #define EIGEN_HOUSEHOLDER_MODULE_H 3 | 4 | #include "Core" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | /** \defgroup Householder_Module Householder module 9 | * This module provides Householder transformations. 10 | * 11 | * \code 12 | * #include 13 | * \endcode 14 | */ 15 | 16 | #include "src/Householder/Householder.h" 17 | #include "src/Householder/HouseholderSequence.h" 18 | #include "src/Householder/BlockHouseholder.h" 19 | 20 | #include "src/Core/util/ReenableStupidWarnings.h" 21 | 22 | #endif // EIGEN_HOUSEHOLDER_MODULE_H 23 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 24 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/IterativeLinearSolvers: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_ITERATIVELINEARSOLVERS_MODULE_H 2 | #define EIGEN_ITERATIVELINEARSOLVERS_MODULE_H 3 | 4 | #include "SparseCore" 5 | #include "OrderingMethods" 6 | 7 | #include "src/Core/util/DisableStupidWarnings.h" 8 | 9 | /** \ingroup Sparse_modules 10 | * \defgroup IterativeLinearSolvers_Module IterativeLinearSolvers module 11 | * 12 | * This module currently provides iterative methods to solve problems of the form \c A \c x = \c b, where \c A is a squared matrix, usually very large and sparse. 13 | * Those solvers are accessible via the following classes: 14 | * - ConjugateGradient for selfadjoint (hermitian) matrices, 15 | * - BiCGSTAB for general square matrices. 16 | * 17 | * These iterative solvers are associated with some preconditioners: 18 | * - IdentityPreconditioner - not really useful 19 | * - DiagonalPreconditioner - also called JAcobi preconditioner, work very well on diagonal dominant matrices. 20 | * - IncompleteILUT - incomplete LU factorization with dual thresholding 21 | * 22 | * Such problems can also be solved using the direct sparse decomposition modules: SparseCholesky, CholmodSupport, UmfPackSupport, SuperLUSupport. 23 | * 24 | * \code 25 | * #include 26 | * \endcode 27 | */ 28 | 29 | #include "src/misc/Solve.h" 30 | #include "src/misc/SparseSolve.h" 31 | 32 | #include "src/IterativeLinearSolvers/IterativeSolverBase.h" 33 | #include "src/IterativeLinearSolvers/BasicPreconditioners.h" 34 | #include "src/IterativeLinearSolvers/ConjugateGradient.h" 35 | #include "src/IterativeLinearSolvers/BiCGSTAB.h" 36 | #include "src/IterativeLinearSolvers/IncompleteLUT.h" 37 | 38 | #include "src/Core/util/ReenableStupidWarnings.h" 39 | 40 | #endif // EIGEN_ITERATIVELINEARSOLVERS_MODULE_H 41 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/Jacobi: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_JACOBI_MODULE_H 2 | #define EIGEN_JACOBI_MODULE_H 3 | 4 | #include "Core" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | /** \defgroup Jacobi_Module Jacobi module 9 | * This module provides Jacobi and Givens rotations. 10 | * 11 | * \code 12 | * #include 13 | * \endcode 14 | * 15 | * In addition to listed classes, it defines the two following MatrixBase methods to apply a Jacobi or Givens rotation: 16 | * - MatrixBase::applyOnTheLeft() 17 | * - MatrixBase::applyOnTheRight(). 18 | */ 19 | 20 | #include "src/Jacobi/Jacobi.h" 21 | 22 | #include "src/Core/util/ReenableStupidWarnings.h" 23 | 24 | #endif // EIGEN_JACOBI_MODULE_H 25 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 26 | 27 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/LU: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_LU_MODULE_H 2 | #define EIGEN_LU_MODULE_H 3 | 4 | #include "Core" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | /** \defgroup LU_Module LU module 9 | * This module includes %LU decomposition and related notions such as matrix inversion and determinant. 10 | * This module defines the following MatrixBase methods: 11 | * - MatrixBase::inverse() 12 | * - MatrixBase::determinant() 13 | * 14 | * \code 15 | * #include 16 | * \endcode 17 | */ 18 | 19 | #include "src/misc/Solve.h" 20 | #include "src/misc/Kernel.h" 21 | #include "src/misc/Image.h" 22 | #include "src/LU/FullPivLU.h" 23 | #include "src/LU/PartialPivLU.h" 24 | #ifdef EIGEN_USE_LAPACKE 25 | #include "src/LU/PartialPivLU_MKL.h" 26 | #endif 27 | #include "src/LU/Determinant.h" 28 | #include "src/LU/Inverse.h" 29 | 30 | #if defined EIGEN_VECTORIZE_SSE 31 | #include "src/LU/arch/Inverse_SSE.h" 32 | #endif 33 | 34 | #ifdef EIGEN2_SUPPORT 35 | #include "src/Eigen2Support/LU.h" 36 | #endif 37 | 38 | #include "src/Core/util/ReenableStupidWarnings.h" 39 | 40 | #endif // EIGEN_LU_MODULE_H 41 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 42 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/LeastSquares: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_REGRESSION_MODULE_H 2 | #define EIGEN_REGRESSION_MODULE_H 3 | 4 | #ifndef EIGEN2_SUPPORT 5 | #error LeastSquares is only available in Eigen2 support mode (define EIGEN2_SUPPORT) 6 | #endif 7 | 8 | // exclude from normal eigen3-only documentation 9 | #ifdef EIGEN2_SUPPORT 10 | 11 | #include "Core" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | #include "Eigenvalues" 16 | #include "Geometry" 17 | 18 | /** \defgroup LeastSquares_Module LeastSquares module 19 | * This module provides linear regression and related features. 20 | * 21 | * \code 22 | * #include 23 | * \endcode 24 | */ 25 | 26 | #include "src/Eigen2Support/LeastSquares.h" 27 | 28 | #include "src/Core/util/ReenableStupidWarnings.h" 29 | 30 | #endif // EIGEN2_SUPPORT 31 | 32 | #endif // EIGEN_REGRESSION_MODULE_H 33 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/OrderingMethods: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_ORDERINGMETHODS_MODULE_H 2 | #define EIGEN_ORDERINGMETHODS_MODULE_H 3 | 4 | #include "SparseCore" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | /** \ingroup Sparse_modules 9 | * \defgroup OrderingMethods_Module OrderingMethods module 10 | * 11 | * This module is currently for internal use only. 12 | * 13 | * 14 | * \code 15 | * #include 16 | * \endcode 17 | */ 18 | 19 | #include "src/OrderingMethods/Amd.h" 20 | 21 | #include "src/Core/util/ReenableStupidWarnings.h" 22 | 23 | #endif // EIGEN_ORDERINGMETHODS_MODULE_H 24 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/PaStiXSupport: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_PASTIXSUPPORT_MODULE_H 2 | #define EIGEN_PASTIXSUPPORT_MODULE_H 3 | 4 | #include "SparseCore" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | #include 9 | extern "C" { 10 | #include 11 | #include 12 | } 13 | 14 | #ifdef complex 15 | #undef complex 16 | #endif 17 | 18 | /** \ingroup Support_modules 19 | * \defgroup PaStiXSupport_Module PaStiXSupport module 20 | * 21 | * This module provides an interface to the PaSTiX library. 22 | * PaSTiX is a general \b supernodal, \b parallel and \b opensource sparse solver. 23 | * It provides the two following main factorization classes: 24 | * - class PastixLLT : a supernodal, parallel LLt Cholesky factorization. 25 | * - class PastixLDLT: a supernodal, parallel LDLt Cholesky factorization. 26 | * - class PastixLU : a supernodal, parallel LU factorization (optimized for a symmetric pattern). 27 | * 28 | * \code 29 | * #include 30 | * \endcode 31 | * 32 | * In order to use this module, the PaSTiX headers must be accessible from the include paths, and your binary must be linked to the PaSTiX library and its dependencies. 33 | * The dependencies depend on how PaSTiX has been compiled. 34 | * For a cmake based project, you can use our FindPaSTiX.cmake module to help you in this task. 35 | * 36 | */ 37 | 38 | #include "src/misc/Solve.h" 39 | #include "src/misc/SparseSolve.h" 40 | 41 | #include "src/PaStiXSupport/PaStiXSupport.h" 42 | 43 | 44 | #include "src/Core/util/ReenableStupidWarnings.h" 45 | 46 | #endif // EIGEN_PASTIXSUPPORT_MODULE_H 47 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/PardisoSupport: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_PARDISOSUPPORT_MODULE_H 2 | #define EIGEN_PARDISOSUPPORT_MODULE_H 3 | 4 | #include "SparseCore" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | #include 9 | 10 | #include 11 | 12 | /** \ingroup Support_modules 13 | * \defgroup PardisoSupport_Module PardisoSupport module 14 | * 15 | * This module brings support for the Intel(R) MKL PARDISO direct sparse solvers. 16 | * 17 | * \code 18 | * #include 19 | * \endcode 20 | * 21 | * In order to use this module, the MKL headers must be accessible from the include paths, and your binary must be linked to the MKL library and its dependencies. 22 | * See this \ref TopicUsingIntelMKL "page" for more information on MKL-Eigen integration. 23 | * 24 | */ 25 | 26 | #include "src/PardisoSupport/PardisoSupport.h" 27 | 28 | #include "src/Core/util/ReenableStupidWarnings.h" 29 | 30 | #endif // EIGEN_PARDISOSUPPORT_MODULE_H 31 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/QR: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_QR_MODULE_H 2 | #define EIGEN_QR_MODULE_H 3 | 4 | #include "Core" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | #include "Cholesky" 9 | #include "Jacobi" 10 | #include "Householder" 11 | 12 | /** \defgroup QR_Module QR module 13 | * 14 | * 15 | * 16 | * This module provides various QR decompositions 17 | * This module also provides some MatrixBase methods, including: 18 | * - MatrixBase::qr(), 19 | * 20 | * \code 21 | * #include 22 | * \endcode 23 | */ 24 | 25 | #include "src/misc/Solve.h" 26 | #include "src/QR/HouseholderQR.h" 27 | #include "src/QR/FullPivHouseholderQR.h" 28 | #include "src/QR/ColPivHouseholderQR.h" 29 | #ifdef EIGEN_USE_LAPACKE 30 | #include "src/QR/HouseholderQR_MKL.h" 31 | #include "src/QR/ColPivHouseholderQR_MKL.h" 32 | #endif 33 | 34 | #ifdef EIGEN2_SUPPORT 35 | #include "src/Eigen2Support/QR.h" 36 | #endif 37 | 38 | #include "src/Core/util/ReenableStupidWarnings.h" 39 | 40 | #ifdef EIGEN2_SUPPORT 41 | #include "Eigenvalues" 42 | #endif 43 | 44 | #endif // EIGEN_QR_MODULE_H 45 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 46 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/QtAlignedMalloc: -------------------------------------------------------------------------------- 1 | 2 | #ifndef EIGEN_QTMALLOC_MODULE_H 3 | #define EIGEN_QTMALLOC_MODULE_H 4 | 5 | #include "Core" 6 | 7 | #if (!EIGEN_MALLOC_ALREADY_ALIGNED) 8 | 9 | #include "src/Core/util/DisableStupidWarnings.h" 10 | 11 | void *qMalloc(size_t size) 12 | { 13 | return Eigen::internal::aligned_malloc(size); 14 | } 15 | 16 | void qFree(void *ptr) 17 | { 18 | Eigen::internal::aligned_free(ptr); 19 | } 20 | 21 | void *qRealloc(void *ptr, size_t size) 22 | { 23 | void* newPtr = Eigen::internal::aligned_malloc(size); 24 | memcpy(newPtr, ptr, size); 25 | Eigen::internal::aligned_free(ptr); 26 | return newPtr; 27 | } 28 | 29 | #include "src/Core/util/ReenableStupidWarnings.h" 30 | 31 | #endif 32 | 33 | #endif // EIGEN_QTMALLOC_MODULE_H 34 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 35 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/SVD: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_SVD_MODULE_H 2 | #define EIGEN_SVD_MODULE_H 3 | 4 | #include "QR" 5 | #include "Householder" 6 | #include "Jacobi" 7 | 8 | #include "src/Core/util/DisableStupidWarnings.h" 9 | 10 | /** \defgroup SVD_Module SVD module 11 | * 12 | * 13 | * 14 | * This module provides SVD decomposition for matrices (both real and complex). 15 | * This decomposition is accessible via the following MatrixBase method: 16 | * - MatrixBase::jacobiSvd() 17 | * 18 | * \code 19 | * #include 20 | * \endcode 21 | */ 22 | 23 | #include "src/misc/Solve.h" 24 | #include "src/SVD/JacobiSVD.h" 25 | #if defined(EIGEN_USE_LAPACKE) && !defined(EIGEN_USE_LAPACKE_STRICT) 26 | #include "src/SVD/JacobiSVD_MKL.h" 27 | #endif 28 | #include "src/SVD/UpperBidiagonalization.h" 29 | 30 | #ifdef EIGEN2_SUPPORT 31 | #include "src/Eigen2Support/SVD.h" 32 | #endif 33 | 34 | #include "src/Core/util/ReenableStupidWarnings.h" 35 | 36 | #endif // EIGEN_SVD_MODULE_H 37 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 38 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/Sparse: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_SPARSE_MODULE_H 2 | #define EIGEN_SPARSE_MODULE_H 3 | 4 | /** \defgroup Sparse_modules Sparse modules 5 | * 6 | * Meta-module including all related modules: 7 | * - SparseCore 8 | * - OrderingMethods 9 | * - SparseCholesky 10 | * - IterativeLinearSolvers 11 | * 12 | * \code 13 | * #include 14 | * \endcode 15 | */ 16 | 17 | #include "SparseCore" 18 | #include "OrderingMethods" 19 | #include "SparseCholesky" 20 | #include "IterativeLinearSolvers" 21 | 22 | #endif // EIGEN_SPARSE_MODULE_H 23 | 24 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/SparseCholesky: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_SPARSECHOLESKY_MODULE_H 2 | #define EIGEN_SPARSECHOLESKY_MODULE_H 3 | 4 | #include "SparseCore" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | /** \ingroup Sparse_modules 9 | * \defgroup SparseCholesky_Module SparseCholesky module 10 | * 11 | * This module currently provides two variants of the direct sparse Cholesky decomposition for selfadjoint (hermitian) matrices. 12 | * Those decompositions are accessible via the following classes: 13 | * - SimplicialLLt, 14 | * - SimplicialLDLt 15 | * 16 | * Such problems can also be solved using the ConjugateGradient solver from the IterativeLinearSolvers module. 17 | * 18 | * \code 19 | * #include 20 | * \endcode 21 | */ 22 | 23 | #include "src/misc/Solve.h" 24 | #include "src/misc/SparseSolve.h" 25 | 26 | #include "src/SparseCholesky/SimplicialCholesky.h" 27 | 28 | #include "src/Core/util/ReenableStupidWarnings.h" 29 | 30 | #endif // EIGEN_SPARSECHOLESKY_MODULE_H 31 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/SparseCore: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_SPARSECORE_MODULE_H 2 | #define EIGEN_SPARSECORE_MODULE_H 3 | 4 | #include "Core" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | /** \ingroup Sparse_modules 15 | * \defgroup SparseCore_Module SparseCore module 16 | * 17 | * This module provides a sparse matrix representation, and basic associatd matrix manipulations 18 | * and operations. 19 | * 20 | * See the \ref TutorialSparse "Sparse tutorial" 21 | * 22 | * \code 23 | * #include 24 | * \endcode 25 | * 26 | * This module depends on: Core. 27 | */ 28 | 29 | namespace Eigen { 30 | 31 | /** The type used to identify a general sparse storage. */ 32 | struct Sparse {}; 33 | 34 | } 35 | 36 | #include "src/SparseCore/SparseUtil.h" 37 | #include "src/SparseCore/SparseMatrixBase.h" 38 | #include "src/SparseCore/CompressedStorage.h" 39 | #include "src/SparseCore/AmbiVector.h" 40 | #include "src/SparseCore/SparseMatrix.h" 41 | #include "src/SparseCore/MappedSparseMatrix.h" 42 | #include "src/SparseCore/SparseVector.h" 43 | #include "src/SparseCore/CoreIterators.h" 44 | #include "src/SparseCore/SparseBlock.h" 45 | #include "src/SparseCore/SparseTranspose.h" 46 | #include "src/SparseCore/SparseCwiseUnaryOp.h" 47 | #include "src/SparseCore/SparseCwiseBinaryOp.h" 48 | #include "src/SparseCore/SparseDot.h" 49 | #include "src/SparseCore/SparsePermutation.h" 50 | #include "src/SparseCore/SparseAssign.h" 51 | #include "src/SparseCore/SparseRedux.h" 52 | #include "src/SparseCore/SparseFuzzy.h" 53 | #include "src/SparseCore/ConservativeSparseSparseProduct.h" 54 | #include "src/SparseCore/SparseSparseProductWithPruning.h" 55 | #include "src/SparseCore/SparseProduct.h" 56 | #include "src/SparseCore/SparseDenseProduct.h" 57 | #include "src/SparseCore/SparseDiagonalProduct.h" 58 | #include "src/SparseCore/SparseTriangularView.h" 59 | #include "src/SparseCore/SparseSelfAdjointView.h" 60 | #include "src/SparseCore/TriangularSolver.h" 61 | #include "src/SparseCore/SparseView.h" 62 | 63 | #include "src/Core/util/ReenableStupidWarnings.h" 64 | 65 | #endif // EIGEN_SPARSECORE_MODULE_H 66 | 67 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/StdDeque: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Gael Guennebaud 5 | // Copyright (C) 2009 Hauke Heibel 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_STDDEQUE_MODULE_H 12 | #define EIGEN_STDDEQUE_MODULE_H 13 | 14 | #include "Core" 15 | #include 16 | 17 | #if (defined(_MSC_VER) && defined(_WIN64)) /* MSVC auto aligns in 64 bit builds */ 18 | 19 | #define EIGEN_DEFINE_STL_DEQUE_SPECIALIZATION(...) 20 | 21 | #else 22 | 23 | #include "src/StlSupport/StdDeque.h" 24 | 25 | #endif 26 | 27 | #endif // EIGEN_STDDEQUE_MODULE_H 28 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/StdList: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Hauke Heibel 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_STDLIST_MODULE_H 11 | #define EIGEN_STDLIST_MODULE_H 12 | 13 | #include "Core" 14 | #include 15 | 16 | #if (defined(_MSC_VER) && defined(_WIN64)) /* MSVC auto aligns in 64 bit builds */ 17 | 18 | #define EIGEN_DEFINE_STL_LIST_SPECIALIZATION(...) 19 | 20 | #else 21 | 22 | #include "src/StlSupport/StdList.h" 23 | 24 | #endif 25 | 26 | #endif // EIGEN_STDLIST_MODULE_H 27 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/StdVector: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Gael Guennebaud 5 | // Copyright (C) 2009 Hauke Heibel 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_STDVECTOR_MODULE_H 12 | #define EIGEN_STDVECTOR_MODULE_H 13 | 14 | #include "Core" 15 | #include 16 | 17 | #if (defined(_MSC_VER) && defined(_WIN64)) /* MSVC auto aligns in 64 bit builds */ 18 | 19 | #define EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(...) 20 | 21 | #else 22 | 23 | #include "src/StlSupport/StdVector.h" 24 | 25 | #endif 26 | 27 | #endif // EIGEN_STDVECTOR_MODULE_H 28 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/SuperLUSupport: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_SUPERLUSUPPORT_MODULE_H 2 | #define EIGEN_SUPERLUSUPPORT_MODULE_H 3 | 4 | #include "SparseCore" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | #ifdef EMPTY 9 | #define EIGEN_EMPTY_WAS_ALREADY_DEFINED 10 | #endif 11 | 12 | typedef int int_t; 13 | #include 14 | #include 15 | #include 16 | 17 | // slu_util.h defines a preprocessor token named EMPTY which is really polluting, 18 | // so we remove it in favor of a SUPERLU_EMPTY token. 19 | // If EMPTY was already defined then we don't undef it. 20 | 21 | #if defined(EIGEN_EMPTY_WAS_ALREADY_DEFINED) 22 | # undef EIGEN_EMPTY_WAS_ALREADY_DEFINED 23 | #elif defined(EMPTY) 24 | # undef EMPTY 25 | #endif 26 | 27 | #define SUPERLU_EMPTY (-1) 28 | 29 | namespace Eigen { struct SluMatrix; } 30 | 31 | /** \ingroup Support_modules 32 | * \defgroup SuperLUSupport_Module SuperLUSupport module 33 | * 34 | * This module provides an interface to the SuperLU library. 35 | * It provides the following factorization class: 36 | * - class SuperLU: a supernodal sequential LU factorization. 37 | * - class SuperILU: a supernodal sequential incomplete LU factorization (to be used as a preconditioner for iterative methods). 38 | * 39 | * \warning When including this module, you have to use SUPERLU_EMPTY instead of EMPTY which is no longer defined because it is too polluting. 40 | * 41 | * \code 42 | * #include 43 | * \endcode 44 | * 45 | * In order to use this module, the superlu headers must be accessible from the include paths, and your binary must be linked to the superlu library and its dependencies. 46 | * The dependencies depend on how superlu has been compiled. 47 | * For a cmake based project, you can use our FindSuperLU.cmake module to help you in this task. 48 | * 49 | */ 50 | 51 | #include "src/misc/Solve.h" 52 | #include "src/misc/SparseSolve.h" 53 | 54 | #include "src/SuperLUSupport/SuperLUSupport.h" 55 | 56 | 57 | #include "src/Core/util/ReenableStupidWarnings.h" 58 | 59 | #endif // EIGEN_SUPERLUSUPPORT_MODULE_H 60 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/UmfPackSupport: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_UMFPACKSUPPORT_MODULE_H 2 | #define EIGEN_UMFPACKSUPPORT_MODULE_H 3 | 4 | #include "SparseCore" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | extern "C" { 9 | #include 10 | } 11 | 12 | /** \ingroup Support_modules 13 | * \defgroup UmfPackSupport_Module UmfPackSupport module 14 | * 15 | * This module provides an interface to the UmfPack library which is part of the suitesparse package. 16 | * It provides the following factorization class: 17 | * - class UmfPackLU: a multifrontal sequential LU factorization. 18 | * 19 | * \code 20 | * #include 21 | * \endcode 22 | * 23 | * In order to use this module, the umfpack headers must be accessible from the include paths, and your binary must be linked to the umfpack library and its dependencies. 24 | * The dependencies depend on how umfpack has been compiled. 25 | * For a cmake based project, you can use our FindUmfPack.cmake module to help you in this task. 26 | * 27 | */ 28 | 29 | #include "src/misc/Solve.h" 30 | #include "src/misc/SparseSolve.h" 31 | 32 | #include "src/UmfPackSupport/UmfPackSupport.h" 33 | 34 | #include "src/Core/util/ReenableStupidWarnings.h" 35 | 36 | #endif // EIGEN_UMFPACKSUPPORT_MODULE_H 37 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB Eigen_src_subdirectories "*") 2 | escape_string_as_regex(ESCAPED_CMAKE_CURRENT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") 3 | foreach(f ${Eigen_src_subdirectories}) 4 | if(NOT f MATCHES "\\.txt" AND NOT f MATCHES "${ESCAPED_CMAKE_CURRENT_SOURCE_DIR}/[.].+" ) 5 | add_subdirectory(${f}) 6 | endif() 7 | endforeach() 8 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/Cholesky/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Cholesky_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Cholesky_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Cholesky COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/CholmodSupport/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_CholmodSupport_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_CholmodSupport_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/CholmodSupport COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/Core/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Core_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Core_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Core COMPONENT Devel 6 | ) 7 | 8 | ADD_SUBDIRECTORY(products) 9 | ADD_SUBDIRECTORY(util) 10 | ADD_SUBDIRECTORY(arch) 11 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/Core/NestByValue.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008 Gael Guennebaud 5 | // Copyright (C) 2006-2008 Benoit Jacob 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_NESTBYVALUE_H 12 | #define EIGEN_NESTBYVALUE_H 13 | 14 | namespace Eigen { 15 | 16 | /** \class NestByValue 17 | * \ingroup Core_Module 18 | * 19 | * \brief Expression which must be nested by value 20 | * 21 | * \param ExpressionType the type of the object of which we are requiring nesting-by-value 22 | * 23 | * This class is the return type of MatrixBase::nestByValue() 24 | * and most of the time this is the only way it is used. 25 | * 26 | * \sa MatrixBase::nestByValue() 27 | */ 28 | 29 | namespace internal { 30 | template 31 | struct traits > : public traits 32 | {}; 33 | } 34 | 35 | template class NestByValue 36 | : public internal::dense_xpr_base< NestByValue >::type 37 | { 38 | public: 39 | 40 | typedef typename internal::dense_xpr_base::type Base; 41 | EIGEN_DENSE_PUBLIC_INTERFACE(NestByValue) 42 | 43 | inline NestByValue(const ExpressionType& matrix) : m_expression(matrix) {} 44 | 45 | inline Index rows() const { return m_expression.rows(); } 46 | inline Index cols() const { return m_expression.cols(); } 47 | inline Index outerStride() const { return m_expression.outerStride(); } 48 | inline Index innerStride() const { return m_expression.innerStride(); } 49 | 50 | inline const CoeffReturnType coeff(Index row, Index col) const 51 | { 52 | return m_expression.coeff(row, col); 53 | } 54 | 55 | inline Scalar& coeffRef(Index row, Index col) 56 | { 57 | return m_expression.const_cast_derived().coeffRef(row, col); 58 | } 59 | 60 | inline const CoeffReturnType coeff(Index index) const 61 | { 62 | return m_expression.coeff(index); 63 | } 64 | 65 | inline Scalar& coeffRef(Index index) 66 | { 67 | return m_expression.const_cast_derived().coeffRef(index); 68 | } 69 | 70 | template 71 | inline const PacketScalar packet(Index row, Index col) const 72 | { 73 | return m_expression.template packet(row, col); 74 | } 75 | 76 | template 77 | inline void writePacket(Index row, Index col, const PacketScalar& x) 78 | { 79 | m_expression.const_cast_derived().template writePacket(row, col, x); 80 | } 81 | 82 | template 83 | inline const PacketScalar packet(Index index) const 84 | { 85 | return m_expression.template packet(index); 86 | } 87 | 88 | template 89 | inline void writePacket(Index index, const PacketScalar& x) 90 | { 91 | m_expression.const_cast_derived().template writePacket(index, x); 92 | } 93 | 94 | operator const ExpressionType&() const { return m_expression; } 95 | 96 | protected: 97 | const ExpressionType m_expression; 98 | }; 99 | 100 | /** \returns an expression of the temporary version of *this. 101 | */ 102 | template 103 | inline const NestByValue 104 | DenseBase::nestByValue() const 105 | { 106 | return NestByValue(derived()); 107 | } 108 | 109 | } // end namespace Eigen 110 | 111 | #endif // EIGEN_NESTBYVALUE_H 112 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/Core/Product.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2011 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla Public 7 | // License, v. 2.0. If a copy of the MPL was not distributed with this 8 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_PRODUCT_H 11 | #define EIGEN_PRODUCT_H 12 | 13 | template class Product; 14 | template class ProductImpl; 15 | 16 | /** \class Product 17 | * \ingroup Core_Module 18 | * 19 | * \brief Expression of the product of two arbitrary matrices or vectors 20 | * 21 | * \param Lhs the type of the left-hand side expression 22 | * \param Rhs the type of the right-hand side expression 23 | * 24 | * This class represents an expression of the product of two arbitrary matrices. 25 | * 26 | */ 27 | 28 | namespace internal { 29 | template 30 | struct traits > 31 | { 32 | typedef MatrixXpr XprKind; 33 | typedef typename remove_all::type LhsCleaned; 34 | typedef typename remove_all::type RhsCleaned; 35 | typedef typename scalar_product_traits::Scalar, typename traits::Scalar>::ReturnType Scalar; 36 | typedef typename promote_storage_type::StorageKind, 37 | typename traits::StorageKind>::ret StorageKind; 38 | typedef typename promote_index_type::Index, 39 | typename traits::Index>::type Index; 40 | enum { 41 | RowsAtCompileTime = LhsCleaned::RowsAtCompileTime, 42 | ColsAtCompileTime = RhsCleaned::ColsAtCompileTime, 43 | MaxRowsAtCompileTime = LhsCleaned::MaxRowsAtCompileTime, 44 | MaxColsAtCompileTime = RhsCleaned::MaxColsAtCompileTime, 45 | Flags = (MaxRowsAtCompileTime==1 ? RowMajorBit : 0), // TODO should be no storage order 46 | CoeffReadCost = 0 // TODO CoeffReadCost should not be part of the expression traits 47 | }; 48 | }; 49 | } // end namespace internal 50 | 51 | 52 | template 53 | class Product : public ProductImpl::StorageKind, 54 | typename internal::traits::StorageKind>::ret> 55 | { 56 | public: 57 | 58 | typedef typename ProductImpl< 59 | Lhs, Rhs, 60 | typename internal::promote_storage_type::ret>::Base Base; 62 | EIGEN_GENERIC_PUBLIC_INTERFACE(Product) 63 | 64 | typedef typename Lhs::Nested LhsNested; 65 | typedef typename Rhs::Nested RhsNested; 66 | typedef typename internal::remove_all::type LhsNestedCleaned; 67 | typedef typename internal::remove_all::type RhsNestedCleaned; 68 | 69 | Product(const Lhs& lhs, const Rhs& rhs) : m_lhs(lhs), m_rhs(rhs) 70 | { 71 | eigen_assert(lhs.cols() == rhs.rows() 72 | && "invalid matrix product" 73 | && "if you wanted a coeff-wise or a dot product use the respective explicit functions"); 74 | } 75 | 76 | inline Index rows() const { return m_lhs.rows(); } 77 | inline Index cols() const { return m_rhs.cols(); } 78 | 79 | const LhsNestedCleaned& lhs() const { return m_lhs; } 80 | const RhsNestedCleaned& rhs() const { return m_rhs; } 81 | 82 | protected: 83 | 84 | const LhsNested m_lhs; 85 | const RhsNested m_rhs; 86 | }; 87 | 88 | template 89 | class ProductImpl : public internal::dense_xpr_base >::type 90 | { 91 | typedef Product Derived; 92 | public: 93 | 94 | typedef typename internal::dense_xpr_base >::type Base; 95 | EIGEN_DENSE_PUBLIC_INTERFACE(Derived) 96 | }; 97 | 98 | #endif // EIGEN_PRODUCT_H 99 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/Core/ReturnByValue.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009-2010 Gael Guennebaud 5 | // Copyright (C) 2009-2010 Benoit Jacob 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_RETURNBYVALUE_H 12 | #define EIGEN_RETURNBYVALUE_H 13 | 14 | namespace Eigen { 15 | 16 | /** \class ReturnByValue 17 | * \ingroup Core_Module 18 | * 19 | */ 20 | 21 | namespace internal { 22 | 23 | template 24 | struct traits > 25 | : public traits::ReturnType> 26 | { 27 | enum { 28 | // We're disabling the DirectAccess because e.g. the constructor of 29 | // the Block-with-DirectAccess expression requires to have a coeffRef method. 30 | // Also, we don't want to have to implement the stride stuff. 31 | Flags = (traits::ReturnType>::Flags 32 | | EvalBeforeNestingBit) & ~DirectAccessBit 33 | }; 34 | }; 35 | 36 | /* The ReturnByValue object doesn't even have a coeff() method. 37 | * So the only way that nesting it in an expression can work, is by evaluating it into a plain matrix. 38 | * So internal::nested always gives the plain return matrix type. 39 | * 40 | * FIXME: I don't understand why we need this specialization: isn't this taken care of by the EvalBeforeNestingBit ?? 41 | */ 42 | template 43 | struct nested, n, PlainObject> 44 | { 45 | typedef typename traits::ReturnType type; 46 | }; 47 | 48 | } // end namespace internal 49 | 50 | template class ReturnByValue 51 | : public internal::dense_xpr_base< ReturnByValue >::type 52 | { 53 | public: 54 | typedef typename internal::traits::ReturnType ReturnType; 55 | 56 | typedef typename internal::dense_xpr_base::type Base; 57 | EIGEN_DENSE_PUBLIC_INTERFACE(ReturnByValue) 58 | 59 | template 60 | inline void evalTo(Dest& dst) const 61 | { static_cast(this)->evalTo(dst); } 62 | inline Index rows() const { return static_cast(this)->rows(); } 63 | inline Index cols() const { return static_cast(this)->cols(); } 64 | 65 | #ifndef EIGEN_PARSED_BY_DOXYGEN 66 | #define Unusable YOU_ARE_TRYING_TO_ACCESS_A_SINGLE_COEFFICIENT_IN_A_SPECIAL_EXPRESSION_WHERE_THAT_IS_NOT_ALLOWED_BECAUSE_THAT_WOULD_BE_INEFFICIENT 67 | class Unusable{ 68 | Unusable(const Unusable&) {} 69 | Unusable& operator=(const Unusable&) {return *this;} 70 | }; 71 | const Unusable& coeff(Index) const { return *reinterpret_cast(this); } 72 | const Unusable& coeff(Index,Index) const { return *reinterpret_cast(this); } 73 | Unusable& coeffRef(Index) { return *reinterpret_cast(this); } 74 | Unusable& coeffRef(Index,Index) { return *reinterpret_cast(this); } 75 | #endif 76 | }; 77 | 78 | template 79 | template 80 | Derived& DenseBase::operator=(const ReturnByValue& other) 81 | { 82 | other.evalTo(derived()); 83 | return derived(); 84 | } 85 | 86 | } // end namespace Eigen 87 | 88 | #endif // EIGEN_RETURNBYVALUE_H 89 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/Core/Stride.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2010 Benoit Jacob 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_STRIDE_H 11 | #define EIGEN_STRIDE_H 12 | 13 | namespace Eigen { 14 | 15 | /** \class Stride 16 | * \ingroup Core_Module 17 | * 18 | * \brief Holds strides information for Map 19 | * 20 | * This class holds the strides information for mapping arrays with strides with class Map. 21 | * 22 | * It holds two values: the inner stride and the outer stride. 23 | * 24 | * The inner stride is the pointer increment between two consecutive entries within a given row of a 25 | * row-major matrix or within a given column of a column-major matrix. 26 | * 27 | * The outer stride is the pointer increment between two consecutive rows of a row-major matrix or 28 | * between two consecutive columns of a column-major matrix. 29 | * 30 | * These two values can be passed either at compile-time as template parameters, or at runtime as 31 | * arguments to the constructor. 32 | * 33 | * Indeed, this class takes two template parameters: 34 | * \param _OuterStrideAtCompileTime the outer stride, or Dynamic if you want to specify it at runtime. 35 | * \param _InnerStrideAtCompileTime the inner stride, or Dynamic if you want to specify it at runtime. 36 | * 37 | * Here is an example: 38 | * \include Map_general_stride.cpp 39 | * Output: \verbinclude Map_general_stride.out 40 | * 41 | * \sa class InnerStride, class OuterStride, \ref TopicStorageOrders 42 | */ 43 | template 44 | class Stride 45 | { 46 | public: 47 | typedef DenseIndex Index; 48 | enum { 49 | InnerStrideAtCompileTime = _InnerStrideAtCompileTime, 50 | OuterStrideAtCompileTime = _OuterStrideAtCompileTime 51 | }; 52 | 53 | /** Default constructor, for use when strides are fixed at compile time */ 54 | Stride() 55 | : m_outer(OuterStrideAtCompileTime), m_inner(InnerStrideAtCompileTime) 56 | { 57 | eigen_assert(InnerStrideAtCompileTime != Dynamic && OuterStrideAtCompileTime != Dynamic); 58 | } 59 | 60 | /** Constructor allowing to pass the strides at runtime */ 61 | Stride(Index outerStride, Index innerStride) 62 | : m_outer(outerStride), m_inner(innerStride) 63 | { 64 | eigen_assert(innerStride>=0 && outerStride>=0); 65 | } 66 | 67 | /** Copy constructor */ 68 | Stride(const Stride& other) 69 | : m_outer(other.outer()), m_inner(other.inner()) 70 | {} 71 | 72 | /** \returns the outer stride */ 73 | inline Index outer() const { return m_outer.value(); } 74 | /** \returns the inner stride */ 75 | inline Index inner() const { return m_inner.value(); } 76 | 77 | protected: 78 | internal::variable_if_dynamic m_outer; 79 | internal::variable_if_dynamic m_inner; 80 | }; 81 | 82 | /** \brief Convenience specialization of Stride to specify only an inner stride 83 | * See class Map for some examples */ 84 | template 85 | class InnerStride : public Stride<0, Value> 86 | { 87 | typedef Stride<0, Value> Base; 88 | public: 89 | typedef DenseIndex Index; 90 | InnerStride() : Base() {} 91 | InnerStride(Index v) : Base(0, v) {} 92 | }; 93 | 94 | /** \brief Convenience specialization of Stride to specify only an outer stride 95 | * See class Map for some examples */ 96 | template 97 | class OuterStride : public Stride 98 | { 99 | typedef Stride Base; 100 | public: 101 | typedef DenseIndex Index; 102 | OuterStride() : Base() {} 103 | OuterStride(Index v) : Base(v,0) {} 104 | }; 105 | 106 | } // end namespace Eigen 107 | 108 | #endif // EIGEN_STRIDE_H 109 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/Core/arch/AltiVec/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Core_arch_AltiVec_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Core_arch_AltiVec_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Core/arch/AltiVec COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/Core/arch/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ADD_SUBDIRECTORY(SSE) 2 | ADD_SUBDIRECTORY(AltiVec) 3 | ADD_SUBDIRECTORY(NEON) 4 | ADD_SUBDIRECTORY(Default) 5 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/Core/arch/Default/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Core_arch_Default_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Core_arch_Default_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Core/arch/Default COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/Core/arch/Default/Settings.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2010 Gael Guennebaud 5 | // Copyright (C) 2006-2008 Benoit Jacob 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | 12 | /* All the parameters defined in this file can be specialized in the 13 | * architecture specific files, and/or by the user. 14 | * More to come... */ 15 | 16 | #ifndef EIGEN_DEFAULT_SETTINGS_H 17 | #define EIGEN_DEFAULT_SETTINGS_H 18 | 19 | /** Defines the maximal loop size to enable meta unrolling of loops. 20 | * Note that the value here is expressed in Eigen's own notion of "number of FLOPS", 21 | * it does not correspond to the number of iterations or the number of instructions 22 | */ 23 | #ifndef EIGEN_UNROLLING_LIMIT 24 | #define EIGEN_UNROLLING_LIMIT 100 25 | #endif 26 | 27 | /** Defines the threshold between a "small" and a "large" matrix. 28 | * This threshold is mainly used to select the proper product implementation. 29 | */ 30 | #ifndef EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD 31 | #define EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD 8 32 | #endif 33 | 34 | /** Defines the maximal width of the blocks used in the triangular product and solver 35 | * for vectors (level 2 blas xTRMV and xTRSV). The default is 8. 36 | */ 37 | #ifndef EIGEN_TUNE_TRIANGULAR_PANEL_WIDTH 38 | #define EIGEN_TUNE_TRIANGULAR_PANEL_WIDTH 8 39 | #endif 40 | 41 | 42 | /** Defines the default number of registers available for that architecture. 43 | * Currently it must be 8 or 16. Other values will fail. 44 | */ 45 | #ifndef EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS 46 | #define EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS 8 47 | #endif 48 | 49 | #endif // EIGEN_DEFAULT_SETTINGS_H 50 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/Core/arch/NEON/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Core_arch_NEON_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Core_arch_NEON_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Core/arch/NEON COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/Core/arch/SSE/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Core_arch_SSE_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Core_arch_SSE_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Core/arch/SSE COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/Core/products/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Core_Product_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Core_Product_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Core/products COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/Core/util/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Core_util_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Core_util_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Core/util COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/Core/util/DisableStupidWarnings.h: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_WARNINGS_DISABLED 2 | #define EIGEN_WARNINGS_DISABLED 3 | 4 | #ifdef _MSC_VER 5 | // 4100 - unreferenced formal parameter (occurred e.g. in aligned_allocator::destroy(pointer p)) 6 | // 4101 - unreferenced local variable 7 | // 4127 - conditional expression is constant 8 | // 4181 - qualifier applied to reference type ignored 9 | // 4211 - nonstandard extension used : redefined extern to static 10 | // 4244 - 'argument' : conversion from 'type1' to 'type2', possible loss of data 11 | // 4273 - QtAlignedMalloc, inconsistent DLL linkage 12 | // 4324 - structure was padded due to declspec(align()) 13 | // 4512 - assignment operator could not be generated 14 | // 4522 - 'class' : multiple assignment operators specified 15 | // 4700 - uninitialized local variable 'xyz' used 16 | // 4717 - 'function' : recursive on all control paths, function will cause runtime stack overflow 17 | #ifndef EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS 18 | #pragma warning( push ) 19 | #endif 20 | #pragma warning( disable : 4100 4101 4127 4181 4211 4244 4273 4324 4512 4522 4700 4717 ) 21 | #elif defined __INTEL_COMPILER 22 | // 2196 - routine is both "inline" and "noinline" ("noinline" assumed) 23 | // ICC 12 generates this warning even without any inline keyword, when defining class methods 'inline' i.e. inside of class body 24 | // typedef that may be a reference type. 25 | // 279 - controlling expression is constant 26 | // ICC 12 generates this warning on assert(constant_expression_depending_on_template_params) and frankly this is a legitimate use case. 27 | #ifndef EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS 28 | #pragma warning push 29 | #endif 30 | #pragma warning disable 2196 279 31 | #elif defined __clang__ 32 | // -Wconstant-logical-operand - warning: use of logical && with constant operand; switch to bitwise & or remove constant 33 | // this is really a stupid warning as it warns on compile-time expressions involving enums 34 | #ifndef EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS 35 | #pragma clang diagnostic push 36 | #endif 37 | #pragma clang diagnostic ignored "-Wconstant-logical-operand" 38 | #endif 39 | 40 | #endif // not EIGEN_WARNINGS_DISABLED 41 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/Core/util/NonMPL2.h: -------------------------------------------------------------------------------- 1 | #ifdef EIGEN_MPL2_ONLY 2 | #error Including non-MPL2 code in EIGEN_MPL2_ONLY mode 3 | #endif 4 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/Core/util/ReenableStupidWarnings.h: -------------------------------------------------------------------------------- 1 | #ifdef EIGEN_WARNINGS_DISABLED 2 | #undef EIGEN_WARNINGS_DISABLED 3 | 4 | #ifndef EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS 5 | #ifdef _MSC_VER 6 | #pragma warning( pop ) 7 | #elif defined __INTEL_COMPILER 8 | #pragma warning pop 9 | #elif defined __clang__ 10 | #pragma clang diagnostic pop 11 | #endif 12 | #endif 13 | 14 | #endif // EIGEN_WARNINGS_DISABLED 15 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/Eigen2Support/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Eigen2Support_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Eigen2Support_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Eigen2Support COMPONENT Devel 6 | ) 7 | 8 | ADD_SUBDIRECTORY(Geometry) -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/Eigen2Support/Geometry/All.h: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN2_GEOMETRY_MODULE_H 2 | #define EIGEN2_GEOMETRY_MODULE_H 3 | 4 | #include 5 | 6 | #ifndef M_PI 7 | #define M_PI 3.14159265358979323846 8 | #endif 9 | 10 | #if EIGEN2_SUPPORT_STAGE < STAGE20_RESOLVE_API_CONFLICTS 11 | #include "RotationBase.h" 12 | #include "Rotation2D.h" 13 | #include "Quaternion.h" 14 | #include "AngleAxis.h" 15 | #include "Transform.h" 16 | #include "Translation.h" 17 | #include "Scaling.h" 18 | #include "AlignedBox.h" 19 | #include "Hyperplane.h" 20 | #include "ParametrizedLine.h" 21 | #endif 22 | 23 | 24 | #define RotationBase eigen2_RotationBase 25 | #define Rotation2D eigen2_Rotation2D 26 | #define Rotation2Df eigen2_Rotation2Df 27 | #define Rotation2Dd eigen2_Rotation2Dd 28 | 29 | #define Quaternion eigen2_Quaternion 30 | #define Quaternionf eigen2_Quaternionf 31 | #define Quaterniond eigen2_Quaterniond 32 | 33 | #define AngleAxis eigen2_AngleAxis 34 | #define AngleAxisf eigen2_AngleAxisf 35 | #define AngleAxisd eigen2_AngleAxisd 36 | 37 | #define Transform eigen2_Transform 38 | #define Transform2f eigen2_Transform2f 39 | #define Transform2d eigen2_Transform2d 40 | #define Transform3f eigen2_Transform3f 41 | #define Transform3d eigen2_Transform3d 42 | 43 | #define Translation eigen2_Translation 44 | #define Translation2f eigen2_Translation2f 45 | #define Translation2d eigen2_Translation2d 46 | #define Translation3f eigen2_Translation3f 47 | #define Translation3d eigen2_Translation3d 48 | 49 | #define Scaling eigen2_Scaling 50 | #define Scaling2f eigen2_Scaling2f 51 | #define Scaling2d eigen2_Scaling2d 52 | #define Scaling3f eigen2_Scaling3f 53 | #define Scaling3d eigen2_Scaling3d 54 | 55 | #define AlignedBox eigen2_AlignedBox 56 | 57 | #define Hyperplane eigen2_Hyperplane 58 | #define ParametrizedLine eigen2_ParametrizedLine 59 | 60 | #define ei_toRotationMatrix eigen2_ei_toRotationMatrix 61 | #define ei_quaternion_assign_impl eigen2_ei_quaternion_assign_impl 62 | #define ei_transform_product_impl eigen2_ei_transform_product_impl 63 | 64 | #include "RotationBase.h" 65 | #include "Rotation2D.h" 66 | #include "Quaternion.h" 67 | #include "AngleAxis.h" 68 | #include "Transform.h" 69 | #include "Translation.h" 70 | #include "Scaling.h" 71 | #include "AlignedBox.h" 72 | #include "Hyperplane.h" 73 | #include "ParametrizedLine.h" 74 | 75 | #undef ei_toRotationMatrix 76 | #undef ei_quaternion_assign_impl 77 | #undef ei_transform_product_impl 78 | 79 | #undef RotationBase 80 | #undef Rotation2D 81 | #undef Rotation2Df 82 | #undef Rotation2Dd 83 | 84 | #undef Quaternion 85 | #undef Quaternionf 86 | #undef Quaterniond 87 | 88 | #undef AngleAxis 89 | #undef AngleAxisf 90 | #undef AngleAxisd 91 | 92 | #undef Transform 93 | #undef Transform2f 94 | #undef Transform2d 95 | #undef Transform3f 96 | #undef Transform3d 97 | 98 | #undef Translation 99 | #undef Translation2f 100 | #undef Translation2d 101 | #undef Translation3f 102 | #undef Translation3d 103 | 104 | #undef Scaling 105 | #undef Scaling2f 106 | #undef Scaling2d 107 | #undef Scaling3f 108 | #undef Scaling3d 109 | 110 | #undef AlignedBox 111 | 112 | #undef Hyperplane 113 | #undef ParametrizedLine 114 | 115 | #endif // EIGEN2_GEOMETRY_MODULE_H 116 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/Eigen2Support/Geometry/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Eigen2Support_Geometry_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Eigen2Support_Geometry_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Eigen2Support/Geometry 6 | ) 7 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/Eigen2Support/Lazy.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008 Benoit Jacob 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_LAZY_H 11 | #define EIGEN_LAZY_H 12 | 13 | namespace Eigen { 14 | 15 | /** \deprecated it is only used by lazy() which is deprecated 16 | * 17 | * \returns an expression of *this with added flags 18 | * 19 | * Example: \include MatrixBase_marked.cpp 20 | * Output: \verbinclude MatrixBase_marked.out 21 | * 22 | * \sa class Flagged, extract(), part() 23 | */ 24 | template 25 | template 26 | inline const Flagged 27 | MatrixBase::marked() const 28 | { 29 | return derived(); 30 | } 31 | 32 | /** \deprecated use MatrixBase::noalias() 33 | * 34 | * \returns an expression of *this with the EvalBeforeAssigningBit flag removed. 35 | * 36 | * Example: \include MatrixBase_lazy.cpp 37 | * Output: \verbinclude MatrixBase_lazy.out 38 | * 39 | * \sa class Flagged, marked() 40 | */ 41 | template 42 | inline const Flagged 43 | MatrixBase::lazy() const 44 | { 45 | return derived(); 46 | } 47 | 48 | 49 | /** \internal 50 | * Overloaded to perform an efficient C += (A*B).lazy() */ 51 | template 52 | template 53 | Derived& MatrixBase::operator+=(const Flagged, 0, 54 | EvalBeforeAssigningBit>& other) 55 | { 56 | other._expression().derived().addTo(derived()); return derived(); 57 | } 58 | 59 | /** \internal 60 | * Overloaded to perform an efficient C -= (A*B).lazy() */ 61 | template 62 | template 63 | Derived& MatrixBase::operator-=(const Flagged, 0, 64 | EvalBeforeAssigningBit>& other) 65 | { 66 | other._expression().derived().subTo(derived()); return derived(); 67 | } 68 | 69 | } // end namespace Eigen 70 | 71 | #endif // EIGEN_LAZY_H 72 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/Eigen2Support/Macros.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2011 Benoit Jacob 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN2_MACROS_H 11 | #define EIGEN2_MACROS_H 12 | 13 | #define ei_assert eigen_assert 14 | #define ei_internal_assert eigen_internal_assert 15 | 16 | #define EIGEN_ALIGN_128 EIGEN_ALIGN16 17 | 18 | #define EIGEN_ARCH_WANTS_ALIGNMENT EIGEN_ALIGN_STATICALLY 19 | 20 | #endif // EIGEN2_MACROS_H 21 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/Eigen2Support/MathFunctions.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2010 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN2_MATH_FUNCTIONS_H 11 | #define EIGEN2_MATH_FUNCTIONS_H 12 | 13 | namespace Eigen { 14 | 15 | template inline typename NumTraits::Real ei_real(const T& x) { return internal::real(x); } 16 | template inline typename NumTraits::Real ei_imag(const T& x) { return internal::imag(x); } 17 | template inline T ei_conj(const T& x) { return internal::conj(x); } 18 | template inline typename NumTraits::Real ei_abs (const T& x) { return internal::abs(x); } 19 | template inline typename NumTraits::Real ei_abs2(const T& x) { return internal::abs2(x); } 20 | template inline T ei_sqrt(const T& x) { return internal::sqrt(x); } 21 | template inline T ei_exp (const T& x) { return internal::exp(x); } 22 | template inline T ei_log (const T& x) { return internal::log(x); } 23 | template inline T ei_sin (const T& x) { return internal::sin(x); } 24 | template inline T ei_cos (const T& x) { return internal::cos(x); } 25 | template inline T ei_atan2(const T& x,const T& y) { return internal::atan2(x,y); } 26 | template inline T ei_pow (const T& x,const T& y) { return internal::pow(x,y); } 27 | template inline T ei_random () { return internal::random(); } 28 | template inline T ei_random (const T& x, const T& y) { return internal::random(x, y); } 29 | 30 | template inline T precision () { return NumTraits::dummy_precision(); } 31 | template inline T machine_epsilon () { return NumTraits::epsilon(); } 32 | 33 | 34 | template 35 | inline bool ei_isMuchSmallerThan(const Scalar& x, const OtherScalar& y, 36 | typename NumTraits::Real precision = NumTraits::dummy_precision()) 37 | { 38 | return internal::isMuchSmallerThan(x, y, precision); 39 | } 40 | 41 | template 42 | inline bool ei_isApprox(const Scalar& x, const Scalar& y, 43 | typename NumTraits::Real precision = NumTraits::dummy_precision()) 44 | { 45 | return internal::isApprox(x, y, precision); 46 | } 47 | 48 | template 49 | inline bool ei_isApproxOrLessThan(const Scalar& x, const Scalar& y, 50 | typename NumTraits::Real precision = NumTraits::dummy_precision()) 51 | { 52 | return internal::isApproxOrLessThan(x, y, precision); 53 | } 54 | 55 | } // end namespace Eigen 56 | 57 | #endif // EIGEN2_MATH_FUNCTIONS_H 58 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/Eigen2Support/Memory.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2011 Benoit Jacob 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN2_MEMORY_H 11 | #define EIGEN2_MEMORY_H 12 | 13 | namespace Eigen { 14 | 15 | inline void* ei_aligned_malloc(size_t size) { return internal::aligned_malloc(size); } 16 | inline void ei_aligned_free(void *ptr) { internal::aligned_free(ptr); } 17 | inline void* ei_aligned_realloc(void *ptr, size_t new_size, size_t old_size) { return internal::aligned_realloc(ptr, new_size, old_size); } 18 | inline void* ei_handmade_aligned_malloc(size_t size) { return internal::handmade_aligned_malloc(size); } 19 | inline void ei_handmade_aligned_free(void *ptr) { internal::handmade_aligned_free(ptr); } 20 | 21 | template inline void* ei_conditional_aligned_malloc(size_t size) 22 | { 23 | return internal::conditional_aligned_malloc(size); 24 | } 25 | template inline void ei_conditional_aligned_free(void *ptr) 26 | { 27 | internal::conditional_aligned_free(ptr); 28 | } 29 | template inline void* ei_conditional_aligned_realloc(void* ptr, size_t new_size, size_t old_size) 30 | { 31 | return internal::conditional_aligned_realloc(ptr, new_size, old_size); 32 | } 33 | 34 | template inline T* ei_aligned_new(size_t size) 35 | { 36 | return internal::aligned_new(size); 37 | } 38 | template inline void ei_aligned_delete(T *ptr, size_t size) 39 | { 40 | return internal::aligned_delete(ptr, size); 41 | } 42 | 43 | } // end namespace Eigen 44 | 45 | #endif // EIGEN2_MACROS_H 46 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/Eigen2Support/Meta.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2011 Benoit Jacob 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN2_META_H 11 | #define EIGEN2_META_H 12 | 13 | namespace Eigen { 14 | 15 | template 16 | struct ei_traits : internal::traits 17 | {}; 18 | 19 | struct ei_meta_true { enum { ret = 1 }; }; 20 | struct ei_meta_false { enum { ret = 0 }; }; 21 | 22 | template 23 | struct ei_meta_if { typedef Then ret; }; 24 | 25 | template 26 | struct ei_meta_if { typedef Else ret; }; 27 | 28 | template struct ei_is_same_type { enum { ret = 0 }; }; 29 | template struct ei_is_same_type { enum { ret = 1 }; }; 30 | 31 | template struct ei_unref { typedef T type; }; 32 | template struct ei_unref { typedef T type; }; 33 | 34 | template struct ei_unpointer { typedef T type; }; 35 | template struct ei_unpointer { typedef T type; }; 36 | template struct ei_unpointer { typedef T type; }; 37 | 38 | template struct ei_unconst { typedef T type; }; 39 | template struct ei_unconst { typedef T type; }; 40 | template struct ei_unconst { typedef T & type; }; 41 | template struct ei_unconst { typedef T * type; }; 42 | 43 | template struct ei_cleantype { typedef T type; }; 44 | template struct ei_cleantype { typedef typename ei_cleantype::type type; }; 45 | template struct ei_cleantype { typedef typename ei_cleantype::type type; }; 46 | template struct ei_cleantype { typedef typename ei_cleantype::type type; }; 47 | template struct ei_cleantype { typedef typename ei_cleantype::type type; }; 48 | template struct ei_cleantype { typedef typename ei_cleantype::type type; }; 49 | 50 | /** \internal In short, it computes int(sqrt(\a Y)) with \a Y an integer. 51 | * Usage example: \code ei_meta_sqrt<1023>::ret \endcode 52 | */ 53 | template Y))) > 57 | // use ?: instead of || just to shut up a stupid gcc 4.3 warning 58 | class ei_meta_sqrt 59 | { 60 | enum { 61 | MidX = (InfX+SupX)/2, 62 | TakeInf = MidX*MidX > Y ? 1 : 0, 63 | NewInf = int(TakeInf) ? InfX : int(MidX), 64 | NewSup = int(TakeInf) ? int(MidX) : SupX 65 | }; 66 | public: 67 | enum { ret = ei_meta_sqrt::ret }; 68 | }; 69 | 70 | template 71 | class ei_meta_sqrt { public: enum { ret = (SupX*SupX <= Y) ? SupX : InfX }; }; 72 | 73 | } // end namespace Eigen 74 | 75 | #endif // EIGEN2_META_H 76 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/Eigen2Support/Minor.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2006-2009 Benoit Jacob 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_MINOR_H 11 | #define EIGEN_MINOR_H 12 | 13 | namespace Eigen { 14 | 15 | /** 16 | * \class Minor 17 | * 18 | * \brief Expression of a minor 19 | * 20 | * \param MatrixType the type of the object in which we are taking a minor 21 | * 22 | * This class represents an expression of a minor. It is the return 23 | * type of MatrixBase::minor() and most of the time this is the only way it 24 | * is used. 25 | * 26 | * \sa MatrixBase::minor() 27 | */ 28 | 29 | namespace internal { 30 | template 31 | struct traits > 32 | : traits 33 | { 34 | typedef typename nested::type MatrixTypeNested; 35 | typedef typename remove_reference::type _MatrixTypeNested; 36 | typedef typename MatrixType::StorageKind StorageKind; 37 | enum { 38 | RowsAtCompileTime = (MatrixType::RowsAtCompileTime != Dynamic) ? 39 | int(MatrixType::RowsAtCompileTime) - 1 : Dynamic, 40 | ColsAtCompileTime = (MatrixType::ColsAtCompileTime != Dynamic) ? 41 | int(MatrixType::ColsAtCompileTime) - 1 : Dynamic, 42 | MaxRowsAtCompileTime = (MatrixType::MaxRowsAtCompileTime != Dynamic) ? 43 | int(MatrixType::MaxRowsAtCompileTime) - 1 : Dynamic, 44 | MaxColsAtCompileTime = (MatrixType::MaxColsAtCompileTime != Dynamic) ? 45 | int(MatrixType::MaxColsAtCompileTime) - 1 : Dynamic, 46 | Flags = _MatrixTypeNested::Flags & (HereditaryBits | LvalueBit), 47 | CoeffReadCost = _MatrixTypeNested::CoeffReadCost // minor is used typically on tiny matrices, 48 | // where loops are unrolled and the 'if' evaluates at compile time 49 | }; 50 | }; 51 | } 52 | 53 | template class Minor 54 | : public MatrixBase > 55 | { 56 | public: 57 | 58 | typedef MatrixBase Base; 59 | EIGEN_DENSE_PUBLIC_INTERFACE(Minor) 60 | 61 | inline Minor(const MatrixType& matrix, 62 | Index row, Index col) 63 | : m_matrix(matrix), m_row(row), m_col(col) 64 | { 65 | eigen_assert(row >= 0 && row < matrix.rows() 66 | && col >= 0 && col < matrix.cols()); 67 | } 68 | 69 | EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Minor) 70 | 71 | inline Index rows() const { return m_matrix.rows() - 1; } 72 | inline Index cols() const { return m_matrix.cols() - 1; } 73 | 74 | inline Scalar& coeffRef(Index row, Index col) 75 | { 76 | return m_matrix.const_cast_derived().coeffRef(row + (row >= m_row), col + (col >= m_col)); 77 | } 78 | 79 | inline const Scalar coeff(Index row, Index col) const 80 | { 81 | return m_matrix.coeff(row + (row >= m_row), col + (col >= m_col)); 82 | } 83 | 84 | protected: 85 | const typename MatrixType::Nested m_matrix; 86 | const Index m_row, m_col; 87 | }; 88 | 89 | /** 90 | * \return an expression of the (\a row, \a col)-minor of *this, 91 | * i.e. an expression constructed from *this by removing the specified 92 | * row and column. 93 | * 94 | * Example: \include MatrixBase_minor.cpp 95 | * Output: \verbinclude MatrixBase_minor.out 96 | * 97 | * \sa class Minor 98 | */ 99 | template 100 | inline Minor 101 | MatrixBase::minor(Index row, Index col) 102 | { 103 | return Minor(derived(), row, col); 104 | } 105 | 106 | /** 107 | * This is the const version of minor(). */ 108 | template 109 | inline const Minor 110 | MatrixBase::minor(Index row, Index col) const 111 | { 112 | return Minor(derived(), row, col); 113 | } 114 | 115 | } // end namespace Eigen 116 | 117 | #endif // EIGEN_MINOR_H 118 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/Eigen2Support/QR.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008 Gael Guennebaud 5 | // Copyright (C) 2011 Benoit Jacob 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN2_QR_H 12 | #define EIGEN2_QR_H 13 | 14 | namespace Eigen { 15 | 16 | template 17 | class QR : public HouseholderQR 18 | { 19 | public: 20 | 21 | typedef HouseholderQR Base; 22 | typedef Block MatrixRBlockType; 23 | 24 | QR() : Base() {} 25 | 26 | template 27 | explicit QR(const T& t) : Base(t) {} 28 | 29 | template 30 | bool solve(const MatrixBase& b, ResultType *result) const 31 | { 32 | *result = static_cast(this)->solve(b); 33 | return true; 34 | } 35 | 36 | MatrixType matrixQ(void) const { 37 | MatrixType ret = MatrixType::Identity(this->rows(), this->cols()); 38 | ret = this->householderQ() * ret; 39 | return ret; 40 | } 41 | 42 | bool isFullRank() const { 43 | return true; 44 | } 45 | 46 | const TriangularView 47 | matrixR(void) const 48 | { 49 | int cols = this->cols(); 50 | return MatrixRBlockType(this->matrixQR(), 0, 0, cols, cols).template triangularView(); 51 | } 52 | }; 53 | 54 | /** \return the QR decomposition of \c *this. 55 | * 56 | * \sa class QR 57 | */ 58 | template 59 | const QR::PlainObject> 60 | MatrixBase::qr() const 61 | { 62 | return QR(eval()); 63 | } 64 | 65 | } // end namespace Eigen 66 | 67 | #endif // EIGEN2_QR_H 68 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/Eigen2Support/TriangularSolver.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2010 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_TRIANGULAR_SOLVER2_H 11 | #define EIGEN_TRIANGULAR_SOLVER2_H 12 | 13 | namespace Eigen { 14 | 15 | const unsigned int UnitDiagBit = UnitDiag; 16 | const unsigned int SelfAdjointBit = SelfAdjoint; 17 | const unsigned int UpperTriangularBit = Upper; 18 | const unsigned int LowerTriangularBit = Lower; 19 | 20 | const unsigned int UpperTriangular = Upper; 21 | const unsigned int LowerTriangular = Lower; 22 | const unsigned int UnitUpperTriangular = UnitUpper; 23 | const unsigned int UnitLowerTriangular = UnitLower; 24 | 25 | template 26 | template 27 | typename ExpressionType::PlainObject 28 | Flagged::solveTriangular(const MatrixBase& other) const 29 | { 30 | return m_matrix.template triangularView().solve(other.derived()); 31 | } 32 | 33 | template 34 | template 35 | void Flagged::solveTriangularInPlace(const MatrixBase& other) const 36 | { 37 | m_matrix.template triangularView().solveInPlace(other.derived()); 38 | } 39 | 40 | } // end namespace Eigen 41 | 42 | #endif // EIGEN_TRIANGULAR_SOLVER2_H 43 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/Eigen2Support/VectorBlock.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2009 Gael Guennebaud 5 | // Copyright (C) 2006-2008 Benoit Jacob 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN2_VECTORBLOCK_H 12 | #define EIGEN2_VECTORBLOCK_H 13 | 14 | namespace Eigen { 15 | 16 | /** \deprecated use DenseMase::head(Index) */ 17 | template 18 | inline VectorBlock 19 | MatrixBase::start(Index size) 20 | { 21 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 22 | return VectorBlock(derived(), 0, size); 23 | } 24 | 25 | /** \deprecated use DenseMase::head(Index) */ 26 | template 27 | inline const VectorBlock 28 | MatrixBase::start(Index size) const 29 | { 30 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 31 | return VectorBlock(derived(), 0, size); 32 | } 33 | 34 | /** \deprecated use DenseMase::tail(Index) */ 35 | template 36 | inline VectorBlock 37 | MatrixBase::end(Index size) 38 | { 39 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 40 | return VectorBlock(derived(), this->size() - size, size); 41 | } 42 | 43 | /** \deprecated use DenseMase::tail(Index) */ 44 | template 45 | inline const VectorBlock 46 | MatrixBase::end(Index size) const 47 | { 48 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 49 | return VectorBlock(derived(), this->size() - size, size); 50 | } 51 | 52 | /** \deprecated use DenseMase::head() */ 53 | template 54 | template 55 | inline VectorBlock 56 | MatrixBase::start() 57 | { 58 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 59 | return VectorBlock(derived(), 0); 60 | } 61 | 62 | /** \deprecated use DenseMase::head() */ 63 | template 64 | template 65 | inline const VectorBlock 66 | MatrixBase::start() const 67 | { 68 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 69 | return VectorBlock(derived(), 0); 70 | } 71 | 72 | /** \deprecated use DenseMase::tail() */ 73 | template 74 | template 75 | inline VectorBlock 76 | MatrixBase::end() 77 | { 78 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 79 | return VectorBlock(derived(), size() - Size); 80 | } 81 | 82 | /** \deprecated use DenseMase::tail() */ 83 | template 84 | template 85 | inline const VectorBlock 86 | MatrixBase::end() const 87 | { 88 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 89 | return VectorBlock(derived(), size() - Size); 90 | } 91 | 92 | } // end namespace Eigen 93 | 94 | #endif // EIGEN2_VECTORBLOCK_H 95 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/Eigenvalues/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_EIGENVALUES_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_EIGENVALUES_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Eigenvalues COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/Eigenvalues/RealSchur_MKL.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011, Intel Corporation. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | * Neither the name of Intel Corporation nor the names of its contributors may 13 | be used to endorse or promote products derived from this software without 14 | specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | ******************************************************************************** 28 | * Content : Eigen bindings to Intel(R) MKL 29 | * Real Schur needed to real unsymmetrical eigenvalues/eigenvectors. 30 | ******************************************************************************** 31 | */ 32 | 33 | #ifndef EIGEN_REAL_SCHUR_MKL_H 34 | #define EIGEN_REAL_SCHUR_MKL_H 35 | 36 | #include "Eigen/src/Core/util/MKL_support.h" 37 | 38 | namespace Eigen { 39 | 40 | /** \internal Specialization for the data types supported by MKL */ 41 | 42 | #define EIGEN_MKL_SCHUR_REAL(EIGTYPE, MKLTYPE, MKLPREFIX, MKLPREFIX_U, EIGCOLROW, MKLCOLROW) \ 43 | template<> inline \ 44 | RealSchur >& \ 45 | RealSchur >::compute(const Matrix& matrix, bool computeU) \ 46 | { \ 47 | typedef Matrix MatrixType; \ 48 | typedef MatrixType::Scalar Scalar; \ 49 | typedef MatrixType::RealScalar RealScalar; \ 50 | \ 51 | assert(matrix.cols() == matrix.rows()); \ 52 | \ 53 | lapack_int n = matrix.cols(), sdim, info; \ 54 | lapack_int lda = matrix.outerStride(); \ 55 | lapack_int matrix_order = MKLCOLROW; \ 56 | char jobvs, sort='N'; \ 57 | LAPACK_##MKLPREFIX_U##_SELECT2 select = 0; \ 58 | jobvs = (computeU) ? 'V' : 'N'; \ 59 | m_matU.resize(n, n); \ 60 | lapack_int ldvs = m_matU.outerStride(); \ 61 | m_matT = matrix; \ 62 | Matrix wr, wi; \ 63 | wr.resize(n, 1); wi.resize(n, 1); \ 64 | info = LAPACKE_##MKLPREFIX##gees( matrix_order, jobvs, sort, select, n, (MKLTYPE*)m_matT.data(), lda, &sdim, (MKLTYPE*)wr.data(), (MKLTYPE*)wi.data(), (MKLTYPE*)m_matU.data(), ldvs ); \ 65 | if(info == 0) \ 66 | m_info = Success; \ 67 | else \ 68 | m_info = NoConvergence; \ 69 | \ 70 | m_isInitialized = true; \ 71 | m_matUisUptodate = computeU; \ 72 | return *this; \ 73 | \ 74 | } 75 | 76 | EIGEN_MKL_SCHUR_REAL(double, double, d, D, ColMajor, LAPACK_COL_MAJOR) 77 | EIGEN_MKL_SCHUR_REAL(float, float, s, S, ColMajor, LAPACK_COL_MAJOR) 78 | EIGEN_MKL_SCHUR_REAL(double, double, d, D, RowMajor, LAPACK_ROW_MAJOR) 79 | EIGEN_MKL_SCHUR_REAL(float, float, s, S, RowMajor, LAPACK_ROW_MAJOR) 80 | 81 | } // end namespace Eigen 82 | 83 | #endif // EIGEN_REAL_SCHUR_MKL_H 84 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/Geometry/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Geometry_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Geometry_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Geometry COMPONENT Devel 6 | ) 7 | 8 | ADD_SUBDIRECTORY(arch) 9 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/Geometry/EulerAngles.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_EULERANGLES_H 11 | #define EIGEN_EULERANGLES_H 12 | 13 | namespace Eigen { 14 | 15 | /** \geometry_module \ingroup Geometry_Module 16 | * 17 | * 18 | * \returns the Euler-angles of the rotation matrix \c *this using the convention defined by the triplet (\a a0,\a a1,\a a2) 19 | * 20 | * Each of the three parameters \a a0,\a a1,\a a2 represents the respective rotation axis as an integer in {0,1,2}. 21 | * For instance, in: 22 | * \code Vector3f ea = mat.eulerAngles(2, 0, 2); \endcode 23 | * "2" represents the z axis and "0" the x axis, etc. The returned angles are such that 24 | * we have the following equality: 25 | * \code 26 | * mat == AngleAxisf(ea[0], Vector3f::UnitZ()) 27 | * * AngleAxisf(ea[1], Vector3f::UnitX()) 28 | * * AngleAxisf(ea[2], Vector3f::UnitZ()); \endcode 29 | * This corresponds to the right-multiply conventions (with right hand side frames). 30 | */ 31 | template 32 | inline Matrix::Scalar,3,1> 33 | MatrixBase::eulerAngles(Index a0, Index a1, Index a2) const 34 | { 35 | /* Implemented from Graphics Gems IV */ 36 | EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Derived,3,3) 37 | 38 | Matrix res; 39 | typedef Matrix Vector2; 40 | const Scalar epsilon = NumTraits::dummy_precision(); 41 | 42 | const Index odd = ((a0+1)%3 == a1) ? 0 : 1; 43 | const Index i = a0; 44 | const Index j = (a0 + 1 + odd)%3; 45 | const Index k = (a0 + 2 - odd)%3; 46 | 47 | if (a0==a2) 48 | { 49 | Scalar s = Vector2(coeff(j,i) , coeff(k,i)).norm(); 50 | res[1] = internal::atan2(s, coeff(i,i)); 51 | if (s > epsilon) 52 | { 53 | res[0] = internal::atan2(coeff(j,i), coeff(k,i)); 54 | res[2] = internal::atan2(coeff(i,j),-coeff(i,k)); 55 | } 56 | else 57 | { 58 | res[0] = Scalar(0); 59 | res[2] = (coeff(i,i)>0?1:-1)*internal::atan2(-coeff(k,j), coeff(j,j)); 60 | } 61 | } 62 | else 63 | { 64 | Scalar c = Vector2(coeff(i,i) , coeff(i,j)).norm(); 65 | res[1] = internal::atan2(-coeff(i,k), c); 66 | if (c > epsilon) 67 | { 68 | res[0] = internal::atan2(coeff(j,k), coeff(k,k)); 69 | res[2] = internal::atan2(coeff(i,j), coeff(i,i)); 70 | } 71 | else 72 | { 73 | res[0] = Scalar(0); 74 | res[2] = (coeff(i,k)>0?1:-1)*internal::atan2(-coeff(k,j), coeff(j,j)); 75 | } 76 | } 77 | if (!odd) 78 | res = -res; 79 | return res; 80 | } 81 | 82 | } // end namespace Eigen 83 | 84 | #endif // EIGEN_EULERANGLES_H 85 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/Geometry/arch/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Geometry_arch_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Geometry_arch_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Geometry/arch COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/Householder/BlockHouseholder.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2010 Vincent Lejeune 5 | // Copyright (C) 2010 Gael Guennebaud 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_BLOCK_HOUSEHOLDER_H 12 | #define EIGEN_BLOCK_HOUSEHOLDER_H 13 | 14 | // This file contains some helper function to deal with block householder reflectors 15 | 16 | namespace Eigen { 17 | 18 | namespace internal { 19 | 20 | /** \internal */ 21 | template 22 | void make_block_householder_triangular_factor(TriangularFactorType& triFactor, const VectorsType& vectors, const CoeffsType& hCoeffs) 23 | { 24 | typedef typename TriangularFactorType::Index Index; 25 | typedef typename VectorsType::Scalar Scalar; 26 | const Index nbVecs = vectors.cols(); 27 | eigen_assert(triFactor.rows() == nbVecs && triFactor.cols() == nbVecs && vectors.rows()>=nbVecs); 28 | 29 | for(Index i = 0; i < nbVecs; i++) 30 | { 31 | Index rs = vectors.rows() - i; 32 | Scalar Vii = vectors(i,i); 33 | vectors.const_cast_derived().coeffRef(i,i) = Scalar(1); 34 | triFactor.col(i).head(i).noalias() = -hCoeffs(i) * vectors.block(i, 0, rs, i).adjoint() 35 | * vectors.col(i).tail(rs); 36 | vectors.const_cast_derived().coeffRef(i, i) = Vii; 37 | // FIXME add .noalias() once the triangular product can work inplace 38 | triFactor.col(i).head(i) = triFactor.block(0,0,i,i).template triangularView() 39 | * triFactor.col(i).head(i); 40 | triFactor(i,i) = hCoeffs(i); 41 | } 42 | } 43 | 44 | /** \internal */ 45 | template 46 | void apply_block_householder_on_the_left(MatrixType& mat, const VectorsType& vectors, const CoeffsType& hCoeffs) 47 | { 48 | typedef typename MatrixType::Index Index; 49 | enum { TFactorSize = MatrixType::ColsAtCompileTime }; 50 | Index nbVecs = vectors.cols(); 51 | Matrix T(nbVecs,nbVecs); 52 | make_block_householder_triangular_factor(T, vectors, hCoeffs); 53 | 54 | const TriangularView& V(vectors); 55 | 56 | // A -= V T V^* A 57 | Matrix tmp = V.adjoint() * mat; 59 | // FIXME add .noalias() once the triangular product can work inplace 60 | tmp = T.template triangularView().adjoint() * tmp; 61 | mat.noalias() -= V * tmp; 62 | } 63 | 64 | } // end namespace internal 65 | 66 | } // end namespace Eigen 67 | 68 | #endif // EIGEN_BLOCK_HOUSEHOLDER_H 69 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/Householder/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Householder_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Householder_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Householder COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/IterativeLinearSolvers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_IterativeLinearSolvers_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_IterativeLinearSolvers_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/IterativeLinearSolvers COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/Jacobi/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Jacobi_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Jacobi_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Jacobi COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/LU/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_LU_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_LU_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/LU COMPONENT Devel 6 | ) 7 | 8 | ADD_SUBDIRECTORY(arch) 9 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/LU/Determinant.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008 Benoit Jacob 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_DETERMINANT_H 11 | #define EIGEN_DETERMINANT_H 12 | 13 | namespace Eigen { 14 | 15 | namespace internal { 16 | 17 | template 18 | inline const typename Derived::Scalar bruteforce_det3_helper 19 | (const MatrixBase& matrix, int a, int b, int c) 20 | { 21 | return matrix.coeff(0,a) 22 | * (matrix.coeff(1,b) * matrix.coeff(2,c) - matrix.coeff(1,c) * matrix.coeff(2,b)); 23 | } 24 | 25 | template 26 | const typename Derived::Scalar bruteforce_det4_helper 27 | (const MatrixBase& matrix, int j, int k, int m, int n) 28 | { 29 | return (matrix.coeff(j,0) * matrix.coeff(k,1) - matrix.coeff(k,0) * matrix.coeff(j,1)) 30 | * (matrix.coeff(m,2) * matrix.coeff(n,3) - matrix.coeff(n,2) * matrix.coeff(m,3)); 31 | } 32 | 33 | template struct determinant_impl 36 | { 37 | static inline typename traits::Scalar run(const Derived& m) 38 | { 39 | if(Derived::ColsAtCompileTime==Dynamic && m.rows()==0) 40 | return typename traits::Scalar(1); 41 | return m.partialPivLu().determinant(); 42 | } 43 | }; 44 | 45 | template struct determinant_impl 46 | { 47 | static inline typename traits::Scalar run(const Derived& m) 48 | { 49 | return m.coeff(0,0); 50 | } 51 | }; 52 | 53 | template struct determinant_impl 54 | { 55 | static inline typename traits::Scalar run(const Derived& m) 56 | { 57 | return m.coeff(0,0) * m.coeff(1,1) - m.coeff(1,0) * m.coeff(0,1); 58 | } 59 | }; 60 | 61 | template struct determinant_impl 62 | { 63 | static inline typename traits::Scalar run(const Derived& m) 64 | { 65 | return bruteforce_det3_helper(m,0,1,2) 66 | - bruteforce_det3_helper(m,1,0,2) 67 | + bruteforce_det3_helper(m,2,0,1); 68 | } 69 | }; 70 | 71 | template struct determinant_impl 72 | { 73 | static typename traits::Scalar run(const Derived& m) 74 | { 75 | // trick by Martin Costabel to compute 4x4 det with only 30 muls 76 | return bruteforce_det4_helper(m,0,1,2,3) 77 | - bruteforce_det4_helper(m,0,2,1,3) 78 | + bruteforce_det4_helper(m,0,3,1,2) 79 | + bruteforce_det4_helper(m,1,2,0,3) 80 | - bruteforce_det4_helper(m,1,3,0,2) 81 | + bruteforce_det4_helper(m,2,3,0,1); 82 | } 83 | }; 84 | 85 | } // end namespace internal 86 | 87 | /** \lu_module 88 | * 89 | * \returns the determinant of this matrix 90 | */ 91 | template 92 | inline typename internal::traits::Scalar MatrixBase::determinant() const 93 | { 94 | assert(rows() == cols()); 95 | typedef typename internal::nested::type Nested; 96 | return internal::determinant_impl::type>::run(derived()); 97 | } 98 | 99 | } // end namespace Eigen 100 | 101 | #endif // EIGEN_DETERMINANT_H 102 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/LU/PartialPivLU_MKL.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011, Intel Corporation. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | * Neither the name of Intel Corporation nor the names of its contributors may 13 | be used to endorse or promote products derived from this software without 14 | specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | ******************************************************************************** 28 | * Content : Eigen bindings to Intel(R) MKL 29 | * LU decomposition with partial pivoting based on LAPACKE_?getrf function. 30 | ******************************************************************************** 31 | */ 32 | 33 | #ifndef EIGEN_PARTIALLU_LAPACK_H 34 | #define EIGEN_PARTIALLU_LAPACK_H 35 | 36 | #include "Eigen/src/Core/util/MKL_support.h" 37 | 38 | namespace Eigen { 39 | 40 | namespace internal { 41 | 42 | /** \internal Specialization for the data types supported by MKL */ 43 | 44 | #define EIGEN_MKL_LU_PARTPIV(EIGTYPE, MKLTYPE, MKLPREFIX) \ 45 | template \ 46 | struct partial_lu_impl \ 47 | { \ 48 | /* \internal performs the LU decomposition in-place of the matrix represented */ \ 49 | static lapack_int blocked_lu(lapack_int rows, lapack_int cols, EIGTYPE* lu_data, lapack_int luStride, lapack_int* row_transpositions, lapack_int& nb_transpositions, lapack_int maxBlockSize=256) \ 50 | { \ 51 | EIGEN_UNUSED_VARIABLE(maxBlockSize);\ 52 | lapack_int matrix_order, first_zero_pivot; \ 53 | lapack_int m, n, lda, *ipiv, info; \ 54 | EIGTYPE* a; \ 55 | /* Set up parameters for ?getrf */ \ 56 | matrix_order = StorageOrder==RowMajor ? LAPACK_ROW_MAJOR : LAPACK_COL_MAJOR; \ 57 | lda = luStride; \ 58 | a = lu_data; \ 59 | ipiv = row_transpositions; \ 60 | m = rows; \ 61 | n = cols; \ 62 | nb_transpositions = 0; \ 63 | \ 64 | info = LAPACKE_##MKLPREFIX##getrf( matrix_order, m, n, (MKLTYPE*)a, lda, ipiv ); \ 65 | \ 66 | for(int i=0;i= 0); \ 69 | /* something should be done with nb_transpositions */ \ 70 | \ 71 | first_zero_pivot = info; \ 72 | return first_zero_pivot; \ 73 | } \ 74 | }; 75 | 76 | EIGEN_MKL_LU_PARTPIV(double, double, d) 77 | EIGEN_MKL_LU_PARTPIV(float, float, s) 78 | EIGEN_MKL_LU_PARTPIV(dcomplex, MKL_Complex16, z) 79 | EIGEN_MKL_LU_PARTPIV(scomplex, MKL_Complex8, c) 80 | 81 | } // end namespace internal 82 | 83 | } // end namespace Eigen 84 | 85 | #endif // EIGEN_PARTIALLU_LAPACK_H 86 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/LU/arch/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_LU_arch_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_LU_arch_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/LU/arch COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/OrderingMethods/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_OrderingMethods_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_OrderingMethods_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/OrderingMethods COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/PaStiXSupport/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_PastixSupport_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_PastixSupport_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/PaStiXSupport COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/PardisoSupport/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_PardisoSupport_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_PardisoSupport_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/PardisoSupport COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/QR/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_QR_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_QR_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/QR COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/QR/HouseholderQR_MKL.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011, Intel Corporation. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | * Neither the name of Intel Corporation nor the names of its contributors may 13 | be used to endorse or promote products derived from this software without 14 | specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | ******************************************************************************** 28 | * Content : Eigen bindings to Intel(R) MKL 29 | * Householder QR decomposition of a matrix w/o pivoting based on 30 | * LAPACKE_?geqrf function. 31 | ******************************************************************************** 32 | */ 33 | 34 | #ifndef EIGEN_QR_MKL_H 35 | #define EIGEN_QR_MKL_H 36 | 37 | #include "Eigen/src/Core/util/MKL_support.h" 38 | 39 | namespace Eigen { 40 | 41 | namespace internal { 42 | 43 | /** \internal Specialization for the data types supported by MKL */ 44 | 45 | #define EIGEN_MKL_QR_NOPIV(EIGTYPE, MKLTYPE, MKLPREFIX) \ 46 | template \ 47 | void householder_qr_inplace_blocked(MatrixQR& mat, HCoeffs& hCoeffs, \ 48 | typename MatrixQR::Index maxBlockSize=32, \ 49 | EIGTYPE* tempData = 0) \ 50 | { \ 51 | lapack_int m = mat.rows(); \ 52 | lapack_int n = mat.cols(); \ 53 | lapack_int lda = mat.outerStride(); \ 54 | lapack_int matrix_order = (MatrixQR::IsRowMajor) ? LAPACK_ROW_MAJOR : LAPACK_COL_MAJOR; \ 55 | LAPACKE_##MKLPREFIX##geqrf( matrix_order, m, n, (MKLTYPE*)mat.data(), lda, (MKLTYPE*)hCoeffs.data()); \ 56 | hCoeffs.adjointInPlace(); \ 57 | \ 58 | } 59 | 60 | EIGEN_MKL_QR_NOPIV(double, double, d) 61 | EIGEN_MKL_QR_NOPIV(float, float, s) 62 | EIGEN_MKL_QR_NOPIV(dcomplex, MKL_Complex16, z) 63 | EIGEN_MKL_QR_NOPIV(scomplex, MKL_Complex8, c) 64 | 65 | } // end namespace internal 66 | 67 | } // end namespace Eigen 68 | 69 | #endif // EIGEN_QR_MKL_H 70 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/SVD/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_SVD_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_SVD_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/SVD COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/SparseCholesky/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_SparseCholesky_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_SparseCholesky_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/SparseCholesky COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/SparseCore/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_SparseCore_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_SparseCore_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/SparseCore COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/SparseCore/CoreIterators.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2010 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_COREITERATORS_H 11 | #define EIGEN_COREITERATORS_H 12 | 13 | namespace Eigen { 14 | 15 | /* This file contains the respective InnerIterator definition of the expressions defined in Eigen/Core 16 | */ 17 | 18 | /** \ingroup SparseCore_Module 19 | * \class InnerIterator 20 | * \brief An InnerIterator allows to loop over the element of a sparse (or dense) matrix or expression 21 | * 22 | * todo 23 | */ 24 | 25 | // generic version for dense matrix and expressions 26 | template class DenseBase::InnerIterator 27 | { 28 | protected: 29 | typedef typename Derived::Scalar Scalar; 30 | typedef typename Derived::Index Index; 31 | 32 | enum { IsRowMajor = (Derived::Flags&RowMajorBit)==RowMajorBit }; 33 | public: 34 | EIGEN_STRONG_INLINE InnerIterator(const Derived& expr, Index outer) 35 | : m_expression(expr), m_inner(0), m_outer(outer), m_end(expr.innerSize()) 36 | {} 37 | 38 | EIGEN_STRONG_INLINE Scalar value() const 39 | { 40 | return (IsRowMajor) ? m_expression.coeff(m_outer, m_inner) 41 | : m_expression.coeff(m_inner, m_outer); 42 | } 43 | 44 | EIGEN_STRONG_INLINE InnerIterator& operator++() { m_inner++; return *this; } 45 | 46 | EIGEN_STRONG_INLINE Index index() const { return m_inner; } 47 | inline Index row() const { return IsRowMajor ? m_outer : index(); } 48 | inline Index col() const { return IsRowMajor ? index() : m_outer; } 49 | 50 | EIGEN_STRONG_INLINE operator bool() const { return m_inner < m_end && m_inner>=0; } 51 | 52 | protected: 53 | const Derived& m_expression; 54 | Index m_inner; 55 | const Index m_outer; 56 | const Index m_end; 57 | }; 58 | 59 | } // end namespace Eigen 60 | 61 | #endif // EIGEN_COREITERATORS_H 62 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/SparseCore/SparseAssign.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/houqb/dss_crf/91ac933dc2544d6c4037ce0c3acbb9fea1c70c1c/pydensecrf/densecrf/include/Eigen/src/SparseCore/SparseAssign.h -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/SparseCore/SparseDot.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_SPARSE_DOT_H 11 | #define EIGEN_SPARSE_DOT_H 12 | 13 | namespace Eigen { 14 | 15 | template 16 | template 17 | typename internal::traits::Scalar 18 | SparseMatrixBase::dot(const MatrixBase& other) const 19 | { 20 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 21 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived) 22 | EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(Derived,OtherDerived) 23 | EIGEN_STATIC_ASSERT((internal::is_same::value), 24 | YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY) 25 | 26 | eigen_assert(size() == other.size()); 27 | eigen_assert(other.size()>0 && "you are using a non initialized vector"); 28 | 29 | typename Derived::InnerIterator i(derived(),0); 30 | Scalar res(0); 31 | while (i) 32 | { 33 | res += internal::conj(i.value()) * other.coeff(i.index()); 34 | ++i; 35 | } 36 | return res; 37 | } 38 | 39 | template 40 | template 41 | typename internal::traits::Scalar 42 | SparseMatrixBase::dot(const SparseMatrixBase& other) const 43 | { 44 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 45 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived) 46 | EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(Derived,OtherDerived) 47 | EIGEN_STATIC_ASSERT((internal::is_same::value), 48 | YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY) 49 | 50 | eigen_assert(size() == other.size()); 51 | 52 | typedef typename Derived::Nested Nested; 53 | typedef typename OtherDerived::Nested OtherNested; 54 | typedef typename internal::remove_all::type NestedCleaned; 55 | typedef typename internal::remove_all::type OtherNestedCleaned; 56 | 57 | const Nested nthis(derived()); 58 | const OtherNested nother(other.derived()); 59 | 60 | typename NestedCleaned::InnerIterator i(nthis,0); 61 | typename OtherNestedCleaned::InnerIterator j(nother,0); 62 | Scalar res(0); 63 | while (i && j) 64 | { 65 | if (i.index()==j.index()) 66 | { 67 | res += internal::conj(i.value()) * j.value(); 68 | ++i; ++j; 69 | } 70 | else if (i.index() 79 | inline typename NumTraits::Scalar>::Real 80 | SparseMatrixBase::squaredNorm() const 81 | { 82 | return internal::real((*this).cwiseAbs2().sum()); 83 | } 84 | 85 | template 86 | inline typename NumTraits::Scalar>::Real 87 | SparseMatrixBase::norm() const 88 | { 89 | return internal::sqrt(squaredNorm()); 90 | } 91 | 92 | } // end namespace Eigen 93 | 94 | #endif // EIGEN_SPARSE_DOT_H 95 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/SparseCore/SparseFuzzy.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_SPARSE_FUZZY_H 11 | #define EIGEN_SPARSE_FUZZY_H 12 | 13 | // template 14 | // template 15 | // bool SparseMatrixBase::isApprox( 16 | // const OtherDerived& other, 17 | // typename NumTraits::Real prec 18 | // ) const 19 | // { 20 | // const typename internal::nested::type nested(derived()); 21 | // const typename internal::nested::type otherNested(other.derived()); 22 | // return (nested - otherNested).cwise().abs2().sum() 23 | // <= prec * prec * (std::min)(nested.cwise().abs2().sum(), otherNested.cwise().abs2().sum()); 24 | // } 25 | 26 | #endif // EIGEN_SPARSE_FUZZY_H 27 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/SparseCore/SparseRedux.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_SPARSEREDUX_H 11 | #define EIGEN_SPARSEREDUX_H 12 | 13 | namespace Eigen { 14 | 15 | template 16 | typename internal::traits::Scalar 17 | SparseMatrixBase::sum() const 18 | { 19 | eigen_assert(rows()>0 && cols()>0 && "you are using a non initialized matrix"); 20 | Scalar res(0); 21 | for (Index j=0; j 28 | typename internal::traits >::Scalar 29 | SparseMatrix<_Scalar,_Options,_Index>::sum() const 30 | { 31 | eigen_assert(rows()>0 && cols()>0 && "you are using a non initialized matrix"); 32 | return Matrix::Map(&m_data.value(0), m_data.size()).sum(); 33 | } 34 | 35 | template 36 | typename internal::traits >::Scalar 37 | SparseVector<_Scalar,_Options,_Index>::sum() const 38 | { 39 | eigen_assert(rows()>0 && cols()>0 && "you are using a non initialized matrix"); 40 | return Matrix::Map(&m_data.value(0), m_data.size()).sum(); 41 | } 42 | 43 | } // end namespace Eigen 44 | 45 | #endif // EIGEN_SPARSEREDUX_H 46 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/SparseCore/SparseTranspose.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2009 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_SPARSETRANSPOSE_H 11 | #define EIGEN_SPARSETRANSPOSE_H 12 | 13 | namespace Eigen { 14 | 15 | template class TransposeImpl 16 | : public SparseMatrixBase > 17 | { 18 | typedef typename internal::remove_all::type _MatrixTypeNested; 19 | public: 20 | 21 | EIGEN_SPARSE_PUBLIC_INTERFACE(Transpose) 22 | 23 | class InnerIterator; 24 | class ReverseInnerIterator; 25 | 26 | inline Index nonZeros() const { return derived().nestedExpression().nonZeros(); } 27 | }; 28 | 29 | // NOTE: VC10 trigger an ICE if don't put typename TransposeImpl:: in front of Index, 30 | // a typedef typename TransposeImpl::Index Index; 31 | // does not fix the issue. 32 | // An alternative is to define the nested class in the parent class itself. 33 | template class TransposeImpl::InnerIterator 34 | : public _MatrixTypeNested::InnerIterator 35 | { 36 | typedef typename _MatrixTypeNested::InnerIterator Base; 37 | public: 38 | 39 | EIGEN_STRONG_INLINE InnerIterator(const TransposeImpl& trans, typename TransposeImpl::Index outer) 40 | : Base(trans.derived().nestedExpression(), outer) 41 | {} 42 | inline typename TransposeImpl::Index row() const { return Base::col(); } 43 | inline typename TransposeImpl::Index col() const { return Base::row(); } 44 | }; 45 | 46 | template class TransposeImpl::ReverseInnerIterator 47 | : public _MatrixTypeNested::ReverseInnerIterator 48 | { 49 | typedef typename _MatrixTypeNested::ReverseInnerIterator Base; 50 | public: 51 | 52 | EIGEN_STRONG_INLINE ReverseInnerIterator(const TransposeImpl& xpr, typename TransposeImpl::Index outer) 53 | : Base(xpr.derived().nestedExpression(), outer) 54 | {} 55 | inline typename TransposeImpl::Index row() const { return Base::col(); } 56 | inline typename TransposeImpl::Index col() const { return Base::row(); } 57 | }; 58 | 59 | } // end namespace Eigen 60 | 61 | #endif // EIGEN_SPARSETRANSPOSE_H 62 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/SparseCore/SparseView.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2011 Gael Guennebaud 5 | // Copyright (C) 2010 Daniel Lowengrub 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_SPARSEVIEW_H 12 | #define EIGEN_SPARSEVIEW_H 13 | 14 | namespace Eigen { 15 | 16 | namespace internal { 17 | 18 | template 19 | struct traits > : traits 20 | { 21 | typedef int Index; 22 | typedef Sparse StorageKind; 23 | enum { 24 | Flags = int(traits::Flags) & (RowMajorBit) 25 | }; 26 | }; 27 | 28 | } // end namespace internal 29 | 30 | template 31 | class SparseView : public SparseMatrixBase > 32 | { 33 | typedef typename MatrixType::Nested MatrixTypeNested; 34 | typedef typename internal::remove_all::type _MatrixTypeNested; 35 | public: 36 | EIGEN_SPARSE_PUBLIC_INTERFACE(SparseView) 37 | 38 | SparseView(const MatrixType& mat, const Scalar& m_reference = Scalar(0), 39 | typename NumTraits::Real m_epsilon = NumTraits::dummy_precision()) : 40 | m_matrix(mat), m_reference(m_reference), m_epsilon(m_epsilon) {} 41 | 42 | class InnerIterator; 43 | 44 | inline Index rows() const { return m_matrix.rows(); } 45 | inline Index cols() const { return m_matrix.cols(); } 46 | 47 | inline Index innerSize() const { return m_matrix.innerSize(); } 48 | inline Index outerSize() const { return m_matrix.outerSize(); } 49 | 50 | protected: 51 | MatrixTypeNested m_matrix; 52 | Scalar m_reference; 53 | typename NumTraits::Real m_epsilon; 54 | }; 55 | 56 | template 57 | class SparseView::InnerIterator : public _MatrixTypeNested::InnerIterator 58 | { 59 | public: 60 | typedef typename _MatrixTypeNested::InnerIterator IterBase; 61 | InnerIterator(const SparseView& view, Index outer) : 62 | IterBase(view.m_matrix, outer), m_view(view) 63 | { 64 | incrementToNonZero(); 65 | } 66 | 67 | EIGEN_STRONG_INLINE InnerIterator& operator++() 68 | { 69 | IterBase::operator++(); 70 | incrementToNonZero(); 71 | return *this; 72 | } 73 | 74 | using IterBase::value; 75 | 76 | protected: 77 | const SparseView& m_view; 78 | 79 | private: 80 | void incrementToNonZero() 81 | { 82 | while((bool(*this)) && internal::isMuchSmallerThan(value(), m_view.m_reference, m_view.m_epsilon)) 83 | { 84 | IterBase::operator++(); 85 | } 86 | } 87 | }; 88 | 89 | template 90 | const SparseView MatrixBase::sparseView(const Scalar& m_reference, 91 | typename NumTraits::Real m_epsilon) const 92 | { 93 | return SparseView(derived(), m_reference, m_epsilon); 94 | } 95 | 96 | } // end namespace Eigen 97 | 98 | #endif 99 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/StlSupport/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_StlSupport_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_StlSupport_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/StlSupport COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/StlSupport/details.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Gael Guennebaud 5 | // Copyright (C) 2009 Hauke Heibel 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_STL_DETAILS_H 12 | #define EIGEN_STL_DETAILS_H 13 | 14 | #ifndef EIGEN_ALIGNED_ALLOCATOR 15 | #define EIGEN_ALIGNED_ALLOCATOR Eigen::aligned_allocator 16 | #endif 17 | 18 | namespace Eigen { 19 | 20 | // This one is needed to prevent reimplementing the whole std::vector. 21 | template 22 | class aligned_allocator_indirection : public EIGEN_ALIGNED_ALLOCATOR 23 | { 24 | public: 25 | typedef size_t size_type; 26 | typedef ptrdiff_t difference_type; 27 | typedef T* pointer; 28 | typedef const T* const_pointer; 29 | typedef T& reference; 30 | typedef const T& const_reference; 31 | typedef T value_type; 32 | 33 | template 34 | struct rebind 35 | { 36 | typedef aligned_allocator_indirection other; 37 | }; 38 | 39 | aligned_allocator_indirection() {} 40 | aligned_allocator_indirection(const aligned_allocator_indirection& ) : EIGEN_ALIGNED_ALLOCATOR() {} 41 | aligned_allocator_indirection(const EIGEN_ALIGNED_ALLOCATOR& ) {} 42 | template 43 | aligned_allocator_indirection(const aligned_allocator_indirection& ) {} 44 | template 45 | aligned_allocator_indirection(const EIGEN_ALIGNED_ALLOCATOR& ) {} 46 | ~aligned_allocator_indirection() {} 47 | }; 48 | 49 | #ifdef _MSC_VER 50 | 51 | // sometimes, MSVC detects, at compile time, that the argument x 52 | // in std::vector::resize(size_t s,T x) won't be aligned and generate an error 53 | // even if this function is never called. Whence this little wrapper. 54 | #define EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T) \ 55 | typename Eigen::internal::conditional< \ 56 | Eigen::internal::is_arithmetic::value, \ 57 | T, \ 58 | Eigen::internal::workaround_msvc_stl_support \ 59 | >::type 60 | 61 | namespace internal { 62 | template struct workaround_msvc_stl_support : public T 63 | { 64 | inline workaround_msvc_stl_support() : T() {} 65 | inline workaround_msvc_stl_support(const T& other) : T(other) {} 66 | inline operator T& () { return *static_cast(this); } 67 | inline operator const T& () const { return *static_cast(this); } 68 | template 69 | inline T& operator=(const OtherT& other) 70 | { T::operator=(other); return *this; } 71 | inline workaround_msvc_stl_support& operator=(const workaround_msvc_stl_support& other) 72 | { T::operator=(other); return *this; } 73 | }; 74 | } 75 | 76 | #else 77 | 78 | #define EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T) T 79 | 80 | #endif 81 | 82 | } 83 | 84 | #endif // EIGEN_STL_DETAILS_H 85 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/SuperLUSupport/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_SuperLUSupport_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_SuperLUSupport_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/SuperLUSupport COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/UmfPackSupport/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_UmfPackSupport_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_UmfPackSupport_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/UmfPackSupport COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/misc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_misc_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_misc_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/misc COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/misc/Image.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Benoit Jacob 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_MISC_IMAGE_H 11 | #define EIGEN_MISC_IMAGE_H 12 | 13 | namespace Eigen { 14 | 15 | namespace internal { 16 | 17 | /** \class image_retval_base 18 | * 19 | */ 20 | template 21 | struct traits > 22 | { 23 | typedef typename DecompositionType::MatrixType MatrixType; 24 | typedef Matrix< 25 | typename MatrixType::Scalar, 26 | MatrixType::RowsAtCompileTime, // the image is a subspace of the destination space, whose 27 | // dimension is the number of rows of the original matrix 28 | Dynamic, // we don't know at compile time the dimension of the image (the rank) 29 | MatrixType::Options, 30 | MatrixType::MaxRowsAtCompileTime, // the image matrix will consist of columns from the original matrix, 31 | MatrixType::MaxColsAtCompileTime // so it has the same number of rows and at most as many columns. 32 | > ReturnType; 33 | }; 34 | 35 | template struct image_retval_base 36 | : public ReturnByValue > 37 | { 38 | typedef _DecompositionType DecompositionType; 39 | typedef typename DecompositionType::MatrixType MatrixType; 40 | typedef ReturnByValue Base; 41 | typedef typename Base::Index Index; 42 | 43 | image_retval_base(const DecompositionType& dec, const MatrixType& originalMatrix) 44 | : m_dec(dec), m_rank(dec.rank()), 45 | m_cols(m_rank == 0 ? 1 : m_rank), 46 | m_originalMatrix(originalMatrix) 47 | {} 48 | 49 | inline Index rows() const { return m_dec.rows(); } 50 | inline Index cols() const { return m_cols; } 51 | inline Index rank() const { return m_rank; } 52 | inline const DecompositionType& dec() const { return m_dec; } 53 | inline const MatrixType& originalMatrix() const { return m_originalMatrix; } 54 | 55 | template inline void evalTo(Dest& dst) const 56 | { 57 | static_cast*>(this)->evalTo(dst); 58 | } 59 | 60 | protected: 61 | const DecompositionType& m_dec; 62 | Index m_rank, m_cols; 63 | const MatrixType& m_originalMatrix; 64 | }; 65 | 66 | } // end namespace internal 67 | 68 | #define EIGEN_MAKE_IMAGE_HELPERS(DecompositionType) \ 69 | typedef typename DecompositionType::MatrixType MatrixType; \ 70 | typedef typename MatrixType::Scalar Scalar; \ 71 | typedef typename MatrixType::RealScalar RealScalar; \ 72 | typedef typename MatrixType::Index Index; \ 73 | typedef Eigen::internal::image_retval_base Base; \ 74 | using Base::dec; \ 75 | using Base::originalMatrix; \ 76 | using Base::rank; \ 77 | using Base::rows; \ 78 | using Base::cols; \ 79 | image_retval(const DecompositionType& dec, const MatrixType& originalMatrix) \ 80 | : Base(dec, originalMatrix) {} 81 | 82 | } // end namespace Eigen 83 | 84 | #endif // EIGEN_MISC_IMAGE_H 85 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/misc/Kernel.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Benoit Jacob 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_MISC_KERNEL_H 11 | #define EIGEN_MISC_KERNEL_H 12 | 13 | namespace Eigen { 14 | 15 | namespace internal { 16 | 17 | /** \class kernel_retval_base 18 | * 19 | */ 20 | template 21 | struct traits > 22 | { 23 | typedef typename DecompositionType::MatrixType MatrixType; 24 | typedef Matrix< 25 | typename MatrixType::Scalar, 26 | MatrixType::ColsAtCompileTime, // the number of rows in the "kernel matrix" 27 | // is the number of cols of the original matrix 28 | // so that the product "matrix * kernel = zero" makes sense 29 | Dynamic, // we don't know at compile-time the dimension of the kernel 30 | MatrixType::Options, 31 | MatrixType::MaxColsAtCompileTime, // see explanation for 2nd template parameter 32 | MatrixType::MaxColsAtCompileTime // the kernel is a subspace of the domain space, 33 | // whose dimension is the number of columns of the original matrix 34 | > ReturnType; 35 | }; 36 | 37 | template struct kernel_retval_base 38 | : public ReturnByValue > 39 | { 40 | typedef _DecompositionType DecompositionType; 41 | typedef ReturnByValue Base; 42 | typedef typename Base::Index Index; 43 | 44 | kernel_retval_base(const DecompositionType& dec) 45 | : m_dec(dec), 46 | m_rank(dec.rank()), 47 | m_cols(m_rank==dec.cols() ? 1 : dec.cols() - m_rank) 48 | {} 49 | 50 | inline Index rows() const { return m_dec.cols(); } 51 | inline Index cols() const { return m_cols; } 52 | inline Index rank() const { return m_rank; } 53 | inline const DecompositionType& dec() const { return m_dec; } 54 | 55 | template inline void evalTo(Dest& dst) const 56 | { 57 | static_cast*>(this)->evalTo(dst); 58 | } 59 | 60 | protected: 61 | const DecompositionType& m_dec; 62 | Index m_rank, m_cols; 63 | }; 64 | 65 | } // end namespace internal 66 | 67 | #define EIGEN_MAKE_KERNEL_HELPERS(DecompositionType) \ 68 | typedef typename DecompositionType::MatrixType MatrixType; \ 69 | typedef typename MatrixType::Scalar Scalar; \ 70 | typedef typename MatrixType::RealScalar RealScalar; \ 71 | typedef typename MatrixType::Index Index; \ 72 | typedef Eigen::internal::kernel_retval_base Base; \ 73 | using Base::dec; \ 74 | using Base::rank; \ 75 | using Base::rows; \ 76 | using Base::cols; \ 77 | kernel_retval(const DecompositionType& dec) : Base(dec) {} 78 | 79 | } // end namespace Eigen 80 | 81 | #endif // EIGEN_MISC_KERNEL_H 82 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/misc/Solve.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Benoit Jacob 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_MISC_SOLVE_H 11 | #define EIGEN_MISC_SOLVE_H 12 | 13 | namespace Eigen { 14 | 15 | namespace internal { 16 | 17 | /** \class solve_retval_base 18 | * 19 | */ 20 | template 21 | struct traits > 22 | { 23 | typedef typename DecompositionType::MatrixType MatrixType; 24 | typedef Matrix ReturnType; 30 | }; 31 | 32 | template struct solve_retval_base 33 | : public ReturnByValue > 34 | { 35 | typedef typename remove_all::type RhsNestedCleaned; 36 | typedef _DecompositionType DecompositionType; 37 | typedef ReturnByValue Base; 38 | typedef typename Base::Index Index; 39 | 40 | solve_retval_base(const DecompositionType& dec, const Rhs& rhs) 41 | : m_dec(dec), m_rhs(rhs) 42 | {} 43 | 44 | inline Index rows() const { return m_dec.cols(); } 45 | inline Index cols() const { return m_rhs.cols(); } 46 | inline const DecompositionType& dec() const { return m_dec; } 47 | inline const RhsNestedCleaned& rhs() const { return m_rhs; } 48 | 49 | template inline void evalTo(Dest& dst) const 50 | { 51 | static_cast*>(this)->evalTo(dst); 52 | } 53 | 54 | protected: 55 | const DecompositionType& m_dec; 56 | typename Rhs::Nested m_rhs; 57 | }; 58 | 59 | } // end namespace internal 60 | 61 | #define EIGEN_MAKE_SOLVE_HELPERS(DecompositionType,Rhs) \ 62 | typedef typename DecompositionType::MatrixType MatrixType; \ 63 | typedef typename MatrixType::Scalar Scalar; \ 64 | typedef typename MatrixType::RealScalar RealScalar; \ 65 | typedef typename MatrixType::Index Index; \ 66 | typedef Eigen::internal::solve_retval_base Base; \ 67 | using Base::dec; \ 68 | using Base::rhs; \ 69 | using Base::rows; \ 70 | using Base::cols; \ 71 | solve_retval(const DecompositionType& dec, const Rhs& rhs) \ 72 | : Base(dec, rhs) {} 73 | 74 | } // end namespace Eigen 75 | 76 | #endif // EIGEN_MISC_SOLVE_H 77 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/plugins/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_plugins_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_plugins_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/plugins COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/plugins/CommonCwiseBinaryOps.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2009 Gael Guennebaud 5 | // Copyright (C) 2006-2008 Benoit Jacob 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | // This file is a base class plugin containing common coefficient wise functions. 12 | 13 | /** \returns an expression of the difference of \c *this and \a other 14 | * 15 | * \note If you want to substract a given scalar from all coefficients, see Cwise::operator-(). 16 | * 17 | * \sa class CwiseBinaryOp, operator-=() 18 | */ 19 | EIGEN_MAKE_CWISE_BINARY_OP(operator-,internal::scalar_difference_op) 20 | 21 | /** \returns an expression of the sum of \c *this and \a other 22 | * 23 | * \note If you want to add a given scalar to all coefficients, see Cwise::operator+(). 24 | * 25 | * \sa class CwiseBinaryOp, operator+=() 26 | */ 27 | EIGEN_MAKE_CWISE_BINARY_OP(operator+,internal::scalar_sum_op) 28 | 29 | /** \returns an expression of a custom coefficient-wise operator \a func of *this and \a other 30 | * 31 | * The template parameter \a CustomBinaryOp is the type of the functor 32 | * of the custom operator (see class CwiseBinaryOp for an example) 33 | * 34 | * Here is an example illustrating the use of custom functors: 35 | * \include class_CwiseBinaryOp.cpp 36 | * Output: \verbinclude class_CwiseBinaryOp.out 37 | * 38 | * \sa class CwiseBinaryOp, operator+(), operator-(), cwiseProduct() 39 | */ 40 | template 41 | EIGEN_STRONG_INLINE const CwiseBinaryOp 42 | binaryExpr(const EIGEN_CURRENT_STORAGE_BASE_CLASS &other, const CustomBinaryOp& func = CustomBinaryOp()) const 43 | { 44 | return CwiseBinaryOp(derived(), other.derived(), func); 45 | } 46 | 47 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/Eigen/src/plugins/MatrixCwiseUnaryOps.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2009 Gael Guennebaud 5 | // Copyright (C) 2006-2008 Benoit Jacob 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | // This file is a base class plugin containing matrix specifics coefficient wise functions. 12 | 13 | /** \returns an expression of the coefficient-wise absolute value of \c *this 14 | * 15 | * Example: \include MatrixBase_cwiseAbs.cpp 16 | * Output: \verbinclude MatrixBase_cwiseAbs.out 17 | * 18 | * \sa cwiseAbs2() 19 | */ 20 | EIGEN_STRONG_INLINE const CwiseUnaryOp, const Derived> 21 | cwiseAbs() const { return derived(); } 22 | 23 | /** \returns an expression of the coefficient-wise squared absolute value of \c *this 24 | * 25 | * Example: \include MatrixBase_cwiseAbs2.cpp 26 | * Output: \verbinclude MatrixBase_cwiseAbs2.out 27 | * 28 | * \sa cwiseAbs() 29 | */ 30 | EIGEN_STRONG_INLINE const CwiseUnaryOp, const Derived> 31 | cwiseAbs2() const { return derived(); } 32 | 33 | /** \returns an expression of the coefficient-wise square root of *this. 34 | * 35 | * Example: \include MatrixBase_cwiseSqrt.cpp 36 | * Output: \verbinclude MatrixBase_cwiseSqrt.out 37 | * 38 | * \sa cwisePow(), cwiseSquare() 39 | */ 40 | inline const CwiseUnaryOp, const Derived> 41 | cwiseSqrt() const { return derived(); } 42 | 43 | /** \returns an expression of the coefficient-wise inverse of *this. 44 | * 45 | * Example: \include MatrixBase_cwiseInverse.cpp 46 | * Output: \verbinclude MatrixBase_cwiseInverse.out 47 | * 48 | * \sa cwiseProduct() 49 | */ 50 | inline const CwiseUnaryOp, const Derived> 51 | cwiseInverse() const { return derived(); } 52 | 53 | /** \returns an expression of the coefficient-wise == operator of \c *this and a scalar \a s 54 | * 55 | * \warning this performs an exact comparison, which is generally a bad idea with floating-point types. 56 | * In order to check for equality between two vectors or matrices with floating-point coefficients, it is 57 | * generally a far better idea to use a fuzzy comparison as provided by isApprox() and 58 | * isMuchSmallerThan(). 59 | * 60 | * \sa cwiseEqual(const MatrixBase &) const 61 | */ 62 | inline const CwiseUnaryOp >, const Derived> 63 | cwiseEqual(const Scalar& s) const 64 | { 65 | return CwiseUnaryOp >,const Derived> 66 | (derived(), std::bind1st(std::equal_to(), s)); 67 | } 68 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/objective.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2013, Philipp Krähenbühl 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the Stanford University nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY Philipp Krähenbühl ''AS IS'' AND ANY 17 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL Philipp Krähenbühl BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #pragma once 28 | #include 29 | using namespace Eigen; 30 | 31 | typedef Matrix VectorXs; 32 | 33 | /**** Learning Objective ****/ 34 | class ObjectiveFunction { 35 | public: 36 | virtual ~ObjectiveFunction(); 37 | // Evaluate an objective function L(Q) and its gradient \nabla L(Q) 38 | // Return the objetive value L(Q) and set gradient[i*M+l] to Q_i(l)*\partial L / \partial Q_i(l) 39 | // We use the scales gradient here for numerical reasons! 40 | virtual double evaluate( MatrixXf & d_mul_Q, const MatrixXf & Q ) const = 0; 41 | }; 42 | // Log likelihood objective 43 | class LogLikelihood: public ObjectiveFunction { 44 | protected: 45 | VectorXs gt_; 46 | float robust_; 47 | public: 48 | // Give a ground_truth labeling of size N, optional use a robustness term robust>0 49 | LogLikelihood( const VectorXs & gt, float robust=0 ); 50 | // The objective value is sum_i log( Q_i( ground_truth_i ) + robust ) 51 | virtual double evaluate( MatrixXf & d_mul_Q, const MatrixXf & Q ) const; 52 | }; 53 | // Log likelihood objective 54 | class Hamming: public ObjectiveFunction { 55 | protected: 56 | VectorXs gt_; 57 | VectorXf class_weight_; 58 | public: 59 | // Give a ground_truth labeling of size N, reweight classes to cope with an invariance 60 | // weight by w_c = pow( #labels_c, -class_weight_pow ) 61 | Hamming( const VectorXs & gt, float class_weight_pow=0 ); 62 | Hamming( const VectorXs & gt, const VectorXf & class_weight ); 63 | // The objective value is sum_i Q_i( ground_truth_i ) 64 | virtual double evaluate( MatrixXf & d_mul_Q, const MatrixXf & Q ) const; 65 | }; 66 | // Intersection over union objective 67 | class IntersectionOverUnion: public ObjectiveFunction { 68 | protected: 69 | VectorXs gt_; 70 | public: 71 | // Give a ground_truth labeling of size N 72 | IntersectionOverUnion( const VectorXs & gt ); 73 | // The objective value is sum_l ( sum_i [ground_truth_i == l] Q_i( l ) ) / ( |ground_truth_i == l| + sum_i [ground_truth_i != l] Q_i( l ) ) 74 | virtual double evaluate( MatrixXf & d_mul_Q, const MatrixXf & Q ) const; 75 | }; 76 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/optimization.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2013, Philipp Krähenbühl 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the Stanford University nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY Philipp Krähenbühl ''AS IS'' AND ANY 17 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL Philipp Krähenbühl BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #pragma once 28 | #include 29 | using namespace Eigen; 30 | 31 | class EnergyFunction { 32 | public: 33 | virtual VectorXf initialValue() = 0; 34 | virtual double gradient( const VectorXf & x, VectorXf & dx ) = 0; 35 | }; 36 | VectorXf minimizeLBFGS( EnergyFunction & efun, int restart=0, bool verbose=false ); 37 | VectorXf numericGradient( EnergyFunction & efun, const VectorXf & x, float EPS=1e-3 ); 38 | VectorXf gradient( EnergyFunction & efun, const VectorXf & x ); 39 | double gradCheck( EnergyFunction & efun, const VectorXf & x, float EPS=1e-3 ); 40 | VectorXf computeFunction( EnergyFunction & efun, const VectorXf & x, const VectorXf & dx, int n_samples = 100 ); 41 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/pairwise.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2013, Philipp Krähenbühl 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the Stanford University nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY Philipp Krähenbühl ''AS IS'' AND ANY 17 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL Philipp Krähenbühl BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #pragma once 28 | #include "labelcompatibility.h" 29 | #include "permutohedral.h" 30 | 31 | // The filter in the dense CRF can be normalized in a few different ways 32 | enum NormalizationType { 33 | NO_NORMALIZATION, // No normalization whatsoever (will lead to a substantial approximation error) 34 | NORMALIZE_BEFORE, // Normalize before filtering (Not used, just there for completeness) 35 | NORMALIZE_AFTER, // Normalize after filtering (original normalization in NIPS 11 work) 36 | NORMALIZE_SYMMETRIC, // Normalize before and after (ICML 2013, low approximation error and preserves the symmetry of CRF) 37 | }; 38 | enum KernelType { 39 | CONST_KERNEL, // Constant kernel, no parameters 40 | DIAG_KERNEL, // Diagonal kernel (scaling features) 41 | FULL_KERNEL, // Full kernel matrix (arbitrary squared matrix) 42 | }; 43 | 44 | class Kernel { 45 | public: 46 | virtual ~Kernel(); 47 | virtual void apply( MatrixXf & out, const MatrixXf & Q ) const = 0; 48 | virtual void applyTranspose( MatrixXf & out, const MatrixXf & Q ) const = 0; 49 | virtual VectorXf parameters() const = 0; 50 | virtual void setParameters( const VectorXf & p ) = 0; 51 | virtual VectorXf gradient( const MatrixXf & b, const MatrixXf & Q ) const = 0; 52 | }; 53 | 54 | class PairwisePotential{ 55 | protected: 56 | LabelCompatibility * compatibility_; 57 | Kernel * kernel_; 58 | PairwisePotential( const PairwisePotential &o ){} 59 | void filter( MatrixXf & out, const MatrixXf & in, bool transpose=false ) const; 60 | public: 61 | virtual ~PairwisePotential(); 62 | PairwisePotential(const MatrixXf & features, LabelCompatibility * compatibility, KernelType ktype=CONST_KERNEL, NormalizationType ntype=NORMALIZE_SYMMETRIC); 63 | void apply(MatrixXf & out, const MatrixXf & Q) const; 64 | void applyTranspose(MatrixXf & out, const MatrixXf & Q) const; 65 | 66 | // Get the parameters 67 | virtual VectorXf parameters() const; 68 | virtual VectorXf kernelParameters() const; 69 | virtual void setParameters( const VectorXf & v ); 70 | virtual void setKernelParameters( const VectorXf & v ); 71 | virtual VectorXf gradient( const MatrixXf & b, const MatrixXf & Q ) const; 72 | virtual VectorXf kernelGradient( const MatrixXf & b, const MatrixXf & Q ) const; 73 | }; -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/permutohedral.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2013, Philipp Krähenbühl 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the Stanford University nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY Philipp Krähenbühl ''AS IS'' AND ANY 17 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL Philipp Krähenbühl BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #pragma once 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | using namespace Eigen; 36 | 37 | /************************************************/ 38 | /*** Permutohedral Lattice ***/ 39 | /************************************************/ 40 | 41 | class Permutohedral 42 | { 43 | protected: 44 | struct Neighbors{ 45 | int n1, n2; 46 | Neighbors( int n1=0, int n2=0 ):n1(n1),n2(n2){ 47 | } 48 | }; 49 | std::vector offset_, rank_; 50 | std::vector barycentric_; 51 | std::vector blur_neighbors_; 52 | // Number of elements, size of sparse discretized space, dimension of features 53 | int N_, M_, d_; 54 | void sseCompute ( float* out, const float* in, int value_size, bool reverse=false ) const; 55 | void seqCompute ( float* out, const float* in, int value_size, bool reverse=false ) const; 56 | public: 57 | Permutohedral(); 58 | void init ( const MatrixXf & features ); 59 | MatrixXf compute ( const MatrixXf & v, bool reverse=false ) const; 60 | void compute ( MatrixXf & out, const MatrixXf & in, bool reverse=false ) const; 61 | // Compute the gradient of a^T K b 62 | void gradient ( float* df, const float * a, const float* b, int value_size ) const; 63 | }; 64 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/include/unary.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2013, Philipp Krähenbühl 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the Stanford University nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY Philipp Krähenbühl ''AS IS'' AND ANY 17 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL Philipp Krähenbühl BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #pragma once 28 | #include 29 | using namespace Eigen; 30 | 31 | class UnaryEnergy { 32 | public: 33 | virtual ~UnaryEnergy(); 34 | // Set the unary 35 | virtual MatrixXf get( ) const = 0; 36 | // Gradient computation 37 | virtual VectorXf parameters() const; 38 | virtual void setParameters( const VectorXf & v ); 39 | virtual VectorXf gradient( const MatrixXf & b ) const; 40 | }; 41 | class ConstUnaryEnergy: public UnaryEnergy { 42 | protected: 43 | MatrixXf unary_; 44 | public: 45 | ConstUnaryEnergy( const MatrixXf & unary ); 46 | virtual MatrixXf get( ) const; 47 | }; 48 | class LogisticUnaryEnergy: public UnaryEnergy { 49 | protected: 50 | MatrixXf L_, f_; 51 | public: 52 | LogisticUnaryEnergy( const MatrixXf & L, const MatrixXf & feature ); 53 | virtual MatrixXf get( ) const; 54 | virtual VectorXf parameters() const; 55 | virtual void setParameters( const VectorXf & v ); 56 | virtual VectorXf gradient( const MatrixXf & b ) const; 57 | }; 58 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories( ../external/liblbfgs/include ../external/ ) 2 | 3 | add_library( densecrf util.cpp permutohedral.cpp unary.cpp pairwise.cpp objective.cpp densecrf.cpp labelcompatibility.cpp ) 4 | 5 | add_library( optimization optimization.cpp ) 6 | target_link_libraries( optimization lbfgs ) 7 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/src/unary.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2013, Philipp Krähenbühl 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the Stanford University nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY Philipp Krähenbühl ''AS IS'' AND ANY 17 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL Philipp Krähenbühl BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #include "unary.h" 28 | 29 | 30 | UnaryEnergy::~UnaryEnergy() { 31 | } 32 | VectorXf UnaryEnergy::parameters() const { 33 | return VectorXf(); 34 | } 35 | void UnaryEnergy::setParameters( const VectorXf & v ) { 36 | } 37 | VectorXf UnaryEnergy::gradient( const MatrixXf & b ) const { 38 | return VectorXf(); 39 | } 40 | 41 | 42 | ConstUnaryEnergy::ConstUnaryEnergy( const MatrixXf & u ):unary_(u) { 43 | } 44 | MatrixXf ConstUnaryEnergy::get() const { 45 | return unary_; 46 | } 47 | 48 | LogisticUnaryEnergy::LogisticUnaryEnergy( const MatrixXf & L, const MatrixXf & f ):L_(L),f_(f) { 49 | } 50 | MatrixXf LogisticUnaryEnergy::get() const { 51 | return L_*f_; 52 | } 53 | VectorXf LogisticUnaryEnergy::parameters() const { 54 | MatrixXf l = L_; 55 | l.resize( l.cols()*l.rows(), 1 ); 56 | return l; 57 | } 58 | void LogisticUnaryEnergy::setParameters( const VectorXf & v ) { 59 | assert( v.rows() == L_.cols()*L_.rows() ); 60 | MatrixXf l = v; 61 | l.resizeLike( L_ ); 62 | L_ = l; 63 | } 64 | VectorXf LogisticUnaryEnergy::gradient( const MatrixXf & b ) const { 65 | MatrixXf g = b*f_.transpose(); 66 | g.resize( g.cols()*g.rows(), 1 ); 67 | return g; 68 | } 69 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/src/util.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2013, Philipp Krähenbühl 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the Stanford University nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY Philipp Krähenbühl ''AS IS'' AND ANY 17 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL Philipp Krähenbühl BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include "util.h" 29 | #include 30 | 31 | float* allocate(size_t N) { 32 | float * r = NULL; 33 | if (N>0) 34 | #ifdef SSE_DENSE_CRF 35 | r = (float*)_mm_malloc( N*sizeof(float)+16, 16 ); 36 | #else 37 | r = new float[N]; 38 | #endif 39 | memset( r, 0, sizeof(float)*N); 40 | return r; 41 | } 42 | void deallocate(float*& ptr) { 43 | if (ptr) 44 | #ifdef SSE_DENSE_CRF 45 | _mm_free( ptr ); 46 | #else 47 | delete[] ptr; 48 | #endif 49 | ptr = NULL; 50 | } 51 | -------------------------------------------------------------------------------- /pydensecrf/densecrf/src/util.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2013, Philipp Krähenbühl 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the Stanford University nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY Philipp Krähenbühl ''AS IS'' AND ANY 17 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL Philipp Krähenbühl BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #pragma once 29 | 30 | #include "densecrf.h" 31 | #include "permutohedral.h" 32 | 33 | #ifdef __SSE__ 34 | # define SSE_DENSE_CRF 35 | #endif 36 | 37 | #if defined(SSE_DENSE_CRF) 38 | # include 39 | # include 40 | #endif 41 | 42 | // Memory handling switches between SSE and new 43 | float* allocate ( size_t N ) ; 44 | void deallocate ( float *& ptr ) ; 45 | -------------------------------------------------------------------------------- /pydensecrf/eigen.pxd: -------------------------------------------------------------------------------- 1 | cdef extern from "Eigen/Dense": 2 | cdef cppclass c_MatrixXf "Eigen::MatrixXf": 3 | float* data() 4 | Py_ssize_t cols() 5 | Py_ssize_t rows() 6 | 7 | cdef cppclass c_VectorXf "Eigen::VectorXf": 8 | float* data() 9 | Py_ssize_t size() 10 | 11 | 12 | cdef extern from "eigen_impl.cpp": 13 | c_VectorXf c_buf2vecf "buf2vecf" (float *mem, Py_ssize_t n) 14 | void c_vecf2buf "vecf2buf" (const c_VectorXf &mat, float *buf) 15 | c_MatrixXf c_buf2matf "buf2matf" (float *mem, Py_ssize_t h, Py_ssize_t w) 16 | void c_matf2buf "matf2buf" (const c_MatrixXf &mat, float *buf) 17 | 18 | 19 | cdef class VectorXf: 20 | cdef c_VectorXf v 21 | cdef Py_ssize_t shape[1] 22 | cdef Py_ssize_t strides[1] 23 | 24 | cdef VectorXf wrap(self, c_VectorXf v) 25 | 26 | cdef c_VectorXf c_vectorXf(float[::1] arr) 27 | 28 | 29 | cdef class MatrixXf: 30 | cdef c_MatrixXf m 31 | cdef Py_ssize_t shape[2] 32 | cdef Py_ssize_t strides[2] 33 | 34 | cdef MatrixXf wrap(self, c_MatrixXf m) 35 | 36 | cdef c_MatrixXf c_matrixXf(float[:,::1] arr) 37 | -------------------------------------------------------------------------------- /pydensecrf/eigen.pyx: -------------------------------------------------------------------------------- 1 | # distutils: language = c++ 2 | # distutils: sources = pydensecrf/eigen_impl.cpp 3 | # distutils: include_dirs = pydensecrf/densecrf/include 4 | 5 | 6 | # [::1] means we want a C-contiguous array. 7 | cdef c_VectorXf c_vectorXf(float[::1] arr): 8 | return c_buf2vecf(&arr[0], arr.shape[0]) 9 | 10 | 11 | def vectorXf(float[::1] arr not None): 12 | return VectorXf().wrap(c_vectorXf(arr)) 13 | 14 | 15 | cdef class VectorXf: 16 | 17 | def __cinit__(self): 18 | # Can't directly initialize v on construction because arguments 19 | # passed to `__cinit__` need to be Python objects. Refs: 20 | # - https://mail.python.org/pipermail/cython-devel/2012-June/002734.html 21 | # - https://kaushikghose.wordpress.com/2015/03/08/cython-__cinit__/ 22 | self.shape = (0,) 23 | self.strides = (0,) 24 | 25 | cdef VectorXf wrap(self, c_VectorXf v): 26 | self.v = v 27 | self.shape[0] = v.size() 28 | self.strides[0] = sizeof(float) 29 | return self 30 | 31 | # http://docs.cython.org/src/userguide/buffer.html 32 | def __getbuffer__(self, Py_buffer *buf, int flags): 33 | buf.buf = self.v.data() 34 | buf.format = 'f' 35 | buf.internal = NULL 36 | buf.itemsize = sizeof(float) 37 | buf.len = self.shape[0] * buf.itemsize 38 | buf.ndim = 1 39 | buf.obj = self 40 | buf.readonly = 0 41 | buf.shape = self.shape 42 | buf.strides = self.strides 43 | buf.suboffsets = NULL 44 | 45 | def __releasebuffer__(self, Py_buffer *buf): 46 | pass 47 | 48 | 49 | # [:,::1] means we want a C-contiguous array. 50 | cdef c_MatrixXf c_matrixXf(float[:,::1] arr): 51 | return c_buf2matf(&arr[0,0], arr.shape[0], arr.shape[1]) 52 | 53 | 54 | def matrixXf(float[:,::1] arr not None): 55 | return MatrixXf().wrap(c_matrixXf(arr)) 56 | 57 | 58 | cdef class MatrixXf: 59 | 60 | def __cinit__(self): 61 | # Can't directly initialize m on construction because arguments 62 | # passed to `__cinit__` need to be Python objects. Refs: 63 | # - https://mail.python.org/pipermail/cython-devel/2012-June/002734.html 64 | # - https://kaushikghose.wordpress.com/2015/03/08/cython-__cinit__/ 65 | self.shape = (0,0) 66 | self.strides = (0,0) 67 | 68 | cdef MatrixXf wrap(self, c_MatrixXf m): 69 | self.m = m 70 | self.shape = (m.rows(), m.cols()) 71 | 72 | # From http://docs.cython.org/src/userguide/buffer.html: 73 | # > Stride 1 is the distance, in bytes, between two items in a row; 74 | # > this is the distance between two adjacent items in the vector. 75 | # > Stride 0 is the distance between the first elements of adjacent rows. 76 | # 77 | # Since eigen's matrix (MatrixXf) is col-major, we've got: 78 | self.strides[0] = sizeof(float) 79 | self.strides[1] = self.shape[0] * self.strides[0] 80 | 81 | return self 82 | 83 | # http://docs.cython.org/src/userguide/buffer.html 84 | def __getbuffer__(self, Py_buffer *buf, int flags): 85 | buf.buf = self.m.data() 86 | buf.format = 'f' 87 | buf.internal = NULL 88 | buf.itemsize = sizeof(float) 89 | buf.len = self.shape[0] * self.shape[1] * buf.itemsize 90 | buf.ndim = 2 91 | buf.obj = self 92 | buf.readonly = 0 93 | buf.shape = self.shape 94 | buf.strides = self.strides 95 | buf.suboffsets = NULL 96 | 97 | def __releasebuffer__(self, Py_buffer *buf): 98 | pass 99 | -------------------------------------------------------------------------------- /pydensecrf/eigen_impl.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include // for Py_ssize_t 5 | 6 | typedef Eigen::Matrix NumpyVecF; 7 | 8 | static Eigen::VectorXf buf2vecf(float *mem, Py_ssize_t n) 9 | { 10 | return Eigen::Map(mem, n); 11 | } 12 | 13 | static void vecf2buf(const Eigen::VectorXf& vec, float *mem) 14 | { 15 | Eigen::Map(mem, vec.size()) = vec; 16 | } 17 | 18 | // In Python, the default is row-major (C) while in Eigen it's ColMajor (F). 19 | typedef Eigen::Matrix NumpyMatF; 20 | 21 | static Eigen::MatrixXf buf2matf(float *mem, Py_ssize_t h, Py_ssize_t w) 22 | { 23 | // This does the conversion, so very likely makes a copy. 24 | return Eigen::Map(mem, h, w); 25 | } 26 | 27 | static void matf2buf(const Eigen::MatrixXf& mat, float *mem) 28 | { 29 | Eigen::Map(mem, mat.rows(), mat.cols()) = mat; 30 | } 31 | 32 | -------------------------------------------------------------------------------- /pydensecrf/test.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import densecrf as dcrf 3 | 4 | # d = densecrf.PyDenseCRF2D(3, 2, 3) 5 | # U = np.full((3,6), 0.1, dtype=np.float32) 6 | # U[0,0] = U[1,1] = U[2,2] = U[0,3] = U[1,4] = U[2,5] = 0.8 7 | 8 | d = dcrf.DenseCRF2D(10, 10, 2) 9 | 10 | U1 = np.zeros((10, 10), dtype=np.float32) 11 | U1[:,[0,-1]] = U1[[0,-1],:] = 1 12 | 13 | U2 = np.zeros((10, 10), dtype=np.float32) 14 | U2[4:7,4:7] = 1 15 | 16 | U = np.vstack([U1.flat, U2.flat]) 17 | Up = (U + 1) / (np.sum(U, axis=0) + 2) 18 | 19 | img = np.zeros((10,10,3), dtype=np.uint8) 20 | img[2:8,2:8,:] = 255 21 | 22 | d.setUnaryEnergy(-np.log(Up)) 23 | #d.setUnaryEnergy(PyConstUnary(-np.log(Up))) 24 | 25 | d.addPairwiseBilateral(2, 2, img, 3) 26 | # d.addPairwiseBilateral(2, 2, img, 3) 27 | np.argmax(d.inference(10), axis=0).reshape(10,10) 28 | -------------------------------------------------------------------------------- /pydensecrf/test_eigen.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import eigen as e 3 | 4 | V = np.random.randn(3).astype(np.float32) 5 | M = np.random.randn(3,3).astype(np.float32) 6 | 7 | foo = e.vectorXf(V) 8 | assert np.all(np.array(foo) == V) 9 | 10 | foo = e.matrixXf(M) 11 | assert np.all(np.array(foo) == M) 12 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | # coding: UTF-8 2 | from distutils.core import setup 3 | from Cython.Build import cythonize 4 | 5 | # TODO: 6 | # - Wrap learning. 7 | # - Make LabelCompatibility, UnaryEnergy, PairwisePotential extensible? (Maybe overkill?) 8 | 9 | setup( 10 | name="pydensecrf", 11 | version="0.1", 12 | description="A python interface to Philipp Krähenbühl's fully-connected CRF code.", 13 | author="Lucas Beyer", 14 | author_email="lucasb.eyer.be@gmail.com", 15 | url="http://github.com/lucasb-eyer/pydensecrf", 16 | ext_modules=cythonize(['pydensecrf/eigen.pyx', 'pydensecrf/densecrf.pyx']), 17 | packages=["pydensecrf"] 18 | ) 19 | 20 | --------------------------------------------------------------------------------