├── CMakeLists.txt ├── README.md ├── bin └── .gitignore ├── matlab ├── parsePfm.m ├── plot_ctf.m ├── read_pfm.m ├── vis_HDR.m └── vis_pfm_diff.m └── src ├── CTF.cpp ├── CTF.h ├── CTFSolver.cpp ├── CTFSolver.h ├── Eigen ├── Array ├── CMakeFiles │ ├── CMakeDirectoryInformation.cmake │ └── progress.marks ├── Cholesky ├── Core ├── Dense ├── Eigen ├── Eigen2Support ├── Eigenvalues ├── Geometry ├── Householder ├── Jacobi ├── LU ├── LeastSquares ├── Makefile ├── QR ├── QtAlignedMalloc ├── SVD ├── Sparse ├── StdDeque ├── StdList ├── StdVector ├── cmake_install.cmake └── src │ ├── Cholesky │ ├── LDLT.h │ └── LLT.h │ ├── Core │ ├── Array.h │ ├── ArrayBase.h │ ├── ArrayWrapper.h │ ├── Assign.h │ ├── BandMatrix.h │ ├── Block.h │ ├── BooleanRedux.h │ ├── CommaInitializer.h │ ├── CwiseBinaryOp.h │ ├── CwiseNullaryOp.h │ ├── CwiseUnaryOp.h │ ├── CwiseUnaryView.h │ ├── DenseBase.h │ ├── DenseCoeffsBase.h │ ├── DenseStorage.h │ ├── Diagonal.h │ ├── DiagonalMatrix.h │ ├── DiagonalProduct.h │ ├── Dot.h │ ├── EigenBase.h │ ├── Flagged.h │ ├── ForceAlignedAccess.h │ ├── Functors.h │ ├── Fuzzy.h │ ├── GenericPacketMath.h │ ├── GlobalFunctions.h │ ├── IO.h │ ├── Map.h │ ├── MapBase.h │ ├── MathFunctions.h │ ├── Matrix.h │ ├── MatrixBase.h │ ├── NestByValue.h │ ├── NoAlias.h │ ├── NumTraits.h │ ├── PermutationMatrix.h │ ├── PlainObjectBase.h │ ├── Product.h │ ├── ProductBase.h │ ├── Random.h │ ├── Redux.h │ ├── Replicate.h │ ├── ReturnByValue.h │ ├── Reverse.h │ ├── Select.h │ ├── SelfAdjointView.h │ ├── SelfCwiseBinaryOp.h │ ├── SolveTriangular.h │ ├── StableNorm.h │ ├── Stride.h │ ├── Swap.h │ ├── Transpose.h │ ├── Transpositions.h │ ├── TriangularMatrix.h │ ├── VectorBlock.h │ ├── VectorwiseOp.h │ ├── Visitor.h │ ├── arch │ │ ├── AltiVec │ │ │ ├── CMakeLists.txt │ │ │ ├── Complex.h │ │ │ └── PacketMath.h │ │ ├── CMakeLists.txt │ │ ├── Default │ │ │ ├── CMakeLists.txt │ │ │ └── Settings.h │ │ ├── NEON │ │ │ ├── CMakeLists.txt │ │ │ ├── Complex.h │ │ │ └── PacketMath.h │ │ └── SSE │ │ │ ├── CMakeLists.txt │ │ │ ├── Complex.h │ │ │ ├── MathFunctions.h │ │ │ └── PacketMath.h │ ├── products │ │ ├── CMakeLists.txt │ │ ├── CoeffBasedProduct.h │ │ ├── GeneralBlockPanelKernel.h │ │ ├── GeneralMatrixMatrix.h │ │ ├── GeneralMatrixMatrixTriangular.h │ │ ├── GeneralMatrixVector.h │ │ ├── Parallelizer.h │ │ ├── SelfadjointMatrixMatrix.h │ │ ├── SelfadjointMatrixVector.h │ │ ├── SelfadjointProduct.h │ │ ├── SelfadjointRank2Update.h │ │ ├── TriangularMatrixMatrix.h │ │ ├── TriangularMatrixVector.h │ │ ├── TriangularSolverMatrix.h │ │ └── TriangularSolverVector.h │ └── util │ │ ├── BlasUtil.h │ │ ├── CMakeLists.txt │ │ ├── Constants.h │ │ ├── DisableStupidWarnings.h │ │ ├── ForwardDeclarations.h │ │ ├── Macros.h │ │ ├── Memory.h │ │ ├── Meta.h │ │ ├── ReenableStupidWarnings.h │ │ ├── StaticAssert.h │ │ └── XprHelper.h │ ├── Eigen2Support │ ├── Block.h │ ├── 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 │ ├── ComplexEigenSolver.h │ ├── ComplexSchur.h │ ├── EigenSolver.h │ ├── EigenvaluesCommon.h │ ├── GeneralizedSelfAdjointEigenSolver.h │ ├── HessenbergDecomposition.h │ ├── MatrixBaseEigenvalues.h │ ├── RealSchur.h │ ├── SelfAdjointEigenSolver.h │ └── Tridiagonalization.h │ ├── Geometry │ ├── AlignedBox.h │ ├── AngleAxis.h │ ├── EulerAngles.h │ ├── Homogeneous.h │ ├── Hyperplane.h │ ├── OrthoMethods.h │ ├── ParametrizedLine.h │ ├── Quaternion.h │ ├── Rotation2D.h │ ├── RotationBase.h │ ├── Scaling.h │ ├── Transform.h │ ├── Translation.h │ ├── Umeyama.h │ └── arch │ │ ├── CMakeLists.txt │ │ └── Geometry_SSE.h │ ├── Householder │ ├── BlockHouseholder.h │ ├── Householder.h │ └── HouseholderSequence.h │ ├── Jacobi │ └── Jacobi.h │ ├── LU │ ├── Determinant.h │ ├── FullPivLU.h │ ├── Inverse.h │ ├── PartialPivLU.h │ └── arch │ │ ├── CMakeLists.txt │ │ └── Inverse_SSE.h │ ├── QR │ ├── ColPivHouseholderQR.h │ ├── FullPivHouseholderQR.h │ └── HouseholderQR.h │ ├── SVD │ ├── JacobiSVD.h │ └── UpperBidiagonalization.h │ ├── Sparse │ ├── AmbiVector.h │ ├── CompressedStorage.h │ ├── CoreIterators.h │ ├── DynamicSparseMatrix.h │ ├── MappedSparseMatrix.h │ ├── SparseAssign.h │ ├── SparseBlock.h │ ├── SparseCwiseBinaryOp.h │ ├── SparseCwiseUnaryOp.h │ ├── SparseDenseProduct.h │ ├── SparseDiagonalProduct.h │ ├── SparseDot.h │ ├── SparseFuzzy.h │ ├── SparseMatrix.h │ ├── SparseMatrixBase.h │ ├── SparseProduct.h │ ├── SparseRedux.h │ ├── SparseSelfAdjointView.h │ ├── SparseSparseProduct.h │ ├── SparseTranspose.h │ ├── SparseTriangularView.h │ ├── SparseUtil.h │ ├── SparseVector.h │ ├── SparseView.h │ └── TriangularSolver.h │ ├── StlSupport │ ├── StdDeque.h │ ├── StdList.h │ ├── StdVector.h │ └── details.h │ ├── misc │ ├── Image.h │ ├── Kernel.h │ └── Solve.h │ └── plugins │ ├── ArrayCwiseBinaryOps.h │ ├── ArrayCwiseUnaryOps.h │ ├── BlockMethods.h │ ├── CommonCwiseBinaryOps.h │ ├── CommonCwiseUnaryOps.h │ ├── MatrixCwiseBinaryOps.h │ └── MatrixCwiseUnaryOps.h ├── LinearRegression.h ├── WeightingFunctions.cpp ├── WeightingFunctions.h ├── cimg └── CImg.h ├── main.cpp └── mainHDRMake.cpp /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #Main CMAKE file 2 | #Program to recover a camera transfer function. 3 | #Currently only works on 8 bit cameras; this could however be generalized to N-bit sensors. 4 | # 5 | #Implements a slightly modified version of the 1997 paper 6 | #"Recovering High Dynamic Range Radiance Maps from Photographs" 7 | #by Debevec and Malik 8 | # 9 | #Colin Braley 10 | #Initial revision - May 15 2012 11 | #Added code to make HDR images(replaces my old HDR code) - May 21 2012 12 | 13 | #The basics 14 | cmake_minimum_required(VERSION 2.6) 15 | project(CTFSolve) 16 | set(CMAKE_VERBOSE_MAKEFILE OFF) 17 | 18 | #Application for finding camera CTF functions 19 | set(CTF_SRCS src/main.cpp src/CTFSolver.cpp src/CTF.cpp) 20 | set(CTF_APP bin/ctf_find ) 21 | 22 | #Application for making HDR images from exposure stacks 23 | set(HDR_MAKE_SRCS src/mainHDRMake.cpp src/CTF.cpp src/CTFSolver.cpp src/WeightingFunctions.cpp) 24 | set(HDR_MAKE_APP bin/hdr_make ) 25 | 26 | #To build in debug mode change BUILD_TYPE to "Debug" 27 | set(BUILD_TYPE Release ) 28 | 29 | #Compiler flags 30 | #TODO: The below code only works with G++ 31 | IF(CMAKE_COMPILER_IS_GNUCC) 32 | #set(CMAKE_CXX_FLAGS "-fpermissive") #Permissive only needed for Eigen library issues.... 33 | 34 | #Always use -Wall and enable SSE 3 vector instructions 35 | set(CMAKE_CXX_FLAGS "-Wall -msse3") 36 | 37 | #In debug mode, don't optimize, output debugger symbols, and don't inline 38 | set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -fno-inline") 39 | 40 | #In release mode, allow inlining, enable OpenMP and turn off assertions 41 | set(CMAKE_CXX_FLAGS_RELEASE "-O3 -finline-functions -fopenmp -D NDEBUG") 42 | ELSE(CMAKE_COMPILER_IS_GNUCC) 43 | MESSAGE(FATAL_ERROR "This CMake file only works with g++!") 44 | ENDIF(CMAKE_COMPILER_IS_GNUCC) 45 | 46 | #Executables to create 47 | set(CMAKE_BUILD_TYPE ${BUILD_TYPE}) 48 | 49 | #------------------------------------------------------------- 50 | #Typically should not need to modify below this line---------- 51 | #------------------------------------------------------------- 52 | add_executable(${CTF_APP} ${CTF_SRCS} ) 53 | add_executable(${HDR_MAKE_APP} ${HDR_MAKE_SRCS}) 54 | 55 | MESSAGE( STATUS "----------------------------------------") 56 | MESSAGE( STATUS "\tBuild type: ${CMAKE_BUILD_TYPE}" ) 57 | MESSAGE( STATUS "\tCXX Flags: ${CMAKE_CXX_FLAGS}" ) 58 | MESSAGE( STATUS "----------------------------------------") 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | hdr 2 | === 3 | 4 | C++ code for finding camera response functions(CTFs) and creating HDR images. Implements the 1997 paper "Recovering High Dynamic Range Radiance Maps from Photographs". 5 | 6 | 7 | Uses the [Eigen](http://eigen.tuxfamily.org/index.php?title=Main_Page) library for linear algebra. 8 | 9 | 10 | Current TODO list: 11 | * Make code fail gracefully when run with images that don't exist. 12 | * Include second executable for creating HDR images(this code here just creates the response curve) 13 | * Include a few example images w/ response curves and info on how to use this 14 | * Stratified sampling of the image; not pure random 15 | * Account for pixel bloom 16 | * Make sure code does not crash if system is under-determined. Print warning to use to raise num_samples if system is under-determined. Also, warn if regularization term will dominate fitting term. 17 | -------------------------------------------------------------------------------- /bin/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbraley/hdr/1453818cc97eb498effa1a32f751972bdd135ab3/bin/.gitignore -------------------------------------------------------------------------------- /matlab/parsePfm.m: -------------------------------------------------------------------------------- 1 | function [img, scaleFactor] = parsePfm(filePath) 2 | %parsePfm Parses .pfm images. 3 | % Bring a .pfm image into matlab. 4 | 5 | %Open the file and check for errors 6 | fid = fopen(filePath, 'r'); 7 | if fid == -1 8 | error('pfm:IOError', 'Could not open file!'); 9 | end 10 | 11 | %File opened OK 12 | % 13 | %.pfm headers have 3 ASCII lines 14 | %Line 1: The text 'PF' or 'Pf' where the former denotes color and the 15 | % latter denotes grayscale 16 | %Line 2: Two integers, width then height. 17 | %Line 3: A single signed decimal number S 18 | % is S < 0 then the file is little endian 19 | % otherwise the file is big endian 20 | % |S| is a scale factor to relate pixel samples to a physical 21 | % quantity(like radiance for example). 22 | % 23 | 24 | %Info to determine during header parse 25 | numChannels = 0; %1 = grayscale, 3 = RGB 26 | imWidth = 0; 27 | imHeight = 0; 28 | isBigEndian = 0; 29 | scaleFactor = 1; %Described above, ignored by this code for now 30 | 31 | %Read the whole 3 line header 32 | line1 = fgetl(fid); 33 | line2 = fgetl(fid); 34 | line3 = fgetl(fid); 35 | if ~(ischar(line1) && ischar(line2) && ischar(line3)) 36 | fclose(fid); 37 | error('pfm:IOError', 'Header was incomplete!'); 38 | end 39 | 40 | %Parse line 1, determine color or BW 41 | if strcmp(line1, 'PF') == 1 %Color 42 | numChannels = 3; 43 | elseif strcmp(line1, 'Pf') == 1 %Gray 44 | numChannels = 1; 45 | else %Invalid header 46 | fclose(fid); 47 | error('pfm:IOError', 'Invalid .pfm header!'); 48 | end 49 | 50 | %Parse line 2, get image dims 51 | [dims, foundCount, errMsg] = sscanf(line2, '%u %u'); 52 | if numel(dims) ~= 2 || strcmp(errMsg,'') ~= 1 || foundCount ~= 2 53 | fclose(fid); 54 | error('pfm:IOError', 'Dimensions line was malformed!'); 55 | end 56 | imWidth = dims(1); 57 | imHeight = dims(2); 58 | 59 | %Line 3, the endianness+scale line 60 | [scale, matchCount, errMsg] = sscanf(line3, '%f'); 61 | if matchCount ~= 1 || strcmp(errMsg,'') ~= 1 62 | fclose(fid); 63 | error('pfm:IOError', 'Endianness+Scale line was malformed!'); 64 | end 65 | scaleFactor = abs(scale); 66 | endianChar = 'n'; 67 | if scale < 0.0 68 | isBigEndian = 0; 69 | endianChar = 'l'; 70 | else 71 | isBigEndian = 1; 72 | endianChar = 'b'; 73 | end 74 | 75 | %Allocate image buffer 76 | img = zeros(imWidth, imHeight, numChannels); 77 | totElems = numel(img); 78 | 79 | %Now at last parse in the pixel raster 80 | %the raster is a 4 byte valeues arranged left to right, starting in the 81 | %upper left corner of the image. In the case of a color image, 82 | %channels are interleaved 83 | [rawData, numFloatsRead] = fread(fid, totElems, 'single', 0, endianChar); 84 | if numFloatsRead ~= totElems 85 | fclose(fid); 86 | error('pfm:IOError', 'Raster data did not match header!'); 87 | end 88 | fclose(fid); 89 | 90 | %Put the data into the output buffer after re-shaping to match Matlab's 91 | %ordering and color channel order. 92 | imDataInReadOrder = reshape(rawData, [numChannels, imWidth, imHeight]); 93 | img = permute(imDataInReadOrder, [3, 2, 1]); 94 | 95 | end 96 | -------------------------------------------------------------------------------- /matlab/plot_ctf.m: -------------------------------------------------------------------------------- 1 | function [] = plot_ctf(ctfFile, pointsFile) 2 | %PLOT_CTF Plot CTF and (optionally) the points used to generate it. 3 | % ctfFile is the path to the CTF data. 4 | % pointsFile is the path to the points data. Use '' to ignore this 5 | % parameter. 6 | 7 | %Constants 8 | LINE_W = 3; 9 | LINE_COLOR = [0 0 0]; 10 | DOT_SIZE = 5; 11 | DOT_COLOR = [0 0 1]; 12 | FONT_SIZE = 24; 13 | PERC = .1; 14 | 15 | %Maybe plot the points 16 | hold on; 17 | if strcmp(pointsFile, '') ~= 1 18 | points = load(pointsFile); 19 | plot(points(:,1), points(:,2), 'o', 'MarkerEdgeColor', DOT_COLOR, ... 20 | 'MarkerSize', DOT_SIZE); 21 | end 22 | 23 | %Plot the CTF 24 | pix_vals = 0:255; 25 | ctf = load(ctfFile); 26 | plot(pix_vals, ctf, '-', 'LineWidth', LINE_W, 'Color', LINE_COLOR); 27 | 28 | 29 | %Make the plot pretty 30 | t = title(sprintf('CTF From file: %s', ctfFile)); 31 | set(t, 'FontSize', FONT_SIZE); 32 | axis tight; 33 | grid on; 34 | grid minor; 35 | t = xlabel('8 bit pixel values'); 36 | set(t, 'FontSize', FONT_SIZE); 37 | t = ylabel('Exposure'); 38 | set(t, 'FontSize', FONT_SIZE); 39 | hold off; 40 | 41 | %Make the plot fit the CTF well 42 | ctfMin = min(ctf); 43 | ctfMax = max(ctf); 44 | ctfRange = ctfMax - ctfMin; 45 | ylim([ctfMin - (PERC * ctfRange), ctfMax + (PERC * ctfRange)]); 46 | 47 | 48 | end 49 | 50 | -------------------------------------------------------------------------------- /matlab/read_pfm.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbraley/hdr/1453818cc97eb498effa1a32f751972bdd135ab3/matlab/read_pfm.m -------------------------------------------------------------------------------- /matlab/vis_HDR.m: -------------------------------------------------------------------------------- 1 | function [] = vis_HDR(hdrPfmPath, Npath, residualPath ) 2 | %VISUALZE_HDR_RESULTS Visaulize output of gen_hdr. 3 | % hdrPfmPath is a path to a HDR .pfm image. May be '' to skip. 4 | % Npath is a path to a LDR image generated via --out_n . May be '' to skip. 5 | % residualPath is a path to a LDR image generated via --out_r . May be '' to skip. 6 | 7 | FONT_SIZE = 24; 8 | 9 | %Potentially show the monochrome HDR 10 | if( strcmp(hdrPfmPath,'') ~= 1) 11 | hdr = parsePfm(hdrPfmPath); 12 | figure; 13 | 14 | %Check for RGB (unsupported) 15 | if( size(hdr,3) ~= 1) 16 | fprintf('Error - Only monochrome HDRs are currently supported!'); 17 | return; 18 | end 19 | 20 | hm = HeatMap(hdr); 21 | %colormap jet; 22 | %colorbar; 23 | %axis image; 24 | t = addTitle(hm, sprintf('HDR image from %s',hdrPfmPath)); 25 | set(t, 'FontSize', FONT_SIZE); 26 | end 27 | 28 | %Potentialyl show # samples 29 | if( strcmp(Npath,'') ~= 1) 30 | im = imread(Npath); 31 | figure; 32 | image(im,'CDataMapping','scaled'); 33 | temp = colormap('jet'); 34 | colormap(flipud(temp)); 35 | colorbar; 36 | axis image; 37 | t = title(sprintf('Num Valid HDR samples visualization from %s',Npath)); 38 | set(t, 'FontSize', FONT_SIZE); 39 | end 40 | 41 | %Plot residual 42 | if( strcmp(residualPath,'') ~= 1) 43 | im = parsePfm(residualPath); 44 | figure; 45 | %image(im,'CDataMapping','scaled'); 46 | hm = HeatMap(im); 47 | %colormap jet; 48 | %colorbar; 49 | %axis image; 50 | t = addTitle(hm, sprintf('Residual visualization from: %s',residualPath)); 51 | set(t, 'FontSize', FONT_SIZE); 52 | end 53 | 54 | 55 | end 56 | 57 | -------------------------------------------------------------------------------- /matlab/vis_pfm_diff.m: -------------------------------------------------------------------------------- 1 | function [] = vis_pfm_diff(pfmAPath, pfmBPath) 2 | %VIS_PFM_DIFF Visualize percent difference between PDMs 3 | 4 | FONT_SIZE = 24; 5 | 6 | a = parsePfm(pfmAPath); 7 | b = parsePfm(pfmBPath); 8 | 9 | diff = abs(a - b); 10 | maxAbsVal = max( max(abs(a(:))), max(abs(b(:))) ); 11 | 12 | imshow((diff / maxAbsVal) * 100.0); 13 | colorbar; 14 | colormap jet; 15 | t = title('Absolute percent diff'); 16 | 17 | 18 | end 19 | 20 | -------------------------------------------------------------------------------- /src/CTF.cpp: -------------------------------------------------------------------------------- 1 | #include "CTF.h" 2 | //-- 3 | #include 4 | #include 5 | 6 | CTF::CTF(){ 7 | CTF::ctf_t v = static_cast(0.0); 8 | const CTF::ctf_t step = static_cast(0.0/256.0); 9 | for(int i = 0; i < 256; i++){ 10 | data.push_back(v); 11 | v += step; 12 | } 13 | 14 | } 15 | 16 | CTF::CTF(const std::vector& values) : 17 | data(values) 18 | { 19 | assert(values.size() == 256); 20 | } 21 | 22 | std::ostream& operator<<(std::ostream& os, const CTF& ctf){ 23 | for(size_t i = 0; i < ctf.data.size(); i++){ 24 | os << ctf.data[i] << std::endl; 25 | } 26 | return os; 27 | } 28 | 29 | 30 | bool CTF::loadCTF(CTF& ctf, const std::string& fileName){ 31 | std::fstream fs(fileName.c_str(), std::fstream::in); 32 | if(! fs.good() ){ 33 | fs.close(); 34 | return false; 35 | } 36 | 37 | //Read the data 38 | assert(ctf.data.size() == 256); 39 | std::string str; 40 | for(int i = 0; i < 256; i++){ 41 | std::getline(fs, str); 42 | 43 | //Convert to ctf_t 44 | CTF::ctf_t exposure = static_cast(strtod(str.c_str(), NULL)); 45 | 46 | //exposure == 0.0 indicates a parse error (strtod's way of error handling) 47 | //exposure < 0 indicates a physically implausable response curve 48 | if(exposure <= static_cast(0.0) ){ 49 | fs.close(); 50 | return false; 51 | } 52 | 53 | //Update the CTF 54 | ctf.data[i] = exposure; 55 | } 56 | 57 | 58 | const bool worked = fs.good(); 59 | fs.close(); 60 | return worked; 61 | } 62 | 63 | 64 | CTF CTF::makeLinearCTF(CTF::ctf_t maxCTFValue, 65 | CTF::ctf_t minCTFValue) 66 | { 67 | assert(minCTFValue < maxCTFValue); 68 | 69 | CTF ctf; 70 | CTF::ctf_t step = (maxCTFValue - minCTFValue) / static_cast(255); 71 | CTF::ctf_t val = minCTFValue; 72 | for(int pix = 0; pix <= 255; pix++){ 73 | ctf.data[pix] = val; 74 | val += step; 75 | } 76 | 77 | return ctf; 78 | } 79 | -------------------------------------------------------------------------------- /src/CTF.h: -------------------------------------------------------------------------------- 1 | #ifndef CTF_H 2 | #define CTF_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | /** 10 | * Class representing the camera transfer function of a camera(the CTF). The goal of this 11 | * software is to solve for these curves. The CTF is a function, internal to the camera, that 12 | * converts "irradiance" to 8 bit values. 13 | */ 14 | class CTF{ 15 | public: 16 | 17 | //Single precision(float) should typically be sufficient, but you 18 | //could change this to double if you like 19 | typedef float ctf_t; 20 | 21 | /** 22 | * Initialize a CTF. 23 | */ 24 | CTF(const std::vector& values); 25 | 26 | CTF(); 27 | 28 | /** 29 | * Load the CTF value for a particular pixel value in the range [0, 255]. 30 | */ 31 | ctf_t operator()(unsigned char pixelVal)const; 32 | 33 | /** 34 | * Write CTF to a stream. 35 | */ 36 | friend std::ostream& operator<<(std::ostream& os, const CTF& ctf); 37 | 38 | /** 39 | * Load a CTF from disk. Return true on success, false on failure. 40 | * The CTF ctf is modified to return the result. 41 | * This is not a constructor because constructors have no good way to indicate failure. 42 | */ 43 | static bool loadCTF(CTF& ctf, const std::string& fileName); 44 | 45 | /** 46 | * Create a linear CTF. 47 | * 48 | * @param maxCTFValue is the maximum CTF value. 49 | * @param minimumCTFValue is the minimum CTF value. Defaults to 0. 50 | */ 51 | static CTF makeLinearCTF(CTF::ctf_t maxCTFValue, 52 | CTF::ctf_t minCTFValue = static_cast(0.0)); 53 | 54 | 55 | private: 56 | 57 | std::vector data; //Array of length num_bits (currently 256) 58 | }; 59 | 60 | 61 | inline CTF::ctf_t CTF::operator()(unsigned char pixelVal)const{ 62 | assert(data.size() == 256); 63 | return data[pixelVal]; 64 | } 65 | 66 | 67 | 68 | #endif //CTF_H 69 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/Eigen/CMakeFiles/CMakeDirectoryInformation.cmake: -------------------------------------------------------------------------------- 1 | # CMAKE generated file: DO NOT EDIT! 2 | # Generated by "Unix Makefiles" Generator, CMake Version 2.8 3 | 4 | # Relative path conversion top directories. 5 | SET(CMAKE_RELATIVE_PATH_TOP_SOURCE "/home/cab6fh/Documents/Projects/FindCTF") 6 | SET(CMAKE_RELATIVE_PATH_TOP_BINARY "/home/cab6fh/Documents/Projects/FindCTF") 7 | 8 | # Force unix paths in dependencies. 9 | SET(CMAKE_FORCE_UNIX_PATHS 1) 10 | 11 | # The C and CXX include file search paths: 12 | SET(CMAKE_C_INCLUDE_PATH 13 | ) 14 | SET(CMAKE_CXX_INCLUDE_PATH ${CMAKE_C_INCLUDE_PATH}) 15 | SET(CMAKE_Fortran_INCLUDE_PATH ${CMAKE_C_INCLUDE_PATH}) 16 | 17 | # The C and CXX include file regular expressions for this directory. 18 | SET(CMAKE_C_INCLUDE_REGEX_SCAN "^.*$") 19 | SET(CMAKE_C_INCLUDE_REGEX_COMPLAIN "^$") 20 | SET(CMAKE_CXX_INCLUDE_REGEX_SCAN ${CMAKE_C_INCLUDE_REGEX_SCAN}) 21 | SET(CMAKE_CXX_INCLUDE_REGEX_COMPLAIN ${CMAKE_C_INCLUDE_REGEX_COMPLAIN}) 22 | -------------------------------------------------------------------------------- /src/Eigen/CMakeFiles/progress.marks: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /src/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 | namespace Eigen { 9 | 10 | /** \defgroup Cholesky_Module Cholesky module 11 | * 12 | * 13 | * 14 | * This module provides two variants of the Cholesky decomposition for selfadjoint (hermitian) matrices. 15 | * Those decompositions are accessible via the following MatrixBase methods: 16 | * - MatrixBase::llt(), 17 | * - MatrixBase::ldlt() 18 | * 19 | * \code 20 | * #include 21 | * \endcode 22 | */ 23 | 24 | #include "src/misc/Solve.h" 25 | #include "src/Cholesky/LLT.h" 26 | #include "src/Cholesky/LDLT.h" 27 | 28 | } // namespace Eigen 29 | 30 | #include "src/Core/util/ReenableStupidWarnings.h" 31 | 32 | #endif // EIGEN_CHOLESKY_MODULE_H 33 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 34 | -------------------------------------------------------------------------------- /src/Eigen/Dense: -------------------------------------------------------------------------------- 1 | #include "Core" 2 | #include "LU" 3 | #include "Cholesky" 4 | #include "QR" 5 | #include "SVD" 6 | #include "Geometry" 7 | #include "Eigenvalues" 8 | -------------------------------------------------------------------------------- /src/Eigen/Eigen: -------------------------------------------------------------------------------- 1 | #include "Dense" 2 | //#include "Sparse" 3 | -------------------------------------------------------------------------------- /src/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 | // Eigen is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU Lesser General Public 8 | // License as published by the Free Software Foundation; either 9 | // version 3 of the License, or (at your option) any later version. 10 | // 11 | // Alternatively, you can redistribute it and/or 12 | // modify it under the terms of the GNU General Public License as 13 | // published by the Free Software Foundation; either version 2 of 14 | // the License, or (at your option) any later version. 15 | // 16 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 17 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU Lesser General Public 22 | // License and a copy of the GNU General Public License along with 23 | // Eigen. If not, see . 24 | 25 | #ifndef EIGEN2SUPPORT_H 26 | #define EIGEN2SUPPORT_H 27 | 28 | #if (!defined(EIGEN2_SUPPORT)) || (!defined(EIGEN_CORE_H)) 29 | #error Eigen2 support must be enabled by defining EIGEN2_SUPPORT before including any Eigen header 30 | #endif 31 | 32 | #include "src/Core/util/DisableStupidWarnings.h" 33 | 34 | namespace Eigen { 35 | 36 | /** \defgroup Eigen2Support_Module Eigen2 support module 37 | * This module provides a couple of deprecated functions improving the compatibility with Eigen2. 38 | * 39 | * To use it, define EIGEN2_SUPPORT before including any Eigen header 40 | * \code 41 | * #define EIGEN2_SUPPORT 42 | * \endcode 43 | * 44 | */ 45 | 46 | #include "src/Eigen2Support/Macros.h" 47 | #include "src/Eigen2Support/Memory.h" 48 | #include "src/Eigen2Support/Meta.h" 49 | #include "src/Eigen2Support/Lazy.h" 50 | #include "src/Eigen2Support/Cwise.h" 51 | #include "src/Eigen2Support/CwiseOperators.h" 52 | #include "src/Eigen2Support/TriangularSolver.h" 53 | #include "src/Eigen2Support/Block.h" 54 | #include "src/Eigen2Support/VectorBlock.h" 55 | #include "src/Eigen2Support/Minor.h" 56 | #include "src/Eigen2Support/MathFunctions.h" 57 | 58 | 59 | } // namespace Eigen 60 | 61 | #include "src/Core/util/ReenableStupidWarnings.h" 62 | 63 | // Eigen2 used to include iostream 64 | #include 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 | -------------------------------------------------------------------------------- /src/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 | 13 | namespace Eigen { 14 | 15 | /** \defgroup Eigenvalues_Module Eigenvalues module 16 | * 17 | * 18 | * 19 | * This module mainly provides various eigenvalue solvers. 20 | * This module also provides some MatrixBase methods, including: 21 | * - MatrixBase::eigenvalues(), 22 | * - MatrixBase::operatorNorm() 23 | * 24 | * \code 25 | * #include 26 | * \endcode 27 | */ 28 | 29 | #include "src/Eigenvalues/Tridiagonalization.h" 30 | #include "src/Eigenvalues/RealSchur.h" 31 | #include "src/Eigenvalues/EigenSolver.h" 32 | #include "src/Eigenvalues/SelfAdjointEigenSolver.h" 33 | #include "src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h" 34 | #include "src/Eigenvalues/HessenbergDecomposition.h" 35 | #include "src/Eigenvalues/ComplexSchur.h" 36 | #include "src/Eigenvalues/ComplexEigenSolver.h" 37 | #include "src/Eigenvalues/MatrixBaseEigenvalues.h" 38 | 39 | } // namespace Eigen 40 | 41 | #include "src/Core/util/ReenableStupidWarnings.h" 42 | 43 | #endif // EIGEN_EIGENVALUES_MODULE_H 44 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 45 | -------------------------------------------------------------------------------- /src/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 | namespace Eigen { 17 | 18 | /** \defgroup Geometry_Module Geometry module 19 | * 20 | * 21 | * 22 | * This module provides support for: 23 | * - fixed-size homogeneous transformations 24 | * - translation, scaling, 2D and 3D rotations 25 | * - quaternions 26 | * - \ref MatrixBase::cross() "cross product" 27 | * - \ref MatrixBase::unitOrthogonal() "orthognal vector generation" 28 | * - some linear components: parametrized-lines and hyperplanes 29 | * 30 | * \code 31 | * #include 32 | * \endcode 33 | */ 34 | 35 | #include "src/Geometry/OrthoMethods.h" 36 | #include "src/Geometry/EulerAngles.h" 37 | 38 | #if EIGEN2_SUPPORT_STAGE > STAGE20_RESOLVE_API_CONFLICTS 39 | #include "src/Geometry/Homogeneous.h" 40 | #include "src/Geometry/RotationBase.h" 41 | #include "src/Geometry/Rotation2D.h" 42 | #include "src/Geometry/Quaternion.h" 43 | #include "src/Geometry/AngleAxis.h" 44 | #include "src/Geometry/Transform.h" 45 | #include "src/Geometry/Translation.h" 46 | #include "src/Geometry/Scaling.h" 47 | #include "src/Geometry/Hyperplane.h" 48 | #include "src/Geometry/ParametrizedLine.h" 49 | #include "src/Geometry/AlignedBox.h" 50 | #include "src/Geometry/Umeyama.h" 51 | 52 | #if defined EIGEN_VECTORIZE_SSE 53 | #include "src/Geometry/arch/Geometry_SSE.h" 54 | #endif 55 | #endif 56 | 57 | #ifdef EIGEN2_SUPPORT 58 | #include "src/Eigen2Support/Geometry/All.h" 59 | #endif 60 | 61 | } // namespace Eigen 62 | 63 | #include "src/Core/util/ReenableStupidWarnings.h" 64 | 65 | #endif // EIGEN_GEOMETRY_MODULE_H 66 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 67 | 68 | -------------------------------------------------------------------------------- /src/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 | namespace Eigen { 9 | 10 | /** \defgroup Householder_Module Householder module 11 | * This module provides Householder transformations. 12 | * 13 | * \code 14 | * #include 15 | * \endcode 16 | */ 17 | 18 | #include "src/Householder/Householder.h" 19 | #include "src/Householder/HouseholderSequence.h" 20 | #include "src/Householder/BlockHouseholder.h" 21 | 22 | } // namespace Eigen 23 | 24 | #include "src/Core/util/ReenableStupidWarnings.h" 25 | 26 | #endif // EIGEN_HOUSEHOLDER_MODULE_H 27 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 28 | -------------------------------------------------------------------------------- /src/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 | namespace Eigen { 9 | 10 | /** \defgroup Jacobi_Module Jacobi module 11 | * This module provides Jacobi and Givens rotations. 12 | * 13 | * \code 14 | * #include 15 | * \endcode 16 | * 17 | * In addition to listed classes, it defines the two following MatrixBase methods to apply a Jacobi or Givens rotation: 18 | * - MatrixBase::applyOnTheLeft() 19 | * - MatrixBase::applyOnTheRight(). 20 | */ 21 | 22 | #include "src/Jacobi/Jacobi.h" 23 | 24 | } // namespace Eigen 25 | 26 | #include "src/Core/util/ReenableStupidWarnings.h" 27 | 28 | #endif // EIGEN_JACOBI_MODULE_H 29 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 30 | 31 | -------------------------------------------------------------------------------- /src/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 | namespace Eigen { 9 | 10 | /** \defgroup LU_Module LU module 11 | * This module includes %LU decomposition and related notions such as matrix inversion and determinant. 12 | * This module defines the following MatrixBase methods: 13 | * - MatrixBase::inverse() 14 | * - MatrixBase::determinant() 15 | * 16 | * \code 17 | * #include 18 | * \endcode 19 | */ 20 | 21 | #include "src/misc/Solve.h" 22 | #include "src/misc/Kernel.h" 23 | #include "src/misc/Image.h" 24 | #include "src/LU/FullPivLU.h" 25 | #include "src/LU/PartialPivLU.h" 26 | #include "src/LU/Determinant.h" 27 | #include "src/LU/Inverse.h" 28 | 29 | #if defined EIGEN_VECTORIZE_SSE 30 | #include "src/LU/arch/Inverse_SSE.h" 31 | #endif 32 | 33 | #ifdef EIGEN2_SUPPORT 34 | #include "src/Eigen2Support/LU.h" 35 | #endif 36 | 37 | } // namespace Eigen 38 | 39 | #include "src/Core/util/ReenableStupidWarnings.h" 40 | 41 | #endif // EIGEN_LU_MODULE_H 42 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 43 | -------------------------------------------------------------------------------- /src/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 | namespace Eigen { 19 | 20 | /** \defgroup LeastSquares_Module LeastSquares module 21 | * This module provides linear regression and related features. 22 | * 23 | * \code 24 | * #include 25 | * \endcode 26 | */ 27 | 28 | #include "src/Eigen2Support/LeastSquares.h" 29 | 30 | } // namespace Eigen 31 | 32 | #include "src/Core/util/ReenableStupidWarnings.h" 33 | 34 | #endif // EIGEN2_SUPPORT 35 | 36 | #endif // EIGEN_REGRESSION_MODULE_H 37 | -------------------------------------------------------------------------------- /src/Eigen/Makefile: -------------------------------------------------------------------------------- 1 | # CMAKE generated file: DO NOT EDIT! 2 | # Generated by "Unix Makefiles" Generator, CMake Version 2.8 3 | 4 | # Default target executed when no arguments are given to make. 5 | default_target: all 6 | .PHONY : default_target 7 | 8 | #============================================================================= 9 | # Special targets provided by cmake. 10 | 11 | # Disable implicit rules so canoncical targets will work. 12 | .SUFFIXES: 13 | 14 | # Remove some rules from gmake that .SUFFIXES does not remove. 15 | SUFFIXES = 16 | 17 | .SUFFIXES: .hpux_make_needs_suffix_list 18 | 19 | # Suppress display of executed commands. 20 | $(VERBOSE).SILENT: 21 | 22 | # A target that is always out of date. 23 | cmake_force: 24 | .PHONY : cmake_force 25 | 26 | #============================================================================= 27 | # Set environment variables for the build. 28 | 29 | # The shell in which to execute make rules. 30 | SHELL = /bin/sh 31 | 32 | # The CMake executable. 33 | CMAKE_COMMAND = /usr/bin/cmake 34 | 35 | # The command to remove a file. 36 | RM = /usr/bin/cmake -E remove -f 37 | 38 | # The top-level source directory on which CMake was run. 39 | CMAKE_SOURCE_DIR = /home/cab6fh/Documents/Projects/FindCTF 40 | 41 | # The top-level build directory on which CMake was run. 42 | CMAKE_BINARY_DIR = /home/cab6fh/Documents/Projects/FindCTF 43 | 44 | #============================================================================= 45 | # Targets provided globally by CMake. 46 | 47 | # Special rule for the target edit_cache 48 | edit_cache: 49 | @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running interactive CMake command-line interface..." 50 | /usr/bin/cmake -i . 51 | .PHONY : edit_cache 52 | 53 | # Special rule for the target edit_cache 54 | edit_cache/fast: edit_cache 55 | .PHONY : edit_cache/fast 56 | 57 | # Special rule for the target rebuild_cache 58 | rebuild_cache: 59 | @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..." 60 | /usr/bin/cmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) 61 | .PHONY : rebuild_cache 62 | 63 | # Special rule for the target rebuild_cache 64 | rebuild_cache/fast: rebuild_cache 65 | .PHONY : rebuild_cache/fast 66 | 67 | # The main all target 68 | all: cmake_check_build_system 69 | cd /home/cab6fh/Documents/Projects/FindCTF && $(CMAKE_COMMAND) -E cmake_progress_start /home/cab6fh/Documents/Projects/FindCTF/CMakeFiles /home/cab6fh/Documents/Projects/FindCTF/src/Eigen/CMakeFiles/progress.marks 70 | cd /home/cab6fh/Documents/Projects/FindCTF && $(MAKE) -f CMakeFiles/Makefile2 src/Eigen/all 71 | $(CMAKE_COMMAND) -E cmake_progress_start /home/cab6fh/Documents/Projects/FindCTF/CMakeFiles 0 72 | .PHONY : all 73 | 74 | # The main clean target 75 | clean: 76 | cd /home/cab6fh/Documents/Projects/FindCTF && $(MAKE) -f CMakeFiles/Makefile2 src/Eigen/clean 77 | .PHONY : clean 78 | 79 | # The main clean target 80 | clean/fast: clean 81 | .PHONY : clean/fast 82 | 83 | # Prepare targets for installation. 84 | preinstall: all 85 | cd /home/cab6fh/Documents/Projects/FindCTF && $(MAKE) -f CMakeFiles/Makefile2 src/Eigen/preinstall 86 | .PHONY : preinstall 87 | 88 | # Prepare targets for installation. 89 | preinstall/fast: 90 | cd /home/cab6fh/Documents/Projects/FindCTF && $(MAKE) -f CMakeFiles/Makefile2 src/Eigen/preinstall 91 | .PHONY : preinstall/fast 92 | 93 | # clear depends 94 | depend: 95 | cd /home/cab6fh/Documents/Projects/FindCTF && $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1 96 | .PHONY : depend 97 | 98 | # Help Target 99 | help: 100 | @echo "The following are some of the valid targets for this Makefile:" 101 | @echo "... all (the default if no target is provided)" 102 | @echo "... clean" 103 | @echo "... depend" 104 | @echo "... edit_cache" 105 | @echo "... rebuild_cache" 106 | .PHONY : help 107 | 108 | 109 | 110 | #============================================================================= 111 | # Special targets to cleanup operation of make. 112 | 113 | # Special rule to run CMake to check the build system integrity. 114 | # No rule that depends on this can have commands that come from listfiles 115 | # because they might be regenerated. 116 | cmake_check_build_system: 117 | cd /home/cab6fh/Documents/Projects/FindCTF && $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0 118 | .PHONY : cmake_check_build_system 119 | 120 | -------------------------------------------------------------------------------- /src/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 | namespace Eigen { 13 | 14 | /** \defgroup QR_Module QR module 15 | * 16 | * 17 | * 18 | * This module provides various QR decompositions 19 | * This module also provides some MatrixBase methods, including: 20 | * - MatrixBase::qr(), 21 | * 22 | * \code 23 | * #include 24 | * \endcode 25 | */ 26 | 27 | #include "src/misc/Solve.h" 28 | #include "src/QR/HouseholderQR.h" 29 | #include "src/QR/FullPivHouseholderQR.h" 30 | #include "src/QR/ColPivHouseholderQR.h" 31 | 32 | #ifdef EIGEN2_SUPPORT 33 | #include "src/Eigen2Support/QR.h" 34 | #endif 35 | 36 | } // namespace Eigen 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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | namespace Eigen { 11 | 12 | /** \defgroup SVD_Module SVD module 13 | * 14 | * 15 | * 16 | * This module provides SVD decomposition for matrices (both real and complex). 17 | * This decomposition is accessible via the following MatrixBase method: 18 | * - MatrixBase::jacobiSvd() 19 | * 20 | * \code 21 | * #include 22 | * \endcode 23 | */ 24 | 25 | #include "src/misc/Solve.h" 26 | #include "src/SVD/JacobiSVD.h" 27 | #include "src/SVD/UpperBidiagonalization.h" 28 | 29 | #ifdef EIGEN2_SUPPORT 30 | #include "src/Eigen2Support/SVD.h" 31 | #endif 32 | 33 | } // namespace Eigen 34 | 35 | #include "src/Core/util/ReenableStupidWarnings.h" 36 | 37 | #endif // EIGEN_SVD_MODULE_H 38 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 39 | -------------------------------------------------------------------------------- /src/Eigen/Sparse: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_SPARSE_MODULE_H 2 | #define EIGEN_SPARSE_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 | #ifdef EIGEN2_SUPPORT 15 | #define EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET 16 | #endif 17 | 18 | #ifndef EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET 19 | #error The sparse module API is not stable yet. To use it anyway, please define the EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET preprocessor token. 20 | #endif 21 | 22 | namespace Eigen { 23 | 24 | /** \defgroup Sparse_Module Sparse module 25 | * 26 | * 27 | * 28 | * See the \ref TutorialSparse "Sparse tutorial" 29 | * 30 | * \code 31 | * #include 32 | * \endcode 33 | */ 34 | 35 | /** The type used to identify a general sparse storage. */ 36 | struct Sparse {}; 37 | 38 | #include "src/Sparse/SparseUtil.h" 39 | #include "src/Sparse/SparseMatrixBase.h" 40 | #include "src/Sparse/CompressedStorage.h" 41 | #include "src/Sparse/AmbiVector.h" 42 | #include "src/Sparse/SparseMatrix.h" 43 | #include "src/Sparse/DynamicSparseMatrix.h" 44 | #include "src/Sparse/MappedSparseMatrix.h" 45 | #include "src/Sparse/SparseVector.h" 46 | #include "src/Sparse/CoreIterators.h" 47 | #include "src/Sparse/SparseBlock.h" 48 | #include "src/Sparse/SparseTranspose.h" 49 | #include "src/Sparse/SparseCwiseUnaryOp.h" 50 | #include "src/Sparse/SparseCwiseBinaryOp.h" 51 | #include "src/Sparse/SparseDot.h" 52 | #include "src/Sparse/SparseAssign.h" 53 | #include "src/Sparse/SparseRedux.h" 54 | #include "src/Sparse/SparseFuzzy.h" 55 | #include "src/Sparse/SparseProduct.h" 56 | #include "src/Sparse/SparseSparseProduct.h" 57 | #include "src/Sparse/SparseDenseProduct.h" 58 | #include "src/Sparse/SparseDiagonalProduct.h" 59 | #include "src/Sparse/SparseTriangularView.h" 60 | #include "src/Sparse/SparseSelfAdjointView.h" 61 | #include "src/Sparse/TriangularSolver.h" 62 | #include "src/Sparse/SparseView.h" 63 | 64 | } // namespace Eigen 65 | 66 | #include "src/Core/util/ReenableStupidWarnings.h" 67 | 68 | #endif // EIGEN_SPARSE_MODULE_H 69 | 70 | -------------------------------------------------------------------------------- /src/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 | // Eigen is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU Lesser General Public 9 | // License as published by the Free Software Foundation; either 10 | // version 3 of the License, or (at your option) any later version. 11 | // 12 | // Alternatively, you can redistribute it and/or 13 | // modify it under the terms of the GNU General Public License as 14 | // published by the Free Software Foundation; either version 2 of 15 | // the License, or (at your option) any later version. 16 | // 17 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 18 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 19 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 20 | // GNU General Public License for more details. 21 | // 22 | // You should have received a copy of the GNU Lesser General Public 23 | // License and a copy of the GNU General Public License along with 24 | // Eigen. If not, see . 25 | 26 | #ifndef EIGEN_STDDEQUE_MODULE_H 27 | #define EIGEN_STDDEQUE_MODULE_H 28 | 29 | #include "Core" 30 | #include 31 | 32 | #if (defined(_MSC_VER) && defined(_WIN64)) /* MSVC auto aligns in 64 bit builds */ 33 | 34 | #define EIGEN_DEFINE_STL_DEQUE_SPECIALIZATION(...) 35 | 36 | #else 37 | 38 | #include "src/StlSupport/StdDeque.h" 39 | 40 | #endif 41 | 42 | #endif // EIGEN_STDDEQUE_MODULE_H 43 | -------------------------------------------------------------------------------- /src/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 | // Eigen is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU Lesser General Public 8 | // License as published by the Free Software Foundation; either 9 | // version 3 of the License, or (at your option) any later version. 10 | // 11 | // Alternatively, you can redistribute it and/or 12 | // modify it under the terms of the GNU General Public License as 13 | // published by the Free Software Foundation; either version 2 of 14 | // the License, or (at your option) any later version. 15 | // 16 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 17 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU Lesser General Public 22 | // License and a copy of the GNU General Public License along with 23 | // Eigen. If not, see . 24 | 25 | #ifndef EIGEN_STDLIST_MODULE_H 26 | #define EIGEN_STDLIST_MODULE_H 27 | 28 | #include "Core" 29 | #include 30 | 31 | #if (defined(_MSC_VER) && defined(_WIN64)) /* MSVC auto aligns in 64 bit builds */ 32 | 33 | #define EIGEN_DEFINE_STL_LIST_SPECIALIZATION(...) 34 | 35 | #else 36 | 37 | #include "src/StlSupport/StdList.h" 38 | 39 | #endif 40 | 41 | #endif // EIGEN_STDLIST_MODULE_H 42 | -------------------------------------------------------------------------------- /src/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 | // Eigen is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU Lesser General Public 9 | // License as published by the Free Software Foundation; either 10 | // version 3 of the License, or (at your option) any later version. 11 | // 12 | // Alternatively, you can redistribute it and/or 13 | // modify it under the terms of the GNU General Public License as 14 | // published by the Free Software Foundation; either version 2 of 15 | // the License, or (at your option) any later version. 16 | // 17 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 18 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 19 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 20 | // GNU General Public License for more details. 21 | // 22 | // You should have received a copy of the GNU Lesser General Public 23 | // License and a copy of the GNU General Public License along with 24 | // Eigen. If not, see . 25 | 26 | #ifndef EIGEN_STDVECTOR_MODULE_H 27 | #define EIGEN_STDVECTOR_MODULE_H 28 | 29 | #include "Core" 30 | #include 31 | 32 | #if (defined(_MSC_VER) && defined(_WIN64)) /* MSVC auto aligns in 64 bit builds */ 33 | 34 | #define EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(...) 35 | 36 | #else 37 | 38 | #include "src/StlSupport/StdVector.h" 39 | 40 | #endif 41 | 42 | #endif // EIGEN_STDVECTOR_MODULE_H 43 | -------------------------------------------------------------------------------- /src/Eigen/cmake_install.cmake: -------------------------------------------------------------------------------- 1 | # Install script for directory: /home/cab6fh/Documents/Projects/FindCTF/src/Eigen 2 | 3 | # Set the install prefix 4 | IF(NOT DEFINED CMAKE_INSTALL_PREFIX) 5 | SET(CMAKE_INSTALL_PREFIX "/usr/local") 6 | ENDIF(NOT DEFINED CMAKE_INSTALL_PREFIX) 7 | STRING(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") 8 | 9 | # Set the install configuration name. 10 | IF(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME) 11 | IF(BUILD_TYPE) 12 | STRING(REGEX REPLACE "^[^A-Za-z0-9_]+" "" 13 | CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}") 14 | ELSE(BUILD_TYPE) 15 | SET(CMAKE_INSTALL_CONFIG_NAME "Release") 16 | ENDIF(BUILD_TYPE) 17 | MESSAGE(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"") 18 | ENDIF(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME) 19 | 20 | # Set the component getting installed. 21 | IF(NOT CMAKE_INSTALL_COMPONENT) 22 | IF(COMPONENT) 23 | MESSAGE(STATUS "Install component: \"${COMPONENT}\"") 24 | SET(CMAKE_INSTALL_COMPONENT "${COMPONENT}") 25 | ELSE(COMPONENT) 26 | SET(CMAKE_INSTALL_COMPONENT) 27 | ENDIF(COMPONENT) 28 | ENDIF(NOT CMAKE_INSTALL_COMPONENT) 29 | 30 | # Install shared libraries without execute permission? 31 | IF(NOT DEFINED CMAKE_INSTALL_SO_NO_EXE) 32 | SET(CMAKE_INSTALL_SO_NO_EXE "1") 33 | ENDIF(NOT DEFINED CMAKE_INSTALL_SO_NO_EXE) 34 | 35 | -------------------------------------------------------------------------------- /src/Eigen/src/Core/BooleanRedux.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 | // Eigen is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU Lesser General Public 8 | // License as published by the Free Software Foundation; either 9 | // version 3 of the License, or (at your option) any later version. 10 | // 11 | // Alternatively, you can redistribute it and/or 12 | // modify it under the terms of the GNU General Public License as 13 | // published by the Free Software Foundation; either version 2 of 14 | // the License, or (at your option) any later version. 15 | // 16 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 17 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU Lesser General Public 22 | // License and a copy of the GNU General Public License along with 23 | // Eigen. If not, see . 24 | 25 | #ifndef EIGEN_ALLANDANY_H 26 | #define EIGEN_ALLANDANY_H 27 | 28 | namespace internal { 29 | 30 | template 31 | struct all_unroller 32 | { 33 | enum { 34 | col = (UnrollCount-1) / Derived::RowsAtCompileTime, 35 | row = (UnrollCount-1) % Derived::RowsAtCompileTime 36 | }; 37 | 38 | inline static bool run(const Derived &mat) 39 | { 40 | return all_unroller::run(mat) && mat.coeff(row, col); 41 | } 42 | }; 43 | 44 | template 45 | struct all_unroller 46 | { 47 | inline static bool run(const Derived &mat) { return mat.coeff(0, 0); } 48 | }; 49 | 50 | template 51 | struct all_unroller 52 | { 53 | inline static bool run(const Derived &) { return false; } 54 | }; 55 | 56 | template 57 | struct any_unroller 58 | { 59 | enum { 60 | col = (UnrollCount-1) / Derived::RowsAtCompileTime, 61 | row = (UnrollCount-1) % Derived::RowsAtCompileTime 62 | }; 63 | 64 | inline static bool run(const Derived &mat) 65 | { 66 | return any_unroller::run(mat) || mat.coeff(row, col); 67 | } 68 | }; 69 | 70 | template 71 | struct any_unroller 72 | { 73 | inline static bool run(const Derived &mat) { return mat.coeff(0, 0); } 74 | }; 75 | 76 | template 77 | struct any_unroller 78 | { 79 | inline static bool run(const Derived &) { return false; } 80 | }; 81 | 82 | } // end namespace internal 83 | 84 | /** \returns true if all coefficients are true 85 | * 86 | * Example: \include MatrixBase_all.cpp 87 | * Output: \verbinclude MatrixBase_all.out 88 | * 89 | * \sa any(), Cwise::operator<() 90 | */ 91 | template 92 | inline bool DenseBase::all() const 93 | { 94 | enum { 95 | unroll = SizeAtCompileTime != Dynamic 96 | && CoeffReadCost != Dynamic 97 | && NumTraits::AddCost != Dynamic 98 | && SizeAtCompileTime * (CoeffReadCost + NumTraits::AddCost) <= EIGEN_UNROLLING_LIMIT 99 | }; 100 | if(unroll) 101 | return internal::all_unroller::run(derived()); 104 | else 105 | { 106 | for(Index j = 0; j < cols(); ++j) 107 | for(Index i = 0; i < rows(); ++i) 108 | if (!coeff(i, j)) return false; 109 | return true; 110 | } 111 | } 112 | 113 | /** \returns true if at least one coefficient is true 114 | * 115 | * \sa all() 116 | */ 117 | template 118 | inline bool DenseBase::any() const 119 | { 120 | enum { 121 | unroll = SizeAtCompileTime != Dynamic 122 | && CoeffReadCost != Dynamic 123 | && NumTraits::AddCost != Dynamic 124 | && SizeAtCompileTime * (CoeffReadCost + NumTraits::AddCost) <= EIGEN_UNROLLING_LIMIT 125 | }; 126 | if(unroll) 127 | return internal::any_unroller::run(derived()); 130 | else 131 | { 132 | for(Index j = 0; j < cols(); ++j) 133 | for(Index i = 0; i < rows(); ++i) 134 | if (coeff(i, j)) return true; 135 | return false; 136 | } 137 | } 138 | 139 | /** \returns the number of coefficients which evaluate to true 140 | * 141 | * \sa all(), any() 142 | */ 143 | template 144 | inline typename DenseBase::Index DenseBase::count() const 145 | { 146 | return derived().template cast().template cast().sum(); 147 | } 148 | 149 | #endif // EIGEN_ALLANDANY_H 150 | -------------------------------------------------------------------------------- /src/Eigen/src/Core/Flagged.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 | // Eigen is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU Lesser General Public 8 | // License as published by the Free Software Foundation; either 9 | // version 3 of the License, or (at your option) any later version. 10 | // 11 | // Alternatively, you can redistribute it and/or 12 | // modify it under the terms of the GNU General Public License as 13 | // published by the Free Software Foundation; either version 2 of 14 | // the License, or (at your option) any later version. 15 | // 16 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 17 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU Lesser General Public 22 | // License and a copy of the GNU General Public License along with 23 | // Eigen. If not, see . 24 | 25 | #ifndef EIGEN_FLAGGED_H 26 | #define EIGEN_FLAGGED_H 27 | 28 | /** \class Flagged 29 | * \ingroup Core_Module 30 | * 31 | * \brief Expression with modified flags 32 | * 33 | * \param ExpressionType the type of the object of which we are modifying the flags 34 | * \param Added the flags added to the expression 35 | * \param Removed the flags removed from the expression (has priority over Added). 36 | * 37 | * This class represents an expression whose flags have been modified. 38 | * It is the return type of MatrixBase::flagged() 39 | * and most of the time this is the only way it is used. 40 | * 41 | * \sa MatrixBase::flagged() 42 | */ 43 | 44 | namespace internal { 45 | template 46 | struct traits > : traits 47 | { 48 | enum { Flags = (ExpressionType::Flags | Added) & ~Removed }; 49 | }; 50 | } 51 | 52 | template class Flagged 53 | : public MatrixBase > 54 | { 55 | public: 56 | 57 | typedef MatrixBase Base; 58 | 59 | EIGEN_DENSE_PUBLIC_INTERFACE(Flagged) 60 | typedef typename internal::conditional::ret, 61 | ExpressionType, const ExpressionType&>::type ExpressionTypeNested; 62 | typedef typename ExpressionType::InnerIterator InnerIterator; 63 | 64 | inline Flagged(const ExpressionType& matrix) : m_matrix(matrix) {} 65 | 66 | inline Index rows() const { return m_matrix.rows(); } 67 | inline Index cols() const { return m_matrix.cols(); } 68 | inline Index outerStride() const { return m_matrix.outerStride(); } 69 | inline Index innerStride() const { return m_matrix.innerStride(); } 70 | 71 | inline CoeffReturnType coeff(Index row, Index col) const 72 | { 73 | return m_matrix.coeff(row, col); 74 | } 75 | 76 | inline CoeffReturnType coeff(Index index) const 77 | { 78 | return m_matrix.coeff(index); 79 | } 80 | 81 | inline const Scalar& coeffRef(Index row, Index col) const 82 | { 83 | return m_matrix.const_cast_derived().coeffRef(row, col); 84 | } 85 | 86 | inline const Scalar& coeffRef(Index index) const 87 | { 88 | return m_matrix.const_cast_derived().coeffRef(index); 89 | } 90 | 91 | inline Scalar& coeffRef(Index row, Index col) 92 | { 93 | return m_matrix.const_cast_derived().coeffRef(row, col); 94 | } 95 | 96 | inline Scalar& coeffRef(Index index) 97 | { 98 | return m_matrix.const_cast_derived().coeffRef(index); 99 | } 100 | 101 | template 102 | inline const PacketScalar packet(Index row, Index col) const 103 | { 104 | return m_matrix.template packet(row, col); 105 | } 106 | 107 | template 108 | inline void writePacket(Index row, Index col, const PacketScalar& x) 109 | { 110 | m_matrix.const_cast_derived().template writePacket(row, col, x); 111 | } 112 | 113 | template 114 | inline const PacketScalar packet(Index index) const 115 | { 116 | return m_matrix.template packet(index); 117 | } 118 | 119 | template 120 | inline void writePacket(Index index, const PacketScalar& x) 121 | { 122 | m_matrix.const_cast_derived().template writePacket(index, x); 123 | } 124 | 125 | const ExpressionType& _expression() const { return m_matrix; } 126 | 127 | template 128 | typename ExpressionType::PlainObject solveTriangular(const MatrixBase& other) const; 129 | 130 | template 131 | void solveTriangularInPlace(const MatrixBase& other) const; 132 | 133 | protected: 134 | ExpressionTypeNested m_matrix; 135 | }; 136 | 137 | /** \returns an expression of *this with added and removed flags 138 | * 139 | * This is mostly for internal use. 140 | * 141 | * \sa class Flagged 142 | */ 143 | template 144 | template 145 | inline const Flagged 146 | DenseBase::flagged() const 147 | { 148 | return derived(); 149 | } 150 | 151 | #endif // EIGEN_FLAGGED_H 152 | -------------------------------------------------------------------------------- /src/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 Gael Guennebaud 5 | // Copyright (C) 2010 Benoit Jacob 6 | // 7 | // Eigen is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU Lesser General Public 9 | // License as published by the Free Software Foundation; either 10 | // version 3 of the License, or (at your option) any later version. 11 | // 12 | // Alternatively, you can redistribute it and/or 13 | // modify it under the terms of the GNU General Public License as 14 | // published by the Free Software Foundation; either version 2 of 15 | // the License, or (at your option) any later version. 16 | // 17 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 18 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 19 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 20 | // GNU General Public License for more details. 21 | // 22 | // You should have received a copy of the GNU Lesser General Public 23 | // License and a copy of the GNU General Public License along with 24 | // Eigen. If not, see . 25 | 26 | #ifndef EIGEN_GLOBAL_FUNCTIONS_H 27 | #define EIGEN_GLOBAL_FUNCTIONS_H 28 | 29 | #define EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(NAME,FUNCTOR) \ 30 | template \ 31 | inline const Eigen::CwiseUnaryOp, const Derived> \ 32 | NAME(const Eigen::ArrayBase& x) { \ 33 | return x.derived(); \ 34 | } 35 | 36 | #define EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(NAME,FUNCTOR) \ 37 | \ 38 | template \ 39 | struct NAME##_retval > \ 40 | { \ 41 | typedef const Eigen::CwiseUnaryOp, const Derived> type; \ 42 | }; \ 43 | template \ 44 | struct NAME##_impl > \ 45 | { \ 46 | static inline typename NAME##_retval >::type run(const Eigen::ArrayBase& x) \ 47 | { \ 48 | return x.derived(); \ 49 | } \ 50 | }; 51 | 52 | 53 | namespace std 54 | { 55 | EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(real,scalar_real_op) 56 | EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(imag,scalar_imag_op) 57 | EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(sin,scalar_sin_op) 58 | EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(cos,scalar_cos_op) 59 | EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(asin,scalar_asin_op) 60 | EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(acos,scalar_acos_op) 61 | EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(tan,scalar_tan_op) 62 | EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(exp,scalar_exp_op) 63 | EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(log,scalar_log_op) 64 | EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(abs,scalar_abs_op) 65 | EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(sqrt,scalar_sqrt_op) 66 | 67 | template 68 | inline const Eigen::CwiseUnaryOp, const Derived> 69 | pow(const Eigen::ArrayBase& x, const typename Derived::Scalar& exponent) { \ 70 | return x.derived().pow(exponent); \ 71 | } 72 | } 73 | 74 | namespace Eigen 75 | { 76 | namespace internal 77 | { 78 | EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(real,scalar_real_op) 79 | EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(imag,scalar_imag_op) 80 | EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(sin,scalar_sin_op) 81 | EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(cos,scalar_cos_op) 82 | EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(asin,scalar_asin_op) 83 | EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(acos,scalar_acos_op) 84 | EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(tan,scalar_tan_op) 85 | EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(exp,scalar_exp_op) 86 | EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(log,scalar_log_op) 87 | EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(abs,scalar_abs_op) 88 | EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(abs2,scalar_abs2_op) 89 | EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(sqrt,scalar_sqrt_op) 90 | } 91 | } 92 | 93 | // TODO: cleanly disable those functions that are not supported on Array (internal::real_ref, internal::random, internal::isApprox...) 94 | 95 | #endif // EIGEN_GLOBAL_FUNCTIONS_H 96 | -------------------------------------------------------------------------------- /src/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 | // Eigen is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU Lesser General Public 9 | // License as published by the Free Software Foundation; either 10 | // version 3 of the License, or (at your option) any later version. 11 | // 12 | // Alternatively, you can redistribute it and/or 13 | // modify it under the terms of the GNU General Public License as 14 | // published by the Free Software Foundation; either version 2 of 15 | // the License, or (at your option) any later version. 16 | // 17 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 18 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 19 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 20 | // GNU General Public License for more details. 21 | // 22 | // You should have received a copy of the GNU Lesser General Public 23 | // License and a copy of the GNU General Public License along with 24 | // Eigen. If not, see . 25 | 26 | #ifndef EIGEN_NESTBYVALUE_H 27 | #define EIGEN_NESTBYVALUE_H 28 | 29 | /** \class NestByValue 30 | * \ingroup Core_Module 31 | * 32 | * \brief Expression which must be nested by value 33 | * 34 | * \param ExpressionType the type of the object of which we are requiring nesting-by-value 35 | * 36 | * This class is the return type of MatrixBase::nestByValue() 37 | * and most of the time this is the only way it is used. 38 | * 39 | * \sa MatrixBase::nestByValue() 40 | */ 41 | 42 | namespace internal { 43 | template 44 | struct traits > : public traits 45 | {}; 46 | } 47 | 48 | template class NestByValue 49 | : public internal::dense_xpr_base< NestByValue >::type 50 | { 51 | public: 52 | 53 | typedef typename internal::dense_xpr_base::type Base; 54 | EIGEN_DENSE_PUBLIC_INTERFACE(NestByValue) 55 | 56 | inline NestByValue(const ExpressionType& matrix) : m_expression(matrix) {} 57 | 58 | inline Index rows() const { return m_expression.rows(); } 59 | inline Index cols() const { return m_expression.cols(); } 60 | inline Index outerStride() const { return m_expression.outerStride(); } 61 | inline Index innerStride() const { return m_expression.innerStride(); } 62 | 63 | inline const CoeffReturnType coeff(Index row, Index col) const 64 | { 65 | return m_expression.coeff(row, col); 66 | } 67 | 68 | inline Scalar& coeffRef(Index row, Index col) 69 | { 70 | return m_expression.const_cast_derived().coeffRef(row, col); 71 | } 72 | 73 | inline const CoeffReturnType coeff(Index index) const 74 | { 75 | return m_expression.coeff(index); 76 | } 77 | 78 | inline Scalar& coeffRef(Index index) 79 | { 80 | return m_expression.const_cast_derived().coeffRef(index); 81 | } 82 | 83 | template 84 | inline const PacketScalar packet(Index row, Index col) const 85 | { 86 | return m_expression.template packet(row, col); 87 | } 88 | 89 | template 90 | inline void writePacket(Index row, Index col, const PacketScalar& x) 91 | { 92 | m_expression.const_cast_derived().template writePacket(row, col, x); 93 | } 94 | 95 | template 96 | inline const PacketScalar packet(Index index) const 97 | { 98 | return m_expression.template packet(index); 99 | } 100 | 101 | template 102 | inline void writePacket(Index index, const PacketScalar& x) 103 | { 104 | m_expression.const_cast_derived().template writePacket(index, x); 105 | } 106 | 107 | operator const ExpressionType&() const { return m_expression; } 108 | 109 | protected: 110 | const ExpressionType m_expression; 111 | }; 112 | 113 | /** \returns an expression of the temporary version of *this. 114 | */ 115 | template 116 | inline const NestByValue 117 | DenseBase::nestByValue() const 118 | { 119 | return NestByValue(derived()); 120 | } 121 | 122 | #endif // EIGEN_NESTBYVALUE_H 123 | -------------------------------------------------------------------------------- /src/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 | // Eigen is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU Lesser General Public 9 | // License as published by the Free Software Foundation; either 10 | // version 3 of the License, or (at your option) any later version. 11 | // 12 | // Alternatively, you can redistribute it and/or 13 | // modify it under the terms of the GNU General Public License as 14 | // published by the Free Software Foundation; either version 2 of 15 | // the License, or (at your option) any later version. 16 | // 17 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 18 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 19 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 20 | // GNU General Public License for more details. 21 | // 22 | // You should have received a copy of the GNU Lesser General Public 23 | // License and a copy of the GNU General Public License along with 24 | // Eigen. If not, see . 25 | 26 | #ifndef EIGEN_RETURNBYVALUE_H 27 | #define EIGEN_RETURNBYVALUE_H 28 | 29 | /** \class ReturnByValue 30 | * \ingroup Core_Module 31 | * 32 | */ 33 | 34 | namespace internal { 35 | 36 | template 37 | struct traits > 38 | : public traits::ReturnType> 39 | { 40 | enum { 41 | // We're disabling the DirectAccess because e.g. the constructor of 42 | // the Block-with-DirectAccess expression requires to have a coeffRef method. 43 | // Also, we don't want to have to implement the stride stuff. 44 | Flags = (traits::ReturnType>::Flags 45 | | EvalBeforeNestingBit) & ~DirectAccessBit 46 | }; 47 | }; 48 | 49 | /* The ReturnByValue object doesn't even have a coeff() method. 50 | * So the only way that nesting it in an expression can work, is by evaluating it into a plain matrix. 51 | * So internal::nested always gives the plain return matrix type. 52 | * 53 | * FIXME: I don't understand why we need this specialization: isn't this taken care of by the EvalBeforeNestingBit ?? 54 | */ 55 | template 56 | struct nested, n, PlainObject> 57 | { 58 | typedef typename traits::ReturnType type; 59 | }; 60 | 61 | } // end namespace internal 62 | 63 | template class ReturnByValue 64 | : public internal::dense_xpr_base< ReturnByValue >::type 65 | { 66 | public: 67 | typedef typename internal::traits::ReturnType ReturnType; 68 | 69 | typedef typename internal::dense_xpr_base::type Base; 70 | EIGEN_DENSE_PUBLIC_INTERFACE(ReturnByValue) 71 | 72 | template 73 | inline void evalTo(Dest& dst) const 74 | { static_cast(this)->evalTo(dst); } 75 | inline Index rows() const { return static_cast(this)->rows(); } 76 | inline Index cols() const { return static_cast(this)->cols(); } 77 | 78 | #ifndef EIGEN_PARSED_BY_DOXYGEN 79 | #define Unusable YOU_ARE_TRYING_TO_ACCESS_A_SINGLE_COEFFICIENT_IN_A_SPECIAL_EXPRESSION_WHERE_THAT_IS_NOT_ALLOWED_BECAUSE_THAT_WOULD_BE_INEFFICIENT 80 | class Unusable{ 81 | Unusable(const Unusable&) {} 82 | Unusable& operator=(const Unusable&) {return *this;} 83 | }; 84 | const Unusable& coeff(Index) const { return *reinterpret_cast(this); } 85 | const Unusable& coeff(Index,Index) const { return *reinterpret_cast(this); } 86 | Unusable& coeffRef(Index) { return *reinterpret_cast(this); } 87 | Unusable& coeffRef(Index,Index) { return *reinterpret_cast(this); } 88 | #endif 89 | }; 90 | 91 | template 92 | template 93 | Derived& DenseBase::operator=(const ReturnByValue& other) 94 | { 95 | other.evalTo(derived()); 96 | return derived(); 97 | } 98 | 99 | #endif // EIGEN_RETURNBYVALUE_H 100 | -------------------------------------------------------------------------------- /src/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 | // Eigen is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU Lesser General Public 8 | // License as published by the Free Software Foundation; either 9 | // version 3 of the License, or (at your option) any later version. 10 | // 11 | // Alternatively, you can redistribute it and/or 12 | // modify it under the terms of the GNU General Public License as 13 | // published by the Free Software Foundation; either version 2 of 14 | // the License, or (at your option) any later version. 15 | // 16 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 17 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU Lesser General Public 22 | // License and a copy of the GNU General Public License along with 23 | // Eigen. If not, see . 24 | 25 | #ifndef EIGEN_STRIDE_H 26 | #define EIGEN_STRIDE_H 27 | 28 | /** \class Stride 29 | * \ingroup Core_Module 30 | * 31 | * \brief Holds strides information for Map 32 | * 33 | * This class holds the strides information for mapping arrays with strides with class Map. 34 | * 35 | * It holds two values: the inner stride and the outer stride. 36 | * 37 | * The inner stride is the pointer increment between two consecutive entries within a given row of a 38 | * row-major matrix or within a given column of a column-major matrix. 39 | * 40 | * The outer stride is the pointer increment between two consecutive rows of a row-major matrix or 41 | * between two consecutive columns of a column-major matrix. 42 | * 43 | * These two values can be passed either at compile-time as template parameters, or at runtime as 44 | * arguments to the constructor. 45 | * 46 | * Indeed, this class takes two template parameters: 47 | * \param _OuterStrideAtCompileTime the outer stride, or Dynamic if you want to specify it at runtime. 48 | * \param _InnerStrideAtCompileTime the inner stride, or Dynamic if you want to specify it at runtime. 49 | * 50 | * Here is an example: 51 | * \include Map_general_stride.cpp 52 | * Output: \verbinclude Map_general_stride.out 53 | * 54 | * \sa class InnerStride, class OuterStride, \ref TopicStorageOrders 55 | */ 56 | template 57 | class Stride 58 | { 59 | public: 60 | typedef DenseIndex Index; 61 | enum { 62 | InnerStrideAtCompileTime = _InnerStrideAtCompileTime, 63 | OuterStrideAtCompileTime = _OuterStrideAtCompileTime 64 | }; 65 | 66 | /** Default constructor, for use when strides are fixed at compile time */ 67 | Stride() 68 | : m_outer(OuterStrideAtCompileTime), m_inner(InnerStrideAtCompileTime) 69 | { 70 | eigen_assert(InnerStrideAtCompileTime != Dynamic && OuterStrideAtCompileTime != Dynamic); 71 | } 72 | 73 | /** Constructor allowing to pass the strides at runtime */ 74 | Stride(Index outerStride, Index innerStride) 75 | : m_outer(outerStride), m_inner(innerStride) 76 | { 77 | eigen_assert(innerStride>=0 && outerStride>=0); 78 | } 79 | 80 | /** Copy constructor */ 81 | Stride(const Stride& other) 82 | : m_outer(other.outer()), m_inner(other.inner()) 83 | {} 84 | 85 | /** \returns the outer stride */ 86 | inline Index outer() const { return m_outer.value(); } 87 | /** \returns the inner stride */ 88 | inline Index inner() const { return m_inner.value(); } 89 | 90 | protected: 91 | internal::variable_if_dynamic m_outer; 92 | internal::variable_if_dynamic m_inner; 93 | }; 94 | 95 | /** \brief Convenience specialization of Stride to specify only an inner stride 96 | * See class Map for some examples */ 97 | template 98 | class InnerStride : public Stride<0, Value> 99 | { 100 | typedef Stride<0, Value> Base; 101 | public: 102 | typedef DenseIndex Index; 103 | InnerStride() : Base() {} 104 | InnerStride(Index v) : Base(0, v) {} 105 | }; 106 | 107 | /** \brief Convenience specialization of Stride to specify only an outer stride 108 | * See class Map for some examples */ 109 | template 110 | class OuterStride : public Stride 111 | { 112 | typedef Stride Base; 113 | public: 114 | typedef DenseIndex Index; 115 | OuterStride() : Base() {} 116 | OuterStride(Index v) : Base(v,0) {} 117 | }; 118 | 119 | #endif // EIGEN_STRIDE_H 120 | -------------------------------------------------------------------------------- /src/Eigen/src/Core/Swap.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2006-2008 Benoit Jacob 5 | // 6 | // Eigen is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU Lesser General Public 8 | // License as published by the Free Software Foundation; either 9 | // version 3 of the License, or (at your option) any later version. 10 | // 11 | // Alternatively, you can redistribute it and/or 12 | // modify it under the terms of the GNU General Public License as 13 | // published by the Free Software Foundation; either version 2 of 14 | // the License, or (at your option) any later version. 15 | // 16 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 17 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU Lesser General Public 22 | // License and a copy of the GNU General Public License along with 23 | // Eigen. If not, see . 24 | 25 | #ifndef EIGEN_SWAP_H 26 | #define EIGEN_SWAP_H 27 | 28 | /** \class SwapWrapper 29 | * \ingroup Core_Module 30 | * 31 | * \internal 32 | * 33 | * \brief Internal helper class for swapping two expressions 34 | */ 35 | namespace internal { 36 | template 37 | struct traits > : traits {}; 38 | } 39 | 40 | template class SwapWrapper 41 | : public internal::dense_xpr_base >::type 42 | { 43 | public: 44 | 45 | typedef typename internal::dense_xpr_base::type Base; 46 | EIGEN_DENSE_PUBLIC_INTERFACE(SwapWrapper) 47 | typedef typename internal::packet_traits::type Packet; 48 | 49 | inline SwapWrapper(ExpressionType& xpr) : m_expression(xpr) {} 50 | 51 | inline Index rows() const { return m_expression.rows(); } 52 | inline Index cols() const { return m_expression.cols(); } 53 | inline Index outerStride() const { return m_expression.outerStride(); } 54 | inline Index innerStride() const { return m_expression.innerStride(); } 55 | 56 | inline Scalar& coeffRef(Index row, Index col) 57 | { 58 | return m_expression.const_cast_derived().coeffRef(row, col); 59 | } 60 | 61 | inline Scalar& coeffRef(Index index) 62 | { 63 | return m_expression.const_cast_derived().coeffRef(index); 64 | } 65 | 66 | inline Scalar& coeffRef(Index row, Index col) const 67 | { 68 | return m_expression.coeffRef(row, col); 69 | } 70 | 71 | inline Scalar& coeffRef(Index index) const 72 | { 73 | return m_expression.coeffRef(index); 74 | } 75 | 76 | template 77 | void copyCoeff(Index row, Index col, const DenseBase& other) 78 | { 79 | OtherDerived& _other = other.const_cast_derived(); 80 | eigen_internal_assert(row >= 0 && row < rows() 81 | && col >= 0 && col < cols()); 82 | Scalar tmp = m_expression.coeff(row, col); 83 | m_expression.coeffRef(row, col) = _other.coeff(row, col); 84 | _other.coeffRef(row, col) = tmp; 85 | } 86 | 87 | template 88 | void copyCoeff(Index index, const DenseBase& other) 89 | { 90 | OtherDerived& _other = other.const_cast_derived(); 91 | eigen_internal_assert(index >= 0 && index < m_expression.size()); 92 | Scalar tmp = m_expression.coeff(index); 93 | m_expression.coeffRef(index) = _other.coeff(index); 94 | _other.coeffRef(index) = tmp; 95 | } 96 | 97 | template 98 | void copyPacket(Index row, Index col, const DenseBase& other) 99 | { 100 | OtherDerived& _other = other.const_cast_derived(); 101 | eigen_internal_assert(row >= 0 && row < rows() 102 | && col >= 0 && col < cols()); 103 | Packet tmp = m_expression.template packet(row, col); 104 | m_expression.template writePacket(row, col, 105 | _other.template packet(row, col) 106 | ); 107 | _other.template writePacket(row, col, tmp); 108 | } 109 | 110 | template 111 | void copyPacket(Index index, const DenseBase& other) 112 | { 113 | OtherDerived& _other = other.const_cast_derived(); 114 | eigen_internal_assert(index >= 0 && index < m_expression.size()); 115 | Packet tmp = m_expression.template packet(index); 116 | m_expression.template writePacket(index, 117 | _other.template packet(index) 118 | ); 119 | _other.template writePacket(index, tmp); 120 | } 121 | 122 | protected: 123 | ExpressionType& m_expression; 124 | }; 125 | 126 | #endif // EIGEN_SWAP_H 127 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/Eigen/src/Core/arch/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ADD_SUBDIRECTORY(SSE) 2 | ADD_SUBDIRECTORY(AltiVec) 3 | ADD_SUBDIRECTORY(NEON) 4 | ADD_SUBDIRECTORY(Default) 5 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | // Eigen is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU Lesser General Public 9 | // License as published by the Free Software Foundation; either 10 | // version 3 of the License, or (at your option) any later version. 11 | // 12 | // Alternatively, you can redistribute it and/or 13 | // modify it under the terms of the GNU General Public License as 14 | // published by the Free Software Foundation; either version 2 of 15 | // the License, or (at your option) any later version. 16 | // 17 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 18 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 19 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 20 | // GNU General Public License for more details. 21 | // 22 | // You should have received a copy of the GNU Lesser General Public 23 | // License and a copy of the GNU General Public License along with 24 | // Eigen. If not, see . 25 | 26 | 27 | /* All the parameters defined in this file can be specialized in the 28 | * architecture specific files, and/or by the user. 29 | * More to come... */ 30 | 31 | #ifndef EIGEN_DEFAULT_SETTINGS_H 32 | #define EIGEN_DEFAULT_SETTINGS_H 33 | 34 | /** Defines the maximal loop size to enable meta unrolling of loops. 35 | * Note that the value here is expressed in Eigen's own notion of "number of FLOPS", 36 | * it does not correspond to the number of iterations or the number of instructions 37 | */ 38 | #ifndef EIGEN_UNROLLING_LIMIT 39 | #define EIGEN_UNROLLING_LIMIT 100 40 | #endif 41 | 42 | /** Defines the threshold between a "small" and a "large" matrix. 43 | * This threshold is mainly used to select the proper product implementation. 44 | */ 45 | #ifndef EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD 46 | #define EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD 8 47 | #endif 48 | 49 | /** Defines the maximal width of the blocks used in the triangular product and solver 50 | * for vectors (level 2 blas xTRMV and xTRSV). The default is 8. 51 | */ 52 | #ifndef EIGEN_TUNE_TRIANGULAR_PANEL_WIDTH 53 | #define EIGEN_TUNE_TRIANGULAR_PANEL_WIDTH 8 54 | #endif 55 | 56 | 57 | /** Defines the default number of registers available for that architecture. 58 | * Currently it must be 8 or 16. Other values will fail. 59 | */ 60 | #ifndef EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS 61 | #define EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS 8 62 | #endif 63 | 64 | #endif // EIGEN_DEFAULT_SETTINGS_H 65 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/Eigen/src/Core/products/Parallelizer.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 | // Eigen is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU Lesser General Public 8 | // License as published by the Free Software Foundation; either 9 | // version 3 of the License, or (at your option) any later version. 10 | // 11 | // Alternatively, you can redistribute it and/or 12 | // modify it under the terms of the GNU General Public License as 13 | // published by the Free Software Foundation; either version 2 of 14 | // the License, or (at your option) any later version. 15 | // 16 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 17 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU Lesser General Public 22 | // License and a copy of the GNU General Public License along with 23 | // Eigen. If not, see . 24 | 25 | #ifndef EIGEN_PARALLELIZER_H 26 | #define EIGEN_PARALLELIZER_H 27 | 28 | namespace internal { 29 | 30 | /** \internal */ 31 | inline void manage_multi_threading(Action action, int* v) 32 | { 33 | static EIGEN_UNUSED int m_maxThreads = -1; 34 | 35 | if(action==SetAction) 36 | { 37 | eigen_internal_assert(v!=0); 38 | m_maxThreads = *v; 39 | } 40 | else if(action==GetAction) 41 | { 42 | eigen_internal_assert(v!=0); 43 | #ifdef EIGEN_HAS_OPENMP 44 | if(m_maxThreads>0) 45 | *v = m_maxThreads; 46 | else 47 | *v = omp_get_max_threads(); 48 | #else 49 | *v = 1; 50 | #endif 51 | } 52 | else 53 | { 54 | eigen_internal_assert(false); 55 | } 56 | } 57 | 58 | /** \returns the max number of threads reserved for Eigen 59 | * \sa setNbThreads */ 60 | inline int nbThreads() 61 | { 62 | int ret; 63 | manage_multi_threading(GetAction, &ret); 64 | return ret; 65 | } 66 | 67 | /** Sets the max number of threads reserved for Eigen 68 | * \sa nbThreads */ 69 | inline void setNbThreads(int v) 70 | { 71 | manage_multi_threading(SetAction, &v); 72 | } 73 | 74 | template struct GemmParallelInfo 75 | { 76 | GemmParallelInfo() : sync(-1), users(0), rhs_start(0), rhs_length(0) {} 77 | 78 | int volatile sync; 79 | int volatile users; 80 | 81 | Index rhs_start; 82 | Index rhs_length; 83 | }; 84 | 85 | template 86 | void parallelize_gemm(const Functor& func, Index rows, Index cols, bool transpose) 87 | { 88 | #ifndef EIGEN_HAS_OPENMP 89 | // FIXME the transpose variable is only needed to properly split 90 | // the matrix product when multithreading is enabled. This is a temporary 91 | // fix to support row-major destination matrices. This whole 92 | // parallelizer mechanism has to be redisigned anyway. 93 | EIGEN_UNUSED_VARIABLE(transpose); 94 | func(0,rows, 0,cols); 95 | #else 96 | 97 | // Dynamically check whether we should enable or disable OpenMP. 98 | // The conditions are: 99 | // - the max number of threads we can create is greater than 1 100 | // - we are not already in a parallel code 101 | // - the sizes are large enough 102 | 103 | // 1- are we already in a parallel session? 104 | // FIXME omp_get_num_threads()>1 only works for openmp, what if the user does not use openmp? 105 | if((!Condition) || (omp_get_num_threads()>1)) 106 | return func(0,rows, 0,cols); 107 | 108 | Index size = transpose ? cols : rows; 109 | 110 | // 2- compute the maximal number of threads from the size of the product: 111 | // FIXME this has to be fine tuned 112 | Index max_threads = std::max(1,size / 32); 113 | 114 | // 3 - compute the number of threads we are going to use 115 | Index threads = std::min(nbThreads(), max_threads); 116 | 117 | if(threads==1) 118 | return func(0,rows, 0,cols); 119 | 120 | func.initParallelSession(); 121 | 122 | if(transpose) 123 | std::swap(rows,cols); 124 | 125 | Index blockCols = (cols / threads) & ~Index(0x3); 126 | Index blockRows = (rows / threads) & ~Index(0x7); 127 | 128 | GemmParallelInfo* info = new GemmParallelInfo[threads]; 129 | 130 | #pragma omp parallel for schedule(static,1) num_threads(threads) 131 | for(Index i=0; i 5 | // 6 | // Eigen is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU Lesser General Public 8 | // License as published by the Free Software Foundation; either 9 | // version 3 of the License, or (at your option) any later version. 10 | // 11 | // Alternatively, you can redistribute it and/or 12 | // modify it under the terms of the GNU General Public License as 13 | // published by the Free Software Foundation; either version 2 of 14 | // the License, or (at your option) any later version. 15 | // 16 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 17 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU Lesser General Public 22 | // License and a copy of the GNU General Public License along with 23 | // Eigen. If not, see . 24 | 25 | #ifndef EIGEN_SELFADJOINTRANK2UPTADE_H 26 | #define EIGEN_SELFADJOINTRANK2UPTADE_H 27 | 28 | namespace internal { 29 | 30 | /* Optimized selfadjoint matrix += alpha * uv' + conj(alpha)*vu' 31 | * It corresponds to the Level2 syr2 BLAS routine 32 | */ 33 | 34 | template 35 | struct selfadjoint_rank2_update_selector; 36 | 37 | template 38 | struct selfadjoint_rank2_update_selector 39 | { 40 | static void run(Scalar* mat, Index stride, const UType& u, const VType& v, Scalar alpha) 41 | { 42 | const Index size = u.size(); 43 | for (Index i=0; i >(mat+stride*i+i, size-i) += 46 | (conj(alpha) * conj(u.coeff(i))) * v.tail(size-i) 47 | + (alpha * conj(v.coeff(i))) * u.tail(size-i); 48 | } 49 | } 50 | }; 51 | 52 | template 53 | struct selfadjoint_rank2_update_selector 54 | { 55 | static void run(Scalar* mat, Index stride, const UType& u, const VType& v, Scalar alpha) 56 | { 57 | const Index size = u.size(); 58 | for (Index i=0; i >(mat+stride*i, i+1) += 60 | (conj(alpha) * conj(u.coeff(i))) * v.head(i+1) 61 | + (alpha * conj(v.coeff(i))) * u.head(i+1); 62 | } 63 | }; 64 | 65 | template struct conj_expr_if 66 | : conditional::Scalar>,T> > {}; 68 | 69 | } // end namespace internal 70 | 71 | template 72 | template 73 | SelfAdjointView& SelfAdjointView 74 | ::rankUpdate(const MatrixBase& u, const MatrixBase& v, Scalar alpha) 75 | { 76 | typedef internal::blas_traits UBlasTraits; 77 | typedef typename UBlasTraits::DirectLinearAccessType ActualUType; 78 | typedef typename internal::remove_all::type _ActualUType; 79 | const ActualUType actualU = UBlasTraits::extract(u.derived()); 80 | 81 | typedef internal::blas_traits VBlasTraits; 82 | typedef typename VBlasTraits::DirectLinearAccessType ActualVType; 83 | typedef typename internal::remove_all::type _ActualVType; 84 | const ActualVType actualV = VBlasTraits::extract(v.derived()); 85 | 86 | // If MatrixType is row major, then we use the routine for lower triangular in the upper triangular case and 87 | // vice versa, and take the complex conjugate of all coefficients and vector entries. 88 | 89 | enum { IsRowMajor = (internal::traits::Flags&RowMajorBit) ? 1 : 0 }; 90 | Scalar actualAlpha = alpha * UBlasTraits::extractScalarFactor(u.derived()) 91 | * internal::conj(VBlasTraits::extractScalarFactor(v.derived())); 92 | if (IsRowMajor) 93 | actualAlpha = internal::conj(actualAlpha); 94 | 95 | internal::selfadjoint_rank2_update_selector::type>::type, 97 | typename internal::remove_all::type>::type, 98 | (IsRowMajor ? int(UpLo==Upper ? Lower : Upper) : UpLo)> 99 | ::run(_expression().const_cast_derived().data(),_expression().outerStride(),actualU,actualV,actualAlpha); 100 | 101 | return *this; 102 | } 103 | 104 | #endif // EIGEN_SELFADJOINTRANK2UPTADE_H 105 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | // 2536 - type qualifiers are meaningless here 25 | // ICC 12 generates this warning when a function return type is const qualified, even if that type is a template-parameter-dependent 26 | // typedef that may be a reference type. 27 | // 279 - controlling expression is constant 28 | // ICC 12 generates this warning on assert(constant_expression_depending_on_template_params) and frankly this is a legitimate use case. 29 | #ifndef EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS 30 | #pragma warning push 31 | #endif 32 | #pragma warning disable 2196 2536 279 33 | #elif defined __clang__ 34 | // -Wconstant-logical-operand - warning: use of logical && with constant operand; switch to bitwise & or remove constant 35 | // this is really a stupid warning as it warns on compile-time expressions involving enums 36 | #ifndef EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS 37 | #pragma clang diagnostic push 38 | #endif 39 | #pragma clang diagnostic ignored "-Wconstant-logical-operand" 40 | #endif 41 | 42 | #endif // not EIGEN_WARNINGS_DISABLED 43 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/Eigen/src/Eigen2Support/Block.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 | // Eigen is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU Lesser General Public 9 | // License as published by the Free Software Foundation; either 10 | // version 3 of the License, or (at your option) any later version. 11 | // 12 | // Alternatively, you can redistribute it and/or 13 | // modify it under the terms of the GNU General Public License as 14 | // published by the Free Software Foundation; either version 2 of 15 | // the License, or (at your option) any later version. 16 | // 17 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 18 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 19 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 20 | // GNU General Public License for more details. 21 | // 22 | // You should have received a copy of the GNU Lesser General Public 23 | // License and a copy of the GNU General Public License along with 24 | // Eigen. If not, see . 25 | 26 | #ifndef EIGEN_BLOCK2_H 27 | #define EIGEN_BLOCK2_H 28 | 29 | /** \returns a dynamic-size expression of a corner of *this. 30 | * 31 | * \param type the type of corner. Can be \a Eigen::TopLeft, \a Eigen::TopRight, 32 | * \a Eigen::BottomLeft, \a Eigen::BottomRight. 33 | * \param cRows the number of rows in the corner 34 | * \param cCols the number of columns in the corner 35 | * 36 | * Example: \include MatrixBase_corner_enum_int_int.cpp 37 | * Output: \verbinclude MatrixBase_corner_enum_int_int.out 38 | * 39 | * \note Even though the returned expression has dynamic size, in the case 40 | * when it is applied to a fixed-size matrix, it inherits a fixed maximal size, 41 | * which means that evaluating it does not cause a dynamic memory allocation. 42 | * 43 | * \sa class Block, block(Index,Index,Index,Index) 44 | */ 45 | template 46 | inline Block DenseBase 47 | ::corner(CornerType type, Index cRows, Index cCols) 48 | { 49 | switch(type) 50 | { 51 | default: 52 | eigen_assert(false && "Bad corner type."); 53 | case TopLeft: 54 | return Block(derived(), 0, 0, cRows, cCols); 55 | case TopRight: 56 | return Block(derived(), 0, cols() - cCols, cRows, cCols); 57 | case BottomLeft: 58 | return Block(derived(), rows() - cRows, 0, cRows, cCols); 59 | case BottomRight: 60 | return Block(derived(), rows() - cRows, cols() - cCols, cRows, cCols); 61 | } 62 | } 63 | 64 | /** This is the const version of corner(CornerType, Index, Index).*/ 65 | template 66 | inline const Block 67 | DenseBase::corner(CornerType type, Index cRows, Index cCols) const 68 | { 69 | switch(type) 70 | { 71 | default: 72 | eigen_assert(false && "Bad corner type."); 73 | case TopLeft: 74 | return Block(derived(), 0, 0, cRows, cCols); 75 | case TopRight: 76 | return Block(derived(), 0, cols() - cCols, cRows, cCols); 77 | case BottomLeft: 78 | return Block(derived(), rows() - cRows, 0, cRows, cCols); 79 | case BottomRight: 80 | return Block(derived(), rows() - cRows, cols() - cCols, cRows, cCols); 81 | } 82 | } 83 | 84 | /** \returns a fixed-size expression of a corner of *this. 85 | * 86 | * \param type the type of corner. Can be \a Eigen::TopLeft, \a Eigen::TopRight, 87 | * \a Eigen::BottomLeft, \a Eigen::BottomRight. 88 | * 89 | * The template parameters CRows and CCols arethe number of rows and columns in the corner. 90 | * 91 | * Example: \include MatrixBase_template_int_int_corner_enum.cpp 92 | * Output: \verbinclude MatrixBase_template_int_int_corner_enum.out 93 | * 94 | * \sa class Block, block(Index,Index,Index,Index) 95 | */ 96 | template 97 | template 98 | inline Block 99 | DenseBase::corner(CornerType type) 100 | { 101 | switch(type) 102 | { 103 | default: 104 | eigen_assert(false && "Bad corner type."); 105 | case TopLeft: 106 | return Block(derived(), 0, 0); 107 | case TopRight: 108 | return Block(derived(), 0, cols() - CCols); 109 | case BottomLeft: 110 | return Block(derived(), rows() - CRows, 0); 111 | case BottomRight: 112 | return Block(derived(), rows() - CRows, cols() - CCols); 113 | } 114 | } 115 | 116 | /** This is the const version of corner(CornerType).*/ 117 | template 118 | template 119 | inline const Block 120 | DenseBase::corner(CornerType type) const 121 | { 122 | switch(type) 123 | { 124 | default: 125 | eigen_assert(false && "Bad corner type."); 126 | case TopLeft: 127 | return Block(derived(), 0, 0); 128 | case TopRight: 129 | return Block(derived(), 0, cols() - CCols); 130 | case BottomLeft: 131 | return Block(derived(), rows() - CRows, 0); 132 | case BottomRight: 133 | return Block(derived(), rows() - CRows, cols() - CCols); 134 | } 135 | } 136 | 137 | #endif // EIGEN_BLOCK2_H 138 | -------------------------------------------------------------------------------- /src/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 -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/Eigen/src/Eigen2Support/LU.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 | // Eigen is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU Lesser General Public 8 | // License as published by the Free Software Foundation; either 9 | // version 3 of the License, or (at your option) any later version. 10 | // 11 | // Alternatively, you can redistribute it and/or 12 | // modify it under the terms of the GNU General Public License as 13 | // published by the Free Software Foundation; either version 2 of 14 | // the License, or (at your option) any later version. 15 | // 16 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 17 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU Lesser General Public 22 | // License and a copy of the GNU General Public License along with 23 | // Eigen. If not, see . 24 | 25 | #ifndef EIGEN2_LU_H 26 | #define EIGEN2_LU_H 27 | 28 | template 29 | class LU : public FullPivLU 30 | { 31 | public: 32 | 33 | typedef typename MatrixType::Scalar Scalar; 34 | typedef typename NumTraits::Real RealScalar; 35 | typedef Matrix IntRowVectorType; 36 | typedef Matrix IntColVectorType; 37 | typedef Matrix RowVectorType; 38 | typedef Matrix ColVectorType; 39 | 40 | typedef Matrix KernelResultType; 49 | 50 | typedef Matrix ImageResultType; 58 | 59 | typedef FullPivLU Base; 60 | LU() : Base() {} 61 | 62 | template 63 | explicit LU(const T& t) : Base(t), m_originalMatrix(t) {} 64 | 65 | template 66 | bool solve(const MatrixBase& b, ResultType *result) const 67 | { 68 | *result = static_cast(this)->solve(b); 69 | return true; 70 | } 71 | 72 | template 73 | inline void computeInverse(ResultType *result) const 74 | { 75 | solve(MatrixType::Identity(this->rows(), this->cols()), result); 76 | } 77 | 78 | template 79 | void computeKernel(KernelMatrixType *result) const 80 | { 81 | *result = static_cast(this)->kernel(); 82 | } 83 | 84 | template 85 | void computeImage(ImageMatrixType *result) const 86 | { 87 | *result = static_cast(this)->image(m_originalMatrix); 88 | } 89 | 90 | const ImageResultType image() const 91 | { 92 | return static_cast(this)->image(m_originalMatrix); 93 | } 94 | 95 | const MatrixType& m_originalMatrix; 96 | }; 97 | 98 | #if EIGEN2_SUPPORT_STAGE < STAGE20_RESOLVE_API_CONFLICTS 99 | /** \lu_module 100 | * 101 | * Synonym of partialPivLu(). 102 | * 103 | * \return the partial-pivoting LU decomposition of \c *this. 104 | * 105 | * \sa class PartialPivLU 106 | */ 107 | template 108 | inline const LU::PlainObject> 109 | MatrixBase::lu() const 110 | { 111 | return LU(eval()); 112 | } 113 | #endif 114 | 115 | #ifdef EIGEN2_SUPPORT 116 | /** \lu_module 117 | * 118 | * Synonym of partialPivLu(). 119 | * 120 | * \return the partial-pivoting LU decomposition of \c *this. 121 | * 122 | * \sa class PartialPivLU 123 | */ 124 | template 125 | inline const LU::PlainObject> 126 | MatrixBase::eigen2_lu() const 127 | { 128 | return LU(eval()); 129 | } 130 | #endif 131 | 132 | 133 | #endif // EIGEN2_LU_H 134 | -------------------------------------------------------------------------------- /src/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 | // Eigen is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU Lesser General Public 8 | // License as published by the Free Software Foundation; either 9 | // version 3 of the License, or (at your option) any later version. 10 | // 11 | // Alternatively, you can redistribute it and/or 12 | // modify it under the terms of the GNU General Public License as 13 | // published by the Free Software Foundation; either version 2 of 14 | // the License, or (at your option) any later version. 15 | // 16 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 17 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU Lesser General Public 22 | // License and a copy of the GNU General Public License along with 23 | // Eigen. If not, see . 24 | 25 | #ifndef EIGEN_LAZY_H 26 | #define EIGEN_LAZY_H 27 | 28 | /** \deprecated it is only used by lazy() which is deprecated 29 | * 30 | * \returns an expression of *this with added flags 31 | * 32 | * Example: \include MatrixBase_marked.cpp 33 | * Output: \verbinclude MatrixBase_marked.out 34 | * 35 | * \sa class Flagged, extract(), part() 36 | */ 37 | template 38 | template 39 | inline const Flagged 40 | MatrixBase::marked() const 41 | { 42 | return derived(); 43 | } 44 | 45 | /** \deprecated use MatrixBase::noalias() 46 | * 47 | * \returns an expression of *this with the EvalBeforeAssigningBit flag removed. 48 | * 49 | * Example: \include MatrixBase_lazy.cpp 50 | * Output: \verbinclude MatrixBase_lazy.out 51 | * 52 | * \sa class Flagged, marked() 53 | */ 54 | template 55 | inline const Flagged 56 | MatrixBase::lazy() const 57 | { 58 | return derived(); 59 | } 60 | 61 | 62 | /** \internal 63 | * Overloaded to perform an efficient C += (A*B).lazy() */ 64 | template 65 | template 66 | Derived& MatrixBase::operator+=(const Flagged, 0, 67 | EvalBeforeAssigningBit>& other) 68 | { 69 | other._expression().derived().addTo(derived()); return derived(); 70 | } 71 | 72 | /** \internal 73 | * Overloaded to perform an efficient C -= (A*B).lazy() */ 74 | template 75 | template 76 | Derived& MatrixBase::operator-=(const Flagged, 0, 77 | EvalBeforeAssigningBit>& other) 78 | { 79 | other._expression().derived().subTo(derived()); return derived(); 80 | } 81 | 82 | #endif // EIGEN_LAZY_H 83 | -------------------------------------------------------------------------------- /src/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 | // Eigen is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU Lesser General Public 8 | // License as published by the Free Software Foundation; either 9 | // version 3 of the License, or (at your option) any later version. 10 | // 11 | // Alternatively, you can redistribute it and/or 12 | // modify it under the terms of the GNU General Public License as 13 | // published by the Free Software Foundation; either version 2 of 14 | // the License, or (at your option) any later version. 15 | // 16 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 17 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU Lesser General Public 22 | // License and a copy of the GNU General Public License along with 23 | // Eigen. If not, see . 24 | 25 | #ifndef EIGEN2_MACROS_H 26 | #define EIGEN2_MACROS_H 27 | 28 | #define ei_assert eigen_assert 29 | #define ei_internal_assert eigen_internal_assert 30 | 31 | #define EIGEN_ALIGN_128 EIGEN_ALIGN16 32 | 33 | #define EIGEN_ARCH_WANTS_ALIGNMENT EIGEN_ALIGN_STATICALLY 34 | 35 | #endif // EIGEN2_MACROS_H 36 | -------------------------------------------------------------------------------- /src/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 | // Eigen is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU Lesser General Public 8 | // License as published by the Free Software Foundation; either 9 | // version 3 of the License, or (at your option) any later version. 10 | // 11 | // Alternatively, you can redistribute it and/or 12 | // modify it under the terms of the GNU General Public License as 13 | // published by the Free Software Foundation; either version 2 of 14 | // the License, or (at your option) any later version. 15 | // 16 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 17 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU Lesser General Public 22 | // License and a copy of the GNU General Public License along with 23 | // Eigen. If not, see . 24 | 25 | #ifndef EIGEN2_MATH_FUNCTIONS_H 26 | #define EIGEN2_MATH_FUNCTIONS_H 27 | 28 | template inline typename NumTraits::Real ei_real(const T& x) { return internal::real(x); } 29 | template inline typename NumTraits::Real ei_imag(const T& x) { return internal::imag(x); } 30 | template inline T ei_conj(const T& x) { return internal::conj(x); } 31 | template inline typename NumTraits::Real ei_abs (const T& x) { return internal::abs(x); } 32 | template inline typename NumTraits::Real ei_abs2(const T& x) { return internal::abs2(x); } 33 | template inline T ei_sqrt(const T& x) { return internal::sqrt(x); } 34 | template inline T ei_exp (const T& x) { return internal::exp(x); } 35 | template inline T ei_log (const T& x) { return internal::log(x); } 36 | template inline T ei_sin (const T& x) { return internal::sin(x); } 37 | template inline T ei_cos (const T& x) { return internal::cos(x); } 38 | template inline T ei_atan2(const T& x,const T& y) { return internal::atan2(x,y); } 39 | template inline T ei_pow (const T& x,const T& y) { return internal::pow(x,y); } 40 | template inline T ei_random () { return internal::random(); } 41 | template inline T ei_random (const T& x, const T& y) { return internal::random(x, y); } 42 | 43 | template inline T precision () { return NumTraits::dummy_precision(); } 44 | template inline T machine_epsilon () { return NumTraits::epsilon(); } 45 | 46 | 47 | template 48 | inline bool ei_isMuchSmallerThan(const Scalar& x, const OtherScalar& y, 49 | typename NumTraits::Real precision = NumTraits::dummy_precision()) 50 | { 51 | return internal::isMuchSmallerThan(x, y, precision); 52 | } 53 | 54 | template 55 | inline bool ei_isApprox(const Scalar& x, const Scalar& y, 56 | typename NumTraits::Real precision = NumTraits::dummy_precision()) 57 | { 58 | return internal::isApprox(x, y, precision); 59 | } 60 | 61 | template 62 | inline bool ei_isApproxOrLessThan(const Scalar& x, const Scalar& y, 63 | typename NumTraits::Real precision = NumTraits::dummy_precision()) 64 | { 65 | return internal::isApproxOrLessThan(x, y, precision); 66 | } 67 | 68 | #endif // EIGEN2_MATH_FUNCTIONS_H 69 | -------------------------------------------------------------------------------- /src/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 | // Eigen is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU Lesser General Public 8 | // License as published by the Free Software Foundation; either 9 | // version 3 of the License, or (at your option) any later version. 10 | // 11 | // Alternatively, you can redistribute it and/or 12 | // modify it under the terms of the GNU General Public License as 13 | // published by the Free Software Foundation; either version 2 of 14 | // the License, or (at your option) any later version. 15 | // 16 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 17 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU Lesser General Public 22 | // License and a copy of the GNU General Public License along with 23 | // Eigen. If not, see . 24 | 25 | #ifndef EIGEN2_MEMORY_H 26 | #define EIGEN2_MEMORY_H 27 | 28 | inline void* ei_aligned_malloc(size_t size) { return internal::aligned_malloc(size); } 29 | inline void ei_aligned_free(void *ptr) { internal::aligned_free(ptr); } 30 | inline void* ei_aligned_realloc(void *ptr, size_t new_size, size_t old_size) { return internal::aligned_realloc(ptr, new_size, old_size); } 31 | inline void* ei_handmade_aligned_malloc(size_t size) { return internal::handmade_aligned_malloc(size); } 32 | inline void ei_handmade_aligned_free(void *ptr) { internal::handmade_aligned_free(ptr); } 33 | 34 | template inline void* ei_conditional_aligned_malloc(size_t size) 35 | { 36 | return internal::conditional_aligned_malloc(size); 37 | } 38 | template inline void ei_conditional_aligned_free(void *ptr) 39 | { 40 | internal::conditional_aligned_free(ptr); 41 | } 42 | template inline void* ei_conditional_aligned_realloc(void* ptr, size_t new_size, size_t old_size) 43 | { 44 | return internal::conditional_aligned_realloc(ptr, new_size, old_size); 45 | } 46 | 47 | template inline T* ei_aligned_new(size_t size) 48 | { 49 | return internal::aligned_new(size); 50 | } 51 | template inline void ei_aligned_delete(T *ptr, size_t size) 52 | { 53 | return internal::aligned_delete(ptr, size); 54 | } 55 | 56 | 57 | 58 | #endif // EIGEN2_MACROS_H 59 | -------------------------------------------------------------------------------- /src/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 | // Eigen is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU Lesser General Public 8 | // License as published by the Free Software Foundation; either 9 | // version 3 of the License, or (at your option) any later version. 10 | // 11 | // Alternatively, you can redistribute it and/or 12 | // modify it under the terms of the GNU General Public License as 13 | // published by the Free Software Foundation; either version 2 of 14 | // the License, or (at your option) any later version. 15 | // 16 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 17 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU Lesser General Public 22 | // License and a copy of the GNU General Public License along with 23 | // Eigen. If not, see . 24 | 25 | #ifndef EIGEN2_META_H 26 | #define EIGEN2_META_H 27 | 28 | template 29 | struct ei_traits : internal::traits 30 | {}; 31 | 32 | struct ei_meta_true { enum { ret = 1 }; }; 33 | struct ei_meta_false { enum { ret = 0 }; }; 34 | 35 | template 36 | struct ei_meta_if { typedef Then ret; }; 37 | 38 | template 39 | struct ei_meta_if { typedef Else ret; }; 40 | 41 | template struct ei_is_same_type { enum { ret = 0 }; }; 42 | template struct ei_is_same_type { enum { ret = 1 }; }; 43 | 44 | template struct ei_unref { typedef T type; }; 45 | template struct ei_unref { typedef T type; }; 46 | 47 | template struct ei_unpointer { typedef T type; }; 48 | template struct ei_unpointer { typedef T type; }; 49 | template struct ei_unpointer { typedef T type; }; 50 | 51 | template struct ei_unconst { typedef T type; }; 52 | template struct ei_unconst { typedef T type; }; 53 | template struct ei_unconst { typedef T & type; }; 54 | template struct ei_unconst { typedef T * type; }; 55 | 56 | template struct ei_cleantype { typedef T type; }; 57 | template struct ei_cleantype { typedef typename ei_cleantype::type type; }; 58 | template struct ei_cleantype { typedef typename ei_cleantype::type type; }; 59 | template struct ei_cleantype { typedef typename ei_cleantype::type type; }; 60 | template struct ei_cleantype { typedef typename ei_cleantype::type type; }; 61 | template struct ei_cleantype { typedef typename ei_cleantype::type type; }; 62 | 63 | /** \internal In short, it computes int(sqrt(\a Y)) with \a Y an integer. 64 | * Usage example: \code ei_meta_sqrt<1023>::ret \endcode 65 | */ 66 | template Y))) > 70 | // use ?: instead of || just to shut up a stupid gcc 4.3 warning 71 | class ei_meta_sqrt 72 | { 73 | enum { 74 | MidX = (InfX+SupX)/2, 75 | TakeInf = MidX*MidX > Y ? 1 : 0, 76 | NewInf = int(TakeInf) ? InfX : int(MidX), 77 | NewSup = int(TakeInf) ? int(MidX) : SupX 78 | }; 79 | public: 80 | enum { ret = ei_meta_sqrt::ret }; 81 | }; 82 | 83 | template 84 | class ei_meta_sqrt { public: enum { ret = (SupX*SupX <= Y) ? SupX : InfX }; }; 85 | 86 | #endif // EIGEN2_META_H 87 | -------------------------------------------------------------------------------- /src/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 | // Eigen is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU Lesser General Public 8 | // License as published by the Free Software Foundation; either 9 | // version 3 of the License, or (at your option) any later version. 10 | // 11 | // Alternatively, you can redistribute it and/or 12 | // modify it under the terms of the GNU General Public License as 13 | // published by the Free Software Foundation; either version 2 of 14 | // the License, or (at your option) any later version. 15 | // 16 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 17 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU Lesser General Public 22 | // License and a copy of the GNU General Public License along with 23 | // Eigen. If not, see . 24 | 25 | #ifndef EIGEN_MINOR_H 26 | #define EIGEN_MINOR_H 27 | 28 | /** 29 | * \class Minor 30 | * 31 | * \brief Expression of a minor 32 | * 33 | * \param MatrixType the type of the object in which we are taking a minor 34 | * 35 | * This class represents an expression of a minor. It is the return 36 | * type of MatrixBase::minor() and most of the time this is the only way it 37 | * is used. 38 | * 39 | * \sa MatrixBase::minor() 40 | */ 41 | 42 | namespace internal { 43 | template 44 | struct traits > 45 | : traits 46 | { 47 | typedef typename nested::type MatrixTypeNested; 48 | typedef typename remove_reference::type _MatrixTypeNested; 49 | typedef typename MatrixType::StorageKind StorageKind; 50 | enum { 51 | RowsAtCompileTime = (MatrixType::RowsAtCompileTime != Dynamic) ? 52 | int(MatrixType::RowsAtCompileTime) - 1 : Dynamic, 53 | ColsAtCompileTime = (MatrixType::ColsAtCompileTime != Dynamic) ? 54 | int(MatrixType::ColsAtCompileTime) - 1 : Dynamic, 55 | MaxRowsAtCompileTime = (MatrixType::MaxRowsAtCompileTime != Dynamic) ? 56 | int(MatrixType::MaxRowsAtCompileTime) - 1 : Dynamic, 57 | MaxColsAtCompileTime = (MatrixType::MaxColsAtCompileTime != Dynamic) ? 58 | int(MatrixType::MaxColsAtCompileTime) - 1 : Dynamic, 59 | Flags = _MatrixTypeNested::Flags & (HereditaryBits | LvalueBit), 60 | CoeffReadCost = _MatrixTypeNested::CoeffReadCost // minor is used typically on tiny matrices, 61 | // where loops are unrolled and the 'if' evaluates at compile time 62 | }; 63 | }; 64 | } 65 | 66 | template class Minor 67 | : public MatrixBase > 68 | { 69 | public: 70 | 71 | typedef MatrixBase Base; 72 | EIGEN_DENSE_PUBLIC_INTERFACE(Minor) 73 | 74 | inline Minor(const MatrixType& matrix, 75 | Index row, Index col) 76 | : m_matrix(matrix), m_row(row), m_col(col) 77 | { 78 | eigen_assert(row >= 0 && row < matrix.rows() 79 | && col >= 0 && col < matrix.cols()); 80 | } 81 | 82 | EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Minor) 83 | 84 | inline Index rows() const { return m_matrix.rows() - 1; } 85 | inline Index cols() const { return m_matrix.cols() - 1; } 86 | 87 | inline Scalar& coeffRef(Index row, Index col) 88 | { 89 | return m_matrix.const_cast_derived().coeffRef(row + (row >= m_row), col + (col >= m_col)); 90 | } 91 | 92 | inline const Scalar coeff(Index row, Index col) const 93 | { 94 | return m_matrix.coeff(row + (row >= m_row), col + (col >= m_col)); 95 | } 96 | 97 | protected: 98 | const typename MatrixType::Nested m_matrix; 99 | const Index m_row, m_col; 100 | }; 101 | 102 | /** 103 | * \return an expression of the (\a row, \a col)-minor of *this, 104 | * i.e. an expression constructed from *this by removing the specified 105 | * row and column. 106 | * 107 | * Example: \include MatrixBase_minor.cpp 108 | * Output: \verbinclude MatrixBase_minor.out 109 | * 110 | * \sa class Minor 111 | */ 112 | template 113 | inline Minor 114 | MatrixBase::minor(Index row, Index col) 115 | { 116 | return Minor(derived(), row, col); 117 | } 118 | 119 | /** 120 | * This is the const version of minor(). */ 121 | template 122 | inline const Minor 123 | MatrixBase::minor(Index row, Index col) const 124 | { 125 | return Minor(derived(), row, col); 126 | } 127 | 128 | #endif // EIGEN_MINOR_H 129 | -------------------------------------------------------------------------------- /src/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 | // Eigen is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU Lesser General Public 9 | // License as published by the Free Software Foundation; either 10 | // version 3 of the License, or (at your option) any later version. 11 | // 12 | // Alternatively, you can redistribute it and/or 13 | // modify it under the terms of the GNU General Public License as 14 | // published by the Free Software Foundation; either version 2 of 15 | // the License, or (at your option) any later version. 16 | // 17 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 18 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 19 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 20 | // GNU General Public License for more details. 21 | // 22 | // You should have received a copy of the GNU Lesser General Public 23 | // License and a copy of the GNU General Public License along with 24 | // Eigen. If not, see . 25 | 26 | #ifndef EIGEN2_QR_H 27 | #define EIGEN2_QR_H 28 | 29 | template 30 | class QR : public HouseholderQR 31 | { 32 | public: 33 | 34 | typedef HouseholderQR Base; 35 | typedef Block MatrixRBlockType; 36 | 37 | QR() : Base() {} 38 | 39 | template 40 | explicit QR(const T& t) : Base(t) {} 41 | 42 | template 43 | bool solve(const MatrixBase& b, ResultType *result) const 44 | { 45 | *result = static_cast(this)->solve(b); 46 | return true; 47 | } 48 | 49 | MatrixType matrixQ(void) const { 50 | MatrixType ret = MatrixType::Identity(this->rows(), this->cols()); 51 | ret = this->householderQ() * ret; 52 | return ret; 53 | } 54 | 55 | bool isFullRank() const { 56 | return true; 57 | } 58 | 59 | const TriangularView 60 | matrixR(void) const 61 | { 62 | int cols = this->cols(); 63 | return MatrixRBlockType(this->matrixQR(), 0, 0, cols, cols).template triangularView(); 64 | } 65 | }; 66 | 67 | /** \return the QR decomposition of \c *this. 68 | * 69 | * \sa class QR 70 | */ 71 | template 72 | const QR::PlainObject> 73 | MatrixBase::qr() const 74 | { 75 | return QR(eval()); 76 | } 77 | 78 | 79 | #endif // EIGEN2_QR_H 80 | -------------------------------------------------------------------------------- /src/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 | // Eigen is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU Lesser General Public 8 | // License as published by the Free Software Foundation; either 9 | // version 3 of the License, or (at your option) any later version. 10 | // 11 | // Alternatively, you can redistribute it and/or 12 | // modify it under the terms of the GNU General Public License as 13 | // published by the Free Software Foundation; either version 2 of 14 | // the License, or (at your option) any later version. 15 | // 16 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 17 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU Lesser General Public 22 | // License and a copy of the GNU General Public License along with 23 | // Eigen. If not, see . 24 | 25 | #ifndef EIGEN_TRIANGULAR_SOLVER2_H 26 | #define EIGEN_TRIANGULAR_SOLVER2_H 27 | 28 | const unsigned int UnitDiagBit = UnitDiag; 29 | const unsigned int SelfAdjointBit = SelfAdjoint; 30 | const unsigned int UpperTriangularBit = Upper; 31 | const unsigned int LowerTriangularBit = Lower; 32 | 33 | const unsigned int UpperTriangular = Upper; 34 | const unsigned int LowerTriangular = Lower; 35 | const unsigned int UnitUpperTriangular = UnitUpper; 36 | const unsigned int UnitLowerTriangular = UnitLower; 37 | 38 | template 39 | template 40 | typename ExpressionType::PlainObject 41 | Flagged::solveTriangular(const MatrixBase& other) const 42 | { 43 | return m_matrix.template triangularView().solve(other.derived()); 44 | } 45 | 46 | template 47 | template 48 | void Flagged::solveTriangularInPlace(const MatrixBase& other) const 49 | { 50 | m_matrix.template triangularView().solveInPlace(other.derived()); 51 | } 52 | 53 | #endif // EIGEN_TRIANGULAR_SOLVER2_H 54 | -------------------------------------------------------------------------------- /src/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 | // Eigen is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU Lesser General Public 9 | // License as published by the Free Software Foundation; either 10 | // version 3 of the License, or (at your option) any later version. 11 | // 12 | // Alternatively, you can redistribute it and/or 13 | // modify it under the terms of the GNU General Public License as 14 | // published by the Free Software Foundation; either version 2 of 15 | // the License, or (at your option) any later version. 16 | // 17 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 18 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 19 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 20 | // GNU General Public License for more details. 21 | // 22 | // You should have received a copy of the GNU Lesser General Public 23 | // License and a copy of the GNU General Public License along with 24 | // Eigen. If not, see . 25 | 26 | #ifndef EIGEN2_VECTORBLOCK_H 27 | #define EIGEN2_VECTORBLOCK_H 28 | 29 | /** \deprecated use DenseMase::head(Index) */ 30 | template 31 | inline VectorBlock 32 | MatrixBase::start(Index size) 33 | { 34 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 35 | return VectorBlock(derived(), 0, size); 36 | } 37 | 38 | /** \deprecated use DenseMase::head(Index) */ 39 | template 40 | inline const VectorBlock 41 | MatrixBase::start(Index size) const 42 | { 43 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 44 | return VectorBlock(derived(), 0, size); 45 | } 46 | 47 | /** \deprecated use DenseMase::tail(Index) */ 48 | template 49 | inline VectorBlock 50 | MatrixBase::end(Index size) 51 | { 52 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 53 | return VectorBlock(derived(), this->size() - size, size); 54 | } 55 | 56 | /** \deprecated use DenseMase::tail(Index) */ 57 | template 58 | inline const VectorBlock 59 | MatrixBase::end(Index size) const 60 | { 61 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 62 | return VectorBlock(derived(), this->size() - size, size); 63 | } 64 | 65 | /** \deprecated use DenseMase::head() */ 66 | template 67 | template 68 | inline VectorBlock 69 | MatrixBase::start() 70 | { 71 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 72 | return VectorBlock(derived(), 0); 73 | } 74 | 75 | /** \deprecated use DenseMase::head() */ 76 | template 77 | template 78 | inline const VectorBlock 79 | MatrixBase::start() const 80 | { 81 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 82 | return VectorBlock(derived(), 0); 83 | } 84 | 85 | /** \deprecated use DenseMase::tail() */ 86 | template 87 | template 88 | inline VectorBlock 89 | MatrixBase::end() 90 | { 91 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 92 | return VectorBlock(derived(), size() - Size); 93 | } 94 | 95 | /** \deprecated use DenseMase::tail() */ 96 | template 97 | template 98 | inline const VectorBlock 99 | MatrixBase::end() const 100 | { 101 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 102 | return VectorBlock(derived(), size() - Size); 103 | } 104 | 105 | #endif // EIGEN2_VECTORBLOCK_H 106 | -------------------------------------------------------------------------------- /src/Eigen/src/Eigenvalues/EigenvaluesCommon.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2010 Jitse Niesen 5 | // 6 | // Eigen is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU Lesser General Public 8 | // License as published by the Free Software Foundation; either 9 | // version 3 of the License, or (at your option) any later version. 10 | // 11 | // Alternatively, you can redistribute it and/or 12 | // modify it under the terms of the GNU General Public License as 13 | // published by the Free Software Foundation; either version 2 of 14 | // the License, or (at your option) any later version. 15 | // 16 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 17 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU Lesser General Public 22 | // License and a copy of the GNU General Public License along with 23 | // Eigen. If not, see . 24 | 25 | #ifndef EIGEN_EIGENVALUES_COMMON_H 26 | #define EIGEN_EIGENVALUES_COMMON_H 27 | 28 | 29 | 30 | #endif // EIGEN_EIGENVALUES_COMMON_H 31 | 32 | -------------------------------------------------------------------------------- /src/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 | // Eigen is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU Lesser General Public 8 | // License as published by the Free Software Foundation; either 9 | // version 3 of the License, or (at your option) any later version. 10 | // 11 | // Alternatively, you can redistribute it and/or 12 | // modify it under the terms of the GNU General Public License as 13 | // published by the Free Software Foundation; either version 2 of 14 | // the License, or (at your option) any later version. 15 | // 16 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 17 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU Lesser General Public 22 | // License and a copy of the GNU General Public License along with 23 | // Eigen. If not, see . 24 | 25 | #ifndef EIGEN_EULERANGLES_H 26 | #define EIGEN_EULERANGLES_H 27 | 28 | /** \geometry_module \ingroup Geometry_Module 29 | * 30 | * 31 | * \returns the Euler-angles of the rotation matrix \c *this using the convention defined by the triplet (\a a0,\a a1,\a a2) 32 | * 33 | * Each of the three parameters \a a0,\a a1,\a a2 represents the respective rotation axis as an integer in {0,1,2}. 34 | * For instance, in: 35 | * \code Vector3f ea = mat.eulerAngles(2, 0, 2); \endcode 36 | * "2" represents the z axis and "0" the x axis, etc. The returned angles are such that 37 | * we have the following equality: 38 | * \code 39 | * mat == AngleAxisf(ea[0], Vector3f::UnitZ()) 40 | * * AngleAxisf(ea[1], Vector3f::UnitX()) 41 | * * AngleAxisf(ea[2], Vector3f::UnitZ()); \endcode 42 | * This corresponds to the right-multiply conventions (with right hand side frames). 43 | */ 44 | template 45 | inline Matrix::Scalar,3,1> 46 | MatrixBase::eulerAngles(Index a0, Index a1, Index a2) const 47 | { 48 | /* Implemented from Graphics Gems IV */ 49 | EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Derived,3,3) 50 | 51 | Matrix res; 52 | typedef Matrix Vector2; 53 | const Scalar epsilon = NumTraits::dummy_precision(); 54 | 55 | const Index odd = ((a0+1)%3 == a1) ? 0 : 1; 56 | const Index i = a0; 57 | const Index j = (a0 + 1 + odd)%3; 58 | const Index k = (a0 + 2 - odd)%3; 59 | 60 | if (a0==a2) 61 | { 62 | Scalar s = Vector2(coeff(j,i) , coeff(k,i)).norm(); 63 | res[1] = internal::atan2(s, coeff(i,i)); 64 | if (s > epsilon) 65 | { 66 | res[0] = internal::atan2(coeff(j,i), coeff(k,i)); 67 | res[2] = internal::atan2(coeff(i,j),-coeff(i,k)); 68 | } 69 | else 70 | { 71 | res[0] = Scalar(0); 72 | res[2] = (coeff(i,i)>0?1:-1)*internal::atan2(-coeff(k,j), coeff(j,j)); 73 | } 74 | } 75 | else 76 | { 77 | Scalar c = Vector2(coeff(i,i) , coeff(i,j)).norm(); 78 | res[1] = internal::atan2(-coeff(i,k), c); 79 | if (c > epsilon) 80 | { 81 | res[0] = internal::atan2(coeff(j,k), coeff(k,k)); 82 | res[2] = internal::atan2(coeff(i,j), coeff(i,i)); 83 | } 84 | else 85 | { 86 | res[0] = Scalar(0); 87 | res[2] = (coeff(i,k)>0?1:-1)*internal::atan2(-coeff(k,j), coeff(j,j)); 88 | } 89 | } 90 | if (!odd) 91 | res = -res; 92 | return res; 93 | } 94 | 95 | 96 | #endif // EIGEN_EULERANGLES_H 97 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/Eigen/src/Geometry/arch/Geometry_SSE.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Rohit Garg 5 | // Copyright (C) 2009-2010 Gael Guennebaud 6 | // 7 | // Eigen is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU Lesser General Public 9 | // License as published by the Free Software Foundation; either 10 | // version 3 of the License, or (at your option) any later version. 11 | // 12 | // Alternatively, you can redistribute it and/or 13 | // modify it under the terms of the GNU General Public License as 14 | // published by the Free Software Foundation; either version 2 of 15 | // the License, or (at your option) any later version. 16 | // 17 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 18 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 19 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 20 | // GNU General Public License for more details. 21 | // 22 | // You should have received a copy of the GNU Lesser General Public 23 | // License and a copy of the GNU General Public License along with 24 | // Eigen. If not, see . 25 | 26 | #ifndef EIGEN_GEOMETRY_SSE_H 27 | #define EIGEN_GEOMETRY_SSE_H 28 | 29 | namespace internal { 30 | 31 | template 32 | struct quat_product 33 | { 34 | inline static Quaternion run(const QuaternionBase& _a, const QuaternionBase& _b) 35 | { 36 | const __m128 mask = _mm_castsi128_ps(_mm_setr_epi32(0,0,0,0x80000000)); 37 | Quaternion res; 38 | __m128 a = _a.coeffs().template packet(0); 39 | __m128 b = _b.coeffs().template packet(0); 40 | __m128 flip1 = _mm_xor_ps(_mm_mul_ps(vec4f_swizzle1(a,1,2,0,2), 41 | vec4f_swizzle1(b,2,0,1,2)),mask); 42 | __m128 flip2 = _mm_xor_ps(_mm_mul_ps(vec4f_swizzle1(a,3,3,3,1), 43 | vec4f_swizzle1(b,0,1,2,1)),mask); 44 | pstore(&res.x(), 45 | _mm_add_ps(_mm_sub_ps(_mm_mul_ps(a,vec4f_swizzle1(b,3,3,3,3)), 46 | _mm_mul_ps(vec4f_swizzle1(a,2,0,1,0), 47 | vec4f_swizzle1(b,1,2,0,0))), 48 | _mm_add_ps(flip1,flip2))); 49 | return res; 50 | } 51 | }; 52 | 53 | template 54 | struct cross3_impl 55 | { 56 | inline static typename plain_matrix_type::type 57 | run(const VectorLhs& lhs, const VectorRhs& rhs) 58 | { 59 | __m128 a = lhs.template packet(0); 60 | __m128 b = rhs.template packet(0); 61 | __m128 mul1=_mm_mul_ps(vec4f_swizzle1(a,1,2,0,3),vec4f_swizzle1(b,2,0,1,3)); 62 | __m128 mul2=_mm_mul_ps(vec4f_swizzle1(a,2,0,1,3),vec4f_swizzle1(b,1,2,0,3)); 63 | typename plain_matrix_type::type res; 64 | pstore(&res.x(),_mm_sub_ps(mul1,mul2)); 65 | return res; 66 | } 67 | }; 68 | 69 | 70 | 71 | 72 | template 73 | struct quat_product 74 | { 75 | inline static Quaternion run(const QuaternionBase& _a, const QuaternionBase& _b) 76 | { 77 | const Packet2d mask = _mm_castsi128_pd(_mm_set_epi32(0x0,0x0,0x80000000,0x0)); 78 | 79 | Quaternion res; 80 | 81 | const double* a = _a.coeffs().data(); 82 | Packet2d b_xy = _b.coeffs().template packet(0); 83 | Packet2d b_zw = _b.coeffs().template packet(2); 84 | Packet2d a_xx = pset1(a[0]); 85 | Packet2d a_yy = pset1(a[1]); 86 | Packet2d a_zz = pset1(a[2]); 87 | Packet2d a_ww = pset1(a[3]); 88 | 89 | // two temporaries: 90 | Packet2d t1, t2; 91 | 92 | /* 93 | * t1 = ww*xy + yy*zw 94 | * t2 = zz*xy - xx*zw 95 | * res.xy = t1 +/- swap(t2) 96 | */ 97 | t1 = padd(pmul(a_ww, b_xy), pmul(a_yy, b_zw)); 98 | t2 = psub(pmul(a_zz, b_xy), pmul(a_xx, b_zw)); 99 | #ifdef __SSE3__ 100 | EIGEN_UNUSED_VARIABLE(mask) 101 | pstore(&res.x(), _mm_addsub_pd(t1, preverse(t2))); 102 | #else 103 | pstore(&res.x(), padd(t1, pxor(mask,preverse(t2)))); 104 | #endif 105 | 106 | /* 107 | * t1 = ww*zw - yy*xy 108 | * t2 = zz*zw + xx*xy 109 | * res.zw = t1 -/+ swap(t2) = swap( swap(t1) +/- t2) 110 | */ 111 | t1 = psub(pmul(a_ww, b_zw), pmul(a_yy, b_xy)); 112 | t2 = padd(pmul(a_zz, b_zw), pmul(a_xx, b_xy)); 113 | #ifdef __SSE3__ 114 | EIGEN_UNUSED_VARIABLE(mask) 115 | pstore(&res.z(), preverse(_mm_addsub_pd(preverse(t1), t2))); 116 | #else 117 | pstore(&res.z(), psub(t1, pxor(mask,preverse(t2)))); 118 | #endif 119 | 120 | return res; 121 | } 122 | }; 123 | 124 | } // end namespace internal 125 | 126 | #endif // EIGEN_GEOMETRY_SSE_H 127 | -------------------------------------------------------------------------------- /src/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 | // Eigen is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU Lesser General Public 9 | // License as published by the Free Software Foundation; either 10 | // version 3 of the License, or (at your option) any later version. 11 | // 12 | // Alternatively, you can redistribute it and/or 13 | // modify it under the terms of the GNU General Public License as 14 | // published by the Free Software Foundation; either version 2 of 15 | // the License, or (at your option) any later version. 16 | // 17 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 18 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 19 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 20 | // GNU General Public License for more details. 21 | // 22 | // You should have received a copy of the GNU Lesser General Public 23 | // License and a copy of the GNU General Public License along with 24 | // Eigen. If not, see . 25 | 26 | #ifndef EIGEN_BLOCK_HOUSEHOLDER_H 27 | #define EIGEN_BLOCK_HOUSEHOLDER_H 28 | 29 | // This file contains some helper function to deal with block householder reflectors 30 | 31 | namespace internal { 32 | 33 | /** \internal */ 34 | template 35 | void make_block_householder_triangular_factor(TriangularFactorType& triFactor, const VectorsType& vectors, const CoeffsType& hCoeffs) 36 | { 37 | typedef typename TriangularFactorType::Index Index; 38 | typedef typename VectorsType::Scalar Scalar; 39 | const Index nbVecs = vectors.cols(); 40 | eigen_assert(triFactor.rows() == nbVecs && triFactor.cols() == nbVecs && vectors.rows()>=nbVecs); 41 | 42 | for(Index i = 0; i < nbVecs; i++) 43 | { 44 | Index rs = vectors.rows() - i; 45 | Scalar Vii = vectors(i,i); 46 | vectors.const_cast_derived().coeffRef(i,i) = Scalar(1); 47 | triFactor.col(i).head(i).noalias() = -hCoeffs(i) * vectors.block(i, 0, rs, i).adjoint() 48 | * vectors.col(i).tail(rs); 49 | vectors.const_cast_derived().coeffRef(i, i) = Vii; 50 | // FIXME add .noalias() once the triangular product can work inplace 51 | triFactor.col(i).head(i) = triFactor.block(0,0,i,i).template triangularView() 52 | * triFactor.col(i).head(i); 53 | triFactor(i,i) = hCoeffs(i); 54 | } 55 | } 56 | 57 | /** \internal */ 58 | template 59 | void apply_block_householder_on_the_left(MatrixType& mat, const VectorsType& vectors, const CoeffsType& hCoeffs) 60 | { 61 | typedef typename MatrixType::Index Index; 62 | enum { TFactorSize = MatrixType::ColsAtCompileTime }; 63 | Index nbVecs = vectors.cols(); 64 | Matrix T(nbVecs,nbVecs); 65 | make_block_householder_triangular_factor(T, vectors, hCoeffs); 66 | 67 | const TriangularView& V(vectors); 68 | 69 | // A -= V T V^* A 70 | Matrix tmp = V.adjoint() * mat; 72 | // FIXME add .noalias() once the triangular product can work inplace 73 | tmp = T.template triangularView().adjoint() * tmp; 74 | mat.noalias() -= V * tmp; 75 | } 76 | 77 | } // end namespace internal 78 | 79 | #endif // EIGEN_BLOCK_HOUSEHOLDER_H 80 | -------------------------------------------------------------------------------- /src/Eigen/src/Householder/Householder.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 | // Copyright (C) 2009 Gael Guennebaud 6 | // 7 | // Eigen is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU Lesser General Public 9 | // License as published by the Free Software Foundation; either 10 | // version 3 of the License, or (at your option) any later version. 11 | // 12 | // Alternatively, you can redistribute it and/or 13 | // modify it under the terms of the GNU General Public License as 14 | // published by the Free Software Foundation; either version 2 of 15 | // the License, or (at your option) any later version. 16 | // 17 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 18 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 19 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 20 | // GNU General Public License for more details. 21 | // 22 | // You should have received a copy of the GNU Lesser General Public 23 | // License and a copy of the GNU General Public License along with 24 | // Eigen. If not, see . 25 | 26 | #ifndef EIGEN_HOUSEHOLDER_H 27 | #define EIGEN_HOUSEHOLDER_H 28 | 29 | namespace internal { 30 | template struct decrement_size 31 | { 32 | enum { 33 | ret = n==Dynamic ? n : n-1 34 | }; 35 | }; 36 | } 37 | 38 | template 39 | void MatrixBase::makeHouseholderInPlace(Scalar& tau, RealScalar& beta) 40 | { 41 | VectorBlock::ret> essentialPart(derived(), 1, size()-1); 42 | makeHouseholder(essentialPart, tau, beta); 43 | } 44 | 45 | /** Computes the elementary reflector H such that: 46 | * \f$ H *this = [ beta 0 ... 0]^T \f$ 47 | * where the transformation H is: 48 | * \f$ H = I - tau v v^*\f$ 49 | * and the vector v is: 50 | * \f$ v^T = [1 essential^T] \f$ 51 | * 52 | * On output: 53 | * \param essential the essential part of the vector \c v 54 | * \param tau the scaling factor of the householder transformation 55 | * \param beta the result of H * \c *this 56 | * 57 | * \sa MatrixBase::makeHouseholderInPlace(), MatrixBase::applyHouseholderOnTheLeft(), 58 | * MatrixBase::applyHouseholderOnTheRight() 59 | */ 60 | template 61 | template 62 | void MatrixBase::makeHouseholder( 63 | EssentialPart& essential, 64 | Scalar& tau, 65 | RealScalar& beta) const 66 | { 67 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(EssentialPart) 68 | VectorBlock tail(derived(), 1, size()-1); 69 | 70 | RealScalar tailSqNorm = size()==1 ? RealScalar(0) : tail.squaredNorm(); 71 | Scalar c0 = coeff(0); 72 | 73 | if(tailSqNorm == RealScalar(0) && internal::imag(c0)==RealScalar(0)) 74 | { 75 | tau = RealScalar(0); 76 | beta = internal::real(c0); 77 | essential.setZero(); 78 | } 79 | else 80 | { 81 | beta = internal::sqrt(internal::abs2(c0) + tailSqNorm); 82 | if (internal::real(c0)>=RealScalar(0)) 83 | beta = -beta; 84 | essential = tail / (c0 - beta); 85 | tau = internal::conj((beta - c0) / beta); 86 | } 87 | } 88 | 89 | template 90 | template 91 | void MatrixBase::applyHouseholderOnTheLeft( 92 | const EssentialPart& essential, 93 | const Scalar& tau, 94 | Scalar* workspace) 95 | { 96 | if(rows() == 1) 97 | { 98 | *this *= Scalar(1)-tau; 99 | } 100 | else 101 | { 102 | Map::type> tmp(workspace,cols()); 103 | Block bottom(derived(), 1, 0, rows()-1, cols()); 104 | tmp.noalias() = essential.adjoint() * bottom; 105 | tmp += this->row(0); 106 | this->row(0) -= tau * tmp; 107 | bottom.noalias() -= tau * essential * tmp; 108 | } 109 | } 110 | 111 | template 112 | template 113 | void MatrixBase::applyHouseholderOnTheRight( 114 | const EssentialPart& essential, 115 | const Scalar& tau, 116 | Scalar* workspace) 117 | { 118 | if(cols() == 1) 119 | { 120 | *this *= Scalar(1)-tau; 121 | } 122 | else 123 | { 124 | Map::type> tmp(workspace,rows()); 125 | Block right(derived(), 0, 1, rows(), cols()-1); 126 | tmp.noalias() = right * essential.conjugate(); 127 | tmp += this->col(0); 128 | this->col(0) -= tau * tmp; 129 | right.noalias() -= tau * tmp * essential.transpose(); 130 | } 131 | } 132 | 133 | #endif // EIGEN_HOUSEHOLDER_H 134 | -------------------------------------------------------------------------------- /src/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 | // Eigen is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU Lesser General Public 8 | // License as published by the Free Software Foundation; either 9 | // version 3 of the License, or (at your option) any later version. 10 | // 11 | // Alternatively, you can redistribute it and/or 12 | // modify it under the terms of the GNU General Public License as 13 | // published by the Free Software Foundation; either version 2 of 14 | // the License, or (at your option) any later version. 15 | // 16 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 17 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU Lesser General Public 22 | // License and a copy of the GNU General Public License along with 23 | // Eigen. If not, see . 24 | 25 | #ifndef EIGEN_DETERMINANT_H 26 | #define EIGEN_DETERMINANT_H 27 | 28 | namespace internal { 29 | 30 | template 31 | inline const typename Derived::Scalar bruteforce_det3_helper 32 | (const MatrixBase& matrix, int a, int b, int c) 33 | { 34 | return matrix.coeff(0,a) 35 | * (matrix.coeff(1,b) * matrix.coeff(2,c) - matrix.coeff(1,c) * matrix.coeff(2,b)); 36 | } 37 | 38 | template 39 | const typename Derived::Scalar bruteforce_det4_helper 40 | (const MatrixBase& matrix, int j, int k, int m, int n) 41 | { 42 | return (matrix.coeff(j,0) * matrix.coeff(k,1) - matrix.coeff(k,0) * matrix.coeff(j,1)) 43 | * (matrix.coeff(m,2) * matrix.coeff(n,3) - matrix.coeff(n,2) * matrix.coeff(m,3)); 44 | } 45 | 46 | template struct determinant_impl 49 | { 50 | static inline typename traits::Scalar run(const Derived& m) 51 | { 52 | if(Derived::ColsAtCompileTime==Dynamic && m.rows()==0) 53 | return typename traits::Scalar(1); 54 | return m.partialPivLu().determinant(); 55 | } 56 | }; 57 | 58 | template struct determinant_impl 59 | { 60 | static inline typename traits::Scalar run(const Derived& m) 61 | { 62 | return m.coeff(0,0); 63 | } 64 | }; 65 | 66 | template struct determinant_impl 67 | { 68 | static inline typename traits::Scalar run(const Derived& m) 69 | { 70 | return m.coeff(0,0) * m.coeff(1,1) - m.coeff(1,0) * m.coeff(0,1); 71 | } 72 | }; 73 | 74 | template struct determinant_impl 75 | { 76 | static inline typename traits::Scalar run(const Derived& m) 77 | { 78 | return bruteforce_det3_helper(m,0,1,2) 79 | - bruteforce_det3_helper(m,1,0,2) 80 | + bruteforce_det3_helper(m,2,0,1); 81 | } 82 | }; 83 | 84 | template struct determinant_impl 85 | { 86 | static typename traits::Scalar run(const Derived& m) 87 | { 88 | // trick by Martin Costabel to compute 4x4 det with only 30 muls 89 | return bruteforce_det4_helper(m,0,1,2,3) 90 | - bruteforce_det4_helper(m,0,2,1,3) 91 | + bruteforce_det4_helper(m,0,3,1,2) 92 | + bruteforce_det4_helper(m,1,2,0,3) 93 | - bruteforce_det4_helper(m,1,3,0,2) 94 | + bruteforce_det4_helper(m,2,3,0,1); 95 | } 96 | }; 97 | 98 | } // end namespace internal 99 | 100 | /** \lu_module 101 | * 102 | * \returns the determinant of this matrix 103 | */ 104 | template 105 | inline typename internal::traits::Scalar MatrixBase::determinant() const 106 | { 107 | assert(rows() == cols()); 108 | typedef typename internal::nested::type Nested; 109 | return internal::determinant_impl::type>::run(derived()); 110 | } 111 | 112 | #endif // EIGEN_DETERMINANT_H 113 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/Eigen/src/Sparse/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 | // Eigen is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU Lesser General Public 8 | // License as published by the Free Software Foundation; either 9 | // version 3 of the License, or (at your option) any later version. 10 | // 11 | // Alternatively, you can redistribute it and/or 12 | // modify it under the terms of the GNU General Public License as 13 | // published by the Free Software Foundation; either version 2 of 14 | // the License, or (at your option) any later version. 15 | // 16 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 17 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU Lesser General Public 22 | // License and a copy of the GNU General Public License along with 23 | // Eigen. If not, see . 24 | 25 | #ifndef EIGEN_COREITERATORS_H 26 | #define EIGEN_COREITERATORS_H 27 | 28 | /* This file contains the respective InnerIterator definition of the expressions defined in Eigen/Core 29 | */ 30 | 31 | /** \class InnerIterator 32 | * \brief An InnerIterator allows to loop over the element of a sparse (or dense) matrix or expression 33 | * 34 | * todo 35 | */ 36 | 37 | // generic version for dense matrix and expressions 38 | template class DenseBase::InnerIterator 39 | { 40 | protected: 41 | typedef typename Derived::Scalar Scalar; 42 | typedef typename Derived::Index Index; 43 | 44 | enum { IsRowMajor = (Derived::Flags&RowMajorBit)==RowMajorBit }; 45 | public: 46 | EIGEN_STRONG_INLINE InnerIterator(const Derived& expr, Index outer) 47 | : m_expression(expr), m_inner(0), m_outer(outer), m_end(expr.innerSize()) 48 | {} 49 | 50 | EIGEN_STRONG_INLINE Scalar value() const 51 | { 52 | return (IsRowMajor) ? m_expression.coeff(m_outer, m_inner) 53 | : m_expression.coeff(m_inner, m_outer); 54 | } 55 | 56 | EIGEN_STRONG_INLINE InnerIterator& operator++() { m_inner++; return *this; } 57 | 58 | EIGEN_STRONG_INLINE Index index() const { return m_inner; } 59 | inline Index row() const { return IsRowMajor ? m_outer : index(); } 60 | inline Index col() const { return IsRowMajor ? index() : m_outer; } 61 | 62 | EIGEN_STRONG_INLINE operator bool() const { return m_inner < m_end && m_inner>=0; } 63 | 64 | protected: 65 | const Derived& m_expression; 66 | Index m_inner; 67 | const Index m_outer; 68 | const Index m_end; 69 | }; 70 | 71 | #endif // EIGEN_COREITERATORS_H 72 | -------------------------------------------------------------------------------- /src/Eigen/src/Sparse/SparseAssign.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cbraley/hdr/1453818cc97eb498effa1a32f751972bdd135ab3/src/Eigen/src/Sparse/SparseAssign.h -------------------------------------------------------------------------------- /src/Eigen/src/Sparse/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 | // Eigen is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU Lesser General Public 8 | // License as published by the Free Software Foundation; either 9 | // version 3 of the License, or (at your option) any later version. 10 | // 11 | // Alternatively, you can redistribute it and/or 12 | // modify it under the terms of the GNU General Public License as 13 | // published by the Free Software Foundation; either version 2 of 14 | // the License, or (at your option) any later version. 15 | // 16 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 17 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU Lesser General Public 22 | // License and a copy of the GNU General Public License along with 23 | // Eigen. If not, see . 24 | 25 | #ifndef EIGEN_SPARSE_DOT_H 26 | #define EIGEN_SPARSE_DOT_H 27 | 28 | template 29 | template 30 | typename internal::traits::Scalar 31 | SparseMatrixBase::dot(const MatrixBase& other) const 32 | { 33 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 34 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived) 35 | EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(Derived,OtherDerived) 36 | EIGEN_STATIC_ASSERT((internal::is_same::value), 37 | YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY) 38 | 39 | eigen_assert(size() == other.size()); 40 | eigen_assert(other.size()>0 && "you are using a non initialized vector"); 41 | 42 | typename Derived::InnerIterator i(derived(),0); 43 | Scalar res = 0; 44 | while (i) 45 | { 46 | res += internal::conj(i.value()) * other.coeff(i.index()); 47 | ++i; 48 | } 49 | return res; 50 | } 51 | 52 | template 53 | template 54 | typename internal::traits::Scalar 55 | SparseMatrixBase::dot(const SparseMatrixBase& other) const 56 | { 57 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 58 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived) 59 | EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(Derived,OtherDerived) 60 | EIGEN_STATIC_ASSERT((internal::is_same::value), 61 | YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY) 62 | 63 | eigen_assert(size() == other.size()); 64 | 65 | typename Derived::InnerIterator i(derived(),0); 66 | typename OtherDerived::InnerIterator j(other.derived(),0); 67 | Scalar res = 0; 68 | while (i && j) 69 | { 70 | if (i.index()==j.index()) 71 | { 72 | res += internal::conj(i.value()) * j.value(); 73 | ++i; ++j; 74 | } 75 | else if (i.index() 84 | inline typename NumTraits::Scalar>::Real 85 | SparseMatrixBase::squaredNorm() const 86 | { 87 | return internal::real((*this).cwiseAbs2().sum()); 88 | } 89 | 90 | template 91 | inline typename NumTraits::Scalar>::Real 92 | SparseMatrixBase::norm() const 93 | { 94 | return internal::sqrt(squaredNorm()); 95 | } 96 | 97 | #endif // EIGEN_SPARSE_DOT_H 98 | -------------------------------------------------------------------------------- /src/Eigen/src/Sparse/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 | // Eigen is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU Lesser General Public 8 | // License as published by the Free Software Foundation; either 9 | // version 3 of the License, or (at your option) any later version. 10 | // 11 | // Alternatively, you can redistribute it and/or 12 | // modify it under the terms of the GNU General Public License as 13 | // published by the Free Software Foundation; either version 2 of 14 | // the License, or (at your option) any later version. 15 | // 16 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 17 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU Lesser General Public 22 | // License and a copy of the GNU General Public License along with 23 | // Eigen. If not, see . 24 | 25 | #ifndef EIGEN_SPARSE_FUZZY_H 26 | #define EIGEN_SPARSE_FUZZY_H 27 | 28 | // template 29 | // template 30 | // bool SparseMatrixBase::isApprox( 31 | // const OtherDerived& other, 32 | // typename NumTraits::Real prec 33 | // ) const 34 | // { 35 | // const typename internal::nested::type nested(derived()); 36 | // const typename internal::nested::type otherNested(other.derived()); 37 | // return (nested - otherNested).cwise().abs2().sum() 38 | // <= prec * prec * (std::min)(nested.cwise().abs2().sum(), otherNested.cwise().abs2().sum()); 39 | // } 40 | 41 | #endif // EIGEN_SPARSE_FUZZY_H 42 | -------------------------------------------------------------------------------- /src/Eigen/src/Sparse/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 | // Eigen is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU Lesser General Public 8 | // License as published by the Free Software Foundation; either 9 | // version 3 of the License, or (at your option) any later version. 10 | // 11 | // Alternatively, you can redistribute it and/or 12 | // modify it under the terms of the GNU General Public License as 13 | // published by the Free Software Foundation; either version 2 of 14 | // the License, or (at your option) any later version. 15 | // 16 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 17 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU Lesser General Public 22 | // License and a copy of the GNU General Public License along with 23 | // Eigen. If not, see . 24 | 25 | #ifndef EIGEN_SPARSEREDUX_H 26 | #define EIGEN_SPARSEREDUX_H 27 | 28 | template 29 | typename internal::traits::Scalar 30 | SparseMatrixBase::sum() const 31 | { 32 | eigen_assert(rows()>0 && cols()>0 && "you are using a non initialized matrix"); 33 | Scalar res = 0; 34 | for (Index j=0; j 41 | typename internal::traits >::Scalar 42 | SparseMatrix<_Scalar,_Options,_Index>::sum() const 43 | { 44 | eigen_assert(rows()>0 && cols()>0 && "you are using a non initialized matrix"); 45 | return Matrix::Map(&m_data.value(0), m_data.size()).sum(); 46 | } 47 | 48 | template 49 | typename internal::traits >::Scalar 50 | SparseVector<_Scalar,_Options,_Index>::sum() const 51 | { 52 | eigen_assert(rows()>0 && cols()>0 && "you are using a non initialized matrix"); 53 | return Matrix::Map(&m_data.value(0), m_data.size()).sum(); 54 | } 55 | 56 | #endif // EIGEN_SPARSEREDUX_H 57 | -------------------------------------------------------------------------------- /src/Eigen/src/Sparse/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 | // Eigen is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU Lesser General Public 8 | // License as published by the Free Software Foundation; either 9 | // version 3 of the License, or (at your option) any later version. 10 | // 11 | // Alternatively, you can redistribute it and/or 12 | // modify it under the terms of the GNU General Public License as 13 | // published by the Free Software Foundation; either version 2 of 14 | // the License, or (at your option) any later version. 15 | // 16 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 17 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU Lesser General Public 22 | // License and a copy of the GNU General Public License along with 23 | // Eigen. If not, see . 24 | 25 | #ifndef EIGEN_SPARSETRANSPOSE_H 26 | #define EIGEN_SPARSETRANSPOSE_H 27 | 28 | template class TransposeImpl 29 | : public SparseMatrixBase > 30 | { 31 | typedef typename internal::remove_all::type _MatrixTypeNested; 32 | public: 33 | 34 | EIGEN_SPARSE_PUBLIC_INTERFACE(Transpose) 35 | 36 | class InnerIterator; 37 | class ReverseInnerIterator; 38 | 39 | inline Index nonZeros() const { return derived().nestedExpression().nonZeros(); } 40 | }; 41 | 42 | template class TransposeImpl::InnerIterator 43 | : public _MatrixTypeNested::InnerIterator 44 | { 45 | typedef typename _MatrixTypeNested::InnerIterator Base; 46 | public: 47 | 48 | EIGEN_STRONG_INLINE InnerIterator(const TransposeImpl& trans, Index outer) 49 | : Base(trans.derived().nestedExpression(), outer) 50 | {} 51 | inline Index row() const { return Base::col(); } 52 | inline Index col() const { return Base::row(); } 53 | }; 54 | 55 | template class TransposeImpl::ReverseInnerIterator 56 | : public _MatrixTypeNested::ReverseInnerIterator 57 | { 58 | typedef typename _MatrixTypeNested::ReverseInnerIterator Base; 59 | public: 60 | 61 | EIGEN_STRONG_INLINE ReverseInnerIterator(const TransposeImpl& xpr, Index outer) 62 | : Base(xpr.derived().nestedExpression(), outer) 63 | {} 64 | inline Index row() const { return Base::col(); } 65 | inline Index col() const { return Base::row(); } 66 | }; 67 | 68 | #endif // EIGEN_SPARSETRANSPOSE_H 69 | -------------------------------------------------------------------------------- /src/Eigen/src/Sparse/SparseTriangularView.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 | // Eigen is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU Lesser General Public 8 | // License as published by the Free Software Foundation; either 9 | // version 3 of the License, or (at your option) any later version. 10 | // 11 | // Alternatively, you can redistribute it and/or 12 | // modify it under the terms of the GNU General Public License as 13 | // published by the Free Software Foundation; either version 2 of 14 | // the License, or (at your option) any later version. 15 | // 16 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 17 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU Lesser General Public 22 | // License and a copy of the GNU General Public License along with 23 | // Eigen. If not, see . 24 | 25 | #ifndef EIGEN_SPARSE_TRIANGULARVIEW_H 26 | #define EIGEN_SPARSE_TRIANGULARVIEW_H 27 | 28 | namespace internal { 29 | 30 | template 31 | struct traits > 32 | : public traits 33 | {}; 34 | 35 | } // namespace internal 36 | 37 | template class SparseTriangularView 38 | : public SparseMatrixBase > 39 | { 40 | enum { SkipFirst = (Mode==Lower && !(MatrixType::Flags&RowMajorBit)) 41 | || (Mode==Upper && (MatrixType::Flags&RowMajorBit)) }; 42 | public: 43 | 44 | EIGEN_SPARSE_PUBLIC_INTERFACE(SparseTriangularView) 45 | 46 | class InnerIterator; 47 | 48 | inline Index rows() const { return m_matrix.rows(); } 49 | inline Index cols() const { return m_matrix.cols(); } 50 | 51 | typedef typename internal::conditional::ret, 52 | MatrixType, const MatrixType&>::type MatrixTypeNested; 53 | 54 | inline SparseTriangularView(const MatrixType& matrix) : m_matrix(matrix) {} 55 | 56 | /** \internal */ 57 | inline const MatrixType& nestedExpression() const { return m_matrix; } 58 | 59 | template 60 | typename internal::plain_matrix_type_column_major::type 61 | solve(const MatrixBase& other) const; 62 | 63 | template void solveInPlace(MatrixBase& other) const; 64 | template void solveInPlace(SparseMatrixBase& other) const; 65 | 66 | protected: 67 | MatrixTypeNested m_matrix; 68 | }; 69 | 70 | template 71 | class SparseTriangularView::InnerIterator : public MatrixType::InnerIterator 72 | { 73 | typedef typename MatrixType::InnerIterator Base; 74 | public: 75 | 76 | EIGEN_STRONG_INLINE InnerIterator(const SparseTriangularView& view, Index outer) 77 | : Base(view.nestedExpression(), outer) 78 | { 79 | if(SkipFirst) 80 | while((*this) && this->index()index() <= this->outer()); 89 | } 90 | }; 91 | 92 | template 93 | template 94 | inline const SparseTriangularView 95 | SparseMatrixBase::triangularView() const 96 | { 97 | return derived(); 98 | } 99 | 100 | #endif // EIGEN_SPARSE_TRIANGULARVIEW_H 101 | -------------------------------------------------------------------------------- /src/Eigen/src/Sparse/SparseView.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 | // Copyright (C) 2010 Daniel Lowengrub 6 | // 7 | // Eigen is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU Lesser General Public 9 | // License as published by the Free Software Foundation; either 10 | // version 3 of the License, or (at your option) any later version. 11 | // 12 | // Alternatively, you can redistribute it and/or 13 | // modify it under the terms of the GNU General Public License as 14 | // published by the Free Software Foundation; either version 2 of 15 | // the License, or (at your option) any later version. 16 | // 17 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 18 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 19 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 20 | // GNU General Public License for more details. 21 | // 22 | // You should have received a copy of the GNU Lesser General Public 23 | // License and a copy of the GNU General Public License along with 24 | // Eigen. If not, see . 25 | 26 | #ifndef EIGEN_SPARSEVIEW_H 27 | #define EIGEN_SPARSEVIEW_H 28 | 29 | namespace internal { 30 | 31 | template 32 | struct traits > : traits 33 | { 34 | typedef int Index; 35 | typedef Sparse StorageKind; 36 | enum { 37 | Flags = int(traits::Flags) & (RowMajorBit) 38 | }; 39 | }; 40 | 41 | } // end namespace internal 42 | 43 | template 44 | class SparseView : public SparseMatrixBase > 45 | { 46 | typedef typename MatrixType::Nested MatrixTypeNested; 47 | typedef typename internal::remove_all::type _MatrixTypeNested; 48 | public: 49 | EIGEN_SPARSE_PUBLIC_INTERFACE(SparseView) 50 | 51 | SparseView(const MatrixType& mat, const Scalar& m_reference = Scalar(0), 52 | typename NumTraits::Real m_epsilon = NumTraits::dummy_precision()) : 53 | m_matrix(mat), m_reference(m_reference), m_epsilon(m_epsilon) {} 54 | 55 | class InnerIterator; 56 | 57 | inline Index rows() const { return m_matrix.rows(); } 58 | inline Index cols() const { return m_matrix.cols(); } 59 | 60 | inline Index innerSize() const { return m_matrix.innerSize(); } 61 | inline Index outerSize() const { return m_matrix.outerSize(); } 62 | 63 | protected: 64 | const MatrixTypeNested m_matrix; 65 | Scalar m_reference; 66 | typename NumTraits::Real m_epsilon; 67 | }; 68 | 69 | template 70 | class SparseView::InnerIterator : public _MatrixTypeNested::InnerIterator 71 | { 72 | public: 73 | typedef typename _MatrixTypeNested::InnerIterator IterBase; 74 | InnerIterator(const SparseView& view, Index outer) : 75 | IterBase(view.m_matrix, outer), m_view(view) 76 | { 77 | incrementToNonZero(); 78 | } 79 | 80 | EIGEN_STRONG_INLINE InnerIterator& operator++() 81 | { 82 | IterBase::operator++(); 83 | incrementToNonZero(); 84 | return *this; 85 | } 86 | 87 | using IterBase::value; 88 | 89 | protected: 90 | const SparseView& m_view; 91 | 92 | private: 93 | void incrementToNonZero() 94 | { 95 | while(internal::isMuchSmallerThan(value(), m_view.m_reference, m_view.m_epsilon) && (bool(*this))) 96 | { 97 | IterBase::operator++(); 98 | } 99 | } 100 | }; 101 | 102 | template 103 | const SparseView MatrixBase::sparseView(const Scalar& m_reference, 104 | typename NumTraits::Real m_epsilon) const 105 | { 106 | return SparseView(derived(), m_reference, m_epsilon); 107 | } 108 | 109 | #endif 110 | -------------------------------------------------------------------------------- /src/Eigen/src/StlSupport/StdList.h: -------------------------------------------------------------------------------- 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 | // Eigen is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU Lesser General Public 8 | // License as published by the Free Software Foundation; either 9 | // version 3 of the License, or (at your option) any later version. 10 | // 11 | // Alternatively, you can redistribute it and/or 12 | // modify it under the terms of the GNU General Public License as 13 | // published by the Free Software Foundation; either version 2 of 14 | // the License, or (at your option) any later version. 15 | // 16 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 17 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU Lesser General Public 22 | // License and a copy of the GNU General Public License along with 23 | // Eigen. If not, see . 24 | 25 | #ifndef EIGEN_STDLIST_H 26 | #define EIGEN_STDLIST_H 27 | 28 | #include "Eigen/src/StlSupport/details.h" 29 | 30 | // Define the explicit instantiation (e.g. necessary for the Intel compiler) 31 | #if defined(__INTEL_COMPILER) || defined(__GNUC__) 32 | #define EIGEN_EXPLICIT_STL_LIST_INSTANTIATION(...) template class std::list<__VA_ARGS__, EIGEN_ALIGNED_ALLOCATOR<__VA_ARGS__> >; 33 | #else 34 | #define EIGEN_EXPLICIT_STL_LIST_INSTANTIATION(...) 35 | #endif 36 | 37 | /** 38 | * This section contains a convenience MACRO which allows an easy specialization of 39 | * std::list such that for data types with alignment issues the correct allocator 40 | * is used automatically. 41 | */ 42 | #define EIGEN_DEFINE_STL_LIST_SPECIALIZATION(...) \ 43 | EIGEN_EXPLICIT_STL_LIST_INSTANTIATION(__VA_ARGS__) \ 44 | namespace std \ 45 | { \ 46 | template \ 47 | class list<__VA_ARGS__, _Ay> \ 48 | : public list<__VA_ARGS__, EIGEN_ALIGNED_ALLOCATOR<__VA_ARGS__> > \ 49 | { \ 50 | typedef list<__VA_ARGS__, EIGEN_ALIGNED_ALLOCATOR<__VA_ARGS__> > list_base; \ 51 | public: \ 52 | typedef __VA_ARGS__ value_type; \ 53 | typedef typename list_base::allocator_type allocator_type; \ 54 | typedef typename list_base::size_type size_type; \ 55 | typedef typename list_base::iterator iterator; \ 56 | explicit list(const allocator_type& a = allocator_type()) : list_base(a) {} \ 57 | template \ 58 | list(InputIterator first, InputIterator last, const allocator_type& a = allocator_type()) : list_base(first, last, a) {} \ 59 | list(const list& c) : list_base(c) {} \ 60 | explicit list(size_type num, const value_type& val = value_type()) : list_base(num, val) {} \ 61 | list(iterator start, iterator end) : list_base(start, end) {} \ 62 | list& operator=(const list& x) { \ 63 | list_base::operator=(x); \ 64 | return *this; \ 65 | } \ 66 | }; \ 67 | } 68 | 69 | // check whether we really need the std::vector specialization 70 | #if !(defined(_GLIBCXX_VECTOR) && (!EIGEN_GNUC_AT_LEAST(4,1))) /* Note that before gcc-4.1 we already have: std::list::resize(size_type,const T&). */ 71 | 72 | namespace std 73 | { 74 | 75 | #define EIGEN_STD_LIST_SPECIALIZATION_BODY \ 76 | public: \ 77 | typedef T value_type; \ 78 | typedef typename list_base::allocator_type allocator_type; \ 79 | typedef typename list_base::size_type size_type; \ 80 | typedef typename list_base::iterator iterator; \ 81 | typedef typename list_base::const_iterator const_iterator; \ 82 | explicit list(const allocator_type& a = allocator_type()) : list_base(a) {} \ 83 | template \ 84 | list(InputIterator first, InputIterator last, const allocator_type& a = allocator_type()) \ 85 | : list_base(first, last, a) {} \ 86 | list(const list& c) : list_base(c) {} \ 87 | explicit list(size_type num, const value_type& val = value_type()) : list_base(num, val) {} \ 88 | list(iterator start, iterator end) : list_base(start, end) {} \ 89 | list& operator=(const list& x) { \ 90 | list_base::operator=(x); \ 91 | return *this; \ 92 | } 93 | 94 | template 95 | class list > 96 | : public list > 98 | { 99 | typedef list > list_base; 101 | EIGEN_STD_LIST_SPECIALIZATION_BODY 102 | 103 | void resize(size_type new_size) 104 | { resize(new_size, T()); } 105 | 106 | void resize(size_type new_size, const value_type& x) 107 | { 108 | if (list_base::size() < new_size) 109 | list_base::insert(list_base::end(), new_size - list_base::size(), x); 110 | else 111 | while (new_size < list_base::size()) list_base::pop_back(); 112 | } 113 | 114 | #if defined(_LIST_) 115 | // workaround MSVC std::list implementation 116 | void push_back(const value_type& x) 117 | { list_base::push_back(x); } 118 | using list_base::insert; 119 | iterator insert(const_iterator position, const value_type& x) 120 | { return list_base::insert(position,x); } 121 | void insert(const_iterator position, size_type new_size, const value_type& x) 122 | { list_base::insert(position, new_size, x); } 123 | #endif 124 | }; 125 | } 126 | 127 | #endif // check whether specialization is actually required 128 | 129 | #endif // EIGEN_STDLIST_H 130 | -------------------------------------------------------------------------------- /src/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 | // Eigen is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU Lesser General Public 9 | // License as published by the Free Software Foundation; either 10 | // version 3 of the License, or (at your option) any later version. 11 | // 12 | // Alternatively, you can redistribute it and/or 13 | // modify it under the terms of the GNU General Public License as 14 | // published by the Free Software Foundation; either version 2 of 15 | // the License, or (at your option) any later version. 16 | // 17 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 18 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 19 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 20 | // GNU General Public License for more details. 21 | // 22 | // You should have received a copy of the GNU Lesser General Public 23 | // License and a copy of the GNU General Public License along with 24 | // Eigen. If not, see . 25 | 26 | #ifndef EIGEN_STL_DETAILS_H 27 | #define EIGEN_STL_DETAILS_H 28 | 29 | #ifndef EIGEN_ALIGNED_ALLOCATOR 30 | #define EIGEN_ALIGNED_ALLOCATOR Eigen::aligned_allocator 31 | #endif 32 | 33 | namespace Eigen { 34 | 35 | // This one is needed to prevent reimplementing the whole std::vector. 36 | template 37 | class aligned_allocator_indirection : public EIGEN_ALIGNED_ALLOCATOR 38 | { 39 | public: 40 | typedef size_t size_type; 41 | typedef ptrdiff_t difference_type; 42 | typedef T* pointer; 43 | typedef const T* const_pointer; 44 | typedef T& reference; 45 | typedef const T& const_reference; 46 | typedef T value_type; 47 | 48 | template 49 | struct rebind 50 | { 51 | typedef aligned_allocator_indirection other; 52 | }; 53 | 54 | aligned_allocator_indirection() {} 55 | aligned_allocator_indirection(const aligned_allocator_indirection& ) : EIGEN_ALIGNED_ALLOCATOR() {} 56 | aligned_allocator_indirection(const EIGEN_ALIGNED_ALLOCATOR& ) {} 57 | template 58 | aligned_allocator_indirection(const aligned_allocator_indirection& ) {} 59 | template 60 | aligned_allocator_indirection(const EIGEN_ALIGNED_ALLOCATOR& ) {} 61 | ~aligned_allocator_indirection() {} 62 | }; 63 | 64 | #ifdef _MSC_VER 65 | 66 | // sometimes, MSVC detects, at compile time, that the argument x 67 | // in std::vector::resize(size_t s,T x) won't be aligned and generate an error 68 | // even if this function is never called. Whence this little wrapper. 69 | #define EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T) \ 70 | typename Eigen::internal::conditional< \ 71 | Eigen::internal::is_arithmetic::value, \ 72 | T, \ 73 | Eigen::internal::workaround_msvc_stl_support \ 74 | >::type 75 | 76 | namespace internal { 77 | template struct workaround_msvc_stl_support : public T 78 | { 79 | inline workaround_msvc_stl_support() : T() {} 80 | inline workaround_msvc_stl_support(const T& other) : T(other) {} 81 | inline operator T& () { return *static_cast(this); } 82 | inline operator const T& () const { return *static_cast(this); } 83 | template 84 | inline T& operator=(const OtherT& other) 85 | { T::operator=(other); return *this; } 86 | inline workaround_msvc_stl_support& operator=(const workaround_msvc_stl_support& other) 87 | { T::operator=(other); return *this; } 88 | }; 89 | } 90 | 91 | #else 92 | 93 | #define EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T) T 94 | 95 | #endif 96 | 97 | } 98 | 99 | #endif // EIGEN_STL_DETAILS_H 100 | -------------------------------------------------------------------------------- /src/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 | // Eigen is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU Lesser General Public 8 | // License as published by the Free Software Foundation; either 9 | // version 3 of the License, or (at your option) any later version. 10 | // 11 | // Alternatively, you can redistribute it and/or 12 | // modify it under the terms of the GNU General Public License as 13 | // published by the Free Software Foundation; either version 2 of 14 | // the License, or (at your option) any later version. 15 | // 16 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 17 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU Lesser General Public 22 | // License and a copy of the GNU General Public License along with 23 | // Eigen. If not, see . 24 | 25 | #ifndef EIGEN_MISC_IMAGE_H 26 | #define EIGEN_MISC_IMAGE_H 27 | 28 | namespace internal { 29 | 30 | /** \class image_retval_base 31 | * 32 | */ 33 | template 34 | struct traits > 35 | { 36 | typedef typename DecompositionType::MatrixType MatrixType; 37 | typedef Matrix< 38 | typename MatrixType::Scalar, 39 | MatrixType::RowsAtCompileTime, // the image is a subspace of the destination space, whose 40 | // dimension is the number of rows of the original matrix 41 | Dynamic, // we don't know at compile time the dimension of the image (the rank) 42 | MatrixType::Options, 43 | MatrixType::MaxRowsAtCompileTime, // the image matrix will consist of columns from the original matrix, 44 | MatrixType::MaxColsAtCompileTime // so it has the same number of rows and at most as many columns. 45 | > ReturnType; 46 | }; 47 | 48 | template struct image_retval_base 49 | : public ReturnByValue > 50 | { 51 | typedef _DecompositionType DecompositionType; 52 | typedef typename DecompositionType::MatrixType MatrixType; 53 | typedef ReturnByValue Base; 54 | typedef typename Base::Index Index; 55 | 56 | image_retval_base(const DecompositionType& dec, const MatrixType& originalMatrix) 57 | : m_dec(dec), m_rank(dec.rank()), 58 | m_cols(m_rank == 0 ? 1 : m_rank), 59 | m_originalMatrix(originalMatrix) 60 | {} 61 | 62 | inline Index rows() const { return m_dec.rows(); } 63 | inline Index cols() const { return m_cols; } 64 | inline Index rank() const { return m_rank; } 65 | inline const DecompositionType& dec() const { return m_dec; } 66 | inline const MatrixType& originalMatrix() const { return m_originalMatrix; } 67 | 68 | template inline void evalTo(Dest& dst) const 69 | { 70 | static_cast*>(this)->evalTo(dst); 71 | } 72 | 73 | protected: 74 | const DecompositionType& m_dec; 75 | Index m_rank, m_cols; 76 | const MatrixType& m_originalMatrix; 77 | }; 78 | 79 | } // end namespace internal 80 | 81 | #define EIGEN_MAKE_IMAGE_HELPERS(DecompositionType) \ 82 | typedef typename DecompositionType::MatrixType MatrixType; \ 83 | typedef typename MatrixType::Scalar Scalar; \ 84 | typedef typename MatrixType::RealScalar RealScalar; \ 85 | typedef typename MatrixType::Index Index; \ 86 | typedef Eigen::internal::image_retval_base Base; \ 87 | using Base::dec; \ 88 | using Base::originalMatrix; \ 89 | using Base::rank; \ 90 | using Base::rows; \ 91 | using Base::cols; \ 92 | image_retval(const DecompositionType& dec, const MatrixType& originalMatrix) \ 93 | : Base(dec, originalMatrix) {} 94 | 95 | #endif // EIGEN_MISC_IMAGE_H 96 | -------------------------------------------------------------------------------- /src/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 | // Eigen is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU Lesser General Public 8 | // License as published by the Free Software Foundation; either 9 | // version 3 of the License, or (at your option) any later version. 10 | // 11 | // Alternatively, you can redistribute it and/or 12 | // modify it under the terms of the GNU General Public License as 13 | // published by the Free Software Foundation; either version 2 of 14 | // the License, or (at your option) any later version. 15 | // 16 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 17 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU Lesser General Public 22 | // License and a copy of the GNU General Public License along with 23 | // Eigen. If not, see . 24 | 25 | #ifndef EIGEN_MISC_KERNEL_H 26 | #define EIGEN_MISC_KERNEL_H 27 | 28 | namespace internal { 29 | 30 | /** \class kernel_retval_base 31 | * 32 | */ 33 | template 34 | struct traits > 35 | { 36 | typedef typename DecompositionType::MatrixType MatrixType; 37 | typedef Matrix< 38 | typename MatrixType::Scalar, 39 | MatrixType::ColsAtCompileTime, // the number of rows in the "kernel matrix" 40 | // is the number of cols of the original matrix 41 | // so that the product "matrix * kernel = zero" makes sense 42 | Dynamic, // we don't know at compile-time the dimension of the kernel 43 | MatrixType::Options, 44 | MatrixType::MaxColsAtCompileTime, // see explanation for 2nd template parameter 45 | MatrixType::MaxColsAtCompileTime // the kernel is a subspace of the domain space, 46 | // whose dimension is the number of columns of the original matrix 47 | > ReturnType; 48 | }; 49 | 50 | template struct kernel_retval_base 51 | : public ReturnByValue > 52 | { 53 | typedef _DecompositionType DecompositionType; 54 | typedef ReturnByValue Base; 55 | typedef typename Base::Index Index; 56 | 57 | kernel_retval_base(const DecompositionType& dec) 58 | : m_dec(dec), 59 | m_rank(dec.rank()), 60 | m_cols(m_rank==dec.cols() ? 1 : dec.cols() - m_rank) 61 | {} 62 | 63 | inline Index rows() const { return m_dec.cols(); } 64 | inline Index cols() const { return m_cols; } 65 | inline Index rank() const { return m_rank; } 66 | inline const DecompositionType& dec() const { return m_dec; } 67 | 68 | template inline void evalTo(Dest& dst) const 69 | { 70 | static_cast*>(this)->evalTo(dst); 71 | } 72 | 73 | protected: 74 | const DecompositionType& m_dec; 75 | Index m_rank, m_cols; 76 | }; 77 | 78 | } // end namespace internal 79 | 80 | #define EIGEN_MAKE_KERNEL_HELPERS(DecompositionType) \ 81 | typedef typename DecompositionType::MatrixType MatrixType; \ 82 | typedef typename MatrixType::Scalar Scalar; \ 83 | typedef typename MatrixType::RealScalar RealScalar; \ 84 | typedef typename MatrixType::Index Index; \ 85 | typedef Eigen::internal::kernel_retval_base Base; \ 86 | using Base::dec; \ 87 | using Base::rank; \ 88 | using Base::rows; \ 89 | using Base::cols; \ 90 | kernel_retval(const DecompositionType& dec) : Base(dec) {} 91 | 92 | #endif // EIGEN_MISC_KERNEL_H 93 | -------------------------------------------------------------------------------- /src/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 | // Eigen is free software; you can redistribute it and/or 7 | // modify it under the terms of the GNU Lesser General Public 8 | // License as published by the Free Software Foundation; either 9 | // version 3 of the License, or (at your option) any later version. 10 | // 11 | // Alternatively, you can redistribute it and/or 12 | // modify it under the terms of the GNU General Public License as 13 | // published by the Free Software Foundation; either version 2 of 14 | // the License, or (at your option) any later version. 15 | // 16 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 17 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 19 | // GNU General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU Lesser General Public 22 | // License and a copy of the GNU General Public License along with 23 | // Eigen. If not, see . 24 | 25 | #ifndef EIGEN_MISC_SOLVE_H 26 | #define EIGEN_MISC_SOLVE_H 27 | 28 | namespace internal { 29 | 30 | /** \class solve_retval_base 31 | * 32 | */ 33 | template 34 | struct traits > 35 | { 36 | typedef typename DecompositionType::MatrixType MatrixType; 37 | typedef Matrix ReturnType; 43 | }; 44 | 45 | template struct solve_retval_base 46 | : public ReturnByValue > 47 | { 48 | typedef typename remove_all::type RhsNestedCleaned; 49 | typedef _DecompositionType DecompositionType; 50 | typedef ReturnByValue Base; 51 | typedef typename Base::Index Index; 52 | 53 | solve_retval_base(const DecompositionType& dec, const Rhs& rhs) 54 | : m_dec(dec), m_rhs(rhs) 55 | {} 56 | 57 | inline Index rows() const { return m_dec.cols(); } 58 | inline Index cols() const { return m_rhs.cols(); } 59 | inline const DecompositionType& dec() const { return m_dec; } 60 | inline const RhsNestedCleaned& rhs() const { return m_rhs; } 61 | 62 | template inline void evalTo(Dest& dst) const 63 | { 64 | static_cast*>(this)->evalTo(dst); 65 | } 66 | 67 | protected: 68 | const DecompositionType& m_dec; 69 | const typename Rhs::Nested m_rhs; 70 | }; 71 | 72 | } // end namespace internal 73 | 74 | #define EIGEN_MAKE_SOLVE_HELPERS(DecompositionType,Rhs) \ 75 | typedef typename DecompositionType::MatrixType MatrixType; \ 76 | typedef typename MatrixType::Scalar Scalar; \ 77 | typedef typename MatrixType::RealScalar RealScalar; \ 78 | typedef typename MatrixType::Index Index; \ 79 | typedef Eigen::internal::solve_retval_base Base; \ 80 | using Base::dec; \ 81 | using Base::rhs; \ 82 | using Base::rows; \ 83 | using Base::cols; \ 84 | solve_retval(const DecompositionType& dec, const Rhs& rhs) \ 85 | : Base(dec, rhs) {} 86 | 87 | #endif // EIGEN_MISC_SOLVE_H 88 | -------------------------------------------------------------------------------- /src/Eigen/src/plugins/ArrayCwiseBinaryOps.h: -------------------------------------------------------------------------------- 1 | /** \returns an expression of the coefficient wise product of \c *this and \a other 2 | * 3 | * \sa MatrixBase::cwiseProduct 4 | */ 5 | template 6 | EIGEN_STRONG_INLINE const EIGEN_CWISE_PRODUCT_RETURN_TYPE(Derived,OtherDerived) 7 | operator*(const EIGEN_CURRENT_STORAGE_BASE_CLASS &other) const 8 | { 9 | return EIGEN_CWISE_PRODUCT_RETURN_TYPE(Derived,OtherDerived)(derived(), other.derived()); 10 | } 11 | 12 | /** \returns an expression of the coefficient wise quotient of \c *this and \a other 13 | * 14 | * \sa MatrixBase::cwiseQuotient 15 | */ 16 | template 17 | EIGEN_STRONG_INLINE const CwiseBinaryOp, const Derived, const OtherDerived> 18 | operator/(const EIGEN_CURRENT_STORAGE_BASE_CLASS &other) const 19 | { 20 | return CwiseBinaryOp, const Derived, const OtherDerived>(derived(), other.derived()); 21 | } 22 | 23 | /** \returns an expression of the coefficient-wise min of \c *this and \a other 24 | * 25 | * Example: \include Cwise_min.cpp 26 | * Output: \verbinclude Cwise_min.out 27 | * 28 | * \sa max() 29 | */ 30 | EIGEN_MAKE_CWISE_BINARY_OP(min,internal::scalar_min_op) 31 | 32 | /** \returns an expression of the coefficient-wise max of \c *this and \a other 33 | * 34 | * Example: \include Cwise_max.cpp 35 | * Output: \verbinclude Cwise_max.out 36 | * 37 | * \sa min() 38 | */ 39 | EIGEN_MAKE_CWISE_BINARY_OP(max,internal::scalar_max_op) 40 | 41 | /** \returns an expression of the coefficient-wise \< operator of *this and \a other 42 | * 43 | * Example: \include Cwise_less.cpp 44 | * Output: \verbinclude Cwise_less.out 45 | * 46 | * \sa all(), any(), operator>(), operator<=() 47 | */ 48 | EIGEN_MAKE_CWISE_BINARY_OP(operator<,std::less) 49 | 50 | /** \returns an expression of the coefficient-wise \<= operator of *this and \a other 51 | * 52 | * Example: \include Cwise_less_equal.cpp 53 | * Output: \verbinclude Cwise_less_equal.out 54 | * 55 | * \sa all(), any(), operator>=(), operator<() 56 | */ 57 | EIGEN_MAKE_CWISE_BINARY_OP(operator<=,std::less_equal) 58 | 59 | /** \returns an expression of the coefficient-wise \> operator of *this and \a other 60 | * 61 | * Example: \include Cwise_greater.cpp 62 | * Output: \verbinclude Cwise_greater.out 63 | * 64 | * \sa all(), any(), operator>=(), operator<() 65 | */ 66 | EIGEN_MAKE_CWISE_BINARY_OP(operator>,std::greater) 67 | 68 | /** \returns an expression of the coefficient-wise \>= operator of *this and \a other 69 | * 70 | * Example: \include Cwise_greater_equal.cpp 71 | * Output: \verbinclude Cwise_greater_equal.out 72 | * 73 | * \sa all(), any(), operator>(), operator<=() 74 | */ 75 | EIGEN_MAKE_CWISE_BINARY_OP(operator>=,std::greater_equal) 76 | 77 | /** \returns an expression of the coefficient-wise == operator of *this and \a other 78 | * 79 | * \warning this performs an exact comparison, which is generally a bad idea with floating-point types. 80 | * In order to check for equality between two vectors or matrices with floating-point coefficients, it is 81 | * generally a far better idea to use a fuzzy comparison as provided by isApprox() and 82 | * isMuchSmallerThan(). 83 | * 84 | * Example: \include Cwise_equal_equal.cpp 85 | * Output: \verbinclude Cwise_equal_equal.out 86 | * 87 | * \sa all(), any(), isApprox(), isMuchSmallerThan() 88 | */ 89 | EIGEN_MAKE_CWISE_BINARY_OP(operator==,std::equal_to) 90 | 91 | /** \returns an expression of the coefficient-wise != operator of *this and \a other 92 | * 93 | * \warning this performs an exact comparison, which is generally a bad idea with floating-point types. 94 | * In order to check for equality between two vectors or matrices with floating-point coefficients, it is 95 | * generally a far better idea to use a fuzzy comparison as provided by isApprox() and 96 | * isMuchSmallerThan(). 97 | * 98 | * Example: \include Cwise_not_equal.cpp 99 | * Output: \verbinclude Cwise_not_equal.out 100 | * 101 | * \sa all(), any(), isApprox(), isMuchSmallerThan() 102 | */ 103 | EIGEN_MAKE_CWISE_BINARY_OP(operator!=,std::not_equal_to) 104 | 105 | // scalar addition 106 | 107 | /** \returns an expression of \c *this with each coeff incremented by the constant \a scalar 108 | * 109 | * Example: \include Cwise_plus.cpp 110 | * Output: \verbinclude Cwise_plus.out 111 | * 112 | * \sa operator+=(), operator-() 113 | */ 114 | inline const CwiseUnaryOp, const Derived> 115 | operator+(const Scalar& scalar) const 116 | { 117 | return CwiseUnaryOp, const Derived>(derived(), internal::scalar_add_op(scalar)); 118 | } 119 | 120 | friend inline const CwiseUnaryOp, const Derived> 121 | operator+(const Scalar& scalar,const EIGEN_CURRENT_STORAGE_BASE_CLASS& other) 122 | { 123 | return other + scalar; 124 | } 125 | 126 | /** \returns an expression of \c *this with each coeff decremented by the constant \a scalar 127 | * 128 | * Example: \include Cwise_minus.cpp 129 | * Output: \verbinclude Cwise_minus.out 130 | * 131 | * \sa operator+(), operator-=() 132 | */ 133 | inline const CwiseUnaryOp, const Derived> 134 | operator-(const Scalar& scalar) const 135 | { 136 | return *this + (-scalar); 137 | } 138 | 139 | friend inline const CwiseUnaryOp, const CwiseUnaryOp, const Derived> > 140 | operator-(const Scalar& scalar,const EIGEN_CURRENT_STORAGE_BASE_CLASS& other) 141 | { 142 | return (-other) + scalar; 143 | } 144 | -------------------------------------------------------------------------------- /src/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 | // Eigen is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU Lesser General Public 9 | // License as published by the Free Software Foundation; either 10 | // version 3 of the License, or (at your option) any later version. 11 | // 12 | // Alternatively, you can redistribute it and/or 13 | // modify it under the terms of the GNU General Public License as 14 | // published by the Free Software Foundation; either version 2 of 15 | // the License, or (at your option) any later version. 16 | // 17 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 18 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 19 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 20 | // GNU General Public License for more details. 21 | // 22 | // You should have received a copy of the GNU Lesser General Public 23 | // License and a copy of the GNU General Public License along with 24 | // Eigen. If not, see . 25 | 26 | // This file is a base class plugin containing common coefficient wise functions. 27 | 28 | /** \returns an expression of the difference of \c *this and \a other 29 | * 30 | * \note If you want to substract a given scalar from all coefficients, see Cwise::operator-(). 31 | * 32 | * \sa class CwiseBinaryOp, operator-=() 33 | */ 34 | EIGEN_MAKE_CWISE_BINARY_OP(operator-,internal::scalar_difference_op) 35 | 36 | /** \returns an expression of the sum of \c *this and \a other 37 | * 38 | * \note If you want to add a given scalar to all coefficients, see Cwise::operator+(). 39 | * 40 | * \sa class CwiseBinaryOp, operator+=() 41 | */ 42 | EIGEN_MAKE_CWISE_BINARY_OP(operator+,internal::scalar_sum_op) 43 | 44 | /** \returns an expression of a custom coefficient-wise operator \a func of *this and \a other 45 | * 46 | * The template parameter \a CustomBinaryOp is the type of the functor 47 | * of the custom operator (see class CwiseBinaryOp for an example) 48 | * 49 | * Here is an example illustrating the use of custom functors: 50 | * \include class_CwiseBinaryOp.cpp 51 | * Output: \verbinclude class_CwiseBinaryOp.out 52 | * 53 | * \sa class CwiseBinaryOp, operator+(), operator-(), cwiseProduct() 54 | */ 55 | template 56 | EIGEN_STRONG_INLINE const CwiseBinaryOp 57 | binaryExpr(const EIGEN_CURRENT_STORAGE_BASE_CLASS &other, const CustomBinaryOp& func = CustomBinaryOp()) const 58 | { 59 | return CwiseBinaryOp(derived(), other.derived(), func); 60 | } 61 | 62 | -------------------------------------------------------------------------------- /src/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 | // Eigen is free software; you can redistribute it and/or 8 | // modify it under the terms of the GNU Lesser General Public 9 | // License as published by the Free Software Foundation; either 10 | // version 3 of the License, or (at your option) any later version. 11 | // 12 | // Alternatively, you can redistribute it and/or 13 | // modify it under the terms of the GNU General Public License as 14 | // published by the Free Software Foundation; either version 2 of 15 | // the License, or (at your option) any later version. 16 | // 17 | // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 18 | // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 19 | // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 20 | // GNU General Public License for more details. 21 | // 22 | // You should have received a copy of the GNU Lesser General Public 23 | // License and a copy of the GNU General Public License along with 24 | // Eigen. If not, see . 25 | 26 | // This file is a base class plugin containing matrix specifics coefficient wise functions. 27 | 28 | /** \returns an expression of the coefficient-wise absolute value of \c *this 29 | * 30 | * Example: \include MatrixBase_cwiseAbs.cpp 31 | * Output: \verbinclude MatrixBase_cwiseAbs.out 32 | * 33 | * \sa cwiseAbs2() 34 | */ 35 | EIGEN_STRONG_INLINE const CwiseUnaryOp, const Derived> 36 | cwiseAbs() const { return derived(); } 37 | 38 | /** \returns an expression of the coefficient-wise squared absolute value of \c *this 39 | * 40 | * Example: \include MatrixBase_cwiseAbs2.cpp 41 | * Output: \verbinclude MatrixBase_cwiseAbs2.out 42 | * 43 | * \sa cwiseAbs() 44 | */ 45 | EIGEN_STRONG_INLINE const CwiseUnaryOp, const Derived> 46 | cwiseAbs2() const { return derived(); } 47 | 48 | /** \returns an expression of the coefficient-wise square root of *this. 49 | * 50 | * Example: \include MatrixBase_cwiseSqrt.cpp 51 | * Output: \verbinclude MatrixBase_cwiseSqrt.out 52 | * 53 | * \sa cwisePow(), cwiseSquare() 54 | */ 55 | inline const CwiseUnaryOp, const Derived> 56 | cwiseSqrt() const { return derived(); } 57 | 58 | /** \returns an expression of the coefficient-wise inverse of *this. 59 | * 60 | * Example: \include MatrixBase_cwiseInverse.cpp 61 | * Output: \verbinclude MatrixBase_cwiseInverse.out 62 | * 63 | * \sa cwiseProduct() 64 | */ 65 | inline const CwiseUnaryOp, const Derived> 66 | cwiseInverse() const { return derived(); } 67 | 68 | /** \returns an expression of the coefficient-wise == operator of \c *this and a scalar \a s 69 | * 70 | * \warning this performs an exact comparison, which is generally a bad idea with floating-point types. 71 | * In order to check for equality between two vectors or matrices with floating-point coefficients, it is 72 | * generally a far better idea to use a fuzzy comparison as provided by isApprox() and 73 | * isMuchSmallerThan(). 74 | * 75 | * \sa cwiseEqual(const MatrixBase &) const 76 | */ 77 | inline const CwiseUnaryOp >, const Derived> 78 | cwiseEqual(const Scalar& s) const 79 | { 80 | return CwiseUnaryOp >,const Derived> 81 | (derived(), std::bind1st(std::equal_to(), s)); 82 | } 83 | -------------------------------------------------------------------------------- /src/LinearRegression.h: -------------------------------------------------------------------------------- 1 | #ifndef LINEAR_REGRESSION_H 2 | #define LINEAR_REGRESSION_H 3 | 4 | #include 5 | //-- 6 | #include "Eigen/Eigen" 7 | #include "Eigen/Dense" 8 | //-- 9 | #define ei_assert assert 10 | #define EIGEN2_SUPPORT 11 | #include "Eigen/LeastSquares" 12 | 13 | /** 14 | * Helper functions for fitting a line to a set of points in 15 | * R^2. 16 | */ 17 | namespace LinearRegression{ 18 | 19 | template 20 | struct Line{ 21 | T m,b; //Slope and y intercept, respectively 22 | 23 | /** 24 | * Get the y-value of the line at a specific point. 25 | * @param x is the x value. Returns f(x) = mx + b 26 | */ 27 | inline T operator()(const T x)const{ return m * x + b; } 28 | 29 | /// \brief Parameterized constructor. 30 | Line(T myM = (T)1.0, T myB = (T)0.0) : 31 | m(myM), b(myB) {} 32 | 33 | /// \brief Overloaded stream insertion operator 34 | friend std::ostream& operator<<(std::ostream& os, const Line& line){ 35 | os << "y = " << line.m << "x + " << line.b; 36 | return os; 37 | } 38 | 39 | }; 40 | 41 | 42 | /** 43 | * Fit a line to a set of points. Optinally return the residual. 44 | * 45 | * @param N is the number of points. Must be >= 2. 46 | * @param dataPoints is a pointer to a vector of points in R^2. 47 | * @param residual returns the residual error. If NULL this is ignored. Defaults to NULL. 48 | */ 49 | template 50 | struct Line linearRegression( 51 | int N, 52 | const Eigen::Matrix* dataPoints, 53 | T* residual = NULL) 54 | { 55 | assert(N >= 2); 56 | assert(dataPoints != NULL); 57 | assert(dataPoints->rows() >= N); 58 | 59 | Line retLine; //Declare line to return 60 | 61 | //Compute parameters of the line 62 | //TODO: Delete unnedded vars 63 | T xBar, yBar, xSum, ySum, xySum, xSqSum; 64 | xBar = yBar = xSum = ySum = xySum = xSqSum = static_cast(0.0); 65 | const T invNf = static_cast(1.0) / static_cast(N); 66 | const T Nf = static_cast(N); 67 | for(int i = 0; i < N; i++){ 68 | const T x = (*dataPoints)(i,0); 69 | const T y = (*dataPoints)(i,1); 70 | xSum += x; 71 | ySum += y; 72 | xySum += x*y; 73 | xSqSum += x*x; 74 | } 75 | xBar = xSum * invNf; 76 | yBar = ySum * invNf; 77 | 78 | const T m = (Nf * xySum - (xSum * ySum)) / (Nf * xSqSum - (xSum * xSum)); 79 | const T b = invNf * (ySum - m*xSum); 80 | 81 | retLine.m = m; 82 | retLine.b = b; 83 | 84 | //potentially compute ressidual 85 | if(residual != NULL){ 86 | *residual = (T)(0.0); 87 | for(int i = 0; i < N; i++){ 88 | const T lineVal = retLine( (*dataPoints)(i,0) ); 89 | const T goalVal = (*dataPoints)(i,1); 90 | *residual += 91 | (goalVal - lineVal) * (goalVal - lineVal); 92 | } 93 | } 94 | 95 | return retLine; 96 | } 97 | } 98 | 99 | 100 | #endif //LINEAR_REGRESSION_H 101 | -------------------------------------------------------------------------------- /src/WeightingFunctions.cpp: -------------------------------------------------------------------------------- 1 | #include "WeightingFunctions.h" 2 | 3 | void WeightingFunctions::makeLUTHat(CTF::ctf_t* lut, unsigned char lower, unsigned char upper){ 4 | assert(lut != NULL); 5 | for(int pixVal = 0; pixVal < 256; pixVal++){ 6 | lut[pixVal] = WeightingFunctions::hat(static_cast(pixVal), lower, upper); 7 | } 8 | } 9 | 10 | -------------------------------------------------------------------------------- /src/WeightingFunctions.h: -------------------------------------------------------------------------------- 1 | #ifndef WEIGHTING_FUNCTIONS_H 2 | #define WEIGHTING_FUNCTIONS_H 3 | 4 | #include 5 | #include 6 | #include 7 | //-- 8 | #include "CTF.h" 9 | 10 | /** 11 | * Weight functions for 8 bit pixel values. 12 | * Includes the hat function in Debevec and Malik 1997, plus 13 | * additional functions. Includes the ability to sample a weighting function 14 | * into a LUT for fast evaluations. 15 | */ 16 | namespace WeightingFunctions{ 17 | 18 | //Hat function 19 | //with default parameters, becomes the hat function in the debevec and Malik paper 20 | CTF::ctf_t hat(unsigned char value, unsigned char lower = 0, unsigned char upper = 255); 21 | void makeLUTHat(CTF::ctf_t* lut, unsigned char lower = 0, unsigned char upper = 255); 22 | } 23 | 24 | 25 | //All weight functions are inlined--------------------------------------------- 26 | 27 | inline CTF::ctf_t WeightingFunctions::hat(unsigned char value, unsigned char lower, unsigned char upper){ 28 | assert(pow(2,sizeof(unsigned char) * CHAR_BIT) == 256); //sanity check for 8-bit uchars 29 | assert(lower < upper); //Make sure hat bounds are correct 30 | 31 | const CTF::ctf_t z = static_cast(value); 32 | const CTF::ctf_t Z_MIN = static_cast(lower); 33 | const CTF::ctf_t Z_MAX = static_cast(upper); 34 | return 35 | (z <= Z_MIN || z >= Z_MAX) ? 0 : 36 | ((z <= (Z_MIN + Z_MAX)/static_cast(2.0)) ? (z - Z_MIN) : 37 | (Z_MAX - z)); 38 | } 39 | 40 | 41 | 42 | 43 | 44 | #endif //WEIGHTING_FUNCTIONS_H 45 | --------------------------------------------------------------------------------