├── .gitignore ├── README.md ├── autopointer.t ├── bbox.t ├── colors.t ├── fasthash.h ├── gl.t ├── glutils.t ├── grid.t ├── hash.t ├── hashmap.t ├── image.t ├── inheritance.t ├── interface.t ├── linalg.t ├── linsolve ├── Eigen │ ├── Array │ ├── CMakeLists.txt │ ├── Cholesky │ ├── CholmodSupport │ ├── Core │ ├── Dense │ ├── Eigen │ ├── Eigen2Support │ ├── Eigenvalues │ ├── Geometry │ ├── Householder │ ├── IterativeLinearSolvers │ ├── Jacobi │ ├── LU │ ├── LeastSquares │ ├── MetisSupport │ ├── OrderingMethods │ ├── PaStiXSupport │ ├── PardisoSupport │ ├── QR │ ├── QtAlignedMalloc │ ├── SPQRSupport │ ├── SVD │ ├── Sparse │ ├── SparseCholesky │ ├── SparseCore │ ├── SparseLU │ ├── SparseQR │ ├── StdDeque │ ├── StdList │ ├── StdVector │ ├── SuperLUSupport │ ├── UmfPackSupport │ └── src │ │ ├── CMakeLists.txt │ │ ├── Cholesky │ │ ├── CMakeLists.txt │ │ ├── LDLT.h │ │ ├── LLT.h │ │ └── LLT_MKL.h │ │ ├── CholmodSupport │ │ ├── CMakeLists.txt │ │ └── CholmodSupport.h │ │ ├── Core │ │ ├── Array.h │ │ ├── ArrayBase.h │ │ ├── ArrayWrapper.h │ │ ├── Assign.h │ │ ├── Assign_MKL.h │ │ ├── BandMatrix.h │ │ ├── Block.h │ │ ├── BooleanRedux.h │ │ ├── CMakeLists.txt │ │ ├── CommaInitializer.h │ │ ├── CoreIterators.h │ │ ├── CwiseBinaryOp.h │ │ ├── CwiseNullaryOp.h │ │ ├── CwiseUnaryOp.h │ │ ├── CwiseUnaryView.h │ │ ├── DenseBase.h │ │ ├── DenseCoeffsBase.h │ │ ├── DenseStorage.h │ │ ├── Diagonal.h │ │ ├── DiagonalMatrix.h │ │ ├── DiagonalProduct.h │ │ ├── Dot.h │ │ ├── EigenBase.h │ │ ├── Flagged.h │ │ ├── ForceAlignedAccess.h │ │ ├── Functors.h │ │ ├── Fuzzy.h │ │ ├── GeneralProduct.h │ │ ├── GenericPacketMath.h │ │ ├── GlobalFunctions.h │ │ ├── IO.h │ │ ├── Map.h │ │ ├── MapBase.h │ │ ├── MathFunctions.h │ │ ├── Matrix.h │ │ ├── MatrixBase.h │ │ ├── NestByValue.h │ │ ├── NoAlias.h │ │ ├── NumTraits.h │ │ ├── PermutationMatrix.h │ │ ├── PlainObjectBase.h │ │ ├── ProductBase.h │ │ ├── Random.h │ │ ├── Redux.h │ │ ├── Ref.h │ │ ├── Replicate.h │ │ ├── ReturnByValue.h │ │ ├── Reverse.h │ │ ├── Select.h │ │ ├── SelfAdjointView.h │ │ ├── SelfCwiseBinaryOp.h │ │ ├── SolveTriangular.h │ │ ├── StableNorm.h │ │ ├── Stride.h │ │ ├── Swap.h │ │ ├── Transpose.h │ │ ├── Transpositions.h │ │ ├── TriangularMatrix.h │ │ ├── VectorBlock.h │ │ ├── VectorwiseOp.h │ │ ├── Visitor.h │ │ ├── arch │ │ │ ├── AltiVec │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── Complex.h │ │ │ │ └── PacketMath.h │ │ │ ├── CMakeLists.txt │ │ │ ├── Default │ │ │ │ ├── CMakeLists.txt │ │ │ │ └── Settings.h │ │ │ ├── NEON │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── Complex.h │ │ │ │ └── PacketMath.h │ │ │ └── SSE │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── Complex.h │ │ │ │ ├── MathFunctions.h │ │ │ │ └── PacketMath.h │ │ ├── products │ │ │ ├── CMakeLists.txt │ │ │ ├── CoeffBasedProduct.h │ │ │ ├── GeneralBlockPanelKernel.h │ │ │ ├── GeneralMatrixMatrix.h │ │ │ ├── GeneralMatrixMatrixTriangular.h │ │ │ ├── GeneralMatrixMatrixTriangular_MKL.h │ │ │ ├── GeneralMatrixMatrix_MKL.h │ │ │ ├── GeneralMatrixVector.h │ │ │ ├── GeneralMatrixVector_MKL.h │ │ │ ├── Parallelizer.h │ │ │ ├── SelfadjointMatrixMatrix.h │ │ │ ├── SelfadjointMatrixMatrix_MKL.h │ │ │ ├── SelfadjointMatrixVector.h │ │ │ ├── SelfadjointMatrixVector_MKL.h │ │ │ ├── SelfadjointProduct.h │ │ │ ├── SelfadjointRank2Update.h │ │ │ ├── TriangularMatrixMatrix.h │ │ │ ├── TriangularMatrixMatrix_MKL.h │ │ │ ├── TriangularMatrixVector.h │ │ │ ├── TriangularMatrixVector_MKL.h │ │ │ ├── TriangularSolverMatrix.h │ │ │ ├── TriangularSolverMatrix_MKL.h │ │ │ └── TriangularSolverVector.h │ │ └── util │ │ │ ├── BlasUtil.h │ │ │ ├── CMakeLists.txt │ │ │ ├── Constants.h │ │ │ ├── DisableStupidWarnings.h │ │ │ ├── ForwardDeclarations.h │ │ │ ├── MKL_support.h │ │ │ ├── Macros.h │ │ │ ├── Memory.h │ │ │ ├── Meta.h │ │ │ ├── NonMPL2.h │ │ │ ├── ReenableStupidWarnings.h │ │ │ ├── StaticAssert.h │ │ │ └── XprHelper.h │ │ ├── Eigen2Support │ │ ├── Block.h │ │ ├── CMakeLists.txt │ │ ├── Cwise.h │ │ ├── CwiseOperators.h │ │ ├── Geometry │ │ │ ├── AlignedBox.h │ │ │ ├── All.h │ │ │ ├── AngleAxis.h │ │ │ ├── CMakeLists.txt │ │ │ ├── Hyperplane.h │ │ │ ├── ParametrizedLine.h │ │ │ ├── Quaternion.h │ │ │ ├── Rotation2D.h │ │ │ ├── RotationBase.h │ │ │ ├── Scaling.h │ │ │ ├── Transform.h │ │ │ └── Translation.h │ │ ├── LU.h │ │ ├── Lazy.h │ │ ├── LeastSquares.h │ │ ├── Macros.h │ │ ├── MathFunctions.h │ │ ├── Memory.h │ │ ├── Meta.h │ │ ├── Minor.h │ │ ├── QR.h │ │ ├── SVD.h │ │ ├── TriangularSolver.h │ │ └── VectorBlock.h │ │ ├── Eigenvalues │ │ ├── CMakeLists.txt │ │ ├── ComplexEigenSolver.h │ │ ├── ComplexSchur.h │ │ ├── ComplexSchur_MKL.h │ │ ├── EigenSolver.h │ │ ├── GeneralizedEigenSolver.h │ │ ├── GeneralizedSelfAdjointEigenSolver.h │ │ ├── HessenbergDecomposition.h │ │ ├── MatrixBaseEigenvalues.h │ │ ├── RealQZ.h │ │ ├── RealSchur.h │ │ ├── RealSchur_MKL.h │ │ ├── SelfAdjointEigenSolver.h │ │ ├── SelfAdjointEigenSolver_MKL.h │ │ └── Tridiagonalization.h │ │ ├── Geometry │ │ ├── AlignedBox.h │ │ ├── AngleAxis.h │ │ ├── CMakeLists.txt │ │ ├── EulerAngles.h │ │ ├── Homogeneous.h │ │ ├── Hyperplane.h │ │ ├── OrthoMethods.h │ │ ├── ParametrizedLine.h │ │ ├── Quaternion.h │ │ ├── Rotation2D.h │ │ ├── RotationBase.h │ │ ├── Scaling.h │ │ ├── Transform.h │ │ ├── Translation.h │ │ ├── Umeyama.h │ │ └── arch │ │ │ ├── CMakeLists.txt │ │ │ └── Geometry_SSE.h │ │ ├── Householder │ │ ├── BlockHouseholder.h │ │ ├── CMakeLists.txt │ │ ├── Householder.h │ │ └── HouseholderSequence.h │ │ ├── IterativeLinearSolvers │ │ ├── BasicPreconditioners.h │ │ ├── BiCGSTAB.h │ │ ├── CMakeLists.txt │ │ ├── ConjugateGradient.h │ │ ├── IncompleteLUT.h │ │ └── IterativeSolverBase.h │ │ ├── Jacobi │ │ ├── CMakeLists.txt │ │ └── Jacobi.h │ │ ├── LU │ │ ├── CMakeLists.txt │ │ ├── Determinant.h │ │ ├── FullPivLU.h │ │ ├── Inverse.h │ │ ├── PartialPivLU.h │ │ ├── PartialPivLU_MKL.h │ │ └── arch │ │ │ ├── CMakeLists.txt │ │ │ └── Inverse_SSE.h │ │ ├── MetisSupport │ │ ├── CMakeLists.txt │ │ └── MetisSupport.h │ │ ├── OrderingMethods │ │ ├── Amd.h │ │ ├── CMakeLists.txt │ │ ├── Eigen_Colamd.h │ │ └── Ordering.h │ │ ├── PaStiXSupport │ │ ├── CMakeLists.txt │ │ └── PaStiXSupport.h │ │ ├── PardisoSupport │ │ ├── CMakeLists.txt │ │ └── PardisoSupport.h │ │ ├── QR │ │ ├── CMakeLists.txt │ │ ├── ColPivHouseholderQR.h │ │ ├── ColPivHouseholderQR_MKL.h │ │ ├── FullPivHouseholderQR.h │ │ ├── HouseholderQR.h │ │ └── HouseholderQR_MKL.h │ │ ├── SPQRSupport │ │ ├── CMakeLists.txt │ │ └── SuiteSparseQRSupport.h │ │ ├── SVD │ │ ├── CMakeLists.txt │ │ ├── JacobiSVD.h │ │ ├── JacobiSVD_MKL.h │ │ └── UpperBidiagonalization.h │ │ ├── SparseCholesky │ │ ├── CMakeLists.txt │ │ ├── SimplicialCholesky.h │ │ └── SimplicialCholesky_impl.h │ │ ├── SparseCore │ │ ├── AmbiVector.h │ │ ├── CMakeLists.txt │ │ ├── CompressedStorage.h │ │ ├── ConservativeSparseSparseProduct.h │ │ ├── MappedSparseMatrix.h │ │ ├── SparseBlock.h │ │ ├── SparseColEtree.h │ │ ├── SparseCwiseBinaryOp.h │ │ ├── SparseCwiseUnaryOp.h │ │ ├── SparseDenseProduct.h │ │ ├── SparseDiagonalProduct.h │ │ ├── SparseDot.h │ │ ├── SparseFuzzy.h │ │ ├── SparseMatrix.h │ │ ├── SparseMatrixBase.h │ │ ├── SparsePermutation.h │ │ ├── SparseProduct.h │ │ ├── SparseRedux.h │ │ ├── SparseSelfAdjointView.h │ │ ├── SparseSparseProductWithPruning.h │ │ ├── SparseTranspose.h │ │ ├── SparseTriangularView.h │ │ ├── SparseUtil.h │ │ ├── SparseVector.h │ │ ├── SparseView.h │ │ └── TriangularSolver.h │ │ ├── SparseLU │ │ ├── CMakeLists.txt │ │ ├── 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 │ │ ├── CMakeLists.txt │ │ └── SparseQR.h │ │ ├── StlSupport │ │ ├── CMakeLists.txt │ │ ├── StdDeque.h │ │ ├── StdList.h │ │ ├── StdVector.h │ │ └── details.h │ │ ├── SuperLUSupport │ │ ├── CMakeLists.txt │ │ └── SuperLUSupport.h │ │ ├── UmfPackSupport │ │ ├── CMakeLists.txt │ │ └── UmfPackSupport.h │ │ ├── misc │ │ ├── CMakeLists.txt │ │ ├── Image.h │ │ ├── Kernel.h │ │ ├── Solve.h │ │ ├── SparseSolve.h │ │ └── blas.h │ │ └── plugins │ │ ├── ArrayCwiseBinaryOps.h │ │ ├── ArrayCwiseUnaryOps.h │ │ ├── BlockMethods.h │ │ ├── CMakeLists.txt │ │ ├── CommonCwiseBinaryOps.h │ │ ├── CommonCwiseUnaryOps.h │ │ ├── MatrixCwiseBinaryOps.h │ │ └── MatrixCwiseUnaryOps.h ├── Makefile ├── exports.cpp ├── exports.h └── init.t ├── lpsolve ├── init.t ├── liblpsolve55.dylib ├── lp_Hash.h ├── lp_SOS.h ├── lp_lib.h ├── lp_matrix.h ├── lp_mipbb.h ├── lp_types.h └── lp_utils.h ├── mem.t ├── newton.t ├── templatize.t ├── test.t ├── util.t ├── vector.t └── vtemplate.t /.gitignore: -------------------------------------------------------------------------------- 1 | *.jpeg 2 | *.o 3 | *.so 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | terra-utils 2 | =========== 3 | 4 | Generally applicable Terra utilities. 5 | -------------------------------------------------------------------------------- /autopointer.t: -------------------------------------------------------------------------------- 1 | 2 | local util = require("util") 3 | local m = require("mem") 4 | local templatize = require("templatize") 5 | 6 | local C = terralib.includecstring [[ 7 | #include "stdio.h" 8 | ]] 9 | 10 | -- Pretty much just like stl::auto_ptr 11 | 12 | local struct RefCount 13 | { 14 | count: uint 15 | } 16 | 17 | terra RefCount:__construct() 18 | self.count = 1 19 | end 20 | 21 | terra RefCount:retain() 22 | self.count = self.count + 1 23 | end 24 | 25 | terra RefCount:release() 26 | util.assert(self.count > 0, 27 | "Cannot release on a RefCount with zero references\n") 28 | self.count = self.count - 1 29 | end 30 | 31 | terra RefCount:empty() 32 | return self.count == 0 33 | end 34 | 35 | m.addConstructors(RefCount) 36 | 37 | 38 | local AutoPtr = templatize(function(T) 39 | local struct AutoPtrT 40 | { 41 | ptr: &T, 42 | refCount: &RefCount 43 | } 44 | 45 | AutoPtrT.metamethods.__typename = function(self) 46 | return string.format("AutoPtr(%s)", tostring(T)) 47 | end 48 | 49 | terra AutoPtrT:__construct() 50 | self.ptr = nil 51 | self.refCount = nil 52 | end 53 | 54 | terra AutoPtrT:__construct(ptr: &T) 55 | self.ptr = ptr 56 | self.refCount = RefCount.heapAlloc() 57 | end 58 | 59 | terra AutoPtrT:__copy(other: &AutoPtrT) 60 | self.ptr = other.ptr 61 | self.refCount = other.refCount 62 | self.refCount:retain() 63 | end 64 | 65 | terra AutoPtrT:__destruct() 66 | if self.ptr ~= nil and self.refCount ~= nil then 67 | self.refCount:release() 68 | if self.refCount:empty() then 69 | -- C.printf("deleting %p\n", self.ptr) 70 | m.delete(self.refCount) 71 | m.delete(self.ptr) 72 | end 73 | end 74 | end 75 | 76 | AutoPtrT.metamethods.__entrymissing = macro(function(fieldname, self) 77 | return `self.ptr.[fieldname] 78 | end) 79 | 80 | -- I use this more complicated behavior, rather than just using __methodmissing, 81 | -- because I want AutoPtrT:getmethod to still return nil exactly when T:getmethod 82 | -- would return nil. 83 | AutoPtrT.metamethods.__getmethod = function(self, methodname) 84 | -- IMPORTANT: We shouldn't forward the __initvtable method of the wrapped type 85 | -- (There may need to be more exceptions like this...) 86 | if methodname == "__initvtable" then return nil end 87 | -- If AutoPtrT has the method (i.e. is it __construct, __destruct, __copy), 88 | -- then just return that 89 | local mymethod = self.methods[methodname] 90 | if mymethod then return mymethod end 91 | -- Otherwise, if T has it, then return a macro that will invoke T's 92 | -- method on the .ptr member 93 | local tmethod = T:getmethod(methodname) 94 | if tmethod then 95 | return macro(function(self, ...) 96 | local args = {...} 97 | return `[tmethod](self.ptr, [args]) 98 | end) 99 | end 100 | -- Otherwise, return nil 101 | return nil 102 | end 103 | 104 | m.addConstructors(AutoPtrT) 105 | return AutoPtrT 106 | end) 107 | 108 | -- Convience macro to create a new auto pointer without explicitly specifying the type 109 | -- It'll figure out the type from the type of the argument 110 | AutoPtr.wrap = macro(function(ptr) 111 | local pT = ptr:gettype() 112 | util.luaAssertWithTrace(pT:ispointertostruct(), 113 | "Can only create an auto pointer from a pointer to a struct.") 114 | local T = pT.type 115 | return `[AutoPtr(T)].stackAlloc(ptr) 116 | end) 117 | 118 | 119 | ------- TESTS 120 | 121 | -- local struct Foo { x: int } 122 | -- terra Foo:__construct() end 123 | -- terra Foo:setX(x: int) self.x = x end 124 | -- m.addConstructors(Foo) 125 | 126 | -- local terra test() 127 | -- var f = Foo.heapAlloc() 128 | -- var af = [AutoPtr(Foo)].stackAlloc(f) 129 | -- af:setX(42) 130 | -- var x = af.x 131 | -- var af2 = m.copy(af) 132 | -- m.destruct(af) 133 | -- m.destruct(af2) 134 | -- return x 135 | -- end 136 | -- test:compile() 137 | -- print(test()) 138 | 139 | ------- 140 | 141 | 142 | return AutoPtr 143 | 144 | 145 | 146 | 147 | 148 | 149 | -------------------------------------------------------------------------------- /bbox.t: -------------------------------------------------------------------------------- 1 | local m = require("mem") 2 | local templatize = require("templatize") 3 | 4 | 5 | local BBox = templatize(function(VecT) 6 | 7 | local real = VecT.RealType 8 | 9 | local struct BBoxT { mins: VecT, maxs: VecT } 10 | 11 | terra BBoxT:__construct(mins: VecT, maxs: VecT) : {} 12 | self.mins = m.copy(mins) 13 | self.maxs = m.copy(maxs) 14 | end 15 | 16 | terra BBoxT:__construct() : {} 17 | self:__construct(VecT.stackAlloc([math.huge]), VecT.stackAlloc([-math.huge])) 18 | end 19 | 20 | terra BBoxT:expand(point: VecT) 21 | self.mins:minInPlace(point) 22 | self.maxs:maxInPlace(point) 23 | end 24 | 25 | terra BBoxT:expand(amount: real) 26 | [VecT.foreach(`self.mins, function(x) return quote [x] = [x] - amount end end)] 27 | [VecT.foreach(`self.maxs, function(x) return quote [x] = [x] + amount end end)] 28 | end 29 | 30 | terra BBoxT:contains(point: VecT) 31 | return point > self.mins and point < self.maxs 32 | end 33 | 34 | terra BBoxT:unionWith(other: &BBoxT) 35 | self.mins:minInPlace(other.mins) 36 | self.maxs:maxInPlace(other.maxs) 37 | end 38 | 39 | terra BBoxT:intersectWith(other: &BBoxT) 40 | self.mins:maxInPlace(other.mins) 41 | self.maxs:minInPlace(other.maxs) 42 | end 43 | 44 | terra BBoxT:extents() 45 | return self.maxs - self.mins 46 | end 47 | 48 | m.addConstructors(BBoxT) 49 | return BBoxT 50 | 51 | end) 52 | 53 | 54 | return BBox 55 | -------------------------------------------------------------------------------- /colors.t: -------------------------------------------------------------------------------- 1 | 2 | -- I got tired of repeatedly hard-coding color values, so I made this 3 | 4 | -- dequantize 5 | local function dq(x) return x/255.0 end 6 | local function dqv(v) 7 | local t = {} 8 | for _,x in ipairs(v) do 9 | table.insert(t, dq(x)) 10 | end 11 | return t 12 | end 13 | 14 | local Tableau10 = 15 | { 16 | Blue = dqv({31, 119, 180}), 17 | Orange = dqv({255, 127, 14}), 18 | Green = dqv({44, 160, 44}), 19 | Red = dqv({214, 39, 40}), 20 | Purple = dqv({148, 103, 189}), 21 | Brown = dqv({140, 86, 75}), 22 | Pink = dqv({227, 119, 194}), 23 | Gray = dqv({127, 127, 127}), 24 | Yellow = dqv({188, 189, 34}), 25 | Teal = dqv({23, 190, 207}) 26 | } 27 | 28 | 29 | -- Add more palettes? 30 | 31 | 32 | return 33 | { 34 | Black = dqv({0, 0, 0}), 35 | White = dqv({255, 255, 255}), 36 | Tableau10 = Tableau10 37 | } 38 | -------------------------------------------------------------------------------- /fasthash.h: -------------------------------------------------------------------------------- 1 | // The following hash function adapted from: 2 | // http://www.azillionmonkeys.com/qed/hash.html 3 | 4 | #include "stdint.h" 5 | #include "stddef.h" 6 | #undef get16bits 7 | #if (defined(__GNUC__) && defined(__i386__)) || defined(__WATCOMC__) \ 8 | || defined(_MSC_VER) || defined (__BORLANDC__) || defined (__TURBOC__) 9 | #define get16bits(d) (*((const uint16_t *) (d))) 10 | #endif 11 | 12 | #if !defined (get16bits) 13 | #define get16bits(d) ((((uint32_t)(((const uint8_t *)(d))[1])) << 8)\ 14 | +(uint32_t)(((const uint8_t *)(d))[0]) ) 15 | #endif 16 | 17 | uint32_t SuperFastHash (const char * data, int len) { 18 | uint32_t hash = len, tmp; 19 | int rem; 20 | 21 | if (len <= 0 || data == NULL) return 0; 22 | 23 | rem = len & 3; 24 | len >>= 2; 25 | 26 | /* Main loop */ 27 | for (;len > 0; len--) { 28 | hash += get16bits (data); 29 | tmp = (get16bits (data+2) << 11) ^ hash; 30 | hash = (hash << 16) ^ tmp; 31 | data += 2*sizeof (uint16_t); 32 | hash += hash >> 11; 33 | } 34 | 35 | /* Handle end cases */ 36 | switch (rem) { 37 | case 3: hash += get16bits (data); 38 | hash ^= hash << 16; 39 | hash ^= ((signed char)data[sizeof (uint16_t)]) << 18; 40 | hash += hash >> 11; 41 | break; 42 | case 2: hash += get16bits (data); 43 | hash ^= hash << 11; 44 | hash += hash >> 17; 45 | break; 46 | case 1: hash += (signed char)*data; 47 | hash ^= hash << 10; 48 | hash += hash >> 1; 49 | } 50 | 51 | /* Force "avalanching" of final 127 bits */ 52 | hash ^= hash << 3; 53 | hash += hash >> 5; 54 | hash ^= hash << 4; 55 | hash += hash >> 17; 56 | hash ^= hash << 25; 57 | hash += hash >> 6; 58 | 59 | return hash; 60 | } -------------------------------------------------------------------------------- /gl.t: -------------------------------------------------------------------------------- 1 | local util = require("util") 2 | 3 | -- Mac OSX only, for now 4 | if not (util.osName() == "Darwin\n") then 5 | error("GLUT/OpenGL module currently only supported on OSX.") 6 | end 7 | 8 | -- Automatically generate functions that return commonly-used macro constants 9 | -- that are otherwise not accessible from Terra. 10 | local function genConstantAccessorDef(constantName, constantType) 11 | return string.format("inline %s m%s() { return %s; }\n", constantType, constantName, constantName) 12 | end 13 | local function genAllConstantAccessorDefs(constants) 14 | local code = "" 15 | for name,typ in pairs(constants) do 16 | code = code .. genConstantAccessorDef(name, typ) 17 | end 18 | return code 19 | end 20 | 21 | -- Constants to be exposed 22 | local constTable = {} 23 | local function addConstants(constants) 24 | for _,c in ipairs(constants) do 25 | -- default type of a constant is int 26 | if type(c) == "string" then 27 | constTable[c] = "int" 28 | elseif type(c) == "table" then 29 | constTable[c[1]] = c[2] 30 | else 31 | error("gl.addConstants: entries must be either names or {name, type} tables") 32 | end 33 | end 34 | end 35 | addConstants({ 36 | "GL_PROJECTION", 37 | "GL_MODELVIEW", 38 | "GL_COLOR_BUFFER_BIT", 39 | "GL_DEPTH_BUFFER_BIT", 40 | "GL_DEPTH_TEST", 41 | "GL_POINTS", 42 | "GL_LINES", 43 | "GL_LINE_LOOP", 44 | "GL_QUADS", 45 | "GL_QUAD_STRIP", 46 | "GL_POLYGON", 47 | "GL_TRIANGLES", 48 | "GL_TRIANGLE_STRIP", 49 | "GL_RGB", 50 | "GL_BGR", 51 | "GL_RGBA", 52 | "GL_UNSIGNED_BYTE", 53 | "GLUT_RGB", 54 | "GLUT_RGBA", 55 | "GLUT_SINGLE", 56 | "GLUT_DOUBLE", 57 | "GLUT_DEPTH", 58 | "GL_FILL", 59 | "GL_LINE", 60 | "GL_FRONT", 61 | "GL_BACK", 62 | "GL_FRONT_AND_BACK", 63 | "GL_LIGHTING", 64 | "GL_LIGHT0", 65 | "GL_LIGHT1", 66 | "GL_LIGHT2", 67 | "GL_LIGHT3", 68 | "GL_LIGHT4", 69 | "GL_LIGHT5", 70 | "GL_LIGHT6", 71 | "GL_LIGHT7", 72 | "GL_MAX_LIGHTS", 73 | "GL_AMBIENT", 74 | "GL_DIFFUSE", 75 | "GL_SPECULAR", 76 | "GL_POSITION", 77 | "GL_SHININESS", 78 | "GL_FLAT", 79 | "GL_SMOOTH", 80 | "GL_NORMALIZE", 81 | "GL_CULL_FACE" 82 | }) 83 | 84 | local function loadHeaders() 85 | -- Get GLUT header, adding functions for constants 86 | return util.includecstring_path(string.format([[ 87 | #include 88 | %s 89 | ]], genAllConstantAccessorDefs(constTable))) 90 | end 91 | 92 | -- Initialize the module with the default set of constants exposed 93 | local gl = loadHeaders() 94 | 95 | -- Link dynamic libraries 96 | terralib.linklibrary("/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib") 97 | terralib.linklibrary("/System/Library/Frameworks/OpenGL.framework/Libraries/libGLU.dylib") 98 | terralib.linklibrary("/System/Library/Frameworks/GLUT.framework/GLUT") 99 | 100 | -- If you need access to additional macro constants, use this function. 101 | -- It will reload the GLUT/OpenGL headers and add accessor functions for 102 | -- the requested constants. 103 | -- This is cumulative; it will provide access to all constants requested 104 | -- up to this call as well. 105 | function gl.exposeConstants(constants) 106 | addConstants(constants) 107 | local h = loadHeaders() 108 | for k,v in pairs(h) do gl[k] = v end 109 | end 110 | 111 | return gl 112 | 113 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /grid.t: -------------------------------------------------------------------------------- 1 | local m = require("mem") 2 | local templatize = require("templatize") 3 | local util = require("util") 4 | local Vector = require("vector") 5 | 6 | local C = terralib.includecstring [[ 7 | #include 8 | ]] 9 | 10 | -- A simple 2D grid of values, like a matrix, but without 11 | -- any linear algebra operations defined. 12 | -- Useful as an interchange format for e.g. Eigen 13 | local Grid2D 14 | Grid2D = templatize(function(valueType) 15 | 16 | local struct GridT 17 | { 18 | rows: int, 19 | cols: int, 20 | data: &valueType 21 | } 22 | GridT.metamethods.__typename = function(self) 23 | return string.format("Grid2D(%s)", tostring(valueType)) 24 | end 25 | 26 | GridT.metamethods.__apply = macro(function(self, i, j) 27 | return `self.data[i*self.cols + j] 28 | end) 29 | 30 | terra GridT:__construct() : {} 31 | self.rows = 0 32 | self.cols = 0 33 | self.data = nil 34 | end 35 | 36 | terra GridT:__construct(r: int, c: int) : {} 37 | self:__construct() 38 | self.rows = r 39 | self.cols = c 40 | if r*c > 0 then 41 | self.data = [&valueType](C.malloc(r*c*sizeof(valueType))) 42 | for i=0,r do 43 | for j=0,c do 44 | m.init(self(i,j)) 45 | end 46 | end 47 | end 48 | end 49 | 50 | terra GridT:__construct(r: int, c: int, fillVal: valueType) : {} 51 | self:__construct(r, c) 52 | for i=0,r do 53 | for j=0,c do 54 | self(i,j) = m.copy(fillVal) 55 | end 56 | end 57 | end 58 | 59 | terra GridT:__copy(other: &GridT) 60 | self.rows = other.rows 61 | self.cols = other.cols 62 | self.data = [&valueType](C.malloc(self.rows*self.cols*sizeof(valueType))) 63 | for i=0,self.rows do 64 | for j=0,self.cols do 65 | self(i,j) = m.copy(other(i,j)) 66 | end 67 | end 68 | end 69 | 70 | GridT.__templatecopy = templatize(function(valueType2) 71 | return terra(self: &GridT, other: &Grid2D(valueType2)) 72 | self.rows = other.rows 73 | self.cols = other.cols 74 | self.data = [&valueType](C.malloc(self.rows*self.cols*sizeof(valueType))) 75 | for i=0,self.rows do 76 | for j=0,self.cols do 77 | self(i,j) = [m.templatecopy(valueType)](other(i,j)) 78 | end 79 | end 80 | end 81 | end) 82 | 83 | terra GridT:__destruct() 84 | if self.data ~= nil then 85 | for i=0,self.rows do 86 | for j=0,self.cols do 87 | m.destruct(self(i,j)) 88 | end 89 | end 90 | C.free(self.data) 91 | end 92 | end 93 | 94 | -- Completely wipes all the stored data 95 | terra GridT:resize(r: int, c: int) 96 | if r ~= self.rows or c ~= self.cols then 97 | self:__destruct() 98 | self:__construct(r, c) 99 | end 100 | end 101 | 102 | terra GridT:mult(invec: &Vector(valueType), outvec: &Vector(valueType)) 103 | outvec:resize(self.rows) 104 | for i=0,self.rows do 105 | var sum = valueType(0.0) 106 | for j=0,self.cols do 107 | sum = sum + self(i,j)*invec(j) 108 | end 109 | outvec(i) = sum 110 | end 111 | end 112 | 113 | terra GridT:transposeMult(invec: &Vector(valueType), outvec: &Vector(valueType)) 114 | outvec:resize(self.cols) 115 | for i=0,self.cols do 116 | var sum = valueType(0.0) 117 | for j=0,self.rows do 118 | sum = sum + self(j,i)*invec(j) 119 | end 120 | outvec(i) = sum 121 | end 122 | end 123 | 124 | m.addConstructors(GridT) 125 | return GridT 126 | 127 | end) 128 | 129 | 130 | return 131 | { 132 | Grid2D = Grid2D 133 | } 134 | 135 | 136 | 137 | 138 | 139 | -------------------------------------------------------------------------------- /hash.t: -------------------------------------------------------------------------------- 1 | local thisfile = debug.getinfo(1, "S").source:gsub("@", "") 2 | 3 | local util = require("util") 4 | local fasthash = util.includec_path(thisfile:gsub("hash.t", "fasthash.h")).SuperFastHash 5 | local templatize = require("templatize") 6 | 7 | local C = terralib.includecstring [[ 8 | #include 9 | ]] 10 | 11 | -- We can provide a 'default' hash for aggregates that can be 12 | -- easily adopted but is not present unless explicity asked for. 13 | local function getDefaultHash(typ) 14 | local fn = terra(val: typ) 15 | return fasthash([&int8](&val), sizeof(typ)) 16 | end 17 | util.inline(fn) 18 | return fn 19 | end 20 | 21 | local hash = templatize(function(T) 22 | return getDefaultHash(T) 23 | end) 24 | 25 | hash.rawhash = fasthash 26 | 27 | function hash.gethashfn(typ) 28 | if typ:isprimitive() or typ:ispointer() then 29 | return hash(typ) 30 | elseif typ:isstruct() and typ:getmethod("__hash") then 31 | return macro(function(val) return `val:__hash() end) 32 | else 33 | error(string.format("No __hash method for aggregate type '%s'", tostring(K))) 34 | end 35 | end 36 | 37 | -- Simple wrapper around rawstring that allows for hashing 38 | local struct HashableString { str: rawstring } 39 | terra HashableString:__hash() 40 | return fasthash(self.str, C.strlen(self.str)) 41 | end 42 | HashableString.metamethods.__eq = terra(hs1: HashableString, hs2: HashableString) 43 | return C.strcmp(hs1.str, hs2.str) == 0 44 | end 45 | hash.HashableString = HashableString 46 | 47 | return hash 48 | -------------------------------------------------------------------------------- /interface.t: -------------------------------------------------------------------------------- 1 | local m = require("mem") 2 | 3 | -- Taken from terra/tests/lib/golike.t 4 | 5 | local Interface = {} 6 | 7 | Interface.interface = {} 8 | Interface.interface.__index = Interface.interface 9 | Interface.defined = {} 10 | 11 | function Interface.castmethod(from,to,exp) 12 | if to:isstruct() and from:ispointertostruct() then 13 | local self = Interface.defined[to] 14 | if not self then error("not a interface") end 15 | local cst = self:createcast(from.type,exp) 16 | return cst 17 | end 18 | error("invalid cast") 19 | end 20 | function Interface.create(methods) 21 | local self = setmetatable({},Interface.interface) 22 | struct self.type { 23 | data : uint64 24 | } 25 | Interface.defined[self.type] = self 26 | self.type.metamethods.__cast = Interface.castmethod 27 | 28 | self.nextid = 0 29 | self.allocatedsize = 256 30 | self.implementedtypes = {} 31 | 32 | self.methods = terralib.newlist() 33 | self.vtabletype = terralib.types.newstruct("vtable") 34 | for k,v in pairs(methods) do 35 | -- print(k," = ",v) 36 | assert(v:ispointer() and v.type:isfunction()) 37 | local params,rets = terralib.newlist{&uint8}, v.type.returns 38 | local syms = terralib.newlist() 39 | for i,p in ipairs(v.type.parameters) do 40 | params:insert(p) 41 | syms:insert(symbol(p)) 42 | end 43 | local typ = params -> rets 44 | self.methods:insert({name = k, type = typ, syms = syms}) 45 | self.vtabletype.entries:insert { field = k, type = &uint8 } 46 | end 47 | self.vtables = global(&self.vtabletype) 48 | self.vtablearray = terralib.new(self.vtabletype[self.allocatedsize]) 49 | self.vtables:set(self.vtablearray) 50 | 51 | for _,m in ipairs(self.methods) do 52 | self.type.methods[m.name] = terra(interface : &self.type, [m.syms]) 53 | var id = interface.data >> 48 54 | var mask = (1ULL << 48) - 1 55 | var obj = [&uint8](mask and interface.data) 56 | return m.type(self.vtables[id].[m.name])(obj,[m.syms]) 57 | end 58 | end 59 | 60 | return self.type 61 | end 62 | 63 | function Interface.interface:createcast(from,exp) 64 | if not self.implementedtypes[from] then 65 | local instance = {} 66 | instance.id = self.nextid 67 | assert(instance.id < self.allocatedsize) --TODO: handle resize 68 | local vtableentry = self.vtablearray[self.nextid] 69 | self.nextid = self.nextid + 1 70 | for _,m in ipairs(self.methods) do 71 | local fn = from.methods[m.name] 72 | assert(fn and terralib.isfunction(fn)) 73 | fn:compile(function(fndef) 74 | vtableentry[m.name] = terralib.cast(&uint8,fndef:getpointer()) 75 | end) 76 | end 77 | self.implementedtypes[from] = instance 78 | end 79 | 80 | local id = self.implementedtypes[from].id 81 | return `self.type { uint64(exp) or (uint64(id) << 48) } 82 | end 83 | 84 | return Interface 85 | -------------------------------------------------------------------------------- /linsolve/Eigen/Array: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_ARRAY_MODULE_H 2 | #define EIGEN_ARRAY_MODULE_H 3 | 4 | // include Core first to handle Eigen2 support macros 5 | #include "Core" 6 | 7 | #ifndef EIGEN2_SUPPORT 8 | #error The Eigen/Array header does no longer exist in Eigen3. All that functionality has moved to Eigen/Core. 9 | #endif 10 | 11 | #endif // EIGEN_ARRAY_MODULE_H 12 | -------------------------------------------------------------------------------- /linsolve/Eigen/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include(RegexUtils) 2 | test_escape_string_as_regex() 3 | 4 | file(GLOB Eigen_directory_files "*") 5 | 6 | escape_string_as_regex(ESCAPED_CMAKE_CURRENT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") 7 | 8 | foreach(f ${Eigen_directory_files}) 9 | if(NOT f MATCHES "\\.txt" AND NOT f MATCHES "${ESCAPED_CMAKE_CURRENT_SOURCE_DIR}/[.].+" AND NOT f MATCHES "${ESCAPED_CMAKE_CURRENT_SOURCE_DIR}/src") 10 | list(APPEND Eigen_directory_files_to_install ${f}) 11 | endif() 12 | endforeach(f ${Eigen_directory_files}) 13 | 14 | install(FILES 15 | ${Eigen_directory_files_to_install} 16 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen COMPONENT Devel 17 | ) 18 | 19 | add_subdirectory(src) 20 | -------------------------------------------------------------------------------- /linsolve/Eigen/Cholesky: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_CHOLESKY_MODULE_H 2 | #define EIGEN_CHOLESKY_MODULE_H 3 | 4 | #include "Core" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | /** \defgroup Cholesky_Module Cholesky module 9 | * 10 | * 11 | * 12 | * This module provides two variants of the Cholesky decomposition for selfadjoint (hermitian) matrices. 13 | * Those decompositions are accessible via the following MatrixBase methods: 14 | * - MatrixBase::llt(), 15 | * - MatrixBase::ldlt() 16 | * 17 | * \code 18 | * #include 19 | * \endcode 20 | */ 21 | 22 | #include "src/misc/Solve.h" 23 | #include "src/Cholesky/LLT.h" 24 | #include "src/Cholesky/LDLT.h" 25 | #ifdef EIGEN_USE_LAPACKE 26 | #include "src/Cholesky/LLT_MKL.h" 27 | #endif 28 | 29 | #include "src/Core/util/ReenableStupidWarnings.h" 30 | 31 | #endif // EIGEN_CHOLESKY_MODULE_H 32 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 33 | -------------------------------------------------------------------------------- /linsolve/Eigen/CholmodSupport: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_CHOLMODSUPPORT_MODULE_H 2 | #define EIGEN_CHOLMODSUPPORT_MODULE_H 3 | 4 | #include "SparseCore" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | extern "C" { 9 | #include 10 | } 11 | 12 | /** \ingroup Support_modules 13 | * \defgroup CholmodSupport_Module CholmodSupport module 14 | * 15 | * This module provides an interface to the Cholmod library which is part of the suitesparse package. 16 | * It provides the two following main factorization classes: 17 | * - class CholmodSupernodalLLT: a supernodal LLT Cholesky factorization. 18 | * - class CholmodDecomposiiton: a general L(D)LT Cholesky factorization with automatic or explicit runtime selection of the underlying factorization method (supernodal or simplicial). 19 | * 20 | * For the sake of completeness, this module also propose the two following classes: 21 | * - class CholmodSimplicialLLT 22 | * - class CholmodSimplicialLDLT 23 | * Note that these classes does not bring any particular advantage compared to the built-in 24 | * SimplicialLLT and SimplicialLDLT factorization classes. 25 | * 26 | * \code 27 | * #include 28 | * \endcode 29 | * 30 | * In order to use this module, the cholmod headers must be accessible from the include paths, and your binary must be linked to the cholmod library and its dependencies. 31 | * The dependencies depend on how cholmod has been compiled. 32 | * For a cmake based project, you can use our FindCholmod.cmake module to help you in this task. 33 | * 34 | */ 35 | 36 | #include "src/misc/Solve.h" 37 | #include "src/misc/SparseSolve.h" 38 | 39 | #include "src/CholmodSupport/CholmodSupport.h" 40 | 41 | 42 | #include "src/Core/util/ReenableStupidWarnings.h" 43 | 44 | #endif // EIGEN_CHOLMODSUPPORT_MODULE_H 45 | 46 | -------------------------------------------------------------------------------- /linsolve/Eigen/Dense: -------------------------------------------------------------------------------- 1 | #include "Core" 2 | #include "LU" 3 | #include "Cholesky" 4 | #include "QR" 5 | #include "SVD" 6 | #include "Geometry" 7 | #include "Eigenvalues" 8 | -------------------------------------------------------------------------------- /linsolve/Eigen/Eigen: -------------------------------------------------------------------------------- 1 | #include "Dense" 2 | //#include "Sparse" 3 | -------------------------------------------------------------------------------- /linsolve/Eigen/Eigen2Support: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN2SUPPORT_H 11 | #define EIGEN2SUPPORT_H 12 | 13 | #if (!defined(EIGEN2_SUPPORT)) || (!defined(EIGEN_CORE_H)) 14 | #error Eigen2 support must be enabled by defining EIGEN2_SUPPORT before including any Eigen header 15 | #endif 16 | 17 | #include "src/Core/util/DisableStupidWarnings.h" 18 | 19 | /** \ingroup Support_modules 20 | * \defgroup Eigen2Support_Module Eigen2 support module 21 | * This module provides a couple of deprecated functions improving the compatibility with Eigen2. 22 | * 23 | * To use it, define EIGEN2_SUPPORT before including any Eigen header 24 | * \code 25 | * #define EIGEN2_SUPPORT 26 | * \endcode 27 | * 28 | */ 29 | 30 | #include "src/Eigen2Support/Macros.h" 31 | #include "src/Eigen2Support/Memory.h" 32 | #include "src/Eigen2Support/Meta.h" 33 | #include "src/Eigen2Support/Lazy.h" 34 | #include "src/Eigen2Support/Cwise.h" 35 | #include "src/Eigen2Support/CwiseOperators.h" 36 | #include "src/Eigen2Support/TriangularSolver.h" 37 | #include "src/Eigen2Support/Block.h" 38 | #include "src/Eigen2Support/VectorBlock.h" 39 | #include "src/Eigen2Support/Minor.h" 40 | #include "src/Eigen2Support/MathFunctions.h" 41 | 42 | 43 | #include "src/Core/util/ReenableStupidWarnings.h" 44 | 45 | // Eigen2 used to include iostream 46 | #include 47 | 48 | #define EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, SizeSuffix) \ 49 | using Eigen::Matrix##SizeSuffix##TypeSuffix; \ 50 | using Eigen::Vector##SizeSuffix##TypeSuffix; \ 51 | using Eigen::RowVector##SizeSuffix##TypeSuffix; 52 | 53 | #define EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(TypeSuffix) \ 54 | EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 2) \ 55 | EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 3) \ 56 | EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 4) \ 57 | EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, X) \ 58 | 59 | #define EIGEN_USING_MATRIX_TYPEDEFS \ 60 | EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(i) \ 61 | EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(f) \ 62 | EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(d) \ 63 | EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(cf) \ 64 | EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(cd) 65 | 66 | #define USING_PART_OF_NAMESPACE_EIGEN \ 67 | EIGEN_USING_MATRIX_TYPEDEFS \ 68 | using Eigen::Matrix; \ 69 | using Eigen::MatrixBase; \ 70 | using Eigen::ei_random; \ 71 | using Eigen::ei_real; \ 72 | using Eigen::ei_imag; \ 73 | using Eigen::ei_conj; \ 74 | using Eigen::ei_abs; \ 75 | using Eigen::ei_abs2; \ 76 | using Eigen::ei_sqrt; \ 77 | using Eigen::ei_exp; \ 78 | using Eigen::ei_log; \ 79 | using Eigen::ei_sin; \ 80 | using Eigen::ei_cos; 81 | 82 | #endif // EIGEN2SUPPORT_H 83 | -------------------------------------------------------------------------------- /linsolve/Eigen/Eigenvalues: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_EIGENVALUES_MODULE_H 2 | #define EIGEN_EIGENVALUES_MODULE_H 3 | 4 | #include "Core" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | #include "Cholesky" 9 | #include "Jacobi" 10 | #include "Householder" 11 | #include "LU" 12 | #include "Geometry" 13 | 14 | /** \defgroup Eigenvalues_Module Eigenvalues module 15 | * 16 | * 17 | * 18 | * This module mainly provides various eigenvalue solvers. 19 | * This module also provides some MatrixBase methods, including: 20 | * - MatrixBase::eigenvalues(), 21 | * - MatrixBase::operatorNorm() 22 | * 23 | * \code 24 | * #include 25 | * \endcode 26 | */ 27 | 28 | #include "src/Eigenvalues/Tridiagonalization.h" 29 | #include "src/Eigenvalues/RealSchur.h" 30 | #include "src/Eigenvalues/EigenSolver.h" 31 | #include "src/Eigenvalues/SelfAdjointEigenSolver.h" 32 | #include "src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h" 33 | #include "src/Eigenvalues/HessenbergDecomposition.h" 34 | #include "src/Eigenvalues/ComplexSchur.h" 35 | #include "src/Eigenvalues/ComplexEigenSolver.h" 36 | #include "src/Eigenvalues/RealQZ.h" 37 | #include "src/Eigenvalues/GeneralizedEigenSolver.h" 38 | #include "src/Eigenvalues/MatrixBaseEigenvalues.h" 39 | #ifdef EIGEN_USE_LAPACKE 40 | #include "src/Eigenvalues/RealSchur_MKL.h" 41 | #include "src/Eigenvalues/ComplexSchur_MKL.h" 42 | #include "src/Eigenvalues/SelfAdjointEigenSolver_MKL.h" 43 | #endif 44 | 45 | #include "src/Core/util/ReenableStupidWarnings.h" 46 | 47 | #endif // EIGEN_EIGENVALUES_MODULE_H 48 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 49 | -------------------------------------------------------------------------------- /linsolve/Eigen/Geometry: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_GEOMETRY_MODULE_H 2 | #define EIGEN_GEOMETRY_MODULE_H 3 | 4 | #include "Core" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | #include "SVD" 9 | #include "LU" 10 | #include 11 | 12 | #ifndef M_PI 13 | #define M_PI 3.14159265358979323846 14 | #endif 15 | 16 | /** \defgroup Geometry_Module Geometry module 17 | * 18 | * 19 | * 20 | * This module provides support for: 21 | * - fixed-size homogeneous transformations 22 | * - translation, scaling, 2D and 3D rotations 23 | * - quaternions 24 | * - \ref MatrixBase::cross() "cross product" 25 | * - \ref MatrixBase::unitOrthogonal() "orthognal vector generation" 26 | * - some linear components: parametrized-lines and hyperplanes 27 | * 28 | * \code 29 | * #include 30 | * \endcode 31 | */ 32 | 33 | #include "src/Geometry/OrthoMethods.h" 34 | #include "src/Geometry/EulerAngles.h" 35 | 36 | #if EIGEN2_SUPPORT_STAGE > STAGE20_RESOLVE_API_CONFLICTS 37 | #include "src/Geometry/Homogeneous.h" 38 | #include "src/Geometry/RotationBase.h" 39 | #include "src/Geometry/Rotation2D.h" 40 | #include "src/Geometry/Quaternion.h" 41 | #include "src/Geometry/AngleAxis.h" 42 | #include "src/Geometry/Transform.h" 43 | #include "src/Geometry/Translation.h" 44 | #include "src/Geometry/Scaling.h" 45 | #include "src/Geometry/Hyperplane.h" 46 | #include "src/Geometry/ParametrizedLine.h" 47 | #include "src/Geometry/AlignedBox.h" 48 | #include "src/Geometry/Umeyama.h" 49 | 50 | #if defined EIGEN_VECTORIZE_SSE 51 | #include "src/Geometry/arch/Geometry_SSE.h" 52 | #endif 53 | #endif 54 | 55 | #ifdef EIGEN2_SUPPORT 56 | #include "src/Eigen2Support/Geometry/All.h" 57 | #endif 58 | 59 | #include "src/Core/util/ReenableStupidWarnings.h" 60 | 61 | #endif // EIGEN_GEOMETRY_MODULE_H 62 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 63 | 64 | -------------------------------------------------------------------------------- /linsolve/Eigen/Householder: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_HOUSEHOLDER_MODULE_H 2 | #define EIGEN_HOUSEHOLDER_MODULE_H 3 | 4 | #include "Core" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | /** \defgroup Householder_Module Householder module 9 | * This module provides Householder transformations. 10 | * 11 | * \code 12 | * #include 13 | * \endcode 14 | */ 15 | 16 | #include "src/Householder/Householder.h" 17 | #include "src/Householder/HouseholderSequence.h" 18 | #include "src/Householder/BlockHouseholder.h" 19 | 20 | #include "src/Core/util/ReenableStupidWarnings.h" 21 | 22 | #endif // EIGEN_HOUSEHOLDER_MODULE_H 23 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 24 | -------------------------------------------------------------------------------- /linsolve/Eigen/IterativeLinearSolvers: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_ITERATIVELINEARSOLVERS_MODULE_H 2 | #define EIGEN_ITERATIVELINEARSOLVERS_MODULE_H 3 | 4 | #include "SparseCore" 5 | #include "OrderingMethods" 6 | 7 | #include "src/Core/util/DisableStupidWarnings.h" 8 | 9 | /** 10 | * \defgroup IterativeLinearSolvers_Module IterativeLinearSolvers module 11 | * 12 | * This module currently provides iterative methods to solve problems of the form \c A \c x = \c b, where \c A is a squared matrix, usually very large and sparse. 13 | * Those solvers are accessible via the following classes: 14 | * - ConjugateGradient for selfadjoint (hermitian) matrices, 15 | * - BiCGSTAB for general square matrices. 16 | * 17 | * These iterative solvers are associated with some preconditioners: 18 | * - IdentityPreconditioner - not really useful 19 | * - DiagonalPreconditioner - also called JAcobi preconditioner, work very well on diagonal dominant matrices. 20 | * - IncompleteILUT - incomplete LU factorization with dual thresholding 21 | * 22 | * Such problems can also be solved using the direct sparse decomposition modules: SparseCholesky, CholmodSupport, UmfPackSupport, SuperLUSupport. 23 | * 24 | * \code 25 | * #include 26 | * \endcode 27 | */ 28 | 29 | #include "src/misc/Solve.h" 30 | #include "src/misc/SparseSolve.h" 31 | 32 | #include "src/IterativeLinearSolvers/IterativeSolverBase.h" 33 | #include "src/IterativeLinearSolvers/BasicPreconditioners.h" 34 | #include "src/IterativeLinearSolvers/ConjugateGradient.h" 35 | #include "src/IterativeLinearSolvers/BiCGSTAB.h" 36 | #include "src/IterativeLinearSolvers/IncompleteLUT.h" 37 | 38 | #include "src/Core/util/ReenableStupidWarnings.h" 39 | 40 | #endif // EIGEN_ITERATIVELINEARSOLVERS_MODULE_H 41 | -------------------------------------------------------------------------------- /linsolve/Eigen/Jacobi: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_JACOBI_MODULE_H 2 | #define EIGEN_JACOBI_MODULE_H 3 | 4 | #include "Core" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | /** \defgroup Jacobi_Module Jacobi module 9 | * This module provides Jacobi and Givens rotations. 10 | * 11 | * \code 12 | * #include 13 | * \endcode 14 | * 15 | * In addition to listed classes, it defines the two following MatrixBase methods to apply a Jacobi or Givens rotation: 16 | * - MatrixBase::applyOnTheLeft() 17 | * - MatrixBase::applyOnTheRight(). 18 | */ 19 | 20 | #include "src/Jacobi/Jacobi.h" 21 | 22 | #include "src/Core/util/ReenableStupidWarnings.h" 23 | 24 | #endif // EIGEN_JACOBI_MODULE_H 25 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 26 | 27 | -------------------------------------------------------------------------------- /linsolve/Eigen/LU: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_LU_MODULE_H 2 | #define EIGEN_LU_MODULE_H 3 | 4 | #include "Core" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | /** \defgroup LU_Module LU module 9 | * This module includes %LU decomposition and related notions such as matrix inversion and determinant. 10 | * This module defines the following MatrixBase methods: 11 | * - MatrixBase::inverse() 12 | * - MatrixBase::determinant() 13 | * 14 | * \code 15 | * #include 16 | * \endcode 17 | */ 18 | 19 | #include "src/misc/Solve.h" 20 | #include "src/misc/Kernel.h" 21 | #include "src/misc/Image.h" 22 | #include "src/LU/FullPivLU.h" 23 | #include "src/LU/PartialPivLU.h" 24 | #ifdef EIGEN_USE_LAPACKE 25 | #include "src/LU/PartialPivLU_MKL.h" 26 | #endif 27 | #include "src/LU/Determinant.h" 28 | #include "src/LU/Inverse.h" 29 | 30 | #if defined EIGEN_VECTORIZE_SSE 31 | #include "src/LU/arch/Inverse_SSE.h" 32 | #endif 33 | 34 | #ifdef EIGEN2_SUPPORT 35 | #include "src/Eigen2Support/LU.h" 36 | #endif 37 | 38 | #include "src/Core/util/ReenableStupidWarnings.h" 39 | 40 | #endif // EIGEN_LU_MODULE_H 41 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 42 | -------------------------------------------------------------------------------- /linsolve/Eigen/LeastSquares: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_REGRESSION_MODULE_H 2 | #define EIGEN_REGRESSION_MODULE_H 3 | 4 | #ifndef EIGEN2_SUPPORT 5 | #error LeastSquares is only available in Eigen2 support mode (define EIGEN2_SUPPORT) 6 | #endif 7 | 8 | // exclude from normal eigen3-only documentation 9 | #ifdef EIGEN2_SUPPORT 10 | 11 | #include "Core" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | #include "Eigenvalues" 16 | #include "Geometry" 17 | 18 | /** \defgroup LeastSquares_Module LeastSquares module 19 | * This module provides linear regression and related features. 20 | * 21 | * \code 22 | * #include 23 | * \endcode 24 | */ 25 | 26 | #include "src/Eigen2Support/LeastSquares.h" 27 | 28 | #include "src/Core/util/ReenableStupidWarnings.h" 29 | 30 | #endif // EIGEN2_SUPPORT 31 | 32 | #endif // EIGEN_REGRESSION_MODULE_H 33 | -------------------------------------------------------------------------------- /linsolve/Eigen/MetisSupport: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_METISSUPPORT_MODULE_H 2 | #define EIGEN_METISSUPPORT_MODULE_H 3 | 4 | #include "SparseCore" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | extern "C" { 9 | #include 10 | } 11 | 12 | 13 | /** \ingroup Support_modules 14 | * \defgroup MetisSupport_Module MetisSupport module 15 | * 16 | * \code 17 | * #include 18 | * \endcode 19 | * This module defines an interface to the METIS reordering package (http://glaros.dtc.umn.edu/gkhome/views/metis). 20 | * It can be used just as any other built-in method as explained in \link OrderingMethods_Module here. \endlink 21 | */ 22 | 23 | 24 | #include "src/MetisSupport/MetisSupport.h" 25 | 26 | #include "src/Core/util/ReenableStupidWarnings.h" 27 | 28 | #endif // EIGEN_METISSUPPORT_MODULE_H 29 | -------------------------------------------------------------------------------- /linsolve/Eigen/OrderingMethods: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_ORDERINGMETHODS_MODULE_H 2 | #define EIGEN_ORDERINGMETHODS_MODULE_H 3 | 4 | #include "SparseCore" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | /** 9 | * \defgroup OrderingMethods_Module OrderingMethods module 10 | * 11 | * This module is currently for internal use only 12 | * 13 | * It defines various built-in and external ordering methods for sparse matrices. 14 | * They are typically used to reduce the number of elements during 15 | * the sparse matrix decomposition (LLT, LU, QR). 16 | * Precisely, in a preprocessing step, a permutation matrix P is computed using 17 | * those ordering methods and applied to the columns of the matrix. 18 | * Using for instance the sparse Cholesky decomposition, it is expected that 19 | * the nonzeros elements in LLT(A*P) will be much smaller than that in LLT(A). 20 | * 21 | * 22 | * Usage : 23 | * \code 24 | * #include 25 | * \endcode 26 | * 27 | * A simple usage is as a template parameter in the sparse decomposition classes : 28 | * 29 | * \code 30 | * SparseLU > solver; 31 | * \endcode 32 | * 33 | * \code 34 | * SparseQR > solver; 35 | * \endcode 36 | * 37 | * It is possible as well to call directly a particular ordering method for your own purpose, 38 | * \code 39 | * AMDOrdering ordering; 40 | * PermutationMatrix perm; 41 | * SparseMatrix A; 42 | * //Fill the matrix ... 43 | * 44 | * ordering(A, perm); // Call AMD 45 | * \endcode 46 | * 47 | * \note Some of these methods (like AMD or METIS), need the sparsity pattern 48 | * of the input matrix to be symmetric. When the matrix is structurally unsymmetric, 49 | * Eigen computes internally the pattern of \f$A^T*A\f$ before calling the method. 50 | * If your matrix is already symmetric (at leat in structure), you can avoid that 51 | * by calling the method with a SelfAdjointView type. 52 | * 53 | * \code 54 | * // Call the ordering on the pattern of the lower triangular matrix A 55 | * ordering(A.selfadjointView(), perm); 56 | * \endcode 57 | */ 58 | 59 | #ifndef EIGEN_MPL2_ONLY 60 | #include "src/OrderingMethods/Amd.h" 61 | #endif 62 | 63 | #include "src/OrderingMethods/Ordering.h" 64 | #include "src/Core/util/ReenableStupidWarnings.h" 65 | 66 | #endif // EIGEN_ORDERINGMETHODS_MODULE_H 67 | -------------------------------------------------------------------------------- /linsolve/Eigen/PaStiXSupport: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_PASTIXSUPPORT_MODULE_H 2 | #define EIGEN_PASTIXSUPPORT_MODULE_H 3 | 4 | #include "SparseCore" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | #include 9 | extern "C" { 10 | #include 11 | #include 12 | } 13 | 14 | #ifdef complex 15 | #undef complex 16 | #endif 17 | 18 | /** \ingroup Support_modules 19 | * \defgroup PaStiXSupport_Module PaStiXSupport module 20 | * 21 | * This module provides an interface to the PaSTiX library. 22 | * PaSTiX is a general \b supernodal, \b parallel and \b opensource sparse solver. 23 | * It provides the two following main factorization classes: 24 | * - class PastixLLT : a supernodal, parallel LLt Cholesky factorization. 25 | * - class PastixLDLT: a supernodal, parallel LDLt Cholesky factorization. 26 | * - class PastixLU : a supernodal, parallel LU factorization (optimized for a symmetric pattern). 27 | * 28 | * \code 29 | * #include 30 | * \endcode 31 | * 32 | * In order to use this module, the PaSTiX headers must be accessible from the include paths, and your binary must be linked to the PaSTiX library and its dependencies. 33 | * The dependencies depend on how PaSTiX has been compiled. 34 | * For a cmake based project, you can use our FindPaSTiX.cmake module to help you in this task. 35 | * 36 | */ 37 | 38 | #include "src/misc/Solve.h" 39 | #include "src/misc/SparseSolve.h" 40 | 41 | #include "src/PaStiXSupport/PaStiXSupport.h" 42 | 43 | 44 | #include "src/Core/util/ReenableStupidWarnings.h" 45 | 46 | #endif // EIGEN_PASTIXSUPPORT_MODULE_H 47 | -------------------------------------------------------------------------------- /linsolve/Eigen/PardisoSupport: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_PARDISOSUPPORT_MODULE_H 2 | #define EIGEN_PARDISOSUPPORT_MODULE_H 3 | 4 | #include "SparseCore" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | #include 9 | 10 | #include 11 | 12 | /** \ingroup Support_modules 13 | * \defgroup PardisoSupport_Module PardisoSupport module 14 | * 15 | * This module brings support for the Intel(R) MKL PARDISO direct sparse solvers. 16 | * 17 | * \code 18 | * #include 19 | * \endcode 20 | * 21 | * In order to use this module, the MKL headers must be accessible from the include paths, and your binary must be linked to the MKL library and its dependencies. 22 | * See this \ref TopicUsingIntelMKL "page" for more information on MKL-Eigen integration. 23 | * 24 | */ 25 | 26 | #include "src/PardisoSupport/PardisoSupport.h" 27 | 28 | #include "src/Core/util/ReenableStupidWarnings.h" 29 | 30 | #endif // EIGEN_PARDISOSUPPORT_MODULE_H 31 | -------------------------------------------------------------------------------- /linsolve/Eigen/QR: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_QR_MODULE_H 2 | #define EIGEN_QR_MODULE_H 3 | 4 | #include "Core" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | #include "Cholesky" 9 | #include "Jacobi" 10 | #include "Householder" 11 | 12 | /** \defgroup QR_Module QR module 13 | * 14 | * 15 | * 16 | * This module provides various QR decompositions 17 | * This module also provides some MatrixBase methods, including: 18 | * - MatrixBase::qr(), 19 | * 20 | * \code 21 | * #include 22 | * \endcode 23 | */ 24 | 25 | #include "src/misc/Solve.h" 26 | #include "src/QR/HouseholderQR.h" 27 | #include "src/QR/FullPivHouseholderQR.h" 28 | #include "src/QR/ColPivHouseholderQR.h" 29 | #ifdef EIGEN_USE_LAPACKE 30 | #include "src/QR/HouseholderQR_MKL.h" 31 | #include "src/QR/ColPivHouseholderQR_MKL.h" 32 | #endif 33 | 34 | #ifdef EIGEN2_SUPPORT 35 | #include "src/Eigen2Support/QR.h" 36 | #endif 37 | 38 | #include "src/Core/util/ReenableStupidWarnings.h" 39 | 40 | #ifdef EIGEN2_SUPPORT 41 | #include "Eigenvalues" 42 | #endif 43 | 44 | #endif // EIGEN_QR_MODULE_H 45 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 46 | -------------------------------------------------------------------------------- /linsolve/Eigen/QtAlignedMalloc: -------------------------------------------------------------------------------- 1 | 2 | #ifndef EIGEN_QTMALLOC_MODULE_H 3 | #define EIGEN_QTMALLOC_MODULE_H 4 | 5 | #include "Core" 6 | 7 | #if (!EIGEN_MALLOC_ALREADY_ALIGNED) 8 | 9 | #include "src/Core/util/DisableStupidWarnings.h" 10 | 11 | void *qMalloc(size_t size) 12 | { 13 | return Eigen::internal::aligned_malloc(size); 14 | } 15 | 16 | void qFree(void *ptr) 17 | { 18 | Eigen::internal::aligned_free(ptr); 19 | } 20 | 21 | void *qRealloc(void *ptr, size_t size) 22 | { 23 | void* newPtr = Eigen::internal::aligned_malloc(size); 24 | memcpy(newPtr, ptr, size); 25 | Eigen::internal::aligned_free(ptr); 26 | return newPtr; 27 | } 28 | 29 | #include "src/Core/util/ReenableStupidWarnings.h" 30 | 31 | #endif 32 | 33 | #endif // EIGEN_QTMALLOC_MODULE_H 34 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 35 | -------------------------------------------------------------------------------- /linsolve/Eigen/SPQRSupport: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_SPQRSUPPORT_MODULE_H 2 | #define EIGEN_SPQRSUPPORT_MODULE_H 3 | 4 | #include "SparseCore" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | #include "SuiteSparseQR.hpp" 9 | 10 | /** \ingroup Support_modules 11 | * \defgroup SPQRSupport_Module SuiteSparseQR module 12 | * 13 | * This module provides an interface to the SPQR library, which is part of the suitesparse package. 14 | * 15 | * \code 16 | * #include 17 | * \endcode 18 | * 19 | * 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,...). 20 | * For a cmake based project, you can use our FindSPQR.cmake and FindCholmod.Cmake modules 21 | * 22 | */ 23 | 24 | #include "src/misc/Solve.h" 25 | #include "src/misc/SparseSolve.h" 26 | #include "src/CholmodSupport/CholmodSupport.h" 27 | #include "src/SPQRSupport/SuiteSparseQRSupport.h" 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /linsolve/Eigen/SVD: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_SVD_MODULE_H 2 | #define EIGEN_SVD_MODULE_H 3 | 4 | #include "QR" 5 | #include "Householder" 6 | #include "Jacobi" 7 | 8 | #include "src/Core/util/DisableStupidWarnings.h" 9 | 10 | /** \defgroup SVD_Module SVD module 11 | * 12 | * 13 | * 14 | * This module provides SVD decomposition for matrices (both real and complex). 15 | * This decomposition is accessible via the following MatrixBase method: 16 | * - MatrixBase::jacobiSvd() 17 | * 18 | * \code 19 | * #include 20 | * \endcode 21 | */ 22 | 23 | #include "src/misc/Solve.h" 24 | #include "src/SVD/JacobiSVD.h" 25 | #if defined(EIGEN_USE_LAPACKE) && !defined(EIGEN_USE_LAPACKE_STRICT) 26 | #include "src/SVD/JacobiSVD_MKL.h" 27 | #endif 28 | #include "src/SVD/UpperBidiagonalization.h" 29 | 30 | #ifdef EIGEN2_SUPPORT 31 | #include "src/Eigen2Support/SVD.h" 32 | #endif 33 | 34 | #include "src/Core/util/ReenableStupidWarnings.h" 35 | 36 | #endif // EIGEN_SVD_MODULE_H 37 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 38 | -------------------------------------------------------------------------------- /linsolve/Eigen/Sparse: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_SPARSE_MODULE_H 2 | #define EIGEN_SPARSE_MODULE_H 3 | 4 | /** \defgroup Sparse_Module Sparse meta-module 5 | * 6 | * Meta-module including all related modules: 7 | * - \ref SparseCore_Module 8 | * - \ref OrderingMethods_Module 9 | * - \ref SparseCholesky_Module 10 | * - \ref SparseLU_Module 11 | * - \ref SparseQR_Module 12 | * - \ref IterativeLinearSolvers_Module 13 | * 14 | * \code 15 | * #include 16 | * \endcode 17 | */ 18 | 19 | #include "SparseCore" 20 | #include "OrderingMethods" 21 | #include "SparseCholesky" 22 | #include "SparseLU" 23 | #include "SparseQR" 24 | #include "IterativeLinearSolvers" 25 | 26 | #endif // EIGEN_SPARSE_MODULE_H 27 | 28 | -------------------------------------------------------------------------------- /linsolve/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 | #ifdef EIGEN_MPL2_ONLY 34 | #error The SparseCholesky module has nothing to offer in MPL2 only mode 35 | #endif 36 | 37 | #include "src/misc/Solve.h" 38 | #include "src/misc/SparseSolve.h" 39 | #include "src/SparseCholesky/SimplicialCholesky.h" 40 | 41 | #ifndef EIGEN_MPL2_ONLY 42 | #include "src/SparseCholesky/SimplicialCholesky_impl.h" 43 | #endif 44 | 45 | #include "src/Core/util/ReenableStupidWarnings.h" 46 | 47 | #endif // EIGEN_SPARSECHOLESKY_MODULE_H 48 | -------------------------------------------------------------------------------- /linsolve/Eigen/SparseCore: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_SPARSECORE_MODULE_H 2 | #define EIGEN_SPARSECORE_MODULE_H 3 | 4 | #include "Core" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | /** 15 | * \defgroup SparseCore_Module SparseCore module 16 | * 17 | * This module provides a sparse matrix representation, and basic associatd matrix manipulations 18 | * and operations. 19 | * 20 | * See the \ref TutorialSparse "Sparse tutorial" 21 | * 22 | * \code 23 | * #include 24 | * \endcode 25 | * 26 | * This module depends on: Core. 27 | */ 28 | 29 | namespace Eigen { 30 | 31 | /** The type used to identify a general sparse storage. */ 32 | struct Sparse {}; 33 | 34 | } 35 | 36 | #include "src/SparseCore/SparseUtil.h" 37 | #include "src/SparseCore/SparseMatrixBase.h" 38 | #include "src/SparseCore/CompressedStorage.h" 39 | #include "src/SparseCore/AmbiVector.h" 40 | #include "src/SparseCore/SparseMatrix.h" 41 | #include "src/SparseCore/MappedSparseMatrix.h" 42 | #include "src/SparseCore/SparseVector.h" 43 | #include "src/SparseCore/SparseBlock.h" 44 | #include "src/SparseCore/SparseTranspose.h" 45 | #include "src/SparseCore/SparseCwiseUnaryOp.h" 46 | #include "src/SparseCore/SparseCwiseBinaryOp.h" 47 | #include "src/SparseCore/SparseDot.h" 48 | #include "src/SparseCore/SparsePermutation.h" 49 | #include "src/SparseCore/SparseRedux.h" 50 | #include "src/SparseCore/SparseFuzzy.h" 51 | #include "src/SparseCore/ConservativeSparseSparseProduct.h" 52 | #include "src/SparseCore/SparseSparseProductWithPruning.h" 53 | #include "src/SparseCore/SparseProduct.h" 54 | #include "src/SparseCore/SparseDenseProduct.h" 55 | #include "src/SparseCore/SparseDiagonalProduct.h" 56 | #include "src/SparseCore/SparseTriangularView.h" 57 | #include "src/SparseCore/SparseSelfAdjointView.h" 58 | #include "src/SparseCore/TriangularSolver.h" 59 | #include "src/SparseCore/SparseView.h" 60 | 61 | #include "src/Core/util/ReenableStupidWarnings.h" 62 | 63 | #endif // EIGEN_SPARSECORE_MODULE_H 64 | 65 | -------------------------------------------------------------------------------- /linsolve/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 | #include "src/misc/Solve.h" 24 | #include "src/misc/SparseSolve.h" 25 | 26 | // Ordering interface 27 | #include "OrderingMethods" 28 | 29 | #include "src/SparseLU/SparseLU_gemm_kernel.h" 30 | 31 | #include "src/SparseLU/SparseLU_Structs.h" 32 | #include "src/SparseLU/SparseLU_SupernodalMatrix.h" 33 | #include "src/SparseLU/SparseLUImpl.h" 34 | #include "src/SparseCore/SparseColEtree.h" 35 | #include "src/SparseLU/SparseLU_Memory.h" 36 | #include "src/SparseLU/SparseLU_heap_relax_snode.h" 37 | #include "src/SparseLU/SparseLU_relax_snode.h" 38 | #include "src/SparseLU/SparseLU_pivotL.h" 39 | #include "src/SparseLU/SparseLU_panel_dfs.h" 40 | #include "src/SparseLU/SparseLU_kernel_bmod.h" 41 | #include "src/SparseLU/SparseLU_panel_bmod.h" 42 | #include "src/SparseLU/SparseLU_column_dfs.h" 43 | #include "src/SparseLU/SparseLU_column_bmod.h" 44 | #include "src/SparseLU/SparseLU_copy_to_ucol.h" 45 | #include "src/SparseLU/SparseLU_pruneL.h" 46 | #include "src/SparseLU/SparseLU_Utils.h" 47 | #include "src/SparseLU/SparseLU.h" 48 | 49 | #endif // EIGEN_SPARSELU_MODULE_H 50 | -------------------------------------------------------------------------------- /linsolve/Eigen/SparseQR: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_SPARSEQR_MODULE_H 2 | #define EIGEN_SPARSEQR_MODULE_H 3 | 4 | #include "SparseCore" 5 | #include "OrderingMethods" 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | /** \defgroup SparseQR_Module SparseQR module 9 | * \brief Provides QR decomposition for sparse matrices 10 | * 11 | * This module provides a simplicial version of the left-looking Sparse QR decomposition. 12 | * The columns of the input matrix should be reordered to limit the fill-in during the 13 | * decomposition. Built-in methods (COLAMD, AMD) or external methods (METIS) can be used to this end. 14 | * See the \link OrderingMethods_Module OrderingMethods\endlink module for the list 15 | * of built-in and external ordering methods. 16 | * 17 | * \code 18 | * #include 19 | * \endcode 20 | * 21 | * 22 | */ 23 | 24 | #include "src/misc/Solve.h" 25 | #include "src/misc/SparseSolve.h" 26 | 27 | #include "OrderingMethods" 28 | #include "src/SparseCore/SparseColEtree.h" 29 | #include "src/SparseQR/SparseQR.h" 30 | 31 | #include "src/Core/util/ReenableStupidWarnings.h" 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /linsolve/Eigen/StdDeque: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Gael Guennebaud 5 | // Copyright (C) 2009 Hauke Heibel 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_STDDEQUE_MODULE_H 12 | #define EIGEN_STDDEQUE_MODULE_H 13 | 14 | #include "Core" 15 | #include 16 | 17 | #if (defined(_MSC_VER) && defined(_WIN64)) /* MSVC auto aligns in 64 bit builds */ 18 | 19 | #define EIGEN_DEFINE_STL_DEQUE_SPECIALIZATION(...) 20 | 21 | #else 22 | 23 | #include "src/StlSupport/StdDeque.h" 24 | 25 | #endif 26 | 27 | #endif // EIGEN_STDDEQUE_MODULE_H 28 | -------------------------------------------------------------------------------- /linsolve/Eigen/StdList: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Hauke Heibel 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_STDLIST_MODULE_H 11 | #define EIGEN_STDLIST_MODULE_H 12 | 13 | #include "Core" 14 | #include 15 | 16 | #if (defined(_MSC_VER) && defined(_WIN64)) /* MSVC auto aligns in 64 bit builds */ 17 | 18 | #define EIGEN_DEFINE_STL_LIST_SPECIALIZATION(...) 19 | 20 | #else 21 | 22 | #include "src/StlSupport/StdList.h" 23 | 24 | #endif 25 | 26 | #endif // EIGEN_STDLIST_MODULE_H 27 | -------------------------------------------------------------------------------- /linsolve/Eigen/StdVector: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Gael Guennebaud 5 | // Copyright (C) 2009 Hauke Heibel 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_STDVECTOR_MODULE_H 12 | #define EIGEN_STDVECTOR_MODULE_H 13 | 14 | #include "Core" 15 | #include 16 | 17 | #if (defined(_MSC_VER) && defined(_WIN64)) /* MSVC auto aligns in 64 bit builds */ 18 | 19 | #define EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(...) 20 | 21 | #else 22 | 23 | #include "src/StlSupport/StdVector.h" 24 | 25 | #endif 26 | 27 | #endif // EIGEN_STDVECTOR_MODULE_H 28 | -------------------------------------------------------------------------------- /linsolve/Eigen/SuperLUSupport: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_SUPERLUSUPPORT_MODULE_H 2 | #define EIGEN_SUPERLUSUPPORT_MODULE_H 3 | 4 | #include "SparseCore" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | #ifdef EMPTY 9 | #define EIGEN_EMPTY_WAS_ALREADY_DEFINED 10 | #endif 11 | 12 | typedef int int_t; 13 | #include 14 | #include 15 | #include 16 | 17 | // slu_util.h defines a preprocessor token named EMPTY which is really polluting, 18 | // so we remove it in favor of a SUPERLU_EMPTY token. 19 | // If EMPTY was already defined then we don't undef it. 20 | 21 | #if defined(EIGEN_EMPTY_WAS_ALREADY_DEFINED) 22 | # undef EIGEN_EMPTY_WAS_ALREADY_DEFINED 23 | #elif defined(EMPTY) 24 | # undef EMPTY 25 | #endif 26 | 27 | #define SUPERLU_EMPTY (-1) 28 | 29 | namespace Eigen { struct SluMatrix; } 30 | 31 | /** \ingroup Support_modules 32 | * \defgroup SuperLUSupport_Module SuperLUSupport module 33 | * 34 | * This module provides an interface to the SuperLU library. 35 | * It provides the following factorization class: 36 | * - class SuperLU: a supernodal sequential LU factorization. 37 | * - class SuperILU: a supernodal sequential incomplete LU factorization (to be used as a preconditioner for iterative methods). 38 | * 39 | * \warning When including this module, you have to use SUPERLU_EMPTY instead of EMPTY which is no longer defined because it is too polluting. 40 | * 41 | * \code 42 | * #include 43 | * \endcode 44 | * 45 | * In order to use this module, the superlu headers must be accessible from the include paths, and your binary must be linked to the superlu library and its dependencies. 46 | * The dependencies depend on how superlu has been compiled. 47 | * For a cmake based project, you can use our FindSuperLU.cmake module to help you in this task. 48 | * 49 | */ 50 | 51 | #include "src/misc/Solve.h" 52 | #include "src/misc/SparseSolve.h" 53 | 54 | #include "src/SuperLUSupport/SuperLUSupport.h" 55 | 56 | 57 | #include "src/Core/util/ReenableStupidWarnings.h" 58 | 59 | #endif // EIGEN_SUPERLUSUPPORT_MODULE_H 60 | -------------------------------------------------------------------------------- /linsolve/Eigen/UmfPackSupport: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_UMFPACKSUPPORT_MODULE_H 2 | #define EIGEN_UMFPACKSUPPORT_MODULE_H 3 | 4 | #include "SparseCore" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | extern "C" { 9 | #include 10 | } 11 | 12 | /** \ingroup Support_modules 13 | * \defgroup UmfPackSupport_Module UmfPackSupport module 14 | * 15 | * This module provides an interface to the UmfPack library which is part of the suitesparse package. 16 | * It provides the following factorization class: 17 | * - class UmfPackLU: a multifrontal sequential LU factorization. 18 | * 19 | * \code 20 | * #include 21 | * \endcode 22 | * 23 | * In order to use this module, the umfpack headers must be accessible from the include paths, and your binary must be linked to the umfpack library and its dependencies. 24 | * The dependencies depend on how umfpack has been compiled. 25 | * For a cmake based project, you can use our FindUmfPack.cmake module to help you in this task. 26 | * 27 | */ 28 | 29 | #include "src/misc/Solve.h" 30 | #include "src/misc/SparseSolve.h" 31 | 32 | #include "src/UmfPackSupport/UmfPackSupport.h" 33 | 34 | #include "src/Core/util/ReenableStupidWarnings.h" 35 | 36 | #endif // EIGEN_UMFPACKSUPPORT_MODULE_H 37 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB Eigen_src_subdirectories "*") 2 | escape_string_as_regex(ESCAPED_CMAKE_CURRENT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") 3 | foreach(f ${Eigen_src_subdirectories}) 4 | if(NOT f MATCHES "\\.txt" AND NOT f MATCHES "${ESCAPED_CMAKE_CURRENT_SOURCE_DIR}/[.].+" ) 5 | add_subdirectory(${f}) 6 | endif() 7 | endforeach() 8 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/Cholesky/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Cholesky_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Cholesky_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Cholesky COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/CholmodSupport/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_CholmodSupport_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_CholmodSupport_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/CholmodSupport COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/Core/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Core_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Core_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Core COMPONENT Devel 6 | ) 7 | 8 | ADD_SUBDIRECTORY(products) 9 | ADD_SUBDIRECTORY(util) 10 | ADD_SUBDIRECTORY(arch) 11 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/Core/CoreIterators.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2010 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_COREITERATORS_H 11 | #define EIGEN_COREITERATORS_H 12 | 13 | namespace Eigen { 14 | 15 | /* This file contains the respective InnerIterator definition of the expressions defined in Eigen/Core 16 | */ 17 | 18 | /** \ingroup SparseCore_Module 19 | * \class InnerIterator 20 | * \brief An InnerIterator allows to loop over the element of a sparse (or dense) matrix or expression 21 | * 22 | * todo 23 | */ 24 | 25 | // generic version for dense matrix and expressions 26 | template class DenseBase::InnerIterator 27 | { 28 | protected: 29 | typedef typename Derived::Scalar Scalar; 30 | typedef typename Derived::Index Index; 31 | 32 | enum { IsRowMajor = (Derived::Flags&RowMajorBit)==RowMajorBit }; 33 | public: 34 | EIGEN_STRONG_INLINE InnerIterator(const Derived& expr, Index outer) 35 | : m_expression(expr), m_inner(0), m_outer(outer), m_end(expr.innerSize()) 36 | {} 37 | 38 | EIGEN_STRONG_INLINE Scalar value() const 39 | { 40 | return (IsRowMajor) ? m_expression.coeff(m_outer, m_inner) 41 | : m_expression.coeff(m_inner, m_outer); 42 | } 43 | 44 | EIGEN_STRONG_INLINE InnerIterator& operator++() { m_inner++; return *this; } 45 | 46 | EIGEN_STRONG_INLINE Index index() const { return m_inner; } 47 | inline Index row() const { return IsRowMajor ? m_outer : index(); } 48 | inline Index col() const { return IsRowMajor ? index() : m_outer; } 49 | 50 | EIGEN_STRONG_INLINE operator bool() const { return m_inner < m_end && m_inner>=0; } 51 | 52 | protected: 53 | const Derived& m_expression; 54 | Index m_inner; 55 | const Index m_outer; 56 | const Index m_end; 57 | }; 58 | 59 | } // end namespace Eigen 60 | 61 | #endif // EIGEN_COREITERATORS_H 62 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/Core/GlobalFunctions.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2010-2012 Gael Guennebaud 5 | // Copyright (C) 2010 Benoit Jacob 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_GLOBAL_FUNCTIONS_H 12 | #define EIGEN_GLOBAL_FUNCTIONS_H 13 | 14 | #define EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(NAME,FUNCTOR) \ 15 | template \ 16 | inline const Eigen::CwiseUnaryOp, const Derived> \ 17 | NAME(const Eigen::ArrayBase& x) { \ 18 | return x.derived(); \ 19 | } 20 | 21 | #define EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(NAME,FUNCTOR) \ 22 | \ 23 | template \ 24 | struct NAME##_retval > \ 25 | { \ 26 | typedef const Eigen::CwiseUnaryOp, const Derived> type; \ 27 | }; \ 28 | template \ 29 | struct NAME##_impl > \ 30 | { \ 31 | static inline typename NAME##_retval >::type run(const Eigen::ArrayBase& x) \ 32 | { \ 33 | return x.derived(); \ 34 | } \ 35 | }; 36 | 37 | 38 | namespace Eigen 39 | { 40 | EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(real,scalar_real_op) 41 | EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(imag,scalar_imag_op) 42 | EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(conj,scalar_conjugate_op) 43 | EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(sin,scalar_sin_op) 44 | EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(cos,scalar_cos_op) 45 | EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(asin,scalar_asin_op) 46 | EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(acos,scalar_acos_op) 47 | EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(tan,scalar_tan_op) 48 | EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(exp,scalar_exp_op) 49 | EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(log,scalar_log_op) 50 | EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(abs,scalar_abs_op) 51 | EIGEN_ARRAY_DECLARE_GLOBAL_UNARY(sqrt,scalar_sqrt_op) 52 | 53 | template 54 | inline const Eigen::CwiseUnaryOp, const Derived> 55 | pow(const Eigen::ArrayBase& x, const typename Derived::Scalar& exponent) { 56 | return x.derived().pow(exponent); 57 | } 58 | 59 | template 60 | inline const Eigen::CwiseBinaryOp, const Derived, const Derived> 61 | pow(const Eigen::ArrayBase& x, const Eigen::ArrayBase& exponents) 62 | { 63 | return Eigen::CwiseBinaryOp, const Derived, const Derived>( 64 | x.derived(), 65 | exponents.derived() 66 | ); 67 | } 68 | 69 | /** 70 | * \brief Component-wise division of a scalar by array elements. 71 | **/ 72 | template 73 | inline const Eigen::CwiseUnaryOp, const Derived> 74 | operator/(const typename Derived::Scalar& s, const Eigen::ArrayBase& a) 75 | { 76 | return Eigen::CwiseUnaryOp, const Derived>( 77 | a.derived(), 78 | Eigen::internal::scalar_inverse_mult_op(s) 79 | ); 80 | } 81 | 82 | namespace internal 83 | { 84 | EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(real,scalar_real_op) 85 | EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(imag,scalar_imag_op) 86 | EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(abs2,scalar_abs2_op) 87 | } 88 | } 89 | 90 | // TODO: cleanly disable those functions that are not supported on Array (numext::real_ref, internal::random, internal::isApprox...) 91 | 92 | #endif // EIGEN_GLOBAL_FUNCTIONS_H 93 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/Core/NestByValue.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008 Gael Guennebaud 5 | // Copyright (C) 2006-2008 Benoit Jacob 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_NESTBYVALUE_H 12 | #define EIGEN_NESTBYVALUE_H 13 | 14 | namespace Eigen { 15 | 16 | /** \class NestByValue 17 | * \ingroup Core_Module 18 | * 19 | * \brief Expression which must be nested by value 20 | * 21 | * \param ExpressionType the type of the object of which we are requiring nesting-by-value 22 | * 23 | * This class is the return type of MatrixBase::nestByValue() 24 | * and most of the time this is the only way it is used. 25 | * 26 | * \sa MatrixBase::nestByValue() 27 | */ 28 | 29 | namespace internal { 30 | template 31 | struct traits > : public traits 32 | {}; 33 | } 34 | 35 | template class NestByValue 36 | : public internal::dense_xpr_base< NestByValue >::type 37 | { 38 | public: 39 | 40 | typedef typename internal::dense_xpr_base::type Base; 41 | EIGEN_DENSE_PUBLIC_INTERFACE(NestByValue) 42 | 43 | inline NestByValue(const ExpressionType& matrix) : m_expression(matrix) {} 44 | 45 | inline Index rows() const { return m_expression.rows(); } 46 | inline Index cols() const { return m_expression.cols(); } 47 | inline Index outerStride() const { return m_expression.outerStride(); } 48 | inline Index innerStride() const { return m_expression.innerStride(); } 49 | 50 | inline const CoeffReturnType coeff(Index row, Index col) const 51 | { 52 | return m_expression.coeff(row, col); 53 | } 54 | 55 | inline Scalar& coeffRef(Index row, Index col) 56 | { 57 | return m_expression.const_cast_derived().coeffRef(row, col); 58 | } 59 | 60 | inline const CoeffReturnType coeff(Index index) const 61 | { 62 | return m_expression.coeff(index); 63 | } 64 | 65 | inline Scalar& coeffRef(Index index) 66 | { 67 | return m_expression.const_cast_derived().coeffRef(index); 68 | } 69 | 70 | template 71 | inline const PacketScalar packet(Index row, Index col) const 72 | { 73 | return m_expression.template packet(row, col); 74 | } 75 | 76 | template 77 | inline void writePacket(Index row, Index col, const PacketScalar& x) 78 | { 79 | m_expression.const_cast_derived().template writePacket(row, col, x); 80 | } 81 | 82 | template 83 | inline const PacketScalar packet(Index index) const 84 | { 85 | return m_expression.template packet(index); 86 | } 87 | 88 | template 89 | inline void writePacket(Index index, const PacketScalar& x) 90 | { 91 | m_expression.const_cast_derived().template writePacket(index, x); 92 | } 93 | 94 | operator const ExpressionType&() const { return m_expression; } 95 | 96 | protected: 97 | const ExpressionType m_expression; 98 | }; 99 | 100 | /** \returns an expression of the temporary version of *this. 101 | */ 102 | template 103 | inline const NestByValue 104 | DenseBase::nestByValue() const 105 | { 106 | return NestByValue(derived()); 107 | } 108 | 109 | } // end namespace Eigen 110 | 111 | #endif // EIGEN_NESTBYVALUE_H 112 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/Core/ReturnByValue.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009-2010 Gael Guennebaud 5 | // Copyright (C) 2009-2010 Benoit Jacob 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_RETURNBYVALUE_H 12 | #define EIGEN_RETURNBYVALUE_H 13 | 14 | namespace Eigen { 15 | 16 | /** \class ReturnByValue 17 | * \ingroup Core_Module 18 | * 19 | */ 20 | 21 | namespace internal { 22 | 23 | template 24 | struct traits > 25 | : public traits::ReturnType> 26 | { 27 | enum { 28 | // We're disabling the DirectAccess because e.g. the constructor of 29 | // the Block-with-DirectAccess expression requires to have a coeffRef method. 30 | // Also, we don't want to have to implement the stride stuff. 31 | Flags = (traits::ReturnType>::Flags 32 | | EvalBeforeNestingBit) & ~DirectAccessBit 33 | }; 34 | }; 35 | 36 | /* The ReturnByValue object doesn't even have a coeff() method. 37 | * So the only way that nesting it in an expression can work, is by evaluating it into a plain matrix. 38 | * So internal::nested always gives the plain return matrix type. 39 | * 40 | * FIXME: I don't understand why we need this specialization: isn't this taken care of by the EvalBeforeNestingBit ?? 41 | */ 42 | template 43 | struct nested, n, PlainObject> 44 | { 45 | typedef typename traits::ReturnType type; 46 | }; 47 | 48 | } // end namespace internal 49 | 50 | template class ReturnByValue 51 | : internal::no_assignment_operator, public internal::dense_xpr_base< ReturnByValue >::type 52 | { 53 | public: 54 | typedef typename internal::traits::ReturnType ReturnType; 55 | 56 | typedef typename internal::dense_xpr_base::type Base; 57 | EIGEN_DENSE_PUBLIC_INTERFACE(ReturnByValue) 58 | 59 | template 60 | inline void evalTo(Dest& dst) const 61 | { static_cast(this)->evalTo(dst); } 62 | inline Index rows() const { return static_cast(this)->rows(); } 63 | inline Index cols() const { return static_cast(this)->cols(); } 64 | 65 | #ifndef EIGEN_PARSED_BY_DOXYGEN 66 | #define Unusable YOU_ARE_TRYING_TO_ACCESS_A_SINGLE_COEFFICIENT_IN_A_SPECIAL_EXPRESSION_WHERE_THAT_IS_NOT_ALLOWED_BECAUSE_THAT_WOULD_BE_INEFFICIENT 67 | class Unusable{ 68 | Unusable(const Unusable&) {} 69 | Unusable& operator=(const Unusable&) {return *this;} 70 | }; 71 | const Unusable& coeff(Index) const { return *reinterpret_cast(this); } 72 | const Unusable& coeff(Index,Index) const { return *reinterpret_cast(this); } 73 | Unusable& coeffRef(Index) { return *reinterpret_cast(this); } 74 | Unusable& coeffRef(Index,Index) { return *reinterpret_cast(this); } 75 | #endif 76 | }; 77 | 78 | template 79 | template 80 | Derived& DenseBase::operator=(const ReturnByValue& other) 81 | { 82 | other.evalTo(derived()); 83 | return derived(); 84 | } 85 | 86 | } // end namespace Eigen 87 | 88 | #endif // EIGEN_RETURNBYVALUE_H 89 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/Core/Stride.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2010 Benoit Jacob 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_STRIDE_H 11 | #define EIGEN_STRIDE_H 12 | 13 | namespace Eigen { 14 | 15 | /** \class Stride 16 | * \ingroup Core_Module 17 | * 18 | * \brief Holds strides information for Map 19 | * 20 | * This class holds the strides information for mapping arrays with strides with class Map. 21 | * 22 | * It holds two values: the inner stride and the outer stride. 23 | * 24 | * The inner stride is the pointer increment between two consecutive entries within a given row of a 25 | * row-major matrix or within a given column of a column-major matrix. 26 | * 27 | * The outer stride is the pointer increment between two consecutive rows of a row-major matrix or 28 | * between two consecutive columns of a column-major matrix. 29 | * 30 | * These two values can be passed either at compile-time as template parameters, or at runtime as 31 | * arguments to the constructor. 32 | * 33 | * Indeed, this class takes two template parameters: 34 | * \param _OuterStrideAtCompileTime the outer stride, or Dynamic if you want to specify it at runtime. 35 | * \param _InnerStrideAtCompileTime the inner stride, or Dynamic if you want to specify it at runtime. 36 | * 37 | * Here is an example: 38 | * \include Map_general_stride.cpp 39 | * Output: \verbinclude Map_general_stride.out 40 | * 41 | * \sa class InnerStride, class OuterStride, \ref TopicStorageOrders 42 | */ 43 | template 44 | class Stride 45 | { 46 | public: 47 | typedef DenseIndex Index; 48 | enum { 49 | InnerStrideAtCompileTime = _InnerStrideAtCompileTime, 50 | OuterStrideAtCompileTime = _OuterStrideAtCompileTime 51 | }; 52 | 53 | /** Default constructor, for use when strides are fixed at compile time */ 54 | Stride() 55 | : m_outer(OuterStrideAtCompileTime), m_inner(InnerStrideAtCompileTime) 56 | { 57 | eigen_assert(InnerStrideAtCompileTime != Dynamic && OuterStrideAtCompileTime != Dynamic); 58 | } 59 | 60 | /** Constructor allowing to pass the strides at runtime */ 61 | Stride(Index outerStride, Index innerStride) 62 | : m_outer(outerStride), m_inner(innerStride) 63 | { 64 | eigen_assert(innerStride>=0 && outerStride>=0); 65 | } 66 | 67 | /** Copy constructor */ 68 | Stride(const Stride& other) 69 | : m_outer(other.outer()), m_inner(other.inner()) 70 | {} 71 | 72 | /** \returns the outer stride */ 73 | inline Index outer() const { return m_outer.value(); } 74 | /** \returns the inner stride */ 75 | inline Index inner() const { return m_inner.value(); } 76 | 77 | protected: 78 | internal::variable_if_dynamic m_outer; 79 | internal::variable_if_dynamic m_inner; 80 | }; 81 | 82 | /** \brief Convenience specialization of Stride to specify only an inner stride 83 | * See class Map for some examples */ 84 | template 85 | class InnerStride : public Stride<0, Value> 86 | { 87 | typedef Stride<0, Value> Base; 88 | public: 89 | typedef DenseIndex Index; 90 | InnerStride() : Base() {} 91 | InnerStride(Index v) : Base(0, v) {} 92 | }; 93 | 94 | /** \brief Convenience specialization of Stride to specify only an outer stride 95 | * See class Map for some examples */ 96 | template 97 | class OuterStride : public Stride 98 | { 99 | typedef Stride Base; 100 | public: 101 | typedef DenseIndex Index; 102 | OuterStride() : Base() {} 103 | OuterStride(Index v) : Base(v,0) {} 104 | }; 105 | 106 | } // end namespace Eigen 107 | 108 | #endif // EIGEN_STRIDE_H 109 | -------------------------------------------------------------------------------- /linsolve/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 | /** \class VectorBlock 17 | * \ingroup Core_Module 18 | * 19 | * \brief Expression of a fixed-size or dynamic-size sub-vector 20 | * 21 | * \param VectorType the type of the object in which we are taking a sub-vector 22 | * \param Size size of the sub-vector we are taking at compile time (optional) 23 | * 24 | * This class represents an expression of either a fixed-size or dynamic-size sub-vector. 25 | * It is the return type of DenseBase::segment(Index,Index) and DenseBase::segment(Index) and 26 | * most of the time this is the only way it is used. 27 | * 28 | * However, if you want to directly maniputate sub-vector expressions, 29 | * for instance if you want to write a function returning such an expression, you 30 | * will need to use this class. 31 | * 32 | * Here is an example illustrating the dynamic case: 33 | * \include class_VectorBlock.cpp 34 | * Output: \verbinclude class_VectorBlock.out 35 | * 36 | * \note Even though this expression has dynamic size, in the case where \a VectorType 37 | * has fixed size, this expression inherits a fixed maximal size which means that evaluating 38 | * it does not cause a dynamic memory allocation. 39 | * 40 | * Here is an example illustrating the fixed-size case: 41 | * \include class_FixedVectorBlock.cpp 42 | * Output: \verbinclude class_FixedVectorBlock.out 43 | * 44 | * \sa class Block, DenseBase::segment(Index,Index,Index,Index), DenseBase::segment(Index,Index) 45 | */ 46 | 47 | namespace internal { 48 | template 49 | struct traits > 50 | : public traits::Flags & RowMajorBit ? 1 : Size, 52 | traits::Flags & RowMajorBit ? Size : 1> > 53 | { 54 | }; 55 | } 56 | 57 | template class VectorBlock 58 | : public Block::Flags & RowMajorBit ? 1 : Size, 60 | internal::traits::Flags & RowMajorBit ? Size : 1> 61 | { 62 | typedef Block::Flags & RowMajorBit ? 1 : Size, 64 | internal::traits::Flags & RowMajorBit ? Size : 1> Base; 65 | enum { 66 | IsColVector = !(internal::traits::Flags & RowMajorBit) 67 | }; 68 | public: 69 | EIGEN_DENSE_PUBLIC_INTERFACE(VectorBlock) 70 | 71 | using Base::operator=; 72 | 73 | /** Dynamic-size constructor 74 | */ 75 | inline 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 | inline VectorBlock(VectorType& vector, Index start) 86 | : Base(vector, IsColVector ? start : 0, IsColVector ? 0 : start) 87 | { 88 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(VectorBlock); 89 | } 90 | }; 91 | 92 | 93 | } // end namespace Eigen 94 | 95 | #endif // EIGEN_VECTORBLOCK_H 96 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/Core/arch/AltiVec/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Core_arch_AltiVec_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Core_arch_AltiVec_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Core/arch/AltiVec COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/Core/arch/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ADD_SUBDIRECTORY(SSE) 2 | ADD_SUBDIRECTORY(AltiVec) 3 | ADD_SUBDIRECTORY(NEON) 4 | ADD_SUBDIRECTORY(Default) 5 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/Core/arch/Default/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Core_arch_Default_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Core_arch_Default_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Core/arch/Default COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/Core/arch/Default/Settings.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2010 Gael Guennebaud 5 | // Copyright (C) 2006-2008 Benoit Jacob 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | 12 | /* All the parameters defined in this file can be specialized in the 13 | * architecture specific files, and/or by the user. 14 | * More to come... */ 15 | 16 | #ifndef EIGEN_DEFAULT_SETTINGS_H 17 | #define EIGEN_DEFAULT_SETTINGS_H 18 | 19 | /** Defines the maximal loop size to enable meta unrolling of loops. 20 | * Note that the value here is expressed in Eigen's own notion of "number of FLOPS", 21 | * it does not correspond to the number of iterations or the number of instructions 22 | */ 23 | #ifndef EIGEN_UNROLLING_LIMIT 24 | #define EIGEN_UNROLLING_LIMIT 100 25 | #endif 26 | 27 | /** Defines the threshold between a "small" and a "large" matrix. 28 | * This threshold is mainly used to select the proper product implementation. 29 | */ 30 | #ifndef EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD 31 | #define EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD 8 32 | #endif 33 | 34 | /** Defines the maximal width of the blocks used in the triangular product and solver 35 | * for vectors (level 2 blas xTRMV and xTRSV). The default is 8. 36 | */ 37 | #ifndef EIGEN_TUNE_TRIANGULAR_PANEL_WIDTH 38 | #define EIGEN_TUNE_TRIANGULAR_PANEL_WIDTH 8 39 | #endif 40 | 41 | 42 | /** Defines the default number of registers available for that architecture. 43 | * Currently it must be 8 or 16. Other values will fail. 44 | */ 45 | #ifndef EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS 46 | #define EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS 8 47 | #endif 48 | 49 | #endif // EIGEN_DEFAULT_SETTINGS_H 50 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/Core/arch/NEON/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Core_arch_NEON_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Core_arch_NEON_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Core/arch/NEON COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/Core/arch/SSE/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Core_arch_SSE_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Core_arch_SSE_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Core/arch/SSE COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/Core/products/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Core_Product_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Core_Product_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Core/products COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/Core/products/SelfadjointRank2Update.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 | // 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_SELFADJOINTRANK2UPTADE_H 11 | #define EIGEN_SELFADJOINTRANK2UPTADE_H 12 | 13 | namespace Eigen { 14 | 15 | namespace internal { 16 | 17 | /* Optimized selfadjoint matrix += alpha * uv' + conj(alpha)*vu' 18 | * It corresponds to the Level2 syr2 BLAS routine 19 | */ 20 | 21 | template 22 | struct selfadjoint_rank2_update_selector; 23 | 24 | template 25 | struct selfadjoint_rank2_update_selector 26 | { 27 | static void run(Scalar* mat, Index stride, const UType& u, const VType& v, const Scalar& alpha) 28 | { 29 | const Index size = u.size(); 30 | for (Index i=0; i >(mat+stride*i+i, size-i) += 33 | (numext::conj(alpha) * numext::conj(u.coeff(i))) * v.tail(size-i) 34 | + (alpha * numext::conj(v.coeff(i))) * u.tail(size-i); 35 | } 36 | } 37 | }; 38 | 39 | template 40 | struct selfadjoint_rank2_update_selector 41 | { 42 | static void run(Scalar* mat, Index stride, const UType& u, const VType& v, const Scalar& alpha) 43 | { 44 | const Index size = u.size(); 45 | for (Index i=0; i >(mat+stride*i, i+1) += 47 | (numext::conj(alpha) * numext::conj(u.coeff(i))) * v.head(i+1) 48 | + (alpha * numext::conj(v.coeff(i))) * u.head(i+1); 49 | } 50 | }; 51 | 52 | template struct conj_expr_if 53 | : conditional::Scalar>,T> > {}; 55 | 56 | } // end namespace internal 57 | 58 | template 59 | template 60 | SelfAdjointView& SelfAdjointView 61 | ::rankUpdate(const MatrixBase& u, const MatrixBase& v, const Scalar& alpha) 62 | { 63 | typedef internal::blas_traits UBlasTraits; 64 | typedef typename UBlasTraits::DirectLinearAccessType ActualUType; 65 | typedef typename internal::remove_all::type _ActualUType; 66 | typename internal::add_const_on_value_type::type actualU = UBlasTraits::extract(u.derived()); 67 | 68 | typedef internal::blas_traits VBlasTraits; 69 | typedef typename VBlasTraits::DirectLinearAccessType ActualVType; 70 | typedef typename internal::remove_all::type _ActualVType; 71 | typename internal::add_const_on_value_type::type actualV = VBlasTraits::extract(v.derived()); 72 | 73 | // If MatrixType is row major, then we use the routine for lower triangular in the upper triangular case and 74 | // vice versa, and take the complex conjugate of all coefficients and vector entries. 75 | 76 | enum { IsRowMajor = (internal::traits::Flags&RowMajorBit) ? 1 : 0 }; 77 | Scalar actualAlpha = alpha * UBlasTraits::extractScalarFactor(u.derived()) 78 | * numext::conj(VBlasTraits::extractScalarFactor(v.derived())); 79 | if (IsRowMajor) 80 | actualAlpha = numext::conj(actualAlpha); 81 | 82 | internal::selfadjoint_rank2_update_selector::type>::type, 84 | typename internal::remove_all::type>::type, 85 | (IsRowMajor ? int(UpLo==Upper ? Lower : Upper) : UpLo)> 86 | ::run(_expression().const_cast_derived().data(),_expression().outerStride(),actualU,actualV,actualAlpha); 87 | 88 | return *this; 89 | } 90 | 91 | } // end namespace Eigen 92 | 93 | #endif // EIGEN_SELFADJOINTRANK2UPTADE_H 94 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/Core/util/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Core_util_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Core_util_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Core/util COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/Core/util/DisableStupidWarnings.h: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_WARNINGS_DISABLED 2 | #define EIGEN_WARNINGS_DISABLED 3 | 4 | #ifdef _MSC_VER 5 | // 4100 - unreferenced formal parameter (occurred e.g. in aligned_allocator::destroy(pointer p)) 6 | // 4101 - unreferenced local variable 7 | // 4127 - conditional expression is constant 8 | // 4181 - qualifier applied to reference type ignored 9 | // 4211 - nonstandard extension used : redefined extern to static 10 | // 4244 - 'argument' : conversion from 'type1' to 'type2', possible loss of data 11 | // 4273 - QtAlignedMalloc, inconsistent DLL linkage 12 | // 4324 - structure was padded due to declspec(align()) 13 | // 4512 - assignment operator could not be generated 14 | // 4522 - 'class' : multiple assignment operators specified 15 | // 4700 - uninitialized local variable 'xyz' used 16 | // 4717 - 'function' : recursive on all control paths, function will cause runtime stack overflow 17 | #ifndef EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS 18 | #pragma warning( push ) 19 | #endif 20 | #pragma warning( disable : 4100 4101 4127 4181 4211 4244 4273 4324 4512 4522 4700 4717 ) 21 | #elif defined __INTEL_COMPILER 22 | // 2196 - routine is both "inline" and "noinline" ("noinline" assumed) 23 | // ICC 12 generates this warning even without any inline keyword, when defining class methods 'inline' i.e. inside of class body 24 | // typedef that may be a reference type. 25 | // 279 - controlling expression is constant 26 | // ICC 12 generates this warning on assert(constant_expression_depending_on_template_params) and frankly this is a legitimate use case. 27 | #ifndef EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS 28 | #pragma warning push 29 | #endif 30 | #pragma warning disable 2196 279 31 | #elif defined __clang__ 32 | // -Wconstant-logical-operand - warning: use of logical && with constant operand; switch to bitwise & or remove constant 33 | // this is really a stupid warning as it warns on compile-time expressions involving enums 34 | #ifndef EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS 35 | #pragma clang diagnostic push 36 | #endif 37 | #pragma clang diagnostic ignored "-Wconstant-logical-operand" 38 | #endif 39 | 40 | #endif // not EIGEN_WARNINGS_DISABLED 41 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/Core/util/MKL_support.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011, Intel Corporation. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | * Neither the name of Intel Corporation nor the names of its contributors may 13 | be used to endorse or promote products derived from this software without 14 | specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | ******************************************************************************** 28 | * Content : Eigen bindings to Intel(R) MKL 29 | * Include file with common MKL declarations 30 | ******************************************************************************** 31 | */ 32 | 33 | #ifndef EIGEN_MKL_SUPPORT_H 34 | #define EIGEN_MKL_SUPPORT_H 35 | 36 | #ifdef EIGEN_USE_MKL_ALL 37 | #ifndef EIGEN_USE_BLAS 38 | #define EIGEN_USE_BLAS 39 | #endif 40 | #ifndef EIGEN_USE_LAPACKE 41 | #define EIGEN_USE_LAPACKE 42 | #endif 43 | #ifndef EIGEN_USE_MKL_VML 44 | #define EIGEN_USE_MKL_VML 45 | #endif 46 | #endif 47 | 48 | #ifdef EIGEN_USE_LAPACKE_STRICT 49 | #define EIGEN_USE_LAPACKE 50 | #endif 51 | 52 | #if defined(EIGEN_USE_BLAS) || defined(EIGEN_USE_LAPACKE) || defined(EIGEN_USE_MKL_VML) 53 | #define EIGEN_USE_MKL 54 | #endif 55 | 56 | #if defined EIGEN_USE_MKL 57 | 58 | #include 59 | #include 60 | #define EIGEN_MKL_VML_THRESHOLD 128 61 | 62 | namespace Eigen { 63 | 64 | typedef std::complex dcomplex; 65 | typedef std::complex scomplex; 66 | 67 | namespace internal { 68 | 69 | template 70 | static inline void assign_scalar_eig2mkl(MKLType& mklScalar, const EigenType& eigenScalar) { 71 | mklScalar=eigenScalar; 72 | } 73 | 74 | template 75 | static inline void assign_conj_scalar_eig2mkl(MKLType& mklScalar, const EigenType& eigenScalar) { 76 | mklScalar=eigenScalar; 77 | } 78 | 79 | template <> 80 | inline void assign_scalar_eig2mkl(MKL_Complex16& mklScalar, const dcomplex& eigenScalar) { 81 | mklScalar.real=eigenScalar.real(); 82 | mklScalar.imag=eigenScalar.imag(); 83 | } 84 | 85 | template <> 86 | inline void assign_scalar_eig2mkl(MKL_Complex8& mklScalar, const scomplex& eigenScalar) { 87 | mklScalar.real=eigenScalar.real(); 88 | mklScalar.imag=eigenScalar.imag(); 89 | } 90 | 91 | template <> 92 | inline void assign_conj_scalar_eig2mkl(MKL_Complex16& mklScalar, const dcomplex& eigenScalar) { 93 | mklScalar.real=eigenScalar.real(); 94 | mklScalar.imag=-eigenScalar.imag(); 95 | } 96 | 97 | template <> 98 | inline void assign_conj_scalar_eig2mkl(MKL_Complex8& mklScalar, const scomplex& eigenScalar) { 99 | mklScalar.real=eigenScalar.real(); 100 | mklScalar.imag=-eigenScalar.imag(); 101 | } 102 | 103 | } // end namespace internal 104 | 105 | } // end namespace Eigen 106 | 107 | #endif 108 | 109 | #endif // EIGEN_MKL_SUPPORT_H 110 | -------------------------------------------------------------------------------- /linsolve/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 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/Core/util/ReenableStupidWarnings.h: -------------------------------------------------------------------------------- 1 | #ifdef EIGEN_WARNINGS_DISABLED 2 | #undef EIGEN_WARNINGS_DISABLED 3 | 4 | #ifndef EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS 5 | #ifdef _MSC_VER 6 | #pragma warning( pop ) 7 | #elif defined __INTEL_COMPILER 8 | #pragma warning pop 9 | #elif defined __clang__ 10 | #pragma clang diagnostic pop 11 | #endif 12 | #endif 13 | 14 | #endif // EIGEN_WARNINGS_DISABLED 15 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/Eigen2Support/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Eigen2Support_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Eigen2Support_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Eigen2Support COMPONENT Devel 6 | ) 7 | 8 | ADD_SUBDIRECTORY(Geometry) -------------------------------------------------------------------------------- /linsolve/Eigen/src/Eigen2Support/Geometry/All.h: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN2_GEOMETRY_MODULE_H 2 | #define EIGEN2_GEOMETRY_MODULE_H 3 | 4 | #include 5 | 6 | #ifndef M_PI 7 | #define M_PI 3.14159265358979323846 8 | #endif 9 | 10 | #if EIGEN2_SUPPORT_STAGE < STAGE20_RESOLVE_API_CONFLICTS 11 | #include "RotationBase.h" 12 | #include "Rotation2D.h" 13 | #include "Quaternion.h" 14 | #include "AngleAxis.h" 15 | #include "Transform.h" 16 | #include "Translation.h" 17 | #include "Scaling.h" 18 | #include "AlignedBox.h" 19 | #include "Hyperplane.h" 20 | #include "ParametrizedLine.h" 21 | #endif 22 | 23 | 24 | #define RotationBase eigen2_RotationBase 25 | #define Rotation2D eigen2_Rotation2D 26 | #define Rotation2Df eigen2_Rotation2Df 27 | #define Rotation2Dd eigen2_Rotation2Dd 28 | 29 | #define Quaternion eigen2_Quaternion 30 | #define Quaternionf eigen2_Quaternionf 31 | #define Quaterniond eigen2_Quaterniond 32 | 33 | #define AngleAxis eigen2_AngleAxis 34 | #define AngleAxisf eigen2_AngleAxisf 35 | #define AngleAxisd eigen2_AngleAxisd 36 | 37 | #define Transform eigen2_Transform 38 | #define Transform2f eigen2_Transform2f 39 | #define Transform2d eigen2_Transform2d 40 | #define Transform3f eigen2_Transform3f 41 | #define Transform3d eigen2_Transform3d 42 | 43 | #define Translation eigen2_Translation 44 | #define Translation2f eigen2_Translation2f 45 | #define Translation2d eigen2_Translation2d 46 | #define Translation3f eigen2_Translation3f 47 | #define Translation3d eigen2_Translation3d 48 | 49 | #define Scaling eigen2_Scaling 50 | #define Scaling2f eigen2_Scaling2f 51 | #define Scaling2d eigen2_Scaling2d 52 | #define Scaling3f eigen2_Scaling3f 53 | #define Scaling3d eigen2_Scaling3d 54 | 55 | #define AlignedBox eigen2_AlignedBox 56 | 57 | #define Hyperplane eigen2_Hyperplane 58 | #define ParametrizedLine eigen2_ParametrizedLine 59 | 60 | #define ei_toRotationMatrix eigen2_ei_toRotationMatrix 61 | #define ei_quaternion_assign_impl eigen2_ei_quaternion_assign_impl 62 | #define ei_transform_product_impl eigen2_ei_transform_product_impl 63 | 64 | #include "RotationBase.h" 65 | #include "Rotation2D.h" 66 | #include "Quaternion.h" 67 | #include "AngleAxis.h" 68 | #include "Transform.h" 69 | #include "Translation.h" 70 | #include "Scaling.h" 71 | #include "AlignedBox.h" 72 | #include "Hyperplane.h" 73 | #include "ParametrizedLine.h" 74 | 75 | #undef ei_toRotationMatrix 76 | #undef ei_quaternion_assign_impl 77 | #undef ei_transform_product_impl 78 | 79 | #undef RotationBase 80 | #undef Rotation2D 81 | #undef Rotation2Df 82 | #undef Rotation2Dd 83 | 84 | #undef Quaternion 85 | #undef Quaternionf 86 | #undef Quaterniond 87 | 88 | #undef AngleAxis 89 | #undef AngleAxisf 90 | #undef AngleAxisd 91 | 92 | #undef Transform 93 | #undef Transform2f 94 | #undef Transform2d 95 | #undef Transform3f 96 | #undef Transform3d 97 | 98 | #undef Translation 99 | #undef Translation2f 100 | #undef Translation2d 101 | #undef Translation3f 102 | #undef Translation3d 103 | 104 | #undef Scaling 105 | #undef Scaling2f 106 | #undef Scaling2d 107 | #undef Scaling3f 108 | #undef Scaling3d 109 | 110 | #undef AlignedBox 111 | 112 | #undef Hyperplane 113 | #undef ParametrizedLine 114 | 115 | #endif // EIGEN2_GEOMETRY_MODULE_H 116 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/Eigen2Support/Geometry/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Eigen2Support_Geometry_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Eigen2Support_Geometry_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Eigen2Support/Geometry 6 | ) 7 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/Eigen2Support/Lazy.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008 Benoit Jacob 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_LAZY_H 11 | #define EIGEN_LAZY_H 12 | 13 | namespace Eigen { 14 | 15 | /** \deprecated it is only used by lazy() which is deprecated 16 | * 17 | * \returns an expression of *this with added flags 18 | * 19 | * Example: \include MatrixBase_marked.cpp 20 | * Output: \verbinclude MatrixBase_marked.out 21 | * 22 | * \sa class Flagged, extract(), part() 23 | */ 24 | template 25 | template 26 | inline const Flagged 27 | MatrixBase::marked() const 28 | { 29 | return derived(); 30 | } 31 | 32 | /** \deprecated use MatrixBase::noalias() 33 | * 34 | * \returns an expression of *this with the EvalBeforeAssigningBit flag removed. 35 | * 36 | * Example: \include MatrixBase_lazy.cpp 37 | * Output: \verbinclude MatrixBase_lazy.out 38 | * 39 | * \sa class Flagged, marked() 40 | */ 41 | template 42 | inline const Flagged 43 | MatrixBase::lazy() const 44 | { 45 | return derived(); 46 | } 47 | 48 | 49 | /** \internal 50 | * Overloaded to perform an efficient C += (A*B).lazy() */ 51 | template 52 | template 53 | Derived& MatrixBase::operator+=(const Flagged, 0, 54 | EvalBeforeAssigningBit>& other) 55 | { 56 | other._expression().derived().addTo(derived()); return derived(); 57 | } 58 | 59 | /** \internal 60 | * Overloaded to perform an efficient C -= (A*B).lazy() */ 61 | template 62 | template 63 | Derived& MatrixBase::operator-=(const Flagged, 0, 64 | EvalBeforeAssigningBit>& other) 65 | { 66 | other._expression().derived().subTo(derived()); return derived(); 67 | } 68 | 69 | } // end namespace Eigen 70 | 71 | #endif // EIGEN_LAZY_H 72 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/Eigen2Support/Macros.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2011 Benoit Jacob 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN2_MACROS_H 11 | #define EIGEN2_MACROS_H 12 | 13 | #define ei_assert eigen_assert 14 | #define ei_internal_assert eigen_internal_assert 15 | 16 | #define EIGEN_ALIGN_128 EIGEN_ALIGN16 17 | 18 | #define EIGEN_ARCH_WANTS_ALIGNMENT EIGEN_ALIGN_STATICALLY 19 | 20 | #endif // EIGEN2_MACROS_H 21 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/Eigen2Support/MathFunctions.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2010 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN2_MATH_FUNCTIONS_H 11 | #define EIGEN2_MATH_FUNCTIONS_H 12 | 13 | namespace Eigen { 14 | 15 | template inline typename NumTraits::Real ei_real(const T& x) { return numext::real(x); } 16 | template inline typename NumTraits::Real ei_imag(const T& x) { return numext::imag(x); } 17 | template inline T ei_conj(const T& x) { return numext::conj(x); } 18 | template inline typename NumTraits::Real ei_abs (const T& x) { using std::abs; return abs(x); } 19 | template inline typename NumTraits::Real ei_abs2(const T& x) { return numext::abs2(x); } 20 | template inline T ei_sqrt(const T& x) { using std::sqrt; return sqrt(x); } 21 | template inline T ei_exp (const T& x) { using std::exp; return exp(x); } 22 | template inline T ei_log (const T& x) { using std::log; return log(x); } 23 | template inline T ei_sin (const T& x) { using std::sin; return sin(x); } 24 | template inline T ei_cos (const T& x) { using std::cos; return cos(x); } 25 | template inline T ei_atan2(const T& x,const T& y) { using std::atan2; return atan2(x,y); } 26 | template inline T ei_pow (const T& x,const T& y) { return numext::pow(x,y); } 27 | template inline T ei_random () { return internal::random(); } 28 | template inline T ei_random (const T& x, const T& y) { return internal::random(x, y); } 29 | 30 | template inline T precision () { return NumTraits::dummy_precision(); } 31 | template inline T machine_epsilon () { return NumTraits::epsilon(); } 32 | 33 | 34 | template 35 | inline bool ei_isMuchSmallerThan(const Scalar& x, const OtherScalar& y, 36 | typename NumTraits::Real precision = NumTraits::dummy_precision()) 37 | { 38 | return internal::isMuchSmallerThan(x, y, precision); 39 | } 40 | 41 | template 42 | inline bool ei_isApprox(const Scalar& x, const Scalar& y, 43 | typename NumTraits::Real precision = NumTraits::dummy_precision()) 44 | { 45 | return internal::isApprox(x, y, precision); 46 | } 47 | 48 | template 49 | inline bool ei_isApproxOrLessThan(const Scalar& x, const Scalar& y, 50 | typename NumTraits::Real precision = NumTraits::dummy_precision()) 51 | { 52 | return internal::isApproxOrLessThan(x, y, precision); 53 | } 54 | 55 | } // end namespace Eigen 56 | 57 | #endif // EIGEN2_MATH_FUNCTIONS_H 58 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/Eigen2Support/Memory.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2011 Benoit Jacob 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN2_MEMORY_H 11 | #define EIGEN2_MEMORY_H 12 | 13 | namespace Eigen { 14 | 15 | inline void* ei_aligned_malloc(size_t size) { return internal::aligned_malloc(size); } 16 | inline void ei_aligned_free(void *ptr) { internal::aligned_free(ptr); } 17 | inline void* ei_aligned_realloc(void *ptr, size_t new_size, size_t old_size) { return internal::aligned_realloc(ptr, new_size, old_size); } 18 | inline void* ei_handmade_aligned_malloc(size_t size) { return internal::handmade_aligned_malloc(size); } 19 | inline void ei_handmade_aligned_free(void *ptr) { internal::handmade_aligned_free(ptr); } 20 | 21 | template inline void* ei_conditional_aligned_malloc(size_t size) 22 | { 23 | return internal::conditional_aligned_malloc(size); 24 | } 25 | template inline void ei_conditional_aligned_free(void *ptr) 26 | { 27 | internal::conditional_aligned_free(ptr); 28 | } 29 | template inline void* ei_conditional_aligned_realloc(void* ptr, size_t new_size, size_t old_size) 30 | { 31 | return internal::conditional_aligned_realloc(ptr, new_size, old_size); 32 | } 33 | 34 | template inline T* ei_aligned_new(size_t size) 35 | { 36 | return internal::aligned_new(size); 37 | } 38 | template inline void ei_aligned_delete(T *ptr, size_t size) 39 | { 40 | return internal::aligned_delete(ptr, size); 41 | } 42 | 43 | } // end namespace Eigen 44 | 45 | #endif // EIGEN2_MACROS_H 46 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/Eigen2Support/Meta.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2011 Benoit Jacob 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN2_META_H 11 | #define EIGEN2_META_H 12 | 13 | namespace Eigen { 14 | 15 | template 16 | struct ei_traits : internal::traits 17 | {}; 18 | 19 | struct ei_meta_true { enum { ret = 1 }; }; 20 | struct ei_meta_false { enum { ret = 0 }; }; 21 | 22 | template 23 | struct ei_meta_if { typedef Then ret; }; 24 | 25 | template 26 | struct ei_meta_if { typedef Else ret; }; 27 | 28 | template struct ei_is_same_type { enum { ret = 0 }; }; 29 | template struct ei_is_same_type { enum { ret = 1 }; }; 30 | 31 | template struct ei_unref { typedef T type; }; 32 | template struct ei_unref { typedef T type; }; 33 | 34 | template struct ei_unpointer { typedef T type; }; 35 | template struct ei_unpointer { typedef T type; }; 36 | template struct ei_unpointer { typedef T type; }; 37 | 38 | template struct ei_unconst { typedef T type; }; 39 | template struct ei_unconst { typedef T type; }; 40 | template struct ei_unconst { typedef T & type; }; 41 | template struct ei_unconst { typedef T * type; }; 42 | 43 | template struct ei_cleantype { typedef T type; }; 44 | template struct ei_cleantype { typedef typename ei_cleantype::type type; }; 45 | template struct ei_cleantype { typedef typename ei_cleantype::type type; }; 46 | template struct ei_cleantype { typedef typename ei_cleantype::type type; }; 47 | template struct ei_cleantype { typedef typename ei_cleantype::type type; }; 48 | template struct ei_cleantype { typedef typename ei_cleantype::type type; }; 49 | 50 | /** \internal In short, it computes int(sqrt(\a Y)) with \a Y an integer. 51 | * Usage example: \code ei_meta_sqrt<1023>::ret \endcode 52 | */ 53 | template Y))) > 57 | // use ?: instead of || just to shut up a stupid gcc 4.3 warning 58 | class ei_meta_sqrt 59 | { 60 | enum { 61 | MidX = (InfX+SupX)/2, 62 | TakeInf = MidX*MidX > Y ? 1 : 0, 63 | NewInf = int(TakeInf) ? InfX : int(MidX), 64 | NewSup = int(TakeInf) ? int(MidX) : SupX 65 | }; 66 | public: 67 | enum { ret = ei_meta_sqrt::ret }; 68 | }; 69 | 70 | template 71 | class ei_meta_sqrt { public: enum { ret = (SupX*SupX <= Y) ? SupX : InfX }; }; 72 | 73 | } // end namespace Eigen 74 | 75 | #endif // EIGEN2_META_H 76 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/Eigen2Support/Minor.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2006-2009 Benoit Jacob 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_MINOR_H 11 | #define EIGEN_MINOR_H 12 | 13 | namespace Eigen { 14 | 15 | /** 16 | * \class Minor 17 | * 18 | * \brief Expression of a minor 19 | * 20 | * \param MatrixType the type of the object in which we are taking a minor 21 | * 22 | * This class represents an expression of a minor. It is the return 23 | * type of MatrixBase::minor() and most of the time this is the only way it 24 | * is used. 25 | * 26 | * \sa MatrixBase::minor() 27 | */ 28 | 29 | namespace internal { 30 | template 31 | struct traits > 32 | : traits 33 | { 34 | typedef typename nested::type MatrixTypeNested; 35 | typedef typename remove_reference::type _MatrixTypeNested; 36 | typedef typename MatrixType::StorageKind StorageKind; 37 | enum { 38 | RowsAtCompileTime = (MatrixType::RowsAtCompileTime != Dynamic) ? 39 | int(MatrixType::RowsAtCompileTime) - 1 : Dynamic, 40 | ColsAtCompileTime = (MatrixType::ColsAtCompileTime != Dynamic) ? 41 | int(MatrixType::ColsAtCompileTime) - 1 : Dynamic, 42 | MaxRowsAtCompileTime = (MatrixType::MaxRowsAtCompileTime != Dynamic) ? 43 | int(MatrixType::MaxRowsAtCompileTime) - 1 : Dynamic, 44 | MaxColsAtCompileTime = (MatrixType::MaxColsAtCompileTime != Dynamic) ? 45 | int(MatrixType::MaxColsAtCompileTime) - 1 : Dynamic, 46 | Flags = _MatrixTypeNested::Flags & (HereditaryBits | LvalueBit), 47 | CoeffReadCost = _MatrixTypeNested::CoeffReadCost // minor is used typically on tiny matrices, 48 | // where loops are unrolled and the 'if' evaluates at compile time 49 | }; 50 | }; 51 | } 52 | 53 | template class Minor 54 | : public MatrixBase > 55 | { 56 | public: 57 | 58 | typedef MatrixBase Base; 59 | EIGEN_DENSE_PUBLIC_INTERFACE(Minor) 60 | 61 | inline Minor(const MatrixType& matrix, 62 | Index row, Index col) 63 | : m_matrix(matrix), m_row(row), m_col(col) 64 | { 65 | eigen_assert(row >= 0 && row < matrix.rows() 66 | && col >= 0 && col < matrix.cols()); 67 | } 68 | 69 | EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Minor) 70 | 71 | inline Index rows() const { return m_matrix.rows() - 1; } 72 | inline Index cols() const { return m_matrix.cols() - 1; } 73 | 74 | inline Scalar& coeffRef(Index row, Index col) 75 | { 76 | return m_matrix.const_cast_derived().coeffRef(row + (row >= m_row), col + (col >= m_col)); 77 | } 78 | 79 | inline const Scalar coeff(Index row, Index col) const 80 | { 81 | return m_matrix.coeff(row + (row >= m_row), col + (col >= m_col)); 82 | } 83 | 84 | protected: 85 | const typename MatrixType::Nested m_matrix; 86 | const Index m_row, m_col; 87 | }; 88 | 89 | /** 90 | * \return an expression of the (\a row, \a col)-minor of *this, 91 | * i.e. an expression constructed from *this by removing the specified 92 | * row and column. 93 | * 94 | * Example: \include MatrixBase_minor.cpp 95 | * Output: \verbinclude MatrixBase_minor.out 96 | * 97 | * \sa class Minor 98 | */ 99 | template 100 | inline Minor 101 | MatrixBase::minor(Index row, Index col) 102 | { 103 | return Minor(derived(), row, col); 104 | } 105 | 106 | /** 107 | * This is the const version of minor(). */ 108 | template 109 | inline const Minor 110 | MatrixBase::minor(Index row, Index col) const 111 | { 112 | return Minor(derived(), row, col); 113 | } 114 | 115 | } // end namespace Eigen 116 | 117 | #endif // EIGEN_MINOR_H 118 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/Eigen2Support/QR.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008 Gael Guennebaud 5 | // Copyright (C) 2011 Benoit Jacob 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN2_QR_H 12 | #define EIGEN2_QR_H 13 | 14 | namespace Eigen { 15 | 16 | template 17 | class QR : public HouseholderQR 18 | { 19 | public: 20 | 21 | typedef HouseholderQR Base; 22 | typedef Block MatrixRBlockType; 23 | 24 | QR() : Base() {} 25 | 26 | template 27 | explicit QR(const T& t) : Base(t) {} 28 | 29 | template 30 | bool solve(const MatrixBase& b, ResultType *result) const 31 | { 32 | *result = static_cast(this)->solve(b); 33 | return true; 34 | } 35 | 36 | MatrixType matrixQ(void) const { 37 | MatrixType ret = MatrixType::Identity(this->rows(), this->cols()); 38 | ret = this->householderQ() * ret; 39 | return ret; 40 | } 41 | 42 | bool isFullRank() const { 43 | return true; 44 | } 45 | 46 | const TriangularView 47 | matrixR(void) const 48 | { 49 | int cols = this->cols(); 50 | return MatrixRBlockType(this->matrixQR(), 0, 0, cols, cols).template triangularView(); 51 | } 52 | }; 53 | 54 | /** \return the QR decomposition of \c *this. 55 | * 56 | * \sa class QR 57 | */ 58 | template 59 | const QR::PlainObject> 60 | MatrixBase::qr() const 61 | { 62 | return QR(eval()); 63 | } 64 | 65 | } // end namespace Eigen 66 | 67 | #endif // EIGEN2_QR_H 68 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/Eigen2Support/TriangularSolver.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2010 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_TRIANGULAR_SOLVER2_H 11 | #define EIGEN_TRIANGULAR_SOLVER2_H 12 | 13 | namespace Eigen { 14 | 15 | const unsigned int UnitDiagBit = UnitDiag; 16 | const unsigned int SelfAdjointBit = SelfAdjoint; 17 | const unsigned int UpperTriangularBit = Upper; 18 | const unsigned int LowerTriangularBit = Lower; 19 | 20 | const unsigned int UpperTriangular = Upper; 21 | const unsigned int LowerTriangular = Lower; 22 | const unsigned int UnitUpperTriangular = UnitUpper; 23 | const unsigned int UnitLowerTriangular = UnitLower; 24 | 25 | template 26 | template 27 | typename ExpressionType::PlainObject 28 | Flagged::solveTriangular(const MatrixBase& other) const 29 | { 30 | return m_matrix.template triangularView().solve(other.derived()); 31 | } 32 | 33 | template 34 | template 35 | void Flagged::solveTriangularInPlace(const MatrixBase& other) const 36 | { 37 | m_matrix.template triangularView().solveInPlace(other.derived()); 38 | } 39 | 40 | } // end namespace Eigen 41 | 42 | #endif // EIGEN_TRIANGULAR_SOLVER2_H 43 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/Eigen2Support/VectorBlock.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2009 Gael Guennebaud 5 | // Copyright (C) 2006-2008 Benoit Jacob 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN2_VECTORBLOCK_H 12 | #define EIGEN2_VECTORBLOCK_H 13 | 14 | namespace Eigen { 15 | 16 | /** \deprecated use DenseMase::head(Index) */ 17 | template 18 | inline VectorBlock 19 | MatrixBase::start(Index size) 20 | { 21 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 22 | return VectorBlock(derived(), 0, size); 23 | } 24 | 25 | /** \deprecated use DenseMase::head(Index) */ 26 | template 27 | inline const VectorBlock 28 | MatrixBase::start(Index size) const 29 | { 30 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 31 | return VectorBlock(derived(), 0, size); 32 | } 33 | 34 | /** \deprecated use DenseMase::tail(Index) */ 35 | template 36 | inline VectorBlock 37 | MatrixBase::end(Index size) 38 | { 39 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 40 | return VectorBlock(derived(), this->size() - size, size); 41 | } 42 | 43 | /** \deprecated use DenseMase::tail(Index) */ 44 | template 45 | inline const VectorBlock 46 | MatrixBase::end(Index size) const 47 | { 48 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 49 | return VectorBlock(derived(), this->size() - size, size); 50 | } 51 | 52 | /** \deprecated use DenseMase::head() */ 53 | template 54 | template 55 | inline VectorBlock 56 | MatrixBase::start() 57 | { 58 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 59 | return VectorBlock(derived(), 0); 60 | } 61 | 62 | /** \deprecated use DenseMase::head() */ 63 | template 64 | template 65 | inline const VectorBlock 66 | MatrixBase::start() const 67 | { 68 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 69 | return VectorBlock(derived(), 0); 70 | } 71 | 72 | /** \deprecated use DenseMase::tail() */ 73 | template 74 | template 75 | inline VectorBlock 76 | MatrixBase::end() 77 | { 78 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 79 | return VectorBlock(derived(), size() - Size); 80 | } 81 | 82 | /** \deprecated use DenseMase::tail() */ 83 | template 84 | template 85 | inline const VectorBlock 86 | MatrixBase::end() const 87 | { 88 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 89 | return VectorBlock(derived(), size() - Size); 90 | } 91 | 92 | } // end namespace Eigen 93 | 94 | #endif // EIGEN2_VECTORBLOCK_H 95 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/Eigenvalues/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_EIGENVALUES_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_EIGENVALUES_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Eigenvalues COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/Eigenvalues/ComplexSchur_MKL.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011, Intel Corporation. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | * Neither the name of Intel Corporation nor the names of its contributors may 13 | be used to endorse or promote products derived from this software without 14 | specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | ******************************************************************************** 28 | * Content : Eigen bindings to Intel(R) MKL 29 | * Complex Schur needed to complex unsymmetrical eigenvalues/eigenvectors. 30 | ******************************************************************************** 31 | */ 32 | 33 | #ifndef EIGEN_COMPLEX_SCHUR_MKL_H 34 | #define EIGEN_COMPLEX_SCHUR_MKL_H 35 | 36 | #include "Eigen/src/Core/util/MKL_support.h" 37 | 38 | namespace Eigen { 39 | 40 | /** \internal Specialization for the data types supported by MKL */ 41 | 42 | #define EIGEN_MKL_SCHUR_COMPLEX(EIGTYPE, MKLTYPE, MKLPREFIX, MKLPREFIX_U, EIGCOLROW, MKLCOLROW) \ 43 | template<> inline \ 44 | ComplexSchur >& \ 45 | ComplexSchur >::compute(const Matrix& matrix, bool computeU) \ 46 | { \ 47 | typedef Matrix MatrixType; \ 48 | typedef MatrixType::Scalar Scalar; \ 49 | typedef MatrixType::RealScalar RealScalar; \ 50 | typedef std::complex ComplexScalar; \ 51 | \ 52 | eigen_assert(matrix.cols() == matrix.rows()); \ 53 | \ 54 | m_matUisUptodate = false; \ 55 | if(matrix.cols() == 1) \ 56 | { \ 57 | m_matT = matrix.cast(); \ 58 | if(computeU) m_matU = ComplexMatrixType::Identity(1,1); \ 59 | m_info = Success; \ 60 | m_isInitialized = true; \ 61 | m_matUisUptodate = computeU; \ 62 | return *this; \ 63 | } \ 64 | lapack_int n = matrix.cols(), sdim, info; \ 65 | lapack_int lda = matrix.outerStride(); \ 66 | lapack_int matrix_order = MKLCOLROW; \ 67 | char jobvs, sort='N'; \ 68 | LAPACK_##MKLPREFIX_U##_SELECT1 select = 0; \ 69 | jobvs = (computeU) ? 'V' : 'N'; \ 70 | m_matU.resize(n, n); \ 71 | lapack_int ldvs = m_matU.outerStride(); \ 72 | m_matT = matrix; \ 73 | Matrix w; \ 74 | w.resize(n, 1);\ 75 | info = LAPACKE_##MKLPREFIX##gees( matrix_order, jobvs, sort, select, n, (MKLTYPE*)m_matT.data(), lda, &sdim, (MKLTYPE*)w.data(), (MKLTYPE*)m_matU.data(), ldvs ); \ 76 | if(info == 0) \ 77 | m_info = Success; \ 78 | else \ 79 | m_info = NoConvergence; \ 80 | \ 81 | m_isInitialized = true; \ 82 | m_matUisUptodate = computeU; \ 83 | return *this; \ 84 | \ 85 | } 86 | 87 | EIGEN_MKL_SCHUR_COMPLEX(dcomplex, MKL_Complex16, z, Z, ColMajor, LAPACK_COL_MAJOR) 88 | EIGEN_MKL_SCHUR_COMPLEX(scomplex, MKL_Complex8, c, C, ColMajor, LAPACK_COL_MAJOR) 89 | EIGEN_MKL_SCHUR_COMPLEX(dcomplex, MKL_Complex16, z, Z, RowMajor, LAPACK_ROW_MAJOR) 90 | EIGEN_MKL_SCHUR_COMPLEX(scomplex, MKL_Complex8, c, C, RowMajor, LAPACK_ROW_MAJOR) 91 | 92 | } // end namespace Eigen 93 | 94 | #endif // EIGEN_COMPLEX_SCHUR_MKL_H 95 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/Eigenvalues/RealSchur_MKL.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011, Intel Corporation. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | * Neither the name of Intel Corporation nor the names of its contributors may 13 | be used to endorse or promote products derived from this software without 14 | specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | ******************************************************************************** 28 | * Content : Eigen bindings to Intel(R) MKL 29 | * Real Schur needed to real unsymmetrical eigenvalues/eigenvectors. 30 | ******************************************************************************** 31 | */ 32 | 33 | #ifndef EIGEN_REAL_SCHUR_MKL_H 34 | #define EIGEN_REAL_SCHUR_MKL_H 35 | 36 | #include "Eigen/src/Core/util/MKL_support.h" 37 | 38 | namespace Eigen { 39 | 40 | /** \internal Specialization for the data types supported by MKL */ 41 | 42 | #define EIGEN_MKL_SCHUR_REAL(EIGTYPE, MKLTYPE, MKLPREFIX, MKLPREFIX_U, EIGCOLROW, MKLCOLROW) \ 43 | template<> inline \ 44 | RealSchur >& \ 45 | RealSchur >::compute(const Matrix& matrix, bool computeU) \ 46 | { \ 47 | typedef Matrix MatrixType; \ 48 | typedef MatrixType::Scalar Scalar; \ 49 | typedef MatrixType::RealScalar RealScalar; \ 50 | \ 51 | eigen_assert(matrix.cols() == matrix.rows()); \ 52 | \ 53 | lapack_int n = matrix.cols(), sdim, info; \ 54 | lapack_int lda = matrix.outerStride(); \ 55 | lapack_int matrix_order = MKLCOLROW; \ 56 | char jobvs, sort='N'; \ 57 | LAPACK_##MKLPREFIX_U##_SELECT2 select = 0; \ 58 | jobvs = (computeU) ? 'V' : 'N'; \ 59 | m_matU.resize(n, n); \ 60 | lapack_int ldvs = m_matU.outerStride(); \ 61 | m_matT = matrix; \ 62 | Matrix wr, wi; \ 63 | wr.resize(n, 1); wi.resize(n, 1); \ 64 | info = LAPACKE_##MKLPREFIX##gees( matrix_order, jobvs, sort, select, n, (MKLTYPE*)m_matT.data(), lda, &sdim, (MKLTYPE*)wr.data(), (MKLTYPE*)wi.data(), (MKLTYPE*)m_matU.data(), ldvs ); \ 65 | if(info == 0) \ 66 | m_info = Success; \ 67 | else \ 68 | m_info = NoConvergence; \ 69 | \ 70 | m_isInitialized = true; \ 71 | m_matUisUptodate = computeU; \ 72 | return *this; \ 73 | \ 74 | } 75 | 76 | EIGEN_MKL_SCHUR_REAL(double, double, d, D, ColMajor, LAPACK_COL_MAJOR) 77 | EIGEN_MKL_SCHUR_REAL(float, float, s, S, ColMajor, LAPACK_COL_MAJOR) 78 | EIGEN_MKL_SCHUR_REAL(double, double, d, D, RowMajor, LAPACK_ROW_MAJOR) 79 | EIGEN_MKL_SCHUR_REAL(float, float, s, S, RowMajor, LAPACK_ROW_MAJOR) 80 | 81 | } // end namespace Eigen 82 | 83 | #endif // EIGEN_REAL_SCHUR_MKL_H 84 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/Geometry/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Geometry_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Geometry_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Geometry COMPONENT Devel 6 | ) 7 | 8 | ADD_SUBDIRECTORY(arch) 9 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/Geometry/EulerAngles.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_EULERANGLES_H 11 | #define EIGEN_EULERANGLES_H 12 | 13 | namespace Eigen { 14 | 15 | /** \geometry_module \ingroup Geometry_Module 16 | * 17 | * 18 | * \returns the Euler-angles of the rotation matrix \c *this using the convention defined by the triplet (\a a0,\a a1,\a a2) 19 | * 20 | * Each of the three parameters \a a0,\a a1,\a a2 represents the respective rotation axis as an integer in {0,1,2}. 21 | * For instance, in: 22 | * \code Vector3f ea = mat.eulerAngles(2, 0, 2); \endcode 23 | * "2" represents the z axis and "0" the x axis, etc. The returned angles are such that 24 | * we have the following equality: 25 | * \code 26 | * mat == AngleAxisf(ea[0], Vector3f::UnitZ()) 27 | * * AngleAxisf(ea[1], Vector3f::UnitX()) 28 | * * AngleAxisf(ea[2], Vector3f::UnitZ()); \endcode 29 | * This corresponds to the right-multiply conventions (with right hand side frames). 30 | * 31 | * The returned angles are in the ranges [0:pi]x[0:pi]x[-pi:pi]. 32 | * 33 | * \sa class AngleAxis 34 | */ 35 | template 36 | inline Matrix::Scalar,3,1> 37 | MatrixBase::eulerAngles(Index a0, Index a1, Index a2) const 38 | { 39 | using std::atan2; 40 | using std::sin; 41 | using std::cos; 42 | /* Implemented from Graphics Gems IV */ 43 | EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Derived,3,3) 44 | 45 | Matrix res; 46 | typedef Matrix Vector2; 47 | 48 | const Index odd = ((a0+1)%3 == a1) ? 0 : 1; 49 | const Index i = a0; 50 | const Index j = (a0 + 1 + odd)%3; 51 | const Index k = (a0 + 2 - odd)%3; 52 | 53 | if (a0==a2) 54 | { 55 | res[0] = atan2(coeff(j,i), coeff(k,i)); 56 | if((odd && res[0]Scalar(0))) 57 | { 58 | res[0] = (res[0] > Scalar(0)) ? res[0] - Scalar(M_PI) : res[0] + Scalar(M_PI); 59 | Scalar s2 = Vector2(coeff(j,i), coeff(k,i)).norm(); 60 | res[1] = -atan2(s2, coeff(i,i)); 61 | } 62 | else 63 | { 64 | Scalar s2 = Vector2(coeff(j,i), coeff(k,i)).norm(); 65 | res[1] = atan2(s2, coeff(i,i)); 66 | } 67 | 68 | // With a=(0,1,0), we have i=0; j=1; k=2, and after computing the first two angles, 69 | // we can compute their respective rotation, and apply its inverse to M. Since the result must 70 | // be a rotation around x, we have: 71 | // 72 | // c2 s1.s2 c1.s2 1 0 0 73 | // 0 c1 -s1 * M = 0 c3 s3 74 | // -s2 s1.c2 c1.c2 0 -s3 c3 75 | // 76 | // Thus: m11.c1 - m21.s1 = c3 & m12.c1 - m22.s1 = s3 77 | 78 | Scalar s1 = sin(res[0]); 79 | Scalar c1 = cos(res[0]); 80 | res[2] = atan2(c1*coeff(j,k)-s1*coeff(k,k), c1*coeff(j,j) - s1 * coeff(k,j)); 81 | } 82 | else 83 | { 84 | res[0] = atan2(coeff(j,k), coeff(k,k)); 85 | Scalar c2 = Vector2(coeff(i,i), coeff(i,j)).norm(); 86 | if((odd && res[0]Scalar(0))) { 87 | res[0] = (res[0] > Scalar(0)) ? res[0] - Scalar(M_PI) : res[0] + Scalar(M_PI); 88 | res[1] = atan2(-coeff(i,k), -c2); 89 | } 90 | else 91 | res[1] = atan2(-coeff(i,k), c2); 92 | Scalar s1 = sin(res[0]); 93 | Scalar c1 = cos(res[0]); 94 | res[2] = atan2(s1*coeff(k,i)-c1*coeff(j,i), c1*coeff(j,j) - s1 * coeff(k,j)); 95 | } 96 | if (!odd) 97 | res = -res; 98 | 99 | return res; 100 | } 101 | 102 | } // end namespace Eigen 103 | 104 | #endif // EIGEN_EULERANGLES_H 105 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/Geometry/arch/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Geometry_arch_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Geometry_arch_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Geometry/arch COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/Householder/BlockHouseholder.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2010 Vincent Lejeune 5 | // Copyright (C) 2010 Gael Guennebaud 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_BLOCK_HOUSEHOLDER_H 12 | #define EIGEN_BLOCK_HOUSEHOLDER_H 13 | 14 | // This file contains some helper function to deal with block householder reflectors 15 | 16 | namespace Eigen { 17 | 18 | namespace internal { 19 | 20 | /** \internal */ 21 | template 22 | void make_block_householder_triangular_factor(TriangularFactorType& triFactor, const VectorsType& vectors, const CoeffsType& hCoeffs) 23 | { 24 | typedef typename TriangularFactorType::Index Index; 25 | typedef typename VectorsType::Scalar Scalar; 26 | const Index nbVecs = vectors.cols(); 27 | eigen_assert(triFactor.rows() == nbVecs && triFactor.cols() == nbVecs && vectors.rows()>=nbVecs); 28 | 29 | for(Index i = 0; i < nbVecs; i++) 30 | { 31 | Index rs = vectors.rows() - i; 32 | Scalar Vii = vectors(i,i); 33 | vectors.const_cast_derived().coeffRef(i,i) = Scalar(1); 34 | triFactor.col(i).head(i).noalias() = -hCoeffs(i) * vectors.block(i, 0, rs, i).adjoint() 35 | * vectors.col(i).tail(rs); 36 | vectors.const_cast_derived().coeffRef(i, i) = Vii; 37 | // FIXME add .noalias() once the triangular product can work inplace 38 | triFactor.col(i).head(i) = triFactor.block(0,0,i,i).template triangularView() 39 | * triFactor.col(i).head(i); 40 | triFactor(i,i) = hCoeffs(i); 41 | } 42 | } 43 | 44 | /** \internal */ 45 | template 46 | void apply_block_householder_on_the_left(MatrixType& mat, const VectorsType& vectors, const CoeffsType& hCoeffs) 47 | { 48 | typedef typename MatrixType::Index Index; 49 | enum { TFactorSize = MatrixType::ColsAtCompileTime }; 50 | Index nbVecs = vectors.cols(); 51 | Matrix T(nbVecs,nbVecs); 52 | make_block_householder_triangular_factor(T, vectors, hCoeffs); 53 | 54 | const TriangularView& V(vectors); 55 | 56 | // A -= V T V^* A 57 | Matrix tmp = V.adjoint() * mat; 59 | // FIXME add .noalias() once the triangular product can work inplace 60 | tmp = T.template triangularView().adjoint() * tmp; 61 | mat.noalias() -= V * tmp; 62 | } 63 | 64 | } // end namespace internal 65 | 66 | } // end namespace Eigen 67 | 68 | #endif // EIGEN_BLOCK_HOUSEHOLDER_H 69 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/Householder/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Householder_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Householder_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Householder COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/IterativeLinearSolvers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_IterativeLinearSolvers_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_IterativeLinearSolvers_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/IterativeLinearSolvers COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/Jacobi/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Jacobi_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Jacobi_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Jacobi COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/LU/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_LU_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_LU_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/LU COMPONENT Devel 6 | ) 7 | 8 | ADD_SUBDIRECTORY(arch) 9 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/LU/Determinant.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008 Benoit Jacob 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_DETERMINANT_H 11 | #define EIGEN_DETERMINANT_H 12 | 13 | namespace Eigen { 14 | 15 | namespace internal { 16 | 17 | template 18 | inline const typename Derived::Scalar bruteforce_det3_helper 19 | (const MatrixBase& matrix, int a, int b, int c) 20 | { 21 | return matrix.coeff(0,a) 22 | * (matrix.coeff(1,b) * matrix.coeff(2,c) - matrix.coeff(1,c) * matrix.coeff(2,b)); 23 | } 24 | 25 | template 26 | const typename Derived::Scalar bruteforce_det4_helper 27 | (const MatrixBase& matrix, int j, int k, int m, int n) 28 | { 29 | return (matrix.coeff(j,0) * matrix.coeff(k,1) - matrix.coeff(k,0) * matrix.coeff(j,1)) 30 | * (matrix.coeff(m,2) * matrix.coeff(n,3) - matrix.coeff(n,2) * matrix.coeff(m,3)); 31 | } 32 | 33 | template struct determinant_impl 36 | { 37 | static inline typename traits::Scalar run(const Derived& m) 38 | { 39 | if(Derived::ColsAtCompileTime==Dynamic && m.rows()==0) 40 | return typename traits::Scalar(1); 41 | return m.partialPivLu().determinant(); 42 | } 43 | }; 44 | 45 | template struct determinant_impl 46 | { 47 | static inline typename traits::Scalar run(const Derived& m) 48 | { 49 | return m.coeff(0,0); 50 | } 51 | }; 52 | 53 | template struct determinant_impl 54 | { 55 | static inline typename traits::Scalar run(const Derived& m) 56 | { 57 | return m.coeff(0,0) * m.coeff(1,1) - m.coeff(1,0) * m.coeff(0,1); 58 | } 59 | }; 60 | 61 | template struct determinant_impl 62 | { 63 | static inline typename traits::Scalar run(const Derived& m) 64 | { 65 | return bruteforce_det3_helper(m,0,1,2) 66 | - bruteforce_det3_helper(m,1,0,2) 67 | + bruteforce_det3_helper(m,2,0,1); 68 | } 69 | }; 70 | 71 | template struct determinant_impl 72 | { 73 | static typename traits::Scalar run(const Derived& m) 74 | { 75 | // trick by Martin Costabel to compute 4x4 det with only 30 muls 76 | return bruteforce_det4_helper(m,0,1,2,3) 77 | - bruteforce_det4_helper(m,0,2,1,3) 78 | + bruteforce_det4_helper(m,0,3,1,2) 79 | + bruteforce_det4_helper(m,1,2,0,3) 80 | - bruteforce_det4_helper(m,1,3,0,2) 81 | + bruteforce_det4_helper(m,2,3,0,1); 82 | } 83 | }; 84 | 85 | } // end namespace internal 86 | 87 | /** \lu_module 88 | * 89 | * \returns the determinant of this matrix 90 | */ 91 | template 92 | inline typename internal::traits::Scalar MatrixBase::determinant() const 93 | { 94 | eigen_assert(rows() == cols()); 95 | typedef typename internal::nested::type Nested; 96 | return internal::determinant_impl::type>::run(derived()); 97 | } 98 | 99 | } // end namespace Eigen 100 | 101 | #endif // EIGEN_DETERMINANT_H 102 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/LU/PartialPivLU_MKL.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011, Intel Corporation. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | * Neither the name of Intel Corporation nor the names of its contributors may 13 | be used to endorse or promote products derived from this software without 14 | specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | ******************************************************************************** 28 | * Content : Eigen bindings to Intel(R) MKL 29 | * LU decomposition with partial pivoting based on LAPACKE_?getrf function. 30 | ******************************************************************************** 31 | */ 32 | 33 | #ifndef EIGEN_PARTIALLU_LAPACK_H 34 | #define EIGEN_PARTIALLU_LAPACK_H 35 | 36 | #include "Eigen/src/Core/util/MKL_support.h" 37 | 38 | namespace Eigen { 39 | 40 | namespace internal { 41 | 42 | /** \internal Specialization for the data types supported by MKL */ 43 | 44 | #define EIGEN_MKL_LU_PARTPIV(EIGTYPE, MKLTYPE, MKLPREFIX) \ 45 | template \ 46 | struct partial_lu_impl \ 47 | { \ 48 | /* \internal performs the LU decomposition in-place of the matrix represented */ \ 49 | static lapack_int blocked_lu(lapack_int rows, lapack_int cols, EIGTYPE* lu_data, lapack_int luStride, lapack_int* row_transpositions, lapack_int& nb_transpositions, lapack_int maxBlockSize=256) \ 50 | { \ 51 | EIGEN_UNUSED_VARIABLE(maxBlockSize);\ 52 | lapack_int matrix_order, first_zero_pivot; \ 53 | lapack_int m, n, lda, *ipiv, info; \ 54 | EIGTYPE* a; \ 55 | /* Set up parameters for ?getrf */ \ 56 | matrix_order = StorageOrder==RowMajor ? LAPACK_ROW_MAJOR : LAPACK_COL_MAJOR; \ 57 | lda = luStride; \ 58 | a = lu_data; \ 59 | ipiv = row_transpositions; \ 60 | m = rows; \ 61 | n = cols; \ 62 | nb_transpositions = 0; \ 63 | \ 64 | info = LAPACKE_##MKLPREFIX##getrf( matrix_order, m, n, (MKLTYPE*)a, lda, ipiv ); \ 65 | \ 66 | for(int i=0;i= 0); \ 69 | /* something should be done with nb_transpositions */ \ 70 | \ 71 | first_zero_pivot = info; \ 72 | return first_zero_pivot; \ 73 | } \ 74 | }; 75 | 76 | EIGEN_MKL_LU_PARTPIV(double, double, d) 77 | EIGEN_MKL_LU_PARTPIV(float, float, s) 78 | EIGEN_MKL_LU_PARTPIV(dcomplex, MKL_Complex16, z) 79 | EIGEN_MKL_LU_PARTPIV(scomplex, MKL_Complex8, c) 80 | 81 | } // end namespace internal 82 | 83 | } // end namespace Eigen 84 | 85 | #endif // EIGEN_PARTIALLU_LAPACK_H 86 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/LU/arch/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_LU_arch_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_LU_arch_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/LU/arch COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/MetisSupport/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_MetisSupport_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_MetisSupport_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/MetisSupport COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/OrderingMethods/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_OrderingMethods_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_OrderingMethods_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/OrderingMethods COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/PaStiXSupport/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_PastixSupport_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_PastixSupport_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/PaStiXSupport COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/PardisoSupport/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_PardisoSupport_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_PardisoSupport_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/PardisoSupport COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/QR/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_QR_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_QR_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/QR COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/QR/HouseholderQR_MKL.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011, Intel Corporation. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | * Neither the name of Intel Corporation nor the names of its contributors may 13 | be used to endorse or promote products derived from this software without 14 | specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | ******************************************************************************** 28 | * Content : Eigen bindings to Intel(R) MKL 29 | * Householder QR decomposition of a matrix w/o pivoting based on 30 | * LAPACKE_?geqrf function. 31 | ******************************************************************************** 32 | */ 33 | 34 | #ifndef EIGEN_QR_MKL_H 35 | #define EIGEN_QR_MKL_H 36 | 37 | #include "Eigen/src/Core/util/MKL_support.h" 38 | 39 | namespace Eigen { 40 | 41 | namespace internal { 42 | 43 | /** \internal Specialization for the data types supported by MKL */ 44 | 45 | #define EIGEN_MKL_QR_NOPIV(EIGTYPE, MKLTYPE, MKLPREFIX) \ 46 | template \ 47 | void householder_qr_inplace_blocked(MatrixQR& mat, HCoeffs& hCoeffs, \ 48 | typename MatrixQR::Index maxBlockSize=32, \ 49 | EIGTYPE* tempData = 0) \ 50 | { \ 51 | lapack_int m = mat.rows(); \ 52 | lapack_int n = mat.cols(); \ 53 | lapack_int lda = mat.outerStride(); \ 54 | lapack_int matrix_order = (MatrixQR::IsRowMajor) ? LAPACK_ROW_MAJOR : LAPACK_COL_MAJOR; \ 55 | LAPACKE_##MKLPREFIX##geqrf( matrix_order, m, n, (MKLTYPE*)mat.data(), lda, (MKLTYPE*)hCoeffs.data()); \ 56 | hCoeffs.adjointInPlace(); \ 57 | \ 58 | } 59 | 60 | EIGEN_MKL_QR_NOPIV(double, double, d) 61 | EIGEN_MKL_QR_NOPIV(float, float, s) 62 | EIGEN_MKL_QR_NOPIV(dcomplex, MKL_Complex16, z) 63 | EIGEN_MKL_QR_NOPIV(scomplex, MKL_Complex8, c) 64 | 65 | } // end namespace internal 66 | 67 | } // end namespace Eigen 68 | 69 | #endif // EIGEN_QR_MKL_H 70 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/SPQRSupport/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_SPQRSupport_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_SPQRSupport_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/SPQRSupport/ COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/SVD/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_SVD_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_SVD_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/SVD COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/SparseCholesky/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_SparseCholesky_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_SparseCholesky_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/SparseCholesky COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/SparseCore/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_SparseCore_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_SparseCore_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/SparseCore COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/SparseCore/SparseDot.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_SPARSE_DOT_H 11 | #define EIGEN_SPARSE_DOT_H 12 | 13 | namespace Eigen { 14 | 15 | template 16 | template 17 | typename internal::traits::Scalar 18 | SparseMatrixBase::dot(const MatrixBase& other) const 19 | { 20 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 21 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived) 22 | EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(Derived,OtherDerived) 23 | EIGEN_STATIC_ASSERT((internal::is_same::value), 24 | YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY) 25 | 26 | eigen_assert(size() == other.size()); 27 | eigen_assert(other.size()>0 && "you are using a non initialized vector"); 28 | 29 | typename Derived::InnerIterator i(derived(),0); 30 | Scalar res(0); 31 | while (i) 32 | { 33 | res += numext::conj(i.value()) * other.coeff(i.index()); 34 | ++i; 35 | } 36 | return res; 37 | } 38 | 39 | template 40 | template 41 | typename internal::traits::Scalar 42 | SparseMatrixBase::dot(const SparseMatrixBase& other) const 43 | { 44 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 45 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived) 46 | EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(Derived,OtherDerived) 47 | EIGEN_STATIC_ASSERT((internal::is_same::value), 48 | YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY) 49 | 50 | eigen_assert(size() == other.size()); 51 | 52 | typedef typename Derived::Nested Nested; 53 | typedef typename OtherDerived::Nested OtherNested; 54 | typedef typename internal::remove_all::type NestedCleaned; 55 | typedef typename internal::remove_all::type OtherNestedCleaned; 56 | 57 | Nested nthis(derived()); 58 | OtherNested nother(other.derived()); 59 | 60 | typename NestedCleaned::InnerIterator i(nthis,0); 61 | typename OtherNestedCleaned::InnerIterator j(nother,0); 62 | Scalar res(0); 63 | while (i && j) 64 | { 65 | if (i.index()==j.index()) 66 | { 67 | res += numext::conj(i.value()) * j.value(); 68 | ++i; ++j; 69 | } 70 | else if (i.index() 79 | inline typename NumTraits::Scalar>::Real 80 | SparseMatrixBase::squaredNorm() const 81 | { 82 | return numext::real((*this).cwiseAbs2().sum()); 83 | } 84 | 85 | template 86 | inline typename NumTraits::Scalar>::Real 87 | SparseMatrixBase::norm() const 88 | { 89 | using std::sqrt; 90 | return sqrt(squaredNorm()); 91 | } 92 | 93 | template 94 | inline typename NumTraits::Scalar>::Real 95 | SparseMatrixBase::blueNorm() const 96 | { 97 | return internal::blueNorm_impl(*this); 98 | } 99 | } // end namespace Eigen 100 | 101 | #endif // EIGEN_SPARSE_DOT_H 102 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/SparseCore/SparseFuzzy.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_SPARSE_FUZZY_H 11 | #define EIGEN_SPARSE_FUZZY_H 12 | 13 | // template 14 | // template 15 | // bool SparseMatrixBase::isApprox( 16 | // const OtherDerived& other, 17 | // typename NumTraits::Real prec 18 | // ) const 19 | // { 20 | // const typename internal::nested::type nested(derived()); 21 | // const typename internal::nested::type otherNested(other.derived()); 22 | // return (nested - otherNested).cwise().abs2().sum() 23 | // <= prec * prec * (std::min)(nested.cwise().abs2().sum(), otherNested.cwise().abs2().sum()); 24 | // } 25 | 26 | #endif // EIGEN_SPARSE_FUZZY_H 27 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/SparseCore/SparseRedux.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_SPARSEREDUX_H 11 | #define EIGEN_SPARSEREDUX_H 12 | 13 | namespace Eigen { 14 | 15 | template 16 | typename internal::traits::Scalar 17 | SparseMatrixBase::sum() const 18 | { 19 | eigen_assert(rows()>0 && cols()>0 && "you are using a non initialized matrix"); 20 | Scalar res(0); 21 | for (Index j=0; j 28 | typename internal::traits >::Scalar 29 | SparseMatrix<_Scalar,_Options,_Index>::sum() const 30 | { 31 | eigen_assert(rows()>0 && cols()>0 && "you are using a non initialized matrix"); 32 | return Matrix::Map(&m_data.value(0), m_data.size()).sum(); 33 | } 34 | 35 | template 36 | typename internal::traits >::Scalar 37 | SparseVector<_Scalar,_Options,_Index>::sum() const 38 | { 39 | eigen_assert(rows()>0 && cols()>0 && "you are using a non initialized matrix"); 40 | return Matrix::Map(&m_data.value(0), m_data.size()).sum(); 41 | } 42 | 43 | } // end namespace Eigen 44 | 45 | #endif // EIGEN_SPARSEREDUX_H 46 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/SparseCore/SparseTranspose.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2009 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_SPARSETRANSPOSE_H 11 | #define EIGEN_SPARSETRANSPOSE_H 12 | 13 | namespace Eigen { 14 | 15 | template class TransposeImpl 16 | : public SparseMatrixBase > 17 | { 18 | typedef typename internal::remove_all::type _MatrixTypeNested; 19 | public: 20 | 21 | EIGEN_SPARSE_PUBLIC_INTERFACE(Transpose ) 22 | 23 | class InnerIterator; 24 | class ReverseInnerIterator; 25 | 26 | inline Index nonZeros() const { return derived().nestedExpression().nonZeros(); } 27 | }; 28 | 29 | // NOTE: VC10 trigger an ICE if don't put typename TransposeImpl:: in front of Index, 30 | // a typedef typename TransposeImpl::Index Index; 31 | // does not fix the issue. 32 | // An alternative is to define the nested class in the parent class itself. 33 | template class TransposeImpl::InnerIterator 34 | : public _MatrixTypeNested::InnerIterator 35 | { 36 | typedef typename _MatrixTypeNested::InnerIterator Base; 37 | typedef typename TransposeImpl::Index Index; 38 | public: 39 | 40 | EIGEN_STRONG_INLINE InnerIterator(const TransposeImpl& trans, typename TransposeImpl::Index outer) 41 | : Base(trans.derived().nestedExpression(), outer) 42 | {} 43 | Index row() const { return Base::col(); } 44 | Index col() const { return Base::row(); } 45 | }; 46 | 47 | template class TransposeImpl::ReverseInnerIterator 48 | : public _MatrixTypeNested::ReverseInnerIterator 49 | { 50 | typedef typename _MatrixTypeNested::ReverseInnerIterator Base; 51 | typedef typename TransposeImpl::Index Index; 52 | public: 53 | 54 | EIGEN_STRONG_INLINE ReverseInnerIterator(const TransposeImpl& xpr, typename TransposeImpl::Index outer) 55 | : Base(xpr.derived().nestedExpression(), outer) 56 | {} 57 | Index row() const { return Base::col(); } 58 | Index col() const { return Base::row(); } 59 | }; 60 | 61 | } // end namespace Eigen 62 | 63 | #endif // EIGEN_SPARSETRANSPOSE_H 64 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/SparseCore/SparseView.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2011 Gael Guennebaud 5 | // Copyright (C) 2010 Daniel Lowengrub 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_SPARSEVIEW_H 12 | #define EIGEN_SPARSEVIEW_H 13 | 14 | namespace Eigen { 15 | 16 | namespace internal { 17 | 18 | template 19 | struct traits > : traits 20 | { 21 | typedef typename MatrixType::Index Index; 22 | typedef Sparse StorageKind; 23 | enum { 24 | Flags = int(traits::Flags) & (RowMajorBit) 25 | }; 26 | }; 27 | 28 | } // end namespace internal 29 | 30 | template 31 | class SparseView : public SparseMatrixBase > 32 | { 33 | typedef typename MatrixType::Nested MatrixTypeNested; 34 | typedef typename internal::remove_all::type _MatrixTypeNested; 35 | public: 36 | EIGEN_SPARSE_PUBLIC_INTERFACE(SparseView) 37 | 38 | SparseView(const MatrixType& mat, const Scalar& m_reference = Scalar(0), 39 | typename NumTraits::Real m_epsilon = NumTraits::dummy_precision()) : 40 | m_matrix(mat), m_reference(m_reference), m_epsilon(m_epsilon) {} 41 | 42 | class InnerIterator; 43 | 44 | inline Index rows() const { return m_matrix.rows(); } 45 | inline Index cols() const { return m_matrix.cols(); } 46 | 47 | inline Index innerSize() const { return m_matrix.innerSize(); } 48 | inline Index outerSize() const { return m_matrix.outerSize(); } 49 | 50 | protected: 51 | MatrixTypeNested m_matrix; 52 | Scalar m_reference; 53 | typename NumTraits::Real m_epsilon; 54 | }; 55 | 56 | template 57 | class SparseView::InnerIterator : public _MatrixTypeNested::InnerIterator 58 | { 59 | typedef typename SparseView::Index Index; 60 | public: 61 | typedef typename _MatrixTypeNested::InnerIterator IterBase; 62 | InnerIterator(const SparseView& view, Index outer) : 63 | IterBase(view.m_matrix, outer), m_view(view) 64 | { 65 | incrementToNonZero(); 66 | } 67 | 68 | EIGEN_STRONG_INLINE InnerIterator& operator++() 69 | { 70 | IterBase::operator++(); 71 | incrementToNonZero(); 72 | return *this; 73 | } 74 | 75 | using IterBase::value; 76 | 77 | protected: 78 | const SparseView& m_view; 79 | 80 | private: 81 | void incrementToNonZero() 82 | { 83 | while((bool(*this)) && internal::isMuchSmallerThan(value(), m_view.m_reference, m_view.m_epsilon)) 84 | { 85 | IterBase::operator++(); 86 | } 87 | } 88 | }; 89 | 90 | template 91 | const SparseView MatrixBase::sparseView(const Scalar& m_reference, 92 | const typename NumTraits::Real& m_epsilon) const 93 | { 94 | return SparseView(derived(), m_reference, m_epsilon); 95 | } 96 | 97 | } // end namespace Eigen 98 | 99 | #endif 100 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/SparseLU/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_SparseLU_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_SparseLU_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/SparseLU COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/SparseLU/SparseLUImpl.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 | #ifndef SPARSELU_IMPL_H 10 | #define SPARSELU_IMPL_H 11 | 12 | namespace Eigen { 13 | namespace internal { 14 | 15 | /** \ingroup SparseLU_Module 16 | * \class SparseLUImpl 17 | * Base class for sparseLU 18 | */ 19 | template 20 | class SparseLUImpl 21 | { 22 | public: 23 | typedef Matrix ScalarVector; 24 | typedef Matrix IndexVector; 25 | typedef typename ScalarVector::RealScalar RealScalar; 26 | typedef Ref > BlockScalarVector; 27 | typedef Ref > BlockIndexVector; 28 | typedef LU_GlobalLU_t GlobalLU_t; 29 | typedef SparseMatrix MatrixType; 30 | 31 | protected: 32 | template 33 | Index expand(VectorType& vec, Index& length, Index nbElts, Index keep_prev, Index& num_expansions); 34 | Index memInit(Index m, Index n, Index annz, Index lwork, Index fillratio, Index panel_size, GlobalLU_t& glu); 35 | template 36 | Index memXpand(VectorType& vec, Index& maxlen, Index nbElts, MemType memtype, Index& num_expansions); 37 | void heap_relax_snode (const Index n, IndexVector& et, const Index relax_columns, IndexVector& descendants, IndexVector& relax_end); 38 | void relax_snode (const Index n, IndexVector& et, const Index relax_columns, IndexVector& descendants, IndexVector& relax_end); 39 | Index snode_dfs(const Index jcol, const Index kcol,const MatrixType& mat, IndexVector& xprune, IndexVector& marker, GlobalLU_t& glu); 40 | Index snode_bmod (const Index jcol, const Index fsupc, ScalarVector& dense, GlobalLU_t& glu); 41 | Index pivotL(const Index jcol, const RealScalar& diagpivotthresh, IndexVector& perm_r, IndexVector& iperm_c, Index& pivrow, GlobalLU_t& glu); 42 | template 43 | void dfs_kernel(const Index jj, IndexVector& perm_r, 44 | Index& nseg, IndexVector& panel_lsub, IndexVector& segrep, 45 | Ref repfnz_col, IndexVector& xprune, Ref marker, IndexVector& parent, 46 | IndexVector& xplore, GlobalLU_t& glu, Index& nextl_col, Index krow, Traits& traits); 47 | void panel_dfs(const Index m, const Index w, const Index jcol, MatrixType& A, IndexVector& perm_r, Index& nseg, ScalarVector& dense, IndexVector& panel_lsub, IndexVector& segrep, IndexVector& repfnz, IndexVector& xprune, IndexVector& marker, IndexVector& parent, IndexVector& xplore, GlobalLU_t& glu); 48 | 49 | void panel_bmod(const Index m, const Index w, const Index jcol, const Index nseg, ScalarVector& dense, ScalarVector& tempv, IndexVector& segrep, IndexVector& repfnz, GlobalLU_t& glu); 50 | Index column_dfs(const Index m, const Index jcol, IndexVector& perm_r, Index maxsuper, Index& nseg, BlockIndexVector lsub_col, IndexVector& segrep, BlockIndexVector repfnz, IndexVector& xprune, IndexVector& marker, IndexVector& parent, IndexVector& xplore, GlobalLU_t& glu); 51 | Index column_bmod(const Index jcol, const Index nseg, BlockScalarVector dense, ScalarVector& tempv, BlockIndexVector segrep, BlockIndexVector repfnz, Index fpanelc, GlobalLU_t& glu); 52 | Index copy_to_ucol(const Index jcol, const Index nseg, IndexVector& segrep, BlockIndexVector repfnz ,IndexVector& perm_r, BlockScalarVector dense, GlobalLU_t& glu); 53 | void pruneL(const Index jcol, const IndexVector& perm_r, const Index pivrow, const Index nseg, const IndexVector& segrep, BlockIndexVector repfnz, IndexVector& xprune, GlobalLU_t& glu); 54 | void countnz(const Index n, Index& nnzL, Index& nnzU, GlobalLU_t& glu); 55 | void fixupL(const Index n, const IndexVector& perm_r, GlobalLU_t& glu); 56 | 57 | template 58 | friend struct column_dfs_traits; 59 | }; 60 | 61 | } // end namespace internal 62 | } // namespace Eigen 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /linsolve/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 | Index 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 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/SparseLU/SparseLU_copy_to_ucol.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 | * NOTE: This file is the modified version of [s,d,c,z]copy_to_ucol.c file in SuperLU 12 | 13 | * -- SuperLU routine (version 2.0) -- 14 | * Univ. of California Berkeley, Xerox Palo Alto Research Center, 15 | * and Lawrence Berkeley National Lab. 16 | * November 15, 1997 17 | * 18 | * Copyright (c) 1994 by Xerox Corporation. All rights reserved. 19 | * 20 | * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY 21 | * EXPRESSED OR IMPLIED. ANY USE IS AT YOUR OWN RISK. 22 | * 23 | * Permission is hereby granted to use or copy this program for any 24 | * purpose, provided the above notices are retained on all copies. 25 | * Permission to modify the code and to distribute modified code is 26 | * granted, provided the above notices are retained, and a notice that 27 | * the code was modified is included with the above copyright notice. 28 | */ 29 | #ifndef SPARSELU_COPY_TO_UCOL_H 30 | #define SPARSELU_COPY_TO_UCOL_H 31 | 32 | namespace Eigen { 33 | namespace internal { 34 | 35 | /** 36 | * \brief Performs numeric block updates (sup-col) in topological order 37 | * 38 | * \param jcol current column to update 39 | * \param nseg Number of segments in the U part 40 | * \param segrep segment representative ... 41 | * \param repfnz First nonzero column in each row ... 42 | * \param perm_r Row permutation 43 | * \param dense Store the full representation of the column 44 | * \param glu Global LU data. 45 | * \return 0 - successful return 46 | * > 0 - number of bytes allocated when run out of space 47 | * 48 | */ 49 | template 50 | Index SparseLUImpl::copy_to_ucol(const Index jcol, const Index nseg, IndexVector& segrep, BlockIndexVector repfnz ,IndexVector& perm_r, BlockScalarVector dense, GlobalLU_t& glu) 51 | { 52 | Index ksub, krep, ksupno; 53 | 54 | Index jsupno = glu.supno(jcol); 55 | 56 | // For each nonzero supernode segment of U[*,j] in topological order 57 | Index k = nseg - 1, i; 58 | Index nextu = glu.xusub(jcol); 59 | Index kfnz, isub, segsize; 60 | Index new_next,irow; 61 | Index fsupc, mem; 62 | for (ksub = 0; ksub < nseg; ksub++) 63 | { 64 | krep = segrep(k); k--; 65 | ksupno = glu.supno(krep); 66 | if (jsupno != ksupno ) // should go into ucol(); 67 | { 68 | kfnz = repfnz(krep); 69 | if (kfnz != emptyIdxLU) 70 | { // Nonzero U-segment 71 | fsupc = glu.xsup(ksupno); 72 | isub = glu.xlsub(fsupc) + kfnz - fsupc; 73 | segsize = krep - kfnz + 1; 74 | new_next = nextu + segsize; 75 | while (new_next > glu.nzumax) 76 | { 77 | mem = memXpand(glu.ucol, glu.nzumax, nextu, UCOL, glu.num_expansions); 78 | if (mem) return mem; 79 | mem = memXpand(glu.usub, glu.nzumax, nextu, USUB, glu.num_expansions); 80 | if (mem) return mem; 81 | 82 | } 83 | 84 | for (i = 0; i < segsize; i++) 85 | { 86 | irow = glu.lsub(isub); 87 | glu.usub(nextu) = perm_r(irow); // Unlike the L part, the U part is stored in its final order 88 | glu.ucol(nextu) = dense(irow); 89 | dense(irow) = Scalar(0.0); 90 | nextu++; 91 | isub++; 92 | } 93 | 94 | } // end nonzero U-segment 95 | 96 | } // end if jsupno 97 | 98 | } // end for each segment 99 | glu.xusub(jcol + 1) = nextu; // close U(*,jcol) 100 | return 0; 101 | } 102 | 103 | } // namespace internal 104 | } // end namespace Eigen 105 | 106 | #endif // SPARSELU_COPY_TO_UCOL_H 107 | -------------------------------------------------------------------------------- /linsolve/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 j, parent; 52 | relax_end.setConstant(emptyIdxLU); 53 | descendants.setZero(); 54 | for (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 (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) = 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 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/SparseQR/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_SparseQR_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_SparseQR_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/SparseQR/ COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/StlSupport/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_StlSupport_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_StlSupport_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/StlSupport COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/StlSupport/details.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Gael Guennebaud 5 | // Copyright (C) 2009 Hauke Heibel 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_STL_DETAILS_H 12 | #define EIGEN_STL_DETAILS_H 13 | 14 | #ifndef EIGEN_ALIGNED_ALLOCATOR 15 | #define EIGEN_ALIGNED_ALLOCATOR Eigen::aligned_allocator 16 | #endif 17 | 18 | namespace Eigen { 19 | 20 | // This one is needed to prevent reimplementing the whole std::vector. 21 | template 22 | class aligned_allocator_indirection : public EIGEN_ALIGNED_ALLOCATOR 23 | { 24 | public: 25 | typedef size_t size_type; 26 | typedef ptrdiff_t difference_type; 27 | typedef T* pointer; 28 | typedef const T* const_pointer; 29 | typedef T& reference; 30 | typedef const T& const_reference; 31 | typedef T value_type; 32 | 33 | template 34 | struct rebind 35 | { 36 | typedef aligned_allocator_indirection other; 37 | }; 38 | 39 | aligned_allocator_indirection() {} 40 | aligned_allocator_indirection(const aligned_allocator_indirection& ) : EIGEN_ALIGNED_ALLOCATOR() {} 41 | aligned_allocator_indirection(const EIGEN_ALIGNED_ALLOCATOR& ) {} 42 | template 43 | aligned_allocator_indirection(const aligned_allocator_indirection& ) {} 44 | template 45 | aligned_allocator_indirection(const EIGEN_ALIGNED_ALLOCATOR& ) {} 46 | ~aligned_allocator_indirection() {} 47 | }; 48 | 49 | #ifdef _MSC_VER 50 | 51 | // sometimes, MSVC detects, at compile time, that the argument x 52 | // in std::vector::resize(size_t s,T x) won't be aligned and generate an error 53 | // even if this function is never called. Whence this little wrapper. 54 | #define EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T) \ 55 | typename Eigen::internal::conditional< \ 56 | Eigen::internal::is_arithmetic::value, \ 57 | T, \ 58 | Eigen::internal::workaround_msvc_stl_support \ 59 | >::type 60 | 61 | namespace internal { 62 | template struct workaround_msvc_stl_support : public T 63 | { 64 | inline workaround_msvc_stl_support() : T() {} 65 | inline workaround_msvc_stl_support(const T& other) : T(other) {} 66 | inline operator T& () { return *static_cast(this); } 67 | inline operator const T& () const { return *static_cast(this); } 68 | template 69 | inline T& operator=(const OtherT& other) 70 | { T::operator=(other); return *this; } 71 | inline workaround_msvc_stl_support& operator=(const workaround_msvc_stl_support& other) 72 | { T::operator=(other); return *this; } 73 | }; 74 | } 75 | 76 | #else 77 | 78 | #define EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T) T 79 | 80 | #endif 81 | 82 | } 83 | 84 | #endif // EIGEN_STL_DETAILS_H 85 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/SuperLUSupport/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_SuperLUSupport_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_SuperLUSupport_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/SuperLUSupport COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/UmfPackSupport/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_UmfPackSupport_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_UmfPackSupport_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/UmfPackSupport COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/misc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_misc_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_misc_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/misc COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/misc/Image.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Benoit Jacob 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_MISC_IMAGE_H 11 | #define EIGEN_MISC_IMAGE_H 12 | 13 | namespace Eigen { 14 | 15 | namespace internal { 16 | 17 | /** \class image_retval_base 18 | * 19 | */ 20 | template 21 | struct traits > 22 | { 23 | typedef typename DecompositionType::MatrixType MatrixType; 24 | typedef Matrix< 25 | typename MatrixType::Scalar, 26 | MatrixType::RowsAtCompileTime, // the image is a subspace of the destination space, whose 27 | // dimension is the number of rows of the original matrix 28 | Dynamic, // we don't know at compile time the dimension of the image (the rank) 29 | MatrixType::Options, 30 | MatrixType::MaxRowsAtCompileTime, // the image matrix will consist of columns from the original matrix, 31 | MatrixType::MaxColsAtCompileTime // so it has the same number of rows and at most as many columns. 32 | > ReturnType; 33 | }; 34 | 35 | template struct image_retval_base 36 | : public ReturnByValue > 37 | { 38 | typedef _DecompositionType DecompositionType; 39 | typedef typename DecompositionType::MatrixType MatrixType; 40 | typedef ReturnByValue Base; 41 | typedef typename Base::Index Index; 42 | 43 | image_retval_base(const DecompositionType& dec, const MatrixType& originalMatrix) 44 | : m_dec(dec), m_rank(dec.rank()), 45 | m_cols(m_rank == 0 ? 1 : m_rank), 46 | m_originalMatrix(originalMatrix) 47 | {} 48 | 49 | inline Index rows() const { return m_dec.rows(); } 50 | inline Index cols() const { return m_cols; } 51 | inline Index rank() const { return m_rank; } 52 | inline const DecompositionType& dec() const { return m_dec; } 53 | inline const MatrixType& originalMatrix() const { return m_originalMatrix; } 54 | 55 | template inline void evalTo(Dest& dst) const 56 | { 57 | static_cast*>(this)->evalTo(dst); 58 | } 59 | 60 | protected: 61 | const DecompositionType& m_dec; 62 | Index m_rank, m_cols; 63 | const MatrixType& m_originalMatrix; 64 | }; 65 | 66 | } // end namespace internal 67 | 68 | #define EIGEN_MAKE_IMAGE_HELPERS(DecompositionType) \ 69 | typedef typename DecompositionType::MatrixType MatrixType; \ 70 | typedef typename MatrixType::Scalar Scalar; \ 71 | typedef typename MatrixType::RealScalar RealScalar; \ 72 | typedef typename MatrixType::Index Index; \ 73 | typedef Eigen::internal::image_retval_base Base; \ 74 | using Base::dec; \ 75 | using Base::originalMatrix; \ 76 | using Base::rank; \ 77 | using Base::rows; \ 78 | using Base::cols; \ 79 | image_retval(const DecompositionType& dec, const MatrixType& originalMatrix) \ 80 | : Base(dec, originalMatrix) {} 81 | 82 | } // end namespace Eigen 83 | 84 | #endif // EIGEN_MISC_IMAGE_H 85 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/misc/Kernel.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Benoit Jacob 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_MISC_KERNEL_H 11 | #define EIGEN_MISC_KERNEL_H 12 | 13 | namespace Eigen { 14 | 15 | namespace internal { 16 | 17 | /** \class kernel_retval_base 18 | * 19 | */ 20 | template 21 | struct traits > 22 | { 23 | typedef typename DecompositionType::MatrixType MatrixType; 24 | typedef Matrix< 25 | typename MatrixType::Scalar, 26 | MatrixType::ColsAtCompileTime, // the number of rows in the "kernel matrix" 27 | // is the number of cols of the original matrix 28 | // so that the product "matrix * kernel = zero" makes sense 29 | Dynamic, // we don't know at compile-time the dimension of the kernel 30 | MatrixType::Options, 31 | MatrixType::MaxColsAtCompileTime, // see explanation for 2nd template parameter 32 | MatrixType::MaxColsAtCompileTime // the kernel is a subspace of the domain space, 33 | // whose dimension is the number of columns of the original matrix 34 | > ReturnType; 35 | }; 36 | 37 | template struct kernel_retval_base 38 | : public ReturnByValue > 39 | { 40 | typedef _DecompositionType DecompositionType; 41 | typedef ReturnByValue Base; 42 | typedef typename Base::Index Index; 43 | 44 | kernel_retval_base(const DecompositionType& dec) 45 | : m_dec(dec), 46 | m_rank(dec.rank()), 47 | m_cols(m_rank==dec.cols() ? 1 : dec.cols() - m_rank) 48 | {} 49 | 50 | inline Index rows() const { return m_dec.cols(); } 51 | inline Index cols() const { return m_cols; } 52 | inline Index rank() const { return m_rank; } 53 | inline const DecompositionType& dec() const { return m_dec; } 54 | 55 | template inline void evalTo(Dest& dst) const 56 | { 57 | static_cast*>(this)->evalTo(dst); 58 | } 59 | 60 | protected: 61 | const DecompositionType& m_dec; 62 | Index m_rank, m_cols; 63 | }; 64 | 65 | } // end namespace internal 66 | 67 | #define EIGEN_MAKE_KERNEL_HELPERS(DecompositionType) \ 68 | typedef typename DecompositionType::MatrixType MatrixType; \ 69 | typedef typename MatrixType::Scalar Scalar; \ 70 | typedef typename MatrixType::RealScalar RealScalar; \ 71 | typedef typename MatrixType::Index Index; \ 72 | typedef Eigen::internal::kernel_retval_base Base; \ 73 | using Base::dec; \ 74 | using Base::rank; \ 75 | using Base::rows; \ 76 | using Base::cols; \ 77 | kernel_retval(const DecompositionType& dec) : Base(dec) {} 78 | 79 | } // end namespace Eigen 80 | 81 | #endif // EIGEN_MISC_KERNEL_H 82 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/misc/Solve.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Benoit Jacob 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_MISC_SOLVE_H 11 | #define EIGEN_MISC_SOLVE_H 12 | 13 | namespace Eigen { 14 | 15 | namespace internal { 16 | 17 | /** \class solve_retval_base 18 | * 19 | */ 20 | template 21 | struct traits > 22 | { 23 | typedef typename DecompositionType::MatrixType MatrixType; 24 | typedef Matrix ReturnType; 30 | }; 31 | 32 | template struct solve_retval_base 33 | : public ReturnByValue > 34 | { 35 | typedef typename remove_all::type RhsNestedCleaned; 36 | typedef _DecompositionType DecompositionType; 37 | typedef ReturnByValue Base; 38 | typedef typename Base::Index Index; 39 | 40 | solve_retval_base(const DecompositionType& dec, const Rhs& rhs) 41 | : m_dec(dec), m_rhs(rhs) 42 | {} 43 | 44 | inline Index rows() const { return m_dec.cols(); } 45 | inline Index cols() const { return m_rhs.cols(); } 46 | inline const DecompositionType& dec() const { return m_dec; } 47 | inline const RhsNestedCleaned& rhs() const { return m_rhs; } 48 | 49 | template inline void evalTo(Dest& dst) const 50 | { 51 | static_cast*>(this)->evalTo(dst); 52 | } 53 | 54 | protected: 55 | const DecompositionType& m_dec; 56 | typename Rhs::Nested m_rhs; 57 | }; 58 | 59 | } // end namespace internal 60 | 61 | #define EIGEN_MAKE_SOLVE_HELPERS(DecompositionType,Rhs) \ 62 | typedef typename DecompositionType::MatrixType MatrixType; \ 63 | typedef typename MatrixType::Scalar Scalar; \ 64 | typedef typename MatrixType::RealScalar RealScalar; \ 65 | typedef typename MatrixType::Index Index; \ 66 | typedef Eigen::internal::solve_retval_base Base; \ 67 | using Base::dec; \ 68 | using Base::rhs; \ 69 | using Base::rows; \ 70 | using Base::cols; \ 71 | solve_retval(const DecompositionType& dec, const Rhs& rhs) \ 72 | : Base(dec, rhs) {} 73 | 74 | } // end namespace Eigen 75 | 76 | #endif // EIGEN_MISC_SOLVE_H 77 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/plugins/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_plugins_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_plugins_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/plugins COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/plugins/CommonCwiseBinaryOps.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2009 Gael Guennebaud 5 | // Copyright (C) 2006-2008 Benoit Jacob 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | // This file is a base class plugin containing common coefficient wise functions. 12 | 13 | /** \returns an expression of the difference of \c *this and \a other 14 | * 15 | * \note If you want to substract a given scalar from all coefficients, see Cwise::operator-(). 16 | * 17 | * \sa class CwiseBinaryOp, operator-=() 18 | */ 19 | EIGEN_MAKE_CWISE_BINARY_OP(operator-,internal::scalar_difference_op) 20 | 21 | /** \returns an expression of the sum of \c *this and \a other 22 | * 23 | * \note If you want to add a given scalar to all coefficients, see Cwise::operator+(). 24 | * 25 | * \sa class CwiseBinaryOp, operator+=() 26 | */ 27 | EIGEN_MAKE_CWISE_BINARY_OP(operator+,internal::scalar_sum_op) 28 | 29 | /** \returns an expression of a custom coefficient-wise operator \a func of *this and \a other 30 | * 31 | * The template parameter \a CustomBinaryOp is the type of the functor 32 | * of the custom operator (see class CwiseBinaryOp for an example) 33 | * 34 | * Here is an example illustrating the use of custom functors: 35 | * \include class_CwiseBinaryOp.cpp 36 | * Output: \verbinclude class_CwiseBinaryOp.out 37 | * 38 | * \sa class CwiseBinaryOp, operator+(), operator-(), cwiseProduct() 39 | */ 40 | template 41 | EIGEN_STRONG_INLINE const CwiseBinaryOp 42 | binaryExpr(const EIGEN_CURRENT_STORAGE_BASE_CLASS &other, const CustomBinaryOp& func = CustomBinaryOp()) const 43 | { 44 | return CwiseBinaryOp(derived(), other.derived(), func); 45 | } 46 | 47 | -------------------------------------------------------------------------------- /linsolve/Eigen/src/plugins/MatrixCwiseUnaryOps.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2009 Gael Guennebaud 5 | // Copyright (C) 2006-2008 Benoit Jacob 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | // This file is a base class plugin containing matrix specifics coefficient wise functions. 12 | 13 | /** \returns an expression of the coefficient-wise absolute value of \c *this 14 | * 15 | * Example: \include MatrixBase_cwiseAbs.cpp 16 | * Output: \verbinclude MatrixBase_cwiseAbs.out 17 | * 18 | * \sa cwiseAbs2() 19 | */ 20 | EIGEN_STRONG_INLINE const CwiseUnaryOp, const Derived> 21 | cwiseAbs() const { return derived(); } 22 | 23 | /** \returns an expression of the coefficient-wise squared absolute value of \c *this 24 | * 25 | * Example: \include MatrixBase_cwiseAbs2.cpp 26 | * Output: \verbinclude MatrixBase_cwiseAbs2.out 27 | * 28 | * \sa cwiseAbs() 29 | */ 30 | EIGEN_STRONG_INLINE const CwiseUnaryOp, const Derived> 31 | cwiseAbs2() const { return derived(); } 32 | 33 | /** \returns an expression of the coefficient-wise square root of *this. 34 | * 35 | * Example: \include MatrixBase_cwiseSqrt.cpp 36 | * Output: \verbinclude MatrixBase_cwiseSqrt.out 37 | * 38 | * \sa cwisePow(), cwiseSquare() 39 | */ 40 | inline const CwiseUnaryOp, const Derived> 41 | cwiseSqrt() const { return derived(); } 42 | 43 | /** \returns an expression of the coefficient-wise inverse of *this. 44 | * 45 | * Example: \include MatrixBase_cwiseInverse.cpp 46 | * Output: \verbinclude MatrixBase_cwiseInverse.out 47 | * 48 | * \sa cwiseProduct() 49 | */ 50 | inline const CwiseUnaryOp, const Derived> 51 | cwiseInverse() const { return derived(); } 52 | 53 | /** \returns an expression of the coefficient-wise == operator of \c *this and a scalar \a s 54 | * 55 | * \warning this performs an exact comparison, which is generally a bad idea with floating-point types. 56 | * In order to check for equality between two vectors or matrices with floating-point coefficients, it is 57 | * generally a far better idea to use a fuzzy comparison as provided by isApprox() and 58 | * isMuchSmallerThan(). 59 | * 60 | * \sa cwiseEqual(const MatrixBase &) const 61 | */ 62 | inline const CwiseUnaryOp >, const Derived> 63 | cwiseEqual(const Scalar& s) const 64 | { 65 | return CwiseUnaryOp >,const Derived> 66 | (derived(), std::bind1st(std::equal_to(), s)); 67 | } 68 | -------------------------------------------------------------------------------- /linsolve/Makefile: -------------------------------------------------------------------------------- 1 | 2 | CC=clang++ 3 | SO=liblinsolve.so 4 | 5 | # CFLAGS= 6 | 7 | HEADERS=\ 8 | exports.h 9 | 10 | CPP=\ 11 | exports.cpp 12 | 13 | OBJ=$(CPP:.cpp=.o) 14 | 15 | all: $(SO) 16 | 17 | clean: 18 | rm -f *.o *.so 19 | 20 | $(SO): $(OBJ) 21 | $(CC) -shared $(OBJ) -o $@ 22 | 23 | %.o: %.cpp $(HEADERS) 24 | $(CC) $(CFLAGS) -c -O3 $*.cpp -o $@ -------------------------------------------------------------------------------- /linsolve/exports.cpp: -------------------------------------------------------------------------------- 1 | #include "exports.h" 2 | #include 3 | #include 4 | #include 5 | 6 | // using namespace std; 7 | using namespace Eigen; 8 | 9 | void cDataToMatrix(int rows, int cols, double* cdata, MatrixXd& mat) 10 | { 11 | mat.resize(rows, cols); 12 | for (int i = 0; i < rows; i++) 13 | { 14 | double* dataP = cdata + i*cols; 15 | VectorXd v(cols); 16 | for (int d = 0; d < cols; d++) 17 | v[d] = dataP[d]; 18 | mat.row(i) = v; 19 | } 20 | } 21 | 22 | extern "C" 23 | { 24 | EXPORT void fullRankGeneral(int rows, int cols, double* A, double* b, double* x) 25 | { 26 | // Convert data in 27 | MatrixXd A_mat; 28 | MatrixXd b_vec; 29 | cDataToMatrix(rows, cols, A, A_mat); 30 | cDataToMatrix(rows, 1, b, b_vec); 31 | 32 | // Solve 33 | VectorXd x_vec = A_mat.colPivHouseholderQr().solve(b_vec); 34 | 35 | // Convert data out 36 | for (int i = 0; i < cols; i++) 37 | x[i] = x_vec(i); 38 | } 39 | 40 | EXPORT void fullRankSemidefinite(int rows, int cols, double* A, double* b, double* x) 41 | { 42 | // Convert data in 43 | MatrixXd A_mat; 44 | MatrixXd b_vec; 45 | cDataToMatrix(rows, cols, A, A_mat); 46 | cDataToMatrix(rows, 1, b, b_vec); 47 | 48 | // Solve 49 | VectorXd x_vec = A_mat.ldlt().solve(b_vec); 50 | 51 | // Convert data out 52 | for (int i = 0; i < cols; i++) 53 | x[i] = x_vec(i); 54 | } 55 | 56 | EXPORT void leastSquares(int rows, int cols, double* A, double* b, double* x) 57 | { 58 | // Convert data in 59 | MatrixXd A_mat; 60 | MatrixXd b_vec; 61 | cDataToMatrix(rows, cols, A, A_mat); 62 | cDataToMatrix(rows, 1, b, b_vec); 63 | 64 | // Solve 65 | VectorXd x_vec = A_mat.jacobiSvd(ComputeThinU | ComputeThinV).solve(b_vec); 66 | 67 | // Convert data out 68 | for (int i = 0; i < cols; i++) 69 | x[i] = x_vec(i); 70 | } 71 | 72 | void pseudoinverse(const MatrixXd& A, MatrixXd& P) 73 | { 74 | JacobiSVD svd(A, ComputeThinU | ComputeThinV); 75 | VectorXd invSingularVals = svd.singularValues(); 76 | const double tolerance = 1e-6; 77 | for (int i = 0; i < invSingularVals.size(); i++) 78 | if (fabs(invSingularVals(i)) > tolerance) 79 | invSingularVals(i) = 1.0/invSingularVals(i); 80 | else 81 | invSingularVals(i) = 0.0; 82 | P = svd.matrixV() * invSingularVals.asDiagonal() * svd.matrixU().transpose(); 83 | } 84 | 85 | EXPORT void nullSpaceProjection(int rows, int cols, double* A, double* x, double* p) 86 | { 87 | // Convert data in 88 | MatrixXd A_mat; 89 | MatrixXd x_vec; 90 | cDataToMatrix(rows, cols, A, A_mat); 91 | cDataToMatrix(cols, 1, x, x_vec); 92 | 93 | // Solve 94 | // ( Orthogonal projector is (I - A^+ * A) ) 95 | MatrixXd A_pinv; 96 | pseudoinverse(A_mat, A_pinv); 97 | VectorXd p_vec = (MatrixXd::Identity(A_mat.cols(), A_mat.cols()) - A_pinv*A_mat) * x_vec; 98 | 99 | // Convert data out 100 | for (int i = 0; i < cols; i++) 101 | p[i] = p_vec(i); 102 | } 103 | } 104 | 105 | 106 | 107 | 108 | 109 | -------------------------------------------------------------------------------- /linsolve/exports.h: -------------------------------------------------------------------------------- 1 | #ifndef __LINSOLVE_H 2 | #define __LINSOLVE_H 3 | 4 | #ifdef _WIN32 5 | #define EXPORT __declspec(dllexport) 6 | #else 7 | #define EXPORT __attribute__ ((visibility ("default"))) 8 | #endif 9 | 10 | #define EXTERN extern "C" { 11 | #ifdef __cplusplus 12 | EXTERN 13 | #endif 14 | 15 | EXPORT void fullRankGeneral(int rows, int cols, double* A, double* b, double* x); 16 | EXPORT void fullRankSemidefinite(int rows, int cols, double* A, double* b, double* x); 17 | EXPORT void leastSquares(int rows, int cols, double* A, double* b, double* x); 18 | 19 | EXPORT void nullSpaceProjection(int rows, int cols, double* A, double* x, double* p); 20 | 21 | #ifdef __cplusplus 22 | } 23 | #endif 24 | 25 | #endif -------------------------------------------------------------------------------- /linsolve/init.t: -------------------------------------------------------------------------------- 1 | local util = require("util") 2 | 3 | local sourcefile = debug.getinfo(1, "S").source:gsub("@", "") 4 | local dir = sourcefile:gsub("init.t", "") 5 | 6 | util.wait(string.format("cd %s; make", dir)) 7 | 8 | local header = sourcefile:gsub("init.t", "exports.h") 9 | local linsolve = terralib.includec(header) 10 | 11 | local lib = sourcefile:gsub("init.t", "liblinsolve.so") 12 | terralib.linklibrary(lib) 13 | 14 | ------------------------------------------------------------ 15 | 16 | local Vector = require("vector") 17 | local Grid2D = require("grid").Grid2D 18 | 19 | -- Wrap solvers in Terra code that handles data conversion 20 | terra leastSquares(A: &Grid2D(double), b: &Vector(double), x: &Vector(double)) 21 | -- x should be as big as A has columns 22 | x:resize(A.cols) 23 | linsolve.leastSquares(A.rows, A.cols, A.data, b.__data, x.__data) 24 | end 25 | terra fullRankGeneral(A: &Grid2D(double), b: &Vector(double), x: &Vector(double)) 26 | x:resize(A.cols) 27 | linsolve.fullRankGeneral(A.rows, A.cols, A.data, b.__data, x.__data) 28 | end 29 | terra fullRankSemidefinite(A: &Grid2D(double), b: &Vector(double), x: &Vector(double)) 30 | x:resize(A.cols) 31 | linsolve.fullRankSemidefinite(A.rows, A.cols, A.data, b.__data, x.__data) 32 | end 33 | terra nullSpaceProjection(A: &Grid2D(double), x: &Vector(double), p: &Vector(double)) 34 | p:resize(A.cols) 35 | linsolve.nullSpaceProjection(A.rows, A.cols, A.data, x.__data, p.__data) 36 | end 37 | 38 | local _module = 39 | { 40 | leastSquares = leastSquares, 41 | fullRankGeneral = fullRankGeneral, 42 | fullRankSemidefinite = fullRankSemidefinite, 43 | nullSpaceProjection = nullSpaceProjection 44 | } 45 | 46 | --------- TESTS ---------- 47 | 48 | -- local m = require("mem") 49 | -- local C = terralib.includecstring [[ 50 | -- #include 51 | -- #include 52 | -- ]] 53 | 54 | -- local errThresh = 1e-6 55 | -- local checkVal = macro(function(actual, target) 56 | -- return quote 57 | -- var err = C.fabs(actual-target) 58 | -- util.assert(err < errThresh, "Value was %g, should've been %g\n", actual, target) 59 | -- end 60 | -- end) 61 | 62 | -- local terra tests() 63 | 64 | -- -- Fully determined 65 | -- var A = [Grid2D(double)].stackAlloc(2, 2) 66 | -- A(0,0) = 1.0; A(0,1) = 2.0; 67 | -- A(1,0) = 3.0; A(1,1) = 4.0; 68 | -- var b = [Vector(double)].stackAlloc(2, 0.0) 69 | -- b(0) = 1.0; b(1) = 1.0; 70 | -- var x = [Vector(double)].stackAlloc() 71 | -- leastSquares(&A, &b, &x) 72 | -- checkVal(x(0), -1.0) 73 | -- checkVal(x(1), 1.0) 74 | 75 | -- -- Fully determined, full rank solver 76 | -- fullRankGeneral(&A, &b, &x) 77 | -- checkVal(x(0), -1.0) 78 | -- checkVal(x(1), 1.0) 79 | 80 | -- -- Under-determined 81 | -- A:resize(2, 3) 82 | -- A(0,0) = 1.0; A(0,1) = 2.0; A(0,2) = 3.0; 83 | -- A(1,0) = 4.0; A(1,1) = 5.0; A(1,2) = 6.0; 84 | -- leastSquares(&A, &b, &x) 85 | -- checkVal(x(0), -0.5) 86 | -- checkVal(x(1), 0.0) 87 | -- checkVal(x(2), 0.5) 88 | 89 | -- -- Over-determined 90 | -- A:resize(3, 2) 91 | -- A(0,0) = 1.0; A(0,1) = 2.5; 92 | -- A(1,0) = 3.0; A(1,1) = 4.0; 93 | -- A(2,0) = 5.0; A(2,1) = 6.0; 94 | -- b:resize(3); 95 | -- b(0) = 1.0; b(1) = 1.0; b(2) = 1.0; 96 | -- leastSquares(&A, &b, &x) 97 | -- checkVal(x(0), -5.470085470085458e-01) 98 | -- checkVal(x(1), 6.324786324786315e-01) 99 | 100 | -- m.destruct(b) 101 | -- m.destruct(x) 102 | -- m.destruct(A) 103 | -- end 104 | 105 | -- tests() 106 | 107 | ------------------------- 108 | 109 | return _module 110 | 111 | 112 | 113 | 114 | 115 | 116 | -------------------------------------------------------------------------------- /lpsolve/init.t: -------------------------------------------------------------------------------- 1 | local util = require("util") 2 | 3 | 4 | local sourcefile = debug.getinfo(1, "S").source:gsub("@", "") 5 | local header = sourcefile:gsub("init.t", "lp_lib.h") 6 | 7 | local lpsolve = terralib.includecstring(string.format([[ 8 | #define LPSOLVEAPIFROMLIB 9 | #include "%s" 10 | 11 | // Expose frequently-used constants 12 | inline int _LE() { return LE; } 13 | inline int _EQ() { return EQ; } 14 | inline int _GE() { return GE; } 15 | inline int _NOMEMORY() { return NOMEMORY; } 16 | inline int _OPTIMAL() { return OPTIMAL; } 17 | inline int _SUBOPTIMAL() { return SUBOPTIMAL; } 18 | inline int _INFEASIBLE() { return INFEASIBLE; } 19 | inline int _UNBOUNDED() { return UNBOUNDED; } 20 | inline int _DEGENERATE() { return DEGENERATE; } 21 | inline int _NUMFAILURE() { return NUMFAILURE; } 22 | ]], header)) 23 | 24 | lpsolve.LE = lpsolve._LE() 25 | lpsolve.EQ = lpsolve._EQ() 26 | lpsolve.GE = lpsolve._GE() 27 | lpsolve.NOMEMORY = lpsolve._NOMEMORY() 28 | lpsolve.OPTIMAL = lpsolve._OPTIMAL() 29 | lpsolve.SUBOPTIMAL = lpsolve._SUBOPTIMAL() 30 | lpsolve.INFEASIBLE = lpsolve._INFEASIBLE() 31 | lpsolve.UNBOUNDED = lpsolve._UNBOUNDED() 32 | lpsolve.DEGENERATE = lpsolve._DEGENERATE() 33 | lpsolve.NUMFAILURE = lpsolve._NUMFAILURE() 34 | 35 | local dylib = sourcefile:gsub("init.t", "liblpsolve55.dylib") 36 | terralib.linklibrary(dylib) 37 | 38 | 39 | -- terra test() 40 | -- -- Make lp with no constraints and 2 variables 41 | -- var lp = lpsolve.make_lp(0, 2) 42 | 43 | -- lpsolve.set_verbose(lp, 0) 44 | 45 | -- -- Bound the first variable between -1 and 1 46 | -- lpsolve.set_lowbo(lp, 0, -1.0) 47 | -- lpsolve.set_upbo(lp, 0, 1.0) 48 | 49 | -- -- Constrain the sum of the two variables to be 0.5 50 | -- -- (first element of the array has to be zero, apparently.) 51 | -- var coeffs = array(0.0, 1.0, 1.0) 52 | -- lpsolve.add_constraint(lp, coeffs, lpsolve.EQ, 0.5) 53 | 54 | -- -- Going to try *not* setting the objective function, since 55 | -- -- I only care about feasibility testing. Hopefully this 56 | -- -- will work OK... 57 | 58 | -- lpsolve.solve(lp) 59 | 60 | -- lpsolve.print_objective(lp) 61 | -- lpsolve.print_solution(lp, 1) 62 | -- lpsolve.print_constraints(lp, 1) 63 | -- end 64 | -- test() 65 | 66 | -- terra test2() 67 | -- var lp = lpsolve.make_lp(0, 2) 68 | -- lpsolve.set_verbose(lp, 0) 69 | -- lpsolve.set_unbounded(lp, 1) 70 | -- lpsolve.set_unbounded(lp, 2) 71 | -- var coeffs = array(0.0, 0.434531353, -0.659648752) 72 | -- lpsolve.add_constraint(lp, coeffs, lpsolve.EQ, 0.0) 73 | -- coeffs = array(0.0, 1.17452234, -1.639203) 74 | -- lpsolve.add_constraint(lp, coeffs, lpsolve.EQ, 1.0) 75 | -- lpsolve.solve(lp) 76 | -- lpsolve.print_solution(lp, 1) 77 | -- end 78 | -- test2() 79 | 80 | 81 | return lpsolve 82 | -------------------------------------------------------------------------------- /lpsolve/liblpsolve55.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dritchie/terra-utils/2857e8eea5df0cffd647b736ea9a681a37ffcada/lpsolve/liblpsolve55.dylib -------------------------------------------------------------------------------- /lpsolve/lp_Hash.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_lp_hash 2 | #define HEADER_lp_hash 3 | 4 | /* For row and column name hash tables */ 5 | 6 | typedef struct _hashelem 7 | { 8 | char *name; 9 | int index; 10 | struct _hashelem *next; 11 | struct _hashelem *nextelem; 12 | } hashelem; 13 | 14 | typedef struct /* _hashtable */ 15 | { 16 | hashelem **table; 17 | int size; 18 | int base; 19 | int count; 20 | struct _hashelem *first; 21 | struct _hashelem *last; 22 | } hashtable; 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | STATIC hashtable *create_hash_table(int size, int base); 29 | STATIC void free_hash_table(hashtable *ht); 30 | STATIC hashelem *findhash(const char *name, hashtable *ht); 31 | STATIC hashelem *puthash(const char *name, int index, hashelem **list, hashtable *ht); 32 | STATIC void drophash(const char *name, hashelem **list, hashtable *ht); 33 | STATIC void free_hash_item(hashelem **hp); 34 | STATIC hashtable *copy_hash_table(hashtable *ht, hashelem **list, int newsize); 35 | STATIC int find_var(lprec *lp, char *name, MYBOOL verbose); 36 | STATIC int find_row(lprec *lp, char *name, MYBOOL Unconstrained_rows_found); 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | 42 | #endif /* HEADER_lp_hash */ 43 | 44 | -------------------------------------------------------------------------------- /lpsolve/lp_mipbb.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_lp_mipbb 2 | #define HEADER_lp_mipbb 3 | 4 | #include "lp_types.h" 5 | #include "lp_utils.h" 6 | 7 | 8 | /* Bounds storage for B&B routines */ 9 | typedef struct _BBrec 10 | { 11 | struct _BBrec *parent; 12 | struct _BBrec *child; 13 | lprec *lp; 14 | int varno; 15 | int vartype; 16 | int lastvarcus; /* Count of non-int variables of the previous branch */ 17 | int lastrcf; 18 | int nodesleft; 19 | int nodessolved; 20 | int nodestatus; 21 | REAL noderesult; 22 | REAL lastsolution; /* Optimal solution of the previous branch */ 23 | REAL sc_bound; 24 | REAL *upbo, *lowbo; 25 | REAL UPbound, LObound; 26 | int UBtrack, LBtrack; /* Signals that incoming bounds were changed */ 27 | MYBOOL contentmode; /* Flag indicating if we "own" the bound vectors */ 28 | MYBOOL sc_canset; 29 | MYBOOL isSOS; 30 | MYBOOL isGUB; 31 | int *varmanaged; /* Extended list of variables managed by this B&B level */ 32 | MYBOOL isfloor; /* State variable indicating the active B&B bound */ 33 | MYBOOL UBzerobased; /* State variable indicating if bounds have been rebased */ 34 | } BBrec; 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | STATIC BBrec *create_BB(lprec *lp, BBrec *parentBB, MYBOOL dofullcopy); 41 | STATIC BBrec *push_BB(lprec *lp, BBrec *parentBB, int varno, int vartype, int varcus); 42 | STATIC MYBOOL initbranches_BB(BBrec *BB); 43 | STATIC MYBOOL fillbranches_BB(BBrec *BB); 44 | STATIC MYBOOL nextbranch_BB(BBrec *BB); 45 | STATIC MYBOOL strongbranch_BB(lprec *lp, BBrec *BB, int varno, int vartype, int varcus); 46 | STATIC MYBOOL initcuts_BB(lprec *lp); 47 | STATIC int updatecuts_BB(lprec *lp); 48 | STATIC MYBOOL freecuts_BB(lprec *lp); 49 | STATIC BBrec *findself_BB(BBrec *BB); 50 | STATIC int solve_LP(lprec *lp, BBrec *BB); 51 | STATIC int rcfbound_BB(BBrec *BB, int varno, MYBOOL isINT, REAL *newbound, MYBOOL *isfeasible); 52 | STATIC MYBOOL findnode_BB(BBrec *BB, int *varno, int *vartype, int *varcus); 53 | STATIC int solve_BB(BBrec *BB); 54 | STATIC MYBOOL free_BB(BBrec **BB); 55 | STATIC BBrec *pop_BB(BBrec *BB); 56 | 57 | STATIC int run_BB(lprec *lp); 58 | 59 | #ifdef __cplusplus 60 | } 61 | #endif 62 | 63 | #endif /* HEADER_lp_mipbb */ 64 | 65 | -------------------------------------------------------------------------------- /templatize.t: -------------------------------------------------------------------------------- 1 | local m = require("mem") 2 | local util = require("util") 3 | 4 | local TemplatizedEntity = {} 5 | 6 | function TemplatizedEntity:new(creationFn) 7 | local newobj = 8 | { 9 | creationFn = creationFn, 10 | cache = {} 11 | } 12 | setmetatable(newobj, self) 13 | self.__index = self 14 | return newobj 15 | end 16 | 17 | function TemplatizedEntity:__explicit(...) 18 | local key = util.stringify(...) 19 | local val = self.cache[key] 20 | if not val then 21 | val = self.creationFn(...) 22 | if terralib.types.istype(val) and val:isstruct() then 23 | -- Record the template and parameters that this came from 24 | val.__generatorTemplate = self 25 | val.__templateParams = {...} 26 | -- Store the fully parameterized name of this type 27 | -- TODO: Move this into the struct username, once Zach 28 | -- makes that an option. 29 | local stringRep = string.format("%s(", tostring(val)) 30 | for i=1,#val.__templateParams-1 do 31 | stringRep = string.format("%s%s,", stringRep, val.__templateParams[i]) 32 | end 33 | stringRep = string.format("%s%s)", stringRep, val.__templateParams[#val.__templateParams]) 34 | val.__fullName = stringRep 35 | end 36 | self.cache[key] = val 37 | end 38 | return val 39 | end 40 | 41 | function TemplatizedEntity:__implicit(...) 42 | local types = {} 43 | for i=1,select("#",...) do 44 | table.insert(types, (select(i,...)):gettype()) 45 | end 46 | local spec = self:__explicit(unpack(types)) 47 | if terralib.isfunction(spec) or 48 | (terralib.typeof(spec):isstruct() and terralib.typeof(spec).metamethods.__apply) then 49 | local args = {} 50 | for i=1,select("#",...) do table.insert(args, (select(i,...))) end 51 | return `spec([args]) 52 | else 53 | print(debug.traceback("Inferred templatize specialization but could not call resulting value.")) 54 | error(string.format()) 55 | end 56 | end 57 | 58 | -- Apply is like implicit, but for calling the specialized 59 | -- function from Lua code. 60 | function TemplatizedEntity:apply(...) 61 | local types = {} 62 | for i=1,select("#",...) do 63 | table.insert(types, terralib.typeof(select(i,...))) 64 | end 65 | local spec = self:__explicit(unpack(types)) 66 | return m.gc(spec(...)) 67 | end 68 | 69 | function TemplatizedEntity:__call(...) 70 | return self:__explicit(...) 71 | end 72 | 73 | local function templatize(creationFn) 74 | local tent = TemplatizedEntity:new(creationFn) 75 | 76 | -- The templatized function takes types as arguments 77 | -- and explicitly returns the specialized result for those types 78 | local explicit = tent 79 | 80 | -- It is also possible to call the function on values, for which 81 | -- the types will be inferred and the specialization retrieved 82 | -- implicitly. 83 | -- NOTE: This only works if there is one template type for each argument, 84 | -- and the argument types match the template types. 85 | local implicit = macro(function(...) 86 | return tent:__implicit(...) 87 | end) 88 | 89 | -- You can switch between these two options freely 90 | explicit.explicit = explicit 91 | implicit.explicit = explicit 92 | explicit.implicit = implicit 93 | implicit.implicit = implicit 94 | 95 | 96 | -- We default to the explicit version 97 | return explicit 98 | end 99 | 100 | return templatize 101 | --------------------------------------------------------------------------------