├── .clang-format ├── .gitignore ├── BSplineRenderer.qrc ├── CMakeLists.txt ├── Libs ├── Eigen │ ├── Cholesky │ ├── CholmodSupport │ ├── Core │ ├── Dense │ ├── Eigen │ ├── Eigenvalues │ ├── Geometry │ ├── Householder │ ├── IterativeLinearSolvers │ ├── Jacobi │ ├── KLUSupport │ ├── LU │ ├── MetisSupport │ ├── OrderingMethods │ ├── PaStiXSupport │ ├── PardisoSupport │ ├── QR │ ├── QtAlignedMalloc │ ├── SPQRSupport │ ├── SVD │ ├── Sparse │ ├── SparseCholesky │ ├── SparseCore │ ├── SparseLU │ ├── SparseQR │ ├── StdDeque │ ├── StdList │ ├── StdVector │ ├── SuperLUSupport │ ├── UmfPackSupport │ └── src │ │ ├── Cholesky │ │ ├── LDLT.h │ │ ├── LLT.h │ │ └── LLT_LAPACKE.h │ │ ├── CholmodSupport │ │ └── CholmodSupport.h │ │ ├── Core │ │ ├── ArithmeticSequence.h │ │ ├── Array.h │ │ ├── ArrayBase.h │ │ ├── ArrayWrapper.h │ │ ├── Assign.h │ │ ├── AssignEvaluator.h │ │ ├── Assign_MKL.h │ │ ├── BandMatrix.h │ │ ├── Block.h │ │ ├── BooleanRedux.h │ │ ├── CommaInitializer.h │ │ ├── ConditionEstimator.h │ │ ├── CoreEvaluators.h │ │ ├── CoreIterators.h │ │ ├── CwiseBinaryOp.h │ │ ├── CwiseNullaryOp.h │ │ ├── CwiseTernaryOp.h │ │ ├── CwiseUnaryOp.h │ │ ├── CwiseUnaryView.h │ │ ├── DenseBase.h │ │ ├── DenseCoeffsBase.h │ │ ├── DenseStorage.h │ │ ├── Diagonal.h │ │ ├── DiagonalMatrix.h │ │ ├── DiagonalProduct.h │ │ ├── Dot.h │ │ ├── EigenBase.h │ │ ├── ForceAlignedAccess.h │ │ ├── Fuzzy.h │ │ ├── GeneralProduct.h │ │ ├── GenericPacketMath.h │ │ ├── GlobalFunctions.h │ │ ├── IO.h │ │ ├── IndexedView.h │ │ ├── Inverse.h │ │ ├── Map.h │ │ ├── MapBase.h │ │ ├── MathFunctions.h │ │ ├── MathFunctionsImpl.h │ │ ├── Matrix.h │ │ ├── MatrixBase.h │ │ ├── NestByValue.h │ │ ├── NoAlias.h │ │ ├── NumTraits.h │ │ ├── PartialReduxEvaluator.h │ │ ├── PermutationMatrix.h │ │ ├── PlainObjectBase.h │ │ ├── Product.h │ │ ├── ProductEvaluators.h │ │ ├── Random.h │ │ ├── Redux.h │ │ ├── Ref.h │ │ ├── Replicate.h │ │ ├── Reshaped.h │ │ ├── ReturnByValue.h │ │ ├── Reverse.h │ │ ├── Select.h │ │ ├── SelfAdjointView.h │ │ ├── SelfCwiseBinaryOp.h │ │ ├── Solve.h │ │ ├── SolveTriangular.h │ │ ├── SolverBase.h │ │ ├── StableNorm.h │ │ ├── StlIterators.h │ │ ├── Stride.h │ │ ├── Swap.h │ │ ├── Transpose.h │ │ ├── Transpositions.h │ │ ├── TriangularMatrix.h │ │ ├── VectorBlock.h │ │ ├── VectorwiseOp.h │ │ ├── Visitor.h │ │ ├── arch │ │ │ ├── AVX │ │ │ │ ├── Complex.h │ │ │ │ ├── MathFunctions.h │ │ │ │ ├── PacketMath.h │ │ │ │ └── TypeCasting.h │ │ │ ├── AVX512 │ │ │ │ ├── Complex.h │ │ │ │ ├── MathFunctions.h │ │ │ │ ├── PacketMath.h │ │ │ │ └── TypeCasting.h │ │ │ ├── AltiVec │ │ │ │ ├── Complex.h │ │ │ │ ├── MathFunctions.h │ │ │ │ ├── MatrixProduct.h │ │ │ │ ├── MatrixProductCommon.h │ │ │ │ ├── MatrixProductMMA.h │ │ │ │ └── PacketMath.h │ │ │ ├── CUDA │ │ │ │ └── Complex.h │ │ │ ├── Default │ │ │ │ ├── BFloat16.h │ │ │ │ ├── ConjHelper.h │ │ │ │ ├── GenericPacketMathFunctions.h │ │ │ │ ├── GenericPacketMathFunctionsFwd.h │ │ │ │ ├── Half.h │ │ │ │ ├── Settings.h │ │ │ │ └── TypeCasting.h │ │ │ ├── GPU │ │ │ │ ├── MathFunctions.h │ │ │ │ ├── PacketMath.h │ │ │ │ └── TypeCasting.h │ │ │ ├── HIP │ │ │ │ └── hcc │ │ │ │ │ └── math_constants.h │ │ │ ├── MSA │ │ │ │ ├── Complex.h │ │ │ │ ├── MathFunctions.h │ │ │ │ └── PacketMath.h │ │ │ ├── NEON │ │ │ │ ├── Complex.h │ │ │ │ ├── GeneralBlockPanelKernel.h │ │ │ │ ├── MathFunctions.h │ │ │ │ ├── PacketMath.h │ │ │ │ └── TypeCasting.h │ │ │ ├── SSE │ │ │ │ ├── Complex.h │ │ │ │ ├── MathFunctions.h │ │ │ │ ├── PacketMath.h │ │ │ │ └── TypeCasting.h │ │ │ ├── SVE │ │ │ │ ├── MathFunctions.h │ │ │ │ ├── PacketMath.h │ │ │ │ └── TypeCasting.h │ │ │ ├── SYCL │ │ │ │ ├── InteropHeaders.h │ │ │ │ ├── MathFunctions.h │ │ │ │ ├── PacketMath.h │ │ │ │ ├── SyclMemoryModel.h │ │ │ │ └── TypeCasting.h │ │ │ └── ZVector │ │ │ │ ├── Complex.h │ │ │ │ ├── MathFunctions.h │ │ │ │ └── PacketMath.h │ │ ├── functors │ │ │ ├── AssignmentFunctors.h │ │ │ ├── BinaryFunctors.h │ │ │ ├── NullaryFunctors.h │ │ │ ├── StlFunctors.h │ │ │ ├── TernaryFunctors.h │ │ │ └── UnaryFunctors.h │ │ ├── products │ │ │ ├── GeneralBlockPanelKernel.h │ │ │ ├── GeneralMatrixMatrix.h │ │ │ ├── GeneralMatrixMatrixTriangular.h │ │ │ ├── GeneralMatrixMatrixTriangular_BLAS.h │ │ │ ├── GeneralMatrixMatrix_BLAS.h │ │ │ ├── GeneralMatrixVector.h │ │ │ ├── GeneralMatrixVector_BLAS.h │ │ │ ├── Parallelizer.h │ │ │ ├── SelfadjointMatrixMatrix.h │ │ │ ├── SelfadjointMatrixMatrix_BLAS.h │ │ │ ├── SelfadjointMatrixVector.h │ │ │ ├── SelfadjointMatrixVector_BLAS.h │ │ │ ├── SelfadjointProduct.h │ │ │ ├── SelfadjointRank2Update.h │ │ │ ├── TriangularMatrixMatrix.h │ │ │ ├── TriangularMatrixMatrix_BLAS.h │ │ │ ├── TriangularMatrixVector.h │ │ │ ├── TriangularMatrixVector_BLAS.h │ │ │ ├── TriangularSolverMatrix.h │ │ │ ├── TriangularSolverMatrix_BLAS.h │ │ │ └── TriangularSolverVector.h │ │ └── util │ │ │ ├── BlasUtil.h │ │ │ ├── ConfigureVectorization.h │ │ │ ├── Constants.h │ │ │ ├── DisableStupidWarnings.h │ │ │ ├── ForwardDeclarations.h │ │ │ ├── IndexedViewHelper.h │ │ │ ├── IntegralConstant.h │ │ │ ├── MKL_support.h │ │ │ ├── Macros.h │ │ │ ├── Memory.h │ │ │ ├── Meta.h │ │ │ ├── NonMPL2.h │ │ │ ├── ReenableStupidWarnings.h │ │ │ ├── ReshapedHelper.h │ │ │ ├── StaticAssert.h │ │ │ ├── SymbolicIndex.h │ │ │ └── XprHelper.h │ │ ├── Eigenvalues │ │ ├── ComplexEigenSolver.h │ │ ├── ComplexSchur.h │ │ ├── ComplexSchur_LAPACKE.h │ │ ├── EigenSolver.h │ │ ├── GeneralizedEigenSolver.h │ │ ├── GeneralizedSelfAdjointEigenSolver.h │ │ ├── HessenbergDecomposition.h │ │ ├── MatrixBaseEigenvalues.h │ │ ├── RealQZ.h │ │ ├── RealSchur.h │ │ ├── RealSchur_LAPACKE.h │ │ ├── SelfAdjointEigenSolver.h │ │ ├── SelfAdjointEigenSolver_LAPACKE.h │ │ └── Tridiagonalization.h │ │ ├── Geometry │ │ ├── AlignedBox.h │ │ ├── AngleAxis.h │ │ ├── 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 │ │ │ └── Geometry_SIMD.h │ │ ├── Householder │ │ ├── BlockHouseholder.h │ │ ├── Householder.h │ │ └── HouseholderSequence.h │ │ ├── IterativeLinearSolvers │ │ ├── BasicPreconditioners.h │ │ ├── BiCGSTAB.h │ │ ├── ConjugateGradient.h │ │ ├── IncompleteCholesky.h │ │ ├── IncompleteLUT.h │ │ ├── IterativeSolverBase.h │ │ ├── LeastSquareConjugateGradient.h │ │ └── SolveWithGuess.h │ │ ├── Jacobi │ │ └── Jacobi.h │ │ ├── KLUSupport │ │ └── KLUSupport.h │ │ ├── LU │ │ ├── Determinant.h │ │ ├── FullPivLU.h │ │ ├── InverseImpl.h │ │ ├── PartialPivLU.h │ │ ├── PartialPivLU_LAPACKE.h │ │ └── arch │ │ │ └── InverseSize4.h │ │ ├── MetisSupport │ │ └── MetisSupport.h │ │ ├── OrderingMethods │ │ ├── Amd.h │ │ ├── Eigen_Colamd.h │ │ └── Ordering.h │ │ ├── PaStiXSupport │ │ └── PaStiXSupport.h │ │ ├── PardisoSupport │ │ └── PardisoSupport.h │ │ ├── QR │ │ ├── ColPivHouseholderQR.h │ │ ├── ColPivHouseholderQR_LAPACKE.h │ │ ├── CompleteOrthogonalDecomposition.h │ │ ├── FullPivHouseholderQR.h │ │ ├── HouseholderQR.h │ │ └── HouseholderQR_LAPACKE.h │ │ ├── SPQRSupport │ │ └── SuiteSparseQRSupport.h │ │ ├── SVD │ │ ├── BDCSVD.h │ │ ├── JacobiSVD.h │ │ ├── JacobiSVD_LAPACKE.h │ │ ├── SVDBase.h │ │ └── UpperBidiagonalization.h │ │ ├── SparseCholesky │ │ ├── SimplicialCholesky.h │ │ └── SimplicialCholesky_impl.h │ │ ├── SparseCore │ │ ├── AmbiVector.h │ │ ├── CompressedStorage.h │ │ ├── ConservativeSparseSparseProduct.h │ │ ├── MappedSparseMatrix.h │ │ ├── SparseAssign.h │ │ ├── SparseBlock.h │ │ ├── SparseColEtree.h │ │ ├── SparseCompressedBase.h │ │ ├── SparseCwiseBinaryOp.h │ │ ├── SparseCwiseUnaryOp.h │ │ ├── SparseDenseProduct.h │ │ ├── SparseDiagonalProduct.h │ │ ├── SparseDot.h │ │ ├── SparseFuzzy.h │ │ ├── SparseMap.h │ │ ├── SparseMatrix.h │ │ ├── SparseMatrixBase.h │ │ ├── SparsePermutation.h │ │ ├── SparseProduct.h │ │ ├── SparseRedux.h │ │ ├── SparseRef.h │ │ ├── SparseSelfAdjointView.h │ │ ├── SparseSolverBase.h │ │ ├── SparseSparseProductWithPruning.h │ │ ├── SparseTranspose.h │ │ ├── SparseTriangularView.h │ │ ├── SparseUtil.h │ │ ├── SparseVector.h │ │ ├── SparseView.h │ │ └── TriangularSolver.h │ │ ├── SparseLU │ │ ├── SparseLU.h │ │ ├── SparseLUImpl.h │ │ ├── SparseLU_Memory.h │ │ ├── SparseLU_Structs.h │ │ ├── SparseLU_SupernodalMatrix.h │ │ ├── SparseLU_Utils.h │ │ ├── SparseLU_column_bmod.h │ │ ├── SparseLU_column_dfs.h │ │ ├── SparseLU_copy_to_ucol.h │ │ ├── SparseLU_gemm_kernel.h │ │ ├── SparseLU_heap_relax_snode.h │ │ ├── SparseLU_kernel_bmod.h │ │ ├── SparseLU_panel_bmod.h │ │ ├── SparseLU_panel_dfs.h │ │ ├── SparseLU_pivotL.h │ │ ├── SparseLU_pruneL.h │ │ └── SparseLU_relax_snode.h │ │ ├── SparseQR │ │ └── SparseQR.h │ │ ├── StlSupport │ │ ├── StdDeque.h │ │ ├── StdList.h │ │ ├── StdVector.h │ │ └── details.h │ │ ├── SuperLUSupport │ │ └── SuperLUSupport.h │ │ ├── UmfPackSupport │ │ └── UmfPackSupport.h │ │ ├── misc │ │ ├── Image.h │ │ ├── Kernel.h │ │ ├── RealSvd2x2.h │ │ ├── blas.h │ │ ├── lapack.h │ │ ├── lapacke.h │ │ └── lapacke_mangling.h │ │ └── plugins │ │ ├── ArrayCwiseBinaryOps.h │ │ ├── ArrayCwiseUnaryOps.h │ │ ├── BlockMethods.h │ │ ├── CommonCwiseBinaryOps.h │ │ ├── CommonCwiseUnaryOps.h │ │ ├── IndexedViewMethods.h │ │ ├── MatrixCwiseBinaryOps.h │ │ ├── MatrixCwiseUnaryOps.h │ │ └── ReshapedMethods.h └── qtimgui │ ├── include │ ├── ImGuiRenderer.h │ ├── QtImGui.h │ ├── imconfig.h │ ├── imgui.h │ ├── imgui_internal.h │ ├── implot.h │ ├── implot_internal.h │ ├── imstb_rectpack.h │ ├── imstb_textedit.h │ └── imstb_truetype.h │ └── lib │ ├── debug │ ├── imgui.lib │ ├── imgui.pdb │ ├── qt_imgui_widgets.lib │ └── qt_imgui_widgets.pdb │ └── release │ ├── imgui.lib │ └── qt_imgui_widgets.lib ├── README.md ├── Resources ├── Shaders │ ├── CurveSelection.frag │ ├── Model.frag │ ├── Model.vert │ ├── SkyBox.frag │ ├── SkyBox.vert │ ├── Spline.frag │ ├── Spline.tcs │ ├── Spline.tes │ └── Spline.vert └── SkyBox │ ├── nx.png │ ├── ny.png │ ├── nz.png │ ├── px.png │ ├── py.png │ └── pz.png └── Source ├── Core ├── Constants.h ├── Controller.cpp ├── Controller.h ├── CurveContainer.cpp ├── CurveContainer.h ├── Window.cpp └── Window.h ├── Curve ├── Knot.cpp ├── Knot.h ├── Spline.cpp └── Spline.h ├── EventHandler ├── EventHandler.cpp └── EventHandler.h ├── Gui ├── ImGuiWindow.cpp └── ImGuiWindow.h ├── Main.cpp ├── Node ├── Camera │ ├── FreeCamera.cpp │ └── FreeCamera.h ├── Light │ ├── DirectionalLight.h │ ├── Light.h │ └── PointLight.h ├── Mesh │ ├── Mesh.h │ ├── Plane.cpp │ ├── Plane.h │ ├── Sphere.cpp │ ├── Sphere.h │ ├── Texture.h │ └── Vertex.h ├── Model │ └── Model.h ├── Node.cpp ├── Node.h └── SkyBox │ ├── SkyBox.cpp │ └── SkyBox.h ├── Renderer ├── Base │ ├── CurveSelectionFramebuffer.cpp │ ├── CurveSelectionFramebuffer.h │ ├── Interval.cpp │ ├── Interval.h │ ├── Quad.cpp │ ├── Quad.h │ ├── Shader.cpp │ └── Shader.h ├── CurveSelectionRenderer.cpp ├── CurveSelectionRenderer.h ├── RendererManager.cpp ├── RendererManager.h ├── SplineRenderer.cpp └── SplineRenderer.h ├── Structs └── Mouse.h └── Util ├── Logger.cpp ├── Logger.h ├── Macros.h ├── Util.cpp └── Util.h /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | Language: Cpp 3 | AlignAfterOpenBracket: Align 4 | AlignConsecutiveMacros: 'true' 5 | AlignEscapedNewlines: Left 6 | AlignOperands: 'true' 7 | AlignTrailingComments: 'true' 8 | AllowAllArgumentsOnNextLine: 'true' 9 | AllowAllConstructorInitializersOnNextLine: 'false' 10 | AllowAllParametersOfDeclarationOnNextLine: 'false' 11 | AllowShortBlocksOnASingleLine: 'false' 12 | AllowShortCaseLabelsOnASingleLine: 'false' 13 | AllowShortFunctionsOnASingleLine: 'true' 14 | AllowShortIfStatementsOnASingleLine: Never 15 | AllowShortLambdasOnASingleLine: All 16 | AllowShortLoopsOnASingleLine: 'false' 17 | AlwaysBreakAfterReturnType: None 18 | AlwaysBreakBeforeMultilineStrings: 'false' 19 | AlwaysBreakTemplateDeclarations: 'Yes' 20 | BreakBeforeBraces: Allman 21 | BreakBeforeTernaryOperators: 'true' 22 | BreakConstructorInitializers: BeforeComma 23 | BreakStringLiterals: 'true' 24 | ColumnLimit: '0' 25 | CompactNamespaces: 'false' 26 | Cpp11BracedListStyle: 'false' 27 | FixNamespaceComments: 'false' 28 | IndentCaseLabels: 'true' 29 | IndentPPDirectives: None 30 | IndentWidth: '4' 31 | NamespaceIndentation: All 32 | PointerAlignment: Left 33 | SortIncludes: 'true' 34 | SortUsingDeclarations: 'true' 35 | SpaceAfterCStyleCast: 'true' 36 | SpaceAfterLogicalNot: 'false' 37 | SpaceAfterTemplateKeyword: 'false' 38 | SpaceBeforeAssignmentOperators: 'true' 39 | SpaceBeforeCpp11BracedList: 'false' 40 | SpaceBeforeCtorInitializerColon: 'true' 41 | SpaceBeforeInheritanceColon: 'true' 42 | SpaceBeforeRangeBasedForLoopColon: 'true' 43 | SpaceInEmptyParentheses: 'false' 44 | SpacesBeforeTrailingComments: '1' 45 | SpacesInAngles: 'false' 46 | SpacesInCStyleCastParentheses: 'false' 47 | SpacesInContainerLiterals: 'false' 48 | SpacesInParentheses: 'false' 49 | SpacesInSquareBrackets: 'false' 50 | ConstructorInitializerAllOnOneLineOrOnePerLine: 'true' 51 | ForEachMacros: 52 | - forever 53 | - foreach 54 | - Q_FOREACH 55 | - BOOST_FOREACH 56 | IfMacros: 57 | - KJ_IF_MAYBE 58 | IncludeBlocks: Regroup 59 | IncludeCategories: 60 | - Regex: ^ 2 | 3 | Resources/Shaders/Model.vert 4 | Resources/Shaders/Model.frag 5 | Resources/Shaders/SkyBox.vert 6 | Resources/Shaders/SkyBox.frag 7 | Resources/Shaders/Spline.vert 8 | Resources/Shaders/Spline.tcs 9 | Resources/Shaders/Spline.tes 10 | Resources/Shaders/Spline.frag 11 | Resources/Shaders/CurveSelection.frag 12 | 13 | 14 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.25.1) 2 | 3 | project(BSplineRenderer VERSION 1.0.0 LANGUAGES CXX) 4 | 5 | set(CMAKE_PREFIX_PATH "$ENV{Qt6_DIR}") 6 | 7 | set(CMAKE_CXX_STANDARD 20) 8 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 9 | 10 | set(CMAKE_AUTOMOC ON) 11 | set(CMAKE_AUTORCC ON) 12 | set(CMAKE_AUTOUIC ON) 13 | 14 | set(INCLUDE_DIR 15 | Libs/qtimgui/include 16 | Libs/Eigen 17 | ) 18 | 19 | set(LIBS_DIR Libs/qtimgui/lib) 20 | 21 | set(LIBS 22 | debug debug/imgui 23 | debug debug/qt_imgui_widgets 24 | optimized release/imgui 25 | optimized release/qt_imgui_widgets 26 | ) 27 | 28 | file(GLOB_RECURSE SOURCES Source/*.cpp *.qrc) 29 | 30 | find_package(Qt6 COMPONENTS Core Widgets OpenGL Gui Concurrent REQUIRED) 31 | 32 | include_directories("${CMAKE_CURRENT_SOURCE_DIR}/Source" ${INCLUDE_DIR}) 33 | 34 | link_directories(${LIBS_DIR}) 35 | 36 | add_executable(BSplineRenderer ${SOURCES}) 37 | 38 | target_link_libraries(BSplineRenderer Qt6::Core Qt6::Widgets Qt6::OpenGL Qt6::Concurrent ${LIBS}) 39 | 40 | add_custom_command(TARGET BSplineRenderer 41 | POST_BUILD COMMAND ${CMAKE_COMMAND} 42 | -E copy_directory 43 | "${CMAKE_SOURCE_DIR}/Resources/" 44 | "$/Resources/" 45 | ) 46 | 47 | add_custom_command(TARGET BSplineRenderer 48 | POST_BUILD COMMAND 49 | Qt6::windeployqt 50 | --dir "$" 51 | "$/$" 52 | ) 53 | -------------------------------------------------------------------------------- /Libs/Eigen/Cholesky: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_CHOLESKY_MODULE_H 9 | #define EIGEN_CHOLESKY_MODULE_H 10 | 11 | #include "Core" 12 | #include "Jacobi" 13 | 14 | #include "src/Core/util/DisableStupidWarnings.h" 15 | 16 | /** \defgroup Cholesky_Module Cholesky module 17 | * 18 | * 19 | * 20 | * This module provides two variants of the Cholesky decomposition for selfadjoint (hermitian) matrices. 21 | * Those decompositions are also accessible via the following methods: 22 | * - MatrixBase::llt() 23 | * - MatrixBase::ldlt() 24 | * - SelfAdjointView::llt() 25 | * - SelfAdjointView::ldlt() 26 | * 27 | * \code 28 | * #include 29 | * \endcode 30 | */ 31 | 32 | #include "src/Cholesky/LLT.h" 33 | #include "src/Cholesky/LDLT.h" 34 | #ifdef EIGEN_USE_LAPACKE 35 | #ifdef EIGEN_USE_MKL 36 | #include "mkl_lapacke.h" 37 | #else 38 | #include "src/misc/lapacke.h" 39 | #endif 40 | #include "src/Cholesky/LLT_LAPACKE.h" 41 | #endif 42 | 43 | #include "src/Core/util/ReenableStupidWarnings.h" 44 | 45 | #endif // EIGEN_CHOLESKY_MODULE_H 46 | -------------------------------------------------------------------------------- /Libs/Eigen/CholmodSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_CHOLMODSUPPORT_MODULE_H 9 | #define EIGEN_CHOLMODSUPPORT_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | extern "C" { 16 | #include 17 | } 18 | 19 | /** \ingroup Support_modules 20 | * \defgroup CholmodSupport_Module CholmodSupport module 21 | * 22 | * This module provides an interface to the Cholmod library which is part of the suitesparse package. 23 | * It provides the two following main factorization classes: 24 | * - class CholmodSupernodalLLT: a supernodal LLT Cholesky factorization. 25 | * - class CholmodDecomposiiton: a general L(D)LT Cholesky factorization with automatic or explicit runtime selection of the underlying factorization method (supernodal or simplicial). 26 | * 27 | * For the sake of completeness, this module also propose the two following classes: 28 | * - class CholmodSimplicialLLT 29 | * - class CholmodSimplicialLDLT 30 | * Note that these classes does not bring any particular advantage compared to the built-in 31 | * SimplicialLLT and SimplicialLDLT factorization classes. 32 | * 33 | * \code 34 | * #include 35 | * \endcode 36 | * 37 | * 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. 38 | * The dependencies depend on how cholmod has been compiled. 39 | * For a cmake based project, you can use our FindCholmod.cmake module to help you in this task. 40 | * 41 | */ 42 | 43 | #include "src/CholmodSupport/CholmodSupport.h" 44 | 45 | #include "src/Core/util/ReenableStupidWarnings.h" 46 | 47 | #endif // EIGEN_CHOLMODSUPPORT_MODULE_H 48 | 49 | -------------------------------------------------------------------------------- /Libs/Eigen/Dense: -------------------------------------------------------------------------------- 1 | #include "Core" 2 | #include "LU" 3 | #include "Cholesky" 4 | #include "QR" 5 | #include "SVD" 6 | #include "Geometry" 7 | #include "Eigenvalues" 8 | -------------------------------------------------------------------------------- /Libs/Eigen/Eigen: -------------------------------------------------------------------------------- 1 | #include "Dense" 2 | #include "Sparse" 3 | -------------------------------------------------------------------------------- /Libs/Eigen/Eigenvalues: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_EIGENVALUES_MODULE_H 9 | #define EIGEN_EIGENVALUES_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "Cholesky" 14 | #include "Jacobi" 15 | #include "Householder" 16 | #include "LU" 17 | #include "Geometry" 18 | 19 | #include "src/Core/util/DisableStupidWarnings.h" 20 | 21 | /** \defgroup Eigenvalues_Module Eigenvalues module 22 | * 23 | * 24 | * 25 | * This module mainly provides various eigenvalue solvers. 26 | * This module also provides some MatrixBase methods, including: 27 | * - MatrixBase::eigenvalues(), 28 | * - MatrixBase::operatorNorm() 29 | * 30 | * \code 31 | * #include 32 | * \endcode 33 | */ 34 | 35 | #include "src/misc/RealSvd2x2.h" 36 | #include "src/Eigenvalues/Tridiagonalization.h" 37 | #include "src/Eigenvalues/RealSchur.h" 38 | #include "src/Eigenvalues/EigenSolver.h" 39 | #include "src/Eigenvalues/SelfAdjointEigenSolver.h" 40 | #include "src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h" 41 | #include "src/Eigenvalues/HessenbergDecomposition.h" 42 | #include "src/Eigenvalues/ComplexSchur.h" 43 | #include "src/Eigenvalues/ComplexEigenSolver.h" 44 | #include "src/Eigenvalues/RealQZ.h" 45 | #include "src/Eigenvalues/GeneralizedEigenSolver.h" 46 | #include "src/Eigenvalues/MatrixBaseEigenvalues.h" 47 | #ifdef EIGEN_USE_LAPACKE 48 | #ifdef EIGEN_USE_MKL 49 | #include "mkl_lapacke.h" 50 | #else 51 | #include "src/misc/lapacke.h" 52 | #endif 53 | #include "src/Eigenvalues/RealSchur_LAPACKE.h" 54 | #include "src/Eigenvalues/ComplexSchur_LAPACKE.h" 55 | #include "src/Eigenvalues/SelfAdjointEigenSolver_LAPACKE.h" 56 | #endif 57 | 58 | #include "src/Core/util/ReenableStupidWarnings.h" 59 | 60 | #endif // EIGEN_EIGENVALUES_MODULE_H 61 | -------------------------------------------------------------------------------- /Libs/Eigen/Geometry: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_GEOMETRY_MODULE_H 9 | #define EIGEN_GEOMETRY_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "SVD" 14 | #include "LU" 15 | #include 16 | 17 | #include "src/Core/util/DisableStupidWarnings.h" 18 | 19 | /** \defgroup Geometry_Module Geometry module 20 | * 21 | * This module provides support for: 22 | * - fixed-size homogeneous transformations 23 | * - translation, scaling, 2D and 3D rotations 24 | * - \link Quaternion quaternions \endlink 25 | * - cross products (\ref MatrixBase::cross, \ref MatrixBase::cross3) 26 | * - orthognal vector generation (\ref MatrixBase::unitOrthogonal) 27 | * - some linear components: \link ParametrizedLine parametrized-lines \endlink and \link Hyperplane hyperplanes \endlink 28 | * - \link AlignedBox axis aligned bounding boxes \endlink 29 | * - \link umeyama least-square transformation fitting \endlink 30 | * 31 | * \code 32 | * #include 33 | * \endcode 34 | */ 35 | 36 | #include "src/Geometry/OrthoMethods.h" 37 | #include "src/Geometry/EulerAngles.h" 38 | 39 | #include "src/Geometry/Homogeneous.h" 40 | #include "src/Geometry/RotationBase.h" 41 | #include "src/Geometry/Rotation2D.h" 42 | #include "src/Geometry/Quaternion.h" 43 | #include "src/Geometry/AngleAxis.h" 44 | #include "src/Geometry/Transform.h" 45 | #include "src/Geometry/Translation.h" 46 | #include "src/Geometry/Scaling.h" 47 | #include "src/Geometry/Hyperplane.h" 48 | #include "src/Geometry/ParametrizedLine.h" 49 | #include "src/Geometry/AlignedBox.h" 50 | #include "src/Geometry/Umeyama.h" 51 | 52 | // Use the SSE optimized version whenever possible. 53 | #if (defined EIGEN_VECTORIZE_SSE) || (defined EIGEN_VECTORIZE_NEON) 54 | #include "src/Geometry/arch/Geometry_SIMD.h" 55 | #endif 56 | 57 | #include "src/Core/util/ReenableStupidWarnings.h" 58 | 59 | #endif // EIGEN_GEOMETRY_MODULE_H 60 | -------------------------------------------------------------------------------- /Libs/Eigen/Householder: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_HOUSEHOLDER_MODULE_H 9 | #define EIGEN_HOUSEHOLDER_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | /** \defgroup Householder_Module Householder module 16 | * This module provides Householder transformations. 17 | * 18 | * \code 19 | * #include 20 | * \endcode 21 | */ 22 | 23 | #include "src/Householder/Householder.h" 24 | #include "src/Householder/HouseholderSequence.h" 25 | #include "src/Householder/BlockHouseholder.h" 26 | 27 | #include "src/Core/util/ReenableStupidWarnings.h" 28 | 29 | #endif // EIGEN_HOUSEHOLDER_MODULE_H 30 | -------------------------------------------------------------------------------- /Libs/Eigen/IterativeLinearSolvers: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_ITERATIVELINEARSOLVERS_MODULE_H 9 | #define EIGEN_ITERATIVELINEARSOLVERS_MODULE_H 10 | 11 | #include "SparseCore" 12 | #include "OrderingMethods" 13 | 14 | #include "src/Core/util/DisableStupidWarnings.h" 15 | 16 | /** 17 | * \defgroup IterativeLinearSolvers_Module IterativeLinearSolvers module 18 | * 19 | * 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. 20 | * Those solvers are accessible via the following classes: 21 | * - ConjugateGradient for selfadjoint (hermitian) matrices, 22 | * - LeastSquaresConjugateGradient for rectangular least-square problems, 23 | * - BiCGSTAB for general square matrices. 24 | * 25 | * These iterative solvers are associated with some preconditioners: 26 | * - IdentityPreconditioner - not really useful 27 | * - DiagonalPreconditioner - also called Jacobi preconditioner, work very well on diagonal dominant matrices. 28 | * - IncompleteLUT - incomplete LU factorization with dual thresholding 29 | * 30 | * Such problems can also be solved using the direct sparse decomposition modules: SparseCholesky, CholmodSupport, UmfPackSupport, SuperLUSupport. 31 | * 32 | \code 33 | #include 34 | \endcode 35 | */ 36 | 37 | #include "src/IterativeLinearSolvers/SolveWithGuess.h" 38 | #include "src/IterativeLinearSolvers/IterativeSolverBase.h" 39 | #include "src/IterativeLinearSolvers/BasicPreconditioners.h" 40 | #include "src/IterativeLinearSolvers/ConjugateGradient.h" 41 | #include "src/IterativeLinearSolvers/LeastSquareConjugateGradient.h" 42 | #include "src/IterativeLinearSolvers/BiCGSTAB.h" 43 | #include "src/IterativeLinearSolvers/IncompleteLUT.h" 44 | #include "src/IterativeLinearSolvers/IncompleteCholesky.h" 45 | 46 | #include "src/Core/util/ReenableStupidWarnings.h" 47 | 48 | #endif // EIGEN_ITERATIVELINEARSOLVERS_MODULE_H 49 | -------------------------------------------------------------------------------- /Libs/Eigen/Jacobi: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_JACOBI_MODULE_H 9 | #define EIGEN_JACOBI_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | /** \defgroup Jacobi_Module Jacobi module 16 | * This module provides Jacobi and Givens rotations. 17 | * 18 | * \code 19 | * #include 20 | * \endcode 21 | * 22 | * In addition to listed classes, it defines the two following MatrixBase methods to apply a Jacobi or Givens rotation: 23 | * - MatrixBase::applyOnTheLeft() 24 | * - MatrixBase::applyOnTheRight(). 25 | */ 26 | 27 | #include "src/Jacobi/Jacobi.h" 28 | 29 | #include "src/Core/util/ReenableStupidWarnings.h" 30 | 31 | #endif // EIGEN_JACOBI_MODULE_H 32 | 33 | -------------------------------------------------------------------------------- /Libs/Eigen/KLUSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_KLUSUPPORT_MODULE_H 9 | #define EIGEN_KLUSUPPORT_MODULE_H 10 | 11 | #include 12 | 13 | #include 14 | 15 | extern "C" { 16 | #include 17 | #include 18 | } 19 | 20 | /** \ingroup Support_modules 21 | * \defgroup KLUSupport_Module KLUSupport module 22 | * 23 | * This module provides an interface to the KLU library which is part of the suitesparse package. 24 | * It provides the following factorization class: 25 | * - class KLU: a sparse LU factorization, well-suited for circuit simulation. 26 | * 27 | * \code 28 | * #include 29 | * \endcode 30 | * 31 | * In order to use this module, the klu and btf headers must be accessible from the include paths, and your binary must be linked to the klu library and its dependencies. 32 | * The dependencies depend on how umfpack has been compiled. 33 | * For a cmake based project, you can use our FindKLU.cmake module to help you in this task. 34 | * 35 | */ 36 | 37 | #include "src/KLUSupport/KLUSupport.h" 38 | 39 | #include 40 | 41 | #endif // EIGEN_KLUSUPPORT_MODULE_H 42 | -------------------------------------------------------------------------------- /Libs/Eigen/LU: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_LU_MODULE_H 9 | #define EIGEN_LU_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | /** \defgroup LU_Module LU module 16 | * This module includes %LU decomposition and related notions such as matrix inversion and determinant. 17 | * This module defines the following MatrixBase methods: 18 | * - MatrixBase::inverse() 19 | * - MatrixBase::determinant() 20 | * 21 | * \code 22 | * #include 23 | * \endcode 24 | */ 25 | 26 | #include "src/misc/Kernel.h" 27 | #include "src/misc/Image.h" 28 | #include "src/LU/FullPivLU.h" 29 | #include "src/LU/PartialPivLU.h" 30 | #ifdef EIGEN_USE_LAPACKE 31 | #ifdef EIGEN_USE_MKL 32 | #include "mkl_lapacke.h" 33 | #else 34 | #include "src/misc/lapacke.h" 35 | #endif 36 | #include "src/LU/PartialPivLU_LAPACKE.h" 37 | #endif 38 | #include "src/LU/Determinant.h" 39 | #include "src/LU/InverseImpl.h" 40 | 41 | #if defined EIGEN_VECTORIZE_SSE || defined EIGEN_VECTORIZE_NEON 42 | #include "src/LU/arch/InverseSize4.h" 43 | #endif 44 | 45 | #include "src/Core/util/ReenableStupidWarnings.h" 46 | 47 | #endif // EIGEN_LU_MODULE_H 48 | -------------------------------------------------------------------------------- /Libs/Eigen/MetisSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_METISSUPPORT_MODULE_H 9 | #define EIGEN_METISSUPPORT_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | extern "C" { 16 | #include 17 | } 18 | 19 | 20 | /** \ingroup Support_modules 21 | * \defgroup MetisSupport_Module MetisSupport module 22 | * 23 | * \code 24 | * #include 25 | * \endcode 26 | * This module defines an interface to the METIS reordering package (http://glaros.dtc.umn.edu/gkhome/views/metis). 27 | * It can be used just as any other built-in method as explained in \link OrderingMethods_Module here. \endlink 28 | */ 29 | 30 | 31 | #include "src/MetisSupport/MetisSupport.h" 32 | 33 | #include "src/Core/util/ReenableStupidWarnings.h" 34 | 35 | #endif // EIGEN_METISSUPPORT_MODULE_H 36 | -------------------------------------------------------------------------------- /Libs/Eigen/OrderingMethods: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_ORDERINGMETHODS_MODULE_H 9 | #define EIGEN_ORDERINGMETHODS_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | /** 16 | * \defgroup OrderingMethods_Module OrderingMethods module 17 | * 18 | * This module is currently for internal use only 19 | * 20 | * It defines various built-in and external ordering methods for sparse matrices. 21 | * They are typically used to reduce the number of elements during 22 | * the sparse matrix decomposition (LLT, LU, QR). 23 | * Precisely, in a preprocessing step, a permutation matrix P is computed using 24 | * those ordering methods and applied to the columns of the matrix. 25 | * Using for instance the sparse Cholesky decomposition, it is expected that 26 | * the nonzeros elements in LLT(A*P) will be much smaller than that in LLT(A). 27 | * 28 | * 29 | * Usage : 30 | * \code 31 | * #include 32 | * \endcode 33 | * 34 | * A simple usage is as a template parameter in the sparse decomposition classes : 35 | * 36 | * \code 37 | * SparseLU > solver; 38 | * \endcode 39 | * 40 | * \code 41 | * SparseQR > solver; 42 | * \endcode 43 | * 44 | * It is possible as well to call directly a particular ordering method for your own purpose, 45 | * \code 46 | * AMDOrdering ordering; 47 | * PermutationMatrix perm; 48 | * SparseMatrix A; 49 | * //Fill the matrix ... 50 | * 51 | * ordering(A, perm); // Call AMD 52 | * \endcode 53 | * 54 | * \note Some of these methods (like AMD or METIS), need the sparsity pattern 55 | * of the input matrix to be symmetric. When the matrix is structurally unsymmetric, 56 | * Eigen computes internally the pattern of \f$A^T*A\f$ before calling the method. 57 | * If your matrix is already symmetric (at leat in structure), you can avoid that 58 | * by calling the method with a SelfAdjointView type. 59 | * 60 | * \code 61 | * // Call the ordering on the pattern of the lower triangular matrix A 62 | * ordering(A.selfadjointView(), perm); 63 | * \endcode 64 | */ 65 | 66 | #include "src/OrderingMethods/Amd.h" 67 | #include "src/OrderingMethods/Ordering.h" 68 | #include "src/Core/util/ReenableStupidWarnings.h" 69 | 70 | #endif // EIGEN_ORDERINGMETHODS_MODULE_H 71 | -------------------------------------------------------------------------------- /Libs/Eigen/PaStiXSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_PASTIXSUPPORT_MODULE_H 9 | #define EIGEN_PASTIXSUPPORT_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | extern "C" { 16 | #include 17 | #include 18 | } 19 | 20 | #ifdef complex 21 | #undef complex 22 | #endif 23 | 24 | /** \ingroup Support_modules 25 | * \defgroup PaStiXSupport_Module PaStiXSupport module 26 | * 27 | * This module provides an interface to the PaSTiX library. 28 | * PaSTiX is a general \b supernodal, \b parallel and \b opensource sparse solver. 29 | * It provides the two following main factorization classes: 30 | * - class PastixLLT : a supernodal, parallel LLt Cholesky factorization. 31 | * - class PastixLDLT: a supernodal, parallel LDLt Cholesky factorization. 32 | * - class PastixLU : a supernodal, parallel LU factorization (optimized for a symmetric pattern). 33 | * 34 | * \code 35 | * #include 36 | * \endcode 37 | * 38 | * 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. 39 | * This wrapper resuires PaStiX version 5.x compiled without MPI support. 40 | * The dependencies depend on how PaSTiX has been compiled. 41 | * For a cmake based project, you can use our FindPaSTiX.cmake module to help you in this task. 42 | * 43 | */ 44 | 45 | #include "src/PaStiXSupport/PaStiXSupport.h" 46 | 47 | #include "src/Core/util/ReenableStupidWarnings.h" 48 | 49 | #endif // EIGEN_PASTIXSUPPORT_MODULE_H 50 | -------------------------------------------------------------------------------- /Libs/Eigen/PardisoSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_PARDISOSUPPORT_MODULE_H 9 | #define EIGEN_PARDISOSUPPORT_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | #include 16 | 17 | /** \ingroup Support_modules 18 | * \defgroup PardisoSupport_Module PardisoSupport module 19 | * 20 | * This module brings support for the Intel(R) MKL PARDISO direct sparse solvers. 21 | * 22 | * \code 23 | * #include 24 | * \endcode 25 | * 26 | * 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. 27 | * See this \ref TopicUsingIntelMKL "page" for more information on MKL-Eigen integration. 28 | * 29 | */ 30 | 31 | #include "src/PardisoSupport/PardisoSupport.h" 32 | 33 | #include "src/Core/util/ReenableStupidWarnings.h" 34 | 35 | #endif // EIGEN_PARDISOSUPPORT_MODULE_H 36 | -------------------------------------------------------------------------------- /Libs/Eigen/QR: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_QR_MODULE_H 9 | #define EIGEN_QR_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "Cholesky" 14 | #include "Jacobi" 15 | #include "Householder" 16 | 17 | #include "src/Core/util/DisableStupidWarnings.h" 18 | 19 | /** \defgroup QR_Module QR module 20 | * 21 | * 22 | * 23 | * This module provides various QR decompositions 24 | * This module also provides some MatrixBase methods, including: 25 | * - MatrixBase::householderQr() 26 | * - MatrixBase::colPivHouseholderQr() 27 | * - MatrixBase::fullPivHouseholderQr() 28 | * 29 | * \code 30 | * #include 31 | * \endcode 32 | */ 33 | 34 | #include "src/QR/HouseholderQR.h" 35 | #include "src/QR/FullPivHouseholderQR.h" 36 | #include "src/QR/ColPivHouseholderQR.h" 37 | #include "src/QR/CompleteOrthogonalDecomposition.h" 38 | #ifdef EIGEN_USE_LAPACKE 39 | #ifdef EIGEN_USE_MKL 40 | #include "mkl_lapacke.h" 41 | #else 42 | #include "src/misc/lapacke.h" 43 | #endif 44 | #include "src/QR/HouseholderQR_LAPACKE.h" 45 | #include "src/QR/ColPivHouseholderQR_LAPACKE.h" 46 | #endif 47 | 48 | #include "src/Core/util/ReenableStupidWarnings.h" 49 | 50 | #endif // EIGEN_QR_MODULE_H 51 | -------------------------------------------------------------------------------- /Libs/Eigen/QtAlignedMalloc: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_QTMALLOC_MODULE_H 9 | #define EIGEN_QTMALLOC_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #if (!EIGEN_MALLOC_ALREADY_ALIGNED) 14 | 15 | #include "src/Core/util/DisableStupidWarnings.h" 16 | 17 | void *qMalloc(std::size_t size) 18 | { 19 | return Eigen::internal::aligned_malloc(size); 20 | } 21 | 22 | void qFree(void *ptr) 23 | { 24 | Eigen::internal::aligned_free(ptr); 25 | } 26 | 27 | void *qRealloc(void *ptr, std::size_t size) 28 | { 29 | void* newPtr = Eigen::internal::aligned_malloc(size); 30 | std::memcpy(newPtr, ptr, size); 31 | Eigen::internal::aligned_free(ptr); 32 | return newPtr; 33 | } 34 | 35 | #include "src/Core/util/ReenableStupidWarnings.h" 36 | 37 | #endif 38 | 39 | #endif // EIGEN_QTMALLOC_MODULE_H 40 | -------------------------------------------------------------------------------- /Libs/Eigen/SPQRSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_SPQRSUPPORT_MODULE_H 9 | #define EIGEN_SPQRSUPPORT_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | #include "SuiteSparseQR.hpp" 16 | 17 | /** \ingroup Support_modules 18 | * \defgroup SPQRSupport_Module SuiteSparseQR module 19 | * 20 | * This module provides an interface to the SPQR library, which is part of the suitesparse package. 21 | * 22 | * \code 23 | * #include 24 | * \endcode 25 | * 26 | * In order to use this module, the SPQR headers must be accessible from the include paths, and your binary must be linked to the SPQR library and its dependencies (Cholmod, AMD, COLAMD,...). 27 | * For a cmake based project, you can use our FindSPQR.cmake and FindCholmod.Cmake modules 28 | * 29 | */ 30 | 31 | #include "src/CholmodSupport/CholmodSupport.h" 32 | #include "src/SPQRSupport/SuiteSparseQRSupport.h" 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /Libs/Eigen/SVD: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_SVD_MODULE_H 9 | #define EIGEN_SVD_MODULE_H 10 | 11 | #include "QR" 12 | #include "Householder" 13 | #include "Jacobi" 14 | 15 | #include "src/Core/util/DisableStupidWarnings.h" 16 | 17 | /** \defgroup SVD_Module SVD module 18 | * 19 | * 20 | * 21 | * This module provides SVD decomposition for matrices (both real and complex). 22 | * Two decomposition algorithms are provided: 23 | * - JacobiSVD implementing two-sided Jacobi iterations is numerically very accurate, fast for small matrices, but very slow for larger ones. 24 | * - BDCSVD implementing a recursive divide & conquer strategy on top of an upper-bidiagonalization which remains fast for large problems. 25 | * These decompositions are accessible via the respective classes and following MatrixBase methods: 26 | * - MatrixBase::jacobiSvd() 27 | * - MatrixBase::bdcSvd() 28 | * 29 | * \code 30 | * #include 31 | * \endcode 32 | */ 33 | 34 | #include "src/misc/RealSvd2x2.h" 35 | #include "src/SVD/UpperBidiagonalization.h" 36 | #include "src/SVD/SVDBase.h" 37 | #include "src/SVD/JacobiSVD.h" 38 | #include "src/SVD/BDCSVD.h" 39 | #if defined(EIGEN_USE_LAPACKE) && !defined(EIGEN_USE_LAPACKE_STRICT) 40 | #ifdef EIGEN_USE_MKL 41 | #include "mkl_lapacke.h" 42 | #else 43 | #include "src/misc/lapacke.h" 44 | #endif 45 | #include "src/SVD/JacobiSVD_LAPACKE.h" 46 | #endif 47 | 48 | #include "src/Core/util/ReenableStupidWarnings.h" 49 | 50 | #endif // EIGEN_SVD_MODULE_H 51 | -------------------------------------------------------------------------------- /Libs/Eigen/Sparse: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_SPARSE_MODULE_H 9 | #define EIGEN_SPARSE_MODULE_H 10 | 11 | /** \defgroup Sparse_Module Sparse meta-module 12 | * 13 | * Meta-module including all related modules: 14 | * - \ref SparseCore_Module 15 | * - \ref OrderingMethods_Module 16 | * - \ref SparseCholesky_Module 17 | * - \ref SparseLU_Module 18 | * - \ref SparseQR_Module 19 | * - \ref IterativeLinearSolvers_Module 20 | * 21 | \code 22 | #include 23 | \endcode 24 | */ 25 | 26 | #include "SparseCore" 27 | #include "OrderingMethods" 28 | #include "SparseCholesky" 29 | #include "SparseLU" 30 | #include "SparseQR" 31 | #include "IterativeLinearSolvers" 32 | 33 | #endif // EIGEN_SPARSE_MODULE_H 34 | 35 | -------------------------------------------------------------------------------- /Libs/Eigen/SparseCholesky: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2013 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_SPARSECHOLESKY_MODULE_H 11 | #define EIGEN_SPARSECHOLESKY_MODULE_H 12 | 13 | #include "SparseCore" 14 | #include "OrderingMethods" 15 | 16 | #include "src/Core/util/DisableStupidWarnings.h" 17 | 18 | /** 19 | * \defgroup SparseCholesky_Module SparseCholesky module 20 | * 21 | * This module currently provides two variants of the direct sparse Cholesky decomposition for selfadjoint (hermitian) matrices. 22 | * Those decompositions are accessible via the following classes: 23 | * - SimplicialLLt, 24 | * - SimplicialLDLt 25 | * 26 | * Such problems can also be solved using the ConjugateGradient solver from the IterativeLinearSolvers module. 27 | * 28 | * \code 29 | * #include 30 | * \endcode 31 | */ 32 | 33 | #include "src/SparseCholesky/SimplicialCholesky.h" 34 | #include "src/SparseCholesky/SimplicialCholesky_impl.h" 35 | #include "src/Core/util/ReenableStupidWarnings.h" 36 | 37 | #endif // EIGEN_SPARSECHOLESKY_MODULE_H 38 | -------------------------------------------------------------------------------- /Libs/Eigen/SparseCore: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_SPARSECORE_MODULE_H 9 | #define EIGEN_SPARSECORE_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | /** 22 | * \defgroup SparseCore_Module SparseCore module 23 | * 24 | * This module provides a sparse matrix representation, and basic associated matrix manipulations 25 | * and operations. 26 | * 27 | * See the \ref TutorialSparse "Sparse tutorial" 28 | * 29 | * \code 30 | * #include 31 | * \endcode 32 | * 33 | * This module depends on: Core. 34 | */ 35 | 36 | #include "src/SparseCore/SparseUtil.h" 37 | #include "src/SparseCore/SparseMatrixBase.h" 38 | #include "src/SparseCore/SparseAssign.h" 39 | #include "src/SparseCore/CompressedStorage.h" 40 | #include "src/SparseCore/AmbiVector.h" 41 | #include "src/SparseCore/SparseCompressedBase.h" 42 | #include "src/SparseCore/SparseMatrix.h" 43 | #include "src/SparseCore/SparseMap.h" 44 | #include "src/SparseCore/MappedSparseMatrix.h" 45 | #include "src/SparseCore/SparseVector.h" 46 | #include "src/SparseCore/SparseRef.h" 47 | #include "src/SparseCore/SparseCwiseUnaryOp.h" 48 | #include "src/SparseCore/SparseCwiseBinaryOp.h" 49 | #include "src/SparseCore/SparseTranspose.h" 50 | #include "src/SparseCore/SparseBlock.h" 51 | #include "src/SparseCore/SparseDot.h" 52 | #include "src/SparseCore/SparseRedux.h" 53 | #include "src/SparseCore/SparseView.h" 54 | #include "src/SparseCore/SparseDiagonalProduct.h" 55 | #include "src/SparseCore/ConservativeSparseSparseProduct.h" 56 | #include "src/SparseCore/SparseSparseProductWithPruning.h" 57 | #include "src/SparseCore/SparseProduct.h" 58 | #include "src/SparseCore/SparseDenseProduct.h" 59 | #include "src/SparseCore/SparseSelfAdjointView.h" 60 | #include "src/SparseCore/SparseTriangularView.h" 61 | #include "src/SparseCore/TriangularSolver.h" 62 | #include "src/SparseCore/SparsePermutation.h" 63 | #include "src/SparseCore/SparseFuzzy.h" 64 | #include "src/SparseCore/SparseSolverBase.h" 65 | 66 | #include "src/Core/util/ReenableStupidWarnings.h" 67 | 68 | #endif // EIGEN_SPARSECORE_MODULE_H 69 | 70 | -------------------------------------------------------------------------------- /Libs/Eigen/SparseLU: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2012 Désiré Nuentsa-Wakam 5 | // Copyright (C) 2012 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_SPARSELU_MODULE_H 12 | #define EIGEN_SPARSELU_MODULE_H 13 | 14 | #include "SparseCore" 15 | 16 | /** 17 | * \defgroup SparseLU_Module SparseLU module 18 | * This module defines a supernodal factorization of general sparse matrices. 19 | * The code is fully optimized for supernode-panel updates with specialized kernels. 20 | * Please, see the documentation of the SparseLU class for more details. 21 | */ 22 | 23 | // Ordering interface 24 | #include "OrderingMethods" 25 | 26 | #include "src/Core/util/DisableStupidWarnings.h" 27 | 28 | #include "src/SparseLU/SparseLU_gemm_kernel.h" 29 | 30 | #include "src/SparseLU/SparseLU_Structs.h" 31 | #include "src/SparseLU/SparseLU_SupernodalMatrix.h" 32 | #include "src/SparseLU/SparseLUImpl.h" 33 | #include "src/SparseCore/SparseColEtree.h" 34 | #include "src/SparseLU/SparseLU_Memory.h" 35 | #include "src/SparseLU/SparseLU_heap_relax_snode.h" 36 | #include "src/SparseLU/SparseLU_relax_snode.h" 37 | #include "src/SparseLU/SparseLU_pivotL.h" 38 | #include "src/SparseLU/SparseLU_panel_dfs.h" 39 | #include "src/SparseLU/SparseLU_kernel_bmod.h" 40 | #include "src/SparseLU/SparseLU_panel_bmod.h" 41 | #include "src/SparseLU/SparseLU_column_dfs.h" 42 | #include "src/SparseLU/SparseLU_column_bmod.h" 43 | #include "src/SparseLU/SparseLU_copy_to_ucol.h" 44 | #include "src/SparseLU/SparseLU_pruneL.h" 45 | #include "src/SparseLU/SparseLU_Utils.h" 46 | #include "src/SparseLU/SparseLU.h" 47 | 48 | #include "src/Core/util/ReenableStupidWarnings.h" 49 | 50 | #endif // EIGEN_SPARSELU_MODULE_H 51 | -------------------------------------------------------------------------------- /Libs/Eigen/SparseQR: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_SPARSEQR_MODULE_H 9 | #define EIGEN_SPARSEQR_MODULE_H 10 | 11 | #include "SparseCore" 12 | #include "OrderingMethods" 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | /** \defgroup SparseQR_Module SparseQR module 16 | * \brief Provides QR decomposition for sparse matrices 17 | * 18 | * This module provides a simplicial version of the left-looking Sparse QR decomposition. 19 | * The columns of the input matrix should be reordered to limit the fill-in during the 20 | * decomposition. Built-in methods (COLAMD, AMD) or external methods (METIS) can be used to this end. 21 | * See the \link OrderingMethods_Module OrderingMethods\endlink module for the list 22 | * of built-in and external ordering methods. 23 | * 24 | * \code 25 | * #include 26 | * \endcode 27 | * 28 | * 29 | */ 30 | 31 | #include "src/SparseCore/SparseColEtree.h" 32 | #include "src/SparseQR/SparseQR.h" 33 | 34 | #include "src/Core/util/ReenableStupidWarnings.h" 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /Libs/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 EIGEN_COMP_MSVC && EIGEN_OS_WIN64 && (EIGEN_MAX_STATIC_ALIGN_BYTES<=16) /* MSVC auto aligns up to 16 bytes 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 | -------------------------------------------------------------------------------- /Libs/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 EIGEN_COMP_MSVC && EIGEN_OS_WIN64 && (EIGEN_MAX_STATIC_ALIGN_BYTES<=16) /* MSVC auto aligns up to 16 bytes 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 | -------------------------------------------------------------------------------- /Libs/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 EIGEN_COMP_MSVC && EIGEN_OS_WIN64 && (EIGEN_MAX_STATIC_ALIGN_BYTES<=16) /* MSVC auto aligns up to 16 bytes 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 | -------------------------------------------------------------------------------- /Libs/Eigen/SuperLUSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_SUPERLUSUPPORT_MODULE_H 9 | #define EIGEN_SUPERLUSUPPORT_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | #ifdef EMPTY 16 | #define EIGEN_EMPTY_WAS_ALREADY_DEFINED 17 | #endif 18 | 19 | typedef int int_t; 20 | #include 21 | #include 22 | #include 23 | 24 | // slu_util.h defines a preprocessor token named EMPTY which is really polluting, 25 | // so we remove it in favor of a SUPERLU_EMPTY token. 26 | // If EMPTY was already defined then we don't undef it. 27 | 28 | #if defined(EIGEN_EMPTY_WAS_ALREADY_DEFINED) 29 | # undef EIGEN_EMPTY_WAS_ALREADY_DEFINED 30 | #elif defined(EMPTY) 31 | # undef EMPTY 32 | #endif 33 | 34 | #define SUPERLU_EMPTY (-1) 35 | 36 | namespace Eigen { struct SluMatrix; } 37 | 38 | /** \ingroup Support_modules 39 | * \defgroup SuperLUSupport_Module SuperLUSupport module 40 | * 41 | * This module provides an interface to the SuperLU library. 42 | * It provides the following factorization class: 43 | * - class SuperLU: a supernodal sequential LU factorization. 44 | * - class SuperILU: a supernodal sequential incomplete LU factorization (to be used as a preconditioner for iterative methods). 45 | * 46 | * \warning This wrapper requires at least versions 4.0 of SuperLU. The 3.x versions are not supported. 47 | * 48 | * \warning When including this module, you have to use SUPERLU_EMPTY instead of EMPTY which is no longer defined because it is too polluting. 49 | * 50 | * \code 51 | * #include 52 | * \endcode 53 | * 54 | * 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. 55 | * The dependencies depend on how superlu has been compiled. 56 | * For a cmake based project, you can use our FindSuperLU.cmake module to help you in this task. 57 | * 58 | */ 59 | 60 | #include "src/SuperLUSupport/SuperLUSupport.h" 61 | 62 | #include "src/Core/util/ReenableStupidWarnings.h" 63 | 64 | #endif // EIGEN_SUPERLUSUPPORT_MODULE_H 65 | -------------------------------------------------------------------------------- /Libs/Eigen/UmfPackSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_UMFPACKSUPPORT_MODULE_H 9 | #define EIGEN_UMFPACKSUPPORT_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | extern "C" { 16 | #include 17 | } 18 | 19 | /** \ingroup Support_modules 20 | * \defgroup UmfPackSupport_Module UmfPackSupport module 21 | * 22 | * This module provides an interface to the UmfPack library which is part of the suitesparse package. 23 | * It provides the following factorization class: 24 | * - class UmfPackLU: a multifrontal sequential LU factorization. 25 | * 26 | * \code 27 | * #include 28 | * \endcode 29 | * 30 | * 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. 31 | * The dependencies depend on how umfpack has been compiled. 32 | * For a cmake based project, you can use our FindUmfPack.cmake module to help you in this task. 33 | * 34 | */ 35 | 36 | #include "src/UmfPackSupport/UmfPackSupport.h" 37 | 38 | #include "src/Core/util/ReenableStupidWarnings.h" 39 | 40 | #endif // EIGEN_UMFPACKSUPPORT_MODULE_H 41 | -------------------------------------------------------------------------------- /Libs/Eigen/src/Core/Assign.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2007 Michael Olbrich 5 | // Copyright (C) 2006-2010 Benoit Jacob 6 | // Copyright (C) 2008 Gael Guennebaud 7 | // 8 | // This Source Code Form is subject to the terms of the Mozilla 9 | // Public License v. 2.0. If a copy of the MPL was not distributed 10 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 11 | 12 | #ifndef EIGEN_ASSIGN_H 13 | #define EIGEN_ASSIGN_H 14 | 15 | namespace Eigen { 16 | 17 | template 18 | template 19 | EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase 20 | ::lazyAssign(const DenseBase& other) 21 | { 22 | enum{ 23 | SameType = internal::is_same::value 24 | }; 25 | 26 | EIGEN_STATIC_ASSERT_LVALUE(Derived) 27 | EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Derived,OtherDerived) 28 | EIGEN_STATIC_ASSERT(SameType,YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY) 29 | 30 | eigen_assert(rows() == other.rows() && cols() == other.cols()); 31 | internal::call_assignment_no_alias(derived(),other.derived()); 32 | 33 | return derived(); 34 | } 35 | 36 | template 37 | template 38 | EIGEN_DEVICE_FUNC 39 | EIGEN_STRONG_INLINE Derived& DenseBase::operator=(const DenseBase& other) 40 | { 41 | internal::call_assignment(derived(), other.derived()); 42 | return derived(); 43 | } 44 | 45 | template 46 | EIGEN_DEVICE_FUNC 47 | EIGEN_STRONG_INLINE Derived& DenseBase::operator=(const DenseBase& other) 48 | { 49 | internal::call_assignment(derived(), other.derived()); 50 | return derived(); 51 | } 52 | 53 | template 54 | EIGEN_DEVICE_FUNC 55 | EIGEN_STRONG_INLINE Derived& MatrixBase::operator=(const MatrixBase& other) 56 | { 57 | internal::call_assignment(derived(), other.derived()); 58 | return derived(); 59 | } 60 | 61 | template 62 | template 63 | EIGEN_DEVICE_FUNC 64 | EIGEN_STRONG_INLINE Derived& MatrixBase::operator=(const DenseBase& other) 65 | { 66 | internal::call_assignment(derived(), other.derived()); 67 | return derived(); 68 | } 69 | 70 | template 71 | template 72 | EIGEN_DEVICE_FUNC 73 | EIGEN_STRONG_INLINE Derived& MatrixBase::operator=(const EigenBase& other) 74 | { 75 | internal::call_assignment(derived(), other.derived()); 76 | return derived(); 77 | } 78 | 79 | template 80 | template 81 | EIGEN_DEVICE_FUNC 82 | EIGEN_STRONG_INLINE Derived& MatrixBase::operator=(const ReturnByValue& other) 83 | { 84 | other.derived().evalTo(derived()); 85 | return derived(); 86 | } 87 | 88 | } // end namespace Eigen 89 | 90 | #endif // EIGEN_ASSIGN_H 91 | -------------------------------------------------------------------------------- /Libs/Eigen/src/Core/DiagonalProduct.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) 2007-2009 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_DIAGONALPRODUCT_H 12 | #define EIGEN_DIAGONALPRODUCT_H 13 | 14 | namespace Eigen { 15 | 16 | /** \returns the diagonal matrix product of \c *this by the diagonal matrix \a diagonal. 17 | */ 18 | template 19 | template 20 | EIGEN_DEVICE_FUNC inline const Product 21 | MatrixBase::operator*(const DiagonalBase &a_diagonal) const 22 | { 23 | return Product(derived(),a_diagonal.derived()); 24 | } 25 | 26 | } // end namespace Eigen 27 | 28 | #endif // EIGEN_DIAGONALPRODUCT_H 29 | -------------------------------------------------------------------------------- /Libs/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 | namespace internal { 17 | template 18 | struct traits > : public traits 19 | { 20 | enum { 21 | Flags = traits::Flags & ~NestByRefBit 22 | }; 23 | }; 24 | } 25 | 26 | /** \class NestByValue 27 | * \ingroup Core_Module 28 | * 29 | * \brief Expression which must be nested by value 30 | * 31 | * \tparam ExpressionType the type of the object of which we are requiring nesting-by-value 32 | * 33 | * This class is the return type of MatrixBase::nestByValue() 34 | * and most of the time this is the only way it is used. 35 | * 36 | * \sa MatrixBase::nestByValue() 37 | */ 38 | template class NestByValue 39 | : public internal::dense_xpr_base< NestByValue >::type 40 | { 41 | public: 42 | 43 | typedef typename internal::dense_xpr_base::type Base; 44 | EIGEN_DENSE_PUBLIC_INTERFACE(NestByValue) 45 | 46 | EIGEN_DEVICE_FUNC explicit inline NestByValue(const ExpressionType& matrix) : m_expression(matrix) {} 47 | 48 | EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR inline Index rows() const EIGEN_NOEXCEPT { return m_expression.rows(); } 49 | EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR inline Index cols() const EIGEN_NOEXCEPT { return m_expression.cols(); } 50 | 51 | EIGEN_DEVICE_FUNC operator const ExpressionType&() const { return m_expression; } 52 | 53 | EIGEN_DEVICE_FUNC const ExpressionType& nestedExpression() const { return m_expression; } 54 | 55 | protected: 56 | const ExpressionType m_expression; 57 | }; 58 | 59 | /** \returns an expression of the temporary version of *this. 60 | */ 61 | template 62 | EIGEN_DEVICE_FUNC inline const NestByValue 63 | DenseBase::nestByValue() const 64 | { 65 | return NestByValue(derived()); 66 | } 67 | 68 | namespace internal { 69 | 70 | // Evaluator of Solve -> eval into a temporary 71 | template 72 | struct evaluator > 73 | : public evaluator 74 | { 75 | typedef evaluator Base; 76 | 77 | EIGEN_DEVICE_FUNC explicit evaluator(const NestByValue& xpr) 78 | : Base(xpr.nestedExpression()) 79 | {} 80 | }; 81 | } 82 | 83 | } // end namespace Eigen 84 | 85 | #endif // EIGEN_NESTBYVALUE_H 86 | -------------------------------------------------------------------------------- /Libs/Eigen/src/Core/SelfCwiseBinaryOp.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 | // 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_SELFCWISEBINARYOP_H 11 | #define EIGEN_SELFCWISEBINARYOP_H 12 | 13 | namespace Eigen { 14 | 15 | // TODO generalize the scalar type of 'other' 16 | 17 | template 18 | EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase::operator*=(const Scalar& other) 19 | { 20 | internal::call_assignment(this->derived(), PlainObject::Constant(rows(),cols(),other), internal::mul_assign_op()); 21 | return derived(); 22 | } 23 | 24 | template 25 | EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& ArrayBase::operator+=(const Scalar& other) 26 | { 27 | internal::call_assignment(this->derived(), PlainObject::Constant(rows(),cols(),other), internal::add_assign_op()); 28 | return derived(); 29 | } 30 | 31 | template 32 | EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& ArrayBase::operator-=(const Scalar& other) 33 | { 34 | internal::call_assignment(this->derived(), PlainObject::Constant(rows(),cols(),other), internal::sub_assign_op()); 35 | return derived(); 36 | } 37 | 38 | template 39 | EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase::operator/=(const Scalar& other) 40 | { 41 | internal::call_assignment(this->derived(), PlainObject::Constant(rows(),cols(),other), internal::div_assign_op()); 42 | return derived(); 43 | } 44 | 45 | } // end namespace Eigen 46 | 47 | #endif // EIGEN_SELFCWISEBINARYOP_H 48 | -------------------------------------------------------------------------------- /Libs/Eigen/src/Core/Swap.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2006-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_SWAP_H 11 | #define EIGEN_SWAP_H 12 | 13 | namespace Eigen { 14 | 15 | namespace internal { 16 | 17 | // Overload default assignPacket behavior for swapping them 18 | template 19 | class generic_dense_assignment_kernel, Specialized> 20 | : public generic_dense_assignment_kernel, BuiltIn> 21 | { 22 | protected: 23 | typedef generic_dense_assignment_kernel, BuiltIn> Base; 24 | using Base::m_dst; 25 | using Base::m_src; 26 | using Base::m_functor; 27 | 28 | public: 29 | typedef typename Base::Scalar Scalar; 30 | typedef typename Base::DstXprType DstXprType; 31 | typedef swap_assign_op Functor; 32 | 33 | EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 34 | generic_dense_assignment_kernel(DstEvaluatorTypeT &dst, const SrcEvaluatorTypeT &src, const Functor &func, DstXprType& dstExpr) 35 | : Base(dst, src, func, dstExpr) 36 | {} 37 | 38 | template 39 | EIGEN_STRONG_INLINE void assignPacket(Index row, Index col) 40 | { 41 | PacketType tmp = m_src.template packet(row,col); 42 | const_cast(m_src).template writePacket(row,col, m_dst.template packet(row,col)); 43 | m_dst.template writePacket(row,col,tmp); 44 | } 45 | 46 | template 47 | EIGEN_STRONG_INLINE void assignPacket(Index index) 48 | { 49 | PacketType tmp = m_src.template packet(index); 50 | const_cast(m_src).template writePacket(index, m_dst.template packet(index)); 51 | m_dst.template writePacket(index,tmp); 52 | } 53 | 54 | // TODO find a simple way not to have to copy/paste this function from generic_dense_assignment_kernel, by simple I mean no CRTP (Gael) 55 | template 56 | EIGEN_STRONG_INLINE void assignPacketByOuterInner(Index outer, Index inner) 57 | { 58 | Index row = Base::rowIndexByOuterInner(outer, inner); 59 | Index col = Base::colIndexByOuterInner(outer, inner); 60 | assignPacket(row, col); 61 | } 62 | }; 63 | 64 | } // namespace internal 65 | 66 | } // end namespace Eigen 67 | 68 | #endif // EIGEN_SWAP_H 69 | -------------------------------------------------------------------------------- /Libs/Eigen/src/Core/VectorBlock.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 | #ifndef EIGEN_VECTORBLOCK_H 12 | #define EIGEN_VECTORBLOCK_H 13 | 14 | namespace Eigen { 15 | 16 | namespace internal { 17 | template 18 | struct traits > 19 | : public traits::Flags & RowMajorBit ? 1 : Size, 21 | traits::Flags & RowMajorBit ? Size : 1> > 22 | { 23 | }; 24 | } 25 | 26 | /** \class VectorBlock 27 | * \ingroup Core_Module 28 | * 29 | * \brief Expression of a fixed-size or dynamic-size sub-vector 30 | * 31 | * \tparam VectorType the type of the object in which we are taking a sub-vector 32 | * \tparam Size size of the sub-vector we are taking at compile time (optional) 33 | * 34 | * This class represents an expression of either a fixed-size or dynamic-size sub-vector. 35 | * It is the return type of DenseBase::segment(Index,Index) and DenseBase::segment(Index) and 36 | * most of the time this is the only way it is used. 37 | * 38 | * However, if you want to directly manipulate sub-vector expressions, 39 | * for instance if you want to write a function returning such an expression, you 40 | * will need to use this class. 41 | * 42 | * Here is an example illustrating the dynamic case: 43 | * \include class_VectorBlock.cpp 44 | * Output: \verbinclude class_VectorBlock.out 45 | * 46 | * \note Even though this expression has dynamic size, in the case where \a VectorType 47 | * has fixed size, this expression inherits a fixed maximal size which means that evaluating 48 | * it does not cause a dynamic memory allocation. 49 | * 50 | * Here is an example illustrating the fixed-size case: 51 | * \include class_FixedVectorBlock.cpp 52 | * Output: \verbinclude class_FixedVectorBlock.out 53 | * 54 | * \sa class Block, DenseBase::segment(Index,Index,Index,Index), DenseBase::segment(Index,Index) 55 | */ 56 | template class VectorBlock 57 | : public Block::Flags & RowMajorBit ? 1 : Size, 59 | internal::traits::Flags & RowMajorBit ? Size : 1> 60 | { 61 | typedef Block::Flags & RowMajorBit ? 1 : Size, 63 | internal::traits::Flags & RowMajorBit ? Size : 1> Base; 64 | enum { 65 | IsColVector = !(internal::traits::Flags & RowMajorBit) 66 | }; 67 | public: 68 | EIGEN_DENSE_PUBLIC_INTERFACE(VectorBlock) 69 | 70 | using Base::operator=; 71 | 72 | /** Dynamic-size constructor 73 | */ 74 | EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 75 | VectorBlock(VectorType& vector, Index start, Index size) 76 | : Base(vector, 77 | IsColVector ? start : 0, IsColVector ? 0 : start, 78 | IsColVector ? size : 1, IsColVector ? 1 : size) 79 | { 80 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(VectorBlock); 81 | } 82 | 83 | /** Fixed-size constructor 84 | */ 85 | EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 86 | VectorBlock(VectorType& vector, Index start) 87 | : Base(vector, IsColVector ? start : 0, IsColVector ? 0 : start) 88 | { 89 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(VectorBlock); 90 | } 91 | }; 92 | 93 | 94 | } // end namespace Eigen 95 | 96 | #endif // EIGEN_VECTORBLOCK_H 97 | -------------------------------------------------------------------------------- /Libs/Eigen/src/Core/arch/AVX/TypeCasting.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2015 Benoit Steiner 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_TYPE_CASTING_AVX_H 11 | #define EIGEN_TYPE_CASTING_AVX_H 12 | 13 | namespace Eigen { 14 | 15 | namespace internal { 16 | 17 | // For now we use SSE to handle integers, so we can't use AVX instructions to cast 18 | // from int to float 19 | template <> 20 | struct type_casting_traits { 21 | enum { 22 | VectorizedCast = 0, 23 | SrcCoeffRatio = 1, 24 | TgtCoeffRatio = 1 25 | }; 26 | }; 27 | 28 | template <> 29 | struct type_casting_traits { 30 | enum { 31 | VectorizedCast = 0, 32 | SrcCoeffRatio = 1, 33 | TgtCoeffRatio = 1 34 | }; 35 | }; 36 | 37 | 38 | #ifndef EIGEN_VECTORIZE_AVX512 39 | 40 | template <> 41 | struct type_casting_traits { 42 | enum { 43 | VectorizedCast = 1, 44 | SrcCoeffRatio = 1, 45 | TgtCoeffRatio = 1 46 | }; 47 | }; 48 | 49 | 50 | template <> 51 | struct type_casting_traits { 52 | enum { 53 | VectorizedCast = 1, 54 | SrcCoeffRatio = 1, 55 | TgtCoeffRatio = 1 56 | }; 57 | }; 58 | 59 | template <> 60 | struct type_casting_traits { 61 | enum { 62 | VectorizedCast = 1, 63 | SrcCoeffRatio = 1, 64 | TgtCoeffRatio = 1 65 | }; 66 | }; 67 | 68 | template <> 69 | struct type_casting_traits { 70 | enum { 71 | VectorizedCast = 1, 72 | SrcCoeffRatio = 1, 73 | TgtCoeffRatio = 1 74 | }; 75 | }; 76 | 77 | #endif // EIGEN_VECTORIZE_AVX512 78 | 79 | template<> EIGEN_STRONG_INLINE Packet8i pcast(const Packet8f& a) { 80 | return _mm256_cvttps_epi32(a); 81 | } 82 | 83 | template<> EIGEN_STRONG_INLINE Packet8f pcast(const Packet8i& a) { 84 | return _mm256_cvtepi32_ps(a); 85 | } 86 | 87 | template<> EIGEN_STRONG_INLINE Packet8i preinterpret(const Packet8f& a) { 88 | return _mm256_castps_si256(a); 89 | } 90 | 91 | template<> EIGEN_STRONG_INLINE Packet8f preinterpret(const Packet8i& a) { 92 | return _mm256_castsi256_ps(a); 93 | } 94 | 95 | template<> EIGEN_STRONG_INLINE Packet8f pcast(const Packet8h& a) { 96 | return half2float(a); 97 | } 98 | 99 | template<> EIGEN_STRONG_INLINE Packet8f pcast(const Packet8bf& a) { 100 | return Bf16ToF32(a); 101 | } 102 | 103 | template<> EIGEN_STRONG_INLINE Packet8h pcast(const Packet8f& a) { 104 | return float2half(a); 105 | } 106 | 107 | template<> EIGEN_STRONG_INLINE Packet8bf pcast(const Packet8f& a) { 108 | return F32ToBf16(a); 109 | } 110 | 111 | } // end namespace internal 112 | 113 | } // end namespace Eigen 114 | 115 | #endif // EIGEN_TYPE_CASTING_AVX_H 116 | -------------------------------------------------------------------------------- /Libs/Eigen/src/Core/arch/AVX512/TypeCasting.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2019 Rasmus Munk Larsen 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_TYPE_CASTING_AVX512_H 11 | #define EIGEN_TYPE_CASTING_AVX512_H 12 | 13 | namespace Eigen { 14 | 15 | namespace internal { 16 | 17 | template<> EIGEN_STRONG_INLINE Packet16i pcast(const Packet16f& a) { 18 | return _mm512_cvttps_epi32(a); 19 | } 20 | 21 | template<> EIGEN_STRONG_INLINE Packet16f pcast(const Packet16i& a) { 22 | return _mm512_cvtepi32_ps(a); 23 | } 24 | 25 | template<> EIGEN_STRONG_INLINE Packet16i preinterpret(const Packet16f& a) { 26 | return _mm512_castps_si512(a); 27 | } 28 | 29 | template<> EIGEN_STRONG_INLINE Packet16f preinterpret(const Packet16i& a) { 30 | return _mm512_castsi512_ps(a); 31 | } 32 | 33 | template <> 34 | struct type_casting_traits { 35 | enum { 36 | VectorizedCast = 1, 37 | SrcCoeffRatio = 1, 38 | TgtCoeffRatio = 1 39 | }; 40 | }; 41 | 42 | template<> EIGEN_STRONG_INLINE Packet16f pcast(const Packet16h& a) { 43 | return half2float(a); 44 | } 45 | 46 | template <> 47 | struct type_casting_traits { 48 | enum { 49 | VectorizedCast = 1, 50 | SrcCoeffRatio = 1, 51 | TgtCoeffRatio = 1 52 | }; 53 | }; 54 | 55 | template<> EIGEN_STRONG_INLINE Packet16h pcast(const Packet16f& a) { 56 | return float2half(a); 57 | } 58 | 59 | template <> 60 | struct type_casting_traits { 61 | enum { 62 | VectorizedCast = 1, 63 | SrcCoeffRatio = 1, 64 | TgtCoeffRatio = 1 65 | }; 66 | }; 67 | 68 | template<> EIGEN_STRONG_INLINE Packet16f pcast(const Packet16bf& a) { 69 | return Bf16ToF32(a); 70 | } 71 | 72 | template <> 73 | struct type_casting_traits { 74 | enum { 75 | VectorizedCast = 1, 76 | SrcCoeffRatio = 1, 77 | TgtCoeffRatio = 1 78 | }; 79 | }; 80 | 81 | template<> EIGEN_STRONG_INLINE Packet16bf pcast(const Packet16f& a) { 82 | return F32ToBf16(a); 83 | } 84 | 85 | } // end namespace internal 86 | 87 | } // end namespace Eigen 88 | 89 | #endif // EIGEN_TYPE_CASTING_AVX512_H 90 | -------------------------------------------------------------------------------- /Libs/Eigen/src/Core/arch/AltiVec/MathFunctions.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2007 Julien Pommier 5 | // Copyright (C) 2009 Gael Guennebaud 6 | // Copyright (C) 2016 Konstantinos Margaritis 7 | // 8 | // This Source Code Form is subject to the terms of the Mozilla 9 | // Public License v. 2.0. If a copy of the MPL was not distributed 10 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 11 | 12 | #ifndef EIGEN_MATH_FUNCTIONS_ALTIVEC_H 13 | #define EIGEN_MATH_FUNCTIONS_ALTIVEC_H 14 | 15 | namespace Eigen { 16 | 17 | namespace internal { 18 | 19 | template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED 20 | Packet4f plog(const Packet4f& _x) 21 | { 22 | return plog_float(_x); 23 | } 24 | 25 | template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED 26 | Packet4f pexp(const Packet4f& _x) 27 | { 28 | return pexp_float(_x); 29 | } 30 | 31 | template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED 32 | Packet4f psin(const Packet4f& _x) 33 | { 34 | return psin_float(_x); 35 | } 36 | 37 | template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED 38 | Packet4f pcos(const Packet4f& _x) 39 | { 40 | return pcos_float(_x); 41 | } 42 | 43 | #ifndef EIGEN_COMP_CLANG 44 | template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED 45 | Packet4f prsqrt(const Packet4f& x) 46 | { 47 | return vec_rsqrt(x); 48 | } 49 | #endif 50 | 51 | #ifdef __VSX__ 52 | #ifndef EIGEN_COMP_CLANG 53 | template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED 54 | Packet2d prsqrt(const Packet2d& x) 55 | { 56 | return vec_rsqrt(x); 57 | } 58 | #endif 59 | 60 | template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED 61 | Packet4f psqrt(const Packet4f& x) 62 | { 63 | return vec_sqrt(x); 64 | } 65 | 66 | template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED 67 | Packet2d psqrt(const Packet2d& x) 68 | { 69 | return vec_sqrt(x); 70 | } 71 | 72 | template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED 73 | Packet2d pexp(const Packet2d& _x) 74 | { 75 | return pexp_double(_x); 76 | } 77 | #endif 78 | 79 | // Hyperbolic Tangent function. 80 | template <> 81 | EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED Packet4f 82 | ptanh(const Packet4f& x) { 83 | return internal::generic_fast_tanh_float(x); 84 | } 85 | 86 | } // end namespace internal 87 | 88 | } // end namespace Eigen 89 | 90 | #endif // EIGEN_MATH_FUNCTIONS_ALTIVEC_H 91 | -------------------------------------------------------------------------------- /Libs/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 110 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 | -------------------------------------------------------------------------------- /Libs/Eigen/src/Core/arch/GPU/MathFunctions.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2014 Benoit Steiner 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_MATH_FUNCTIONS_GPU_H 11 | #define EIGEN_MATH_FUNCTIONS_GPU_H 12 | 13 | namespace Eigen { 14 | 15 | namespace internal { 16 | 17 | // Make sure this is only available when targeting a GPU: we don't want to 18 | // introduce conflicts between these packet_traits definitions and the ones 19 | // we'll use on the host side (SSE, AVX, ...) 20 | #if defined(EIGEN_GPUCC) && defined(EIGEN_USE_GPU) 21 | template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 22 | float4 plog(const float4& a) 23 | { 24 | return make_float4(logf(a.x), logf(a.y), logf(a.z), logf(a.w)); 25 | } 26 | 27 | template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 28 | double2 plog(const double2& a) 29 | { 30 | using ::log; 31 | return make_double2(log(a.x), log(a.y)); 32 | } 33 | 34 | template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 35 | float4 plog1p(const float4& a) 36 | { 37 | return make_float4(log1pf(a.x), log1pf(a.y), log1pf(a.z), log1pf(a.w)); 38 | } 39 | 40 | template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 41 | double2 plog1p(const double2& a) 42 | { 43 | return make_double2(log1p(a.x), log1p(a.y)); 44 | } 45 | 46 | template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 47 | float4 pexp(const float4& a) 48 | { 49 | return make_float4(expf(a.x), expf(a.y), expf(a.z), expf(a.w)); 50 | } 51 | 52 | template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 53 | double2 pexp(const double2& a) 54 | { 55 | using ::exp; 56 | return make_double2(exp(a.x), exp(a.y)); 57 | } 58 | 59 | template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 60 | float4 pexpm1(const float4& a) 61 | { 62 | return make_float4(expm1f(a.x), expm1f(a.y), expm1f(a.z), expm1f(a.w)); 63 | } 64 | 65 | template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 66 | double2 pexpm1(const double2& a) 67 | { 68 | return make_double2(expm1(a.x), expm1(a.y)); 69 | } 70 | 71 | template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 72 | float4 psqrt(const float4& a) 73 | { 74 | return make_float4(sqrtf(a.x), sqrtf(a.y), sqrtf(a.z), sqrtf(a.w)); 75 | } 76 | 77 | template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 78 | double2 psqrt(const double2& a) 79 | { 80 | using ::sqrt; 81 | return make_double2(sqrt(a.x), sqrt(a.y)); 82 | } 83 | 84 | template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 85 | float4 prsqrt(const float4& a) 86 | { 87 | return make_float4(rsqrtf(a.x), rsqrtf(a.y), rsqrtf(a.z), rsqrtf(a.w)); 88 | } 89 | 90 | template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 91 | double2 prsqrt(const double2& a) 92 | { 93 | return make_double2(rsqrt(a.x), rsqrt(a.y)); 94 | } 95 | 96 | 97 | #endif 98 | 99 | } // end namespace internal 100 | 101 | } // end namespace Eigen 102 | 103 | #endif // EIGEN_MATH_FUNCTIONS_GPU_H 104 | -------------------------------------------------------------------------------- /Libs/Eigen/src/Core/arch/GPU/TypeCasting.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2016 Benoit Steiner 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_TYPE_CASTING_GPU_H 11 | #define EIGEN_TYPE_CASTING_GPU_H 12 | 13 | namespace Eigen { 14 | 15 | namespace internal { 16 | 17 | #if (defined(EIGEN_HAS_CUDA_FP16) && defined(EIGEN_CUDA_ARCH) && EIGEN_CUDA_ARCH >= 300) || \ 18 | (defined(EIGEN_HAS_HIP_FP16) && defined(EIGEN_HIP_DEVICE_COMPILE)) 19 | 20 | 21 | template <> 22 | struct type_casting_traits { 23 | enum { 24 | VectorizedCast = 1, 25 | SrcCoeffRatio = 1, 26 | TgtCoeffRatio = 2 27 | }; 28 | }; 29 | 30 | template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pcast(const half2& a, const half2& b) { 31 | float2 r1 = __half22float2(a); 32 | float2 r2 = __half22float2(b); 33 | return make_float4(r1.x, r1.y, r2.x, r2.y); 34 | } 35 | 36 | 37 | template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet4h2 pcast(const float4& a, const float4& b) { 38 | Packet4h2 r; 39 | half2* r_alias=reinterpret_cast(&r); 40 | r_alias[0]=__floats2half2_rn(a.x,a.y); 41 | r_alias[1]=__floats2half2_rn(a.z,a.w); 42 | r_alias[2]=__floats2half2_rn(b.x,b.y); 43 | r_alias[3]=__floats2half2_rn(b.z,b.w); 44 | return r; 45 | } 46 | 47 | template <> 48 | struct type_casting_traits { 49 | enum { 50 | VectorizedCast = 1, 51 | SrcCoeffRatio = 2, 52 | TgtCoeffRatio = 1 53 | }; 54 | }; 55 | 56 | template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE float4 pcast(const Packet4h2& a) { 57 | // Simply discard the second half of the input 58 | float4 r; 59 | const half2* a_alias=reinterpret_cast(&a); 60 | float2 r1 = __half22float2(a_alias[0]); 61 | float2 r2 = __half22float2(a_alias[1]); 62 | r.x=static_cast(r1.x); 63 | r.y=static_cast(r1.y); 64 | r.z=static_cast(r2.x); 65 | r.w=static_cast(r2.y); 66 | return r; 67 | } 68 | 69 | template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE half2 pcast(const float4& a) { 70 | // Simply discard the second half of the input 71 | return __floats2half2_rn(a.x, a.y); 72 | } 73 | 74 | #endif 75 | 76 | } // end namespace internal 77 | 78 | } // end namespace Eigen 79 | 80 | #endif // EIGEN_TYPE_CASTING_GPU_H 81 | -------------------------------------------------------------------------------- /Libs/Eigen/src/Core/arch/HIP/hcc/math_constants.h: -------------------------------------------------------------------------------- 1 | /* 2 | * math_constants.h - 3 | * HIP equivalent of the CUDA header of the same name 4 | */ 5 | 6 | #ifndef __MATH_CONSTANTS_H__ 7 | #define __MATH_CONSTANTS_H__ 8 | 9 | /* single precision constants */ 10 | 11 | #define HIPRT_INF_F __int_as_float(0x7f800000) 12 | #define HIPRT_NAN_F __int_as_float(0x7fffffff) 13 | #define HIPRT_MIN_DENORM_F __int_as_float(0x00000001) 14 | #define HIPRT_MAX_NORMAL_F __int_as_float(0x7f7fffff) 15 | #define HIPRT_NEG_ZERO_F __int_as_float(0x80000000) 16 | #define HIPRT_ZERO_F 0.0f 17 | #define HIPRT_ONE_F 1.0f 18 | 19 | /* double precision constants */ 20 | #define HIPRT_INF __hiloint2double(0x7ff00000, 0x00000000) 21 | #define HIPRT_NAN __hiloint2double(0xfff80000, 0x00000000) 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /Libs/Eigen/src/Core/arch/NEON/MathFunctions.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_MATH_FUNCTIONS_NEON_H 9 | #define EIGEN_MATH_FUNCTIONS_NEON_H 10 | 11 | namespace Eigen { 12 | 13 | namespace internal { 14 | 15 | template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED Packet2f pexp(const Packet2f& x) 16 | { return pexp_float(x); } 17 | template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED Packet4f pexp(const Packet4f& x) 18 | { return pexp_float(x); } 19 | 20 | template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED Packet2f plog(const Packet2f& x) 21 | { return plog_float(x); } 22 | template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED Packet4f plog(const Packet4f& x) 23 | { return plog_float(x); } 24 | 25 | template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED Packet2f psin(const Packet2f& x) 26 | { return psin_float(x); } 27 | template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED Packet4f psin(const Packet4f& x) 28 | { return psin_float(x); } 29 | 30 | template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED Packet2f pcos(const Packet2f& x) 31 | { return pcos_float(x); } 32 | template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED Packet4f pcos(const Packet4f& x) 33 | { return pcos_float(x); } 34 | 35 | // Hyperbolic Tangent function. 36 | template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED Packet2f ptanh(const Packet2f& x) 37 | { return internal::generic_fast_tanh_float(x); } 38 | template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED Packet4f ptanh(const Packet4f& x) 39 | { return internal::generic_fast_tanh_float(x); } 40 | 41 | BF16_PACKET_FUNCTION(Packet4f, Packet4bf, psin) 42 | BF16_PACKET_FUNCTION(Packet4f, Packet4bf, pcos) 43 | BF16_PACKET_FUNCTION(Packet4f, Packet4bf, plog) 44 | BF16_PACKET_FUNCTION(Packet4f, Packet4bf, pexp) 45 | BF16_PACKET_FUNCTION(Packet4f, Packet4bf, ptanh) 46 | 47 | template <> 48 | EIGEN_STRONG_INLINE Packet4bf pfrexp(const Packet4bf& a, Packet4bf& exponent) { 49 | Packet4f fexponent; 50 | const Packet4bf out = F32ToBf16(pfrexp(Bf16ToF32(a), fexponent)); 51 | exponent = F32ToBf16(fexponent); 52 | return out; 53 | } 54 | 55 | template <> 56 | EIGEN_STRONG_INLINE Packet4bf pldexp(const Packet4bf& a, const Packet4bf& exponent) { 57 | return F32ToBf16(pldexp(Bf16ToF32(a), Bf16ToF32(exponent))); 58 | } 59 | 60 | //---------- double ---------- 61 | 62 | #if EIGEN_ARCH_ARM64 && !EIGEN_APPLE_DOUBLE_NEON_BUG 63 | template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED Packet2d pexp(const Packet2d& x) 64 | { return pexp_double(x); } 65 | 66 | template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED Packet2d plog(const Packet2d& x) 67 | { return plog_double(x); } 68 | 69 | #endif 70 | 71 | } // end namespace internal 72 | 73 | } // end namespace Eigen 74 | 75 | #endif // EIGEN_MATH_FUNCTIONS_NEON_H 76 | -------------------------------------------------------------------------------- /Libs/Eigen/src/Core/arch/SVE/MathFunctions.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2020, Arm Limited and Contributors 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_MATH_FUNCTIONS_SVE_H 11 | #define EIGEN_MATH_FUNCTIONS_SVE_H 12 | 13 | namespace Eigen { 14 | namespace internal { 15 | 16 | template <> 17 | EIGEN_STRONG_INLINE EIGEN_UNUSED PacketXf pexp(const PacketXf& x) { 18 | return pexp_float(x); 19 | } 20 | 21 | template <> 22 | EIGEN_STRONG_INLINE EIGEN_UNUSED PacketXf plog(const PacketXf& x) { 23 | return plog_float(x); 24 | } 25 | 26 | template <> 27 | EIGEN_STRONG_INLINE EIGEN_UNUSED PacketXf psin(const PacketXf& x) { 28 | return psin_float(x); 29 | } 30 | 31 | template <> 32 | EIGEN_STRONG_INLINE EIGEN_UNUSED PacketXf pcos(const PacketXf& x) { 33 | return pcos_float(x); 34 | } 35 | 36 | // Hyperbolic Tangent function. 37 | template <> 38 | EIGEN_STRONG_INLINE EIGEN_UNUSED PacketXf ptanh(const PacketXf& x) { 39 | return internal::generic_fast_tanh_float(x); 40 | } 41 | } // end namespace internal 42 | } // end namespace Eigen 43 | 44 | #endif // EIGEN_MATH_FUNCTIONS_SVE_H 45 | -------------------------------------------------------------------------------- /Libs/Eigen/src/Core/arch/SVE/TypeCasting.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2020, Arm Limited and Contributors 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_TYPE_CASTING_SVE_H 11 | #define EIGEN_TYPE_CASTING_SVE_H 12 | 13 | namespace Eigen { 14 | namespace internal { 15 | 16 | template <> 17 | struct type_casting_traits { 18 | enum { VectorizedCast = 1, SrcCoeffRatio = 1, TgtCoeffRatio = 1 }; 19 | }; 20 | 21 | template <> 22 | struct type_casting_traits { 23 | enum { VectorizedCast = 1, SrcCoeffRatio = 1, TgtCoeffRatio = 1 }; 24 | }; 25 | 26 | template <> 27 | EIGEN_STRONG_INLINE PacketXf pcast(const PacketXi& a) { 28 | return svcvt_f32_s32_z(svptrue_b32(), a); 29 | } 30 | 31 | template <> 32 | EIGEN_STRONG_INLINE PacketXi pcast(const PacketXf& a) { 33 | return svcvt_s32_f32_z(svptrue_b32(), a); 34 | } 35 | 36 | template <> 37 | EIGEN_STRONG_INLINE PacketXf preinterpret(const PacketXi& a) { 38 | return svreinterpret_f32_s32(a); 39 | } 40 | 41 | template <> 42 | EIGEN_STRONG_INLINE PacketXi preinterpret(const PacketXf& a) { 43 | return svreinterpret_s32_f32(a); 44 | } 45 | 46 | } // namespace internal 47 | } // namespace Eigen 48 | 49 | #endif // EIGEN_TYPE_CASTING_SVE_H 50 | -------------------------------------------------------------------------------- /Libs/Eigen/src/Core/arch/SYCL/TypeCasting.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Mehdi Goli Codeplay Software Ltd. 5 | // Ralph Potter Codeplay Software Ltd. 6 | // Luke Iwanski Codeplay Software Ltd. 7 | // Contact: 8 | // 9 | // This Source Code Form is subject to the terms of the Mozilla 10 | // Public License v. 2.0. If a copy of the MPL was not distributed 11 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 12 | 13 | /***************************************************************** 14 | * TypeCasting.h 15 | * 16 | * \brief: 17 | * TypeCasting 18 | * 19 | *****************************************************************/ 20 | 21 | #ifndef EIGEN_TYPE_CASTING_SYCL_H 22 | #define EIGEN_TYPE_CASTING_SYCL_H 23 | 24 | namespace Eigen { 25 | 26 | namespace internal { 27 | #ifdef SYCL_DEVICE_ONLY 28 | template <> 29 | struct type_casting_traits { 30 | enum { VectorizedCast = 1, SrcCoeffRatio = 1, TgtCoeffRatio = 1 }; 31 | }; 32 | 33 | template <> 34 | EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE cl::sycl::cl_int4 35 | pcast(const cl::sycl::cl_float4& a) { 36 | return a 37 | .template convert(); 38 | } 39 | 40 | template <> 41 | struct type_casting_traits { 42 | enum { VectorizedCast = 1, SrcCoeffRatio = 1, TgtCoeffRatio = 1 }; 43 | }; 44 | 45 | template <> 46 | EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE cl::sycl::cl_float4 47 | pcast(const cl::sycl::cl_int4& a) { 48 | return a.template convert(); 50 | } 51 | 52 | template <> 53 | struct type_casting_traits { 54 | enum { VectorizedCast = 1, SrcCoeffRatio = 2, TgtCoeffRatio = 1 }; 55 | }; 56 | 57 | template <> 58 | EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE cl::sycl::cl_float4 59 | pcast( 60 | const cl::sycl::cl_double2& a, const cl::sycl::cl_double2& b) { 61 | auto a1 = a.template convert(); 63 | auto b1 = b.template convert(); 65 | return cl::sycl::float4(a1.x(), a1.y(), b1.x(), b1.y()); 66 | } 67 | 68 | template <> 69 | struct type_casting_traits { 70 | enum { VectorizedCast = 1, SrcCoeffRatio = 1, TgtCoeffRatio = 2 }; 71 | }; 72 | 73 | template <> 74 | EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE cl::sycl::cl_double2 75 | pcast(const cl::sycl::cl_float4& a) { 76 | // Simply discard the second half of the input 77 | return cl::sycl::cl_double2(a.x(), a.y()); 78 | } 79 | 80 | #endif 81 | } // end namespace internal 82 | 83 | } // end namespace Eigen 84 | 85 | #endif // EIGEN_TYPE_CASTING_SYCL_H 86 | -------------------------------------------------------------------------------- /Libs/Eigen/src/Core/functors/TernaryFunctors.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2016 Eugene Brevdo 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_TERNARY_FUNCTORS_H 11 | #define EIGEN_TERNARY_FUNCTORS_H 12 | 13 | namespace Eigen { 14 | 15 | namespace internal { 16 | 17 | //---------- associative ternary functors ---------- 18 | 19 | 20 | 21 | } // end namespace internal 22 | 23 | } // end namespace Eigen 24 | 25 | #endif // EIGEN_TERNARY_FUNCTORS_H 26 | -------------------------------------------------------------------------------- /Libs/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 | -------------------------------------------------------------------------------- /Libs/Eigen/src/Core/util/ReenableStupidWarnings.h: -------------------------------------------------------------------------------- 1 | #ifdef EIGEN_WARNINGS_DISABLED_2 2 | // "DisableStupidWarnings.h" was included twice recursively: Do not reenable warnings yet! 3 | # undef EIGEN_WARNINGS_DISABLED_2 4 | 5 | #elif defined(EIGEN_WARNINGS_DISABLED) 6 | #undef EIGEN_WARNINGS_DISABLED 7 | 8 | #ifndef EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS 9 | #ifdef _MSC_VER 10 | #pragma warning( pop ) 11 | #elif defined __INTEL_COMPILER 12 | #pragma warning pop 13 | #elif defined __clang__ 14 | #pragma clang diagnostic pop 15 | #elif defined __GNUC__ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) 16 | #pragma GCC diagnostic pop 17 | #endif 18 | 19 | #if defined __NVCC__ 20 | // Don't reenable the diagnostic messages, as it turns out these messages need 21 | // to be disabled at the point of the template instantiation (i.e the user code) 22 | // otherwise they'll be triggered by nvcc. 23 | // #pragma diag_default code_is_unreachable 24 | // #pragma diag_default initialization_not_reachable 25 | // #pragma diag_default 2651 26 | // #pragma diag_default 2653 27 | #endif 28 | 29 | #endif 30 | 31 | #endif // EIGEN_WARNINGS_DISABLED 32 | -------------------------------------------------------------------------------- /Libs/Eigen/src/Core/util/ReshapedHelper.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2017 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 | 11 | #ifndef EIGEN_RESHAPED_HELPER_H 12 | #define EIGEN_RESHAPED_HELPER_H 13 | 14 | namespace Eigen { 15 | 16 | enum AutoSize_t { AutoSize }; 17 | const int AutoOrder = 2; 18 | 19 | namespace internal { 20 | 21 | template 22 | struct get_compiletime_reshape_size { 23 | enum { value = get_fixed_value::value }; 24 | }; 25 | 26 | template 27 | Index get_runtime_reshape_size(SizeType size, Index /*other*/, Index /*total*/) { 28 | return internal::get_runtime_value(size); 29 | } 30 | 31 | template 32 | struct get_compiletime_reshape_size { 33 | enum { 34 | other_size = get_fixed_value::value, 35 | value = (TotalSize==Dynamic || other_size==Dynamic) ? Dynamic : TotalSize / other_size }; 36 | }; 37 | 38 | inline Index get_runtime_reshape_size(AutoSize_t /*size*/, Index other, Index total) { 39 | return total/other; 40 | } 41 | 42 | template 43 | struct get_compiletime_reshape_order { 44 | enum { value = Order == AutoOrder ? Flags & RowMajorBit : Order }; 45 | }; 46 | 47 | } 48 | 49 | } // end namespace Eigen 50 | 51 | #endif // EIGEN_RESHAPED_HELPER_H 52 | -------------------------------------------------------------------------------- /Libs/Eigen/src/Eigenvalues/RealSchur_LAPACKE.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 LAPACKe 29 | * Real Schur needed to real unsymmetrical eigenvalues/eigenvectors. 30 | ******************************************************************************** 31 | */ 32 | 33 | #ifndef EIGEN_REAL_SCHUR_LAPACKE_H 34 | #define EIGEN_REAL_SCHUR_LAPACKE_H 35 | 36 | namespace Eigen { 37 | 38 | /** \internal Specialization for the data types supported by LAPACKe */ 39 | 40 | #define EIGEN_LAPACKE_SCHUR_REAL(EIGTYPE, LAPACKE_TYPE, LAPACKE_PREFIX, LAPACKE_PREFIX_U, EIGCOLROW, LAPACKE_COLROW) \ 41 | template<> template inline \ 42 | RealSchur >& \ 43 | RealSchur >::compute(const EigenBase& matrix, bool computeU) \ 44 | { \ 45 | eigen_assert(matrix.cols() == matrix.rows()); \ 46 | \ 47 | lapack_int n = internal::convert_index(matrix.cols()), sdim, info; \ 48 | lapack_int matrix_order = LAPACKE_COLROW; \ 49 | char jobvs, sort='N'; \ 50 | LAPACK_##LAPACKE_PREFIX_U##_SELECT2 select = 0; \ 51 | jobvs = (computeU) ? 'V' : 'N'; \ 52 | m_matU.resize(n, n); \ 53 | lapack_int ldvs = internal::convert_index(m_matU.outerStride()); \ 54 | m_matT = matrix; \ 55 | lapack_int lda = internal::convert_index(m_matT.outerStride()); \ 56 | Matrix wr, wi; \ 57 | wr.resize(n, 1); wi.resize(n, 1); \ 58 | info = LAPACKE_##LAPACKE_PREFIX##gees( matrix_order, jobvs, sort, select, n, (LAPACKE_TYPE*)m_matT.data(), lda, &sdim, (LAPACKE_TYPE*)wr.data(), (LAPACKE_TYPE*)wi.data(), (LAPACKE_TYPE*)m_matU.data(), ldvs ); \ 59 | if(info == 0) \ 60 | m_info = Success; \ 61 | else \ 62 | m_info = NoConvergence; \ 63 | \ 64 | m_isInitialized = true; \ 65 | m_matUisUptodate = computeU; \ 66 | return *this; \ 67 | \ 68 | } 69 | 70 | EIGEN_LAPACKE_SCHUR_REAL(double, double, d, D, ColMajor, LAPACK_COL_MAJOR) 71 | EIGEN_LAPACKE_SCHUR_REAL(float, float, s, S, ColMajor, LAPACK_COL_MAJOR) 72 | EIGEN_LAPACKE_SCHUR_REAL(double, double, d, D, RowMajor, LAPACK_ROW_MAJOR) 73 | EIGEN_LAPACKE_SCHUR_REAL(float, float, s, S, RowMajor, LAPACK_ROW_MAJOR) 74 | 75 | } // end namespace Eigen 76 | 77 | #endif // EIGEN_REAL_SCHUR_LAPACKE_H 78 | -------------------------------------------------------------------------------- /Libs/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 | EIGEN_DEVICE_FUNC 19 | inline const typename Derived::Scalar bruteforce_det3_helper 20 | (const MatrixBase& matrix, int a, int b, int c) 21 | { 22 | return matrix.coeff(0,a) 23 | * (matrix.coeff(1,b) * matrix.coeff(2,c) - matrix.coeff(1,c) * matrix.coeff(2,b)); 24 | } 25 | 26 | template struct determinant_impl 29 | { 30 | static inline typename traits::Scalar run(const Derived& m) 31 | { 32 | if(Derived::ColsAtCompileTime==Dynamic && m.rows()==0) 33 | return typename traits::Scalar(1); 34 | return m.partialPivLu().determinant(); 35 | } 36 | }; 37 | 38 | template struct determinant_impl 39 | { 40 | static inline EIGEN_DEVICE_FUNC 41 | typename traits::Scalar run(const Derived& m) 42 | { 43 | return m.coeff(0,0); 44 | } 45 | }; 46 | 47 | template struct determinant_impl 48 | { 49 | static inline EIGEN_DEVICE_FUNC 50 | typename traits::Scalar run(const Derived& m) 51 | { 52 | return m.coeff(0,0) * m.coeff(1,1) - m.coeff(1,0) * m.coeff(0,1); 53 | } 54 | }; 55 | 56 | template struct determinant_impl 57 | { 58 | static inline EIGEN_DEVICE_FUNC 59 | typename traits::Scalar run(const Derived& m) 60 | { 61 | return bruteforce_det3_helper(m,0,1,2) 62 | - bruteforce_det3_helper(m,1,0,2) 63 | + bruteforce_det3_helper(m,2,0,1); 64 | } 65 | }; 66 | 67 | template struct determinant_impl 68 | { 69 | typedef typename traits::Scalar Scalar; 70 | static EIGEN_DEVICE_FUNC 71 | Scalar run(const Derived& m) 72 | { 73 | Scalar d2_01 = det2(m, 0, 1); 74 | Scalar d2_02 = det2(m, 0, 2); 75 | Scalar d2_03 = det2(m, 0, 3); 76 | Scalar d2_12 = det2(m, 1, 2); 77 | Scalar d2_13 = det2(m, 1, 3); 78 | Scalar d2_23 = det2(m, 2, 3); 79 | Scalar d3_0 = det3(m, 1,d2_23, 2,d2_13, 3,d2_12); 80 | Scalar d3_1 = det3(m, 0,d2_23, 2,d2_03, 3,d2_02); 81 | Scalar d3_2 = det3(m, 0,d2_13, 1,d2_03, 3,d2_01); 82 | Scalar d3_3 = det3(m, 0,d2_12, 1,d2_02, 2,d2_01); 83 | return internal::pmadd(-m(0,3),d3_0, m(1,3)*d3_1) + 84 | internal::pmadd(-m(2,3),d3_2, m(3,3)*d3_3); 85 | } 86 | protected: 87 | static EIGEN_DEVICE_FUNC 88 | Scalar det2(const Derived& m, Index i0, Index i1) 89 | { 90 | return m(i0,0) * m(i1,1) - m(i1,0) * m(i0,1); 91 | } 92 | 93 | static EIGEN_DEVICE_FUNC 94 | Scalar det3(const Derived& m, Index i0, const Scalar& d0, Index i1, const Scalar& d1, Index i2, const Scalar& d2) 95 | { 96 | return internal::pmadd(m(i0,2), d0, internal::pmadd(-m(i1,2), d1, m(i2,2)*d2)); 97 | } 98 | }; 99 | 100 | } // end namespace internal 101 | 102 | /** \lu_module 103 | * 104 | * \returns the determinant of this matrix 105 | */ 106 | template 107 | EIGEN_DEVICE_FUNC 108 | inline typename internal::traits::Scalar MatrixBase::determinant() const 109 | { 110 | eigen_assert(rows() == cols()); 111 | typedef typename internal::nested_eval::type Nested; 112 | return internal::determinant_impl::type>::run(derived()); 113 | } 114 | 115 | } // end namespace Eigen 116 | 117 | #endif // EIGEN_DETERMINANT_H 118 | -------------------------------------------------------------------------------- /Libs/Eigen/src/LU/PartialPivLU_LAPACKE.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 LAPACKe 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 | namespace Eigen { 37 | 38 | namespace internal { 39 | 40 | /** \internal Specialization for the data types supported by LAPACKe */ 41 | 42 | #define EIGEN_LAPACKE_LU_PARTPIV(EIGTYPE, LAPACKE_TYPE, LAPACKE_PREFIX) \ 43 | template \ 44 | struct partial_lu_impl \ 45 | { \ 46 | /* \internal performs the LU decomposition in-place of the matrix represented */ \ 47 | static lapack_int blocked_lu(Index rows, Index cols, EIGTYPE* lu_data, Index luStride, lapack_int* row_transpositions, lapack_int& nb_transpositions, lapack_int maxBlockSize=256) \ 48 | { \ 49 | EIGEN_UNUSED_VARIABLE(maxBlockSize);\ 50 | lapack_int matrix_order, first_zero_pivot; \ 51 | lapack_int m, n, lda, *ipiv, info; \ 52 | EIGTYPE* a; \ 53 | /* Set up parameters for ?getrf */ \ 54 | matrix_order = StorageOrder==RowMajor ? LAPACK_ROW_MAJOR : LAPACK_COL_MAJOR; \ 55 | lda = convert_index(luStride); \ 56 | a = lu_data; \ 57 | ipiv = row_transpositions; \ 58 | m = convert_index(rows); \ 59 | n = convert_index(cols); \ 60 | nb_transpositions = 0; \ 61 | \ 62 | info = LAPACKE_##LAPACKE_PREFIX##getrf( matrix_order, m, n, (LAPACKE_TYPE*)a, lda, ipiv ); \ 63 | \ 64 | for(int i=0;i= 0); \ 67 | /* something should be done with nb_transpositions */ \ 68 | \ 69 | first_zero_pivot = info; \ 70 | return first_zero_pivot; \ 71 | } \ 72 | }; 73 | 74 | EIGEN_LAPACKE_LU_PARTPIV(double, double, d) 75 | EIGEN_LAPACKE_LU_PARTPIV(float, float, s) 76 | EIGEN_LAPACKE_LU_PARTPIV(dcomplex, lapack_complex_double, z) 77 | EIGEN_LAPACKE_LU_PARTPIV(scomplex, lapack_complex_float, c) 78 | 79 | } // end namespace internal 80 | 81 | } // end namespace Eigen 82 | 83 | #endif // EIGEN_PARTIALLU_LAPACK_H 84 | -------------------------------------------------------------------------------- /Libs/Eigen/src/QR/HouseholderQR_LAPACKE.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 LAPACKe 29 | * Householder QR decomposition of a matrix w/o pivoting based on 30 | * LAPACKE_?geqrf function. 31 | ******************************************************************************** 32 | */ 33 | 34 | #ifndef EIGEN_QR_LAPACKE_H 35 | #define EIGEN_QR_LAPACKE_H 36 | 37 | namespace Eigen { 38 | 39 | namespace internal { 40 | 41 | /** \internal Specialization for the data types supported by LAPACKe */ 42 | 43 | #define EIGEN_LAPACKE_QR_NOPIV(EIGTYPE, LAPACKE_TYPE, LAPACKE_PREFIX) \ 44 | template \ 45 | struct householder_qr_inplace_blocked \ 46 | { \ 47 | static void run(MatrixQR& mat, HCoeffs& hCoeffs, Index = 32, \ 48 | typename MatrixQR::Scalar* = 0) \ 49 | { \ 50 | lapack_int m = (lapack_int) mat.rows(); \ 51 | lapack_int n = (lapack_int) mat.cols(); \ 52 | lapack_int lda = (lapack_int) mat.outerStride(); \ 53 | lapack_int matrix_order = (MatrixQR::IsRowMajor) ? LAPACK_ROW_MAJOR : LAPACK_COL_MAJOR; \ 54 | LAPACKE_##LAPACKE_PREFIX##geqrf( matrix_order, m, n, (LAPACKE_TYPE*)mat.data(), lda, (LAPACKE_TYPE*)hCoeffs.data()); \ 55 | hCoeffs.adjointInPlace(); \ 56 | } \ 57 | }; 58 | 59 | EIGEN_LAPACKE_QR_NOPIV(double, double, d) 60 | EIGEN_LAPACKE_QR_NOPIV(float, float, s) 61 | EIGEN_LAPACKE_QR_NOPIV(dcomplex, lapack_complex_double, z) 62 | EIGEN_LAPACKE_QR_NOPIV(scomplex, lapack_complex_float, c) 63 | 64 | } // end namespace internal 65 | 66 | } // end namespace Eigen 67 | 68 | #endif // EIGEN_QR_LAPACKE_H 69 | -------------------------------------------------------------------------------- /Libs/Eigen/src/SparseCore/MappedSparseMatrix.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2014 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_MAPPED_SPARSEMATRIX_H 11 | #define EIGEN_MAPPED_SPARSEMATRIX_H 12 | 13 | namespace Eigen { 14 | 15 | /** \deprecated Use Map > 16 | * \class MappedSparseMatrix 17 | * 18 | * \brief Sparse matrix 19 | * 20 | * \param _Scalar the scalar type, i.e. the type of the coefficients 21 | * 22 | * See http://www.netlib.org/linalg/html_templates/node91.html for details on the storage scheme. 23 | * 24 | */ 25 | namespace internal { 26 | template 27 | struct traits > : traits > 28 | {}; 29 | } // end namespace internal 30 | 31 | template 32 | class MappedSparseMatrix 33 | : public Map > 34 | { 35 | typedef Map > Base; 36 | 37 | public: 38 | 39 | typedef typename Base::StorageIndex StorageIndex; 40 | typedef typename Base::Scalar Scalar; 41 | 42 | inline MappedSparseMatrix(Index rows, Index cols, Index nnz, StorageIndex* outerIndexPtr, StorageIndex* innerIndexPtr, Scalar* valuePtr, StorageIndex* innerNonZeroPtr = 0) 43 | : Base(rows, cols, nnz, outerIndexPtr, innerIndexPtr, valuePtr, innerNonZeroPtr) 44 | {} 45 | 46 | /** Empty destructor */ 47 | inline ~MappedSparseMatrix() {} 48 | }; 49 | 50 | namespace internal { 51 | 52 | template 53 | struct evaluator > 54 | : evaluator > > 55 | { 56 | typedef MappedSparseMatrix<_Scalar,_Options,_StorageIndex> XprType; 57 | typedef evaluator > Base; 58 | 59 | evaluator() : Base() {} 60 | explicit evaluator(const XprType &mat) : Base(mat) {} 61 | }; 62 | 63 | } 64 | 65 | } // end namespace Eigen 66 | 67 | #endif // EIGEN_MAPPED_SPARSEMATRIX_H 68 | -------------------------------------------------------------------------------- /Libs/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 | internal::evaluator thisEval(derived()); 30 | typename internal::evaluator::InnerIterator i(thisEval, 0); 31 | Scalar res(0); 32 | while (i) 33 | { 34 | res += numext::conj(i.value()) * other.coeff(i.index()); 35 | ++i; 36 | } 37 | return res; 38 | } 39 | 40 | template 41 | template 42 | typename internal::traits::Scalar 43 | SparseMatrixBase::dot(const SparseMatrixBase& other) const 44 | { 45 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 46 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived) 47 | EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(Derived,OtherDerived) 48 | EIGEN_STATIC_ASSERT((internal::is_same::value), 49 | YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY) 50 | 51 | eigen_assert(size() == other.size()); 52 | 53 | internal::evaluator thisEval(derived()); 54 | typename internal::evaluator::InnerIterator i(thisEval, 0); 55 | 56 | internal::evaluator otherEval(other.derived()); 57 | typename internal::evaluator::InnerIterator j(otherEval, 0); 58 | 59 | Scalar res(0); 60 | while (i && j) 61 | { 62 | if (i.index()==j.index()) 63 | { 64 | res += numext::conj(i.value()) * j.value(); 65 | ++i; ++j; 66 | } 67 | else if (i.index() 76 | inline typename NumTraits::Scalar>::Real 77 | SparseMatrixBase::squaredNorm() const 78 | { 79 | return numext::real((*this).cwiseAbs2().sum()); 80 | } 81 | 82 | template 83 | inline typename NumTraits::Scalar>::Real 84 | SparseMatrixBase::norm() const 85 | { 86 | using std::sqrt; 87 | return sqrt(squaredNorm()); 88 | } 89 | 90 | template 91 | inline typename NumTraits::Scalar>::Real 92 | SparseMatrixBase::blueNorm() const 93 | { 94 | return internal::blueNorm_impl(*this); 95 | } 96 | } // end namespace Eigen 97 | 98 | #endif // EIGEN_SPARSE_DOT_H 99 | -------------------------------------------------------------------------------- /Libs/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-2014 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 | namespace Eigen { 14 | 15 | template 16 | template 17 | bool SparseMatrixBase::isApprox(const SparseMatrixBase& other, const RealScalar &prec) const 18 | { 19 | const typename internal::nested_eval::type actualA(derived()); 20 | typename internal::conditional::type, 22 | const PlainObject>::type actualB(other.derived()); 23 | 24 | return (actualA - actualB).squaredNorm() <= prec * prec * numext::mini(actualA.squaredNorm(), actualB.squaredNorm()); 25 | } 26 | 27 | } // end namespace Eigen 28 | 29 | #endif // EIGEN_SPARSE_FUZZY_H 30 | -------------------------------------------------------------------------------- /Libs/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-2014 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 | internal::evaluator thisEval(derived()); 22 | for (Index j=0; j::InnerIterator iter(thisEval,j); iter; ++iter) 24 | res += iter.value(); 25 | return res; 26 | } 27 | 28 | template 29 | typename internal::traits >::Scalar 30 | SparseMatrix<_Scalar,_Options,_Index>::sum() const 31 | { 32 | eigen_assert(rows()>0 && cols()>0 && "you are using a non initialized matrix"); 33 | if(this->isCompressed()) 34 | return Matrix::Map(m_data.valuePtr(), m_data.size()).sum(); 35 | else 36 | return Base::sum(); 37 | } 38 | 39 | template 40 | typename internal::traits >::Scalar 41 | SparseVector<_Scalar,_Options,_Index>::sum() const 42 | { 43 | eigen_assert(rows()>0 && cols()>0 && "you are using a non initialized matrix"); 44 | return Matrix::Map(m_data.valuePtr(), m_data.size()).sum(); 45 | } 46 | 47 | } // end namespace Eigen 48 | 49 | #endif // EIGEN_SPARSEREDUX_H 50 | -------------------------------------------------------------------------------- /Libs/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-2015 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 | namespace internal { 16 | template 17 | class SparseTransposeImpl 18 | : public SparseMatrixBase > 19 | {}; 20 | 21 | template 22 | class SparseTransposeImpl 23 | : public SparseCompressedBase > 24 | { 25 | typedef SparseCompressedBase > Base; 26 | public: 27 | using Base::derived; 28 | typedef typename Base::Scalar Scalar; 29 | typedef typename Base::StorageIndex StorageIndex; 30 | 31 | inline Index nonZeros() const { return derived().nestedExpression().nonZeros(); } 32 | 33 | inline const Scalar* valuePtr() const { return derived().nestedExpression().valuePtr(); } 34 | inline const StorageIndex* innerIndexPtr() const { return derived().nestedExpression().innerIndexPtr(); } 35 | inline const StorageIndex* outerIndexPtr() const { return derived().nestedExpression().outerIndexPtr(); } 36 | inline const StorageIndex* innerNonZeroPtr() const { return derived().nestedExpression().innerNonZeroPtr(); } 37 | 38 | inline Scalar* valuePtr() { return derived().nestedExpression().valuePtr(); } 39 | inline StorageIndex* innerIndexPtr() { return derived().nestedExpression().innerIndexPtr(); } 40 | inline StorageIndex* outerIndexPtr() { return derived().nestedExpression().outerIndexPtr(); } 41 | inline StorageIndex* innerNonZeroPtr() { return derived().nestedExpression().innerNonZeroPtr(); } 42 | }; 43 | } 44 | 45 | template class TransposeImpl 46 | : public internal::SparseTransposeImpl 47 | { 48 | protected: 49 | typedef internal::SparseTransposeImpl Base; 50 | }; 51 | 52 | namespace internal { 53 | 54 | template 55 | struct unary_evaluator, IteratorBased> 56 | : public evaluator_base > 57 | { 58 | typedef typename evaluator::InnerIterator EvalIterator; 59 | public: 60 | typedef Transpose XprType; 61 | 62 | inline Index nonZerosEstimate() const { 63 | return m_argImpl.nonZerosEstimate(); 64 | } 65 | 66 | class InnerIterator : public EvalIterator 67 | { 68 | public: 69 | EIGEN_STRONG_INLINE InnerIterator(const unary_evaluator& unaryOp, Index outer) 70 | : EvalIterator(unaryOp.m_argImpl,outer) 71 | {} 72 | 73 | Index row() const { return EvalIterator::col(); } 74 | Index col() const { return EvalIterator::row(); } 75 | }; 76 | 77 | enum { 78 | CoeffReadCost = evaluator::CoeffReadCost, 79 | Flags = XprType::Flags 80 | }; 81 | 82 | explicit unary_evaluator(const XprType& op) :m_argImpl(op.nestedExpression()) {} 83 | 84 | protected: 85 | evaluator m_argImpl; 86 | }; 87 | 88 | } // end namespace internal 89 | 90 | } // end namespace Eigen 91 | 92 | #endif // EIGEN_SPARSETRANSPOSE_H 93 | -------------------------------------------------------------------------------- /Libs/Eigen/src/SparseLU/SparseLU_Utils.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2012 Désiré Nuentsa-Wakam 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 | 11 | #ifndef EIGEN_SPARSELU_UTILS_H 12 | #define EIGEN_SPARSELU_UTILS_H 13 | 14 | namespace Eigen { 15 | namespace internal { 16 | 17 | /** 18 | * \brief Count Nonzero elements in the factors 19 | */ 20 | template 21 | void SparseLUImpl::countnz(const Index n, Index& nnzL, Index& nnzU, GlobalLU_t& glu) 22 | { 23 | nnzL = 0; 24 | nnzU = (glu.xusub)(n); 25 | Index nsuper = (glu.supno)(n); 26 | Index jlen; 27 | Index i, j, fsupc; 28 | if (n <= 0 ) return; 29 | // For each supernode 30 | for (i = 0; i <= nsuper; i++) 31 | { 32 | fsupc = glu.xsup(i); 33 | jlen = glu.xlsub(fsupc+1) - glu.xlsub(fsupc); 34 | 35 | for (j = fsupc; j < glu.xsup(i+1); j++) 36 | { 37 | nnzL += jlen; 38 | nnzU += j - fsupc + 1; 39 | jlen--; 40 | } 41 | } 42 | } 43 | 44 | /** 45 | * \brief Fix up the data storage lsub for L-subscripts. 46 | * 47 | * It removes the subscripts sets for structural pruning, 48 | * and applies permutation to the remaining subscripts 49 | * 50 | */ 51 | template 52 | void SparseLUImpl::fixupL(const Index n, const IndexVector& perm_r, GlobalLU_t& glu) 53 | { 54 | Index fsupc, i, j, k, jstart; 55 | 56 | StorageIndex nextl = 0; 57 | Index nsuper = (glu.supno)(n); 58 | 59 | // For each supernode 60 | for (i = 0; i <= nsuper; i++) 61 | { 62 | fsupc = glu.xsup(i); 63 | jstart = glu.xlsub(fsupc); 64 | glu.xlsub(fsupc) = nextl; 65 | for (j = jstart; j < glu.xlsub(fsupc + 1); j++) 66 | { 67 | glu.lsub(nextl) = perm_r(glu.lsub(j)); // Now indexed into P*A 68 | nextl++; 69 | } 70 | for (k = fsupc+1; k < glu.xsup(i+1); k++) 71 | glu.xlsub(k) = nextl; // other columns in supernode i 72 | } 73 | 74 | glu.xlsub(n) = nextl; 75 | } 76 | 77 | } // end namespace internal 78 | 79 | } // end namespace Eigen 80 | #endif // EIGEN_SPARSELU_UTILS_H 81 | -------------------------------------------------------------------------------- /Libs/Eigen/src/SparseLU/SparseLU_relax_snode.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2012 Désiré Nuentsa-Wakam 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 | /* This file is a modified version of heap_relax_snode.c file in SuperLU 11 | * -- SuperLU routine (version 3.0) -- 12 | * Univ. of California Berkeley, Xerox Palo Alto Research Center, 13 | * and Lawrence Berkeley National Lab. 14 | * October 15, 2003 15 | * 16 | * Copyright (c) 1994 by Xerox Corporation. All rights reserved. 17 | * 18 | * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY 19 | * EXPRESSED OR IMPLIED. ANY USE IS AT YOUR OWN RISK. 20 | * 21 | * Permission is hereby granted to use or copy this program for any 22 | * purpose, provided the above notices are retained on all copies. 23 | * Permission to modify the code and to distribute modified code is 24 | * granted, provided the above notices are retained, and a notice that 25 | * the code was modified is included with the above copyright notice. 26 | */ 27 | 28 | #ifndef SPARSELU_RELAX_SNODE_H 29 | #define SPARSELU_RELAX_SNODE_H 30 | 31 | namespace Eigen { 32 | 33 | namespace internal { 34 | 35 | /** 36 | * \brief Identify the initial relaxed supernodes 37 | * 38 | * This routine is applied to a column elimination tree. 39 | * It assumes that the matrix has been reordered according to the postorder of the etree 40 | * \param n the number of columns 41 | * \param et elimination tree 42 | * \param relax_columns Maximum number of columns allowed in a relaxed snode 43 | * \param descendants Number of descendants of each node in the etree 44 | * \param relax_end last column in a supernode 45 | */ 46 | template 47 | void SparseLUImpl::relax_snode (const Index n, IndexVector& et, const Index relax_columns, IndexVector& descendants, IndexVector& relax_end) 48 | { 49 | 50 | // compute the number of descendants of each node in the etree 51 | Index parent; 52 | relax_end.setConstant(emptyIdxLU); 53 | descendants.setZero(); 54 | for (Index j = 0; j < n; j++) 55 | { 56 | parent = et(j); 57 | if (parent != n) // not the dummy root 58 | descendants(parent) += descendants(j) + 1; 59 | } 60 | // Identify the relaxed supernodes by postorder traversal of the etree 61 | Index snode_start; // beginning of a snode 62 | for (Index j = 0; j < n; ) 63 | { 64 | parent = et(j); 65 | snode_start = j; 66 | while ( parent != n && descendants(parent) < relax_columns ) 67 | { 68 | j = parent; 69 | parent = et(j); 70 | } 71 | // Found a supernode in postordered etree, j is the last column 72 | relax_end(snode_start) = StorageIndex(j); // Record last column 73 | j++; 74 | // Search for a new leaf 75 | while (descendants(j) != 0 && j < n) j++; 76 | } // End postorder traversal of the etree 77 | 78 | } 79 | 80 | } // end namespace internal 81 | 82 | } // end namespace Eigen 83 | #endif 84 | -------------------------------------------------------------------------------- /Libs/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 std::size_t size_type; 26 | typedef std::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 | #if EIGEN_COMP_MSVC 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 | -------------------------------------------------------------------------------- /Libs/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 | 42 | image_retval_base(const DecompositionType& dec, const MatrixType& originalMatrix) 43 | : m_dec(dec), m_rank(dec.rank()), 44 | m_cols(m_rank == 0 ? 1 : m_rank), 45 | m_originalMatrix(originalMatrix) 46 | {} 47 | 48 | inline Index rows() const { return m_dec.rows(); } 49 | inline Index cols() const { return m_cols; } 50 | inline Index rank() const { return m_rank; } 51 | inline const DecompositionType& dec() const { return m_dec; } 52 | inline const MatrixType& originalMatrix() const { return m_originalMatrix; } 53 | 54 | template inline void evalTo(Dest& dst) const 55 | { 56 | static_cast*>(this)->evalTo(dst); 57 | } 58 | 59 | protected: 60 | const DecompositionType& m_dec; 61 | Index m_rank, m_cols; 62 | const MatrixType& m_originalMatrix; 63 | }; 64 | 65 | } // end namespace internal 66 | 67 | #define EIGEN_MAKE_IMAGE_HELPERS(DecompositionType) \ 68 | typedef typename DecompositionType::MatrixType MatrixType; \ 69 | typedef typename MatrixType::Scalar Scalar; \ 70 | typedef typename MatrixType::RealScalar RealScalar; \ 71 | typedef Eigen::internal::image_retval_base Base; \ 72 | using Base::dec; \ 73 | using Base::originalMatrix; \ 74 | using Base::rank; \ 75 | using Base::rows; \ 76 | using Base::cols; \ 77 | image_retval(const DecompositionType& dec, const MatrixType& originalMatrix) \ 78 | : Base(dec, originalMatrix) {} 79 | 80 | } // end namespace Eigen 81 | 82 | #endif // EIGEN_MISC_IMAGE_H 83 | -------------------------------------------------------------------------------- /Libs/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 | 43 | explicit kernel_retval_base(const DecompositionType& dec) 44 | : m_dec(dec), 45 | m_rank(dec.rank()), 46 | m_cols(m_rank==dec.cols() ? 1 : dec.cols() - m_rank) 47 | {} 48 | 49 | inline Index rows() const { return m_dec.cols(); } 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 | 54 | template inline void evalTo(Dest& dst) const 55 | { 56 | static_cast*>(this)->evalTo(dst); 57 | } 58 | 59 | protected: 60 | const DecompositionType& m_dec; 61 | Index m_rank, m_cols; 62 | }; 63 | 64 | } // end namespace internal 65 | 66 | #define EIGEN_MAKE_KERNEL_HELPERS(DecompositionType) \ 67 | typedef typename DecompositionType::MatrixType MatrixType; \ 68 | typedef typename MatrixType::Scalar Scalar; \ 69 | typedef typename MatrixType::RealScalar RealScalar; \ 70 | typedef Eigen::internal::kernel_retval_base Base; \ 71 | using Base::dec; \ 72 | using Base::rank; \ 73 | using Base::rows; \ 74 | using Base::cols; \ 75 | kernel_retval(const DecompositionType& dec) : Base(dec) {} 76 | 77 | } // end namespace Eigen 78 | 79 | #endif // EIGEN_MISC_KERNEL_H 80 | -------------------------------------------------------------------------------- /Libs/Eigen/src/misc/RealSvd2x2.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009-2010 Benoit Jacob 5 | // Copyright (C) 2013-2016 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_REALSVD2X2_H 12 | #define EIGEN_REALSVD2X2_H 13 | 14 | namespace Eigen { 15 | 16 | namespace internal { 17 | 18 | template 19 | void real_2x2_jacobi_svd(const MatrixType& matrix, Index p, Index q, 20 | JacobiRotation *j_left, 21 | JacobiRotation *j_right) 22 | { 23 | using std::sqrt; 24 | using std::abs; 25 | Matrix m; 26 | m << numext::real(matrix.coeff(p,p)), numext::real(matrix.coeff(p,q)), 27 | numext::real(matrix.coeff(q,p)), numext::real(matrix.coeff(q,q)); 28 | JacobiRotation rot1; 29 | RealScalar t = m.coeff(0,0) + m.coeff(1,1); 30 | RealScalar d = m.coeff(1,0) - m.coeff(0,1); 31 | 32 | if(abs(d) < (std::numeric_limits::min)()) 33 | { 34 | rot1.s() = RealScalar(0); 35 | rot1.c() = RealScalar(1); 36 | } 37 | else 38 | { 39 | // If d!=0, then t/d cannot overflow because the magnitude of the 40 | // entries forming d are not too small compared to the ones forming t. 41 | RealScalar u = t / d; 42 | RealScalar tmp = sqrt(RealScalar(1) + numext::abs2(u)); 43 | rot1.s() = RealScalar(1) / tmp; 44 | rot1.c() = u / tmp; 45 | } 46 | m.applyOnTheLeft(0,1,rot1); 47 | j_right->makeJacobi(m,0,1); 48 | *j_left = rot1 * j_right->transpose(); 49 | } 50 | 51 | } // end namespace internal 52 | 53 | } // end namespace Eigen 54 | 55 | #endif // EIGEN_REALSVD2X2_H 56 | -------------------------------------------------------------------------------- /Libs/Eigen/src/misc/lapacke_mangling.h: -------------------------------------------------------------------------------- 1 | #ifndef LAPACK_HEADER_INCLUDED 2 | #define LAPACK_HEADER_INCLUDED 3 | 4 | #ifndef LAPACK_GLOBAL 5 | #if defined(LAPACK_GLOBAL_PATTERN_LC) || defined(ADD_) 6 | #define LAPACK_GLOBAL(lcname,UCNAME) lcname##_ 7 | #elif defined(LAPACK_GLOBAL_PATTERN_UC) || defined(UPPER) 8 | #define LAPACK_GLOBAL(lcname,UCNAME) UCNAME 9 | #elif defined(LAPACK_GLOBAL_PATTERN_MC) || defined(NOCHANGE) 10 | #define LAPACK_GLOBAL(lcname,UCNAME) lcname 11 | #else 12 | #define LAPACK_GLOBAL(lcname,UCNAME) lcname##_ 13 | #endif 14 | #endif 15 | 16 | #endif 17 | 18 | -------------------------------------------------------------------------------- /Libs/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 included into the body of the base classes supporting matrix specific coefficient-wise functions. 12 | // This include MatrixBase and SparseMatrixBase. 13 | 14 | 15 | typedef CwiseUnaryOp, const Derived> CwiseAbsReturnType; 16 | typedef CwiseUnaryOp, const Derived> CwiseAbs2ReturnType; 17 | typedef CwiseUnaryOp, const Derived> CwiseArgReturnType; 18 | typedef CwiseUnaryOp, const Derived> CwiseSqrtReturnType; 19 | typedef CwiseUnaryOp, const Derived> CwiseSignReturnType; 20 | typedef CwiseUnaryOp, const Derived> CwiseInverseReturnType; 21 | 22 | /// \returns an expression of the coefficient-wise absolute value of \c *this 23 | /// 24 | /// Example: \include MatrixBase_cwiseAbs.cpp 25 | /// Output: \verbinclude MatrixBase_cwiseAbs.out 26 | /// 27 | EIGEN_DOC_UNARY_ADDONS(cwiseAbs,absolute value) 28 | /// 29 | /// \sa cwiseAbs2() 30 | /// 31 | EIGEN_DEVICE_FUNC 32 | EIGEN_STRONG_INLINE const CwiseAbsReturnType 33 | cwiseAbs() const { return CwiseAbsReturnType(derived()); } 34 | 35 | /// \returns an expression of the coefficient-wise squared absolute value of \c *this 36 | /// 37 | /// Example: \include MatrixBase_cwiseAbs2.cpp 38 | /// Output: \verbinclude MatrixBase_cwiseAbs2.out 39 | /// 40 | EIGEN_DOC_UNARY_ADDONS(cwiseAbs2,squared absolute value) 41 | /// 42 | /// \sa cwiseAbs() 43 | /// 44 | EIGEN_DEVICE_FUNC 45 | EIGEN_STRONG_INLINE const CwiseAbs2ReturnType 46 | cwiseAbs2() const { return CwiseAbs2ReturnType(derived()); } 47 | 48 | /// \returns an expression of the coefficient-wise square root of *this. 49 | /// 50 | /// Example: \include MatrixBase_cwiseSqrt.cpp 51 | /// Output: \verbinclude MatrixBase_cwiseSqrt.out 52 | /// 53 | EIGEN_DOC_UNARY_ADDONS(cwiseSqrt,square-root) 54 | /// 55 | /// \sa cwisePow(), cwiseSquare() 56 | /// 57 | EIGEN_DEVICE_FUNC 58 | inline const CwiseSqrtReturnType 59 | cwiseSqrt() const { return CwiseSqrtReturnType(derived()); } 60 | 61 | /// \returns an expression of the coefficient-wise signum of *this. 62 | /// 63 | /// Example: \include MatrixBase_cwiseSign.cpp 64 | /// Output: \verbinclude MatrixBase_cwiseSign.out 65 | /// 66 | EIGEN_DOC_UNARY_ADDONS(cwiseSign,sign function) 67 | /// 68 | EIGEN_DEVICE_FUNC 69 | inline const CwiseSignReturnType 70 | cwiseSign() const { return CwiseSignReturnType(derived()); } 71 | 72 | 73 | /// \returns an expression of the coefficient-wise inverse of *this. 74 | /// 75 | /// Example: \include MatrixBase_cwiseInverse.cpp 76 | /// Output: \verbinclude MatrixBase_cwiseInverse.out 77 | /// 78 | EIGEN_DOC_UNARY_ADDONS(cwiseInverse,inverse) 79 | /// 80 | /// \sa cwiseProduct() 81 | /// 82 | EIGEN_DEVICE_FUNC 83 | inline const CwiseInverseReturnType 84 | cwiseInverse() const { return CwiseInverseReturnType(derived()); } 85 | 86 | /// \returns an expression of the coefficient-wise phase angle of \c *this 87 | /// 88 | /// Example: \include MatrixBase_cwiseArg.cpp 89 | /// Output: \verbinclude MatrixBase_cwiseArg.out 90 | /// 91 | EIGEN_DOC_UNARY_ADDONS(cwiseArg,arg) 92 | 93 | EIGEN_DEVICE_FUNC 94 | inline const CwiseArgReturnType 95 | cwiseArg() const { return CwiseArgReturnType(derived()); } 96 | -------------------------------------------------------------------------------- /Libs/qtimgui/include/ImGuiRenderer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class QMouseEvent; 10 | class QWheelEvent; 11 | class QKeyEvent; 12 | 13 | namespace QtImGui { 14 | 15 | class WindowWrapper { 16 | public: 17 | virtual ~WindowWrapper() {} 18 | virtual void installEventFilter(QObject *object) = 0; 19 | virtual QSize size() const = 0; 20 | virtual qreal devicePixelRatio() const = 0; 21 | virtual bool isActive() const = 0; 22 | virtual QPoint mapFromGlobal(const QPoint &p) const = 0; 23 | virtual QObject* object() = 0; 24 | 25 | virtual void setCursorShape(Qt::CursorShape shape) = 0; 26 | virtual void setCursorPos(const QPoint& local_pos) = 0; 27 | }; 28 | 29 | class ImGuiRenderer : public QObject, QOpenGLExtraFunctions { 30 | Q_OBJECT 31 | public: 32 | void initialize(WindowWrapper *window); 33 | void newFrame(); 34 | void render(); 35 | bool eventFilter(QObject *watched, QEvent *event); 36 | 37 | static ImGuiRenderer *instance(); 38 | 39 | public: 40 | ImGuiRenderer(); 41 | ~ImGuiRenderer(); 42 | 43 | private: 44 | void onMousePressedChange(QMouseEvent *event); 45 | void onWheel(QWheelEvent *event); 46 | void onKeyPressRelease(QKeyEvent *event); 47 | 48 | void updateCursorShape(const ImGuiIO &io); 49 | void setCursorPos(const ImGuiIO &io); 50 | 51 | void renderDrawList(ImDrawData *draw_data); 52 | bool createFontsTexture(); 53 | bool createDeviceObjects(); 54 | 55 | std::unique_ptr m_window; 56 | double g_Time = 0.0f; 57 | bool g_MousePressed[3] = { false, false, false }; 58 | float g_MouseWheel; 59 | float g_MouseWheelH; 60 | GLuint g_FontTexture = 0; 61 | int g_ShaderHandle = 0, g_VertHandle = 0, g_FragHandle = 0; 62 | int g_AttribLocationTex = 0, g_AttribLocationProjMtx = 0; 63 | int g_AttribLocationPosition = 0, g_AttribLocationUV = 0, g_AttribLocationColor = 0; 64 | unsigned int g_VboHandle = 0, g_VaoHandle = 0, g_ElementsHandle = 0; 65 | 66 | ImGuiContext* g_ctx = nullptr; 67 | }; 68 | 69 | } // namespace QtImGui 70 | -------------------------------------------------------------------------------- /Libs/qtimgui/include/QtImGui.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class QWidget; 4 | class QWindow; 5 | 6 | namespace QtImGui { 7 | 8 | typedef void* RenderRef; 9 | 10 | #ifdef QT_WIDGETS_LIB 11 | RenderRef initialize(QWidget *window, bool defaultRender = true); 12 | #endif 13 | 14 | RenderRef initialize(QWindow *window, bool defaultRender = true); 15 | void newFrame(RenderRef ref = nullptr); 16 | void render(RenderRef ref = nullptr); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /Libs/qtimgui/lib/debug/imgui.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berkbavas/BSplineRenderer/c1bf6910a4510554379a1fb174db39df63c70b6e/Libs/qtimgui/lib/debug/imgui.lib -------------------------------------------------------------------------------- /Libs/qtimgui/lib/debug/imgui.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berkbavas/BSplineRenderer/c1bf6910a4510554379a1fb174db39df63c70b6e/Libs/qtimgui/lib/debug/imgui.pdb -------------------------------------------------------------------------------- /Libs/qtimgui/lib/debug/qt_imgui_widgets.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berkbavas/BSplineRenderer/c1bf6910a4510554379a1fb174db39df63c70b6e/Libs/qtimgui/lib/debug/qt_imgui_widgets.lib -------------------------------------------------------------------------------- /Libs/qtimgui/lib/debug/qt_imgui_widgets.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berkbavas/BSplineRenderer/c1bf6910a4510554379a1fb174db39df63c70b6e/Libs/qtimgui/lib/debug/qt_imgui_widgets.pdb -------------------------------------------------------------------------------- /Libs/qtimgui/lib/release/imgui.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berkbavas/BSplineRenderer/c1bf6910a4510554379a1fb174db39df63c70b6e/Libs/qtimgui/lib/release/imgui.lib -------------------------------------------------------------------------------- /Libs/qtimgui/lib/release/qt_imgui_widgets.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berkbavas/BSplineRenderer/c1bf6910a4510554379a1fb174db39df63c70b6e/Libs/qtimgui/lib/release/qt_imgui_widgets.lib -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # B-Spline Renderer 2 | Rendering 3D B-splines in ``C++`` using ``Qt``, ``OpenGL`` and ``Eigen``. 3 | 4 | B-splines are parametric curves that consist of several Bézier curves whose control points satisfy specific conditions. 5 | I used cubic Bézier curves for the interpolation of knots. Given a set of knots, 6 | a cubic Bézier curve is generated between each pair of knots. 7 | Then, these Bézier curves are glued together to form the final curve, the B-spline. 8 | The algorithm for the generation of the curves can be found [here](https://www.math.ucla.edu/~baker/149.1.02w/handouts/dd_splines.pdf). Although it is about 2D B-splines, interpolating 3D B-splines is not so different. 9 | 10 | ## Build 11 | 1) Install `CMake 3.25.1` or above. 12 | 2) Install `Visual Studio 2022` and `MSVC C++ v143 Compiler`. 13 | 3) Install `Qt 6.7.3 MSVC2022 64bit` kit. 14 | 4) Set environment variable `Qt6_DIR` as `C:\Qt\6.7.3\msvc2022_64`. 15 | 5) Clone the repo `git clone https://github.com/berkbavas/BSplineRenderer.git`. 16 | 6) Create a folder `mkdir Build`. 17 | 7) Enter the folder `cd Build`. 18 | 8) Run CMake `cmake ..`. 19 | 9) Open `BSplineRenderer.sln` with `Visual Studio 2022`. 20 | 10) Build with `Release` configuration. 21 | 22 | ## Video 23 | https://github.com/user-attachments/assets/daf205b8-dc9c-4aac-8f7b-df823693db86 24 | 25 | -------------------------------------------------------------------------------- /Resources/Shaders/CurveSelection.frag: -------------------------------------------------------------------------------- 1 | #version 450 core 2 | 3 | in vec3 fs_Position; 4 | in vec3 fs_Normal; 5 | 6 | uniform int curveIndex; 7 | 8 | layout(location = 0) out ivec4 out_CurveInfo; 9 | 10 | void main() 11 | { 12 | out_CurveInfo = ivec4(curveIndex, 0, 0, 1); 13 | } 14 | -------------------------------------------------------------------------------- /Resources/Shaders/Model.frag: -------------------------------------------------------------------------------- 1 | #version 450 core 2 | 3 | struct Model 4 | { 5 | vec4 color; 6 | float ambient; 7 | float diffuse; 8 | }; 9 | 10 | struct Light 11 | { 12 | vec4 color; 13 | vec3 direction; 14 | float ambient; 15 | float diffuse; 16 | }; 17 | 18 | uniform Model model; 19 | uniform Light light; 20 | 21 | in vec4 fs_Position; 22 | in vec3 fs_Normal; 23 | 24 | layout(location = 0) out vec4 out_Color; 25 | 26 | void main() 27 | { 28 | // Ambient 29 | float ambient = light.ambient * model.ambient; 30 | 31 | // Diffuse 32 | float diffuse = max(dot(fs_Normal, -light.direction), 0.0) * light.diffuse * model.diffuse; 33 | 34 | // Combine 35 | out_Color = (ambient + diffuse) * model.color * light.color; 36 | } 37 | -------------------------------------------------------------------------------- /Resources/Shaders/Model.vert: -------------------------------------------------------------------------------- 1 | #version 450 core 2 | 3 | layout(location = 0) in vec3 position; 4 | layout(location = 1) in vec3 normal; 5 | 6 | out vec4 fs_Position; 7 | out vec3 fs_Normal; 8 | 9 | uniform mat4 modelMatrix; 10 | uniform mat3 normalMatrix; 11 | uniform mat4 viewProjectionMatrix; 12 | 13 | void main() 14 | { 15 | fs_Position = modelMatrix * vec4(position, 1.0f); 16 | fs_Normal = normalMatrix * normal; 17 | 18 | gl_Position = viewProjectionMatrix * fs_Position; 19 | } 20 | -------------------------------------------------------------------------------- /Resources/Shaders/SkyBox.frag: -------------------------------------------------------------------------------- 1 | #version 450 core 2 | 3 | uniform samplerCube skybox; 4 | uniform float brightness = 0.5f; 5 | 6 | in vec3 fsTextureCoords; 7 | 8 | out vec4 outColor; 9 | 10 | void main() 11 | { 12 | vec4 color = texture(skybox, fsTextureCoords); 13 | outColor = vec4(brightness * color.x, brightness * color.y, brightness * color.z , 1.0f); 14 | } -------------------------------------------------------------------------------- /Resources/Shaders/SkyBox.vert: -------------------------------------------------------------------------------- 1 | #version 450 core 2 | 3 | layout (location = 0) in vec3 position; 4 | 5 | uniform mat4 projection; 6 | uniform mat4 rotation; 7 | 8 | out vec3 fsTextureCoords; 9 | 10 | void main() 11 | { 12 | fsTextureCoords = position; 13 | gl_Position = projection * rotation * vec4(position, 1.0); 14 | } -------------------------------------------------------------------------------- /Resources/Shaders/Spline.frag: -------------------------------------------------------------------------------- 1 | #version 450 core 2 | 3 | struct Curve 4 | { 5 | vec4 color; 6 | float ambient; 7 | float diffuse; 8 | }; 9 | 10 | struct Light 11 | { 12 | vec4 color; 13 | vec3 direction; 14 | float ambient; 15 | float diffuse; 16 | }; 17 | 18 | uniform Curve curve; 19 | uniform Light light; 20 | 21 | in vec3 fs_Position; 22 | in vec3 fs_Normal; 23 | 24 | layout(location = 0) out vec4 out_Color; 25 | 26 | void main() 27 | { 28 | // Ambient 29 | float ambient = light.ambient * curve.ambient; 30 | 31 | // Diffuse 32 | float diffuse = max(dot(fs_Normal, -light.direction), 0.0) * light.diffuse * curve.diffuse; 33 | 34 | // Combine 35 | out_Color = (ambient + diffuse) * curve.color * light.color; 36 | } 37 | -------------------------------------------------------------------------------- /Resources/Shaders/Spline.tcs: -------------------------------------------------------------------------------- 1 | #version 450 core 2 | 3 | layout(vertices = 4) out; 4 | 5 | uniform int numberOfSegments; 6 | uniform int numberOfSectors; 7 | 8 | void main() 9 | { 10 | gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position; 11 | 12 | gl_TessLevelInner[0] = float(numberOfSegments); 13 | gl_TessLevelInner[1] = float(numberOfSectors); 14 | 15 | gl_TessLevelOuter[0] = gl_TessLevelInner[1]; 16 | gl_TessLevelOuter[1] = gl_TessLevelInner[0]; 17 | gl_TessLevelOuter[2] = gl_TessLevelInner[1]; 18 | gl_TessLevelOuter[3] = gl_TessLevelInner[0]; 19 | } -------------------------------------------------------------------------------- /Resources/Shaders/Spline.tes: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(quads, equal_spacing, ccw) in; 4 | 5 | float customPow(float x, float y) 6 | { 7 | if (x == 0 && y == 0) 8 | { 9 | return 1; 10 | } 11 | 12 | return pow(x, y); 13 | } 14 | 15 | float factorial(int n) 16 | { 17 | float result = 1; 18 | 19 | for (int i = 2; i <= n; ++i) 20 | { 21 | result *= i; 22 | } 23 | 24 | return result; 25 | } 26 | 27 | float choose(int n, int k) 28 | { 29 | return factorial(n) / (factorial(k) * factorial(n - k)); 30 | } 31 | 32 | vec3 getPositionAt(vec3 controlPoints[4], float t) 33 | { 34 | vec3 result = vec3(0, 0, 0); 35 | for (int i = 0; i <= 3; ++i) 36 | { 37 | float c0 = choose(3, i); 38 | float c1 = customPow(t, i); 39 | float c2 = customPow(1 - t, 3 - i); 40 | result += c0 * c1 * c2 * controlPoints[i]; 41 | } 42 | return result; 43 | } 44 | 45 | vec3 getTangentAt(vec3 controlPoints[4], float t) 46 | { 47 | vec3 tangent = vec3(0, 0, 0); 48 | 49 | for (int i = 0; i <= 2; i++) 50 | { 51 | float c0 = choose(2, i); 52 | float c1 = customPow(t, i); 53 | float c2 = customPow(1 - t, 2 - i); 54 | tangent += 3 * c0 * c1 * c2 * (controlPoints[i + 1] - controlPoints[i]); 55 | } 56 | 57 | return normalize(tangent); 58 | } 59 | 60 | mat3 getRotationMatrix(vec3 axis, float angle) 61 | { 62 | axis = normalize(axis); 63 | float s = sin(angle); 64 | float c = cos(angle); 65 | float oc = 1.0f - c; 66 | 67 | return mat3(oc * axis.x * axis.x + c, oc * axis.x * axis.y - axis.z * s, oc * axis.z * axis.x + axis.y * s, 68 | oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s, 69 | oc * axis.z * axis.x - axis.y * s, oc * axis.y * axis.z + axis.x * s, oc * axis.z * axis.z + c); 70 | } 71 | 72 | const float PI = 3.1415926538; 73 | const vec3 AXIS_Y = vec3(0, -1, 0); 74 | 75 | uniform mat4 VP; 76 | uniform float radius; 77 | 78 | out vec3 fs_Normal; 79 | out vec3 fs_Position; 80 | 81 | void main() 82 | { 83 | float t = gl_TessCoord.x; 84 | float s = gl_TessCoord.y; 85 | 86 | vec3 p0 = gl_in[0].gl_Position.xyz; 87 | vec3 p1 = gl_in[1].gl_Position.xyz; 88 | vec3 p2 = gl_in[2].gl_Position.xyz; 89 | vec3 p3 = gl_in[3].gl_Position.xyz; 90 | 91 | vec3 controlPoints[4] = { p0, p1, p2, p3 }; 92 | 93 | vec3 position = getPositionAt(controlPoints, t); 94 | vec3 tangent = getTangentAt(controlPoints, t); 95 | 96 | vec3 axis = cross(tangent, AXIS_Y); 97 | if(length(tangent - AXIS_Y) < 0.001) 98 | { 99 | axis = AXIS_Y; 100 | } 101 | float angle = acos(dot(tangent, AXIS_Y)); 102 | mat3 rotation = getRotationMatrix(axis, angle); 103 | vec3 normal = rotation * vec3(cos(2 * PI * s), 0, sin(2 * PI * s)); 104 | 105 | position += radius * normal; 106 | fs_Normal = normal; 107 | fs_Position = position; 108 | gl_Position = VP * vec4(position, 1.0f); 109 | } -------------------------------------------------------------------------------- /Resources/Shaders/Spline.vert: -------------------------------------------------------------------------------- 1 | #version 450 core 2 | 3 | layout(location = 0) in vec3 position; 4 | 5 | void main() 6 | { 7 | gl_Position = vec4(position, 1.0); 8 | } -------------------------------------------------------------------------------- /Resources/SkyBox/nx.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berkbavas/BSplineRenderer/c1bf6910a4510554379a1fb174db39df63c70b6e/Resources/SkyBox/nx.png -------------------------------------------------------------------------------- /Resources/SkyBox/ny.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berkbavas/BSplineRenderer/c1bf6910a4510554379a1fb174db39df63c70b6e/Resources/SkyBox/ny.png -------------------------------------------------------------------------------- /Resources/SkyBox/nz.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berkbavas/BSplineRenderer/c1bf6910a4510554379a1fb174db39df63c70b6e/Resources/SkyBox/nz.png -------------------------------------------------------------------------------- /Resources/SkyBox/px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berkbavas/BSplineRenderer/c1bf6910a4510554379a1fb174db39df63c70b6e/Resources/SkyBox/px.png -------------------------------------------------------------------------------- /Resources/SkyBox/py.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berkbavas/BSplineRenderer/c1bf6910a4510554379a1fb174db39df63c70b6e/Resources/SkyBox/py.png -------------------------------------------------------------------------------- /Resources/SkyBox/pz.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berkbavas/BSplineRenderer/c1bf6910a4510554379a1fb174db39df63c70b6e/Resources/SkyBox/pz.png -------------------------------------------------------------------------------- /Source/Core/Constants.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace BSplineRenderer 4 | { 5 | constexpr int INITIAL_WIDTH = 1600; 6 | constexpr int INITIAL_HEIGHT = 900; 7 | constexpr int DEFAULT_NUMBER_OF_SEGMENTS = 32; 8 | constexpr int DEFAULT_NUMBER_OF_SECTORS = 32; 9 | constexpr float DEFAULT_RADIUS = 0.25f; 10 | } 11 | -------------------------------------------------------------------------------- /Source/Core/Controller.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Core/Constants.h" 4 | #include "EventHandler/EventHandler.h" 5 | #include "Util/Macros.h" 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | namespace BSplineRenderer 12 | { 13 | class Window; 14 | class ImGuiWindow; 15 | class RendererManager; 16 | class CurveContainer; 17 | 18 | class Controller : public QObject, protected QOpenGLExtraFunctions 19 | { 20 | DISABLE_COPY(Controller); 21 | 22 | Q_OBJECT 23 | public: 24 | explicit Controller(QObject* parent = nullptr); 25 | ~Controller(); 26 | 27 | void Run(); 28 | 29 | public slots: 30 | // Core Events 31 | void Initialize(); 32 | void Resize(int w, int h); 33 | void Render(float ifps); 34 | 35 | // Input Events 36 | void OnKeyPressed(QKeyEvent*); 37 | void OnKeyReleased(QKeyEvent*); 38 | void OnMousePressed(QMouseEvent*); 39 | void OnMouseReleased(QMouseEvent*); 40 | void OnMouseMoved(QMouseEvent*); 41 | void OnWheelMoved(QWheelEvent*); 42 | 43 | private: 44 | float mDevicePixelRatio{ 1.0f }; 45 | float mWidth{ INITIAL_WIDTH }; 46 | float mHeight{ INITIAL_HEIGHT }; 47 | 48 | Window* mWindow; 49 | ImGuiWindow* mImGuiWindow; 50 | 51 | EventHandler* mEventHandler; 52 | RendererManager* mRendererManager; 53 | CurveContainer* mCurveContainer; 54 | FreeCameraPtr mCamera; 55 | }; 56 | } 57 | -------------------------------------------------------------------------------- /Source/Core/CurveContainer.cpp: -------------------------------------------------------------------------------- 1 | #include "CurveContainer.h" 2 | 3 | void BSplineRenderer::CurveContainer::AddCurve(SplinePtr spline) 4 | { 5 | mCurves << spline; 6 | } 7 | 8 | void BSplineRenderer::CurveContainer::RemoveCurve(SplinePtr spline) 9 | { 10 | mCurves.removeAll(spline); 11 | } 12 | 13 | BSplineRenderer::SplinePtr BSplineRenderer::CurveContainer::GetCurve(int index) 14 | { 15 | return mCurves[index]; 16 | } 17 | -------------------------------------------------------------------------------- /Source/Core/CurveContainer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Curve/Spline.h" 4 | 5 | #include 6 | 7 | namespace BSplineRenderer 8 | { 9 | class CurveContainer 10 | { 11 | public: 12 | CurveContainer() = default; 13 | 14 | void AddCurve(SplinePtr spline); 15 | void RemoveCurve(SplinePtr spline); 16 | SplinePtr GetCurve(int index); 17 | 18 | const QVector& GetCurves() const { return mCurves; } 19 | 20 | private: 21 | QVector mCurves; 22 | }; 23 | } -------------------------------------------------------------------------------- /Source/Core/Window.cpp: -------------------------------------------------------------------------------- 1 | #include "Window.h" 2 | 3 | #include "Util/Logger.h" 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | BSplineRenderer::Window::Window(QWindow* parent) 10 | : QOpenGLWindow(QOpenGLWindow::UpdateBehavior::NoPartialUpdate, parent) 11 | 12 | { 13 | QSurfaceFormat format = QSurfaceFormat::defaultFormat(); 14 | format.setSamples(8); 15 | setFormat(format); 16 | 17 | connect(this, &QOpenGLWindow::frameSwapped, [=]() 18 | { update(); }); 19 | } 20 | 21 | void BSplineRenderer::Window::initializeGL() 22 | { 23 | initializeOpenGLFunctions(); 24 | 25 | mCurrentTime = QDateTime::currentMSecsSinceEpoch(); 26 | mPreviousTime = mCurrentTime; 27 | 28 | emit Initialize(); 29 | } 30 | 31 | void BSplineRenderer::Window::resizeGL(int width, int height) 32 | { 33 | emit Resize(width, height); 34 | } 35 | 36 | void BSplineRenderer::Window::paintGL() 37 | { 38 | mCurrentTime = QDateTime::currentMSecsSinceEpoch(); 39 | const float ifps = (mCurrentTime - mPreviousTime) * 0.001f; 40 | mPreviousTime = mCurrentTime; 41 | 42 | emit Render(ifps); 43 | } 44 | 45 | void BSplineRenderer::Window::keyPressEvent(QKeyEvent* event) 46 | { 47 | emit KeyPressed(event); 48 | } 49 | 50 | void BSplineRenderer::Window::keyReleaseEvent(QKeyEvent* event) 51 | { 52 | emit KeyReleased(event); 53 | } 54 | 55 | void BSplineRenderer::Window::mousePressEvent(QMouseEvent* event) 56 | { 57 | emit MousePressed(event); 58 | } 59 | 60 | void BSplineRenderer::Window::mouseReleaseEvent(QMouseEvent* event) 61 | { 62 | emit MouseReleased(event); 63 | } 64 | 65 | void BSplineRenderer::Window::mouseMoveEvent(QMouseEvent* event) 66 | { 67 | emit MouseMoved(event); 68 | } 69 | 70 | void BSplineRenderer::Window::wheelEvent(QWheelEvent* event) 71 | { 72 | emit WheelMoved(event); 73 | } 74 | -------------------------------------------------------------------------------- /Source/Core/Window.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace BSplineRenderer 8 | { 9 | class Window : public QOpenGLWindow, public QOpenGLExtraFunctions 10 | { 11 | Q_OBJECT 12 | public: 13 | Window(QWindow* parent = nullptr); 14 | 15 | private: 16 | void initializeGL() override; 17 | void resizeGL(int width, int height) override; 18 | void paintGL() override; 19 | void keyPressEvent(QKeyEvent*) override; 20 | void keyReleaseEvent(QKeyEvent*) override; 21 | void mousePressEvent(QMouseEvent*) override; 22 | void mouseReleaseEvent(QMouseEvent*) override; 23 | void mouseMoveEvent(QMouseEvent*) override; 24 | void wheelEvent(QWheelEvent*) override; 25 | 26 | signals: 27 | // Core Events 28 | void Initialize(); 29 | void Resize(int w, int h); 30 | void Render(float ifps); 31 | 32 | // Input Events 33 | void KeyPressed(QKeyEvent*); 34 | void KeyReleased(QKeyEvent*); 35 | void MousePressed(QMouseEvent*); 36 | void MouseReleased(QMouseEvent*); 37 | void MouseMoved(QMouseEvent*); 38 | void WheelMoved(QWheelEvent*); 39 | 40 | private: 41 | long long mPreviousTime; 42 | long long mCurrentTime; 43 | }; 44 | } 45 | -------------------------------------------------------------------------------- /Source/Curve/Knot.cpp: -------------------------------------------------------------------------------- 1 | #include "Knot.h" 2 | 3 | BSplineRenderer::Knot::Knot(float x, float y, float z) 4 | : mPosition(x, y, z) 5 | { 6 | } 7 | 8 | BSplineRenderer::Knot::Knot(const QVector3D& position) 9 | : mPosition(position) 10 | { 11 | } 12 | 13 | void BSplineRenderer::Knot::SetPosition(const QVector3D& position) 14 | { 15 | mPosition = position; 16 | } 17 | 18 | void BSplineRenderer::Knot::SetPosition(float x, float y, float z) 19 | { 20 | mPosition.setX(x); 21 | mPosition.setY(y); 22 | mPosition.setZ(z); 23 | } 24 | -------------------------------------------------------------------------------- /Source/Curve/Knot.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace BSplineRenderer 7 | { 8 | class Knot 9 | { 10 | public: 11 | Knot(float x, float y, float z); 12 | Knot(const QVector3D& position); 13 | 14 | void SetPosition(const QVector3D& position); 15 | void SetPosition(float x, float y, float z); 16 | 17 | const QVector3D& GetPosition() const { return mPosition; } 18 | 19 | private: 20 | QVector3D mPosition; 21 | }; 22 | 23 | using KnotPtr = std::shared_ptr; 24 | } 25 | -------------------------------------------------------------------------------- /Source/Curve/Spline.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Core/Constants.h" 4 | #include "Curve/Knot.h" 5 | #include "Util/Macros.h" 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | namespace BSplineRenderer 12 | { 13 | class Spline : QOpenGLExtraFunctions 14 | { 15 | public: 16 | Spline() = default; 17 | 18 | void AddKnot(KnotPtr knot); 19 | KnotPtr AddKnot(float x, float y, float z); 20 | KnotPtr AddKnot(const QVector3D& position); 21 | 22 | const QVector& GetKnots() const { return mKnots; } 23 | 24 | KnotPtr GetClosestKnotToRay(const QVector3D& rayOrigin, const QVector3D& rayDirection, float maxDistance) const; 25 | 26 | void Render(); 27 | void Update(); 28 | void MakeDirty(); 29 | void UpdateIfDirty(); 30 | bool IsDirty() const { return mDirty; } 31 | 32 | private: 33 | void DestroyOpenGLStuff(); 34 | void ContructOpenGLStuff(); 35 | void InitializeOpenGLStuffIfNot(); 36 | 37 | Eigen::MatrixXf CreateCoefficientMatrix(); 38 | void UpdateSplineControlPoints(); 39 | 40 | QVector mKnots; 41 | QVector mSplineControlPoints; 42 | QVector mBezierControlPoints; 43 | GLuint mVertexArray{ 0 }; 44 | GLuint mVertexBuffer{ 0 }; 45 | 46 | bool mDirty{ false }; 47 | 48 | bool mInitialized{ false }; 49 | 50 | DEFINE_MEMBER(QVector4D, Color, QVector4D(1.0f, 1.0f, 1.0f, 1.0f)); 51 | DEFINE_MEMBER(float, Ambient, 0.25f); 52 | DEFINE_MEMBER(float, Diffuse, 0.50f); 53 | DEFINE_MEMBER(float, Specular, 0.25f); 54 | DEFINE_MEMBER(float, Shininess, 4.0f); 55 | DEFINE_MEMBER(float, Radius, DEFAULT_RADIUS); 56 | 57 | static constexpr int NUM_OF_PATCH_POINTS = 4; 58 | }; 59 | 60 | using SplinePtr = std::shared_ptr; 61 | } -------------------------------------------------------------------------------- /Source/EventHandler/EventHandler.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Curve/Spline.h" 4 | #include "Node/Camera/FreeCamera.h" 5 | #include "Structs/Mouse.h" 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | namespace BSplineRenderer 12 | { 13 | class CurveContainer; 14 | class RendererManager; 15 | 16 | class EventHandler : public QObject 17 | { 18 | Q_OBJECT 19 | public: 20 | explicit EventHandler(QObject* parent); 21 | 22 | void OnKeyPressed(QKeyEvent*); 23 | void OnKeyReleased(QKeyEvent*); 24 | void OnMousePressed(QMouseEvent*); 25 | void OnMouseReleased(QMouseEvent*); 26 | void OnMouseMoved(QMouseEvent*); 27 | void OnWheelMoved(QWheelEvent*); 28 | 29 | void SetCamera(FreeCameraPtr camera) { mCamera = camera; } 30 | void SetCurveContainer(CurveContainer* curveContainer) { mCurveContainer = curveContainer; } 31 | void SetRendererManager(RendererManager* manager) { mRendererManager = manager; } 32 | 33 | Eigen::Vector3f GetViewDirection() const; 34 | 35 | void SetSelectedCurve(SplinePtr spline); 36 | void SetSelectedKnot(KnotPtr knot); 37 | void SetKnotAround(KnotPtr knot); 38 | 39 | void SetDevicePixelRatio(float devicePixelRatio) { mDevicePixelRatio = devicePixelRatio; } 40 | 41 | signals: 42 | void SelectedKnotChanged(KnotPtr knot); 43 | void SelectedCurveChanged(SplinePtr curve); 44 | void KnotAroundChanged(KnotPtr knot); 45 | 46 | private: 47 | void TrySelectKnot(float x, float y); 48 | void TrySelectCurve(float x, float y); 49 | void UpdateKnotTranslationPlane(); 50 | Eigen::ParametrizedLine GetRayFromScreenCoordinates(float x, float y); 51 | 52 | FreeCameraPtr mCamera; 53 | Mouse mMouse; 54 | SplinePtr mSelectedCurve{ nullptr }; 55 | KnotPtr mSelectedKnot{ nullptr }; 56 | KnotPtr mKnotAround{ nullptr }; 57 | 58 | CurveContainer* mCurveContainer; 59 | RendererManager* mRendererManager; 60 | 61 | float mDevicePixelRatio{ 1.0f }; 62 | 63 | Eigen::Hyperplane mKnotTranslationPlane; 64 | 65 | template 66 | T GetCameraViewDirection() 67 | { 68 | const auto& viewDirection = mCamera->GetViewDirection(); 69 | return T(viewDirection[0], viewDirection[1], viewDirection[2]); 70 | } 71 | 72 | template 73 | T GetCameraPosition() 74 | { 75 | const auto& position = mCamera->GetPosition(); 76 | 77 | return T(position[0], position[1], position[2]); 78 | } 79 | 80 | template 81 | T GetDirectionFromScreenCoodinates(int x, int y) 82 | { 83 | const auto& direction = mCamera->GetDirectionFromScreenCoodinates(x, y); 84 | return T(direction[0], direction[1], direction[2]); 85 | } 86 | }; 87 | 88 | } 89 | -------------------------------------------------------------------------------- /Source/Gui/ImGuiWindow.cpp: -------------------------------------------------------------------------------- 1 | #include "ImGuiWindow.h" 2 | 3 | #include "Renderer/RendererManager.h" 4 | #include "Util/Logger.h" 5 | 6 | #include 7 | #include 8 | 9 | BSplineRenderer::ImGuiWindow::ImGuiWindow(QObject* parent) 10 | : QObject(parent) 11 | { 12 | } 13 | 14 | void BSplineRenderer::ImGuiWindow::Draw() 15 | { 16 | mNumberOfSegments = mRendererManager->GetNumberOfSegments(); 17 | mNumberOfSectors = mRendererManager->GetNumberOfSectors(); 18 | 19 | ImGui::Begin("Controls"); 20 | 21 | if (ImGui::CollapsingHeader("Render Settings", ImGuiTreeNodeFlags_DefaultOpen)) 22 | { 23 | if (ImGui::SliderInt("Number of Segments", &mNumberOfSegments, 1, 64)) 24 | { 25 | mRendererManager->SetNumberOfSegments(mNumberOfSegments); 26 | } 27 | 28 | if (ImGui::SliderInt("Number of Sectors", &mNumberOfSectors, 1, 64)) 29 | { 30 | mRendererManager->SetNumberOfSectors(mNumberOfSectors); 31 | } 32 | 33 | ImGui::Checkbox("Wireframe", mRendererManager->GetWireframe()); 34 | 35 | ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate); 36 | } 37 | 38 | ImGui::BeginDisabled(!mSelectedCurve); 39 | if (ImGui::CollapsingHeader("Curve", ImGuiTreeNodeFlags_DefaultOpen)) 40 | { 41 | if (mSelectedCurve) 42 | { 43 | ImGui::Text("Pointer: 0x%p", mSelectedCurve.get()); 44 | ImGui::Text("# of Knots: %zu", mSelectedCurve->GetKnots().size()); 45 | ImGui::SliderFloat("Radius", &mSelectedCurve->GetRadius_NonConst(), 0.10f, 0.50f); 46 | ImGui::SliderFloat("Ambient", &mSelectedCurve->GetAmbient_NonConst(), 0.0f, 1.0f); 47 | ImGui::SliderFloat("Diffuse", &mSelectedCurve->GetDiffuse_NonConst(), 0.0f, 1.0f); 48 | ImGui::ColorEdit4("Color", &mSelectedCurve->GetColor_NonConst()[0]); 49 | 50 | if (mSelectedKnot) 51 | { 52 | ImGui::Text("Selected Knot: (%.2f, %.2f)", mSelectedKnot->GetPosition().x(), mSelectedKnot->GetPosition().y()); 53 | } 54 | } 55 | } 56 | ImGui::EndDisabled(); 57 | 58 | ImGui::End(); 59 | } 60 | 61 | void BSplineRenderer::ImGuiWindow::SetRendererManager(RendererManager* manager) 62 | { 63 | mRendererManager = manager; 64 | } 65 | -------------------------------------------------------------------------------- /Source/Gui/ImGuiWindow.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Curve/Knot.h" 4 | #include "Curve/Spline.h" 5 | #include "Util/Macros.h" 6 | 7 | #include 8 | #include 9 | 10 | namespace BSplineRenderer 11 | { 12 | class RendererManager; 13 | 14 | class ImGuiWindow : public QObject 15 | { 16 | Q_OBJECT 17 | public: 18 | explicit ImGuiWindow(QObject* parent); 19 | 20 | void Draw(); 21 | 22 | void SetRendererManager(RendererManager* manager); 23 | 24 | private: 25 | int mNumberOfSegments; 26 | int mNumberOfSectors; 27 | 28 | RendererManager* mRendererManager; 29 | 30 | DEFINE_MEMBER(SplinePtr, SelectedCurve, nullptr); 31 | DEFINE_MEMBER(KnotPtr, SelectedKnot, nullptr); 32 | }; 33 | } -------------------------------------------------------------------------------- /Source/Main.cpp: -------------------------------------------------------------------------------- 1 | #include "Core/Controller.h" 2 | #include "Util/Logger.h" 3 | 4 | #include 5 | #include 6 | 7 | using namespace BSplineRenderer; 8 | 9 | int main(int argc, char* argv[]) 10 | { 11 | QApplication app(argc, argv); 12 | 13 | qInstallMessageHandler(Logger::QtMessageOutputCallback); 14 | 15 | Controller controller; 16 | 17 | controller.Run(); 18 | 19 | return app.exec(); 20 | } 21 | -------------------------------------------------------------------------------- /Source/Node/Camera/FreeCamera.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Node/Node.h" 4 | #include "Structs/Mouse.h" 5 | 6 | #include 7 | #include 8 | 9 | namespace BSplineRenderer 10 | { 11 | class FreeCamera : public Node 12 | { 13 | public: 14 | FreeCamera() = default; 15 | 16 | void Update(float ifps); 17 | void Reset(); 18 | void Resize(int w, int h); 19 | 20 | void KeyPressed(QKeyEvent*); 21 | void KeyReleased(QKeyEvent*); 22 | void MousePressed(QMouseEvent*); 23 | void MouseReleased(QMouseEvent*); 24 | void MouseMoved(QMouseEvent*); 25 | 26 | QVector3D GetDirectionFromScreenCoodinates(int x, int y); 27 | 28 | const QMatrix4x4& GetProjectionMatrix(); 29 | const QMatrix4x4& GetViewProjectionMatrix(); 30 | const QMatrix4x4& GetRotationMatrix(); 31 | const QMatrix4x4& GetViewMatrix(); 32 | const QVector3D& GetViewDirection(); 33 | 34 | float GetHorizontalFov() const; 35 | float GetAspectRatio() const; 36 | 37 | private: 38 | DEFINE_MEMBER(int, Width, 1600); 39 | DEFINE_MEMBER(int, Height, 900); 40 | DEFINE_MEMBER(float, ZNear, 0.1f); 41 | DEFINE_MEMBER(float, ZFar, 10000.0f); 42 | DEFINE_MEMBER(float, VerticalFov, 60.0f); 43 | 44 | DEFINE_MEMBER(float, AngularSpeed, 25.0f); 45 | DEFINE_MEMBER(float, LinearSpeed, 5.0f); 46 | DEFINE_MEMBER(float, LinearSpeedMultiplier, 1.0f); 47 | DEFINE_MEMBER(float, AngularSpeedMultiplier, 1.0f); 48 | DEFINE_MEMBER(Qt::MouseButton, ActionReceiveButton, Qt::MiddleButton) 49 | 50 | QMap mPressedKeys; 51 | 52 | Mouse mMouse; 53 | 54 | // For caching 55 | QMatrix4x4 mViewProjectionMatrix; 56 | QMatrix4x4 mProjectionMatrix; 57 | QMatrix4x4 mViewMatrix; 58 | QMatrix4x4 mRotationMatrix; 59 | QVector3D mViewDirection; 60 | 61 | bool mUpdateRotation{ false }; 62 | bool mUpdatePosition{ false }; 63 | 64 | static const QMap KEY_BINDINGS; 65 | }; 66 | 67 | using FreeCameraPtr = std::shared_ptr; 68 | } -------------------------------------------------------------------------------- /Source/Node/Light/DirectionalLight.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Node/Light/Light.h" 4 | 5 | namespace BSplineRenderer 6 | { 7 | class DirectionalLight : public Light 8 | { 9 | public: 10 | DirectionalLight() = default; 11 | 12 | DEFINE_MEMBER(QVector3D, Direction, QVector3D(0, 1, 0)); 13 | }; 14 | 15 | using DirectionalLightPtr = std::shared_ptr; 16 | } -------------------------------------------------------------------------------- /Source/Node/Light/Light.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Node/Node.h" 4 | 5 | namespace BSplineRenderer 6 | { 7 | class Light : public Node 8 | { 9 | protected: 10 | Light() = default; 11 | 12 | DEFINE_MEMBER(QVector4D, Color, QVector4D(1.0f, 1.0f, 1.0f, 1.0f)); 13 | DEFINE_MEMBER(float, Ambient, 1.0f); 14 | DEFINE_MEMBER(float, Diffuse, 1.0f); 15 | DEFINE_MEMBER(float, Specular, 1.0f); 16 | DEFINE_MEMBER(bool, Enabled, true); 17 | }; 18 | 19 | using LightPtr = std::shared_ptr; 20 | } -------------------------------------------------------------------------------- /Source/Node/Light/PointLight.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Node/Light/Light.h" 4 | 5 | namespace BSplineRenderer 6 | { 7 | class PointLight : public Light 8 | { 9 | public: 10 | PointLight() = default; 11 | 12 | DEFINE_MEMBER(float, Constant, 1.0f); 13 | DEFINE_MEMBER(float, Linear, 0.05f); 14 | DEFINE_MEMBER(float, Quadratic, 0.001f); 15 | }; 16 | 17 | using PointLightPtr = std::shared_ptr; 18 | } -------------------------------------------------------------------------------- /Source/Node/Mesh/Mesh.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Core/Constants.h" 4 | #include "Node/Mesh/Vertex.h" 5 | #include "Util/Macros.h" 6 | 7 | #include 8 | #include 9 | 10 | namespace BSplineRenderer 11 | { 12 | 13 | class Mesh : protected QOpenGLExtraFunctions 14 | { 15 | DISABLE_COPY(Mesh); 16 | 17 | public: 18 | Mesh() = default; 19 | virtual ~Mesh() = default; 20 | 21 | virtual void Render() = 0; 22 | }; 23 | 24 | using MeshPtr = std::shared_ptr; 25 | using MeshWeakPtr = std::weak_ptr; 26 | } -------------------------------------------------------------------------------- /Source/Node/Mesh/Plane.cpp: -------------------------------------------------------------------------------- 1 | #include "Plane.h" 2 | 3 | #include "Util/Logger.h" 4 | 5 | #include 6 | 7 | BSplineRenderer::Plane::Plane(float size) 8 | { 9 | LOG_DEBUG("Plane::Plane: Constructing OpenGL stuff for Plane."); 10 | 11 | mVertices << Vertex{ QVector3D(-size, 0, size), QVector3D(0, 1, 0), QVector2D(0, 0) }; 12 | mVertices << Vertex{ QVector3D(-size, 0, -size), QVector3D(0, 1, 0), QVector2D(0, 1) }; 13 | mVertices << Vertex{ QVector3D(size, 0, -size), QVector3D(0, 1, 0), QVector2D(1, 1) }; 14 | 15 | mVertices << Vertex{ QVector3D(-size, 0, size), QVector3D(0, 1, 0), QVector2D(0, 0) }; 16 | mVertices << Vertex{ QVector3D(size, 0, -size), QVector3D(0, 1, 0), QVector2D(0, 1) }; 17 | mVertices << Vertex{ QVector3D(size, 0, size), QVector3D(0, 1, 0), QVector2D(1, 0) }; 18 | 19 | initializeOpenGLFunctions(); 20 | 21 | glGenVertexArrays(1, &mVertexArray); 22 | glBindVertexArray(mVertexArray); 23 | 24 | glGenBuffers(1, &mVertexBuffer); 25 | glBindBuffer(GL_ARRAY_BUFFER, mVertexBuffer); 26 | glBufferData(GL_ARRAY_BUFFER, mVertices.size() * sizeof(Vertex), mVertices.constData(), GL_STATIC_DRAW); 27 | 28 | glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*) 0); 29 | glEnableVertexAttribArray(0); 30 | 31 | glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*) (offsetof(Vertex, normal))); 32 | glEnableVertexAttribArray(1); 33 | 34 | if (mVertexArray == 0 || mVertexBuffer == 0) 35 | { 36 | BR_EXIT_FAILURE("Plane::Plane: OpenGL handle(s) could not be created!"); 37 | } 38 | 39 | glBindBuffer(GL_ARRAY_BUFFER, 0); 40 | glBindVertexArray(0); 41 | 42 | LOG_DEBUG("Plane::Plane: OpenGL stuff for Plane has been constructed."); 43 | } 44 | 45 | BSplineRenderer::Plane::~Plane() 46 | { 47 | if (mVertexArray) 48 | { 49 | glDeleteVertexArrays(1, &mVertexArray); 50 | mVertexArray = 0; 51 | } 52 | 53 | if (mVertexBuffer) 54 | { 55 | glDeleteBuffers(1, &mVertexBuffer); 56 | mVertexBuffer = 0; 57 | } 58 | } 59 | 60 | void BSplineRenderer::Plane::Render() 61 | { 62 | glBindVertexArray(mVertexArray); 63 | glDrawArrays(GL_TRIANGLES, 0, mVertices.size()); 64 | glBindVertexArray(0); 65 | } 66 | -------------------------------------------------------------------------------- /Source/Node/Mesh/Plane.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Node/Mesh/Mesh.h" 4 | 5 | namespace BSplineRenderer 6 | { 7 | class Plane : public Mesh 8 | { 9 | public: 10 | Plane(float size); 11 | ~Plane(); 12 | 13 | void Render() override; 14 | 15 | private: 16 | GLuint mVertexArray{ 0 }; 17 | GLuint mVertexBuffer{ 0 }; 18 | 19 | QVector mVertices; 20 | }; 21 | 22 | using PlanePtr = std::shared_ptr; 23 | } -------------------------------------------------------------------------------- /Source/Node/Mesh/Texture.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace BSplineRenderer 7 | { 8 | struct Texture 9 | { 10 | GLuint id; // OpenGL handle 11 | GLuint target; // GL_TEXTURE_2D, GL_TEXTURE_CUBE_MAP etc. 12 | GLuint unit; // Uniform location 13 | QString name; // Texture name in the shader 14 | }; 15 | } -------------------------------------------------------------------------------- /Source/Node/Mesh/Vertex.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace BSplineRenderer 7 | { 8 | struct Vertex 9 | { 10 | QVector3D position; 11 | QVector3D normal; 12 | QVector2D textureCoords; 13 | }; 14 | } 15 | -------------------------------------------------------------------------------- /Source/Node/Model/Model.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Node/Mesh/Mesh.h" 4 | #include "Node/Node.h" 5 | 6 | namespace BSplineRenderer 7 | { 8 | class Model : public Node 9 | { 10 | public: 11 | Model(MeshPtr mesh) 12 | : mMesh(mesh) {} 13 | 14 | MeshPtr GetMesh() const { return mMesh; } 15 | 16 | private: 17 | DEFINE_MEMBER(QVector4D, Color, QVector4D(1.0f, 1.0f, 1.0f, 1.0f)); 18 | DEFINE_MEMBER(float, Ambient, 0.10f); 19 | DEFINE_MEMBER(float, Diffuse, 0.50f); 20 | DEFINE_MEMBER(float, Specular, 0.25f); 21 | DEFINE_MEMBER(float, Shininess, 4.0f); 22 | 23 | MeshPtr mMesh; 24 | }; 25 | 26 | using ModelPtr = std::shared_ptr; 27 | } -------------------------------------------------------------------------------- /Source/Node/Node.cpp: -------------------------------------------------------------------------------- 1 | #include "Node.h" 2 | 3 | void BSplineRenderer::Node::SetRotation(const QQuaternion& newRotation) 4 | { 5 | if (mRotation == newRotation) 6 | { 7 | return; 8 | } 9 | 10 | mRotation = newRotation; 11 | Node::UpdateTransformation(); 12 | MakeDirty(); 13 | } 14 | 15 | void BSplineRenderer::Node::SetPosition(const QVector3D& newPosition) 16 | { 17 | if (mPosition == newPosition) 18 | { 19 | return; 20 | } 21 | 22 | mPosition = newPosition; 23 | Node::UpdateTransformation(); 24 | MakeDirty(); 25 | } 26 | 27 | void BSplineRenderer::Node::SetScale(const QVector3D& newScale) 28 | { 29 | if (mScale == newScale) 30 | { 31 | return; 32 | } 33 | 34 | mScale = newScale; 35 | Node::UpdateTransformation(); 36 | MakeDirty(); 37 | } 38 | 39 | void BSplineRenderer::Node::SetTransformation(const QMatrix4x4& newTransformation) 40 | { 41 | if (mTransformation == newTransformation) 42 | { 43 | return; 44 | } 45 | 46 | mTransformation = newTransformation; 47 | mPosition = mTransformation.column(3).toVector3D(); 48 | mRotation = QQuaternion::fromRotationMatrix(mTransformation.normalMatrix()); 49 | MakeDirty(); 50 | } 51 | 52 | void BSplineRenderer::Node::SetPosition(float x, float y, float z) 53 | { 54 | SetPosition(QVector3D(x, y, z)); 55 | } 56 | 57 | void BSplineRenderer::Node::SetScale(float x, float y, float z) 58 | { 59 | SetScale(QVector3D(x, y, z)); 60 | } 61 | 62 | void BSplineRenderer::Node::UpdateTransformation() 63 | { 64 | mTransformation.setToIdentity(); 65 | mTransformation.scale(mScale); 66 | mTransformation.rotate(mRotation); 67 | mTransformation.setColumn(3, QVector4D(mPosition, 1.0f)); 68 | 69 | mNormalMatrix = mTransformation.normalMatrix(); 70 | } 71 | 72 | void BSplineRenderer::Node::RotateGlobal(const QVector3D& axis, float angle) 73 | { 74 | SetRotation(QQuaternion::fromAxisAndAngle(axis, angle) * GetRotation()); 75 | } 76 | 77 | void BSplineRenderer::Node::RotateLocal(const QVector3D& axis, float angle) 78 | { 79 | SetRotation(GetRotation() * QQuaternion::fromAxisAndAngle(axis, angle)); 80 | } 81 | 82 | void BSplineRenderer::Node::Translate(const QVector3D& delta) 83 | { 84 | SetPosition(mPosition + delta); 85 | } 86 | -------------------------------------------------------------------------------- /Source/Node/Node.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Util/Macros.h" 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | namespace BSplineRenderer 12 | { 13 | class Node 14 | { 15 | DISABLE_COPY(Node); 16 | 17 | protected: 18 | Node() = default; 19 | virtual ~Node() = default; 20 | 21 | public: 22 | const QMatrix4x4& GetTransformation() const { return mTransformation; } 23 | const QQuaternion& GetRotation() const { return mRotation; } 24 | 25 | const QVector3D& GetPosition() const { return mPosition; } 26 | const float GetPosition(int coord) const { return mPosition[coord]; } 27 | float* GetPosition(int coord) { return &mPosition[coord]; } 28 | 29 | const QVector3D& GetScale() const { return mScale; } 30 | const float GetScale(int coord) const { return mScale[coord]; } 31 | float* GetScale(int coord) { return &mScale[coord]; } 32 | 33 | const QMatrix3x3 GetNormalMatrix() const { return mNormalMatrix; } 34 | 35 | void SetTransformation(const QMatrix4x4& newTransformation); 36 | void SetRotation(const QQuaternion& newRotation); 37 | void SetPosition(const QVector3D& newPosition); 38 | void SetPosition(float x, float y, float z); 39 | void SetScale(const QVector3D& newScale); 40 | void SetScale(float x, float y, float z); 41 | 42 | virtual void UpdateTransformation(); 43 | 44 | void RotateGlobal(const QVector3D& axis, float angle); 45 | void RotateLocal(const QVector3D& axis, float angle); 46 | void Translate(const QVector3D& delta); 47 | 48 | void MakeDirty() { mDirty = true; } 49 | void MakeClean() { mDirty = false; } 50 | bool GetDirty() const { return mDirty; } 51 | 52 | private: 53 | QMatrix4x4 mTransformation; 54 | QMatrix3x3 mNormalMatrix; 55 | QQuaternion mRotation; 56 | QVector3D mPosition{ QVector3D(0, 0, 0) }; 57 | QVector3D mScale{ QVector3D(1, 1, 1) }; 58 | 59 | bool mDirty{ false }; 60 | 61 | DEFINE_MEMBER(QString, NodeName); 62 | }; 63 | 64 | using NodePtr = std::shared_ptr; 65 | } 66 | -------------------------------------------------------------------------------- /Source/Node/SkyBox/SkyBox.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Node/Mesh/Mesh.h" 4 | #include "Node/Mesh/Texture.h" 5 | #include "Util/Macros.h" 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | namespace BSplineRenderer 12 | { 13 | class SkyBox : public Mesh 14 | { 15 | public: 16 | SkyBox(const QString& folder, const QString& extension); 17 | ~SkyBox(); 18 | 19 | void Render() override; 20 | 21 | private: 22 | GLuint mTexture; 23 | GLuint mVertexArray{ 0 }; 24 | GLuint mVertexBuffer{ 0 }; 25 | 26 | DEFINE_MEMBER(float, Brightness, 0.5f); 27 | 28 | static const float VERTICES[108]; 29 | }; 30 | 31 | using SkyBoxPtr = std::shared_ptr; 32 | } -------------------------------------------------------------------------------- /Source/Renderer/Base/CurveSelectionFramebuffer.cpp: -------------------------------------------------------------------------------- 1 | #include "CurveSelectionFramebuffer.h" 2 | 3 | #include "Util/Logger.h" 4 | 5 | BSplineRenderer::CurveSelectionFramebuffer::CurveSelectionFramebuffer(int width, int height) 6 | : mWidth(width) 7 | , mHeight(height) 8 | { 9 | initializeOpenGLFunctions(); 10 | 11 | // Generate framebuffer 12 | glGenFramebuffers(1, &mFramebuffer); 13 | glBindFramebuffer(GL_FRAMEBUFFER, mFramebuffer); 14 | 15 | // Generate texture 16 | glGenTextures(1, &mTexture); 17 | glBindTexture(GL_TEXTURE_2D, mTexture); 18 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32I, mWidth, mHeight, 0, GL_RGBA_INTEGER, GL_INT, NULL); 19 | 20 | // Bind texture to the framebuffer 21 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mTexture, 0); 22 | 23 | if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) 24 | { 25 | BR_EXIT_FAILURE("CurveSelectionFramebuffer::CurveSelectionFramebuffer: Could not create framebuffer!"); 26 | } 27 | 28 | glBindTexture(GL_TEXTURE_2D, 0); 29 | glBindFramebuffer(GL_FRAMEBUFFER, 0); 30 | } 31 | 32 | BSplineRenderer::CurveSelectionFramebuffer::~CurveSelectionFramebuffer() 33 | { 34 | if (mFramebuffer != 0) 35 | { 36 | glDeleteFramebuffers(1, &mFramebuffer); 37 | } 38 | 39 | if (mTexture != 0) 40 | { 41 | glDeleteTextures(1, &mTexture); 42 | } 43 | } 44 | 45 | void BSplineRenderer::CurveSelectionFramebuffer::Clear() 46 | { 47 | glBindFramebuffer(GL_FRAMEBUFFER, mFramebuffer); 48 | glViewport(0, 0, mWidth, mHeight); 49 | glClearColor(0, 0, 0, 0); 50 | glClear(GL_COLOR_BUFFER_BIT); 51 | } 52 | 53 | void BSplineRenderer::CurveSelectionFramebuffer::Bind() 54 | { 55 | glBindFramebuffer(GL_FRAMEBUFFER, mFramebuffer); 56 | } 57 | 58 | BSplineRenderer::CurveQueryInfo BSplineRenderer::CurveSelectionFramebuffer::Query(const QPoint& queryPoint) 59 | { 60 | CurveQueryInfo info; 61 | Bind(); 62 | glReadBuffer(GL_COLOR_ATTACHMENT0); 63 | glReadPixels(queryPoint.x(), mHeight - queryPoint.y(), 1, 1, GL_RGBA_INTEGER, GL_INT, &info); 64 | 65 | return info; 66 | } 67 | -------------------------------------------------------------------------------- /Source/Renderer/Base/CurveSelectionFramebuffer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | namespace BSplineRenderer 9 | { 10 | struct CurveQueryInfo 11 | { 12 | int index; 13 | int unused0; 14 | int unused1; 15 | int result; // 0: Fail, 1: Success 16 | }; 17 | 18 | class CurveSelectionFramebuffer : protected QOpenGLFunctions_4_5_Core 19 | { 20 | public: 21 | CurveSelectionFramebuffer(int width, int height); 22 | ~CurveSelectionFramebuffer(); 23 | 24 | void Clear(); 25 | void Bind(); 26 | CurveQueryInfo Query(const QPoint& queryPoint); 27 | 28 | GLuint GetHandle() const { return mFramebuffer; } 29 | GLuint GetTexture() const { return mTexture; } 30 | 31 | private: 32 | GLuint mFramebuffer{ 0 }; 33 | GLuint mTexture{ 0 }; 34 | 35 | int mWidth; 36 | int mHeight; 37 | }; 38 | 39 | using CurveSelectionFramebufferPtr = std::shared_ptr; 40 | } -------------------------------------------------------------------------------- /Source/Renderer/Base/Interval.cpp: -------------------------------------------------------------------------------- 1 | #include "Interval.h" 2 | 3 | BSplineRenderer::Interval::Interval(float start, float end, int size) 4 | : mStart(start) 5 | , mEnd(end) 6 | , mSize(size) 7 | { 8 | initializeOpenGLFunctions(); 9 | 10 | mPoints = QVector(mSize, 0.0); 11 | 12 | for (int i = 0; i < mSize; ++i) 13 | { 14 | mPoints[i] = mStart + (mEnd - mStart) * i / mSize; 15 | } 16 | 17 | glGenVertexArrays(1, &mVertexArray); 18 | glBindVertexArray(mVertexArray); 19 | 20 | glGenBuffers(1, &mVertexBuffer); 21 | glBindBuffer(GL_ARRAY_BUFFER, mVertexBuffer); 22 | glBufferData(GL_ARRAY_BUFFER, mPoints.size() * sizeof(float), mPoints.constData(), GL_STATIC_DRAW); 23 | 24 | glVertexAttribPointer(0, 1, GL_FLOAT, GL_FALSE, 0, (void*) 0); 25 | glEnableVertexAttribArray(0); 26 | 27 | glBindVertexArray(0); 28 | } 29 | 30 | void BSplineRenderer::Interval::Bind() 31 | { 32 | glBindVertexArray(mVertexArray); 33 | } 34 | 35 | void BSplineRenderer::Interval::Render() 36 | { 37 | glDrawArrays(GL_POINTS, 0, mPoints.size()); 38 | } 39 | 40 | void BSplineRenderer::Interval::Release() 41 | { 42 | glBindVertexArray(0); 43 | } 44 | 45 | void BSplineRenderer::Interval::Destroy() 46 | { 47 | if (mVertexArray) 48 | { 49 | glDeleteVertexArrays(1, &mVertexArray); 50 | mVertexArray = 0; 51 | } 52 | 53 | if (mVertexBuffer) 54 | { 55 | glDeleteBuffers(1, &mVertexBuffer); 56 | mVertexBuffer = 0; 57 | } 58 | } 59 | 60 | float BSplineRenderer::Interval::GetDelta() const 61 | { 62 | return (mEnd - mStart) / mSize; 63 | } 64 | -------------------------------------------------------------------------------- /Source/Renderer/Base/Interval.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Util/Macros.h" 4 | 5 | #include 6 | #include 7 | 8 | namespace BSplineRenderer 9 | { 10 | class Interval : protected QOpenGLExtraFunctions 11 | { 12 | public: 13 | Interval(float start, float end, int size); 14 | 15 | void Bind(); 16 | void Render(); 17 | void Release(); 18 | void Destroy(); 19 | float GetDelta() const; 20 | 21 | private: 22 | QVector mPoints; 23 | float mStart; 24 | float mEnd; 25 | int mSize; 26 | GLuint mVertexArray{ 0 }; 27 | GLuint mVertexBuffer{ 0 }; 28 | }; 29 | 30 | } -------------------------------------------------------------------------------- /Source/Renderer/Base/Quad.cpp: -------------------------------------------------------------------------------- 1 | #include "Quad.h" 2 | 3 | BSplineRenderer::Quad::Quad() 4 | { 5 | initializeOpenGLFunctions(); 6 | 7 | constexpr float VERTICES[24] = { 8 | -1.0f, +1.0f, 0.0f, 1.0f, 9 | -1.0f, -1.0f, 0.0f, 0.0f, 10 | +1.0f, -1.0f, 1.0f, 0.0f, 11 | -1.0f, +1.0f, 0.0f, 1.0f, 12 | +1.0f, -1.0f, 1.0f, 0.0f, 13 | +1.0f, +1.0f, 1.0f, 1.0f 14 | }; 15 | 16 | glGenVertexArrays(1, &mVertexArray); 17 | glBindVertexArray(mVertexArray); 18 | 19 | glGenBuffers(1, &mVertexBuffer); 20 | glBindBuffer(GL_ARRAY_BUFFER, mVertexBuffer); 21 | glBufferData(GL_ARRAY_BUFFER, sizeof(VERTICES), VERTICES, GL_STATIC_DRAW); 22 | 23 | glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (void*) 0); 24 | glEnableVertexAttribArray(0); 25 | 26 | glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (void*) (2 * sizeof(float))); 27 | glEnableVertexAttribArray(1); 28 | } 29 | 30 | void BSplineRenderer::Quad::Render() 31 | { 32 | glBindVertexArray(mVertexArray); 33 | glDrawArrays(GL_TRIANGLES, 0, 6); 34 | glBindVertexArray(0); 35 | } 36 | -------------------------------------------------------------------------------- /Source/Renderer/Base/Quad.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace BSplineRenderer 6 | { 7 | class Quad : protected QOpenGLExtraFunctions 8 | { 9 | public: 10 | Quad(); 11 | 12 | void Render(); 13 | 14 | private: 15 | GLuint mVertexArray; 16 | GLuint mVertexBuffer; 17 | }; 18 | } 19 | -------------------------------------------------------------------------------- /Source/Renderer/Base/Shader.cpp: -------------------------------------------------------------------------------- 1 | #include "Shader.h" 2 | 3 | #include "Util/Util.h" 4 | 5 | #include 6 | #include 7 | 8 | BSplineRenderer::Shader::Shader(const QString& name) 9 | : mProgram(nullptr) 10 | , mName(name) 11 | { 12 | } 13 | 14 | void BSplineRenderer::Shader::Initialize() 15 | { 16 | LOG_INFO("Shader::Initialize: '{}' is being initializing.", mName.toStdString()); 17 | 18 | initializeOpenGLFunctions(); 19 | 20 | mProgram = QSharedPointer(new QOpenGLShaderProgram); 21 | 22 | for (const auto [shaderType, path] : mPaths) 23 | { 24 | const auto bytes = Util::GetBytes(path); 25 | if (!mProgram->addShaderFromSourceCode(shaderType, bytes)) 26 | { 27 | BR_EXIT_FAILURE("Shader::Initialize: '{}' could not be loaded.", GetShaderTypeString(shaderType).toStdString()); 28 | } 29 | } 30 | 31 | if (!mProgram->link()) 32 | { 33 | BR_EXIT_FAILURE("Shader::Initialize: Could not link shader program."); 34 | } 35 | 36 | if (!mProgram->bind()) 37 | { 38 | BR_EXIT_FAILURE("Shader::Initialize: Could not bind shader program."); 39 | } 40 | 41 | LOG_INFO("Shader::Initialize: '{}' has been initialized.", mName.toStdString()); 42 | } 43 | 44 | bool BSplineRenderer::Shader::Bind() 45 | { 46 | return mProgram->bind(); 47 | } 48 | 49 | void BSplineRenderer::Shader::Release() 50 | { 51 | mProgram->release(); 52 | } 53 | 54 | void BSplineRenderer::Shader::AddPath(QOpenGLShader::ShaderTypeBit type, const QString& path) 55 | { 56 | mPaths.emplace(type, path); 57 | } 58 | 59 | QString BSplineRenderer::Shader::GetName() const 60 | { 61 | return mName; 62 | } 63 | 64 | QString BSplineRenderer::Shader::GetShaderTypeString(QOpenGLShader::ShaderTypeBit type) 65 | { 66 | switch (type) 67 | { 68 | case QOpenGLShader::Vertex: 69 | return "Vertex Shader"; 70 | case QOpenGLShader::Fragment: 71 | return "Fragment Shader"; 72 | case QOpenGLShader::Geometry: 73 | return "Geometry Shader"; 74 | case QOpenGLShader::TessellationControl: 75 | return "Tessellation Control Shader"; 76 | case QOpenGLShader::TessellationEvaluation: 77 | return "Tesselation Evaluation Shader"; 78 | case QOpenGLShader::Compute: 79 | return "Compute Shader"; 80 | default: 81 | return "Unknown Shader"; 82 | } 83 | } 84 | 85 | void BSplineRenderer::Shader::SetSampler(const QString& name, GLuint unit, GLuint textureId, GLuint target) 86 | { 87 | SetUniformValue(name, unit); 88 | glActiveTexture(GL_TEXTURE0 + unit); 89 | glBindTexture(target, textureId); 90 | } 91 | -------------------------------------------------------------------------------- /Source/Renderer/Base/Shader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Util/Logger.h" 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | namespace BSplineRenderer 11 | { 12 | class Shader : protected QOpenGLExtraFunctions 13 | { 14 | public: 15 | Shader(const QString& name); 16 | 17 | void Initialize(); 18 | bool Bind(); 19 | void Release(); 20 | 21 | void AddPath(QOpenGLShader::ShaderTypeBit type, const QString& path); 22 | 23 | QString GetName() const; 24 | 25 | static QString GetShaderTypeString(QOpenGLShader::ShaderTypeBit type); 26 | 27 | template 28 | void SetUniformValue(const QString& name, T value) 29 | { 30 | const auto location = mProgram->uniformLocation(name); 31 | 32 | if (0 <= location) 33 | { 34 | mProgram->setUniformValue(location, value); 35 | } 36 | else 37 | { 38 | LOG_WARN("Shader::SetUniformValue: Uniform location '{}' could not be found.", name.toStdString()); 39 | } 40 | } 41 | 42 | template 43 | void SetUniformValueArray(const QString& name, const QVector& values) 44 | { 45 | const auto location = mProgram->uniformLocation(name); 46 | 47 | if (0 <= location) 48 | { 49 | mProgram->setUniformValueArray(location, values.constData(), values.size()); 50 | } 51 | else 52 | { 53 | LOG_WARN("Shader::SetUniformValue: Uniform location '{}' could not be found.", name.toStdString()); 54 | } 55 | } 56 | 57 | void SetUniformValueFloatArray(const QString& name, const QVector& values) 58 | { 59 | const auto location = mProgram->uniformLocation(name); 60 | 61 | if (0 <= location) 62 | { 63 | mProgram->setUniformValueArray(location, values.constData(), values.size(), 1); 64 | } 65 | else 66 | { 67 | LOG_WARN("Shader::SetUniformValue: Uniform location '{}' could not be found.", name.toStdString()); 68 | } 69 | } 70 | 71 | void SetSampler(const QString& name, GLuint unit, GLuint textureId, GLuint target = GL_TEXTURE_2D); 72 | 73 | private: 74 | QSharedPointer mProgram; 75 | std::map mPaths; 76 | 77 | QString mName; 78 | }; 79 | } 80 | -------------------------------------------------------------------------------- /Source/Renderer/CurveSelectionRenderer.cpp: -------------------------------------------------------------------------------- 1 | #include "CurveSelectionRenderer.h" 2 | 3 | void BSplineRenderer::CurveSelectionRenderer::Initialize() 4 | { 5 | initializeOpenGLFunctions(); 6 | 7 | mShader = new Shader("Curve Selection Shader"); 8 | mShader->AddPath(QOpenGLShader::Vertex, ":/Resources/Shaders/Spline.vert"); 9 | mShader->AddPath(QOpenGLShader::TessellationControl, ":/Resources/Shaders/Spline.tcs"); 10 | mShader->AddPath(QOpenGLShader::TessellationEvaluation, ":/Resources/Shaders/Spline.tes"); 11 | mShader->AddPath(QOpenGLShader::Fragment, ":/Resources/Shaders/CurveSelection.frag"); 12 | mShader->Initialize(); 13 | } 14 | 15 | void BSplineRenderer::CurveSelectionRenderer::Render() 16 | { 17 | mFramebuffer->Clear(); 18 | mFramebuffer->Bind(); 19 | 20 | mShader->Bind(); 21 | mShader->SetUniformValue("numberOfSegments", mNumberOfSegments); 22 | mShader->SetUniformValue("numberOfSectors", mNumberOfSectors); 23 | mShader->SetUniformValue("VP", mCamera->GetViewProjectionMatrix()); 24 | 25 | const auto& curves = mCurveContainer->GetCurves(); 26 | 27 | for (int index = 0; index < curves.size(); ++index) 28 | { 29 | const auto& curve = curves[index]; 30 | mShader->SetUniformValue("curveIndex", index); 31 | mShader->SetUniformValue("radius", curve->GetRadius()); 32 | curve->Render(); 33 | } 34 | 35 | mShader->Release(); 36 | } 37 | 38 | void BSplineRenderer::CurveSelectionRenderer::Resize(int width, int height) 39 | { 40 | if (mFramebuffer) 41 | { 42 | delete mFramebuffer; 43 | mFramebuffer = nullptr; 44 | } 45 | 46 | mFramebuffer = new CurveSelectionFramebuffer(width, height); 47 | } 48 | 49 | BSplineRenderer::CurveQueryInfo BSplineRenderer::CurveSelectionRenderer::Query(const QPoint& queryPoint) 50 | { 51 | return mFramebuffer->Query(queryPoint); 52 | } 53 | 54 | void BSplineRenderer::CurveSelectionRenderer::SetCurveContainer(CurveContainer* curveContainer) 55 | { 56 | mCurveContainer = curveContainer; 57 | } 58 | 59 | void BSplineRenderer::CurveSelectionRenderer::SetCamera(FreeCameraPtr camera) 60 | { 61 | mCamera = camera; 62 | } 63 | -------------------------------------------------------------------------------- /Source/Renderer/CurveSelectionRenderer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Core/CurveContainer.h" 4 | #include "Node/Camera/FreeCamera.h" 5 | #include "Renderer/Base/CurveSelectionFramebuffer.h" 6 | #include "Renderer/Base/Shader.h" 7 | 8 | #include 9 | 10 | namespace BSplineRenderer 11 | { 12 | class CurveSelectionRenderer : protected QOpenGLExtraFunctions 13 | { 14 | public: 15 | CurveSelectionRenderer() = default; 16 | 17 | void Initialize(); 18 | void Render(); 19 | void Resize(int width, int height); 20 | 21 | CurveQueryInfo Query(const QPoint& queryPoint); 22 | 23 | void SetCurveContainer(CurveContainer* curveContainer); 24 | void SetCamera(FreeCameraPtr camera); 25 | 26 | private: 27 | CurveContainer* mCurveContainer; 28 | Shader* mShader; 29 | FreeCameraPtr mCamera; 30 | CurveSelectionFramebuffer* mFramebuffer{ nullptr }; 31 | 32 | DEFINE_MEMBER(int, NumberOfSegments, DEFAULT_NUMBER_OF_SEGMENTS); 33 | DEFINE_MEMBER(int, NumberOfSectors, DEFAULT_NUMBER_OF_SECTORS); 34 | }; 35 | } -------------------------------------------------------------------------------- /Source/Renderer/RendererManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Curve/Spline.h" 4 | #include "Node/Camera/FreeCamera.h" 5 | #include "Node/Light/DirectionalLight.h" 6 | #include "Node/Mesh/Plane.h" 7 | #include "Node/Mesh/Sphere.h" 8 | #include "Node/Model/Model.h" 9 | #include "Node/SkyBox/SkyBox.h" 10 | #include "Renderer/Base/Shader.h" 11 | #include "Renderer/CurveSelectionRenderer.h" 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | namespace BSplineRenderer 19 | { 20 | 21 | class CurveContainer; 22 | class SplineRenderer; 23 | 24 | class RendererManager : protected QOpenGLFunctions_4_5_Core 25 | { 26 | public: 27 | RendererManager(); 28 | 29 | void Initialize(); 30 | void Resize(int width, int height); 31 | void Render(); 32 | 33 | CurveQueryInfo Query(const QPoint& queryPoint); 34 | 35 | void AddModel(ModelPtr model); 36 | void RemoveModel(ModelPtr model); 37 | FreeCameraPtr GetCamera() const { return mCamera; } 38 | 39 | void SetCurveContainer(CurveContainer* curveContainer) { mCurveContainer = curveContainer; } 40 | 41 | void SetNumberOfSegments(int numberOfSegments); 42 | void SetNumberOfSectors(int numberOfSectors); 43 | 44 | int GetNumberOfSegments() const; 45 | int GetNumberOfSectors() const; 46 | 47 | bool* GetWireframe(); 48 | 49 | public slots: 50 | void SetSelectedCurve(SplinePtr spline) { mSelectedCurve = spline; } 51 | void SetSelectedKnot(KnotPtr knot) { mSelectedKnot = knot; } 52 | void SetKnotAround(KnotPtr knot) { mKnotAround = knot; } 53 | 54 | private: 55 | void RenderKnots(SplinePtr curve); 56 | 57 | Shader* mModelShader; 58 | Shader* mSkyBoxShader; 59 | CurveContainer* mCurveContainer; 60 | FreeCameraPtr mCamera; 61 | DirectionalLightPtr mLight; 62 | 63 | QVector mModels; 64 | 65 | SkyBoxPtr mSkyBox; 66 | Model* mSphereModel; 67 | 68 | SplineRenderer* mSplineRenderer; 69 | CurveSelectionRenderer* mCurveSelectionRenderer; 70 | 71 | SplinePtr mSelectedCurve{ nullptr }; 72 | KnotPtr mSelectedKnot{ nullptr }; 73 | KnotPtr mKnotAround{ nullptr }; 74 | }; 75 | } -------------------------------------------------------------------------------- /Source/Renderer/SplineRenderer.cpp: -------------------------------------------------------------------------------- 1 | #include "SplineRenderer.h" 2 | 3 | #include "Core/Constants.h" 4 | #include "Core/CurveContainer.h" 5 | 6 | void BSplineRenderer::SplineRenderer::Initialize() 7 | { 8 | initializeOpenGLFunctions(); 9 | 10 | mSplineShader = new Shader("Spline Shader"); 11 | mSplineShader->AddPath(QOpenGLShader::Vertex, ":/Resources/Shaders/Spline.vert"); 12 | mSplineShader->AddPath(QOpenGLShader::TessellationControl, ":/Resources/Shaders/Spline.tcs"); 13 | mSplineShader->AddPath(QOpenGLShader::TessellationEvaluation, ":/Resources/Shaders/Spline.tes"); 14 | mSplineShader->AddPath(QOpenGLShader::Fragment, ":/Resources/Shaders/Spline.frag"); 15 | mSplineShader->Initialize(); 16 | } 17 | 18 | void BSplineRenderer::SplineRenderer::Render() 19 | { 20 | if (mWireframe) 21 | { 22 | glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); 23 | } 24 | 25 | mSplineShader->Bind(); 26 | mSplineShader->SetUniformValue("numberOfSegments", mNumberOfSegments); 27 | mSplineShader->SetUniformValue("numberOfSectors", mNumberOfSectors); 28 | mSplineShader->SetUniformValue("VP", mCamera->GetProjectionMatrix() * mCamera->GetViewMatrix()); 29 | 30 | mSplineShader->SetUniformValue("light.color", mLight->GetColor()); 31 | mSplineShader->SetUniformValue("light.direction", mLight->GetDirection()); 32 | mSplineShader->SetUniformValue("light.ambient", mLight->GetAmbient()); 33 | mSplineShader->SetUniformValue("light.diffuse", mLight->GetDiffuse()); 34 | 35 | const auto& curves = mCurveContainer->GetCurves(); 36 | 37 | for (int index = 0; index < curves.size(); ++index) 38 | { 39 | const auto& curve = curves[index]; 40 | mSplineShader->SetUniformValue("curve.color", curve->GetColor()); 41 | mSplineShader->SetUniformValue("curve.ambient", curve->GetAmbient()); 42 | mSplineShader->SetUniformValue("curve.diffuse", curve->GetDiffuse()); 43 | mSplineShader->SetUniformValue("radius", curve->GetRadius()); 44 | curve->Render(); 45 | } 46 | 47 | mSplineShader->Release(); 48 | 49 | if (mWireframe) 50 | { 51 | glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); 52 | } 53 | } 54 | 55 | void BSplineRenderer::SplineRenderer::SetCurveContainer(CurveContainer* curveContainer) 56 | { 57 | mCurveContainer = curveContainer; 58 | } 59 | 60 | void BSplineRenderer::SplineRenderer::SetCamera(FreeCameraPtr camera) 61 | { 62 | mCamera = camera; 63 | } 64 | 65 | void BSplineRenderer::SplineRenderer::SetLight(DirectionalLightPtr light) 66 | { 67 | mLight = light; 68 | } 69 | -------------------------------------------------------------------------------- /Source/Renderer/SplineRenderer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Node/Camera/FreeCamera.h" 4 | #include "Node/Light/DirectionalLight.h" 5 | #include "Node/Mesh/Sphere.h" 6 | #include "Node/Model/Model.h" 7 | #include "Renderer/Base/Shader.h" 8 | 9 | #include 10 | 11 | namespace BSplineRenderer 12 | { 13 | class CurveContainer; 14 | 15 | class SplineRenderer : protected QOpenGLFunctions_4_5_Core 16 | { 17 | public: 18 | SplineRenderer() = default; 19 | 20 | void Initialize(); 21 | void Render(); 22 | void SetCurveContainer(CurveContainer* CurveContainer); 23 | void SetCamera(FreeCameraPtr camera); 24 | void SetLight(DirectionalLightPtr light); 25 | 26 | private: 27 | CurveContainer* mCurveContainer; 28 | FreeCameraPtr mCamera; 29 | DirectionalLightPtr mLight; 30 | 31 | Shader* mSplineShader; 32 | 33 | DEFINE_MEMBER(bool, Wireframe, false); 34 | DEFINE_MEMBER(int, NumberOfSegments, DEFAULT_NUMBER_OF_SEGMENTS); 35 | DEFINE_MEMBER(int, NumberOfSectors, DEFAULT_NUMBER_OF_SECTORS); 36 | }; 37 | } -------------------------------------------------------------------------------- /Source/Structs/Mouse.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace BSplineRenderer 6 | { 7 | struct Mouse 8 | { 9 | float x{ 0 }; 10 | float y{ 0 }; 11 | float dx{ 0 }; 12 | float dy{ 0 }; 13 | 14 | Qt::MouseButton button{ Qt::NoButton }; 15 | 16 | void Reset() 17 | { 18 | x = 0; 19 | y = 0; 20 | dx = 0; 21 | dy = 0; 22 | button = Qt::NoButton; 23 | } 24 | }; 25 | } -------------------------------------------------------------------------------- /Source/Util/Logger.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "Logger.h" 3 | 4 | void BSplineRenderer::Logger::Log(LogLevel level, const std::string& message) 5 | { 6 | thread_local const auto TL_THREAD_ID = mLastThreadId.fetch_add(1); 7 | 8 | const auto log = std::format("{:.12} [{:}] [ {:5} ] {:}", GetTimeString(), TL_THREAD_ID, GetLogLevelString(level), message); 9 | 10 | switch (level) 11 | { 12 | case LogLevel::TRACE: 13 | case LogLevel::DEBUG: 14 | 15 | case LogLevel::INFO: 16 | std::cout << log << std::endl; 17 | break; 18 | case LogLevel::WARNING: 19 | case LogLevel::FATAL: 20 | std::cerr << log << std::endl; 21 | break; 22 | default: 23 | break; 24 | } 25 | } 26 | 27 | void BSplineRenderer::Logger::SetLogLevel(LogLevel logLevel) 28 | { 29 | mLogLevel = logLevel; 30 | } 31 | 32 | BSplineRenderer::LogLevel BSplineRenderer::Logger::GetLogLevel() 33 | { 34 | return mLogLevel; 35 | } 36 | 37 | std::string BSplineRenderer::Logger::GetTimeString() 38 | { 39 | const auto zone = std::chrono::current_zone(); 40 | const auto now = std::chrono::system_clock::now(); 41 | const auto local = std::chrono::zoned_time(zone, now); 42 | 43 | return std::format("{:%T}", local); 44 | } 45 | 46 | void BSplineRenderer::Logger::QtMessageOutputCallback(QtMsgType type, const QMessageLogContext& context, const QString& msg) 47 | { 48 | switch (type) 49 | { 50 | case QtDebugMsg: 51 | LOG_DEBUG("{}", msg.toStdString()); 52 | break; 53 | case QtInfoMsg: 54 | LOG_INFO("{}", msg.toStdString()); 55 | break; 56 | case QtWarningMsg: 57 | LOG_WARN("{}", msg.toStdString()); 58 | break; 59 | case QtCriticalMsg: 60 | LOG_FATAL("{}", msg.toStdString()); 61 | break; 62 | case QtFatalMsg: 63 | LOG_FATAL("{}", msg.toStdString()); 64 | break; 65 | } 66 | } 67 | 68 | bool BSplineRenderer::Logger::isLogEnabledFor(LogLevel level) 69 | { 70 | return mLogLevel <= level; 71 | } 72 | 73 | BSplineRenderer::LogLevel BSplineRenderer::Logger::mLogLevel = BSplineRenderer::LogLevel::ALL; 74 | 75 | std::atomic_uint32_t BSplineRenderer::Logger::mLastThreadId = 0; -------------------------------------------------------------------------------- /Source/Util/Logger.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | namespace BSplineRenderer 12 | { 13 | enum class LogLevel 14 | { 15 | ALL = -1, 16 | TRACE = 0, 17 | DEBUG = 1, 18 | INFO = 2, 19 | WARNING = 3, 20 | FATAL = 4, 21 | NONE = 5 22 | }; 23 | 24 | class Logger 25 | { 26 | public: 27 | Logger() = delete; 28 | 29 | static void Log(LogLevel level, const std::string& message); 30 | static void SetLogLevel(LogLevel logLevel); 31 | static bool isLogEnabledFor(LogLevel level); 32 | static LogLevel GetLogLevel(); 33 | static std::string GetTimeString(); 34 | 35 | static void QtMessageOutputCallback(QtMsgType type, const QMessageLogContext& context, const QString& msg); 36 | 37 | inline static std::string GetLogLevelString(LogLevel level) 38 | { 39 | switch (level) 40 | { 41 | case LogLevel::ALL: 42 | return "ALL"; 43 | case LogLevel::NONE: 44 | return "NONE"; 45 | case LogLevel::TRACE: 46 | return "TRACE"; 47 | case LogLevel::DEBUG: 48 | return "DEBUG"; 49 | case LogLevel::INFO: 50 | return "INFO"; 51 | case LogLevel::WARNING: 52 | return "WARN"; 53 | case LogLevel::FATAL: 54 | return "FATAL"; 55 | default: 56 | return "N/A"; 57 | } 58 | } 59 | 60 | private: 61 | static LogLevel mLogLevel; 62 | static std::atomic_uint32_t mLastThreadId; 63 | }; 64 | } 65 | 66 | #define LOG_PRIVATE(LEVEL, FORMAT, ...) \ 67 | do \ 68 | { \ 69 | if (BSplineRenderer::Logger::isLogEnabledFor(LEVEL)) \ 70 | { \ 71 | BSplineRenderer::Logger::Log(LEVEL, std::format(FORMAT, __VA_ARGS__)); \ 72 | } \ 73 | } while (false) 74 | 75 | #define LOG_TRACE(FORMAT, ...) LOG_PRIVATE(BSplineRenderer::LogLevel::TRACE, FORMAT, __VA_ARGS__) 76 | #define LOG_DEBUG(FORMAT, ...) LOG_PRIVATE(BSplineRenderer::LogLevel::DEBUG, FORMAT, __VA_ARGS__) 77 | #define LOG_INFO(FORMAT, ...) LOG_PRIVATE(BSplineRenderer::LogLevel::INFO, FORMAT, __VA_ARGS__) 78 | #define LOG_WARN(FORMAT, ...) LOG_PRIVATE(BSplineRenderer::LogLevel::WARNING, FORMAT, __VA_ARGS__) 79 | #define LOG_FATAL(FORMAT, ...) LOG_PRIVATE(BSplineRenderer::LogLevel::FATAL, FORMAT, __VA_ARGS__) 80 | 81 | #define BR_ASSERT(EXPRESSION) assert(EXPRESSION) 82 | 83 | #define BR_EXIT_FAILURE(FORMAT, ...) \ 84 | do \ 85 | { \ 86 | LOG_FATAL(FORMAT, __VA_ARGS__); \ 87 | std::exit(EXIT_FAILURE); \ 88 | \ 89 | } while (false) -------------------------------------------------------------------------------- /Source/Util/Macros.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Define member 4 | #define DEFINE_MEMBER(TYPE, NAME, ...) \ 5 | protected: \ 6 | TYPE m##NAME{ __VA_ARGS__ }; \ 7 | \ 8 | public: \ 9 | inline const TYPE& Get##NAME(void) const { return m##NAME; } \ 10 | \ 11 | public: \ 12 | inline TYPE& Get##NAME##_NonConst(void) { return m##NAME; } \ 13 | \ 14 | public: \ 15 | inline void Set##NAME(const TYPE& var) { m##NAME = var; } 16 | 17 | // Define member constant 18 | #define DEFINE_MEMBER_CONST(TYPE, NAME, ...) \ 19 | protected: \ 20 | TYPE m##NAME{ __VA_ARGS__ }; \ 21 | \ 22 | public: \ 23 | inline const TYPE& Get##NAME(void) const { return m##NAME; } 24 | 25 | // Define member pointer 26 | #define DEFINE_MEMBER_PTR(TYPE, NAME) \ 27 | protected: \ 28 | TYPE* m##NAME{ nullptr }; \ 29 | \ 30 | public: \ 31 | inline TYPE* Get##NAME(void) const { return m##NAME; } \ 32 | \ 33 | public: \ 34 | inline void Set##NAME(TYPE* var) { m##NAME = var; } 35 | 36 | // Define member pointer constant 37 | #define DEFINE_MEMBER_PTR_CONST(TYPE, NAME) \ 38 | protected: \ 39 | TYPE* m##NAME{ nullptr }; \ 40 | \ 41 | public: \ 42 | inline TYPE* Get##NAME(void) const { return m##NAME; } 43 | 44 | // Define getter 45 | #define DEFINE_GETTER(Type, Name) \ 46 | inline const Type& Get##Name(void) const { return m##Name; } 47 | 48 | // Disable copy 49 | #define DISABLE_COPY(CLASS_NAME) \ 50 | CLASS_NAME(const CLASS_NAME&) = delete; \ 51 | CLASS_NAME& operator=(const CLASS_NAME&) = delete 52 | 53 | #define DEFINE_MESH_TYPE_ID(TYPE_ID) \ 54 | static constexpr int MESH_TYPE_ID { TYPE_ID } 55 | -------------------------------------------------------------------------------- /Source/Util/Util.cpp: -------------------------------------------------------------------------------- 1 | #include "Util.h" 2 | 3 | #include "Util/Logger.h" 4 | 5 | #include 6 | 7 | QByteArray BSplineRenderer::Util::GetBytes(const QString& path) 8 | { 9 | QFile file(path); 10 | 11 | if (file.open(QFile::ReadOnly)) 12 | { 13 | return file.readAll(); 14 | } 15 | else 16 | { 17 | LOG_WARN("Util::GetBytes: '{}' could not be opened", path.toStdString()); 18 | return QByteArray(); 19 | } 20 | } -------------------------------------------------------------------------------- /Source/Util/Util.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace BSplineRenderer 7 | { 8 | class Util 9 | { 10 | public: 11 | Util() = delete; 12 | 13 | static QByteArray GetBytes(const QString& path); 14 | }; 15 | } 16 | --------------------------------------------------------------------------------